Server can leave without problems... not working correct and multiplayermenus rewritten

origin
stpohle 21 years ago
parent 6c660aae1a
commit 14b216577d

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.29 2004/09/26 02:28:05 stpohle Exp $ */
/* $Id: bomberclone.h,v 1.30 2004/11/07 04:13:09 stpohle Exp $ */
/* bomberclone.h */
#ifndef _BOMBERCLONE_H_
@ -119,7 +119,8 @@ extern void game_end ();
extern void game_start();
extern void game_showresult ();
extern int game_check_endgame ();
extern void game_showresultnormal ();
extern void game_showresultteam ();
extern void game_menu_create ();
extern void game_menu_loop (SDL_Event *event, int eventstate);

@ -1,4 +1,4 @@
/* $Id: network.h,v 1.20 2004/10/18 20:20:22 stpohle Exp $
/* $Id: network.h,v 1.21 2004/11/07 04:13:09 stpohle Exp $
* network.h file... for everything what have to do with the network stuff
*/
@ -101,7 +101,7 @@ extern int network_server_port (char *server, char *host, int hostlen, char *por
extern void network_shutdown ();
extern int network_init ();
extern int network_loop ();
extern void net_change_playerid (int pl_nr, unsigned char senddata);
extern void net_change_playerid (int pl_nr);
extern void net_new_game ();
extern void net_transmit_gamedata ();
extern void net_game_send_player (int p_nr);
@ -126,12 +126,6 @@ extern void send_ogc_update ();
// multiwait.c
extern void wait_for_players ();
extern void mw_init ();
extern void mw_shutdown ();
extern void mw_draw_gfxselect (int pl_nr, int selgfx);
extern void mw_draw_status ();
extern void mw_wait_for_connect ();
extern void mw_draw_chat ();
// netsrvlist.c
extern void net_getserver ();
@ -140,9 +134,10 @@ extern void srvlist_rebuildlist ();
/* check if we can send to the player */
#define NET_CANSEND(__pl) (!PS_IS_aiplayer (players[__pl].state) \
&& PS_IS_netplayer (players[__pl].state) \
&& (players[__pl].net.addr.host[0] != 0 && players[__pl].net.addr.port[0] != 0) \
&& __pl != bman.p_nr && __pl != bman.p2_nr \
&& (players[__pl].net.flags & NETF_local2) == 0 \
&& ( GT_MP_PTPM || __pl == bman.p_servnr \
&& (( GT_MP_PTPM && (__pl != bman.p_servnr )) || ( __pl == bman.p_servnr && GT_MP_PTPS ) \
|| (((players[__pl].net.flags & NETF_firewall) == 0) \
&& !bman.firewall)))

@ -1,4 +1,4 @@
/* $Id: packets.h,v 1.27 2004/10/18 20:20:22 stpohle Exp $
/* $Id: packets.h,v 1.28 2004/11/07 04:13:09 stpohle Exp $
* network packets.. */
#ifndef _PACKETS_H_
@ -224,6 +224,7 @@ struct pkg_bombdata {
struct pkg_quit {
struct pkgheader h;
signed char pl_nr;
signed char new_server;
};
@ -373,7 +374,7 @@ extern void send_ping (_net_addr *addr, int data, unsigned char typ);
extern void send_playerdata (_net_addr *addr, int p_nr, _player * pl);
extern void send_playermove (_net_addr *addr, int p_nr, _player * pl);
extern void send_bombdata (_net_addr *addr, int p, int b, _bomb * bomb);
extern void send_quit (_net_addr *addr, int pl_nr);
extern void send_quit (_net_addr *addr, int pl_nr, int new_server);
extern void send_getfield (_net_addr *addr, int line);
extern void send_fieldline (_net_addr *addr, int line);
extern void send_getplayerdata (_net_addr *addr, int pl);

@ -1,9 +1,9 @@
/* $Id: single.h,v 1.5 2004/10/04 21:36:47 stpohle Exp $
/* $Id: single.h,v 1.6 2004/11/07 04:13:09 stpohle Exp $
* single player */
// single.c
extern void single_game_new ();
extern void single_create_ai (int num_players);
extern int single_create_ai (int num_players);
extern void single_loop();
extern void single_playergame (int second_player, int ai_players);
extern void single_menu ();

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.100 2004/10/28 18:15:18 stpohle Exp $
/* $Id: game.c,v 1.101 2004/11/07 04:13:10 stpohle Exp $
game.c - procedures for the game. */
#include <string.h>
@ -543,7 +543,7 @@ game_start ()
#define SHOWRESULT_TEAMHEAD 24
#define SHOWRESULT_TEAMPLAYER 16
#define SHOWRESULT_TEAMPLAYERWIDTH 150
static void game_showresultteam () {
void game_showresultteam () {
int i, t_nr, p_nr; // counter for teams and players
struct {
_team *team; // pointer to the team
@ -624,8 +624,8 @@ static void game_showresultteam () {
for (t_nr = 0; t_nr < t_count; t_nr++) {
sprintf (text, "%s Victorys %d (%d)", tdata[t_nr].team->name, tdata[t_nr].team->wins, tdata[t_nr].team->points);
sx = (gfx.res.y - strlen (text) * font[0].size.x) / 2;
font_drawbold (sx, sy+3, text, 0, COLOR_brown, 1);
font_draw (sx, sy+3, text, 0, COLOR_yellow);
font_gfxdrawbold (sx, sy+3, text, 0, COLOR_brown, 1, 1);
font_gfxdraw (sx, sy+3, text, 0, COLOR_yellow, 2);
sy += SHOWRESULT_TEAMHEAD;
dx = (gfx.res.x - 40) / p_x;
sx = 20 + (dx - SHOWRESULT_TEAMPLAYERWIDTH)/2;
@ -637,6 +637,7 @@ static void game_showresultteam () {
x = sx;
}
if (tdata[t_nr].pl[p_nr]->gfx != NULL) {
dest.x = x;
dest.y = sy;
src.w = dest.w = tdata[t_nr].pl[p_nr]->gfx->small_image->w;
@ -644,13 +645,12 @@ static void game_showresultteam () {
src.x = 0;
src.y = 0;
gfx_blit (tdata[t_nr].pl[p_nr]->gfx->small_image, &src, gfx.screen, &dest, 1);
}
sprintf (text, "%s(%d/%d)", tdata[t_nr].pl[p_nr]->name, tdata[t_nr].pl[p_nr]->wins, tdata[t_nr].pl[p_nr]->points);
font_draw (x + GFX_SMALLPLAYERIMGSIZE_X*2, sy + 2, text, 0, 0);
font_gfxdraw (x + GFX_SMALLPLAYERIMGSIZE_X*2, sy + 2, text, 0, 0, 2);
x += dx;
col++;
}
gfx_blitdraw ();
sy += dy;
}
}
@ -662,7 +662,7 @@ static void game_showresultteam () {
/* Bomberman/Deathmatch Version Play */
#define SHOWRESULT_WIDTH 150
#define SHOWRESULT_HEIGHT 80
static void game_showresultnormal () {
void game_showresultnormal () {
char text[255];
int i, p, x, y, pl_cnt = 0,
pl_x, pl_y, // player in a row/col
@ -708,15 +708,16 @@ static void game_showresultnormal () {
for (i = 1, p = 0; p < pl_cnt; p++) {
if (PS_IS_used (pl[p]->state)) {
if (PS_IS_alife (pl[p]->state)) {
font_drawbold (x + GFX_MENUPLAYERIMGSIZE_X, y - 10, pl[p]->name, 0, COLOR_brown, 1);
font_draw (x + GFX_MENUPLAYERIMGSIZE_X, y - 10, pl[p]->name, 0, COLOR_yellow);
font_gfxdrawbold (x + GFX_MENUPLAYERIMGSIZE_X, y - 10, pl[p]->name, 0, COLOR_brown, 1, 1);
font_gfxdraw (x + GFX_MENUPLAYERIMGSIZE_X, y - 10, pl[p]->name, 0, COLOR_yellow, 1);
}
else
font_draw (x + GFX_MENUPLAYERIMGSIZE_X, y - 10, pl[p]->name, 0, COLOR_gray);
font_gfxdraw (x + GFX_MENUPLAYERIMGSIZE_X, y - 10, pl[p]->name, 0, COLOR_gray, 1);
sprintf (text, "%3d (%3d)", pl[p]->wins, pl[p]->points);
font_draw (x + GFX_MENUPLAYERIMGSIZE_X, y + 6, text, 0, 0);
font_gfxdraw (x + GFX_MENUPLAYERIMGSIZE_X, y + 6, text, 0, 0, 1);
if (pl[p]->gfx != NULL) {
dest.x = x;
dest.y = y - 16;
src.w = dest.w = pl[p]->gfx->menu_image->w;
@ -724,7 +725,7 @@ static void game_showresultnormal () {
src.x = 0;
src.y = 0;
gfx_blit (pl[p]->gfx->menu_image, &src, gfx.screen, &dest, 1);
}
/* setup the new position */
y += (dy / pl_x);
x += dx;

@ -1,4 +1,4 @@
/* $Id: multiwait.c,v 1.50 2004/10/20 19:27:31 stpohle Exp $
/* $Id: multiwait.c,v 1.51 2004/11/07 04:13:10 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
*/
@ -12,25 +12,25 @@
#include "single.h"
#include "keyb.h"
/****************** prototype declaration */
static void mw_init ();
static void mw_shutdown ();
static void mw_keys_loop ();
static void mw_draw_all_player ();
static void mw_draw_all_teams ();
static int mw_team_is_used (int t_nr);
static int mw_check_players ();
static int mw_check_screenredraw ();
extern int UpdateRects_nr;
extern int blitdb_nr;
static int mw_num_readyplayers; // number of players who are ready
static int mw_num_players_x; // number of players in the x
static int mw_num_players_y; // number of players in the y
static int mw_num_players;
_point mw_pos[MAX_PLAYERS+1];
// uncomment to sort by points
// #define SORT_BY_POINTS 1
#define MW_PLAYERSCR_X 310
#define MW_PLAYERSCR_Y 50
#define MW_TITLE_Y 50
/* returns number of active players in a team */
int mw_team_is_used (int t_nr) {
static int mw_team_is_used (int t_nr) {
int i,j=0;
for(i=0;i<MAX_PLAYERS;i++)
if ((teams[t_nr].players[i]!=NULL) && (PS_IS_used(teams[t_nr].players[i]->state))) { j++;}
@ -39,89 +39,21 @@ int mw_team_is_used (int t_nr) {
}
/* Calcs the position of all items on the screen */
int mw_calc_screen() {
int i,j,k=0,n=0,cy;
if (bman.updatestatusbar) {
if (bman.gametype==GT_team) {
/* team mode */
for(i=0;i<MAX_TEAMS;i++){
j=mw_team_is_used(i);
if (j>k) k=j;
if (j>0) n++;
}
mw_num_players_x=2;
mw_num_players_y=floorf(n/2)+n%2;
mw_num_players=n;
for(i=0;i<mw_num_players;i++) {
mw_pos[i].x=gfx.res.x/2/mw_num_players_x+(i%mw_num_players_x)*gfx.res.x/2-MW_PLAYERSCR_X/2;
mw_pos[i].y=ceil(i/2)*(55+k*15);
d_printf("mw_team_Position: x=%d, y=%d\n ",mw_pos[i].x,mw_pos[i].y);
}
cy=mw_num_players_y*(55+k*15)+20;
mw_pos[MAX_PLAYERS].x=8; // Pos of unassigned Players
mw_pos[MAX_PLAYERS].y=cy-15;
}
else
{
mw_num_players=0;
for (i=0;i<MAX_PLAYERS;i++) {
if (PS_IS_used (players[i].state)) mw_num_players++;
}
if (mw_num_players*2>MAX_PLAYERS) {
mw_num_players_x=2;
mw_num_players_y=floorf(mw_num_players/2)+mw_num_players%2;
}
else
{
mw_num_players_x=1;
mw_num_players_y=mw_num_players;
}
for(i=0;i<mw_num_players;i++) {
mw_pos[i].x=gfx.res.x/2/mw_num_players_x+(i%mw_num_players_x)*gfx.res.x/2-MW_PLAYERSCR_X/2;
mw_pos[i].y=floorf(i/mw_num_players_x)*MW_PLAYERSCR_Y;
d_printf("mw_Position: x=%d, y=%d\n ",mw_pos[i].x,mw_pos[i].y);
}
cy=(mw_num_players_y)*MW_PLAYERSCR_Y+15;
}
draw_logo ();
d_printf ("mw_num_players_x : %d, mw_num_players_y : %d mw_players:%d\n", mw_num_players_x, mw_num_players_y,mw_num_players);
chat_show (8, cy, gfx.res.x - 16, gfx.res.y - (8 + cy));
chat.active = 1;
bman.updatestatusbar=0;
return 1;
}
return 0;
}
/* this will load some graphics and so other stuff */
void
mw_init ()
static void mw_init ()
{
team_update ();
gfx_blitdraw ();
draw_logo ();
menu_displaytext ("Please Wait", "Loading GFX Data");
network_loop ();
mw_num_readyplayers = 0;
bman.updatestatusbar = 1;
gfx_blitdraw ();
mw_num_players=-1;
bman.updatestatusbar = 1;
d_playerdetail ("mw_init:\n");
SDL_Flip (gfx.screen);
};
/* free all grafics */
void mw_shutdown () {
/* free all graphics */
static void mw_shutdown () {
chat_show (-1, -1, -1, -1);
gfx_blitdraw ();
draw_logo ();
@ -131,227 +63,30 @@ void mw_shutdown () {
/*
* check if the players are ready
* returns the number of players which are ready
*/
void mw_check_players () {
static int mw_check_players () {
int readyplayers = 0;
int i;
mw_num_readyplayers = 0;
if (GT_MP_PTPS) /* only the master can start the game */
return;
return 0;
for (i = 0; i < MAX_PLAYERS; i++) {
if (players[i].gfx_nr >= 0 && players[i].gfx_nr < MAX_PLAYERS)
mw_num_readyplayers++;
}
}
/*
* draw only the given player
*/
void mw_draw_player (int p_nr, int pos) {
_player *player;
_point p;
char text[255];
SDL_Rect src;
SDL_Rect dest;
player=&players[p_nr];
p.x = mw_pos[pos].x;
p.y = mw_pos[pos].y;
if (PS_IS_used (player->state)) {
/*
* player is used
*/
if (player->gfx_nr >= 0 && player->gfx_nr < gfx.player_gfx_count) {
/* player is used and selected a gfx */
dest.x = p.x;
src.x = 0;
src.y = 0;
if (p_nr==bman.p_nr) {
/* player 1 */
dest.y = p.y;
src.w = dest.w = gfx.players[player->gfx_nr].menu_image->w;
src.h = dest.h = gfx.players[player->gfx_nr].menu_image->h;
gfx_blit (gfx.players[player->gfx_nr].menu_image, &src, gfx.screen, &dest, 10001);
} else if (p_nr==bman.p2_nr) {
/* player 2 */
dest.x=p.x+MW_PLAYERSCR_X-64;
dest.y = p.y;
src.w = dest.w = gfx.players[player->gfx_nr].menu_image->w;
src.h = dest.h = gfx.players[player->gfx_nr].menu_image->h;
gfx_blit (gfx.players[player->gfx_nr].menu_image, &src, gfx.screen, &dest, 10001);
} else {
/* net-player */
dest.x=p.x+35;
dest.y = p.y + 15;
src.w = dest.w = gfx.players[player->gfx_nr].small_image->w;
src.h = dest.h = gfx.players[player->gfx_nr].small_image->h;
gfx_blit (gfx.players[player->gfx_nr].small_image, &src, gfx.screen, &dest, 10001);
}
readyplayers++;
}
font_gfxdraw (p.x + GFX_IMGSIZE, p.y, player->name, 1, COLOR_yellow, 10002);
sprintf (text,"Victorys:%2d(%d)", player->wins, player->points);
font_gfxdraw (p.x + GFX_IMGSIZE, p.y + font[2].size.y - 4, text, 0, COLOR_white, 10002);
if (debug && PS_IS_used (player->state)) {
sprintf (text, "%s:%s [%d]", player->net.addr.host, player->net.addr.port, player->state);
if (player->net.flags & NETF_firewall)
sprintf (text,"%s FW", text);
font_gfxdraw (p.x + GFX_IMGSIZE, p.y + font[0].size.y + font[2].size.y - 4, text, 0, COLOR_white, 10002);
}
}
else {
/*
* player is free
*/
font_gfxdraw (p.x + GFX_IMGSIZE, p.y, "No Player" , 0, COLOR_gray, 10002);
}
};
/*
* draw all player informations
*/
void mw_draw_all_player () {
int i,j,h;
int n[MAX_PLAYERS];
for(i=0;i<MAX_PLAYERS;i++) n[i]=i;
for(i=0;i<MAX_PLAYERS;i++)
for(j=i;j<MAX_PLAYERS;j++)
#ifdef SORT_BY_POINTS
if (players[i].points>players[j].points) {
#else
if (players[i].wins>players[j].wins) {
#endif
h=n[i];n[i]=n[j];n[j]=h;
}
j=0;
for (i = 0; i < MAX_PLAYERS; i++) {
if (PS_IS_used (players[n[i]].state)) {
mw_draw_player (n[i], j);
j++;
}
}
gfx_blitdraw();
};
/*
* draw only the given team
*/
void mw_draw_team (int t_nr, int pos) {
_player *player;
_team *team;
_point p;
int i,j=0;
char text[255];
SDL_Rect src;
SDL_Rect dest;
team=&teams[t_nr];
p.x = mw_pos[pos].x;
p.y = mw_pos[pos].y;
/* Find if there is any active player in that team */
if (mw_team_is_used(t_nr)>0) {
/*
* team is used
*/
font_gfxdraw (p.x + GFX_IMGSIZE, p.y, team->name, 1, COLOR_yellow, 10002);
sprintf (text,"Victorys:%2d(%d)", team->wins, team->points);
font_gfxdraw (p.x + GFX_IMGSIZE, p.y + font[2].size.y - 4, text, 0, COLOR_white, 10002);
j=1;
for(i=0;i<MAX_PLAYERS;i++) {
if ((team->players[i]!=NULL) && (PS_IS_used(team->players[i]->state))) {
player=team->players[i];
if (player->gfx_nr >= 0 && player->gfx_nr < gfx.player_gfx_count) {
/* player is used and selected a gfx */
dest.x = p.x;
src.x = 0;
src.y = 0;
dest.x=p.x+35+20;
dest.y = p.y + 30+j*15;
src.w = dest.w = gfx.players[player->gfx_nr].small_image->w;
src.h = dest.h = gfx.players[player->gfx_nr].small_image->h;
gfx_blit (gfx.players[player->gfx_nr].small_image, &src, gfx.screen, &dest, 10001);
}
font_gfxdraw (p.x + GFX_IMGSIZE+20, p.y + 30+j*15, team->players[i]->name, 0, COLOR_white, 10002);
j++;
}
}
}
else {
/*
* team is emty
*/
font_gfxdraw (p.x + GFX_IMGSIZE, p.y, "No TEAM" , 0, COLOR_gray, 10002);
}
};
/*
Draw players which are not assigned to any team
*/
void mw_draw_unassigned_players () {
int i,
n=0;
char text[255];
sprintf(text,"Unassigned Players: ");
for (i=0;i<MAX_PLAYERS;i++) {
if ((PS_IS_used (players[i].state))&&(players[i].team_nr<0)) {
sprintf(text,"%s %s ",text,players[i].name);
n++;
}
}
d_printf("mw_draw_unassigned: %d players\n",n);
if (n) font_gfxdraw (mw_pos[MAX_PLAYERS].x,mw_pos[MAX_PLAYERS].y, text, 0, COLOR_gray, 10002);
return readyplayers;
}
/*
Draw all teams
*/
void mw_draw_all_teams () {
int i,j,h;
int n[MAX_TEAMS];
for(i=0;i<MAX_TEAMS;i++) n[i]=i;
for(i=0;i<MAX_TEAMS;i++)
for(j=i;j<MAX_TEAMS;j++)
#ifdef SORT_BY_POINTS
if (teams[i].points>teams[j].points) {
#else
if (teams[i].wins>teams[j].wins) {
#endif
h=n[i];n[i]=n[j];n[j]=h;
}
j=0;
for (i = 0; i < MAX_TEAMS; i++) {
if (mw_team_is_used(n[i])) {
mw_draw_team (n[i], j);
j++;
}
}
mw_draw_unassigned_players();
gfx_blitdraw();
};
/*
* check if one key is pressed
*/
void mw_keys_loop () {
if (GT_MP_PTPM && mw_num_readyplayers >= 2 && keyb_gamekeys.state[BCK_pause] && !keyb_gamekeys.old[BCK_pause]) {
static void mw_keys_loop () {
if (GT_MP_PTPM && mw_check_players () >= 2 && keyb_gamekeys.state[BCK_pause] && !keyb_gamekeys.old[BCK_pause]) {
/* min 2 players are ready for the game and
* the start key has pressed */
bman.state = GS_ready;
@ -368,6 +103,7 @@ void mw_keys_loop () {
if (keyb_gamekeys.state[BCK_esc] && !keyb_gamekeys.old[BCK_esc]) {
/* ESCAPE key was pressed */
net_game_send_delplayer (bman.p_nr);
bman.state = GS_startup;
}
@ -375,7 +111,6 @@ void mw_keys_loop () {
|| ((!IS_LPLAYER2) && keyb_gamekeys.state[BCPK_max + BCPK_drop] && !keyb_gamekeys.old[BCPK_max + BCPK_drop])) {
/* player 1 want to select a new gfx */
playermenu_selgfx (bman.p_nr);
net_change_playerid (bman.p_nr, 1);
bman.updatestatusbar = 1;
keyb_loop (NULL); // to reload the current keys
}
@ -383,7 +118,6 @@ void mw_keys_loop () {
if (IS_LPLAYER2 && keyb_gamekeys.state[BCPK_max + BCPK_drop] && !keyb_gamekeys.old[BCPK_max + BCPK_drop]) {
/* player 2 want to select a new gfx */
playermenu_selgfx (bman.p2_nr);
net_change_playerid (bman.p2_nr, 1);
bman.updatestatusbar = 1;
keyb_loop (NULL); // to reload the current keys
}
@ -404,14 +138,44 @@ void mw_keys_loop () {
};
/*
* return 1 if we have to redraw the screen or 0 if everything is still normal
*/
static int mw_check_screenredraw () {
static int old_gametype = -1;
int ret = 0;
if (old_gametype != bman.gametype || bman.updatestatusbar)
ret = 1;
bman.updatestatusbar = 0;
old_gametype = bman.gametype;
return ret;
}
/*
* draw all player informations
*/
static void mw_draw_all_player () {
game_showresultnormal ();
};
/*
* draw all team informations
*/
static void mw_draw_all_teams () {
game_showresultteam ();
};
/* the loop itself */
void wait_for_players () {
SDL_Event event;
mw_init ();
mw_calc_screen();
if (bman.gametype==GT_team) mw_draw_all_teams(); else mw_draw_all_player ();
do {
if (SDL_PollEvent (&event) != 0)
@ -424,14 +188,17 @@ void wait_for_players () {
/*
* check some little things and do the network stuff
*/
mw_check_players ();
network_loop ();
/*
* the drawing stuff
*/
if (mw_calc_screen()) {
if (bman.gametype==GT_team) mw_draw_all_teams(); else mw_draw_all_player ();
if (mw_check_screenredraw()) {
d_printf ("Draw Status\n");
gfx_blitdraw ();
draw_logo ();
if (bman.gametype==GT_team) mw_draw_all_teams();
else mw_draw_all_player ();
}
gfx_blitdraw ();

@ -163,7 +163,10 @@ void host_multiplayer_game () {
send_ogc_update (); /* send the information that we started an server */
multiplayer_game ();
net_send_servermode ();
if (bman.notifygamemaster)
send_ogc_update (); /* send the information that we started an server */
network_shutdown ();
};

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.67 2004/10/18 20:20:22 stpohle Exp $ */
/* $Id: network.c,v 1.68 2004/11/07 04:13:10 stpohle Exp $ */
/*
network routines.
*/
@ -146,19 +146,28 @@ void
network_shutdown ()
{
int i;
int new_server = bman.p_servnr;
d_printf ("network_shutdown\n");
if (GT_MP_PTPM) {
d_printf ("Server Quit Send information\n");
/* find new server */
for (i = 0; i < MAX_PLAYERS; i++) {
if (PS_IS_used(players[i].state) && PS_IS_netplayer(players[i].state) && i != bman.p_servnr && players[i].net.flags == 0)
new_server = i;
}
d_printf ("netword_shutdown: new server set to: %d\n", new_server);
for (i = 0; i < MAX_PLAYERS; i++)
if (i != bman.p_servnr && PS_IS_netplayer (players[i].state) && !PS_IS_aiplayer (players[i].state))
send_quit (&players[i].net.addr, bman.p_servnr);
send_quit (&players[i].net.addr, bman.p_servnr, new_server);
}
else if (players[bman.p_servnr].net.addr.host[0] != 0) {
send_quit (&players[bman.p_servnr].net.addr, bman.p_nr);
send_quit (&players[bman.p_servnr].net.addr, bman.p_nr, bman.p_servnr);
if (IS_LPLAYER2)
send_quit (&players[bman.p_servnr].net.addr, bman.p2_nr);
send_quit (&players[bman.p_servnr].net.addr, bman.p2_nr, bman.p_servnr);
}
if (bman.notifygamemaster) {
@ -410,7 +419,7 @@ draw_netupdatestate (char st)
used to update settings at startup
*/
void
net_change_playerid (int pl_nr, unsigned char senddata)
net_change_playerid (int pl_nr)
{
int i;
@ -419,7 +428,7 @@ net_change_playerid (int pl_nr, unsigned char senddata)
Send to all connected clients the update
*/
for (i = 1; i < MAX_PLAYERS; i++)
if (!PS_IS_aiplayer (players[i].state) && players[i].net.addr.host[0] != 0)
if (NET_CANSEND (i))
send_playerid (&players[i].net.addr, players[pl_nr].name,
players[pl_nr].net.addr.host, players[pl_nr].net.addr.port,
pl_nr, players[pl_nr].gfx_nr, players[pl_nr].team_nr, players[pl_nr].net.flags);
@ -428,12 +437,13 @@ net_change_playerid (int pl_nr, unsigned char senddata)
/*
Send only to the Server the update and only if in_nr == bman.in_nr
*/
if ((pl_nr == bman.p_nr || (IS_LPLAYER2 && pl_nr == bman.p2_nr)) && senddata)
if (pl_nr == bman.p_nr || (IS_LPLAYER2 && pl_nr == bman.p2_nr))
send_playerid (&players[bman.p_servnr].net.addr, players[pl_nr].name,
players[pl_nr].net.addr.host, players[pl_nr].net.addr.port,
pl_nr, players[pl_nr].gfx_nr, players[pl_nr].team_nr, players[pl_nr].net.flags);
}
if ((players[pl_nr].gfx_nr >= 0 && players[pl_nr].gfx != &gfx.players[players[pl_nr].gfx_nr]) || (players[pl_nr].gfx_nr == -1 && players[pl_nr].gfx != NULL))
player_set_gfx (&players[pl_nr], players[pl_nr].gfx_nr);
};
@ -704,13 +714,24 @@ net_game_send_field (int x, int y)
void
net_game_send_delplayer (int pl_nr) {
int i;
int new_server = bman.p_servnr;
d_printf ("net_game_send_delplayer (%d)\n", pl_nr);
if (GT_MP_PTPM && (GS_WAITRUNNING || bman.state == GS_update)) {
/* find new server, if needed */
if (pl_nr == bman.p_servnr) {
for (i = 0; i < MAX_PLAYERS; i++) {
if (PS_IS_used(players[i].state) && PS_IS_netplayer(players[i].state) && i != bman.p_servnr && players[i].net.flags == 0)
new_server = i;
}
d_printf ("new_game_send_delplayer: new server set to: %d\n", new_server);
}
for (i = 0; i < MAX_PLAYERS; i++)
if (NET_CANSEND(i))
send_quit (&players[i].net.addr, pl_nr);
send_quit (&players[i].net.addr, pl_nr, new_server);
if (bman.notifygamemaster)
send_ogc_update ();
bman.updatestatusbar=1;
@ -916,7 +937,6 @@ void send_ogc_update () {
sprintf (status, "error");
break;
}
ogc_sendgamestatus (bman.sock, "BomberClone", VERSION, bman.gamename, j, bman.maxplayer, status);
};

@ -262,7 +262,7 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
else
pl->state &= (0xff - PSF_net);
player_set_gfx (pl, p_id->gfx_nr);
if (pl->gfx_nr != p_id->gfx_nr) player_set_gfx (pl, p_id->gfx_nr);
strncpy (pl->name, p_id->name, LEN_PLAYERNAME);
pl->net.timestamp = timestamp;
pl->net.pingreq = pl->net.pingack + 5;
@ -290,15 +290,15 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
teams[pl->team_nr].points = NTOH16(p_id->team_points);
teams[pl->team_nr].wins = NTOH16(p_id->team_wins);
}
team_update ();
}
/* Send all connected players the new PlayerID */
if (GT_MP_PTPM && GS_WAITRUNNING && addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS)
net_change_playerid (addr->pl_nr, (GT_MP_PTPM));
net_change_playerid (addr->pl_nr);
}
d_playerdetail ("*** PLAYER List ***");
team_update ();
bman.updatestatusbar = 1;
};
@ -399,11 +399,6 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
send_playerid (addr, NULL, NULL, NULL, -1, -1, -1, 0);
}
/* the server changed */
if (bman.p_servnr != s_mod->p_servnr) {
menu_displaymessage ("Server Quit", "The Server Quit the game.");
}
/* do the normal update */
if (GT_MP_PTPS) {
bman.state = s_mod->state;
@ -943,7 +938,7 @@ send_tunneldata (_net_addr * addr, int tunnelnr, int x, int y)
*** Packettype: quit
***/
void
send_quit (_net_addr * addr, int pl_nr)
send_quit (_net_addr * addr, int pl_nr, int new_server)
{
struct pkg_quit q_dat;
@ -953,7 +948,7 @@ send_quit (_net_addr * addr, int pl_nr)
q_dat.h.flags = 0;
q_dat.h.len = HTON16 (sizeof (struct pkg_quit));
q_dat.pl_nr = pl_nr;
q_dat.new_server = new_server;
send_pkg ((struct pkg *) &q_dat, addr);
};
@ -967,6 +962,15 @@ do_quit (struct pkg_quit *q_dat, _net_addr * addr)
return;
/* the player who send this quit */
if (addr->pl_nr == bman.p_servnr && q_dat->new_server != bman.p_servnr) {
d_printf ("do_quit: new server is set to: %d\n", q_dat->new_server);
bman.p_servnr = q_dat->new_server;
if (GT_MP_PTPM && bman.notifygamemaster)
send_ogc_update ();
}
bman.updatestatusbar=1;
player_delete (q_dat->pl_nr);
};

@ -1,4 +1,4 @@
/* $Id: player.c,v 1.91 2004/10/18 18:27:20 stpohle Exp $
/* $Id: player.c,v 1.92 2004/11/07 04:13:10 stpohle Exp $
* player.c - everything what have to do with the player */
#include <SDL.h>
@ -837,6 +837,7 @@ player_set_gfx (_player * p, signed char gfx_nr)
p->gfx = &gfx.players[gfx_nr];
p->state |= PSF_playing;
}
if (GT_MP) net_change_playerid (p-players);
};
@ -1077,10 +1078,10 @@ void team_update () {
int pl;
for (pl = 0; pl < MAX_PLAYERS; pl++) {
if (PS_IS_used (players[pl].state) && players[pl].team_nr < 0 && players[pl].team_nr >= MAX_TEAMS)
if (PS_IS_used (players[pl].state) && (players[pl].team_nr < 0 || players[pl].team_nr >= MAX_TEAMS))
players[pl].team_nr = 0;
if (PS_IS_used (players[pl].state) && players[pl].team_nr >= 0) {
if (PS_IS_used (players[pl].state)) {
teams[players[pl].team_nr].players[cnt[players[pl].team_nr]] = &players[pl];
cnt[players[pl].team_nr]++;
}

@ -1,4 +1,4 @@
/* $Id: playermenu.c,v 1.11 2004/10/06 17:43:29 stpohle Exp $
/* $Id: playermenu.c,v 1.12 2004/11/07 04:13:10 stpohle Exp $
*/
#include "bomberclone.h"
@ -310,7 +310,7 @@ void playermenu () {
}
if (done == 1 && menu->focus->id == 2) { /* create ai player */
single_create_ai (1);
net_change_playerid (single_create_ai (1));
done = 0;
}
@ -323,7 +323,6 @@ void playermenu () {
done = 0;
players[sel_pl_nr].team_nr = teammenu_select (&players[sel_pl_nr]);
bman.updatestatusbar = 1;
team_update ();
}
if (done == 1 && menu->focus->id == 4) { /* kick player */
@ -337,6 +336,9 @@ void playermenu () {
s_calctimesync ();
} while ((done == 0 || menu->focus->id != 5) && done != -1);
team_update ();
ai_team_choosegfx ();
menu_delete (menu);
};

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.78 2004/10/18 18:27:20 stpohle Exp $ */
/* $Id: single.c,v 1.79 2004/11/07 04:13:10 stpohle Exp $ */
/* single player */
#include "basic.h"
@ -482,7 +482,7 @@ ai_checknewpos (_point pos, int d)
/* create a giving number of ai players */
void
int
single_create_ai (int num_players)
{
int p,
@ -516,8 +516,9 @@ single_create_ai (int num_players)
}
if (pl == NULL)
return;
return -1;
}
return p;
};

Loading…
Cancel
Save