mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
fixed so that the latnecy doesn't update so fast
This commit is contained in:
parent
02de672898
commit
c1da3b23b6
|
@ -1541,10 +1541,15 @@ 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;
|
||||
}
|
||||
|
|
|
@ -149,6 +149,7 @@ struct obj_player
|
|||
|
||||
int score;
|
||||
int latency;
|
||||
int latency_flux;
|
||||
int emote;
|
||||
|
||||
int hook_active;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -247,6 +247,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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue