Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ int TerrainTextureClass::update(WorldHeightMap *htMap)
Int i,j;
for (j=0; j<tilePixelExtent; j++) {
UnsignedByte *pBGR = pTile->getRGBDataForWidth(tilePixelExtent);
// Check if getRGBDataForWidth returned NULL (e.g., corrupted tile data)
if (!pBGR) continue;
pBGR += (tilePixelExtent-1-j)*TILE_BYTES_PER_PIXEL*tilePixelExtent; // invert to match.
Int row = position.y+j;
UnsignedByte *pBGRX = ((UnsignedByte*)locked_rect.pBits) +
Expand Down Expand Up @@ -414,6 +416,8 @@ int TerrainTextureClass::update256(WorldHeightMap *htMap)
Int i,j;
for (j=0; j<tilePixelExtent; j++) {
UnsignedByte *pBGR = htMap->getSourceTile(tileNdx)->getRGBDataForWidth(tilePixelExtent);
// Check if getRGBDataForWidth returned NULL (e.g., corrupted tile data)
if (!pBGR) continue;
pBGR += (tilePixelExtent-1-j)*TILE_BYTES_PER_PIXEL*tilePixelExtent; // invert to match.
Int row = cellY*tilePixelExtent+j;
row += tileOffset/2;
Expand Down Expand Up @@ -880,6 +884,8 @@ int AlphaEdgeTextureClass::update(WorldHeightMap *htMap)
for (j=0; j<tilePixelExtent; j++) {
Int row = position.y+j;
UnsignedByte *pBGR = htMap->getEdgeTile(tileNdx)->getRGBDataForWidth(tilePixelExtent);
// Check if getRGBDataForWidth returned NULL (e.g., corrupted tile data)
if (!pBGR) continue;
pBGR += (tilePixelExtent-1-j)*TILE_BYTES_PER_PIXEL*tilePixelExtent; // invert to match.
UnsignedByte *pBGRX = ((UnsignedByte*)locked_rect.pBits) +
(row)*surface_desc.Width*pixelBytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,14 @@ void WorldHeightMap::readTexClass(TXTextureClass *texClass, TileData **tileData)
WorldHeightMap::readTiles(pStr, tileData+texClass->firstTile, width);
}
theFile->close();
} else {
// Failed to open texture file - ensure all tiles for this class are NULL
// to prevent crashes when rendering tries to use uninitialized data
for (Int i = 0; i < texClass->numTiles; i++) {
if (tileData[texClass->firstTile + i] == NULL) {
tileData[texClass->firstTile + i] = NULL; // Explicitly set to NULL
}
}
}
}

Expand Down