X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=976974ac58891e6b9c8db2bab1c9057e876dac75;hb=8cef2a63b6c56ba086183693d3f73f02862cbd8f;hp=505e7457fa71d4f05cd03200b00994f72ac0e8a1;hpb=3abeab753b05c534b4061ad20a1de50a39da6daa;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 505e7457..976974ac 100644 --- a/src/events.c +++ b/src/events.c @@ -62,6 +62,21 @@ void EventLoop(void) break; } } + + HandleNoXEvent(); + + /* don't use all CPU time when idle; the main loop while playing + has its own synchronization and is CPU friendly, too */ + + if (game_status != PLAYING) + { + XSync(display, FALSE); + Delay(10); + } + + + +#if 0 else /* got no event, but don't be lazy... */ { HandleNoXEvent(); @@ -75,6 +90,9 @@ void EventLoop(void) Delay(10); } } +#endif + + if (game_status == EXITGAME) return; @@ -118,7 +136,7 @@ void ClearEventQueue() void SleepWhileUnmapped() { - BOOL window_unmapped = TRUE; + boolean window_unmapped = TRUE; XAutoRepeatOn(display); @@ -159,7 +177,7 @@ void HandleExposeEvent(XExposeEvent *event) int x = event->x, y = event->y; int width = event->width, height = event->height; - if (direct_draw_on && game_status==PLAYING) + if (setup.direct_draw_on && game_status==PLAYING) { int xx,yy; int x1 = (x-SX)/TILEX, y1 = (y-SY)/TILEY; @@ -176,7 +194,7 @@ void HandleExposeEvent(XExposeEvent *event) SetDrawtoField(DRAW_DIRECT); } - if (soft_scrolling_on && game_status == PLAYING) + if (setup.soft_scrolling_on && game_status == PLAYING) { int fx = FX, fy = FY; @@ -245,7 +263,7 @@ void HandleClientMessageEvent(XClientMessageEvent *event) { if ((event->window == window) && (event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE))) - CloseAll(); + CloseAllAndExit(0); } void HandleButton(int mx, int my, int button) @@ -314,7 +332,13 @@ void HandleButton(int mx, int my, int button) HandleSetupScreen(mx,my,0,0,button); break; case PLAYING: + + /* --> NoXEvent() will follow */ + + /* HandleGameActions(0); + */ + break; default: break; @@ -648,7 +672,7 @@ void HandleKey(KeySym key, int key_status) } */ - printf("direct_draw_on == %d\n", direct_draw_on); + printf("direct_draw_on == %d\n", setup.direct_draw_on); break; @@ -702,7 +726,8 @@ void HandleNoXEvent() return; } - HandleNetworking(); + if (options.network) + HandleNetworking(); switch(game_status) { @@ -730,11 +755,6 @@ void HandleJoystick() { int joystick = Joystick(); int keyboard = key_joystick_mapping; - - /* - int joy = (tape.playing ? TapePlayAction() : (joystick | keyboard)); - */ - int joy = (joystick | keyboard); int left = joy & JOY_LEFT; int right = joy & JOY_RIGHT; @@ -753,7 +773,7 @@ void HandleJoystick() { static long joystickmove_delay = 0; - if (joystick && !button && !DelayReached(&joystickmove_delay,15)) + if (joystick && !button && !DelayReached(&joystickmove_delay,150)) newbutton = dx = dy = 0; if (game_status==MAINMENU) @@ -788,7 +808,7 @@ void HandleJoystick() if (tape.pausing || AllPlayersGone) joy = 0; - HandleGameActions(joy); + HandleGameActions((byte)joy); break; default: