Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(w3ddevice): accept retail maps that save no cliff info

Olcay Seygan9ee8f43a5a57
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6462f940f..d26c229cb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1652,7 +1652,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- Another player can no longer make your game write files the host never announced, rewrite or remove someone else's LAN game, crash you with a malformed network or lobby message, or flood your memory with oversized commands. A command with an invalid weapon slot is refused.
- Crash fixes: ordering an upgrade with a Supply Drop Zone, a GLA Hole or a captured Oil Derrick selected, a map that shows a counter it never set, a camera shake at a waypoint that is not there, and closing a menu while it animates. A map message with a percent sign in it shows as written.
- Stopped sounds really stop. A destroyed unit's engine loop and a turret's turning loop no longer play on, and the Idle Worker tooltip shows its key.
-- A damaged map sends you back to the menu with a box naming it as damaged, instead of closing the game. A map file is whatever its maker handed you, and the reader trusted every count in it: a height map claiming four billion cells, a trigger with a negative number of points or a tile class pointing past its table either crashed the game or read on into the next part of the file, where every machine found different garbage. Each count is checked against what the file can hold now, and a map that fails is left out of the list or refused at the start, the same way on every machine in the match.
+- A damaged map sends you back to the menu with a box naming it as damaged, instead of closing the game. A map file is whatever its maker handed you, and the reader trusted every count in it: a height map claiming four billion cells, a trigger with a negative number of points or a tile class pointing past its table either crashed the game or read on into the next part of the file, where every machine found different garbage. Each count is checked against what the file can hold now, and a map that fails is left out of the list or refused at the start, the same way on every machine in the match. For a few hours that check also refused Tournament City, Tournament Desert, Fortress Avalanche, Heartland Shield, Sand Serpent and two campaign maps, all of which save no cliff textures and were read as damaged for it. They open again; all 62 skirmish maps in the game's archives were started headless to prove it.
- A custom map's rules last for that match only. A map.ini could rewrite a weapon, a sound, a particle effect, an FX list, the water or the snow, and the next match on another map played with the change still in it, so two players who had played different maps before were running different rules. Every store a map may touch puts the game's own values back when the match ends, and a block a map has no business changing (the mouse, the multiplayer colours, the campaigns) is skipped with the rest of the file still loading. A map.ini that raised a unit's price showed it on the button and charged the old one; it charges what the button says now. Values no sane map uses, a build time of a hundred years or a snowstorm a million flakes wide, are refused one line at a time. A map that set the weather twice, in its map.ini and its solo.ini, froze the game while it loaded; it loads now.
## Units take corners wide, and drive round a jam instead of into it
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
index 24b8e513e..94426d697 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
@@ -615,9 +615,12 @@ Bool WorldHeightMap::ParseBlendTileData(DataChunkInput &file, DataChunkInfo *inf
} else {
m_numCliffInfo = 1; // cliffInfo[0] is the default info.
}
+ // Zero is a real count: seven retail maps (Tournament City, Tournament Desert, Fortress
+ // Avalanche among them) save no cliff info at all, and both loops below start at 1, while the
+ // patch after the parse sends every out-of-range cell index to entry 0, which is always there.
if (m_numBitmapTiles < 0 || m_numBitmapTiles > NUM_SOURCE_TILES
- || m_numBlendedTiles < 1 || m_numBlendedTiles > NUM_BLEND_TILES
- || m_numCliffInfo < 1 || m_numCliffInfo > NUM_CLIFF_INFO) {
+ || m_numBlendedTiles < 0 || m_numBlendedTiles > NUM_BLEND_TILES
+ || m_numCliffInfo < 0 || m_numCliffInfo > NUM_CLIFF_INFO) {
throw ERROR_CORRUPT_FILE_FORMAT;
}
// --> file loading here