From 959bd1dd475d6d0c7edaf481845b1bd4091223b2 Mon Sep 17 00:00:00 2001 From: stpohle Date: Sat, 3 Jan 2004 02:12:33 +0000 Subject: [PATCH] network help screen added added SHIFT+F3 to delete ai players network_shutdown fixed for ai players and already disconnected players --- include/bomberclone.h | 3 ++- include/network.h | 3 ++- src/multiwait.c | 25 +++++++++++++------------ src/netmenu.c | 22 +++++++++++++++++++++- src/network.c | 4 ++-- src/player.c | 4 ++-- src/single.c | 19 ++++++++++++++++++- 7 files changed, 60 insertions(+), 20 deletions(-) diff --git a/include/bomberclone.h b/include/bomberclone.h index 8e9d705..df95283 100644 --- a/include/bomberclone.h +++ b/include/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.10 2004/01/02 13:54:48 stpohle Exp $ */ +/* $Id: bomberclone.h,v 1.11 2004/01/03 02:12:33 stpohle Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -255,6 +255,7 @@ extern void d_printsdlrect (char *text, SDL_Rect *rect); // single.c extern void single_game_new (); extern void single_create_ai (int num_players); +extern void single_delete_ai (int num_players); extern void single_loop(); extern void single_playergame (); extern void single_menu (); diff --git a/include/network.h b/include/network.h index 143cd97..88f1d88 100644 --- a/include/network.h +++ b/include/network.h @@ -1,4 +1,4 @@ -/* $Id: network.h,v 1.8 2003/12/24 02:38:15 stpohle Exp $ +/* $Id: network.h,v 1.9 2004/01/03 02:12:33 stpohle Exp $ * network.h file... for everything what have to do with the network stuff */ @@ -92,6 +92,7 @@ extern void join_multiplayer_game (); extern void host_multiplayer_game (); extern void multiplayer_firstrun (); extern void multiplayer_game (); +extern void network_helpscreen (); // network.c extern int network_server_port (char *server, char *host, int hostlen, char *port, int portlen); diff --git a/src/multiwait.c b/src/multiwait.c index ac2ef1f..8d82c4d 100644 --- a/src/multiwait.c +++ b/src/multiwait.c @@ -232,14 +232,8 @@ mw_draw_chat () if (chat.visible == 0) { chat_show (16, mw_chat + 16, gfx.res.x - 16, gfx.res.y - 32); chat_addstatusline ("Press [STRG] or [CTRL] - to select a player"); - if (GT_MP_PTPM) { - chat_addstatusline ("F2 - to change map settings"); - chat_addstatusline ("F3 - to change player settings"); - chat_addstatusline ("F4 - to start the game"); - } - else { - chat_addstatusline ("F2 - to see the map settings"); - } + if (GT_MP_PTPM) + chat_addstatusline ("F1 - for the Help Screen"); } }; @@ -307,7 +301,7 @@ wait_for_players () keys = SDL_GetKeyState (NULL); - if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { + if (event.key.keysym.sym == SDLK_ESCAPE && event.type == SDL_KEYDOWN) { /* we want to quit */ done = 1; bman.p_nr = -1; @@ -388,19 +382,26 @@ wait_for_players () mw_draw_chat (); } - if ((GT_MP_PTPM) && keys[SDLK_F3] && (!keypressed)) { - single_create_ai (1); + if ((GT_MP_PTPM) && (!keypressed) && event.key.keysym.sym == SDLK_F3 && event.type == SDL_KEYDOWN) { + if (!keys[SDLK_RSHIFT] && !keys[SDLK_LSHIFT] ) + single_create_ai (1); + else + single_delete_ai (1); + for (i = 0; i < MAX_PLAYERS; i++) net_change_playerid (i, GT_MP_PTPM); bman.updatestatusbar = 1; } + if (keys[SDLK_F1] && (!keypressed)) /* open help screen */ + network_helpscreen (); + chat_loop (&event); } if (event.type == SDL_KEYUP) keypressed = 0; - else if (event.type == SDL_KEYDOWN) + else if (event.type == SDL_KEYDOWN && event.key.keysym.sym != SDLK_RSHIFT && event.key.keysym.sym != SDLK_LSHIFT) keypressed = 1; s_delay (25); diff --git a/src/netmenu.c b/src/netmenu.c index c4ac632..784fc21 100644 --- a/src/netmenu.c +++ b/src/netmenu.c @@ -162,7 +162,7 @@ void multiplayer_game () { net_new_game (); game_start (); if (GT_MP_PTPM) { - net_send_mapinfo (); // maybe we have to make a pause + net_send_mapinfo (); // maybe we have to make a break net_send_servermode (); // between mapinfo and servermode } net_transmit_gamedata (); @@ -233,3 +233,23 @@ join_multiplayer_game () network_shutdown (); }; + + +/* Network Help Screen */ +void network_helpscreen () { + menu_new ("Network Help Screen", 400, 380); + menu_create_label ("F1", 60, 50, 1); + menu_create_label ("Display this Helpscreen", 180, 54, 0); + + menu_create_label ("F2", 60, 80, 1); + menu_create_label ("Change/Show Mapsettings", 180, 84, 0); + + menu_create_label ("F3", 60, 110, 1); + menu_create_label ("Add one AI Player", 180, 114, 0); + + menu_create_label ("Shift-F3", 10, 140, 1); + menu_create_label ("Delete one AI P.", 180, 144, 0); + + menu_loop (); + menu_delete (); +}; diff --git a/src/network.c b/src/network.c index 62d1277..381c427 100644 --- a/src/network.c +++ b/src/network.c @@ -1,4 +1,4 @@ -/* $Id: network.c,v 1.49 2003/12/31 01:09:43 stpohle Exp $ */ +/* $Id: network.c,v 1.50 2004/01/03 02:12:34 stpohle Exp $ */ /* network routines. */ @@ -141,7 +141,7 @@ network_shutdown () if (GT_MP_PTPM) { d_printf ("Server Quit Send information\n"); for (i = 0; i < MAX_PLAYERS; i++) - if (i != bman.p_servnr && players[i].net.addr.host[0] != 0) + if (i != bman.p_servnr && PS_IS_netplayer (players[i].state) && !PS_IS_aiplayer (players[i].state)) send_quit (&players[i].net.addr, NULL, NULL); } else if (players[bman.p_servnr].net.addr.host[0] != 0) diff --git a/src/player.c b/src/player.c index 2879f65..5094104 100644 --- a/src/player.c +++ b/src/player.c @@ -1,4 +1,4 @@ -/* $Id: player.c,v 1.55 2004/01/02 13:54:48 stpohle Exp $ +/* $Id: player.c,v 1.56 2004/01/03 02:12:34 stpohle Exp $ * player.c - everything what have to do with the player */ #include @@ -214,7 +214,7 @@ player_check_powerup (int p_nr) int check_field (short int x, short int y) { - int res = 0, i; + int res = 0; if (map.field[x][y].type != FT_stone && map.field[x][y].type != FT_block) res = 1; diff --git a/src/single.c b/src/single.c index 6bec4ec..99dc1bf 100644 --- a/src/single.c +++ b/src/single.c @@ -1,4 +1,4 @@ -/* $Id: single.c,v 1.52 2003/12/28 04:51:25 stpohle Exp $ */ +/* $Id: single.c,v 1.53 2004/01/03 02:12:34 stpohle Exp $ */ /* single player */ #include "basic.h" @@ -540,6 +540,23 @@ ai_checknewpos (_point pos, int d) }; +/* delete single players from the game */ +void single_delete_ai (int num_players) { + int p, count; + + for (p = 0, count = 0; p < MAX_PLAYERS && count < num_players; p++) { + if (PS_IS_aiplayer (players[p].state)) { + /* ai player found... delete */ + player_set_gfx (&players[p], -1); + players[p].state = 0; + players[p].net.addr.host[0] = 0; + players[p].net.addr.port[0] = 0; + count++; + } + } +}; + + /* create a giving number of ai players */ void single_create_ai (int num_players)