When possibly sending player positions prior to firing, do that before messing multibuf; Added more strict sanity checks for outgoing and incoming multi packets; Moved some general game stuff from net_udp_init() to multi_new_game()
This commit is contained in:
parent
8b22237d4e
commit
2a15431ec7
|
@ -1,5 +1,9 @@
|
||||||
D1X-Rebirth Changelog
|
D1X-Rebirth Changelog
|
||||||
|
|
||||||
|
20120415
|
||||||
|
--------
|
||||||
|
main/multi.c, main/multi.h, main/net_udp.c: When possibly sending player positions prior to firing, do that before messing multibuf; Added more strict sanity checks for outgoing and incoming multi packets; Moved some general game stuff from net_udp_init() to multi_new_game()
|
||||||
|
|
||||||
20120414
|
20120414
|
||||||
--------
|
--------
|
||||||
main/gamesave.c: Fix crash when loading a level in the editor
|
main/gamesave.c: Fix crash when loading a level in the editor
|
||||||
|
|
44
main/multi.c
44
main/multi.c
|
@ -145,11 +145,6 @@ int VerifyPlayerJoined=-1; // Player (num) to enter game before any ing
|
||||||
int Player_joining_extras=-1; // This is so we know who to send 'latecomer' packets to.
|
int Player_joining_extras=-1; // This is so we know who to send 'latecomer' packets to.
|
||||||
int Network_player_added = 0; // Is this a new player or a returning player?
|
int Network_player_added = 0; // Is this a new player or a returning player?
|
||||||
|
|
||||||
//added 02/26/99 Matt Mueller - reactor kill stats
|
|
||||||
short reactor_kills[MAX_NUM_NET_PLAYERS];
|
|
||||||
int reactor_kills_total;
|
|
||||||
//end addition -MM
|
|
||||||
|
|
||||||
ushort my_segments_checksum = 0;
|
ushort my_segments_checksum = 0;
|
||||||
|
|
||||||
netgame_info Netgame;
|
netgame_info Netgame;
|
||||||
|
@ -403,15 +398,15 @@ get_team(int pnum)
|
||||||
void
|
void
|
||||||
multi_new_game(void)
|
multi_new_game(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i, save_pnum = Player_num;
|
||||||
|
|
||||||
// Reset variables for a new net game
|
// Reset variables for a new net game
|
||||||
|
|
||||||
//edited 02/26/99 Matt Mueller - reactor kill stuff, and fix this other memset that hardcoded short=2bytes
|
for (Player_num = 0; Player_num < MAX_NUM_NET_PLAYERS; Player_num++)
|
||||||
|
init_player_stats_game();
|
||||||
|
Player_num = save_pnum;
|
||||||
|
|
||||||
memset(kill_matrix, 0, sizeof(kill_matrix)); // Clear kill matrix
|
memset(kill_matrix, 0, sizeof(kill_matrix)); // Clear kill matrix
|
||||||
memset(reactor_kills, 0, sizeof(reactor_kills)); // Clear kill matrix
|
|
||||||
reactor_kills_total=0;
|
|
||||||
//end edit -MM
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_NUM_NET_PLAYERS; i++)
|
for (i = 0; i < MAX_NUM_NET_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
|
@ -431,14 +426,22 @@ multi_new_game(void)
|
||||||
robot_fired[i] = 0;
|
robot_fired[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i=0;i<MAX_POWERUP_TYPES;i++)
|
||||||
|
{
|
||||||
|
MaxPowerupsAllowed[i]=0;
|
||||||
|
PowerupsInMine[i]=0;
|
||||||
|
}
|
||||||
|
|
||||||
team_kills[0] = team_kills[1] = 0;
|
team_kills[0] = team_kills[1] = 0;
|
||||||
Endlevel_sequence = 0;
|
Endlevel_sequence = 0;
|
||||||
|
Control_center_destroyed = 0;
|
||||||
Player_is_dead = 0;
|
Player_is_dead = 0;
|
||||||
multi_quit_game = 0;
|
multi_quit_game = 0;
|
||||||
Show_kill_list = 1;
|
Show_kill_list = 1;
|
||||||
game_disable_cheats();
|
game_disable_cheats();
|
||||||
Player_exploded = 0;
|
Player_exploded = 0;
|
||||||
Dead_player_camera = 0;
|
Dead_player_camera = 0;
|
||||||
|
Network_new_game = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -591,9 +594,6 @@ void multi_compute_kill(int killer, int killed)
|
||||||
if (Newdemo_state == ND_STATE_RECORDING)
|
if (Newdemo_state == ND_STATE_RECORDING)
|
||||||
newdemo_record_multi_kill(killed_pnum, -1);
|
newdemo_record_multi_kill(killed_pnum, -1);
|
||||||
|
|
||||||
//edited 02/26/99 Matt Mueller - add kill stats to messages
|
|
||||||
reactor_kills[killed_pnum]++;
|
|
||||||
reactor_kills_total++;
|
|
||||||
if (killed_pnum == Player_num)
|
if (killed_pnum == Player_num)
|
||||||
{
|
{
|
||||||
HUD_init_message(HM_MULTI, "%s %s.", TXT_YOU_WERE, TXT_KILLED_BY_NONPLAY);
|
HUD_init_message(HM_MULTI, "%s %s.", TXT_YOU_WERE, TXT_KILLED_BY_NONPLAY);
|
||||||
|
@ -813,8 +813,10 @@ void multi_do_frame(void)
|
||||||
void
|
void
|
||||||
multi_send_data(unsigned char *buf, int len, int priority)
|
multi_send_data(unsigned char *buf, int len, int priority)
|
||||||
{
|
{
|
||||||
Assert(len == message_length[(int)buf[0]]);
|
if (len != message_length[(int)buf[0]])
|
||||||
Assert(buf[0] <= MULTI_MAX_TYPE);
|
Error("multi_send_data: Packet type %i length: %i, expected: %i\n", buf[0], len, message_length[(int)buf[0]]);
|
||||||
|
if (buf[0] < 0 || buf[0] > MULTI_MAX_TYPE)
|
||||||
|
Error("multi_send_data: Illegal packet type %i\n", buf[0]);
|
||||||
|
|
||||||
if (Game_mode & GM_NETWORK)
|
if (Game_mode & GM_NETWORK)
|
||||||
{
|
{
|
||||||
|
@ -834,9 +836,12 @@ multi_send_data(unsigned char *buf, int len, int priority)
|
||||||
|
|
||||||
void multi_send_data_direct(unsigned char *buf, int len, int pnum, int priority)
|
void multi_send_data_direct(unsigned char *buf, int len, int pnum, int priority)
|
||||||
{
|
{
|
||||||
Assert(len == message_length[(int)buf[0]]);
|
if (len != message_length[(int)buf[0]])
|
||||||
Assert(buf[0] <= MULTI_MAX_TYPE);
|
Error("multi_send_data_direct: Packet type %i length: %i, expected: %i\n", buf[0], len, message_length[(int)buf[0]]);
|
||||||
Assert(pnum >= 0 && pnum < MAX_NUM_NET_PLAYERS);
|
if (buf[0] < 0 || buf[0] > MULTI_MAX_TYPE)
|
||||||
|
Error("multi_send_data_direct: Illegal packet type %i\n", buf[0]);
|
||||||
|
if (pnum < 0 && pnum > MAX_NUM_NET_PLAYERS)
|
||||||
|
Error("multi_send_data_direct: Illegal player num: %i\n", pnum);
|
||||||
|
|
||||||
switch (multi_protocol)
|
switch (multi_protocol)
|
||||||
{
|
{
|
||||||
|
@ -2347,6 +2352,8 @@ multi_process_bigdata(char *buf, int len)
|
||||||
|
|
||||||
void multi_send_fire(int laser_gun, int laser_level, int laser_flags, int laser_fired, short laser_track)
|
void multi_send_fire(int laser_gun, int laser_level, int laser_flags, int laser_fired, short laser_track)
|
||||||
{
|
{
|
||||||
|
multi_do_protocol_frame(1, 0); // provoke positional update if possible
|
||||||
|
|
||||||
multibuf[0] = (char)MULTI_FIRE;
|
multibuf[0] = (char)MULTI_FIRE;
|
||||||
multibuf[1] = (char)Player_num;
|
multibuf[1] = (char)Player_num;
|
||||||
multibuf[2] = (char)laser_gun;
|
multibuf[2] = (char)laser_gun;
|
||||||
|
@ -2355,7 +2362,6 @@ void multi_send_fire(int laser_gun, int laser_level, int laser_flags, int laser_
|
||||||
multibuf[5] = (char)laser_fired;
|
multibuf[5] = (char)laser_fired;
|
||||||
PUT_INTEL_SHORT(multibuf+6, laser_track);
|
PUT_INTEL_SHORT(multibuf+6, laser_track);
|
||||||
|
|
||||||
multi_do_protocol_frame(1, 0); // provoke positional update if possible
|
|
||||||
multi_send_data(multibuf, 8, 1);
|
multi_send_data(multibuf, 8, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ extern int multi_protocol; // set and determinate used protocol
|
||||||
// 3 Descent II Shareware
|
// 3 Descent II Shareware
|
||||||
// 4 Descent II Commercial
|
// 4 Descent II Commercial
|
||||||
// > 4 DXX-Rebirth
|
// > 4 DXX-Rebirth
|
||||||
#define MULTI_PROTO_VERSION 8
|
#define MULTI_PROTO_VERSION 9
|
||||||
// PROTOCOL VARIABLES AND DEFINES - END
|
// PROTOCOL VARIABLES AND DEFINES - END
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -108,8 +108,6 @@ struct _sockaddr TrackerSocket;
|
||||||
int iTrackerVerified = 0;
|
int iTrackerVerified = 0;
|
||||||
#endif
|
#endif
|
||||||
extern obj_position Player_init[MAX_PLAYERS];
|
extern obj_position Player_init[MAX_PLAYERS];
|
||||||
extern char MaxPowerupsAllowed[MAX_POWERUP_TYPES];
|
|
||||||
extern char PowerupsInMine[MAX_POWERUP_TYPES];
|
|
||||||
|
|
||||||
/* General UDP functions - START */
|
/* General UDP functions - START */
|
||||||
ssize_t dxx_sendto(int sockfd, const void *msg, int len, unsigned int flags, const struct sockaddr *to, socklen_t tolen)
|
ssize_t dxx_sendto(int sockfd, const void *msg, int len, unsigned int flags, const struct sockaddr *to, socklen_t tolen)
|
||||||
|
@ -1023,10 +1021,7 @@ void net_udp_receive_sequence_packet(ubyte *data, UDP_sequence_packet *seq, stru
|
||||||
|
|
||||||
void net_udp_init()
|
void net_udp_init()
|
||||||
{
|
{
|
||||||
// So you want to play a netgame, eh? Let's a get a few things
|
// So you want to play a netgame, eh? Let's a get a few things straight
|
||||||
// straight
|
|
||||||
|
|
||||||
int save_pnum = Player_num, t;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
{
|
{
|
||||||
|
@ -1044,12 +1039,6 @@ void net_udp_init()
|
||||||
if( UDP_Socket[1] != -1 )
|
if( UDP_Socket[1] != -1 )
|
||||||
udp_close_socket(1);
|
udp_close_socket(1);
|
||||||
|
|
||||||
for (t=0;t<MAX_POWERUP_TYPES;t++)
|
|
||||||
{
|
|
||||||
MaxPowerupsAllowed[t]=0;
|
|
||||||
PowerupsInMine[t]=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&Netgame, 0, sizeof(netgame_info));
|
memset(&Netgame, 0, sizeof(netgame_info));
|
||||||
memset(&UDP_Seq, 0, sizeof(UDP_sequence_packet));
|
memset(&UDP_Seq, 0, sizeof(UDP_sequence_packet));
|
||||||
memset(&UDP_MData, 0, sizeof(UDP_mdata_info));
|
memset(&UDP_MData, 0, sizeof(UDP_mdata_info));
|
||||||
|
@ -1057,17 +1046,9 @@ void net_udp_init()
|
||||||
UDP_Seq.type = UPID_REQUEST;
|
UDP_Seq.type = UPID_REQUEST;
|
||||||
memcpy(UDP_Seq.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1);
|
memcpy(UDP_Seq.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1);
|
||||||
|
|
||||||
for (Player_num = 0; Player_num < MAX_NUM_NET_PLAYERS; Player_num++)
|
|
||||||
init_player_stats_game();
|
|
||||||
|
|
||||||
Player_num = save_pnum;
|
|
||||||
multi_new_game();
|
multi_new_game();
|
||||||
Network_new_game = 1;
|
|
||||||
Control_center_destroyed = 0;
|
|
||||||
net_udp_flush();
|
net_udp_flush();
|
||||||
|
|
||||||
Netgame.PacketsPerSec = 10;
|
|
||||||
|
|
||||||
#ifdef USE_TRACKER
|
#ifdef USE_TRACKER
|
||||||
// Initialize the tracker info
|
// Initialize the tracker info
|
||||||
udp_tracker_init();
|
udp_tracker_init();
|
||||||
|
@ -2428,6 +2409,7 @@ void net_udp_process_dump(ubyte *data, int len, struct _sockaddr sender_addr)
|
||||||
default:
|
default:
|
||||||
if (data[1] > DUMP_LEVEL) // invalid dump... heh
|
if (data[1] > DUMP_LEVEL) // invalid dump... heh
|
||||||
break;
|
break;
|
||||||
|
Network_status = NETSTAT_MENU;
|
||||||
nm_messagebox(NULL, 1, TXT_OK, NET_DUMP_STRINGS(data[1]));
|
nm_messagebox(NULL, 1, TXT_OK, NET_DUMP_STRINGS(data[1]));
|
||||||
Network_status = NETSTAT_MENU;
|
Network_status = NETSTAT_MENU;
|
||||||
break;
|
break;
|
||||||
|
@ -3141,6 +3123,7 @@ int net_udp_setup_game()
|
||||||
Netgame.RefusePlayers=0;
|
Netgame.RefusePlayers=0;
|
||||||
sprintf( Netgame.game_name, "%s%s", Players[Player_num].callsign, TXT_S_GAME );
|
sprintf( Netgame.game_name, "%s%s", Players[Player_num].callsign, TXT_S_GAME );
|
||||||
Netgame.difficulty=PlayerCfg.DefaultDifficulty;
|
Netgame.difficulty=PlayerCfg.DefaultDifficulty;
|
||||||
|
Netgame.PacketsPerSec = 10;
|
||||||
if (GameArg.MplUdpMyPort != 0)
|
if (GameArg.MplUdpMyPort != 0)
|
||||||
snprintf (UDP_MyPort, sizeof(UDP_MyPort), "%d", GameArg.MplUdpMyPort);
|
snprintf (UDP_MyPort, sizeof(UDP_MyPort), "%d", GameArg.MplUdpMyPort);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue