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
fix(gameengine): stop a planned structure from keeping its player alive
Olcay Seyganfcbc097fd1ed
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 84b5ec526..cdbb39a0e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -258,6 +258,10 @@ found and fixed — EA's own, not port damage.**- And nothing shoots at one. A plan is invisible to the other side, so a tank that stopped andopened fire on empty ground was telling that player where your base was going up before a singlewall existed. The first work a builder puts in ends this and the site is a target like any other.+- A plan does not keep a beaten player in the match. Lose your last building with one plan still+ standing in the fog and the game used to run on forever, waiting for an opponent to destroy+ something they could neither see nor shoot. A plan is not a building; only one a worker has started+ counts.- Your units walk straight over a plan — nothing solid is there until the builder starts work.- The plan turns solid the instant the first work goes in, so no building goes up inside its own ghost.- The builder starts work from where it reaches the site instead of shuffling into place first.diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.hindex 2c6727a95..16976e76c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h@@ -180,6 +180,9 @@ extern Bool Object_deathIsSilent( Bool underConstruction, Real constructionPerce///< is there anything standing here for a weapon to shoot at, or is it still only a plan?extern Bool Object_isAttackableStructure( Bool underConstruction, Real constructionPercent );+///< does this object count as something its player still has, for defeat and "team destroyed"?+extern Bool Object_keepsOwnerAlive( Bool underConstruction, Real constructionPercent );+class Object : public Thing, public Snapshot{diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cppindex b5a5885aa..3b94b827e 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cpp@@ -1697,6 +1697,12 @@ void Team::iterateObjects( ObjectIterateFunc func, void *userData )}}+// ------------------------------------------------------------------------+static Bool objectKeepsOwnerAlive(const Object *obj)+{+ return Object_keepsOwnerAlive(obj->testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION), obj->getConstructionPercent());+}+// ------------------------------------------------------------------------Bool Team::hasAnyBuildings() const{@@ -1705,7 +1711,10 @@ Bool Team::hasAnyBuildings() constif (iter.cur()->isEffectivelyDead())continue;- if (iter.cur()->isDestroyed())+ if (iter.cur()->isDestroyed())+ continue;++ if (!objectKeepsOwnerAlive(iter.cur()))continue;if (iter.cur()->isKindOf(KINDOF_STRUCTURE))@@ -1722,7 +1731,10 @@ Bool Team::hasAnyBuildings(KindOfMaskType kindOf) constif (iter.cur()->isEffectivelyDead())continue;- if (iter.cur()->isDestroyed())+ if (iter.cur()->isDestroyed())+ continue;++ if (!objectKeepsOwnerAlive(iter.cur()))continue;kindOf.set(KINDOF_STRUCTURE);@@ -1804,6 +1816,9 @@ Bool Team::hasAnyObjects() constcontinue;}+ if (!objectKeepsOwnerAlive(iter.cur()))+ continue;+return true;}return false;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex 1fc49b626..560fdc0d7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -5446,6 +5446,16 @@ Bool Object_isAttackableStructure( Bool underConstruction, Real constructionPercreturn !Object_isAwaitingBuilder( underConstruction, constructionPercent );}+//-------------------------------------------------------------------------------------------------+/** A plan no enemy can see or shoot must not keep its owner in the game either. A player whose last+ * building fell with one plan still standing in the fog was never beaten: the match waited on a+ * structure the other side had no way to find or destroy. */+//-------------------------------------------------------------------------------------------------+Bool Object_keepsOwnerAlive( Bool underConstruction, Real constructionPercent )+{+ 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 1456aa4ec..7a7a09be0 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -6088,6 +6088,16 @@ TEST(a_structure_waiting_for_its_builder_cannot_be_shot_at)CHECK( Object_isAttackableStructure( FALSE, 0.0f ) == TRUE );}+/** A plan nobody can see or shoot must not hold up the end of the match. A player left with only a+ plan in the fog is beaten; the first percent of work makes it a building that counts. */+TEST(a_structure_waiting_for_its_builder_does_not_keep_its_player_alive)+{+ CHECK( Object_keepsOwnerAlive( TRUE, 0.0f ) == FALSE );+ CHECK( Object_keepsOwnerAlive( TRUE, 0.1f ) == TRUE );+ CHECK( Object_keepsOwnerAlive( FALSE, CONSTRUCTION_COMPLETE ) == TRUE );+ CHECK( Object_keepsOwnerAlive( FALSE, 0.0f ) == TRUE );+}+/** The first percent of work is what ends the plan, so the moment the builder arrives and startsthe structure turns solid and stays solid for the rest of its life. A finished building carriesCONSTRUCTION_COMPLETE (-1) and must not be mistaken for one sitting at zero. */