changed:low cpu usage in menus -- fix send by: Chris E.

origin
stpohle 20 years ago
parent 93f60097c9
commit 862e347fd1

@ -1,4 +1,4 @@
/* $Id: sysfunc.h,v 1.6 2004/01/07 23:04:31 patty21 Exp $ */
/* $Id: sysfunc.h,v 1.7 2005/08/07 17:46:20 stpohle Exp $ */
/* include some system near functions */
#ifndef _SYSFUNC_H_
@ -26,6 +26,7 @@ struct __direntry {
} typedef _direntry;
extern void s_delay (int ms);
extern int s_fetchevent (SDL_Event *event);
extern int s_random (int maxnr);
extern char *s_gethomedir ();
extern int s_countbits (int nbomb, int nr);

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.112 2005/07/06 13:11:55 stpohle Exp $
/* $Id: game.c,v 1.113 2005/08/07 17:46:21 stpohle Exp $
game.c - procedures for the game. */
#include <string.h>
@ -257,7 +257,7 @@ game_loop ()
}
while (!done && (bman.state == GS_running || bman.state == GS_ready)) {
if ((eventstate = SDL_PollEvent (&event)) != 0)
if ((eventstate = s_fetchevent (&event)) != 0)
switch (event.type) {
case (SDL_QUIT):
done = 1;
@ -884,7 +884,7 @@ game_showresult ()
while (!done && bman.state != GS_quit) {
/* do the keyboard handling */
if (SDL_PollEvent (&event) != 0)
if (s_fetchevent (&event) != 0)
switch (event.type) {
case (SDL_QUIT):
bman.state = GS_quit;

@ -1,4 +1,4 @@
/* $Id: keyb.c,v 1.5 2004/09/13 22:15:57 stpohle Exp $
/* $Id: keyb.c,v 1.6 2005/08/07 17:46:21 stpohle Exp $
* keyb.c
*/
@ -202,7 +202,7 @@ void keyb_config_readkey (int key) {
reorder = 0;
}
eventstate = SDL_PollEvent (&event);
eventstate = s_fetchevent (&event);
if (eventstate >= 1) {
switch (event.type) {

@ -1,4 +1,4 @@
/* $Id: mapmenu.c,v 1.25 2004/12/13 21:29:31 stpohle Exp $ */
/* $Id: mapmenu.c,v 1.26 2005/08/07 17:46:21 stpohle Exp $ */
/* map/tileset selection menu */
#include "bomberclone.h"
@ -298,7 +298,7 @@ mapinfo ()
while (!done && bman.state == GS_wait) {
if (GT_MP && bman.sock != -1) {
network_loop ();
eventstate = SDL_PollEvent (&event);
eventstate = s_fetchevent (&event);
}
else
eventstate = SDL_WaitEvent (&event);

@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.50 2005/03/27 01:31:50 stpohle Exp $
/* $Id: menu.c,v 1.51 2005/08/07 17:46:21 stpohle Exp $
* Menuhandling */
#include "basic.h"
@ -538,7 +538,7 @@ menu_loop (_menu * menu)
reorder = 0;
}
eventstate = SDL_PollEvent (&event);
eventstate = s_fetchevent (&event);
done = menu_event_loop (menu, &event, eventstate);

@ -1,4 +1,4 @@
/* $Id: multiwait.c,v 1.56 2005/07/06 13:11:55 stpohle Exp $
/* $Id: multiwait.c,v 1.57 2005/08/07 17:46:21 stpohle Exp $
multiwait.c - this manages only the network screen where
everyone have to select it's players and where even the basic chat is inside
*/
@ -220,7 +220,7 @@ void wait_for_players () {
mw_init ();
do {
if (SDL_PollEvent (&event) != 0)
if (s_fetchevent (&event) != 0)
switch (event.type) {
case (SDL_QUIT):
bman.state = GS_quit;

@ -1,4 +1,4 @@
/* $Id: netsrvlist.c,v 1.16 2005/04/10 03:28:02 stpohle Exp $
/* $Id: netsrvlist.c,v 1.17 2005/08/07 17:46:21 stpohle Exp $
* netsrvlist.c - shows a list of possible servers.*/
#include "basic.h"
@ -157,7 +157,7 @@ void net_getserver () {
menu_draw (menu);
}
eventstate = SDL_PollEvent (&event);
eventstate = s_fetchevent (&event);
gfx_blitdraw ();
done = menu_event_loop (menu, &event, eventstate);

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.75 2005/07/06 13:11:56 stpohle Exp $ */
/* $Id: network.c,v 1.76 2005/08/07 17:46:21 stpohle Exp $ */
/*
network routines.
*/
@ -615,7 +615,7 @@ net_transmit_gamedata ()
/* do the grafik work */
draw_netupdatestate (0);
if (SDL_PollEvent (&event) != 0)
if (s_fetchevent (&event) != 0)
switch (event.type) {
case (SDL_QUIT):
bman.state = GS_quit;

@ -1,4 +1,4 @@
/* $Id: playermenu.c,v 1.17 2005/07/06 13:11:56 stpohle Exp $
/* $Id: playermenu.c,v 1.18 2005/08/07 17:46:21 stpohle Exp $
*/
#include "bomberclone.h"
@ -128,7 +128,7 @@ int playermenu_selgfx (int pl_nr) {
ogc_loop ();
}
eventstate = SDL_PollEvent (&event);
eventstate = s_fetchevent (&event);
if (eventstate) {
switch (event.type) {
@ -300,7 +300,7 @@ void playermenu () {
detail_Addr->changed = 1;
detail_Flags->changed = 1;
eventstate = SDL_PollEvent (&event);
eventstate = s_fetchevent (&event);
if (bman.sock != -1)
network_loop ();

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.84 2005/02/14 20:09:19 stpohle Exp $ */
/* $Id: single.c,v 1.85 2005/08/07 17:46:21 stpohle Exp $ */
/* single player */
#include "basic.h"
@ -744,7 +744,7 @@ single_menu ()
do {
gfx_blitdraw ();
eventstate = SDL_PollEvent (&event);
eventstate = s_fetchevent (&event);
done = menu_event_loop (menu, &event, eventstate);

@ -1,4 +1,4 @@
/* $Id: sysfunc.c,v 1.24 2005/04/08 00:18:29 stpohle Exp $
/* $Id: sysfunc.c,v 1.25 2005/08/07 17:46:22 stpohle Exp $
sysfunc.c - this file hold some routines for the system functions..
like d_delay
*/
@ -27,6 +27,16 @@ s_delay (int ms)
};
int
s_fetchevent (SDL_Event *event)
{
if (SDL_PollEvent (event))
return 1;
s_delay (20);
return 0;
}
int
s_random (int maxnr)
{

Loading…
Cancel
Save