Skip to content

Commit

Permalink
fix #6378
Browse files Browse the repository at this point in the history
  • Loading branch information
rtri committed Jul 26, 2020
1 parent 058dcb2 commit 3b1446a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion rts/Sim/MoveTypes/ScriptMoveType.cpp
Expand Up @@ -63,7 +63,7 @@ CScriptMoveType::~CScriptMoveType()

void CScriptMoveType::CheckNotify()
{
if (!scriptNotify)
if (scriptNotify == HitNothing)
return;

if (eventHandler.MoveCtrlNotify(owner, scriptNotify)) {
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Units/CommandAI/CommandAI.cpp
Expand Up @@ -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);
Expand Down
23 changes: 10 additions & 13 deletions rts/Sim/Units/CommandAI/MobileCAI.cpp
Expand Up @@ -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()) {
Expand Down Expand Up @@ -433,11 +433,12 @@ void CMobileCAI::ExecuteLoadOnto(Command& c) {

if (!inCommand) {
inCommand = true;
// order transport to load <owner>; 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()); // <c> should still be in front
// queue might be empty after transport load-order
if (!commandQue.empty() && owner->GetTransporter() != nullptr) {
StopMoveAndFinishCommand();
return;
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1066,6 +1061,7 @@ void CMobileCAI::FinishCommand()
lastUserGoal = owner->pos;

tempOrder = false;

StopSlowGuard();
CCommandAI::FinishCommand();

Expand Down Expand Up @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion rts/Sim/Units/CommandAI/MobileCAI.h
Expand Up @@ -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;
Expand Down

0 comments on commit 3b1446a

Please sign in to comment.