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 leashing aircraft on an attack move
Olcay Seygan2c192ea9ad80
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cppindex c761553c2..34f0fde74 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp@@ -3663,8 +3663,17 @@ void AIAttackMoveToState::startEngaging( Object *victim )Object *owner = getMachineOwner();AIUpdateInterface *ai = owner->getAI();- ai->friend_endingMove();- ai->destroyPath(); // drop the attack move path; it is rebuilt when the fight is over+ //+ // A ground unit fights from a standstill, so the move ends here and the attack machine's own+ // approach owns the locomotor from now on. An aircraft has no standstill to fight from: it has+ // to keep flying, and the attack machine computes its own path on entry anyway, so telling it+ // the move is over just leaves it drifting for a frame.+ //+ if (!owner->isUsingAirborneLocomotor())+ {+ ai->friend_endingMove();+ ai->destroyPath(); // drop the attack move path; it is rebuilt when the fight is over+ }m_engageOrigin = *owner->getPosition();m_victimID = victim->getID();@@ -3733,6 +3742,22 @@ Bool AIAttackMoveToState::hasLeftTheLeash( void )if (owner->getControllingPlayer()->getPlayerType() != PLAYER_HUMAN)return FALSE;+ //+ // Aircraft are not leashed. The leash keeps a ground unit from being walked off its attack move+ // by a target that backs away, and it is measured from where the target was acquired - but an+ // aircraft acquires out to its weapon range, which is far longer than the leash. It therefore+ // broke the leash on the way in, every time, and disengaged before firing a shot; the+ // requireProgressTowardGoal() that follows then flew it further down the path before it was+ // allowed to try again. The net effect was an aircraft that picked target after target,+ // never shot at any of them, and never ran its tanks dry enough to go home.+ //+ // What bounds an aircraft is its ammunition, not distance: it empties its load and JetAIUpdate+ // takes it home to reload (and, since the attack move is a standing order, picks the order back+ // up afterwards).+ //+ if (owner->isUsingAirborneLocomotor())+ return FALSE;+Real dx = owner->getPosition()->x - m_engageOrigin.x;Real dy = owner->getPosition()->y - m_engageOrigin.y;return (dx*dx + dy*dy) > sqr(ATTACK_MOVE_LEASH_CELLS*PATHFIND_CELL_SIZE_F);diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cppindex 969d946a7..3ac401eed 100644--- a/GeneralsMD/Code/Main/WinMain.cpp+++ b/GeneralsMD/Code/Main/WinMain.cpp@@ -387,13 +387,17 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,case WM_QUERYENDSESSION:{- TheMessageStream->appendMessage(GameMessage::MSG_META_DEMO_INSTANT_QUIT);+ // guarded like the focus handlers below: these messages can arrive before the+ // engine is up and, more often, while it is tearing down - a close or end-session+ // that lands after TheMessageStream is gone used to fault right here.+ if (TheMessageStream)+ TheMessageStream->appendMessage(GameMessage::MSG_META_DEMO_INSTANT_QUIT);return 0; //don't allow Windows to shutdown while game is running.}// ------------------------------------------------------------------------case WM_CLOSE:- if (!TheGameEngine->getQuitting())+ if (TheGameEngine && !TheGameEngine->getQuitting() && TheMessageStream){//user is exiting without using the menus