1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-14 03:10:47 +00:00
freebsd-ports/games/xrally/files/patch-xrally-1.1.1
Edwin Groothuis af063d4788 Upgrade to version 1.1.1
01/12/2001
    There was a bug on XRally 1.1, that made the game use lots of
    CPU.  If you were having this problem, just download this patch
    and apply it to the source.
2005-06-12 03:41:48 +00:00

147 lines
3.9 KiB
Groff

--- menu.c 2001/01/01 18:49:16 1.22 XRALLY_1_1
+++ menu.c 2001/01/11 15:28:03 1.23 HEAD
@@ -5,7 +5,7 @@
copyright : (C) 2000 by Perdig
email : perdig@linuxbr.com.br
- $Id: menu.c,v 1.22 2001/01/01 18:49:16 perdig Exp $
+ $Id: menu.c,v 1.23 2001/01/11 15:28:03 perdig Exp $
***************************************************************************/
/***************************************************************************
@@ -25,7 +25,9 @@
#include "level.h"
#include "score.h"
#include "dirent.h"
+#ifdef USE_SOUND
#include "sound.h"
+#endif
#include "limits.h"
#include <stdio.h>
#include <string.h>
--- graphics.c 2000/12/07 12:44:10 1.15 XRALLY_1_1
+++ graphics.c 2001/01/11 15:28:03 1.16 HEAD
@@ -5,7 +5,7 @@
copyright : (C) 2000 by Perdig
email : perdig@linuxbr.com.br
- $Id: graphics.c,v 1.15 2000/12/07 12:44:10 perdig Exp $
+ $Id: graphics.c,v 1.16 2001/01/11 15:28:03 perdig Exp $
***************************************************************************/
/***************************************************************************
@@ -18,12 +18,13 @@
***************************************************************************/
#include "graphics.h"
#include "global.h"
+#include <unistd.h>
#include <sys/time.h>
// Internal functions
static char ** _split_text(const char *_txt);
-static int _check_event(XEvent *xev);
+static int _check_event(XEvent *xev, int blocking);
long time_diff(struct timeval *rt);
// Basic X11 variables
@@ -401,10 +402,15 @@
return double_buffer;
}
-static int _check_event(XEvent *xev) {
+static int _check_event(XEvent *xev, int blocking) {
XEvent *last = NULL;
+ int a = 0;
- while (XCheckMaskEvent(dpy, KeyPressMask | ExposureMask, xev)) {
+ do {
+ if (blocking)
+ XWindowEvent(dpy, win, KeyPressMask | ExposureMask, xev);
+ else
+ a = XCheckMaskEvent(dpy, KeyPressMask | ExposureMask, xev);
switch (xev->type) {
case KeyPress:
last = xev;
@@ -417,7 +423,7 @@
default:
break;
}
- }
+ } while ((blocking && !last) || (!blocking && a));
// No events
xev = last;
return (last) ? true : false;
@@ -426,32 +432,35 @@
KeySym check_key() {
XEvent xev;
- if (_check_event(&xev) && xev.type == KeyPress)
+ if (_check_event(&xev, 0) && xev.type == KeyPress)
return XLookupKeysym(&xev.xkey, 0);
// No events
return XK_VoidSymbol;
}
KeySym wait_key() {
- KeySym key = XK_VoidSymbol;
- while (key == XK_VoidSymbol) {
- key = check_key();
- }
- return key;
+ XEvent xev;
+ _check_event(&xev, 1);
+ return XLookupKeysym(&xev.xkey, 0);
}
void wait_time(long time_wait) {
- struct timeval it;
+ struct timeval it, tmp;
XEvent xev;
gettimeofday(&it, NULL);
- while (time_diff(&it) < time_wait)
- _check_event(&xev);
+ while (time_diff(&it) < time_wait) {
+ /* Reduce system load, sleeping for a while */
+ tmp.tv_sec = 0;
+ tmp.tv_usec = 1000;
+ select(0, NULL, NULL, NULL, &tmp);
+ _check_event(&xev, 0);
+ }
}
KeySym wait_char(char *str) {
KeySym key = XK_VoidSymbol;
XEvent xev;
- while (!_check_event(&xev) || xev.type != KeyPress);
+ _check_event(&xev, 1);
XLookupString(&xev.xkey, str, 3, &key, NULL);
return key;
}
--- global.h 2001/01/01 18:49:16 1.9 XRALLY_1_1
+++ global.h 2001/01/11 15:28:03 1.10
@@ -5,7 +5,7 @@
copyright : (C) 2000 by Perdig
email : perdig@linuxbr.com.br
- $Id: global.h,v 1.9 2001/01/01 18:49:16 perdig Exp $
+ $Id: global.h,v 1.10 2001/01/11 15:28:03 perdig Exp $
***************************************************************************/
/***************************************************************************
@@ -212,5 +212,14 @@
#define PLAYABLE
+
+#ifndef USE_SOUND
+#define sound_switch()
+#define sound_stop()
+#define sound_volume(a)
+#define sound_start()
+#define sound_select(a)
+#define sound_load(a)
+#endif
#endif