diff --git a/bomberclone.prj b/bomberclone.prj index bc4307d..fb4a243 100644 --- a/bomberclone.prj +++ b/bomberclone.prj @@ -106,7 +106,8 @@ module.source.files=\ chat.h\ keybinput.c\ keybinput.h\ - single.c + single.c\ + sysfunc.h module.pixmap.name=pixmaps module.pixmap.type= diff --git a/src/basic.h b/src/basic.h index a39588c..8dc3b78 100644 --- a/src/basic.h +++ b/src/basic.h @@ -43,7 +43,8 @@ #define LEN_SERVERNAME 41 #define LEN_PORT 6 #define LEN_GAMENAME 32 - +#define LEN_PATHFILENAME 512 +#define LEN_FILENAME 256 #define DEFAULT_UDPPORT 11000 #define DEFAULT_GMUDPPORT "11100" diff --git a/src/configuration.c b/src/configuration.c index ca2e5cf..45002cd 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -32,6 +32,7 @@ game_init () bman.maxplayer = MAX_PLAYERS; bman.net_ai_family = PF_INET; + bman.sock = -1; bman.gamename[0] = 0; sprintf (bman.port, "%d", DEFAULT_UDPPORT); sprintf (bman.gamemaster, DEFAULT_GAMEMASTER); @@ -303,7 +304,7 @@ configuration () {1, "Video Options"}, {2, "Sound Options"}, {3, "Customize Keyboard"}, - {4, "Field File:"}, + {4, "Field File:"}, {5, "Field Size X:"}, {6, "Field Size Y:"}, {7, "Prompt For Player Name"}, diff --git a/src/menu.c b/src/menu.c index 9fe395b..c74f64d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,4 +1,4 @@ -/* $Id: menu.c,v 1.5 2003/05/04 21:00:30 ob1kenewb Exp $ */ +/* $Id: menu.c,v 1.6 2003/05/06 12:25:30 stpohle Exp $ */ /* menu's for the game */ #include @@ -115,19 +115,20 @@ menu_loop (char *menutitle, _menu menu[], int lastselect) by; draw_logo (); - draw_menu (menutitle, menu, &bx, &by); - SDL_Flip (gfx.screen); for (lastentry = 0; menu[lastentry].index != -1; lastentry++); while ((!done || keypressed == 1) && bman.state != GS_quit) { draw_select (menuselect, menu, bx, by); - SDL_Flip (gfx.screen); - if (SDL_WaitEvent (&event) != 0) + /* do the network loop if we have to */ + if (bman.gametype == GT_multi && bman.sock != -1) + network_loop (); + + if (SDL_PollEvent (&event) != 0) switch (event.type) { case (SDL_QUIT): menuselect = -1; @@ -137,19 +138,22 @@ menu_loop (char *menutitle, _menu menu[], int lastselect) /* keyboard handling */ keys = SDL_GetKeyState (NULL); - if (keys[SDLK_DOWN] && event.type == SDL_KEYDOWN) { + if (keys[SDLK_DOWN] && event.type == SDL_KEYDOWN && keypressed == 0) { + keypressed = 1; menuselect++; if (menuselect >= lastentry) menuselect = 0; } - if (keys[SDLK_UP] && event.type == SDL_KEYDOWN) { + if (keys[SDLK_UP] && event.type == SDL_KEYDOWN && keypressed == 0) { + keypressed = 1; menuselect--; if (menuselect < 0) menuselect = lastentry - 1; } if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { + keypressed = 1; return -1; } if (!keys[SDLK_ESCAPE] && event.type == SDL_KEYUP) @@ -162,7 +166,8 @@ menu_loop (char *menutitle, _menu menu[], int lastselect) if (!keys[SDLK_RETURN] && event.type == SDL_KEYUP) keypressed = 0; - }; + s_delay (100); + }; return menuselect; }; @@ -207,12 +212,14 @@ menu_get_text (char *title, char *text, int len) redraw_logo_shaded (x, y, (gfx.font.size.x - 4) * len_, gfx.font.size.y, MENU_BG_SHADE_DARK); draw_text (x, y, t, 1); - draw_text (x + (gfx.font.size.x - 4) * curpos, y, "_", 1); - SDL_Flip (gfx.screen); - if (SDL_WaitEvent (&event) != 0) + /* do the network loop if we have to */ + if (bman.gametype == GT_multi && bman.sock != -1) + network_loop (); + + if (SDL_PollEvent (&event) != 0) switch (event.type) { case (SDL_QUIT): bman.state = GS_quit; @@ -262,7 +269,8 @@ menu_get_text (char *title, char *text, int len) if (event.type == SDL_KEYUP) keypressed = 0; - + + s_delay (100); } }; @@ -313,7 +321,11 @@ menu_displaymessage (char *title, char *text) menu_displaytext (title, text, 64, 0, 0); while (done == 0 || (done == 1 && keypressed == 1)) { - if (SDL_WaitEvent (&event) != 0) + /* do the network loop if we have to */ + if (bman.gametype == GT_multi && bman.sock != -1) + network_loop (); + + if (SDL_PollEvent (&event) != 0) switch (event.type) { case (SDL_QUIT): done = 1; @@ -333,6 +345,8 @@ menu_displaymessage (char *title, char *text) if (event.type == SDL_KEYUP) keypressed = 0; + + s_delay (100); } }; diff --git a/src/multiwait.c b/src/multiwait.c index 55efeed..1a07b1d 100644 --- a/src/multiwait.c +++ b/src/multiwait.c @@ -359,7 +359,6 @@ wait_for_players () else if (event.type == SDL_KEYDOWN) keypressed = 1; - /* calculate time sync. */ s_delay (50); } diff --git a/src/netmenu.c b/src/netmenu.c index 1fc777d..fcb0f28 100644 --- a/src/netmenu.c +++ b/src/netmenu.c @@ -13,20 +13,20 @@ void networkmenu_joingame () { int i; - gamesrv_getserver(); + gamesrv_getserver (); for (i = 0; bman.servername[i] != 0; i++) if (bman.servername[i] == ' ') bman.servername[i] = ':'; - /* connect if we have an Servername */ -if (bman.servername[0] != 0) { - bman.sock = -1; - bman.gametype = GT_multi; - bman.multitype = MT_ptps; - join_multiplayer_game (); - bman.servername[0] = 0; -} + /* connect if we have an Servername */ + if (bman.servername[0] != 0) { + bman.sock = -1; + bman.gametype = GT_multi; + bman.multitype = MT_ptps; + join_multiplayer_game (); + bman.servername[0] = 0; + } }; void @@ -186,8 +186,8 @@ host_multiplayer_game () if (bman.p_nr != -1) { bman.state = GS_update; - net_new_game (); - field_new (bman.fieldpath); + net_new_game (); + field_new (bman.fieldpath); net_send_servermode (); gfx_game_init (); net_new_gamedata (); @@ -228,8 +228,8 @@ join_multiplayer_game () if (bman.p_nr != -1 && (GS_WAITRUNNING || bman.state == GS_update)) { gfx_game_init (); - bman.state = GS_update; - net_new_game (); + bman.state = GS_update; + net_new_game (); net_new_gamedata (); if (bman.state == GS_ready || bman.state == GS_running) diff --git a/src/network.c b/src/network.c index 4cd547b..4dd45fa 100644 --- a/src/network.c +++ b/src/network.c @@ -1,4 +1,4 @@ -/* $Id: network.c,v 1.12 2003/05/05 15:53:27 stpohle Exp $ */ +/* $Id: network.c,v 1.13 2003/05/06 12:25:30 stpohle Exp $ */ /* network routines. */ @@ -193,7 +193,7 @@ network_shutdown () resend_cache.fill = -1; bman.p_nr = -1; - + bman.sock = -1; #ifdef _WIN32 WSACleanup (); #endif