Skip to content

Commit

Permalink
Merge pull request #316 from redv/fix_vehicles_zombies
Browse files Browse the repository at this point in the history
fixed vehicles-zombies
  • Loading branch information
JonnyH committed Dec 22, 2017
2 parents ae86cc2 + 00ca29b commit 3c7e42e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
25 changes: 17 additions & 8 deletions game/state/gamestate.cpp
Expand Up @@ -1070,6 +1070,22 @@ bool GameState::canTurbo() const
return true;
}

/**
* Immediately remove all dead objects.
*/
void OpenApoc::GameState::cleanUpDeathNote()
{
// Any additional death notes should processed here.
if (!vehiclesDeathNote.empty())
{
for (auto &name : this->vehiclesDeathNote)
{
vehicles.erase(name);
}
vehiclesDeathNote.clear();
}
}

void GameState::update(unsigned int ticks)
{
if (this->current_battle)
Expand Down Expand Up @@ -1106,14 +1122,7 @@ void GameState::update(unsigned int ticks)
v.second->update(*this, ticks);
}
}
if (!vehiclesDeathNote.empty())
{
for (auto &name : this->vehiclesDeathNote)
{
vehicles.erase(name);
}
vehiclesDeathNote.clear();
}
cleanUpDeathNote();
Trace::end("GameState::update::vehicles");

Trace::start("GameState::update::agents");
Expand Down
2 changes: 2 additions & 0 deletions game/state/gamestate.h
Expand Up @@ -218,6 +218,8 @@ class GameState : public std::enable_shared_from_this<GameState>
// - there are any projectiles on the current map
bool canTurbo() const;

// Immediately remove all dead objects.
void cleanUpDeathNote();
// Update progress
void update(unsigned int ticks);
// updateTurbo progresses 5 minutes at a time - can only be called if canTurbo() returns true.
Expand Down
1 change: 1 addition & 0 deletions game/ui/base/transactionscreen.cpp
Expand Up @@ -1340,6 +1340,7 @@ void TransactionScreen::executeOrders()
player->balance += v.second;
}
}
state->cleanUpDeathNote();

// Step 03.02: If transfer then move stuff from negative to positive
if (mode == Mode::Transfer || needTransfer)
Expand Down

0 comments on commit 3c7e42e

Please sign in to comment.