From 59a0b2ba6cb65345122f61f3f48dcb292a327eab Mon Sep 17 00:00:00 2001 From: rtri Date: Sun, 26 Jul 2020 15:30:30 +0200 Subject: [PATCH] fix #6378 --- rts/Sim/MoveTypes/ScriptMoveType.cpp | 2 +- rts/Sim/Units/CommandAI/CommandAI.cpp | 2 +- rts/Sim/Units/CommandAI/MobileCAI.cpp | 23 ++++++++++------------- rts/Sim/Units/CommandAI/MobileCAI.h | 7 ++++++- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/rts/Sim/MoveTypes/ScriptMoveType.cpp b/rts/Sim/MoveTypes/ScriptMoveType.cpp index 07f0124c0f5..dfb93428ef1 100644 --- a/rts/Sim/MoveTypes/ScriptMoveType.cpp +++ b/rts/Sim/MoveTypes/ScriptMoveType.cpp @@ -63,7 +63,7 @@ CScriptMoveType::~CScriptMoveType() void CScriptMoveType::CheckNotify() { - if (!scriptNotify) + if (scriptNotify == HitNothing) return; if (eventHandler.MoveCtrlNotify(owner, scriptNotify)) { diff --git a/rts/Sim/Units/CommandAI/CommandAI.cpp b/rts/Sim/Units/CommandAI/CommandAI.cpp index ce4f04f24b7..e75455c26c0 100644 --- a/rts/Sim/Units/CommandAI/CommandAI.cpp +++ b/rts/Sim/Units/CommandAI/CommandAI.cpp @@ -1569,7 +1569,7 @@ void CCommandAI::FinishCommand() { assert(!commandQue.empty()); - const Command cmd = commandQue.front(); //cppcheck false positive, copy is needed here + const Command cmd = commandQue.front(); // copy is needed here const bool dontRepeat = (cmd.IsInternalOrder()); const bool pushCommand = (cmd.GetID() != CMD_STOP && cmd.GetID() != CMD_PATROL); diff --git a/rts/Sim/Units/CommandAI/MobileCAI.cpp b/rts/Sim/Units/CommandAI/MobileCAI.cpp index 9f03fa56c55..00f60cab0e4 100644 --- a/rts/Sim/Units/CommandAI/MobileCAI.cpp +++ b/rts/Sim/Units/CommandAI/MobileCAI.cpp @@ -357,11 +357,11 @@ void CMobileCAI::Execute() Command& c = commandQue.front(); switch (c.GetID()) { - case CMD_MOVE: { ExecuteMove(c); return; } - case CMD_PATROL: { ExecutePatrol(c); return; } - case CMD_FIGHT: { ExecuteFight(c); return; } - case CMD_GUARD: { ExecuteGuard(c); return; } - case CMD_LOAD_ONTO: { ExecuteLoadOnto(c); return; } + case CMD_MOVE: { ExecuteMove(c); return; } + case CMD_PATROL: { ExecutePatrol(c); return; } + case CMD_FIGHT: { ExecuteFight(c); return; } + case CMD_GUARD: { ExecuteGuard(c); return; } + case CMD_LOAD_ONTO: { ExecuteLoadOnto(c); return; } } if (owner->unitDef->IsTransportUnit()) { @@ -433,11 +433,12 @@ void CMobileCAI::ExecuteLoadOnto(Command& c) { if (!inCommand) { inCommand = true; + // order transport to load ; this can recursively end up back in *this::Execute (!) transport->commandAI->GiveCommandReal(Command(CMD_LOAD_UNITS, INTERNAL_ORDER | SHIFT_KEY, owner->id)); } - if (owner->GetTransporter() != nullptr) { - assert(!commandQue.empty()); // should still be in front + // queue might be empty after transport load-order + if (!commandQue.empty() && owner->GetTransporter() != nullptr) { StopMoveAndFinishCommand(); return; } @@ -978,12 +979,6 @@ void CMobileCAI::StopMove() owner->moveType->StopMoving(); } -void CMobileCAI::StopMoveAndFinishCommand() -{ - StopMove(); - FinishCommand(); -} - void CMobileCAI::StopMoveAndKeepPointing(const float3& p, const float r, bool b) { StopMove(); @@ -1066,6 +1061,7 @@ void CMobileCAI::FinishCommand() lastUserGoal = owner->pos; tempOrder = false; + StopSlowGuard(); CCommandAI::FinishCommand(); @@ -1291,6 +1287,7 @@ void CMobileCAI::ExecuteLoadUnits(Command& c) } if (c.IsInternalOrder()) { + // internally issued by MobileCAI if (unit->commandAI->commandQue.empty()) { if (!LoadStillValid(unit)) { StopMoveAndFinishCommand(); diff --git a/rts/Sim/Units/CommandAI/MobileCAI.h b/rts/Sim/Units/CommandAI/MobileCAI.h index 79ba87ffb28..5be88a1b1bd 100644 --- a/rts/Sim/Units/CommandAI/MobileCAI.h +++ b/rts/Sim/Units/CommandAI/MobileCAI.h @@ -25,10 +25,15 @@ class CMobileCAI : public CCommandAI virtual void SetGoal(const float3& pos, const float3& curPos, float goalRadius = SQUARE_SIZE); virtual void SetGoal(const float3& pos, const float3& curPos, float goalRadius, float speed); virtual void BuggerOff(const float3& pos, float radius) override; + bool SetFrontMoveCommandPos(const float3& pos); + void StopMove() override; - void StopMoveAndFinishCommand(); void StopMoveAndKeepPointing(const float3& p, const float r, bool b); + void StopMoveAndFinishCommand() { + StopMove(); + FinishCommand(); + } bool AllowedCommand(const Command& c, bool fromSynced) override; int GetDefaultCmd(const CUnit* pointed, const CFeature* feature) override;