bugfix: Make healed units follow building rally point on exit#1822
bugfix: Make healed units follow building rally point on exit#1822tintinhamans wants to merge 3 commits intoTheSuperHackers:mainfrom
Conversation
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Outdated
Show resolved
Hide resolved
610b09f to
8fe5984
Compare
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp | Modified getRallyPoint() to fall back to primary exit interface and updated exitObjectViaDoor() to use the method instead of direct member access |
| Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp | Added logic to move healed Chinooks to airfield rally point after takeoff, with proper null checks for airfield, exit interface, and rally point |
| Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp | Added logic to move healed helicopters to airfield rally point after takeoff, with proper null checks matching the Chinook implementation |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp | Mirror of Generals version - modified getRallyPoint() fallback logic and exitObjectViaDoor() to use the method |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp | Mirror of Generals version - added rally point movement logic for healed Chinooks with proper null checks |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp | Mirror of Generals version - added rally point movement logic for healed helicopters with proper null checks |
Last reviewed commit: 5a3b849
8fe5984 to
faf8a09
Compare
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Outdated
Show resolved
Hide resolved
faf8a09 to
4e9ef5f
Compare
4e9ef5f to
e87b99b
Compare
Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp
Outdated
Show resolved
Hide resolved
Additional Comments (2)
Prompt To Fix With AIThis is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp
Line: 1038:1039
Comment:
`airfield` could be `nullptr` if the airfield was destroyed or doesn't exist. Need null check before calling `getObjectExitInterface()`.
```suggestion
Object *airfield = TheGameLogic->findObjectByID( m_airfieldForHealing );
if (airfield)
{
const Coord3D *rp = airfield->getObjectExitInterface()->getRallyPoint();
if( rp )
{
AICommandParms parms( AICMD_MOVE_TO_POSITION, CMD_FROM_AI );
parms.m_pos = *rp;
m_pendingCommand.store( parms );
m_hasPendingCommand = true;
}
}
```
How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix With AIThis is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp
Line: 1782:1783
Comment:
`airfield` could be `nullptr` if the airfield was destroyed or doesn't exist (see line 1717-1718 in same file for precedent). Need null check before calling `getObjectExitInterface()`.
```suggestion
Object *airfield = TheGameLogic->findObjectByID( jet->getProducerID() );
if (airfield)
{
const Coord3D *rp = airfield->getObjectExitInterface()->getRallyPoint();
if( rp )
{
AICommandParms parms( AICMD_MOVE_TO_POSITION, CMD_FROM_AI );
parms.m_pos = *rp;
m_mostRecentCommand.store( parms );
setFlag(HAS_PENDING_COMMAND, true);
}
}
```
How can I resolve this? If you propose a fix, please make it concise. |
e87b99b to
ffa98ad
Compare
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp
Outdated
Show resolved
Hide resolved
| // TheSuperHackers @bugfix arcticdolphin 08/02/2026 Move healed helicopter to rally point if present. | ||
| #if !RETAIL_COMPATIBLE_CRC | ||
| { |
There was a problem hiding this comment.
Airfield exit interface unchecked
airfield ? airfield->getObjectExitInterface() : nullptr still assumes the airfield exists and that it has an ExitInterface. The earlier pp != nullptr check doesn’t guarantee findObjectByID(jet->getProducerID()) returns a valid object at this later point, nor that getObjectExitInterface() is non-null. A direct if (airfield != nullptr) { ExitInterface* exit = airfield->getObjectExitInterface(); if (exit != nullptr) ... } guard avoids a crash.
Also appears in GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp:2001-2013.
Prompt To Fix With AI
This is a comment left during a code review.
Path: Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp
Line: 1779:1781
Comment:
**Airfield exit interface unchecked**
`airfield ? airfield->getObjectExitInterface() : nullptr` still assumes the airfield exists and that it has an ExitInterface. The earlier `pp != nullptr` check doesn’t guarantee `findObjectByID(jet->getProducerID())` returns a valid object at this later point, nor that `getObjectExitInterface()` is non-null. A direct `if (airfield != nullptr) { ExitInterface* exit = airfield->getObjectExitInterface(); if (exit != nullptr) ... }` guard avoids a crash.
Also appears in `GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp:2001-2013`.
How can I resolve this? If you propose a fix, please make it concise.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/HealContain.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp
Outdated
Show resolved
Hide resolved
| const Coord3D* rp = buildingExit->getRallyPoint(); | ||
| if (rp) | ||
| { | ||
| setRallyPoint(rp); |
There was a problem hiding this comment.
This looks strange. Basically the Rally Point of the HealContain is now set/updated after every heal. Which begs the question, why is the Rally Point not updated for the Heal Contain when the Rally Point of the Object Exit Interface is updated? That would be the most logical and efficient way (and maybe that is what was supposed to happen but is broken somewhere).
| const Coord3D *rp = exitInterface ? exitInterface->getRallyPoint() : nullptr; | ||
| if( rp ) | ||
| { | ||
| AICommandParms parms( AICMD_MOVE_TO_POSITION, CMD_FROM_AI ); |
There was a problem hiding this comment.
Is this the correct way to do the movement for this purpose?
For reference
OpenContain::exitObjectViaDoor uses ai->aiFollowPath( &exitPath, me, CMD_FROM_AI ) to go to the Rally Point.
DefaultProductionExitUpdate::exitObjectViaDoor uses ai->aiFollowExitProductionPath( &exitPath, creationObject, CMD_FROM_AI ) to go to the Rally Point.
Helicopter looks special, so perhaps that is fine. Unclear.
There was a problem hiding this comment.
I think this is correct. The Chinook/helicopter is landed when healing and needs to take off first - it cannot follow a path directly. This matches how ParkingPlaceBehavior::exitObjectViaDoor handles helipad-produced aircraft:
I did see from above that I can use aiMoveToPosition instead of storing pending command manually since aiDoCommand already handles takeoff in-progress and queues move for us.
ffa98ad to
e4eac2e
Compare
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
Outdated
Show resolved
Hide resolved
…e rally point if available Signed-off-by: tintinhamans <5984296+tintinhamans@users.noreply.github.com>
Signed-off-by: tintinhamans <5984296+tintinhamans@users.noreply.github.com>
Signed-off-by: tintinhamans <5984296+tintinhamans@users.noreply.github.com>
2c1be60 to
5a3b849
Compare
Units will now follow building rally point after healing.
Closes #221