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): dead, destroyed and unbuilt objects stop counting as a base
Olcay Seygan1499406e0428
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 72f583b52..f179afd92 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -480,6 +480,10 @@ found and fixed — EA's own, not port damage.**standing in the fog and the game used to run on forever, waiting for an opponent to destroysomething they could neither see nor shoot. A plan is not a building; only one a worker has startedcounts.+- The same goes for a Generals Challenge or a mission. Lose your last base with a plan still on the+ map, or a factory already burning down, and the game used to sit there waiting for a defeat that+ never came. It ends now. The observer's counts stopped counting units that are already dying and+ plans nobody has started. Found and fixed by 600rr.- 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/Source/Common/RTS/Team.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cppindex 3e979f303..ced50dd17 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Team.cpp@@ -1621,6 +1621,12 @@ Bool Team::removeOverridePlayerRelationship( Int playerIndex )return false;}+// ------------------------------------------------------------------------+static Bool objectKeepsOwnerAlive(const Object *obj)+{+ return Object_keepsOwnerAlive(obj->testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION), obj->getConstructionPercent());+}+// ------------------------------------------------------------------------void Team::countObjectsByThingTemplate(Int numTmplates, const ThingTemplate* const* things, Bool ignoreDead, Int *counts, Bool ignoreUnderConstruction) const{@@ -1635,12 +1641,19 @@ void Team::countObjectsByThingTemplate(Int numTmplates, const ThingTemplate* concontinue;}- if (ignoreDead && iter.cur()->isEffectivelyDead())+ if (ignoreDead && (iter.cur()->isEffectivelyDead() || iter.cur()->isDestroyed()))continue;if( ignoreUnderConstruction && iter.cur()->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) )continue;+ // The plan skip rides on ignoreUnderConstruction rather than running for everyone. A+ // caller that passes false is asking for sites still being built, and a plan is one of+ // them. Every caller today takes the default TRUE, and a plan carries UNDER_CONSTRUCTION,+ // so the check above already drops it; this line states the rule, it changes no count.+ if (ignoreUnderConstruction && !objectKeepsOwnerAlive(iter.cur()))+ continue;+counts[i] += 1;break; // from 'next i', NOT 'next object'@@ -1653,6 +1666,15 @@ Int Team::countBuildings(void){int retVal = 0;for (DLINK_ITERATOR<Object> iter = iterate_TeamMemberList(); !iter.done(); iter.advance()) {+ if (iter.cur()->isEffectivelyDead())+ continue;++ if (iter.cur()->isDestroyed())+ continue;++ if (!objectKeepsOwnerAlive(iter.cur()))+ continue;+const ThingTemplate* objtmpl = iter.cur()->getTemplate();if (!objtmpl) {continue;@@ -1669,6 +1691,15 @@ Int Team::countObjects(KindOfMaskType setMask, KindOfMaskType clearMask){int retVal = 0;for (DLINK_ITERATOR<Object> iter = iterate_TeamMemberList(); !iter.done(); iter.advance()) {+ if (iter.cur()->isEffectivelyDead())+ continue;++ if (iter.cur()->isDestroyed())+ continue;++ if (!objectKeepsOwnerAlive(iter.cur()))+ continue;+const ThingTemplate* objtmpl = iter.cur()->getTemplate();if (!objtmpl) {continue;@@ -1698,12 +1729,6 @@ 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{@@ -2551,8 +2576,17 @@ Bool Team::hasAnyBuildFacility() const{for (DLINK_ITERATOR<Object> iter = iterate_TeamMemberList(); !iter.done(); iter.advance()){+ if (iter.cur()->isEffectivelyDead())+ continue;++ if (iter.cur()->isDestroyed())+ continue;++ if (!objectKeepsOwnerAlive(iter.cur()))+ continue;+const ThingTemplate *objtmpl = iter.cur()->getTemplate();- if (objtmpl->isBuildFacility())+ if (objtmpl && objtmpl->isBuildFacility())return true;}return false;