summaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-11-15 19:35:52 +0000
committerDarkvater <darkvater@openttd.org>2006-11-15 19:35:52 +0000
commit3a03b70319d432b76695d84b4342d1f441ea08b1 (patch)
treea33f8b2226bf03932b173095e369e476546d58ad /window.c
parent4a986e43d4c6e91fae4404d2c92125e6e8fa6cc2 (diff)
downloadopenttd-3a03b70319d432b76695d84b4342d1f441ea08b1.tar.xz
(svn r7153) -Fix [FS#279]: Some keyboard events possibly lost under high CPU load, handle
keyboard input in place instead of global variables magic. (KUDr)
Diffstat (limited to 'window.c')
-rw-r--r--window.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/window.c b/window.c
index 4f2a238f4..b2e91990b 100644
--- a/window.c
+++ b/window.c
@@ -1397,7 +1397,10 @@ void SendWindowMessageClass(WindowClass wnd_class, uint msg, uint wparam, uint l
}
}
-static void HandleKeypress(uint32 key)
+/** Handle keyboard input.
+ * @param key Lower 8 bits contain the ASCII character, the higher
+ * 16 bits the keycode */
+void HandleKeypress(uint32 key)
{
Window *w;
WindowEvent e;
@@ -1406,6 +1409,17 @@ static void HandleKeypress(uint32 key)
* to thein this main toolbar. */
bool query_open = false;
+ /*
+ * During the generation of the world, there might be
+ * another thread that is currently building for example
+ * a road. To not interfere with those tasks, we should
+ * NOT change the _current_player here.
+ *
+ * This is not necessary either, as the only events that
+ * can be handled are the 'close application' events
+ */
+ if (!IsGeneratingWorld()) _current_player = _local_player;
+
// Setup event
e.event = WE_KEYPRESS;
e.we.keypress.ascii = key & 0xFF;
@@ -1564,12 +1578,6 @@ void InputLoop(void)
*/
if (!IsGeneratingWorld()) _current_player = _local_player;
- // Handle pressed keys
- if (_pressed_key != 0) {
- HandleKeypress(_pressed_key);
- _pressed_key = 0;
- }
-
// Mouse event?
click = 0;
if (_left_button_down && !_left_button_clicked) {