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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameengine): keep random map starts off the edge of the map
Olcay Seygand090229c687d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 39d81b417..04a770ab7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1018,6 +1018,10 @@ found and fixed — EA's own, not port damage.**map is one field of noise, and the bases are found in it: the flattest ground first, thenwhichever good ground is furthest from everything already taken. Some seeds give you four cornersand some give you a long diagonal, and where the fighting happens is different every time.+- Nobody starts with their back against the edge of the map. Taking the site furthest from every+ base already placed walks the next one into a corner, so a seventh of the map is now kept clear+ of start positions on every side: there is ground behind a base to fall back into, and a way+ round it for whoever is attacking.- It is a map, not a field. The ground comes in layers: a flat shelf to build and fight on, a cliffdown to the next one, and ramps cut where the route between two players has to change level, sotaking the high ground means holding a ramp. Lakes sit in the hollows with a shoreline thatdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/RandomMapGenerator.h b/GeneralsMD/Code/GameEngine/Include/Common/RandomMapGenerator.hindex 5af4053ab..f10315252 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/RandomMapGenerator.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/RandomMapGenerator.h@@ -34,7 +34,7 @@rather than desyncing partway through it. The fingerprint test intest_gameengine.cpp fails until the version and the recorded CRCs agree, sothe bump cannot be forgotten. */-#define RANDOM_MAP_GENERATOR_VERSION 3+#define RANDOM_MAP_GENERATOR_VERSION 4/// How much ground the map gives everybody, before the per-player share.enum RandomMapSizediff --git a/GeneralsMD/Code/GameEngine/Source/Common/RandomMapGenerator.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RandomMapGenerator.cppindex ac7ad19f3..ba55733fa 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RandomMapGenerator.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RandomMapGenerator.cpp@@ -118,6 +118,7 @@ static const Int K_SCRIPT_LIST_DATA_VERSION_1 = 1;#define RMG_FLAT_RADIUS 13.0f#define RMG_BLEND_RADIUS 26.0f#define RMG_START_MARGIN 10.0f ///< cells of playable area kept outside the blend disc+#define RMG_START_EDGE_FRACTION 0.14f ///< and this much of the map besides, so a base has ground behind it#define RMG_START_STRIDE 3 ///< cells between the spots the search looks at#define RMG_START_ROUGHNESS 2.6f ///< height bytes a base site may vary by, on average@@ -1032,9 +1033,15 @@ void RMGLayout::chooseStarts( void )Int playable = m_settings.m_playableCells;- // Only the flat disc has to be inside the playable area. The blend ring outside it may run- // into the border, which is ground the camera sees and nobody builds on.+ /* The flat disc has to be inside the playable area, and a good deal more than that: the search+ below takes whichever site is furthest from the ones already picked, which on its own walks+ every base into a corner. A share of the map is kept clear of the edge as well, so there is+ ground behind a base to retreat into and to be attacked through. A map too small to give+ that up keeps the disc's own margin and nothing more. */Int margin = (Int)(RMG_FLAT_RADIUS + RMG_START_MARGIN);+ Int inset = (Int)((Real)playable * RMG_START_EDGE_FRACTION);+ if( inset > margin && playable - 2 * inset >= (Int)(4.0f * RMG_FLAT_RADIUS) )+ margin = inset;struct RMGCandidate { Real m_cellX, m_cellY, m_roughness; };std::vector<RMGCandidate> candidates;diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex f8f0ecfc1..cf4759ef9 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -6950,7 +6950,11 @@ TEST(start_positions_land_inside_the_map_with_room_between_them)CHECK_EQ( numSupplyDocks, players * 2 );Real extent = (Real)settings.m_playableCells * MAP_XY_FACTOR;- Real margin = 20.0f * MAP_XY_FACTOR; // enough ground for a base++ /* Enough ground for a base, and then a share of the map behind it: the site search takes+ whichever candidate is furthest from the starts already chosen, which walks every base+ into a corner unless the edge is kept clear of them. */+ Real margin = (Real)settings.m_playableCells * 0.13f * MAP_XY_FACTOR;Int i, j;for( i = 0; i < players; i++ )@@ -7368,14 +7372,14 @@ TEST(the_generator_still_turns_a_seed_into_the_bytes_it_used_to){CHECK( bootOnce() );- CHECK_EQ( RANDOM_MAP_GENERATOR_VERSION, 3 );+ CHECK_EQ( RANDOM_MAP_GENERATOR_VERSION, 4 );struct RMGFingerprint { Int m_seed, m_players, m_cells; UnsignedInt m_crc; };static const RMGFingerprint theFingerprints[] ={- { 0, 2, 64, 0xF59BF75C },- { 12345, 4, 96, 0x6B8891F3 },- { 7, 8, 128, 0x4D5C3AD3 },+ { 0, 2, 64, 0xF5A3F75C },+ { 12345, 4, 96, 0x6B8C91F3 },+ { 7, 8, 128, 0x4D643AD3 },};const Int numFingerprints = sizeof(theFingerprints) / sizeof(theFingerprints[0]);