diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 28c2a2f89..8484275b9 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ 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 -------- main/gamesave.c: Fix crash when loading a level in the editor diff --git a/main/multi.c b/main/multi.c index 699c9c19b..532e134d3 100644 --- a/main/multi.c +++ b/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 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; netgame_info Netgame; @@ -403,15 +398,15 @@ get_team(int pnum) void multi_new_game(void) { - int i; + int i, save_pnum = Player_num; // 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(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++) { @@ -426,21 +421,29 @@ multi_new_game(void) for (i = 0; i < MAX_ROBOTS_CONTROLLED; i++) { - robot_controlled[i] = -1; + robot_controlled[i] = -1; robot_agitation[i] = 0; robot_fired[i] = 0; } + for (i=0;i MULTI_MAX_TYPE) + Error("multi_send_data: Illegal packet type %i\n", buf[0]); 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) { - Assert(len == message_length[(int)buf[0]]); - Assert(buf[0] <= MULTI_MAX_TYPE); - Assert(pnum >= 0 && pnum < MAX_NUM_NET_PLAYERS); + if (len != message_length[(int)buf[0]]) + Error("multi_send_data_direct: 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_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) { @@ -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) { + multi_do_protocol_frame(1, 0); // provoke positional update if possible + multibuf[0] = (char)MULTI_FIRE; multibuf[1] = (char)Player_num; 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; PUT_INTEL_SHORT(multibuf+6, laser_track); - multi_do_protocol_frame(1, 0); // provoke positional update if possible multi_send_data(multibuf, 8, 1); } diff --git a/main/multi.h b/main/multi.h index 67e26bf7d..ea077f47a 100644 --- a/main/multi.h +++ b/main/multi.h @@ -73,7 +73,7 @@ extern int multi_protocol; // set and determinate used protocol // 3 Descent II Shareware // 4 Descent II Commercial // > 4 DXX-Rebirth -#define MULTI_PROTO_VERSION 8 +#define MULTI_PROTO_VERSION 9 // PROTOCOL VARIABLES AND DEFINES - END diff --git a/main/net_udp.c b/main/net_udp.c index 7a11f9add..f5fdb4711 100644 --- a/main/net_udp.c +++ b/main/net_udp.c @@ -108,8 +108,6 @@ struct _sockaddr TrackerSocket; int iTrackerVerified = 0; #endif extern obj_position Player_init[MAX_PLAYERS]; -extern char MaxPowerupsAllowed[MAX_POWERUP_TYPES]; -extern char PowerupsInMine[MAX_POWERUP_TYPES]; /* 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) @@ -1023,10 +1021,7 @@ void net_udp_receive_sequence_packet(ubyte *data, UDP_sequence_packet *seq, stru void net_udp_init() { - // So you want to play a netgame, eh? Let's a get a few things - // straight - - int save_pnum = Player_num, t; + // So you want to play a netgame, eh? Let's a get a few things straight #ifdef _WIN32 { @@ -1044,12 +1039,6 @@ void net_udp_init() if( UDP_Socket[1] != -1 ) udp_close_socket(1); - for (t=0;t DUMP_LEVEL) // invalid dump... heh break; + Network_status = NETSTAT_MENU; nm_messagebox(NULL, 1, TXT_OK, NET_DUMP_STRINGS(data[1])); Network_status = NETSTAT_MENU; break; @@ -3141,6 +3123,7 @@ int net_udp_setup_game() Netgame.RefusePlayers=0; sprintf( Netgame.game_name, "%s%s", Players[Player_num].callsign, TXT_S_GAME ); Netgame.difficulty=PlayerCfg.DefaultDifficulty; + Netgame.PacketsPerSec = 10; if (GameArg.MplUdpMyPort != 0) snprintf (UDP_MyPort, sizeof(UDP_MyPort), "%d", GameArg.MplUdpMyPort); else