when assigning a unit to a player, remove it from the previous owner (if there is one)
This commit is contained in:
parent
4abc6041a5
commit
696e8bccd7
1 changed files with 7 additions and 1 deletions
|
@ -825,7 +825,13 @@ void CPlayer::Clear()
|
|||
|
||||
void CPlayer::AddUnit(CUnit &unit)
|
||||
{
|
||||
Assert(unit.Player != this);
|
||||
if (unit.Player == this) {
|
||||
return;
|
||||
}
|
||||
if (unit.PlayerSlot != static_cast<size_t>(-1)) {
|
||||
// unit is registered with another player
|
||||
unit.Player->RemoveUnit(unit);
|
||||
}
|
||||
Assert(unit.PlayerSlot == static_cast<size_t>(-1));
|
||||
unit.PlayerSlot = this->Units.size();
|
||||
this->Units.push_back(&unit);
|
||||
|
|
Loading…
Add table
Reference in a new issue