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(gamelogic): four defects behind the same shape of mistake
Olcay Seyganf056792806a6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5989676c7..f59a3ffff 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -391,6 +391,9 @@ found and fixed — EA's own, not port damage.**- A unit that kills itself survives its own turn now.- Sniping an empty bike, formation moves and hacker evasion no longer crash.- An order naming a player who is not there is dropped instead of crashing.+- An order that names one selected unit when nothing is selected is dropped too, instead of reading off the end of an empty list.+- Subdual weapons work on a unit that is being healed. Healing could drive the subdual meter below zero and it stayed there, so the next stun gun had to fill a hole before it did anything.+- A stream of projectiles remembers which ones it fired. The list was cleared into a local of the same name, so the real one started as whatever was in the recycled memory.- Something going wrong now writes a readable crash report.## Long orders stopped hitchingdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.hindex b4d7299a2..d74719d8e 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h@@ -1178,7 +1178,7 @@ public:void computeIndividualDestination( Coord3D *dest, const Coord3D *groupDest,Object *obj, const Coord3D *center, Bool isFormation ); ///< compute destination of individual object, based on group destinationInt getCount( void ); ///< return the number of objects in the group- Bool isEmpty( void ); ///< returns true if the group has no members+ Bool isEmpty( void ) const; ///< returns true if the group has no membersvoid queueUpgrade( const UpgradeTemplate *upgrade ); ///< queue an upgradevoid add( Object *obj ); ///< add object to groupdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cppindex 24c3e3b30..8e0f0c580 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp@@ -470,7 +470,7 @@ Int AIGroup::getCount( void )/*** Returns true if the group has no members*/-Bool AIGroup::isEmpty( void )+Bool AIGroup::isEmpty( void ) const{return m_memberList.empty();}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cppindex 53dc89c50..6e6f5c8b7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp@@ -1297,7 +1297,12 @@ void ActiveBody::internalAddSubdualDamage( Real delta )const ActiveBodyModuleData *data = getActiveBodyModuleData();m_currentSubdualDamage += delta;+ // The cap was applied at the top and nothing held the bottom, so healing that outruns weak+ // subdual damage drives this below zero - and it stays there, building up a buffer the next+ // subduing weapon has to fill before it does anything at all.m_currentSubdualDamage = min(m_currentSubdualDamage, data->m_subdualDamageCap);+ if (m_currentSubdualDamage < 0.0f)+ m_currentSubdualDamage = 0.0f;}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex cdbebd22b..ee71081c7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -4176,7 +4176,9 @@ void Object::xfer( Xfer *xfer )Drawable *draw = getDrawable();DrawableID drawableID = draw ? draw->getID() : INVALID_DRAWABLE_ID;xfer->xferDrawableID( &drawableID );- if( xfer->getXferMode() == XFER_LOAD )+ // the line above already allows for there being no drawable; this one did not, so an object+ // without one - which is every object in a headless run - faulted on load+ if( draw && xfer->getXferMode() == XFER_LOAD ){// change the ID of the drawable attached to be the same ID as it was when it was saveddiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProjectileStreamUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProjectileStreamUpdate.cppindex 7fe720505..3062aa188 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProjectileStreamUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProjectileStreamUpdate.cpp@@ -46,7 +46,8 @@//-------------------------------------------------------------------------------------------------ProjectileStreamUpdate::ProjectileStreamUpdate( Thing *thing, const ModuleData* moduleData ) : UpdateModule( thing, moduleData ){- ObjectID m_projectileIDs[MAX_PROJECTILE_STREAM];+ // this declared a *local* array of the same name and filled that in, so the member it was meant+ // to clear was left holding whatever the pool block had in itfor( Int index = 0; index < MAX_PROJECTILE_STREAM; index++ ){m_projectileIDs[index] = INVALID_ID;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cppindex 6e89272c4..7dd54eed7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp@@ -261,7 +261,9 @@ static void doSetRallyPoint( Object *obj, const Coord3D& pos )static Object * getSingleObjectFromSelection(const AIGroup *currentlySelectedGroup){- if( currentlySelectedGroup )+ // an empty group is not the same as no group: the iterator below was taken from an empty+ // vector and dereferenced+ if( currentlySelectedGroup && !currentlySelectedGroup->isEmpty() ){const VecObjectID& selectedObjects = currentlySelectedGroup->getAllIDs();DEBUG_ASSERTCRASH(selectedObjects.size() == 1, ("Trying to get single object from multiple selection!"));