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.

feat(gameengine): template medium is the template's own size, wide exits

Olcay Seyganb744dbc2dccc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4bc7a2dc7..1dacb291e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,8 +11,8 @@ found and fixed — EA's own, not port damage.**
## A Random tab in the map list
- Select Map has a third tab beside Official and Unofficial. Pick a map type from the official maps (or Surprise me), a size from Tiny to Extra Large and the number of players, and a new map is made from them on the spot, in the skirmish, LAN and online rooms alike. The preview and its start positions are that map before you accept it, so there is no guessing what you will land on. New Map rolls another with the same choice, and so does every change you make. Extra Large still seats eight.
-- A map built from an official map takes its sizes from that map. Medium gives every player the ground one seat has on the original, so four players on a Twilight Flame map get 337 cells a side where they had 304, and eight get 477 where they had 416; Extra Large for eight is 708. Surprise me keeps the sizes it always had.
-- Bases on raised ground, as on Twilight Flame, now share one stretch of high ground the way the original's do, and each has a ramp running straight down toward the middle. They used to stand on separate plateaus with a narrow gap between them, and armies queued in it. Over three eight-player matches at Medium size, units stood blocked on the way 163 times per thousand frames, against 205 on Twilight Flame itself and 319 before. Four players at Medium still block one and a half times as often as on the original, where four players spread over a map made for eight.
+- A map built from an official map takes its sizes from that map. Medium is the original's own size for as many players as it seats, the room they would have on it: a Twilight Flame map is 477 cells a side for two to eight players, where four used to get 304 and eight 416, and each player past the original's seats adds one seat's ground. Extra Large is 708. Surprise me keeps the sizes it always had.
+- Bases on raised ground, as on Twilight Flame, now share one stretch of high ground the way the original's do, and each has its ways down widened and one more running straight toward the middle. They used to stand on separate plateaus with a narrow gap between them, and armies queued in it. Over three eight-player matches at Medium size, units stood blocked on the way 163 times per thousand frames, against 205 on Twilight Flame itself and 319 before; four players over five matches 80 against the original's 67, where they used to block twice as often.
- A map built from a river map keeps a bridge over its river at every size. The smallest two-player Silent River map had none: the bases left no clear ground for one, so now the crossing that runs least into a base takes the bridge.
- The player count starts at the number of seats already taken in the room. The tab, the map type and the size you used last are remembered for the next time.
- In a LAN or online room the other players do not download anything: the map's name carries its recipe, and their own game builds the same map from it and checks it against yours. A room that records stats keeps to the official list.
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RandomMapGenerator.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RandomMapGenerator.cpp
index 173160382..7954a4be9 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RandomMapGenerator.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RandomMapGenerator.cpp
@@ -7355,7 +7355,10 @@ Int RandomMapGenerator::cellsForTemplate( RandomMapSize size, Int numPlayers, In
if( numPlayers < MIN_PLAYERS ) numPlayers = MIN_PLAYERS;
if( numPlayers > MAX_PLAYERS ) numPlayers = MAX_PLAYERS;
- double area = (double)cellsX * cellsY * numPlayers * AREA_PERCENT[size] / ( (double)seats * PERCENT );
+ // Medium is the template's own ground for as many players as it seats, the room they have on it;
+ // only players past its seats add a seat's share each
+ const Int seatsFilled = std::max( numPlayers, seats );
+ double area = (double)cellsX * cellsY * seatsFilled * AREA_PERCENT[size] / ( (double)seats * PERCENT );
Int cells = (Int)sqrt( area );
if( cells < MIN_CELLS ) cells = MIN_CELLS;
if( cells > MAX_CELLS ) cells = MAX_CELLS;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RandomMapTemplate.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RandomMapTemplate.cpp
index 4611c7f09..fc6f3af33 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RandomMapTemplate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RandomMapTemplate.cpp
@@ -4938,9 +4938,10 @@ void carryMoney( const Exemplar& src, const std::vector<Copy>& pads, SynthMap& s
}
/** A plateau copied smaller keeps its ramps' climb but not their width, and an army queues at the
- narrow mouth. Every way down off a scaled plateau is widened to WIDE_RAMP_HALF either side of
- its walk, each cell beside it at the height of the walk where it passes: the ramp's own climb,
- as wide as the exemplar's. The ways down are the first cells a walk from the start reaches halfway
+ narrow mouth; one copied at full size keeps only the ramps inside its region, where the exemplar's
+ base opens onto the basin along far more. Every way down off a plateau is widened to
+ WIDE_RAMP_HALF either side of its walk, each cell beside it at the height of the walk where it
+ passes: the ramp's own climb, as wide as the exemplar's. The ways down are the first cells a walk from the start reaches halfway
down, a ramp's width apart; each walk runs on from there to the ground. */
void widenRamps( std::vector<Int>& heights, Int W, Int H, Int border, const Plan& plan, const std::vector<Copy>& pads, Real ground )
{
@@ -4952,7 +4953,6 @@ void widenRamps( std::vector<Int>& heights, Int W, Int H, Int border, const Plan
Field want( W * H ), weight( W * H );
for( size_t p = 0; p < pads.size(); p++ )
{
- if( pads[p].heightScale >= 1.0f ) continue;
const Int start = clampi( roundi( pads[p].target.y ), 0, H - 1 ) * W + clampi( roundi( pads[p].target.x ), 0, W - 1 );
const Real top = (Real)heights[start];
const Real half = 0.5f * ( top + ground ), foot = ground + 0.1f * ( top - ground );
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index ffcfe8fd1..8c6c9ca41 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -11199,8 +11199,12 @@ TEST(a_template_map_gives_each_player_the_ground_a_seat_has_on_the_template)
const Int TEMPLATE_X = 486, TEMPLATE_Y = 469, TEMPLATE_SEATS = 8;
CHECK_EQ( RandomMapGenerator::cellsForTemplate( RANDOM_MAP_SIZE_NORMAL, 8, TEMPLATE_X, TEMPLATE_Y, TEMPLATE_SEATS ), 477 );
- CHECK_EQ( RandomMapGenerator::cellsForTemplate( RANDOM_MAP_SIZE_NORMAL, 4, TEMPLATE_X, TEMPLATE_Y, TEMPLATE_SEATS ), 337 );
+ CHECK_EQ( RandomMapGenerator::cellsForTemplate( RANDOM_MAP_SIZE_NORMAL, 4, TEMPLATE_X, TEMPLATE_Y, TEMPLATE_SEATS ), 477 );
+ CHECK_EQ( RandomMapGenerator::cellsForTemplate( RANDOM_MAP_SIZE_NORMAL, 2, TEMPLATE_X, TEMPLATE_Y, TEMPLATE_SEATS ), 477 );
CHECK_EQ( RandomMapGenerator::cellsForTemplate( RANDOM_MAP_SIZE_HUGE, 8, TEMPLATE_X, TEMPLATE_Y, TEMPLATE_SEATS ), 708 );
+ // past the template's seats each player adds a seat's ground
+ CHECK( RandomMapGenerator::cellsForTemplate( RANDOM_MAP_SIZE_NORMAL, 6, TEMPLATE_X, TEMPLATE_Y, 4 ) >
+ RandomMapGenerator::cellsForTemplate( RANDOM_MAP_SIZE_NORMAL, 4, TEMPLATE_X, TEMPLATE_Y, 4 ) );
for( Int size = 0; size + 1 < RANDOM_MAP_SIZE_COUNT; size++ )
for( Int players = RandomMapGenerator::MIN_PLAYERS; players <= RandomMapGenerator::MAX_PLAYERS; players++ )
CHECK( RandomMapGenerator::cellsForTemplate( (RandomMapSize)size, players, TEMPLATE_X, TEMPLATE_Y, TEMPLATE_SEATS ) <
@@ -11917,7 +11921,7 @@ TEST(a_template_map_comes_out_the_same_twice_and_every_start_walks_to_every_othe
RandomMapGenerator::generate( exemplarSettings, exemplar );
// the bytes themselves, pinned like the generator's: a change here is a change to every template map's name
- static const UnsignedInt theTemplateFingerprints[2] = { 0xF9D5107Cu, 0xEE6AC80Cu };
+ static const UnsignedInt theTemplateFingerprints[2] = { 0xF9D5107Cu, 0x4035FBF7u };
for( Int players = 2; players <= 8; players += 6 )
{
RandomMapSettings settings;