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): let a plan die quietly, and print the stop key on its button
Olcay Seygan852d13cf8c8d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7deb9b79a..1806241c5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -451,6 +451,8 @@ foundation, the building itself - and it stays that way until a worker walks ovespade in. One dozer and four orders gives you the whole base drawn out on the ground before a pennyof it is spent, and if the third one was a mistake, click it and take the money back. Stop cancelsit too, so the same key you use to call off a unit calls off a building.+Calling one off is quiet, too: a plan nobody has built yet has nothing to blow up, so it simply goes+away instead of detonating a building that was never there.Ground your units have already walked stays buildable after they leave it: a forward base can beplanned out into the dark and a worker sent to walk there, instead of parking a scout on the spot@@ -459,6 +461,9 @@ own, so drawing buildings across the map tells you nothing about what is sittingyour own plan through the fog, click it, and send a builder to it whenever you like; your opponentsees nothing. Land nobody of yours has ever seen is still off limits.+The stop button in the command bar now has its key printed on it, the way the build buttons do, so+the key that cancels a half-finished building is written on the button that does the same thing.+## Bonuses that come and go when they shouldA squad of infantry standing over its own dead used to keep the horde bonus the dead were payingdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.hindex 45b91ef43..01107c308 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h@@ -170,6 +170,9 @@ extern Bool Object_isAwaitingBuilder( Bool underConstruction, Real constructionPextern Real Object_shroudClearingRange( Real ownRange, Bool underConstruction, Real constructionPercent,Real boundingCircleRadius );+///< does this object go away without any death of its own - no explosion, no collapse, no rubble?+extern Bool Object_deathIsSilent( Bool underConstruction, Real constructionPercent );+class Object : public Thing, public Snapshot{diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 6c97c4e72..ae6f95bcc 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -3127,6 +3127,23 @@ void ControlBar::setControlCommand( GameWindow *button, const CommandButton *combreak;}}+ //+ // the stop button does not live on the grid: MSG_META_STOP presses it whether or not grid hot+ // keys are switched on, and on a building of yours that is still going up it is the cancel key,+ // so the button wears that letter in both modes.+ //+ if( commandButton->getCommandType() == GUI_COMMAND_STOP )+ {+ UnicodeString stopKey = getMetaKeyLabel( GameMessage::MSG_META_STOP );++ if( stopKey.isEmpty() )+ button->winClearStatus( WIN_STATUS_SHORTCUT_BUTTON );+ else+ button->winSetStatus( WIN_STATUS_SHORTCUT_BUTTON );++ GadgetButtonSetText( button, stopKey );+ }+GadgetButtonSetAltSound(button, "GUICommandBarClick");} // end setControlCommanddiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex a3288eba3..0a466b1b7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -4646,12 +4646,25 @@ void Object::onDie( DamageInfo *damageInfo )Bool selfInflicted = (damageInfo->in.m_sourceID == getID());- // FIRST, call our die modules.- for (BehaviorModule** d = m_behaviors; *d; ++d)+ //+ // FIRST, call our die modules - unless nothing has been built here yet, in which case they are+ // exactly what must not run: the die modules are the explosion, the collapse and the rubble of a+ // building that stood, and a plan waiting for its builder never did. It simply goes away, the+ // way DestroyDie would have taken it. Everything below still happens - the radar, the team+ // notice, a GLA hole starting its rebuild over.+ //+ if( Object_deathIsSilent( testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION ), m_constructionPercent ) )+ {+ TheGameLogic->destroyObject( this );+ }+ else{- DieModuleInterface* die = (*d)->getDie();- if (die)- die->onDie(damageInfo);+ for (BehaviorModule** d = m_behaviors; *d; ++d)+ {+ DieModuleInterface* die = (*d)->getDie();+ if (die)+ die->onDie(damageInfo);+ }}// When objects die we remove from the radar as they're really not interesting anymore@@ -5239,6 +5252,13 @@ Real Object_shroudClearingRange( Real ownRange, Bool underConstruction, Real con}//-------------------------------------------------------------------------------------------------+Bool Object_deathIsSilent( Bool underConstruction, Real constructionPercent )+{+ // a plan the builder never reached is a silhouette of a building, not a building: there is+ // nothing standing to blow up, collapse or leave rubble behind.+ return Object_isAwaitingBuilder( underConstruction, constructionPercent );+}+Real Object::getShroudClearingRange() const{Real shroudClearingRange = Object_shroudClearingRange( m_shroudClearingRange,diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex b706aae18..1f4b1308f 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -4819,3 +4819,16 @@ TEST(the_fog_never_hides_your_own_plan_from_your_own_builder)CHECK( ActionManager_shroudHidesTarget( FALSE, FALSE, TRUE, FALSE ) == FALSE ); // asked by the AICHECK( ActionManager_shroudHidesTarget( TRUE, FALSE, FALSE, FALSE ) == FALSE ); // in plain sight}++//-------------------------------------------------------------------------------------------------+/** A plan is a silhouette, not a building: cancelling it - or an enemy shooting it - must not set+ off the explosion, collapse and rubble of a structure that never stood. Object::onDie skips+ its die modules and destroys it outright when this says so. */+//-------------------------------------------------------------------------------------------------+TEST(a_plan_dies_without_an_explosion_but_a_building_does_not)+{+ CHECK( Object_deathIsSilent( TRUE, 0.0f ) == TRUE ); // still waiting for its builder+ CHECK( Object_deathIsSilent( TRUE, 0.5f ) == FALSE ); // half up, it blows up like a building+ CHECK( Object_deathIsSilent( TRUE, 100.0f ) == FALSE ); // the last frame of construction+ CHECK( Object_deathIsSilent( FALSE, 0.0f ) == FALSE ); // finished: percent means nothing here+}