EMI: Fix VisibleActors crash with free'd actor

This commit is contained in:
Dries Harnie 2012-08-07 00:21:27 +02:00
parent e31fbe6182
commit 1551775b63
4 changed files with 8 additions and 1 deletions

View File

@ -1252,7 +1252,7 @@ bool Actor::updateTalk(uint frameTime) {
if (m == GrimEngine::TextOnly && !textObject) {
shutUp();
return false;
} else if (m != GrimEngine::TextOnly && (strlen(_talkSoundName.c_str()) == 0 || !g_sound->getSoundStatus(_talkSoundName.c_str()))) {
} else if (m != GrimEngine::TextOnly && (_talkSoundName.empty() || !g_sound->getSoundStatus(_talkSoundName.c_str()))) {
_talkDelay -= frameTime;
if (_talkDelay <= 0) {
_talkDelay = 0;

View File

@ -111,6 +111,7 @@ void Lua_V2::UnloadActor() {
// This should be safe.
delete actor;
g_grim->invalidateActiveActorsList();
g_grim->immediatelyRemoveActor(actor);
}
void Lua_V2::SetActorWalkRate() {

View File

@ -1071,6 +1071,11 @@ void GrimEngine::invalidateActiveActorsList() {
_buildActiveActorsList = true;
}
void GrimEngine::immediatelyRemoveActor(Actor *actor) {
_activeActors.remove(actor);
_talkingActors.remove(actor);
}
void GrimEngine::buildActiveActorsList() {
if (!_buildActiveActorsList) {
return;

View File

@ -162,6 +162,7 @@ public:
*/
void addTalkingActor(Actor *actor);
bool areActorsTalking() const;
void immediatelyRemoveActor(Actor *actor);
void setMovieSubtitle(TextObject *to);