diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 040420135..f43319b2d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ D2X-Rebirth Changelog 20070925 -------- main/gamecntl.c: Moved some game keys to not apply if Player_is_dead flag is set +main/gamerend.c, main/multi.c, main/network.c, main/network.h: Small fixes for new netgame info screen; Fixed PING routines; Once again fixed some newmenu mouse actions 20070924 -------- diff --git a/main/gamerend.c b/main/gamerend.c index ff6c3c020..63683c1b8 100644 --- a/main/gamerend.c +++ b/main/gamerend.c @@ -268,7 +268,7 @@ void show_netplayerinfo() for (i=0; i<=MAX_PLAYERS; i++) { y+=line_spacing; - if (!Players[i].callsign[0]) + if (!Players[i].connected) continue; if (Game_mode & GM_TEAM) color=get_team(i); @@ -284,7 +284,7 @@ void show_netplayerinfo() gr_printf(x+char_spacing*12,y,"%-6d",Players[i].net_killed_total); } - gr_printf(x+char_spacing*18,y,"%-6d",ping_table[i]); + gr_printf(x+char_spacing*18,y,"%-6d",PingTable[i]); gr_printf(x+char_spacing*23,y,"%d/%d",kill_matrix[Player_num][i],kill_matrix[i][Player_num]); } diff --git a/main/multi.c b/main/multi.c index 98a10c007..d20315bc2 100644 --- a/main/multi.c +++ b/main/multi.c @@ -80,7 +80,6 @@ void multi_add_lifetime_killed(); void multi_add_lifetime_kills(); void multi_send_play_by_play(int num,int spnum,int dpnum); void multi_send_heartbeat(); -void multi_send_modem_ping(); void multi_cap_objects(); void multi_adjust_remote_cap(int pnum); void multi_save_game(ubyte slot, uint id, char *desc); @@ -1175,9 +1174,7 @@ multi_send_message_start() } extern fix StartingShields; -fix PingLaunchTime,PingReturnTime; -extern void network_send_ping (ubyte); extern int network_who_is_master(); extern char NameReturning; extern int force_cockpit_redraw; @@ -4968,31 +4965,6 @@ void multi_do_ranking (char *buf) if (!GameArg.MplNoRankings) HUD_init_message ("%s has been %s to %s!",Players[(int)pnum].callsign,rankstr,RankStrings[(int)rank]); } -void multi_send_modem_ping () -{ - multibuf[0]=MULTI_MODEM_PING; - multi_send_data (multibuf,1,1); -} -void multi_send_modem_ping_return () -{ - multibuf[0]=MULTI_MODEM_PING_RETURN; - multi_send_data (multibuf,1,1); -} - -void multi_do_modem_ping_return () -{ - if (PingLaunchTime==0) - { - mprintf ((0,"Got invalid PING RETURN from opponent!\n")); - return; - } - - PingReturnTime=timer_get_fixed_seconds(); - - HUD_init_message ("Ping time for opponent is %d ms!",f2i(fixmul(PingReturnTime-PingLaunchTime,i2f(1000)))); - PingLaunchTime=0; -} - void multi_quick_sound_hack (int num) { @@ -5375,10 +5347,6 @@ multi_process_data(char *buf, int len) if (!Endlevel_sequence) multi_do_play_by_play(buf); break; case MULTI_RANK: if (!Endlevel_sequence) multi_do_ranking (buf); break; - case MULTI_MODEM_PING: - if (!Endlevel_sequence) multi_send_modem_ping_return(); break; - case MULTI_MODEM_PING_RETURN: - if (!Endlevel_sequence) multi_do_modem_ping_return(); break; #ifndef SHAREWARE case MULTI_FINISH_GAME: multi_do_finish_game(buf); break; // do this one regardless of endsequence diff --git a/main/network.c b/main/network.c index 26bc39da1..4a4c54e13 100644 --- a/main/network.c +++ b/main/network.c @@ -5729,27 +5729,28 @@ void network_ping (ubyte flag,int pnum) #endif } -extern fix PingLaunchTime,PingReturnTime; -int ping_table[MAX_PLAYERS]; +static fix PingLaunchTime[MAX_PLAYERS],PingReturnTime[MAX_PLAYERS]; +fix PingTable[MAX_PLAYERS]; void network_handle_ping_return (ubyte pnum) { - if (PingLaunchTime==0 || pnum>=N_players) + if (PingLaunchTime[pnum]==0 || pnum>=N_players) { mprintf ((0,"Got invalid PING RETURN from %s!\n",Players[pnum].callsign)); return; } - PingReturnTime=timer_get_fixed_seconds(); - ping_table[pnum]=f2i(fixmul(PingReturnTime-PingLaunchTime,i2f(1000))); - PingLaunchTime=0; + + PingReturnTime[pnum]=timer_get_fixed_seconds(); + PingTable[pnum]=f2i(fixmul(PingReturnTime[pnum]-PingLaunchTime[pnum],i2f(1000))); + PingLaunchTime[pnum]=0; } void network_send_ping (ubyte pnum) - { - network_ping (PID_PING_SEND,pnum); - } +{ + network_ping (PID_PING_SEND,pnum); +} -int PingTime=0; +static int PingTime=0; // ping all connected players (except yourself) in 3sec interval and update ping_table void network_ping_all() { @@ -5759,8 +5760,11 @@ void network_ping_all() { for (i=0; i<=MAX_PLAYERS; i++) { - if (Players[i].callsign[0] && i != Player_num) + if (Players[i].connected && i != Player_num) + { + PingLaunchTime[i]=timer_get_fixed_seconds(); network_send_ping(i); + } } PingTime=GameTime; } diff --git a/main/network.h b/main/network.h index 0d444878d..056f015cb 100644 --- a/main/network.h +++ b/main/network.h @@ -206,7 +206,7 @@ void network_send_data(ubyte * ptr, int len, int urgent); // returns 1 if hoard.ham available extern int HoardEquipped(); -extern int ping_table[MAX_PLAYERS]; +extern int PingTable[MAX_PLAYERS]; extern void network_ping_all(); extern int network_who_is_master(void); diff --git a/main/newmenu.c b/main/newmenu.c index a3bedeb12..857370543 100644 --- a/main/newmenu.c +++ b/main/newmenu.c @@ -1419,7 +1419,7 @@ int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item, mouse_get_pos(&mx, &my, &mz); for (i=0; icv_bitmap.bm_x + item[i].x-FONTSCALE_X(HiresGFX?22:10) /*- item[i].right_offset - 6*/; - x2 = x1 + item[i].w-FONTSCALE_X(HiresGFX?22:10); + x2 = x1 + item[i].w+FONTSCALE_X(HiresGFX?22:10); y1 = grd_curcanv->cv_bitmap.bm_y + item[i].y; y2 = y1 + item[i].h; if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) { @@ -1510,7 +1510,7 @@ int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item, } for (i=0; icv_bitmap.bm_x + item[i].x-FONTSCALE_X(HiresGFX?22:10) /*- item[i].right_offset - 6*/; + x1 = grd_curcanv->cv_bitmap.bm_x + item[i].x-FONTSCALE_X(HiresGFX?22:10); x2 = x1 + item[i].w+FONTSCALE_X(HiresGFX?22:10); y1 = grd_curcanv->cv_bitmap.bm_y + item[i].y; y2 = y1 + item[i].h; @@ -1580,8 +1580,8 @@ int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item, if ( !done && !mouse_state && omouse_state && !all_text && (choice != -1) && (item[choice].type == NM_TYPE_MENU) ) { mouse_get_pos(&mx, &my, &mz); for (i=0; icv_bitmap.bm_x + item[i].x-FONTSCALE_X(HiresGFX?22:10) /*- item[i].right_offset - 6*/; - x2 = x1 + item[i].w-FONTSCALE_X(HiresGFX?22:10); + x1 = grd_curcanv->cv_bitmap.bm_x + item[i].x-FONTSCALE_X(HiresGFX?22:10); + x2 = x1 + item[i].w+FONTSCALE_X(HiresGFX?22:10); y1 = grd_curcanv->cv_bitmap.bm_y + item[i].y; y2 = y1 + item[i].h; if (((mx > x1) && (mx < x2)) && ((my > y1) && (my < y2))) { @@ -1593,7 +1593,7 @@ int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item, } } } - + if ( !done && !mouse_state && omouse_state && (choice>-1) && (item[choice].type==NM_TYPE_INPUT_MENU) && (item[choice].group==0)) { item[choice].group = 1; item[choice].redraw = 1;