mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-05 17:20:30 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take ownership of the pending events
|
// Make a copy of the events to process them safely.
|
||||||
// Note: upstream AGS used std::move, which I haven't been able
|
// WARNING: engine may actually add more events to the global events array,
|
||||||
// to properly implement in ScummVM. Luckily, our events are
|
// and they must NOT be processed here, but instead discarded at the end
|
||||||
// a pointer, so I could get the same result swapping them
|
// of this function; otherwise game may glitch.
|
||||||
std::vector<EventHappened> *evtCopy = new std::vector<EventHappened>();
|
// TODO: need to redesign engine events system?
|
||||||
SWAP(evtCopy, _G(events));
|
std::vector<EventHappened> evtCopy = _GP(events);
|
||||||
|
|
||||||
int room_was = _GP(play).room_changes;
|
int room_was = _GP(play).room_changes;
|
||||||
|
|
||||||
_G(inside_processevent)++;
|
_G(inside_processevent)++;
|
||||||
|
|
||||||
for (size_t i = 0; i < evtCopy->size() && !_G(abort_engine); ++i) {
|
for (size_t i = 0; i < evtCopy.size() && !_G(abort_engine); ++i) {
|
||||||
process_event(&(*evtCopy)[i]);
|
process_event(&evtCopy[i]);
|
||||||
|
|
||||||
if (room_was != _GP(play).room_changes)
|
if (room_was != _GP(play).room_changes)
|
||||||
break; // changed room, so discard other events
|
break; // changed room, so discard other events
|
||||||
}
|
}
|
||||||
|
|
||||||
delete evtCopy;
|
_GP(events).clear();
|
||||||
_G(inside_processevent)--;
|
_G(inside_processevent)--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user