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(gameclient): skip a user map that does not load instead of dying

Olcay Seygan7bb247f42686
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 605b2ad69..0ac7db0ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1251,6 +1251,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- A long chat message or an unusual map name could kill the process.
- A map name the game cannot make sense of is refused as you start, instead of taking the game down later. A path with a space in it and no quotes around it left the loader walking the same step of that path forever, growing a string until it ran out of room, and the game then went on starting with half of itself missing. What you saw was a crash a second later, in the part of the game that runs a match, naming nothing that had anything to do with it. Any failure during start-up now stops the game there and says which one it was.
- A downloaded map made for another mod loads instead of crashing as the match starts. Maps can carry their own tweaks to units, and one a player tried gave a wall a setting Zero Hour has never had; one unfamiliar line was enough to take the whole game down. A setting the game does not know is now passed over and the rest of the map's tweaks still apply.
+- One damaged map in your Maps folder no longer stops the game from starting. The game reads every map there as it starts, to build its map list, and a file it could not read through ended the start-up with "ErrorCode 0xdead0005" before the main menu ever came up. A half-finished download would do it. That map is left off the list now and the rest of the folder loads.
- Starting the game from the folder the zip was unpacked to says what is wrong. None of Zero Hour's own files are in that folder, so the first one the game asked for was missing, and the box that came up blamed viruses and overheated hardware. It now names the folder it looked in and tells you to run install.bat.
- A machine that once had Generals installed from a disc or The First Decade, and later removed it, no longer loses the original game's files. The old install leaves its address behind in Windows, the game trusted it over the copy Steam keeps beside Zero Hour, and the main menu came up over magenta water and black hills. A folder that turns out to be empty is passed over now.
- Buying both games on Steam is enough. Steam writes nothing to Windows saying where it put them and installs the two side by side in their own folders, so the game had no way of finding the original one unless you had copied its files across by hand: a fresh install of both came up on a magenta main menu with most of the sound effects missing. The folder next to Zero Hour's is searched now. When the original game's files really are nowhere, a box names the folder to put them in, rather than leaving you to read a pink menu.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MapUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MapUtil.cpp
index 185d9aa5d..eeaea0865 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MapUtil.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MapUtil.cpp
@@ -805,7 +805,30 @@ Bool MapCache::addMap( AsciiString dirName, AsciiString fname, FileInfo *fileInf
DEBUG_LOG(("MapCache::addMap(): caching '%s' because '%s' was not found\n", fname.str(), lowerFname.str()));
- loadMap(fname); // Just load for querying the data, since we aren't playing this map.
+ // Just load for querying the data, since we aren't playing this map. A user's map is a file
+ // nobody here made, and one the chunk reader could not parse (ERROR_CORRUPT_FILE_FORMAT) used to
+ // stop the game at startup, along with every good map in the same folder. It is left out of the
+ // list instead. A shipped map that does not load under -buildMapCache is still an error.
+ try
+ {
+ loadMap(fname);
+ }
+ catch (ErrorCode ec)
+ {
+ if (isOfficial)
+ throw;
+ DEBUG_LOG(("MapCache::addMap(): skipping '%s', it does not load (ErrorCode 0x%08x)\n", fname.str(), (UnsignedInt)ec));
+ resetMap();
+ return FALSE;
+ }
+ catch (...)
+ {
+ if (isOfficial)
+ throw;
+ DEBUG_LOG(("MapCache::addMap(): skipping '%s', it does not load (not an ErrorCode)\n", fname.str()));
+ resetMap();
+ return FALSE;
+ }
// The map is now loaded. Pick out what we need.
md.m_fileName = lowerFname;