server can only start games if all players are ready. (maybe still some fixes needed for disconnecting players

origin
stpohle 21 years ago
parent 77e68d6870
commit 395d65fd2c

@ -1,17 +1,18 @@
$Id: ChangeLog,v 1.84 2004/10/18 18:30:09 stpohle Exp $
$Id: ChangeLog,v 1.85 2004/10/18 20:20:18 stpohle Exp $
* NEED TO FIX: Server starts the game soo fast that the
client's ignore the gamestat for a running game.
Check if all players are ready.
* FINISH TEAM MODE.
2004-10-18
- AI won't have anymore so many suicide deaths.
- fixed: Server starts the game soo fast that the
client's ignore the gamestat for a running game.
Check if all players are ready.
- fixed: AI won't have anymore so many suicide deaths.
- Variable dir_change added so we won't have anymore
so many suicides.
- Variable dir_change added so we won't have
anymore so many suicides.
- Playermenu (Playerselection changed again)

@ -1,4 +1,4 @@
/* $Id: network.h,v 1.19 2004/05/20 16:55:30 stpohle Exp $
/* $Id: network.h,v 1.20 2004/10/18 20:20:22 stpohle Exp $
* network.h file... for everything what have to do with the network stuff
*/
@ -79,7 +79,7 @@ struct {
int pingreq; // just to send a ping and to save the number in here
int pingack; // just to wait for an ping reply.. it will show up here
Uint32 timestamp; // time of the last incoming package
signed char net_istep;
signed char net_istep; // -1 gfx all is loaded
signed char net_status;
unsigned char flags; // keep some flags.. like NETF_firewall
int firstplayer; // number of the first player (only needed if NETF_local2 is set

@ -1,4 +1,4 @@
/* $Id: packets.h,v 1.26 2004/09/26 22:06:46 stpohle Exp $
/* $Id: packets.h,v 1.27 2004/10/18 20:20:22 stpohle Exp $
* network packets.. */
#ifndef _PACKETS_H_
@ -190,6 +190,7 @@ struct pkg_playerdata {
unsigned char d;
unsigned char frame;
signed char dead_by;
signed char ready; // if the player is ready for the game
};

@ -1,4 +1,4 @@
/* $Id: player.h,v 1.8 2004/10/04 21:36:47 stpohle Exp $
/* $Id: player.h,v 1.9 2004/10/18 20:20:22 stpohle Exp $
* playerinclude file
*/
@ -101,6 +101,7 @@ struct {
char name[LEN_PLAYERNAME]; // name oder name[0] == 0
int team_nr; // number of the team we are in or -1
unsigned char state; // status of the player
int ready; // only used in net games
signed char in_nr; // number of the connected player entry
int points; // points

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.98 2004/10/06 18:16:14 stpohle Exp $
/* $Id: game.c,v 1.99 2004/10/18 20:20:22 stpohle Exp $
game.c - procedures for the game. */
#include <string.h>
@ -159,8 +159,20 @@ void game_keys_loop () {
/* don't go into the game_keys if there is no menu displayed */
if (GT_MP_PTPM && bman.state == GS_ready && keyb_gamekeys.state[BCK_pause] && !keyb_gamekeys.old[BCK_pause]) {
/* Server is starting the game */
bman.state = GS_running;
/* Server is starting the game
* check in multiplayer if all players are ready for the game
*/
int i, ready = 1;
for (i = 0; i < MAX_PLAYERS; i++)
if (NET_CANSEND (i) && !players[i].ready)
ready = 0;
if (ready)
bman.state = GS_running;
else
d_printf ("game_keys_loop: not all players are ready\n");
net_send_servermode ();
bman.updatestatusbar = 1; // force an update
}
@ -220,6 +232,18 @@ game_loop ()
d_gamedetail ("GAME START");
draw_players ();
if (bman.p_nr >= 0 && bman.p_nr < MAX_PLAYERS) {
players[bman.p_nr].ready = 1;
if (GT_MP_PTPS)
send_playerdata (&players[bman.p_servnr].net.addr, bman.p_nr, &players[bman.p_nr]);
}
if (bman.p2_nr >= 0 && bman.p2_nr < MAX_PLAYERS) {
players[bman.p2_nr].ready = 1;
if (GT_MP_PTPS)
send_playerdata (&players[bman.p_servnr].net.addr, bman.p2_nr, &players[bman.p2_nr]);
}
while (!done && (bman.state == GS_running || bman.state == GS_ready)) {
if ((eventstate = SDL_PollEvent (&event)) != 0)
switch (event.type) {
@ -474,6 +498,7 @@ game_start ()
players[p].pos.x = -1;
players[p].pos.y = -1;
players[p].tunnelto = 0.0f;
players[p].ready = 0;
/* all types of illnes turn them off */
for (i = 0; i < PI_max; i++)

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.66 2004/09/25 10:57:51 stpohle Exp $ */
/* $Id: network.c,v 1.67 2004/10/18 20:20:22 stpohle Exp $ */
/*
network routines.
*/
@ -578,6 +578,7 @@ net_transmit_gamedata ()
send_playerstatus (&players[bman.p_servnr].net.addr, bman.p_nr, 0, 0);
}
}
if (net_istep == 0 && players[bman.p_nr].net.net_status == -1
&& timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
/* server did not send informations back */

@ -628,7 +628,7 @@ send_playerdata (_net_addr * addr, int p_nr, _player * pl)
p_dat.dead_by = pl->dead_by;
p_dat.frame = HTON16 (FTOI16 (pl->frame));
p_dat.p_nr = p_nr;
p_dat.ready = pl->ready;
send_pkg ((struct pkg *) &p_dat, addr);
};
@ -666,6 +666,7 @@ do_playerdata (struct pkg_playerdata *p_dat, _net_addr * addr)
pl->frame = I16TOF (NTOH16 (p_dat->frame));
pl->state = p_dat->state;
pl->team_nr = p_dat->team_nr;
pl->ready = p_dat->ready;
team_update ();
}

Loading…
Cancel
Save