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
6 changes: 2 additions & 4 deletions Generals/Code/Tools/WorldBuilder/include/WHeightMapEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class WorldHeightMapEdit : public WorldHeightMap
void showTileStatusInfo(); ///< pops up a dialog box with tile mem usage.


Bool selectDuplicates(); ///< Selects any dupicate map objects.
Bool selectSimilar(); ///< Selects any dupicate map objects.
Bool selectDuplicates(); ///< Selects any duplicate map objects.
Bool selectSimilar(); ///< Selects any duplicate map objects.
Bool selectInvalidTeam(); ///< Selects any objects with invalid teams.

Bool resize(Int newXSize, Int newYSize, Int newHeight, Int newBorder, Bool anchorTop, Bool anchorBottom,
Expand All @@ -147,8 +147,6 @@ class WorldHeightMapEdit : public WorldHeightMap
void reloadTextures(); ///< Reloads textures from disk.
void resetResources(); ///< Releases textures in preparation for device reset.

Bool getRawTileData(Short tileNdx, Int width, UnsignedByte *buffer, Int bufLen);

void dbgVerifyAfterUndo(); ///< Verifies the structures are still consistent.
Bool doCliffAdjustment(Int xIndex, Int yIndex);
Bool removeCliffMapping();
Expand Down
20 changes: 17 additions & 3 deletions Generals/Code/Tools/WorldBuilder/src/BorderTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void BorderTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorld
return;
}

static Coord3D zero = {0.0f, 0.0f, 0.0f};
//static Coord3D zero = {0.0f, 0.0f, 0.0f};

Coord3D groundPt;
pView->viewToDocCoords(viewPt, &groundPt);
Expand All @@ -138,10 +138,24 @@ void BorderTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorld

Int motion;
pDoc->findBoundaryNear(&groundPt, BOUNDARY_PICK_DISTANCE, &m_modifyBorderNdx, &motion);
if (motion == 0) {

// if bottom left boundary grabbed
if (motion == 0)
{
// modifying the bottom left is not allowed.
m_modifyBorderNdx = -1;
} else {
}
// else if no boundary is near
else if (motion == -1)
{
// add a boundary
m_addingNewBorder = true;

ICoord2D initialBoundary = { 1, 1 };
pDoc->addBoundary(&initialBoundary);
}
else
{
m_modificationType = (ModificationType) motion;
}
}
Expand Down
76 changes: 32 additions & 44 deletions Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include "Common/DataChunk.h"


int WorldHeightMapEdit::m_numGlobalTextureClasses=0;
TGlobalTextureClass WorldHeightMapEdit::m_globalTextureClasses[NUM_TEXTURE_CLASSES];
/** Destructor -.
Expand Down Expand Up @@ -120,7 +121,7 @@ WorldHeightMapEdit::WorldHeightMapEdit(Int width, Int height, UnsignedByte initi
// Note - we have one less cell than the width & height. But for paranoia, allocate
// extra row. jba.
//
Int numBytesX = (m_width+1)/8; //how many bytes to fit all bitflags
Int numBytesX = (m_width+7)/8; //how many bytes to fit all bitflags
Int numBytesY = m_height;

m_flipStateWidth=numBytesX;
Expand Down Expand Up @@ -209,7 +210,7 @@ m_warnTooManyBlend(false)
// Note - we have one less cell than the width & height. But for paranoia, allocate
// extra row. jba.
//
Int numBytesX = (m_width+1)/8; //how many bytes to fit all bitflags
Int numBytesX = (m_width+7)/8; //how many bytes to fit all bitflags
Int numBytesY = m_height;

m_flipStateWidth=numBytesX;
Expand Down Expand Up @@ -433,8 +434,7 @@ void WorldHeightMapEdit::loadDirectoryOfImages(const char *pFilePath)
FilenameList::iterator it = filenameList.begin();
do {
AsciiString filename = *it;

snprintf(fileBuf, ARRAY_SIZE(fileBuf), "%s%s", dirBuf, filename.str());
strlcpy(fileBuf, filename.str(), ARRAY_SIZE(fileBuf));
loadBitmap(fileBuf, filename.str());

++it;
Expand Down Expand Up @@ -506,39 +506,6 @@ void WorldHeightMapEdit::loadImagesFromTerrainType( TerrainType *terrain )

}


Bool WorldHeightMapEdit::getRawTileData(Short tileNdx, Int width,
UnsignedByte *buffer, Int bufLen)
{
TileData *pSrc = nullptr;
if (tileNdx/4 < NUM_SOURCE_TILES) {
pSrc = m_sourceTiles[tileNdx/4];
}
if (bufLen < (width*width*TILE_BYTES_PER_PIXEL)) {
return(false);
}
if (pSrc && pSrc->hasRGBDataForWidth(2*width)) {
Int j;
UnsignedByte *pSrcData = pSrc->getRGBDataForWidth(2*width);
Int xOffset=0;
Int yOffset=0;
if (tileNdx & 1) xOffset = width;
if (tileNdx & 2) yOffset = width;
for (j=0; j<width; j++) {
UnsignedByte *pDestData = buffer;
pDestData += j*(width)*TILE_BYTES_PER_PIXEL;
UnsignedByte *pSrc = pSrcData;
pSrc += (j+yOffset)*width*TILE_BYTES_PER_PIXEL*2;
pSrc += xOffset*TILE_BYTES_PER_PIXEL;
memcpy(pDestData, pSrc, width*TILE_BYTES_PER_PIXEL);
}
return(true);
}
return(false);
}



UnsignedByte * WorldHeightMapEdit::getPointerToClassTileData(Int texClass)
{
TileData *pSrc = nullptr;
Expand Down Expand Up @@ -633,13 +600,26 @@ void WorldHeightMapEdit::saveToFile(DataChunkOutput &chunkWriter)
chunkWriter.closeDataChunk();

/***************BLEND TILE DATA ***************/
chunkWriter.openDataChunk("BlendTileData", K_BLEND_TILE_VERSION_7);
#if RTS_GENERALS && RETAIL_COMPATIBLE_DATA
const DataChunkVersionType blendTileVersion = K_BLEND_TILE_VERSION_7;
#else
const DataChunkVersionType blendTileVersion = K_BLEND_TILE_VERSION_8;
#endif
chunkWriter.openDataChunk("BlendTileData", blendTileVersion);
chunkWriter.writeInt(m_dataSize);
chunkWriter.writeArrayOfBytes((char*)m_tileNdxes, m_dataSize*sizeof(Short));
chunkWriter.writeArrayOfBytes((char*)m_blendTileNdxes, m_dataSize*sizeof(Short));
chunkWriter.writeArrayOfBytes((char*)m_extraBlendTileNdxes, m_dataSize*sizeof(Short));
chunkWriter.writeArrayOfBytes((char*)m_cliffInfoNdxes, m_dataSize*sizeof(Short));
chunkWriter.writeArrayOfBytes((char*)m_cellCliffState, m_height*m_flipStateWidth);
if (blendTileVersion <= K_BLEND_TILE_VERSION_7) {
// Version 7 uses the legacy row width, even when the in-memory rows are wider.
Int byteWidth = (m_width+1)/8;
for (Int j=0; j<m_height; j++) {
chunkWriter.writeArrayOfBytes((char*)m_cellCliffState + j*m_flipStateWidth, byteWidth);
}
} else {
chunkWriter.writeArrayOfBytes((char*)m_cellCliffState, m_height*m_flipStateWidth);
}
chunkWriter.writeInt(m_numBitmapTiles);
chunkWriter.writeInt(m_numBlendedTiles);
chunkWriter.writeInt(m_numCliffInfo);
Expand Down Expand Up @@ -1133,7 +1113,7 @@ void WorldHeightMapEdit::blendSpecificTiles(Int xIndex, Int yIndex, Int srcXInde
blendInfo.customBlendEdgeClass = edgeClass;

//Check if there is already a blend tile at the destination and record its flip state.
//We need to know this so that we don't accidentally apply a third blend layer with with
//We need to know this so that we don't accidentally apply a third blend layer with
//a different flip and introduce z-fighting over this tile.
Bool baseNeedsFlip = false;
UnsignedByte baseIsDiagonal = 0;
Expand Down Expand Up @@ -1207,7 +1187,13 @@ void WorldHeightMapEdit::blendSpecificTiles(Int xIndex, Int yIndex, Int srcXInde
//force the primary layer to flip if the extra blend layer needs flip.
//we only do this on vertical/horizontal base blends because they work in either flip cases.
if (flipped && !baseIsDiagonal)
m_blendedTiles[m_blendTileNdxes[ndx]].inverted |= FLIPPED_MASK;
{
//Find a new tile so as not to affect other cells using the base one.
TBlendTileInfo tempBlendTileInfo=m_blendedTiles[m_blendTileNdxes[ndx]];
tempBlendTileInfo.inverted |= FLIPPED_MASK;
Short newNdx = findOrCreateBlendTile(&tempBlendTileInfo);
m_blendTileNdxes[ndx] = newNdx; //remap this tile to use a new one.
Comment on lines +1194 to +1195

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

ast-grep outline Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp \
  --match findOrCreateBlendTile --view expanded
ast-grep run --lang cpp \
  --pattern 'Int WorldHeightMapEdit::findOrCreateBlendTile(TBlendTileInfo *$INFO) { $$$BODY }' \
  Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 306


🏁 Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- helper ---'
sed -n '1040,1115p' Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
printf '%s\n' '--- changed blend block ---'
sed -n '1145,1215p' Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
printf '%s\n' '--- consumers ---'
rg -n -C 5 'm_blendTileNdxes|autoBlendOut|optimizeTiles' Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
printf '%s\n' '--- requested diff ---'
git diff --unified=35 e70f26db9f0dec4e23f2443921b5341e04958a5f 41e4e15b934fd0d37a60f3bb82c80a161349e1d0 -- Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 41942


🏁 Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- autoBlendOut relevant range ---'
sed -n '1210,1360p' Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
printf '%s\n' '--- optimizeTiles relevant range ---'
sed -n '1660,1765p' Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 8401


Handle failure before replacing the primary blend index.

findOrCreateBlendTile can return -1 when the blend table is full. The second allocation stores that value in m_blendTileNdxes[ndx] without a check. optimizeTiles and later blend operations can then use -1 as an array index.

Allocate the flipped description before committing the cell indices. If it fails, preserve the previous cell state.

Suggested fix
 	if (newNdx >= 0) {
 		Int ndx = (yIndex*m_width)+xIndex;
-		m_tileNdxes[ndx] = curTileNdx;
-		if (TheGlobalData->m_use3WayTerrainBlends && m_blendTileNdxes[ndx] != 0)
+		Bool hasBaseBlend = TheGlobalData->m_use3WayTerrainBlends &&
+			m_blendTileNdxes[ndx] != 0;
+		Short primaryNdx = hasBaseBlend ? m_blendTileNdxes[ndx] : newNdx;
+		if (hasBaseBlend)
 		{
 			//this tile already has a blend applied to it.  So we put the new blend into the
 			//secondary layer.
-			m_extraBlendTileNdxes[ndx]=newNdx;
 			//force the primary layer to flip if the extra blend layer needs flip.
 			//we only do this on vertical/horizontal base blends because they work in either flip cases.
 			if (flipped && !baseIsDiagonal)
 			{
 				//Find a new tile so as not to affect other cells using the base one.
 				TBlendTileInfo tempBlendTileInfo=m_blendedTiles[m_blendTileNdxes[ndx]];
 				tempBlendTileInfo.inverted |= FLIPPED_MASK;
-				Short newNdx = findOrCreateBlendTile(&tempBlendTileInfo);
-				m_blendTileNdxes[ndx] = newNdx;	//remap this tile to use a new one.
+				Short flippedNdx = findOrCreateBlendTile(&tempBlendTileInfo);
+				if (flippedNdx < 0)
+					return;
+				primaryNdx = flippedNdx;
 			}
-		}
-		else
-			m_blendTileNdxes[ndx] = newNdx;
+		}
+		m_tileNdxes[ndx] = curTileNdx;
+		if (hasBaseBlend)
+			m_extraBlendTileNdxes[ndx] = newNdx;
+		m_blendTileNdxes[ndx] = primaryNdx;
 	}

}
}
else
m_blendTileNdxes[ndx] = newNdx;
Expand Down Expand Up @@ -1895,7 +1881,7 @@ Bool WorldHeightMapEdit::resize(Int newXSize, Int newYSize, Int newHeight, Int n
m_dataSize = newDataSize;
delete(m_cellCliffState);
delete(m_cellFlipState);
Int numBytesX = (m_width+1)/8; //how many bytes to fit all bitflags
Int numBytesX = (m_width+7)/8; //how many bytes to fit all bitflags
m_flipStateWidth=numBytesX;

m_cellFlipState = MSGNEW("WorldHeightMapEdit::resize") UnsignedByte[numBytesX*m_height];
Expand Down Expand Up @@ -3454,6 +3440,8 @@ void WorldHeightMapEdit::findBoundaryNear(Coord3D *pt, float okDistance, Int *ou
}

(*outNdx) = -1;
// TheSuperHackers @bugfix Handle an omitted boundary handle on the no-match path.
if (outHandle) {
(*outHandle) = -1;
}
}


22 changes: 19 additions & 3 deletions GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,26 @@ void WorldHeightMapEdit::saveToFile(DataChunkOutput &chunkWriter)
chunkWriter.closeDataChunk();

/***************BLEND TILE DATA ***************/
chunkWriter.openDataChunk("BlendTileData", K_BLEND_TILE_VERSION_8);
#if RTS_GENERALS && RETAIL_COMPATIBLE_DATA
const DataChunkVersionType blendTileVersion = K_BLEND_TILE_VERSION_7;
#else
const DataChunkVersionType blendTileVersion = K_BLEND_TILE_VERSION_8;
#endif
chunkWriter.openDataChunk("BlendTileData", blendTileVersion);
chunkWriter.writeInt(m_dataSize);
chunkWriter.writeArrayOfBytes((char*)m_tileNdxes, m_dataSize*sizeof(Short));
chunkWriter.writeArrayOfBytes((char*)m_blendTileNdxes, m_dataSize*sizeof(Short));
chunkWriter.writeArrayOfBytes((char*)m_extraBlendTileNdxes, m_dataSize*sizeof(Short));
chunkWriter.writeArrayOfBytes((char*)m_cliffInfoNdxes, m_dataSize*sizeof(Short));
chunkWriter.writeArrayOfBytes((char*)m_cellCliffState, m_height*m_flipStateWidth);
if (blendTileVersion <= K_BLEND_TILE_VERSION_7) {
// Version 7 uses the legacy row width, even when the in-memory rows are wider.
Int byteWidth = (m_width+1)/8;
for (Int j=0; j<m_height; j++) {
chunkWriter.writeArrayOfBytes((char*)m_cellCliffState + j*m_flipStateWidth, byteWidth);
Comment on lines +614 to +618

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n 'setWidth|setDimensions|m_width[[:space:]]*=|mapWidth|heightMapWidth|resize|newMap|createMap|RETAIL_COMPATIBLE_DATA' Core/Tools/WorldBuilder Core/GameEngineDevice/Source/W3DDevice Generals/Code/Tools/WorldBuilder
rg -n 'width.*(multiple|%|/|64|128)|m_width.*(8|16|32|64|128)' Core/Tools/WorldBuilder Core/GameEngineDevice/Source/W3DDevice/GameClient

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 26448


🏁 Script executed:

set -e
printf '%s\n' '--- WHeightMapEdit declarations and construction ---'
sed -n '80,235p' Core/Tools/WorldBuilder/src/WHeightMapEdit.cpp
sed -n '110,175p' Core/Tools/WorldBuilder/include/WHeightMapEdit.h
printf '%s\n' '--- resize implementation ---'
sed -n '1760,1910p' Core/Tools/WorldBuilder/src/WHeightMapEdit.cpp
printf '%s\n' '--- WorldBuilderDoc map creation/loading entrypoints ---'
sed -n '960,1070p' Core/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
rg -n -C 5 'new WorldHeightMapEdit|WorldHeightMapEdit\(|resize\(|initialHeight|xExtent|yExtent|borderWidth' Core/Tools/WorldBuilder/src Core/Tools/WorldBuilder/include
printf '%s\n' '--- dimension validation and format readers ---'
rg -n -C 6 'xSize|ySize|xExtent|yExtent|width.*8|width.*64|MAP_SIZE|map size|MapSize|newWidth|newHeight' Core/Tools/WorldBuilder/src Core/Tools/WorldBuilder/include Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 11905


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- WorldBuilder document creation/loading and resize callers ---'
rg -n -C 8 'WorldHeightMapEdit|resize\(|xExtent|yExtent|initialHeight|borderWidth|NewHeightMap|load' Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp Generals/Code/Tools/WorldBuilder/src Generals/Code/Tools/WorldBuilder/include
printf '%s\n' '--- NewHeightMap declarations and implementation ---'
fd -i 'NewHeightMap' Generals/Code/Tools/WorldBuilder
printf '%s\n' '--- WorldHeightMap loading dimension handling ---'
sed -n '820,985p' Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
sed -n '1025,1090p' Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
printf '%s\n' '--- all dimension-related guards in relevant WorldBuilder files ---'
rg -n -C 4 'BAD_VALUE|<= *0|< *0|% *8|/ *8|multiple|extent|size' Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp Generals/Code/Tools/WorldBuilder/src Generals/Code/Tools/WorldBuilder/include Core/Tools/WorldBuilder/src/WHeightMapEdit.cpp Core/Tools/WorldBuilder/include/WHeightMapEdit.h

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 45686


🏁 Script executed:

set -e
printf '%s\n' '--- NewHeightMap files ---'
fd -i 'NewHeightMap' Generals/Code/Tools/WorldBuilder Core/Tools/WorldBuilder
printf '%s\n' '--- NewHeightMap validation ---'
rg -n -C 10 'OnInitDialog|OnOK|DDX|xExtent|yExtent|borderWidth|forResize|SetLimitText|GetDlgItem|BAD_VALUE|<=|< *0|% *8|/ *8' Generals/Code/Tools/WorldBuilder/src/NewHeightMap.cpp Generals/Code/Tools/WorldBuilder/include/NewHeightMap.h Core/Tools/WorldBuilder/src/NewHeightMap.cpp Core/Tools/WorldBuilder/include/NewHeightMap.h 2>/dev/null || true
printf '%s\n' '--- WorldHeightMap constructors and readers ---'
rg -n -C 10 'WorldHeightMap::WorldHeightMap|readInt\(\)|K_BLEND_TILE_VERSION|numBytesX|byteWidth|m_width|m_height' Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp Core/GameEngineDevice/Include/W3DDevice/GameClient/WorldHeightMap.h

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 41736


🏁 Script executed:

set -e
printf '%s\n' '--- save function and changed hunk ---'
sed -n '560,635p' Core/Tools/WorldBuilder/src/WHeightMapEdit.cpp
rg -n -C 10 'saveToFile\(|SaveMap|OnSaveDocument|OnFileSave|write.*height|heightMap.*save' Core/Tools/WorldBuilder/src/WHeightMapEdit.cpp Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp Generals/Code/Tools/WorldBuilder/include/SaveMap.h 2>/dev/null || true
printf '%s\n' '--- exact parsing and flag readers ---'
rg -n -C 12 'ParseHeightMapData|ParseSizeOnly|m_dataSize.*m_width|byteWidth|numBytesX' Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 41363


🏁 Script executed:

set -e
sed -n '250,320p' Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
sed -n '780,855p' Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
rg -n -C 6 'throw ERROR|ERROR_CORRUPT_FILE_FORMAT|height map file write failed|saveToFile' Core/Tools/WorldBuilder/src Generals/Code/Tools/WorldBuilder/src

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 12421


🏁 Script executed:

set -e
rg -n -C 12 'setCliffState|m_cellCliffState\[|setCellCliffFlagFromHeights|initCliffFlagsFromHeights' Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp Core/GameEngineDevice/Include/W3DDevice/GameClient/WorldHeightMap.h Core/Tools/WorldBuilder/src/WHeightMapEdit.cpp Core/Tools/WorldBuilder/include/WHeightMapEdit.h

Repository: TheSuperHackers/GeneralsGameCode

Length of output: 28808


Reject version-7 saves when the omitted cliff-state byte is non-zero.

WorldBuilder can resize maps to widths where version 7 writes fewer cliff-state bytes than the in-memory row. Normal cliff recalculation can set bits in that omitted byte. The retail version-7 reader does not read it, so reopening the saved map clears those bits.

Version 8 preserves the bits but violates the retail compatibility contract. Check the omitted byte before writing any chunks and reject the save when it contains data.

Suggested fix
 void WorldHeightMapEdit::saveToFile(DataChunkOutput &chunkWriter)
 {
+	#if RTS_GENERALS && RETAIL_COMPATIBLE_DATA
+		Int legacyByteWidth = (m_width+1)/8;
+		if (legacyByteWidth < m_flipStateWidth) {
+			for (Int j=0; j<m_height; j++) {
+				if (m_cellCliffState[j*m_flipStateWidth + legacyByteWidth] != 0) {
+					throw(ERROR_CORRUPT_FILE_FORMAT);
+				}
+			}
+		}
+	#endif
+
 	// This is the chunk writer stuff.
 	int i;

}
} else {
chunkWriter.writeArrayOfBytes((char*)m_cellCliffState, m_height*m_flipStateWidth);
}
chunkWriter.writeInt(m_numBitmapTiles);
chunkWriter.writeInt(m_numBlendedTiles);
chunkWriter.writeInt(m_numCliffInfo);
Expand Down Expand Up @@ -3427,5 +3440,8 @@ void WorldHeightMapEdit::findBoundaryNear(Coord3D *pt, float okDistance, Int *ou
}

(*outNdx) = -1;
(*outHandle) = -1;
// TheSuperHackers @bugfix Handle an omitted boundary handle on the no-match path.
if (outHandle) {
(*outHandle) = -1;
}
}
Loading