Skip to content

Commit

Permalink
Fix bug in unregisterCreatureEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
marksamman committed Apr 3, 2015
1 parent 95b9cfb commit fb0d05e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,19 +1495,24 @@ bool Creature::unregisterCreatureEvent(const std::string& name)
}

bool resetTypeBit = true;
for (auto it = eventsList.begin(); it != eventsList.end(); ++it) {

auto it = eventsList.begin();
while (it != eventsList.end()) {
CreatureEvent* curEvent = *it;
if (curEvent == event) {
it = eventsList.erase(it);
} else if (curEvent->getEventType() == type) {
continue;
}

if (curEvent->getEventType() == type) {
resetTypeBit = false;
}
++it;
}

if (resetTypeBit) {
scriptEventsBitField &= ~(static_cast<uint32_t>(1) << type);
}

return true;
}

Expand Down

0 comments on commit fb0d05e

Please sign in to comment.