mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
AGS: Engine: force clear event queue in processallevents()
Was broken by a2f9a5b, then tried to fix by 6a71d85, but not fully fixed still. From upstream cbaeff15229bb81828d418ed71a11dfe0b30e6fd
This commit is contained in:
parent
c3589db569
commit
12e4bb39fa
@ -351,25 +351,25 @@ void processallevents() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Take ownership of the pending events
|
||||
// Note: upstream AGS used std::move, which I haven't been able
|
||||
// to properly implement in ScummVM. Luckily, our events are
|
||||
// a pointer, so I could get the same result swapping them
|
||||
std::vector<EventHappened> *evtCopy = new std::vector<EventHappened>();
|
||||
SWAP(evtCopy, _G(events));
|
||||
// Make a copy of the events to process them safely.
|
||||
// WARNING: engine may actually add more events to the global events array,
|
||||
// and they must NOT be processed here, but instead discarded at the end
|
||||
// of this function; otherwise game may glitch.
|
||||
// TODO: need to redesign engine events system?
|
||||
std::vector<EventHappened> evtCopy = _GP(events);
|
||||
|
||||
int room_was = _GP(play).room_changes;
|
||||
|
||||
_G(inside_processevent)++;
|
||||
|
||||
for (size_t i = 0; i < evtCopy->size() && !_G(abort_engine); ++i) {
|
||||
process_event(&(*evtCopy)[i]);
|
||||
for (size_t i = 0; i < evtCopy.size() && !_G(abort_engine); ++i) {
|
||||
process_event(&evtCopy[i]);
|
||||
|
||||
if (room_was != _GP(play).room_changes)
|
||||
break; // changed room, so discard other events
|
||||
}
|
||||
|
||||
delete evtCopy;
|
||||
_GP(events).clear();
|
||||
_G(inside_processevent)--;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user