Small fixes for new netgame info screen; Doing PING routines D2X-way while trying to keep compability to other D1X versions

This commit is contained in:
zicodxx 2007-09-26 18:30:48 +00:00
parent 278779936b
commit 636b244f53
10 changed files with 68 additions and 353 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20070925
--------
main/SConstruct, main/game.c, main/gauges.c, main/multi.c, main/network.c, main/network.h, main/nncoms.c: Small fixes for new netgame info screen; Doing PING routines D2X-way while trying to keep compability to other D1X versions
20070924
--------
main/newmenu.c: Removed key shortcuts for menus

View file

@ -143,7 +143,6 @@ common_sources = [
'main/paging.c',
'main/physics.c',
'main/piggy.c',
'main/pingstat.c',
'main/playsave.c',
'main/polyobj.c',
'main/powerup.c',

View file

@ -106,7 +106,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "radar.h"
#include "vers_id.h"
#include "ban.h"
#include "pingstat.h"
#include "vlcnfire.h"
#include "fvi.h"
//MD2211
@ -619,54 +618,8 @@ void show_framerate()
}
#ifdef NETWORK
void show_netplayerinfo(){
// int j,x1,x2,x3,x4,x5,w,h,aw,y;
// char buf[6];
//
// y=FONTSCALE_Y(25);
// gr_set_curfont( GAME_FONT );
// gr_set_fontcolor(gr_getcolor(0,31,0),-1 );
// gr_printf(0,y,"Lifetime Effeciency: %i%% (%i/%i)",
// (multi_kills_stat+Players[Player_num].net_killed_total+multi_deaths_stat+Players[Player_num].net_kills_total)?((multi_kills_stat+Players[Player_num].net_kills_total)*100)/(multi_deaths_stat+Players[Player_num].net_killed_total+multi_kills_stat+Players[Player_num].net_kills_total):0,
// multi_kills_stat+Players[Player_num].net_kills_total,
// multi_deaths_stat+Players[Player_num].net_killed_total);
// y+=FONTSCALE_Y(GAME_FONT->ft_h+2);
// gr_printf(0,y,"pps: %i",Network_pps);
//
// gr_get_string_size("pps: 20 ", &x1, &h, &aw );
// gr_printf(x1,y,"level: %i:%02i:%02i",Players[Player_num].hours_level,f2i(Players[Player_num].time_level) / 60 % 60,f2i(Players[Player_num].time_level) % 60);//w was 40
//
// gr_get_string_size("level: 24:37:56 ", &w, &h, &aw );
// gr_printf(x1+w,y,"total: %i:%02i:%02i",Players[Player_num].hours_total,f2i(Players[Player_num].time_total) / 60 % 60,f2i(Players[Player_num].time_total) % 60);//x1+w was 110
//
// gr_get_string_size("ABCDEFGH 999/", &x1, &h, &aw );
// gr_get_string_size("999(", &x2, &h, &aw );x2+=x1;
// gr_get_string_size("100%)", &x3, &h, &aw );x3+=x2;
// gr_get_string_size(" ", &x4, &h, &aw );x4+=x3;
// gr_get_string_size("shrt ", &x5, &h, &aw );x5+=x4;
// for (j=0;j<MAX_PLAYERS;j++){
// y+=FONTSCALE_Y(GAME_FONT->ft_h+2);
// if (!Players[j].callsign[0]) continue;//don't print blank entries
// if (Players[j].connected != 1)
// gr_set_fontcolor(gr_getcolor(12, 12, 12), -1);
// else
// gr_set_fontcolor(gr_getcolor(player_rgb[j].r,player_rgb[j].g,player_rgb[j].b),-1 );
// gr_printf(0,y,"%s",Players[j].callsign);
//
// sprintf(buf,"%i/",Players[j].net_kills_total);
// gr_get_string_size(buf, &w, &h, &aw );
// gr_string(x1-w,y,buf);//was 62-w
// sprintf(buf,"%i(",Players[j].net_killed_total);
// gr_get_string_size(buf, &w, &h, &aw );
// gr_string(x2-w,y,buf);//was 80-w
// sprintf(buf,"%i%%)",(Players[j].net_killed_total+Players[j].net_kills_total)?(Players[j].net_kills_total*100)/(Players[j].net_killed_total+Players[j].net_kills_total):0);
// gr_get_string_size(buf, &w, &h, &aw );
// if(w>x3-x2) w=x3-x2;//was 22
// gr_string(x3-w,y,buf);//was 103-w
//
// gr_printf(x4,y,"%s",((j==Player_num)?Network_short_packets:Net_D1xPlayer[j].shp)?"shrt":"long");//x4 was 110
// gr_printf(x5,y,"%s",(j==Player_num)?DESCENT_VERSION:Net_D1xPlayer[j].ver);//x5 was 136
// }
void show_netplayerinfo()
{
int x=0, y=0, i=0, color=0;
int line_spacing=FONTSCALE_Y(GAME_FONT->ft_h+1), char_spacing=FONTSCALE_X(GAME_FONT->ft_w+1);
char *NetworkModeNames[]={"Anarchy","Team Anarchy","Robo Anarchy","Cooperative","Capture the Flag","Hoard","Team Hoard","Unknown"};
@ -724,11 +677,13 @@ void show_netplayerinfo(){
gr_printf(x+char_spacing*18,y,"ping");
gr_printf(x+char_spacing*23,y,"efficiency");
network_ping_all();
// process players table
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);
@ -744,7 +699,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",fixmuldiv(ping_stats_getping(i),1000,F1_0));
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]);
}
@ -766,34 +721,6 @@ void show_netplayerinfo(){
gr_printf(x+char_spacing*8,y,"%i",team_kills[1]);
y+=line_spacing*2;
}
// else
// y+=line_spacing*4;
//
// gr_set_fontcolor(255,-1);
//
// // additional information about game - hoard, ranking
// eff=(int)((float)((float)Netlife_kills/((float)Netlife_killed+(float)Netlife_kills))*100.0);
// if (eff<0)
// eff=0;
//
// if (Game_mode & GM_HOARD)
// {
// if (PhallicMan==-1)
// gr_printf(0x8000,y,"There is no record yet for this level.");
// else
// gr_printf(0x8000,y,"%s has the record at %d points.",Players[PhallicMan].callsign,PhallicLimit);
// }
// else if (!GameArg.MplNoRankings)
// {
// gr_printf(0x8000,y,"Your lifetime efficiency of %d%% (%d/%d)",eff,Netlife_kills,Netlife_killed);
// y+=line_spacing;
// if (eff<60)
// gr_printf(0x8000,y,"is %s your ranking.",eff_strings[eff/10]);
// else
// gr_printf(0x8000,y,"is serving you well.");
// y+=line_spacing;
// gr_printf(0x8000,y,"your rank is: %s",RankStrings[GetMyNetRanking()]);
// }
}
#endif
@ -1832,7 +1759,6 @@ void game()
#ifdef NETWORK
readbans();
ping_stats_init();
#endif
if ( setjmp(LeaveGame)==0 ) {

View file

@ -51,7 +51,6 @@ static char rcsid[] = "$Id: gauges.c,v 1.2 2006/03/18 23:08:13 michaelstather Ex
#include "text.h"
#include "render.h"
#include "piggy.h"
#include "pingstat.h"
#ifdef OGL
#include "ogl_init.h"
#endif

View file

@ -73,10 +73,6 @@ static char rcsid[] = "$Id: multi.c,v 1.1.1.1 2006/03/17 19:43:22 zicodxx Exp $"
#include "ignore.h"
//End addition by GRiM FisH
//added 11/01/98 Matt Mueller
#include "pingstat.h"
//end addition -MM
//added 03/04/99 Matt Mueller
#include "byteswap.h"
#include "types.h"
@ -2373,10 +2369,8 @@ multi_process_data(char *buf, int len)
}break;
case MULTI_PONG:
if (!Endlevel_sequence) {
int pingtime;
mprintf((0,"got DIRECTPONG from %i\n",buf[1]));
pingtime = timer_get_fixed_seconds() - (u_int32_t)swapint(*(u_int32_t*)(buf+2));
hud_message(MSGC_GAME_FEEDBACK, "%s %s %ums", "Ping response from ",Players[(int)buf[1]].callsign, fixmuldiv(pingtime, 1000, F1_0));
network_handle_ping_return (buf[1]);
}break;
//end addition -MM

View file

@ -72,10 +72,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "ignore.h"
// End addition by GRiM FisH
//added 03/04/99 Matt Mueller
#include "pingstat.h"
//end addition -MM
//added 04/23/99 Victor Rachels for alt vulcan fire
#include "vlcnfire.h"
//end addition -MM
@ -3653,15 +3649,15 @@ void network_read_pdata_packet(ubyte *data, int short_packet)
}
// get player number of master
// (the lowest numbered connected player)
int network_whois_master() {
int i;
for (i = 0; i < Netgame.numplayers; i++)
if (Netgame.players[i].connected)
return i;
Error("No players in netgame");
}
// // get player number of master
// // (the lowest numbered connected player)
// int network_whois_master() {
// int i;
// for (i = 0; i < Netgame.numplayers; i++)
// if (Netgame.players[i].connected)
// return i;
// Error("No players in netgame");
// }
int network_who_is_master(void)
{
@ -3678,6 +3674,50 @@ int network_who_is_master(void)
return Player_num;
}
static fix PingLaunchTime[MAX_PLAYERS],PingReturnTime[MAX_PLAYERS];
fix PingTable[MAX_PLAYERS];
void network_handle_ping_return (ubyte pnum)
{
if (PingLaunchTime[pnum]==0 || pnum>=N_players)
{
mprintf ((0,"Got invalid PING RETURN from %s!\n",Players[pnum].callsign));
return;
}
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)
{
multibuf[0]=MULTI_PING;
multibuf[1]=Player_num;
*(u_int32_t*)(multibuf+2)=swapint(timer_get_fixed_seconds());
mekh_send_direct_packet(multibuf,2+4,pnum);
}
static int PingTime=0;
// ping all connected players (except yourself) in 3sec interval and update ping_table
void network_ping_all()
{
int i;
if (PingTime+(F1_0*3)<GameTime)
{
for (i=0; i<=MAX_PLAYERS; i++)
{
if (Players[i].connected && i != Player_num)
{
PingLaunchTime[i]=timer_get_fixed_seconds();
network_send_ping(i);
}
}
PingTime=GameTime;
}
}
void DoRefuseStuff (sequence_packet *their)
{
int i;

View file

@ -157,6 +157,10 @@ extern int Network_pps; // packets per second
extern int network_who_is_master(void);
extern int PingTable[MAX_PLAYERS];
extern void network_ping_all();
extern void network_handle_ping_return (ubyte pnum);
// By putting an up-to-20-char-message into Network_message and
// setting Network_message_reciever to the player num you want to
// send it to (100 for broadcast) the next frame the player will

View file

@ -332,127 +332,4 @@ void recon_by_number (int reconnum) //reconnect by player number command...
Netgame.players[player_list[reconnum - 1]].connected = 1;
return;
}
void ping_by_name(char * pingname)
{
//edited 3/04/99 Matt Mueller - replaced outdated ver with new one
int pl;
//--killed-- //Send only to the recepient in the message..
//--killed-- if(!stricmp(pingname, Players[Player_num].callsign))
//--killed-- {
//--killed-- hud_message(MSGC_GAME_FEEDBACK,"You cannot ping yourself!");
//--killed-- return;
//--killed-- }
//--killed-- for(pl = 0; pl < MAX_NUM_NET_PLAYERS; pl++)
//--killed-- {
//--killed-- if (!stricmp(Players[pl].callsign, pingname))
//--killed-- {
//--killed-- //send only to the specified user.
//--killed-- Network_message_reciever = pl;
//--killed-- sprintf(Network_message, "PING:%lu", timer_get_fixed_seconds());
//--killed-- multi_send_message();
//--killed-- hud_message(MSGC_GAME_FEEDBACK,"Pinging %s...", Players[pl].callsign);
//--killed-- return;
//--killed-- }
//--killed-- }
//--killed-- //Bad username
//Send only to the recepient in the message..
for(pl = 0; pl < MAX_NUM_NET_PLAYERS; pl++)
if (pl!=Player_num && !strnicmp(Players[pl].callsign, pingname, strlen(pingname)))
{
//send only to the specified user.
ping_by_player_num(pl,1);
return;
}
//Bad username
hud_message(MSGC_GAME_FEEDBACK, "PING: %s doesn't exist!", pingname);
//end edit -MM
return;
}
void ping_by_number (int pingnum)
{
int player_list[MAX_NUM_NET_PLAYERS];
int n = multi_get_kill_list(player_list);
if((pingnum <= 0) || (pingnum > n))
{
//Bad usernum
hud_message(MSGC_GAME_FEEDBACK,"PINGN: Player number %i doesn't exist!",pingnum);
Network_message[0]= 0;
multi_message_index = 0;
multi_sending_message = 0;
return;
}
//Send only to the recepient in the message..
if(player_list[pingnum - 1] == Player_num)
{
hud_message(MSGC_GAME_FEEDBACK,"You cannot ping yourself!");
return;
}
//send only to the specified user.
//edited 03/04/99 Matt Mueller - use generic func
//--killed-- Network_message_reciever = player_list[pingnum - 1];
//--killed-- sprintf(Network_message, "PING:%lu %i", timer_get_fixed_seconds(),player_list[pingnum - 1];);
//--killed-- multi_send_message();
//--killed-- hud_message(MSGC_GAME_FEEDBACK,"Pinging %s...", Players[player_list[pingnum - 1]].callsign);
ping_by_player_num(player_list[pingnum - 1],1);
//end edit -MM
return;
}
//added 03/04/99 Matt Mueller - move it all into one func. duplication==bad.
void ping_by_player_num(int pl,int noisy)
{
// static char tmp_message[MAX_MESSAGE_LEN];
//Send only to the recepient in the message..
if ((pl < MAX_NUM_NET_PLAYERS) && Players[pl].connected && pl!=(Player_num))
{
if (Net_D1xPlayer[pl].iver>=D1X_DIRECTPING_IVER){
multibuf[0]=MULTI_PING;
multibuf[1]=Player_num;
*(u_int32_t*)(multibuf+2)=swapint(timer_get_fixed_seconds());
// ipx_send_packet_data( multibuf, 2+sizeof(long), Netgame.players[pl].server, Netgame.players[pl].node, Players[pl].net_address);
//printf("blah. %i %i %i\n",multibuf[0],multibuf[1],2+4);
mekh_send_direct_packet(multibuf,2+4,pl);
}else{
//send only to the specified user.
// strcpy(tmp_message,Network_message);
// Network_message_reciever = pl;
// sprintf(Network_message, "PING:%lu %i", timer_get_fixed_seconds(),pl);
// multi_send_message();
multibuf[0] = (char)MULTI_MESSAGE;
multibuf[1] = (char)Player_num;
sprintf((char*)multibuf+2, "PING:%u %i", timer_get_fixed_seconds(),pl);
//edit 04/19/99 Matt Mueller - use direct sending
//--killed-- multi_send_data(multibuf,message_length[MULTI_MESSAGE],1);
mekh_send_direct_packet(multibuf,message_length[MULTI_MESSAGE],pl);
//end edit -MM
// strcpy(Network_message,tmp_message);
}
if (noisy)
hud_message(MSGC_GAME_FEEDBACK, "Pinging %s...", Players[pl].callsign);
return;// 1;
}
//Bad username
if (noisy)
hud_message(MSGC_GAME_FEEDBACK, "PING: Player_num %i doesn't exist!", pl);
return;
}
void ping_all(int noisy)
{
// Network_message_reciever = 100;
// sprintf(Network_message, "PING:%lu", timer_get_fixed_seconds());
// multi_send_message();
int i;
for (i=0;i<MAX_NUM_NET_PLAYERS;i++)
ping_by_player_num(i,0);//it handles all error cases, so don't worry here.
if (noisy)
hud_message(MSGC_GAME_FEEDBACK,"Pinging...");
}
//end addition -MM
#endif //ifdef NETWORK

View file

@ -1,115 +0,0 @@
/* pingstat.c by Victor Rachels for constant ping/stat info */
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "game.h"
#include "fix.h"
#include "args.h"
#include "network.h"
#include "multi.h"
#include "player.h"
#include "timer.h"
//added 03/04/99 Matt Mueller - use generic pingfunc. duplication==bad.
#include "nncoms.h"
//end addition -MM
#ifdef NETWORK
int ping_stats_on = 0;
fix ping_last_time = 0;
fix ping_next_reset = 0;
int ping_list[MAX_NUM_NET_PLAYERS];
int ping_received_list[MAX_NUM_NET_PLAYERS][2];
void ping_stats_frame()
{
if(!ping_stats_on)
return; //shouldn't be here
if(ping_next_reset<GameTime)
{
int i;
for(i=0;i<MAX_NUM_NET_PLAYERS;i++)
{
ping_received_list[i][0]=0;
ping_received_list[i][1]=0;
}
ping_next_reset=GameTime+F1_0*300;
}
if((ping_last_time+F1_0*3)<GameTime)
{
int i;
for(i=0;i<MAX_NUM_NET_PLAYERS;i++)
if(Players[i].connected)
{
//edited 03/04/99 Matt Mueller - use generic pingfunc. duplication==bad.
//--killed-- char old_message[MAX_MESSAGE_LEN];
//--killed-- strcpy(old_message,Network_message);
//--killed-- Network_message_reciever = i;
//--killed-- sprintf(Network_message, "PING:%lu %i", timer_get_fixed_seconds(),i);
//--killed-- multi_send_message();
//--killed-- strcpy(Network_message,old_message);
if(Net_D1xPlayer[i].iver)
{
ping_by_player_num(i,0);
//end edit -MM
ping_received_list[i][0]++;
}
}
else
{
ping_list[i] = 0;
ping_received_list[i][0]=0;
ping_received_list[i][1]=0;
}
ping_last_time = GameTime;
}
}
void ping_stats_received(int pl,int pingtime)
{
if(!ping_stats_on)
return;
ping_list[pl]=pingtime;
ping_received_list[pl][1]++;
}
int ping_stats_getping(int pl)
{
return ping_list[pl];
}
int ping_stats_getsent(int pl)
{
if(ping_received_list[pl][0])
return ping_received_list[pl][0];
else
return 1;
}
int ping_stats_getgot(int pl)
{
return ping_received_list[pl][1];
}
//added on 4/17/99 by Victor Rachels for ping while pingstats on
void ping_stats_sentping(int pl)
{
ping_received_list[pl][0]++;
return;
}
//end this addition - VR
void ping_stats_init()
{
memset(ping_list,0,MAX_NUM_NET_PLAYERS*sizeof(fix));
memset(ping_received_list,0,MAX_NUM_NET_PLAYERS*2*sizeof(int));
ping_last_time = GameTime;
ping_next_reset = GameTime;
}
#endif

View file

@ -1,13 +0,0 @@
#ifndef PINGSTAT_H
#define PINGSTAT_H
#ifdef NETWORK
void ping_stats_frame();
void ping_stats_received(int pl, int pingtime);
void ping_stats_init();
void ping_stats_sentping();
int ping_stats_getping(int pl);
int ping_stats_getsent(int pl);
int ping_stats_getgot(int pl);
#endif
#endif