Skip to content

Commit fe78186

Browse files
committed
[Fix] Fix crash when moving unit on stealth unit
but moving unit stops :-(
1 parent 2c0f745 commit fe78186

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/lib/game/data/model.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,10 @@ void cModel::refreshMapPointer()
597597
//------------------------------------------------------------------------------
598598
void cModel::runMoveJobs()
599599
{
600-
for (auto& moveJob : moveJobs)
600+
for (std::size_t i = 0; i != moveJobs.size(); ++i)
601601
{
602-
moveJob->run (*this); //this can add new items to 'moveJobs'
602+
moveJobs[i]->run (*this); // this can add new items to 'moveJobs'
603+
auto& moveJob = moveJobs[i];
603604
if (moveJob->isFinished())
604605
{
605606
cVehicle* vehicle = moveJob->getVehicleId() ? getVehicleFromID (*moveJob->getVehicleId()) : nullptr;
@@ -836,8 +837,10 @@ void cModel::sideStepStealthUnit (const cPosition& position, const cStaticUnitDa
836837
{
837838
std::forward_list<cPosition> path;
838839
path.push_front (*bestPosition);
839-
auto moveJob = addMoveJob (*stealthVehicle, path);
840-
moveJob->resume();
840+
if (auto moveJob = addMoveJob (*stealthVehicle, path))
841+
{
842+
moveJob->resume();
843+
}
841844
return;
842845
}
843846

0 commit comments

Comments
 (0)