Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class SupplyTruckAIUpdate : public AIUpdateInterface, public SupplyTruckAIInterf
virtual UnsignedInt getActionDelayForDock( Object *dock ) override;

virtual UpdateSleepTime update() override;
virtual void aiDoCommand(const AICommandParms* parms) override;

protected:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ class ChinookTakeoffOrLandingState : public State
{
// A chinook given transport duty loses his supplies.
while( ai->loseOneBox() );
#if !RETAIL_COMPATIBLE_CRC
ai->setForceWantingState(FALSE);
#endif
}

// kill any drift...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ Real SupplyTruckAIUpdate::getWarehouseScanDistance() const
return getSupplyTruckAIUpdateModuleData()->m_warehouseScanDistance;
}

void SupplyTruckAIUpdate::aiDoCommand(const AICommandParms* parms)
{
#if !RETAIL_COMPATIBLE_CRC
if (parms->m_cmdSource == CMD_FROM_PLAYER)
{
setForceWantingState(FALSE);
}
#endif

AIUpdateInterface::aiDoCommand(parms);
}

// ------------------------------------------------------------------------------------------------
/** CRC */
// ------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ Object *WorkerAIUpdate::construct( const ThingTemplate *what,

// leave the supply truck state and now behave like a dozer.
exitingSupplyTruckState();
#if !RETAIL_COMPATIBLE_CRC
setForceWantingState(FALSE);
#endif

// take the required money away from the player
if( isRebuild == FALSE )
Expand Down Expand Up @@ -673,6 +676,9 @@ void WorkerAIUpdate::newTask( DozerTask task, Object* target )
getObject()->getAIUpdateInterface()->aiIdle(CMD_FROM_AI);
}
m_workerMachine->setState( AS_DOZER );
#if !RETAIL_COMPATIBLE_CRC
setForceWantingState(FALSE);
#endif
// To clarify, I leave supply truck mode when I notice I am doing something not supply
// truck related. When given a construct command, I wait to do anything until I notice
// I'm not busy. Both states are being polite, so I must force the switch.
Expand Down Expand Up @@ -1037,7 +1043,12 @@ void WorkerAIUpdate::aiDoCommand(const AICommandParms* parms)

// when a player issues commands, this will cause the dozer to re-evaluate what it's doing
if( parms->m_cmdSource == CMD_FROM_PLAYER )
{
m_dozerMachine->resetToDefaultState();
#if !RETAIL_COMPATIBLE_CRC
setForceWantingState(FALSE);
#endif
Comment on lines +1048 to +1050

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Repair commands retain supply latch 🐞 Bug ≡ Correctness

WorkerAIUpdate clears m_forcePending only in aiDoCommand's default case, so player
AICMD_REPAIR and AICMD_RESUME_CONSTRUCTION commands skip the reset while a newly produced worker
remains AS_DOZER. Their newTask reset only runs when already AS_SUPPLY_TRUCK, allowing the
production latch to switch the worker into supply mode and override the accepted task on the next
update.
Agent Prompt
## Issue description
Player repair and resume-construction commands bypass the newly added supply-latch reset because they have dedicated `aiDoCommand` switch cases. Clear the force-wanting latch for every accepted player command, including these special cases, in both game variants.

## Issue Context
Production exit sets the force-wanting latch after issuing its exit path. A worker can therefore still be in `AS_DOZER` when a player command arrives; the reset in `newTask` is insufficient because it is conditional on the worker already being in `AS_SUPPLY_TRUCK`.

## Fix Focus Areas
- Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp[1002-1051]
- Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp[665-681]
- GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp[1002-1051]
- GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp[665-681]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

}
break;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class SupplyTruckAIUpdate : public AIUpdateInterface, public SupplyTruckAIInterf
virtual Int getUpgradedSupplyBoost() const override { return 0; }

virtual UpdateSleepTime update() override;
virtual void aiDoCommand(const AICommandParms* parms) override;

protected:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ class ChinookTakeoffOrLandingState : public State
{
// A chinook given transport duty loses his supplies.
while( ai->loseOneBox() );
#if !RETAIL_COMPATIBLE_CRC
ai->setForceWantingState(FALSE);
#endif
}

// kill any drift...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,18 @@ Real SupplyTruckAIUpdate::getWarehouseScanDistance() const
return getSupplyTruckAIUpdateModuleData()->m_warehouseScanDistance;
}

void SupplyTruckAIUpdate::aiDoCommand(const AICommandParms* parms)
{
#if !RETAIL_COMPATIBLE_CRC
if (parms->m_cmdSource == CMD_FROM_PLAYER)
{
setForceWantingState(FALSE);
}
#endif

AIUpdateInterface::aiDoCommand(parms);
}

// ------------------------------------------------------------------------------------------------
/** CRC */
// ------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ Object *WorkerAIUpdate::construct( const ThingTemplate *what,

// leave the supply truck state and now behave like a dozer.
exitingSupplyTruckState();
#if !RETAIL_COMPATIBLE_CRC
setForceWantingState(FALSE);
#endif

// take the required money away from the player
if( isRebuild == FALSE )
Expand Down Expand Up @@ -673,6 +676,9 @@ void WorkerAIUpdate::newTask( DozerTask task, Object* target )
getObject()->getAIUpdateInterface()->aiIdle(CMD_FROM_AI);
}
m_workerMachine->setState( AS_DOZER );
#if !RETAIL_COMPATIBLE_CRC
setForceWantingState(FALSE);
#endif
// To clarify, I leave supply truck mode when I notice I am doing something not supply
// truck related. When given a construct command, I wait to do anything until I notice
// I'm not busy. Both states are being polite, so I must force the switch.
Expand Down Expand Up @@ -1037,7 +1043,12 @@ void WorkerAIUpdate::aiDoCommand(const AICommandParms* parms)

// when a player issues commands, this will cause the dozer to re-evaluate what it's doing
if( parms->m_cmdSource == CMD_FROM_PLAYER )
{
m_dozerMachine->resetToDefaultState();
#if !RETAIL_COMPATIBLE_CRC
setForceWantingState(FALSE);
#endif
}
break;

}
Expand Down
Loading