Fix timed out buffs not calling onExpire

This commit is contained in:
gsemaj 2022-07-19 09:14:38 -07:00 committed by gsemaj
parent 0c5a9400ce
commit eb7daf8eaa
No known key found for this signature in database
GPG Key ID: 24B96BAA40497929

View File

@ -12,8 +12,12 @@ void Buff::tick() {
if(stack.durationTicks > 0) stack.durationTicks--; if(stack.durationTicks > 0) stack.durationTicks--;
if(stack.durationTicks == 0) { if(stack.durationTicks == 0) {
// erase() destroys the callbacks
// with the stack struct, so we need
// to copy it first.
BuffStack deadStack = stack;
it = stacks.erase(it); it = stacks.erase(it);
if(stack.onExpire) stack.onExpire(self, &stack); if(deadStack.onExpire) deadStack.onExpire(self, &deadStack);
} else it++; } else it++;
} }
} }