MENU_entryint* changed for 16bit ints and 32bit ints.. Timeout fixed in the game.. and should work now fine.

origin
stpohle 22 years ago
parent 2ad9ea4271
commit 27726ec2a3

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.9 2003/12/24 02:38:15 stpohle Exp $ */ /* $Id: basic.h,v 1.10 2003/12/28 01:21:42 stpohle Exp $ */
/* basic types which we need everywhere */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -14,8 +14,8 @@
#define GAME_SPECIAL_ITEMSROW 3 #define GAME_SPECIAL_ITEMSROW 3
#define GAME_SPECIAL_ITEMSPUSH 3 #define GAME_SPECIAL_ITEMSPUSH 3
#define GAME_MAX_TUNNELS 4 // number of tunnel entrys #define GAME_MAX_TUNNELS 4 // number of tunnel entrys
#define GAME_TIMEOUT 30000 // game timeout 10min) #define GAME_TIMEOUT 600.0 // game timeout 10min)
#define GAME_TIMEOUTHURRY 3000 // game timeout for hurry and dropping mode (1min) #define GAME_OVERTIMEOUT 5.0 // second of remaining the last player
#define GAME_TUNNEL_TO 0.5 // wait 0.5 seconds #define GAME_TUNNEL_TO 0.5 // wait 0.5 seconds
#define EXPLOSION_SAVE_DISTANCE 0.25 #define EXPLOSION_SAVE_DISTANCE 0.25

@ -1,9 +1,17 @@
/* $Id: map.h,v 1.5 2003/11/08 20:14:31 stpohle Exp $ */ /* $Id: map.h,v 1.6 2003/12/28 01:21:42 stpohle Exp $ */
/* map.h */ /* map.h */
#ifndef _MAP_H_ #ifndef _MAP_H_
#define _MAP_H_ #define _MAP_H_
#define FIELDCHECK_TIMEOUT 2.0 /* timeout for the field check function */
#define FIELDHURRYWARN 5.0 /* hurry warning */
#define FIELDHURRYDROPTO 0.5 /* timeout when to put in some special items */
#define FIELDHURRYSIZE 0.25 /* timeout forresizeing the game */
#define FIELDHURRYSIZEMIN 5 /* min size for the field */
#define FIELDHURRYTIMEOUT 120.0 // game timeout for hurry and dropping mode (1min)
struct __ex_field { struct __ex_field {
unsigned char count; unsigned char count;
float frame; float frame;
@ -32,14 +40,14 @@ struct __map {
char map [LEN_PATHFILENAME]; char map [LEN_PATHFILENAME];
signed char map_selection; signed char map_selection;
signed char type; // type of the map (MAPT_*); signed char type; // type of the map (MAPT_*);
unsigned char bombs; int bombs;
unsigned char fire; int fire;
unsigned char shoes; int shoes;
unsigned char mixed; int mixed;
unsigned char death; int death;
unsigned char sp_trigger; int sp_trigger;
unsigned char sp_push; int sp_push;
unsigned char sp_row; int sp_row;
unsigned char state; // state of the map unsigned char state; // state of the map
} typedef _map; } typedef _map;

@ -1,4 +1,4 @@
/* $Id: menu.h,v 1.1 2003/12/24 02:42:05 stpohle Exp $ /* $Id: menu.h,v 1.2 2003/12/28 01:21:42 stpohle Exp $
* GUI for menuhandling * GUI for menuhandling
*/ */
@ -21,7 +21,8 @@ enum _menu_type {
MENU_label = 0, MENU_label = 0,
MENU_button, MENU_button,
MENU_entrytext, MENU_entrytext,
MENU_entryint, MENU_entryint32,
MENU_entryint16,
MENU_entryfloat, MENU_entryfloat,
MENU_bool, MENU_bool,
MENU_list MENU_list

@ -1,19 +1,14 @@
/* $Id: field.c,v 1.50 2003/11/08 20:14:32 stpohle Exp $ */ /* $Id: field.c,v 1.51 2003/12/28 01:21:43 stpohle Exp $ */
/* field.c - procedures which are needed to control the field */ /* field.c - procedures which are needed to control the field */
#include "bomberclone.h" #include "bomberclone.h"
#include "map.h"
#define FIELDECHECK_TIMEOUT 500 /* timeout for the field check function */
#define FIELDHURRYWARN 500 /* hurry warning */
#define FIELDHURRYDROPTO 50 /* timeout when to put in some special items */
#define FIELDHURRYSIZE 25 /* timeout when to put in some special items */
#define FIELDHURRYSIZEMIN 5 /* min size for the field */
static _point fieldani[MAX_FIELDANIMATION]; static _point fieldani[MAX_FIELDANIMATION];
static _point stonelist[MAX_STONESTODRAW]; // keep all stones to draw static _point stonelist[MAX_STONESTODRAW]; // keep all stones to draw
static int fieldcheck_to; // timeout for the next fieldcheck FIELDCHECK_TIMEOUT static float fieldcheck_to; // timeout for the next fieldcheck FIELDCHECK_TIMEOUT
static int fieldhurry_to; static float fieldhurry_to; // in warning mode set the blinking time
static _point fieldhurrypos; // x,y for the hurry static _point fieldhurrypos; // x,y for the hurry
static int fieldhurryd; // direction for the hurry static int fieldhurryd; // direction for the hurry
@ -336,24 +331,28 @@ field_loop ()
if ((GT_MP_PTPM || GT_SP) && bman.state == GS_running) { if ((GT_MP_PTPM || GT_SP) && bman.state == GS_running) {
/* timeout for rechecking every 5 secs the field */ /* timeout for rechecking every 5 secs the field */
fieldcheck_to -= timediff;
if (map.state == MS_normal && map.map_selection == MAPS_randgen if (map.state == MS_normal && map.map_selection == MAPS_randgen
&& (fieldcheck_to-- > FIELDECHECK_TIMEOUT || fieldcheck_to <= 0)) { && (fieldcheck_to > FIELDCHECK_TIMEOUT || fieldcheck_to <= 0)
&& bman.timeout > FIELDHURRYTIMEOUT) {
if (field_checkisempty ()) if (field_checkisempty ())
bman.timeout = 0; // set the gametimeout to 0 bman.timeout = FIELDHURRYTIMEOUT; // let the hurry time begin
fieldcheck_to = FIELDCHECK_TIMEOUT;
} }
/* to show the warning */ /* set the map_state to the right setting and send the information to all clients */
if (map.state == MS_normal && bman.timeout-- <= 0) { if (map.state == MS_normal
bman.timeout = FIELDHURRYWARN; && bman.timeout <= FIELDHURRYTIMEOUT
&& bman.timeout > (FIELDHURRYTIMEOUT-FIELDHURRYWARN)) {
map.state = MS_hurrywarn; map.state = MS_hurrywarn;
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
if (GT_MP_PTPM) if (GT_MP_PTPM)
net_send_servermode (); net_send_servermode ();
} }
/* gametimeout is 0 and we are still at more normal set randomly a /* after the end of the warning set the new flag */
way to end the game */ if (map.state == MS_hurrywarn
if (bman.timeout-- <= 0 && map.state == MS_hurrywarn) { && bman.timeout <= (FIELDHURRYTIMEOUT-FIELDHURRYWARN)) {
int rndmax; int rndmax;
if (map.map_selection == MAPS_randgen) if (map.map_selection == MAPS_randgen)
@ -363,9 +362,11 @@ field_loop ()
map.state = 2 + s_random (rndmax); map.state = 2 + s_random (rndmax);
d_printf ("Game Timeout 1 over: Random map.state = %d\n", map.state); d_printf ("Game Timeout 1 over: Random map.state = %d\n", map.state);
bman.timeout = GAME_TIMEOUTHURRY;
fieldhurrypos.x = fieldhurrypos.y = 0; fieldhurrypos.x = fieldhurrypos.y = 0;
if (GT_MP_PTPM)
net_send_servermode ();
} }
/* check if we need to small down the map */ /* check if we need to small down the map */
@ -387,7 +388,9 @@ field_hurrydropitems ()
y = 0, y = 0,
try = 100; try = 100;
if (fieldhurry_to-- <= 0 || fieldhurry_to > FIELDHURRYDROPTO) { fieldhurry_to -= timediff;
if (fieldhurry_to <= 0 || fieldhurry_to > FIELDHURRYDROPTO) {
fieldhurry_to = FIELDHURRYDROPTO; fieldhurry_to = FIELDHURRYDROPTO;
while (map.field[x][y].type != FT_nothing && (try--)) { while (map.field[x][y].type != FT_nothing && (try--)) {
@ -413,7 +416,8 @@ field_hurrysize ()
int i; int i;
_point old; _point old;
if (fieldhurry_to-- <= 0 || fieldhurry_to > FIELDHURRYSIZE) { fieldhurry_to -= timediff;
if (fieldhurry_to <= 0 || fieldhurry_to > FIELDHURRYSIZE) {
fieldhurry_to = FIELDHURRYSIZE; fieldhurry_to = FIELDHURRYSIZE;
if (fieldhurrypos.x == 0) { if (fieldhurrypos.x == 0) {
@ -421,7 +425,6 @@ field_hurrysize ()
fieldhurryd = right; fieldhurryd = right;
} }
else if (fieldhurrypos.x > 0) { else if (fieldhurrypos.x > 0) {
bman.timeout = GAME_TIMEOUTHURRY-1;
old = fieldhurrypos; /* save old value in case that there old = fieldhurrypos; /* save old value in case that there
is an explosion or a bomb */ is an explosion or a bomb */
switch (fieldhurryd) { switch (fieldhurryd) {

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.61 2003/12/24 02:38:15 stpohle Exp $ /* $Id: game.c,v 1.62 2003/12/28 01:21:43 stpohle Exp $
game.c - procedures for the game. */ game.c - procedures for the game. */
#include <string.h> #include <string.h>
@ -117,8 +117,6 @@ game_loop ()
SDL_Event event; SDL_Event event;
Uint8 *keys; Uint8 *keys;
int done = 0; int done = 0;
// Uint32 timeloop1;
float gameovertimeout = 5.0; // gameovertimeout
unsigned char key_bomb = 0; // last state of the bomb key unsigned char key_bomb = 0; // last state of the bomb key
gfx_blitupdaterectclear (); gfx_blitupdaterectclear ();
@ -203,11 +201,10 @@ game_loop ()
if ((players[bman.p_nr].state & PSFM_alife) == PSFM_alife) if ((players[bman.p_nr].state & PSFM_alife) == PSFM_alife)
move_player (bman.p_nr); move_player (bman.p_nr);
if (GT_MP) if (GT_MP) {
player_calcpos (); player_calcpos ();
if (GT_MP)
network_loop (); network_loop ();
}
if (bman.state == GS_running) if (bman.state == GS_running)
single_loop (); single_loop ();
@ -221,21 +218,21 @@ game_loop ()
/* check if there is only one player left and the game is in multiplayer mode /* check if there is only one player left and the game is in multiplayer mode
and if there the last dieing animation is done */ and if there the last dieing animation is done */
if ((bman.players_nr < 2 if (((bman.players_nr < 2
&& (GT_MP || (GT_SP && bman.ai_players > 0))) && (GT_MP || (GT_SP && bman.ai_players > 0)))
|| (GT_SP && bman.ai_players == 0 && bman.players_nr < 1) || (GT_SP && bman.ai_players == 0 && bman.players_nr < 1))
|| (bman.timeout <= 0.0f && map.state != MS_normal)) && bman.timeout >= 0.0)
gameovertimeout -= timediff; bman.timeout = 0.0f;
if (gameovertimeout <= 0) { if (bman.timeout < -GAME_OVERTIMEOUT) {
d_printf ("GAME: Game Over\n"); d_printf ("GAME: Game Over\n");
done = 1; done = 1;
} }
stonelist_draw (); stonelist_draw ();
gfx_blitdraw (); gfx_blitdraw ();
s_calctimesync (); s_calctimesync ();
bman.timeout -= timediff;
} }
chat_show (-1, -1, -1, -1); chat_show (-1, -1, -1, -1);
@ -245,7 +242,7 @@ game_loop ()
}; };
/* check which player won and unload all data */ /* check which player won and free all unnneded data */
void void
game_end () game_end ()
{ {
@ -337,6 +334,8 @@ game_start ()
snd_music_start (); snd_music_start ();
map.state = MS_normal; map.state = MS_normal;
bman.timeout = bman.init_timeout; bman.timeout = bman.init_timeout;
s_calctimesync (); /* to clean up the timesyc
s_calctimesync (); * data run this twice */
}; };

@ -1,4 +1,4 @@
/* $Id: mapmenu.c,v 1.14 2003/12/26 02:20:10 stpohle Exp $ */ /* $Id: mapmenu.c,v 1.15 2003/12/28 01:21:43 stpohle Exp $ */
/* map/tileset selection menu */ /* map/tileset selection menu */
#include "bomberclone.h" #include "bomberclone.h"
@ -50,9 +50,9 @@ mapmenu ()
case (MAPS_randgen): // Random Generated Map case (MAPS_randgen): // Random Generated Map
selmt = charlist_findtext (maptypes, "autogenerated"); selmt = charlist_findtext (maptypes, "autogenerated");
d_printf ("autogen\n"); d_printf ("autogen\n");
menu_create_entry ("X Size:", 20, 160, 120, &map.size.x, MAX_FIELDSIZE_X, MENU_entryint, menu_create_entry ("X Size:", 20, 160, 120, &map.size.x, MAX_FIELDSIZE_X, MENU_entryint16,
2); 2);
menu_create_entry ("Y Size:", 20, 180, 120, &map.size.y, MAX_FIELDSIZE_Y, MENU_entryint, menu_create_entry ("Y Size:", 20, 180, 120, &map.size.y, MAX_FIELDSIZE_Y, MENU_entryint16,
3); 3);
break; break;
} }
@ -88,17 +88,17 @@ mapmenu ()
menu_create_list ("ts", 250, 85, 170, 40, tiletypes, &selts, 4); menu_create_list ("ts", 250, 85, 170, 40, tiletypes, &selts, 4);
menu_create_list ("tt", 10, 220, 100, 60, tunneltypes, &seltt, 6); menu_create_list ("tt", 10, 220, 100, 60, tunneltypes, &seltt, 6);
menu_create_entry ("Bombs:", 140, 240, 110, &map.bombs, 100, MENU_entryint, 7); menu_create_entry ("Bombs:", 140, 240, 110, &map.bombs, 100, MENU_entryint32, 7);
menu_create_entry ("Fire: ", 140, 260, 110, &map.fire, 100, MENU_entryint, 8); menu_create_entry ("Fire: ", 140, 260, 110, &map.fire, 100, MENU_entryint32, 8);
menu_create_entry ("Shoes:", 140, 280, 110, &map.shoes, 100, MENU_entryint, 9); menu_create_entry ("Shoes:", 140, 280, 110, &map.shoes, 100, MENU_entryint32, 9);
menu_create_entry ("Mixed:", 140, 300, 110, &map.mixed, 100, MENU_entryint, 10); menu_create_entry ("Mixed:", 140, 300, 110, &map.mixed, 100, MENU_entryint32, 10);
menu_create_entry ("Death:", 140, 320, 110, &map.death, 100, MENU_entryint, 11); menu_create_entry ("Death:", 140, 320, 110, &map.death, 100, MENU_entryint32, 11);
menu_create_entry ("Trigger:", 280, 240, 120, &map.sp_trigger, 30, MENU_entryint, 12); menu_create_entry ("Trigger:", 280, 240, 120, &map.sp_trigger, 30, MENU_entryint32, 12);
menu_create_entry ("Push: ", 280, 260, 120, &map.sp_push, 30, MENU_entryint, 13); menu_create_entry ("Push: ", 280, 260, 120, &map.sp_push, 30, MENU_entryint32, 13);
menu_create_entry ("Row: ", 280, 280, 120, &map.sp_row, 30, MENU_entryint, 14); menu_create_entry ("Row: ", 280, 280, 120, &map.sp_row, 30, MENU_entryint32, 14);
menu_create_entry ("Game Timeout:", -1, 350, 180, &bman.init_timeout, 900, MENU_entryint, 15); menu_create_entry ("Game Timeout:", -1, 350, 180, &bman.init_timeout, 1200, MENU_entryint32, 15);
menu_create_button ("Ok", -1, 380, 150, 0); menu_create_button ("Ok", -1, 380, 150, 0);

@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.31 2003/12/24 02:38:15 stpohle Exp $ /* $Id: menu.c,v 1.32 2003/12/28 01:21:43 stpohle Exp $
* Menuhandling */ * Menuhandling */
#include "basic.h" #include "basic.h"
@ -185,8 +185,10 @@ inline void menu_draw_menuitem (_menuitem *m) {
case (MENU_bool): case (MENU_bool):
menu_draw_bool (m); menu_draw_bool (m);
break; break;
case (MENU_entryint):
case (MENU_entrytext): case (MENU_entrytext):
case (MENU_entryint16):
case (MENU_entryint32):
case (MENU_entryfloat):
menu_draw_entry (m); menu_draw_entry (m);
break; break;
case (MENU_list): case (MENU_list):
@ -238,7 +240,9 @@ void menu_change_focus (_menuitem *newfocus) {
/* lose focus */ /* lose focus */
switch (menu.focus->type) { switch (menu.focus->type) {
case (MENU_entryint): case (MENU_entryfloat):
case (MENU_entryint16):
case (MENU_entryint32):
case (MENU_entrytext): case (MENU_entrytext):
menu_entry_lose_focus (menu.focus); menu_entry_lose_focus (menu.focus);
break; break;
@ -364,8 +368,10 @@ int menu_loop () {
case (MENU_bool): case (MENU_bool):
done = menu_event_bool (menu.focus, &event); done = menu_event_bool (menu.focus, &event);
break; break;
case (MENU_entryint):
case (MENU_entrytext): case (MENU_entrytext):
case (MENU_entryfloat):
case (MENU_entryint16):
case (MENU_entryint32):
done = menu_event_entry (menu.focus, &event); done = menu_event_entry (menu.focus, &event);
break; break;
case (MENU_label): case (MENU_label):

@ -1,4 +1,4 @@
/* $Id: menuentrys.c,v 1.2 2003/12/26 00:54:28 stpohle Exp $ /* $Id: menuentrys.c,v 1.3 2003/12/28 01:21:43 stpohle Exp $
* Menuhandling: entry */ * Menuhandling: entry */
@ -10,15 +10,20 @@
/* save the data into the pointer */ /* save the data into the pointer */
void menu_entry_save (_menuitem *mi) { void menu_entry_save (_menuitem *mi) {
int tmp;
switch (mi->type) { switch (mi->type) {
case (MENU_entryint): case (MENU_entryint16):
sscanf (mi->keybi.text, "%d", (int *) mi->ptrdata); sscanf (mi->keybi.text, "%d", &tmp);
*(Sint16*)mi->ptrdata = (Sint16) tmp;
break;
case (MENU_entryint32):
sscanf (mi->keybi.text, "%d", (Sint32*)mi->ptrdata);
break; break;
case (MENU_entrytext): case (MENU_entrytext):
strncpy (mi->ptrdata, mi->keybi.text, mi->len); strncpy (mi->ptrdata, mi->keybi.text, mi->len);
break; break;
case (MENU_entryfloat): case (MENU_entryfloat):
sscanf (mi->keybi.text, "%f", (float *) mi->ptrdata); sscanf (mi->keybi.text, "%f", (float*)mi->ptrdata);
break; break;
} }
}; };
@ -27,14 +32,17 @@ void menu_entry_save (_menuitem *mi) {
/* restore the data into the pointer */ /* restore the data into the pointer */
void menu_entry_restore (_menuitem *mi) { void menu_entry_restore (_menuitem *mi) {
switch (mi->type) { switch (mi->type) {
case (MENU_entryint): case (MENU_entryint16):
sprintf (mi->keybi.text, "%d", (int) *mi->ptrdata); sprintf (mi->keybi.text, "%d", *(Sint16*)mi->ptrdata);
break;
case (MENU_entryint32):
sprintf (mi->keybi.text, "%d", *(Sint32*)mi->ptrdata);
break; break;
case (MENU_entrytext): case (MENU_entrytext):
sprintf (mi->keybi.text, "%s", (char*) mi->ptrdata); sprintf (mi->keybi.text, "%s", (char*)mi->ptrdata);
break; break;
case (MENU_entryfloat): case (MENU_entryfloat):
sprintf (mi->keybi.text, "%f", (float) *mi->ptrdata); sprintf (mi->keybi.text, "%f", *(float*)mi->ptrdata);
break; break;
} }
mi->keybi.curpos = strlen (mi->keybi.text); mi->keybi.curpos = strlen (mi->keybi.text);
@ -46,10 +54,8 @@ void menu_entry_restore (_menuitem *mi) {
void menu_create_entry (char *name, int x, int y, int w, void *data, int len, int typ, int id) { void menu_create_entry (char *name, int x, int y, int w, void *data, int len, int typ, int id) {
int i = menu_getlastitem(menu.items); int i = menu_getlastitem(menu.items);
if (typ != MENU_entryint && typ != MENU_entryfloat && typ != MENU_entrytext) { if (typ != MENU_entrytext && typ != MENU_entryint16 && typ != MENU_entryint32 && typ != MENU_entryfloat)
d_fatal ("menu_create_entry: wrong typ\n");
return; return;
}
if (i == -1) { /* first entry in the itemslist */ if (i == -1) { /* first entry in the itemslist */
menu.items = &menuitems[0]; menu.items = &menuitems[0];
@ -79,7 +85,9 @@ void menu_create_entry (char *name, int x, int y, int w, void *data, int len, in
if (typ == MENU_entrytext) if (typ == MENU_entrytext)
keybinput_new (&menuitems[i].keybi, KEYBI_text, len); keybinput_new (&menuitems[i].keybi, KEYBI_text, len);
else if (typ == MENU_entryint) else if (typ == MENU_entryint16)
keybinput_new (&menuitems[i].keybi, KEYBI_int, len);
else if (typ == MENU_entryint32)
keybinput_new (&menuitems[i].keybi, KEYBI_int, len); keybinput_new (&menuitems[i].keybi, KEYBI_int, len);
else else
keybinput_new (&menuitems[i].keybi, KEYBI_float, 10); keybinput_new (&menuitems[i].keybi, KEYBI_float, 10);
@ -96,7 +104,7 @@ void menu_draw_entry (_menuitem *mi) {
int px, py, i; int px, py, i;
SDL_Rect dest; SDL_Rect dest;
if (mi->type != MENU_entrytext && mi->type != MENU_entryint && mi->type != MENU_entryfloat) if (mi->type != MENU_entrytext && mi->type != MENU_entryint16 && mi->type != MENU_entryint32 && mi->type != MENU_entryfloat)
return; return;
dest.x = mi->pos.x; dest.x = mi->pos.x;

@ -1,4 +1,4 @@
/* $Id: sysfunc.c,v 1.21 2003/12/24 02:38:16 stpohle Exp $ /* $Id: sysfunc.c,v 1.22 2003/12/28 01:21:43 stpohle Exp $
sysfunc.c - this file hold some routines for the system functions.. sysfunc.c - this file hold some routines for the system functions..
like d_delay like d_delay
*/ */

Loading…
Cancel
Save