Skip to content
Browse files

don't place persistent actors again for already loaded areas

Fixes CheckForReplacementActor spawning multiple copies of replaced
actors on area transition. Also truly delete replaced actors, and
fix an off-by-one error in the replacement loop.
  • Loading branch information...
1 parent 7f06f2c commit 245c5ee4bcd300b79124b7fd6790eb48bb7898b4 @fizzet fizzet committed May 7, 2013
Showing with 2 additions and 3 deletions.
  1. +2 −3 gemrb/core/Game.cpp
View
5 gemrb/core/Game.cpp
@@ -814,7 +814,7 @@ void Game::PlacePersistents(Map *newMap, const char *ResRef)
last = NPCs.size()-1;
for (i = 0; i < NPCs.size(); i++) {
if (stricmp( NPCs[i]->Area, ResRef ) == 0) {
- if (i < last && CheckForReplacementActor(i)) {
+ if (i <= last && CheckForReplacementActor(i)) {
i--;
last--;
continue;
@@ -840,7 +840,6 @@ int Game::LoadMap(const char* ResRef, bool loadscreen)
int index = FindMap(ResRef);
if (index>=0) {
- PlacePersistents(GetMap(index), ResRef);
return index;
}
@@ -929,7 +928,7 @@ bool Game::CheckForReplacementActor(int i)
} else {
newact->Pos = act->Pos; // the map is not loaded yet, so no SetPosition
CopyResRef(newact->Area, act->Area);
- DelNPC(InStore(act));
+ DelNPC(InStore(act), true);
return true;
}
}

0 comments on commit 245c5ee

Please sign in to comment.
Something went wrong with that request. Please try again.