fixed so that the latnecy doesn't update so fast

This commit is contained in:
Magnus Auvinen 2007-07-26 07:15:52 +00:00
parent 02de672898
commit c1da3b23b6
4 changed files with 37 additions and 6 deletions

View file

@ -1541,9 +1541,14 @@ void modc_render()
sprintf(buf, "%4d", player->score);
gfx_pretty_text(x+60-gfx_pretty_text_width(48,buf), y, 48, buf);
gfx_pretty_text(x+128, y, 48, client_datas[player->clientid].name);
sprintf(buf, "%4d", player->latency);
float tw = gfx_pretty_text_width(48.0f, buf);
gfx_pretty_text(x+w-tw-20, y, 48, buf);
/*sprintf(buf, "%4d", player->latency_flux);
tw = gfx_pretty_text_width(24.0f, buf);
gfx_pretty_text(x+w-tw-20, y+20, 24, buf);*/
render_tee(&idlestate, player->clientid, vec2(1,0), vec2(x+90, y+24));
y += 58.0f;

View file

@ -149,6 +149,7 @@ struct obj_player
int score;
int latency;
int latency_flux;
int emote;
int hook_active;

View file

@ -1006,6 +1006,27 @@ int player::handle_weapons()
void player::tick()
{
// do latency stuff
{
client_info info;
if(server_getclientinfo(client_id, &info))
{
latency_accum += info.latency;
latency_accum_max = max(latency_accum_max, info.latency);
latency_accum_min = min(latency_accum_min, info.latency);
}
if(server_tick()%server_tickspeed() == 0)
{
latency_avg = latency_accum/server_tickspeed();
latency_max = latency_accum_max;
latency_min = latency_accum_min;
latency_accum = 0;
latency_accum_min = 1000;
latency_accum_max = 0;
}
}
// TODO: rework the input to be more robust
// TODO: remove this tick count, it feels weird
if(dead)
@ -1287,11 +1308,8 @@ void player::snap(int snaping_client)
player->vy = (int)vel.y;
player->emote = EMOTE_NORMAL;
player->latency = 0;
client_info info;
if(server_getclientinfo(client_id, &info))
player->latency = info.latency;
player->latency = latency_avg;
player->latency_flux = latency_max-latency_min;
player->ammocount = weapons[active_weapon].ammo;
player->health = 0;
@ -1637,8 +1655,8 @@ void mods_client_enter(int client_id)
void mods_client_drop(int client_id)
{
dbg_msg("mods", "client drop %d", client_id);
players[client_id].client_id = -1;
world.remove_entity(&players[client_id]);
players[client_id].client_id = -1;
}
void mods_message(int msg, int client_id)

View file

@ -246,6 +246,13 @@ public:
bool dead;
int die_tick;
int latency_accum;
int latency_accum_min;
int latency_accum_max;
int latency_avg;
int latency_min;
int latency_max;
// hooking stuff
enum