X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=976974ac58891e6b9c8db2bab1c9057e876dac75;hb=338cfb1f6b043bdeaa0c77518b2a58b364ebc941;hp=e77b7510ea1c02ec2b30d74378ac34dc0cfc21ea;hpb=57562a0f29074feea1dc01ddf1b1d5e4e6d59730;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index e77b7510..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))) - game_status = EXITGAME; + 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)