From 6fdf44035e6ede7099c74b82a160d3ac6b304d8a Mon Sep 17 00:00:00 2001 From: zicodxx Date: Thu, 15 Sep 2011 10:45:45 +0200 Subject: [PATCH] Added new priority level for MDATA packets to also send them ASAP without the need for an ACK; Streamlined sending multibot and fire packets and on the way artificially and automatically scaling fire rates, energy/ammo usage and damage of weapons in Multiplayer to decrease traffic easy way without changing the Gameplay --- CHANGELOG.txt | 4 +++ main/laser.c | 62 +++++++++++++++++++------------------- main/laser.h | 1 + main/multi.c | 70 +++++++++++++++++++------------------------ main/multi.h | 8 +---- main/multibot.c | 29 ++++++++---------- main/net_udp.c | 79 +++++++++++++++++++++---------------------------- main/net_udp.h | 4 +-- 8 files changed, 113 insertions(+), 144 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 845326d11..3c7c0d336 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D1X-Rebirth Changelog +20110915 +-------- +main/laser.c, main/laser.h, main/multi.c, main/multi.h, main/multibot.c, main/net_udp.c, main/net_udp.h: Added new priority level for MDATA packets to also send them ASAP without the need for an ACK; Streamlined sending multibot and fire packets and on the way artificially and automatically scaling fire rates, energy/ammo usage and damage of weapons in Multiplayer to decrease traffic easy way without changing the Gameplay + 20110914 -------- INSTALL.txt, README.txt, SConstruct, arch/carbon/conf.h, d1x.ini, include/args.h, main/inferno.c, main/kmatrix.c, main/kmatrix.h, main/menu.c, main/multi.c, main/multi.h, misc/args.c: Removed support for IPX protocol and MS-DOS-Multiplayer-compability due to age and lack of real need and to really improve on the Multiplayer without adding too much complexity for backwards-compability diff --git a/main/laser.c b/main/laser.c index 58b75d37b..0bec8f73c 100644 --- a/main/laser.c +++ b/main/laser.c @@ -49,6 +49,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define NEWHOMER +int Network_laser_track = -1; + int find_homing_object_complete(vms_vector *curpos, object *tracker, int track_obj_type1, int track_obj_type2); //--------------------------------------------------------------------------------- @@ -180,6 +182,19 @@ void do_muzzle_stuff(int segnum, vms_vector *pos) Muzzle_queue_index = 0; } +/* + * In effort to reduce weapon fire traffic in Multiplayer games artificially decrease the fire rate down to 100ms between shots. + * This will work for all weapons, even if game is modded. + */ +float weapon_rate_scale(int wp_id) +{ + if ( !(Game_mode & GM_MULTI) ) + return 1.0; + if ( Weapon_info[wp_id].fire_wait >= f0_1 || Weapon_info[wp_id].fire_wait <= 0 ) + return 1.0; + return (f0_1/Weapon_info[wp_id].fire_wait); +} + //--------------------------------------------------------------------------------- // Initializes a laser after Fire is pressed @@ -288,7 +303,7 @@ int Laser_create_new( vms_vector * direction, vms_vector * position, int segnum, if (weapon_type == FLARE_ID) obj->mtype.phys_info.flags |= PF_STICK; //this obj sticks to walls - obj->shields = Weapon_info[obj->id].strength[Difficulty_level]; + obj->shields = Weapon_info[obj->id].strength[Difficulty_level]*weapon_rate_scale(obj->id); // Fill in laser-specific data @@ -856,7 +871,7 @@ void Flare_create(object *obj) { fix energy_usage; - energy_usage = Weapon_info[FLARE_ID].energy_usage; + energy_usage = Weapon_info[FLARE_ID].energy_usage*weapon_rate_scale(FLARE_ID); if (Difficulty_level < 2) energy_usage = fixmul(energy_usage, i2f(Difficulty_level+2)/4); @@ -873,12 +888,7 @@ void Flare_create(object *obj) #ifdef NETWORK if (Game_mode & GM_MULTI) - { - Network_laser_fired = 1; - Network_laser_gun = FLARE_ID+MISSILE_ADJUST; - Network_laser_flags = 0; - Network_laser_level = 0; - } + multi_send_fire(FLARE_ID+MISSILE_ADJUST, 0, 0, 1, -1); #endif } @@ -1148,12 +1158,12 @@ int do_laser_firing_player(void) return 0; weapon_index = Primary_weapon_to_weapon_info[Primary_weapon]; - energy_used = Weapon_info[weapon_index].energy_usage; + energy_used = Weapon_info[weapon_index].energy_usage*weapon_rate_scale(weapon_index); if (Difficulty_level < 2) energy_used = fixmul(energy_used, i2f(Difficulty_level+2)/4); - ammo_used = Weapon_info[weapon_index].ammo_usage; + ammo_used = Weapon_info[weapon_index].ammo_usage*weapon_rate_scale(weapon_index); // addval = 2*FrameTime; // if (addval > F1_0) @@ -1171,7 +1181,7 @@ int do_laser_firing_player(void) //end move - Victor Rachels if (!cheats.rapidfire) - Next_laser_fire_time += Weapon_info[weapon_index].fire_wait; + Next_laser_fire_time += Weapon_info[weapon_index].fire_wait*weapon_rate_scale(weapon_index); else Next_laser_fire_time += F1_0/25; @@ -1307,12 +1317,7 @@ int do_laser_firing(int objnum, int weapon_num, int level, int flags, int nfires // one shooting #ifdef NETWORK if ((Game_mode & GM_MULTI) && (objnum == Players[Player_num].objnum)) - { - Network_laser_fired = nfires; - Network_laser_gun = weapon_num; - Network_laser_flags = flags; - Network_laser_level = level; - } + multi_send_fire(weapon_num, level, flags, nfires, -1); #endif return nfires; @@ -1424,22 +1429,18 @@ void create_smart_children(object *objp) if (numobjs == 0) { for (i=0; i> 15].objnum, PLAYER_SMART_HOMING_ID, make_sound); + create_homing_missile(objp, objlist[(d_rand() * numobjs) >> 15].objnum, PLAYER_SMART_HOMING_ID, make_sound); } else { - int hobjnum; - hobjnum = create_homing_missile(objp, objlist[(d_rand() * numobjs) >> 15].objnum, ROBOT_SMART_HOMING_ID, make_sound); + create_homing_missile(objp, objlist[(d_rand() * numobjs) >> 15].objnum, ROBOT_SMART_HOMING_ID, make_sound); } make_sound = 0; } @@ -1462,6 +1463,8 @@ int Missile_gun=0, Proximity_dropped = 0; void do_missile_firing(int drop_bomb) { int weapon = (drop_bomb) ? PROXIMITY_INDEX : Secondary_weapon; + + Network_laser_track = -1; Assert(weapon < MAX_SECONDARY_WEAPONS); @@ -1473,7 +1476,7 @@ void do_missile_firing(int drop_bomb) weapon_index = Secondary_weapon_to_weapon_info[weapon]; if (!cheats.rapidfire) - Next_missile_fire_time = GameTime64 + Weapon_info[weapon_index].fire_wait; + Next_missile_fire_time = GameTime64 + Weapon_info[weapon_index].fire_wait*weapon_rate_scale(weapon_index); else Next_missile_fire_time = GameTime64 + F1_0/25; @@ -1534,12 +1537,7 @@ void do_missile_firing(int drop_bomb) #ifdef NETWORK if (Game_mode & GM_MULTI) - { - Network_laser_gun = weapon+MISSILE_ADJUST; - Network_laser_level = 0; - Network_laser_flags = (Missile_gun-1); - Network_laser_fired = 1; - } + multi_send_fire(weapon+MISSILE_ADJUST, 0, (Missile_gun-1), 1, Network_laser_track); #endif // don't autoselect if dropping prox and prox not current weapon diff --git a/main/laser.h b/main/laser.h index e317256a6..341f55fbb 100644 --- a/main/laser.h +++ b/main/laser.h @@ -71,6 +71,7 @@ int laser_are_related( int o1, int o2 ); extern int do_laser_firing_player(void); extern void do_missile_firing(int drop_bomb); extern void net_missile_firing(int player, int weapon, int flags); +extern int Network_laser_track; int Laser_create_new( vms_vector * direction, vms_vector * position, int segnum, int parent, int type, int make_sound ); diff --git a/main/multi.c b/main/multi.c index 3c4977a79..e22298a8b 100644 --- a/main/multi.c +++ b/main/multi.c @@ -122,11 +122,6 @@ sbyte object_owner[MAX_OBJECTS]; // Who created each object in my universe, - int Net_create_objnums[MAX_NET_CREATE_OBJECTS]; // For tracking object creation that will be sent to remote int Net_create_loc = 0; // pointer into previous array int Network_status = 0; -int Network_laser_fired = 0; // How many times we shot -int Network_laser_gun; // Which gun number we shot -int Network_laser_flags; // Special flags for the shot -int Network_laser_level; // What level -short Network_laser_track; // Who is it tracking? char Network_message[MAX_MESSAGE_LEN]; int Network_message_reciever=-1; int sorted_kills[MAX_NUM_NET_PLAYERS]; @@ -134,7 +129,6 @@ short kill_matrix[MAX_NUM_NET_PLAYERS][MAX_NUM_NET_PLAYERS]; int multi_goto_secret = 0; short team_kills[2]; int multi_quit_game = 0; -int PacketUrgent = 0; char *GMNames[8]={"Anarchy","Team Anarchy","Robo Anarchy","Cooperative","Unknown","","","Bounty"}; char *GMNamesShrt[8]={"ANRCHY","TEAM","ROBO","COOP","UNKNOWN","","","BOUNTY"}; @@ -1640,7 +1634,7 @@ multi_do_kill(char *buf) multibuf[5] = Netgame.team_vector; multibuf[6] = Bounty_target; - multi_send_data(multibuf, 7, 1); + multi_send_data(multibuf, 7, 2); } killed = Players[pnum].objnum; @@ -2306,21 +2300,17 @@ multi_process_bigdata(char *buf, int len) // players of something we did. // -void multi_send_fire() +void multi_send_fire(int laser_gun, int laser_level, int laser_flags, int laser_fired, short laser_track) { - if (!Network_laser_fired) - return; + multibuf[0] = (char)MULTI_FIRE; + multibuf[1] = (char)Player_num; + multibuf[2] = (char)laser_gun; + multibuf[3] = (char)laser_level; + multibuf[4] = (char)laser_flags; + multibuf[5] = (char)laser_fired; + PUT_INTEL_SHORT(multibuf+6, laser_track); - multibuf[1] = (char)Player_num; - multibuf[2] = (char)Network_laser_gun; - multibuf[3] = (char)Network_laser_level; - multibuf[4] = (char)Network_laser_flags; - multibuf[5] = (char)Network_laser_fired; - PUT_INTEL_SHORT(multibuf+6, Network_laser_track); - multibuf[0] = (char)MULTI_FIRE; - multi_send_data(multibuf, 8, 0); - - Network_laser_fired = 0; + multi_send_data(multibuf, 8, 1); } @@ -2337,7 +2327,7 @@ multi_send_destroy_controlcen(int objnum, int player) multibuf[0] = (char)MULTI_CONTROLCEN; PUT_INTEL_SHORT(multibuf+1, objnum); multibuf[3] = player; - multi_send_data(multibuf, 4, 1); + multi_send_data(multibuf, 4, 2); } void @@ -2352,7 +2342,7 @@ multi_send_endlevel_start(int secret) else if (!multi_goto_secret) multi_goto_secret = 2; - multi_send_data(multibuf, 3, 1); + multi_send_data(multibuf, 3, 2); if (Game_mode & GM_NETWORK) { Players[Player_num].connected = CONNECT_ESCAPE_TUNNEL; @@ -2428,7 +2418,7 @@ multi_send_player_explode(char type) Int3(); // See Rob } - multi_send_data(multibuf, message_length[MULTI_PLAYER_EXPLODE], 1); + multi_send_data(multibuf, message_length[MULTI_PLAYER_EXPLODE], 2); if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) multi_send_decloak(); @@ -2601,7 +2591,7 @@ multi_send_reappear() multibuf[0] = (char)MULTI_REAPPEAR; PUT_INTEL_SHORT(multibuf+1, Players[Player_num].objnum); - multi_send_data(multibuf, 3, 1); + multi_send_data(multibuf, 3, 2); PKilledFlags[Player_num]=0; } @@ -2626,7 +2616,7 @@ multi_send_position(int objnum) count += 14; #endif // send twice while first has priority so the next one will be attached to the next bigdata packet - multi_send_data(multibuf, count, 1); + multi_send_data(multibuf, count, 2); multi_send_data(multibuf, count, 0); } @@ -2672,10 +2662,10 @@ multi_send_kill(int objnum) if (multi_i_am_master()) { multi_compute_kill(killer_objnum, objnum); - multi_send_data(multibuf, count, 1); + multi_send_data(multibuf, count, 2); } else - multi_send_data_direct((ubyte*)multibuf, count, multi_who_is_master(), 1); // I am just a client so I'll only send my kill but not compute it, yet. I'll get response from host so I can compute it correctly + multi_send_data_direct((ubyte*)multibuf, count, multi_who_is_master(), 2); // I am just a client so I'll only send my kill but not compute it, yet. I'll get response from host so I can compute it correctly if (Game_mode & GM_MULTI_ROBOTS) multi_strip_robots(Player_num); @@ -2716,7 +2706,7 @@ multi_send_remobj(int objnum) multibuf[3] = obj_owner; - multi_send_data(multibuf, 4, 1); + multi_send_data(multibuf, 4, 2); if (Network_send_objects && multi_objnum_is_past(objnum)) { @@ -2733,7 +2723,7 @@ multi_send_quit(int why) multibuf[0] = (char)why; multibuf[1] = Player_num; - multi_send_data(multibuf, 2, 1); + multi_send_data(multibuf, 2, 2); } void @@ -2744,7 +2734,7 @@ multi_send_cloak(void) multibuf[0] = MULTI_CLOAK; multibuf[1] = (char)Player_num; - multi_send_data(multibuf, 2, 1); + multi_send_data(multibuf, 2, 2); if (Game_mode & GM_MULTI_ROBOTS) multi_strip_robots(Player_num); @@ -2758,7 +2748,7 @@ multi_send_decloak(void) multibuf[0] = MULTI_DECLOAK; multibuf[1] = (char)Player_num; - multi_send_data(multibuf, 2, 1); + multi_send_data(multibuf, 2, 2); } void @@ -2767,7 +2757,7 @@ multi_send_door_open(int segnum, int side) multibuf[0] = MULTI_DOOR_OPEN; PUT_INTEL_SHORT(multibuf+1, segnum ); multibuf[3] = (sbyte)side; - multi_send_data(multibuf, 4, 1); + multi_send_data(multibuf, 4, 2); } // @@ -2852,7 +2842,7 @@ multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector * #endif // ----------- // Total = 19 - multi_send_data(multibuf, count, 1); + multi_send_data(multibuf, count, 2); if (Network_send_objects && multi_objnum_is_past(objnum)) { @@ -2925,7 +2915,7 @@ multi_send_trigger(int triggernum) multibuf[count] = Player_num; count += 1; multibuf[count] = (ubyte)triggernum; count += 1; - multi_send_data(multibuf, count, 1); + multi_send_data(multibuf, count, 2); } void @@ -3237,7 +3227,7 @@ void multi_send_powcap_update () for (i=0;i1)?1:0); + robot_send_pending[sending] = 0; } if (robot_fired[sending]) { robot_fired[sending] = 0; - multi_send_data((unsigned char*)robot_fire_buf[sending], 18, 0); + multi_send_data((unsigned char*)robot_fire_buf[sending], 18, 1); } if (!(Game_mode & GM_NETWORK)) @@ -390,7 +390,7 @@ multi_send_robot_frame(int sent) } void -multi_send_robot_position_sub(int objnum) +multi_send_robot_position_sub(int objnum, int now) { int loc = 0; short s; @@ -413,7 +413,7 @@ multi_send_robot_position_sub(int objnum) memcpy(&(multibuf[loc]), (ubyte *)&(sp.xo), 14); loc += 14; #endif - multi_send_data(multibuf, loc, 0); + multi_send_data(multibuf, loc, now?1:0); } void @@ -445,9 +445,6 @@ multi_send_robot_position(int objnum, int force) robot_send_pending[Objects[objnum].ctype.ai_info.REMOTE_SLOT_NUM] = 1+force; - if (force & (Game_mode & GM_NETWORK)) - PacketUrgent = 1; - return; } @@ -486,8 +483,6 @@ multi_send_robot_fire(int objnum, int gun_num, vms_vector *fire) Int3(); // ROB! memcpy(robot_fire_buf[slot], multibuf, loc); robot_fired[slot] = 1; -// if (Game_mode & GM_NETWORK) -// PacketUrgent = 1; } else multi_send_data(multibuf, loc, 0); // Not our robot, send ASAP @@ -509,7 +504,7 @@ multi_send_robot_explode(int objnum, int killer) s = (short)objnum_local_to_remote(objnum, (sbyte *)&multibuf[loc+2]); PUT_INTEL_SHORT(multibuf+loc, s); loc += 3; - multi_send_data(multibuf, loc, 1); + multi_send_data(multibuf, loc, 2); multi_delete_controlled_robot(objnum); } @@ -529,7 +524,7 @@ multi_send_create_robot(int station, int objnum, int type) map_objnum_local_to_local((short)objnum); - multi_send_data(multibuf, loc, 1); + multi_send_data(multibuf, loc, 2); } void @@ -559,7 +554,7 @@ multi_send_boss_actions(int bossobjnum, int action, int secondary, int objnum) // Objects[bossobjnum].ctype.ai_info.REMOTE_OWNER = -1; Objects[bossobjnum].ctype.ai_info.REMOTE_SLOT_NUM = 5; // Hands-off period! } - multi_send_data(multibuf, loc, 1); + multi_send_data(multibuf, loc, 2); } #define MAX_ROBOT_POWERUPS 4 @@ -605,7 +600,7 @@ multi_send_create_robot_powerups(object *del_obj) Net_create_loc = 0; - multi_send_data(multibuf, 27, 1); + multi_send_data(multibuf, 27, 2); } void diff --git a/main/net_udp.c b/main/net_udp.c index 4f8d26bfe..e43114c53 100644 --- a/main/net_udp.c +++ b/main/net_udp.c @@ -71,8 +71,8 @@ void net_udp_process_ping(ubyte *data, int data_len, struct _sockaddr sender_add void net_udp_process_pong(ubyte *data, int data_len, struct _sockaddr sender_addr); void net_udp_process_game_info(ubyte *data, int data_len, struct _sockaddr game_addr, int lite_info); void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr sender_addr ); -void net_udp_send_mdata(int priority, fix64 time); -void net_udp_process_mdata (ubyte *data, int data_len, struct _sockaddr sender_addr, int priority); +void net_udp_send_mdata(int needack, fix64 time); +void net_udp_process_mdata (ubyte *data, int data_len, struct _sockaddr sender_addr, int needack); void net_udp_send_pdata(); void net_udp_process_pdata ( ubyte *data, int data_len, struct _sockaddr sender_addr ); void net_udp_read_pdata_short_packet(UDP_frame_info *pd); @@ -2550,10 +2550,10 @@ void net_udp_process_packet(ubyte *data, struct _sockaddr sender_addr, int lengt if (multi_i_am_master()) net_udp_process_pdata( data, length, sender_addr ); break; - case UPID_MDATA_P0: + case UPID_MDATA_PNORM: net_udp_process_mdata( data, length, sender_addr, 0 ); break; - case UPID_MDATA_P1: + case UPID_MDATA_PNEEDACK: net_udp_process_mdata( data, length, sender_addr, 1 ); break; case UPID_MDATA_ACK: @@ -3933,13 +3933,10 @@ void net_udp_send_data( ubyte * ptr, int len, int priority ) if (Endlevel_sequence) return; - if (priority) - PacketUrgent = 1; - if ((UDP_MData.mbuf_size+len) > UPID_MDATA_BUF_SIZE ) { check = ptr[0]; - net_udp_do_frame(1, 0); + net_udp_send_mdata(0, timer_query()); if (UDP_MData.mbuf_size != 0) Int3(); Assert(check == ptr[0]); @@ -3950,6 +3947,9 @@ void net_udp_send_data( ubyte * ptr, int len, int priority ) memcpy( &UDP_MData.mbuf[UDP_MData.mbuf_size], ptr, len ); UDP_MData.mbuf_size += len; + + if (priority) + net_udp_send_mdata((priority==2)?1:0, timer_query()); } void net_udp_timeout_check(fix64 time) @@ -4013,7 +4013,6 @@ void net_udp_timeout_player(int playernum) void net_udp_do_frame(int force, int listen) { - int send_mdata = (Network_laser_fired || force || PacketUrgent); fix64 time = 0; static fix64 last_send_time = 0, last_endlevel_time = 0, last_bcast_time = 0; @@ -4022,37 +4021,27 @@ void net_udp_do_frame(int force, int listen) time = timer_query(); - net_udp_ping_frame(time); - if (WaitForRefuseAnswer && time>(RefuseTimeLimit+(F1_0*12))) WaitForRefuseAnswer=0; // Send player position packet (and endlevel if needed) - if (time >= (last_send_time+(F1_0/Netgame.PacketsPerSec))) + if (force || time >= (last_send_time+(F1_0/Netgame.PacketsPerSec))) { + net_udp_noloss_process_queue(time); multi_send_robot_frame(0); - last_send_time = time; - net_udp_send_pdata(); - - send_mdata = 1; + net_udp_send_mdata(0, time); } - if (send_mdata) - { - multi_send_fire(); // Do firing if needed.. - net_udp_send_mdata(PacketUrgent, time); - } - - net_udp_noloss_process_queue(time); - if ((time>=last_endlevel_time+F1_0) && Control_center_destroyed) { last_endlevel_time = time; net_udp_send_endlevel_packet(); } + net_udp_ping_frame(time); + // broadcast lite_info every 10 seconds if (multi_i_am_master() && time>=last_bcast_time+(F1_0*10)) { @@ -4111,8 +4100,6 @@ void net_udp_do_frame(int force, int listen) } } #endif - - PacketUrgent = 0; } /* CODE FOR PACKET LOSS PREVENTION - START */ @@ -4280,7 +4267,7 @@ void net_udp_noloss_process_queue(fix64 time) memset(&buf, 0, sizeof(UDP_mdata_info)); // Prepare the packet and send it - buf[len] = UPID_MDATA_P1; len++; + buf[len] = UPID_MDATA_PNEEDACK; len++; buf[len] = UDP_mdata_queue[queuec].Player_num; len++; PUT_INTEL_INT(buf + len, UDP_mdata_queue[queuec].pkt_num); len += 4; memcpy(&buf[len], UDP_mdata_queue[queuec].data, sizeof(char)*UDP_mdata_queue[queuec].data_size); @@ -4306,7 +4293,7 @@ void net_udp_noloss_process_queue(fix64 time) } /* CODE FOR PACKET LOSS PREVENTION - END */ -void net_udp_send_mdata_direct(ubyte *data, int data_len, int pnum, int priority) +void net_udp_send_mdata_direct(ubyte *data, int data_len, int pnum, int needack) { ubyte buf[sizeof(UDP_mdata_info)]; ubyte pack[MAX_PLAYERS]; @@ -4322,20 +4309,20 @@ void net_udp_send_mdata_direct(ubyte *data, int data_len, int pnum, int priority Error("Client sent direct data to non-Host in net_udp_send_mdata_direct()!\n"); if (!Netgame.PacketLossPrevention) - priority = 0; + needack = 0; memset(&buf, 0, sizeof(UDP_mdata_info)); memset(&pack, 1, sizeof(ubyte)*MAX_PLAYERS); pack[pnum] = 0; - if (priority) - buf[len] = UPID_MDATA_P1; + if (needack) + buf[len] = UPID_MDATA_PNEEDACK; else - buf[len] = UPID_MDATA_P0; + buf[len] = UPID_MDATA_PNORM; len++; buf[len] = Player_num; len++; - if (priority) + if (needack) { UDP_MData.pkt_num++; PUT_INTEL_INT(buf + len, UDP_MData.pkt_num); len += 4; @@ -4344,11 +4331,11 @@ void net_udp_send_mdata_direct(ubyte *data, int data_len, int pnum, int priority sendto (UDP_Socket[0], buf, len, 0, (struct sockaddr *)&Netgame.players[pnum].protocol.udp.addr, sizeof(struct _sockaddr)); - if (priority) + if (needack) net_udp_noloss_add_queue_pkt(UDP_MData.pkt_num, timer_query(), data, data_len, Player_num, pack); } -void net_udp_send_mdata(int priority, fix64 time) +void net_udp_send_mdata(int needack, fix64 time) { ubyte buf[sizeof(UDP_mdata_info)]; ubyte pack[MAX_PLAYERS]; @@ -4361,18 +4348,18 @@ void net_udp_send_mdata(int priority, fix64 time) return; if (!Netgame.PacketLossPrevention) - priority = 0; + needack = 0; memset(&buf, 0, sizeof(UDP_mdata_info)); memset(&pack, 1, sizeof(ubyte)*MAX_PLAYERS); - if (priority) - buf[len] = UPID_MDATA_P1; + if (needack) + buf[len] = UPID_MDATA_PNEEDACK; else - buf[len] = UPID_MDATA_P0; + buf[len] = UPID_MDATA_PNORM; len++; buf[len] = Player_num; len++; - if (priority) + if (needack) { UDP_MData.pkt_num++; PUT_INTEL_INT(buf + len, UDP_MData.pkt_num); len += 4; @@ -4396,7 +4383,7 @@ void net_udp_send_mdata(int priority, fix64 time) pack[0] = 0; } - if (priority) + if (needack) net_udp_noloss_add_queue_pkt(UDP_MData.pkt_num, time, UDP_MData.mbuf, UDP_MData.mbuf_size, Player_num, pack); // Clear UDP_MData except pkt_num. That one must not be deleted so we can clearly keep track of important packets. @@ -4406,9 +4393,9 @@ void net_udp_send_mdata(int priority, fix64 time) memset(&UDP_MData.mbuf, 0, sizeof(ubyte)*UPID_MDATA_BUF_SIZE); } -void net_udp_process_mdata (ubyte *data, int data_len, struct _sockaddr sender_addr, int priority) +void net_udp_process_mdata (ubyte *data, int data_len, struct _sockaddr sender_addr, int needack) { - int pnum = data[1], dataoffset = (priority?6:2); + int pnum = data[1], dataoffset = (needack?6:2); // Check if packet might be bogus if ((pnum < 0) || (data_len > sizeof(UDP_mdata_info))) @@ -4430,8 +4417,8 @@ void net_udp_process_mdata (ubyte *data, int data_len, struct _sockaddr sender_a } } - // Add priority packet and check for possible redundancy - if (priority) + // Add needack packet and check for possible redundancy + if (needack) { if (!net_udp_noloss_validate_mdata(GET_INTEL_SHORT(&data[2]), pnum, sender_addr)) return; @@ -4454,7 +4441,7 @@ void net_udp_process_mdata (ubyte *data, int data_len, struct _sockaddr sender_a } } - if (priority && N_players > 2) + if (needack && N_players > 2) { net_udp_noloss_add_queue_pkt(GET_INTEL_SHORT(&data[2]), timer_query(), data+dataoffset, data_len-dataoffset, pnum, pack); } diff --git a/main/net_udp.h b/main/net_udp.h index 2180553c8..0e171825b 100644 --- a/main/net_udp.h +++ b/main/net_udp.h @@ -67,8 +67,8 @@ void net_udp_send_mdata_direct(ubyte *data, int data_len, int pnum, int priority #define UPID_ENDLEVEL_C 15 // Packet from Client to Host containing connect-state and kills information from this Client. #define UPID_PDATA_H 16 // Packet from Host to all Clients containing all players movement data. #define UPID_PDATA_C 17 // Packet from Client to Host containing his movement data. -#define UPID_MDATA_P0 18 // Packet containing multi buffer from a player. Priority 0 - no ACK needed. -#define UPID_MDATA_P1 19 // Packet containing multi buffer from a player. Priority 1 - ACK needed. Also contains pkt_num +#define UPID_MDATA_PNORM 18 // Packet containing multi buffer from a player. Priority 0,1 - no ACK needed. +#define UPID_MDATA_PNEEDACK 19 // Packet containing multi buffer from a player. Priority 2 - ACK needed. Also contains pkt_num #define UPID_MDATA_ACK 20 // ACK packet for UPID_MDATA_P1. #define UPID_MAX_SIZE 1024 // Max size for a packet #define UPID_MDATA_BUF_SIZE 454