diff options
author | Paul Gilbert | 2011-07-02 22:26:40 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-07-02 22:26:40 +1000 |
commit | f150126a0b209418d3a91ec5b5f1c1c0fdced9c7 (patch) | |
tree | 00274682e1af4580894ff37cdd6b5d0c9bdcb231 | |
parent | d510d2505b7c9e4968020de6926dea19cfb7fa34 (diff) | |
download | scummvm-rg350-f150126a0b209418d3a91ec5b5f1c1c0fdced9c7.tar.gz scummvm-rg350-f150126a0b209418d3a91ec5b5f1c1c0fdced9c7.tar.bz2 scummvm-rg350-f150126a0b209418d3a91ec5b5f1c1c0fdced9c7.zip |
CGE: Bugfix for wrapping event queue when it reaches the 256th event
-rw-r--r-- | engines/cge/events.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 99ada03bd5..2b9cc7fc6c 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -33,6 +33,10 @@ namespace CGE { +CGEEvent Evt[EVT_MAX]; + +uint16 EvtHead = 0, EvtTail = 0; + /*----------------- KEYBOARD interface -----------------*/ const uint16 Keyboard::_code[0x60] = { @@ -126,7 +130,8 @@ void Keyboard::NewKeyboard(Common::Event &event) { _current = Keyboard::_code[event.kbd.keycode]; if (_client) { - CGEEvent &evt = Evt[EvtHead++]; + CGEEvent &evt = Evt[EvtHead]; + EvtHead = (EvtHead + 1) % EVT_MAX; evt._x = _current; // Keycode evt._msk = KEYB; // Event mask evt._ptr = _client; // Sprite pointer @@ -136,10 +141,6 @@ void Keyboard::NewKeyboard(Common::Event &event) { /*----------------- MOUSE interface -----------------*/ -CGEEvent Evt[EVT_MAX]; - -uint16 EvtHead = 0, EvtTail = 0; - MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) { static Seq ms[] = { { 0, 0, 0, 0, 1 }, @@ -195,7 +196,8 @@ void MOUSE::NewMouse(Common::Event &event) { if (!_active) return; - CGEEvent &evt = Evt[EvtHead++]; + CGEEvent &evt = Evt[EvtHead]; + EvtHead = (EvtHead + 1) % EVT_MAX; evt._x = event.mouse.x; evt._y = event.mouse.y; evt._ptr = SpriteAt(evt._x, evt._y); |