try to clean up a bit better

This commit is contained in:
Tim Felgentreff 2022-02-02 14:00:52 +01:00
parent 2b5b820bab
commit 4b21fc9306
3 changed files with 6 additions and 2 deletions

View file

@ -94,8 +94,8 @@ void CPlayer::Load(lua_State *l)
{
const int args = lua_gettop(l);
this->Units.resize(0);
this->FreeWorkers.resize(0);
this->Units.clear();
this->FreeWorkers.clear();
// j = 0 represent player Index.
for (int j = 1; j < args; ++j) {

View file

@ -491,6 +491,9 @@ void CUnit::Release(bool final)
DebugPrint("unit already free\n");
return;
}
if (PlayerSlot != static_cast<size_t>(-1)) {
Player->RemoveUnit(*this);
}
Assert(Orders.size() == 1);
// Must be removed before here
Assert(Removed);

View file

@ -120,6 +120,7 @@ void CUnitManager::ReleaseUnit(CUnit *unit)
unit->UnitManagerData.unitSlot = -1;
units.pop_back();
}
Assert(unit->PlayerSlot == -1);
releasedUnits.push_back(unit);
unit->ReleaseCycle = GameCycle + 500; // can be reused after this time
//Refs = GameCycle + (NetworkMaxLag << 1); // could be reuse after this time