Skip to content

Commit 69a1be7

Browse files
committed
bugfix: Defer commands that require ammo during reload
1 parent 5409558 commit 69a1be7

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

Generals/Code/GameEngine/Include/GameLogic/Module/JetAIUpdate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class JetAIUpdate : public AIUpdateInterface
133133
virtual Bool getTreatAsAircraftForLocoDistToGoal() const;
134134
virtual Bool shouldDeferCommand(const AICommandType commandType) const; ///< returns whether the specified command type should be deferred
135135
virtual Bool commandRequiresTakeoff(const AICommandParms* parms) const; ///< returns whether the specified command requires takeoff
136+
virtual Bool commandRequiresAmmo(const AICommandType commandType) const; ///< returns whether the specified command type requires ammo
136137
virtual Bool isGuardCommand(const AICommandType commandType) const; ///< returns whether the specified command type is a guard command
137138
Bool isParkedAt(const Object* obj) const;
138139

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ Bool JetAIUpdate::shouldDeferCommand(const AICommandType commandType) const
23552355
return true;
23562356

23572357
#if !RETAIL_COMPATIBLE_CRC
2358-
if (isGuardCommand(commandType) && currentState == RELOAD_AMMO)
2358+
if (commandRequiresAmmo(commandType) && currentState == RELOAD_AMMO)
23592359
return true;
23602360
#endif
23612361

@@ -2382,6 +2382,22 @@ Bool JetAIUpdate::commandRequiresTakeoff(const AICommandParms* parms) const
23822382
}
23832383
}
23842384

2385+
Bool JetAIUpdate::commandRequiresAmmo(const AICommandType commandType) const
2386+
{
2387+
switch (commandType)
2388+
{
2389+
case AICMD_ATTACKMOVE_TO_POSITION:
2390+
case AICMD_ATTACK_AREA:
2391+
case AICMD_ATTACK_OBJECT:
2392+
case AICMD_ATTACK_POSITION:
2393+
case AICMD_ATTACK_TEAM:
2394+
case AICMD_FORCE_ATTACK_OBJECT:
2395+
return true;
2396+
default:
2397+
return isGuardCommand(commandType);
2398+
}
2399+
}
2400+
23852401
Bool JetAIUpdate::isGuardCommand(const AICommandType commandType) const
23862402
{
23872403
switch (commandType)

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/JetAIUpdate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class JetAIUpdate : public AIUpdateInterface
142142
virtual Bool getTreatAsAircraftForLocoDistToGoal() const;
143143
virtual Bool shouldDeferCommand(const AICommandType commandType) const; ///< returns whether the specified command type should be deferred
144144
virtual Bool commandRequiresTakeoff(const AICommandParms* parms) const; ///< returns whether the specified command requires takeoff
145+
virtual Bool commandRequiresAmmo(const AICommandType commandType) const; ///< returns whether the specified command type requires ammo
145146
virtual Bool isGuardCommand(const AICommandType commandType) const; ///< returns whether the specified command type is a guard command
146147
Bool isParkedAt(const Object* obj) const;
147148

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,7 @@ Bool JetAIUpdate::shouldDeferCommand(const AICommandType commandType) const
25902590
return true;
25912591

25922592
#if !RETAIL_COMPATIBLE_CRC
2593-
if (isGuardCommand(commandType) && currentState == RELOAD_AMMO)
2593+
if (commandRequiresAmmo(commandType) && currentState == RELOAD_AMMO)
25942594
return true;
25952595
#endif
25962596

@@ -2617,6 +2617,22 @@ Bool JetAIUpdate::commandRequiresTakeoff(const AICommandParms* parms) const
26172617
}
26182618
}
26192619

2620+
Bool JetAIUpdate::commandRequiresAmmo(const AICommandType commandType) const
2621+
{
2622+
switch (commandType)
2623+
{
2624+
case AICMD_ATTACKMOVE_TO_POSITION:
2625+
case AICMD_ATTACK_AREA:
2626+
case AICMD_ATTACK_OBJECT:
2627+
case AICMD_ATTACK_POSITION:
2628+
case AICMD_ATTACK_TEAM:
2629+
case AICMD_FORCE_ATTACK_OBJECT:
2630+
return true;
2631+
default:
2632+
return isGuardCommand(commandType);
2633+
}
2634+
}
2635+
26202636
Bool JetAIUpdate::isGuardCommand(const AICommandType commandType) const
26212637
{
26222638
switch (commandType)

0 commit comments

Comments
 (0)