Skip to content

Commit

Permalink
fix #2127
Browse files Browse the repository at this point in the history
  • Loading branch information
rt committed Mar 13, 2018
1 parent 5fcac17 commit 498c5fa
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions rts/Sim/Units/CommandAI/MobileCAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,32 +449,34 @@ void CMobileCAI::ExecuteMove(Command& c)
}

void CMobileCAI::ExecuteLoadOnto(Command& c) {
CUnit* unit = unitHandler.GetUnit(c.params[0]);
CUnit* transport = unitHandler.GetUnit(c.params[0]);

if (unit == nullptr || !unit->unitDef->IsTransportUnit()) {
if (transport == nullptr) {
StopMoveAndFinishCommand();
return;
}

// prevent <owner> from chasing after full transports, etc
if (!transport->unitDef->IsTransportUnit() || !transport->CanTransport(owner)) {
StopMoveAndFinishCommand();
return;
}

if (!inCommand) {
inCommand = true;
Command newCommand(CMD_LOAD_UNITS, INTERNAL_ORDER | SHIFT_KEY, owner->id);
unit->commandAI->GiveCommandReal(newCommand);
transport->commandAI->GiveCommandReal(Command(CMD_LOAD_UNITS, INTERNAL_ORDER | SHIFT_KEY, owner->id));
}
if (owner->GetTransporter() != nullptr) {
if (!commandQue.empty())
StopMoveAndFinishCommand();

if (owner->GetTransporter() != nullptr) {
assert(!commandQue.empty()); // <c> should still be in front
StopMoveAndFinishCommand();
return;
}

if (unit == nullptr)
return;

if ((owner->pos - unit->pos).SqLength2D() < cancelDistance) {
if ((owner->pos - transport->pos).SqLength2D() < cancelDistance) {
StopMove();
} else {
SetGoal(unit->pos, owner->pos);
SetGoal(transport->pos, owner->pos);
}
}

Expand Down

0 comments on commit 498c5fa

Please sign in to comment.