mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
improved the prediction timer to handle crappy connections better
This commit is contained in:
parent
30695c09a8
commit
24899a13e8
|
@ -18,7 +18,7 @@ def get_server_info(address, port):
|
||||||
server_info["version"] = slots[0]
|
server_info["version"] = slots[0]
|
||||||
server_info["name"] = slots[1]
|
server_info["name"] = slots[1]
|
||||||
server_info["map"] = slots[2]
|
server_info["map"] = slots[2]
|
||||||
server_info["gametype_id"] = int(slots[3])
|
server_info["gametype"] = slots[3]
|
||||||
server_info["flags"] = int(slots[4])
|
server_info["flags"] = int(slots[4])
|
||||||
server_info["progression"] = int(slots[5])
|
server_info["progression"] = int(slots[5])
|
||||||
server_info["num_players"] = int(slots[6])
|
server_info["num_players"] = int(slots[6])
|
||||||
|
@ -83,17 +83,49 @@ def get_all_servers():
|
||||||
addr = "master%d.teeworlds.com"%i
|
addr = "master%d.teeworlds.com"%i
|
||||||
list = get_servers(addr)
|
list = get_servers(addr)
|
||||||
if list:
|
if list:
|
||||||
print addr, "had", len(list), "servers"
|
#print addr, "had", len(list), "servers"
|
||||||
servers += list
|
servers += list
|
||||||
return servers
|
return servers
|
||||||
|
|
||||||
servers = get_all_servers()
|
servers = get_all_servers()
|
||||||
total_players = 0
|
total_players = 0
|
||||||
|
players_per_versions = {}
|
||||||
|
versions = {}
|
||||||
|
gametypes = {}
|
||||||
if 1:
|
if 1:
|
||||||
for server in servers:
|
for server in servers:
|
||||||
print "checking server", server[0], server[1]
|
#print "checking server", server[0], server[1]
|
||||||
info = get_server_info(server[0], server[1])
|
info = get_server_info(server[0], server[1])
|
||||||
if info:
|
if info:
|
||||||
total_players += len(info["players"])
|
total_players += len(info["players"])
|
||||||
|
if info["version"] in versions:
|
||||||
|
versions[info["version"]] += 1
|
||||||
|
else:
|
||||||
|
versions[info["version"]] = 1
|
||||||
|
|
||||||
|
if info["version"] in players_per_versions:
|
||||||
|
players_per_versions[info["version"]] += len(info["players"])
|
||||||
|
else:
|
||||||
|
players_per_versions[info["version"]] = len(info["players"])
|
||||||
|
|
||||||
|
if info["gametype"] in gametypes:
|
||||||
|
gametypes[info["gametype"]] += 1
|
||||||
|
else:
|
||||||
|
gametypes[info["gametype"]] = 1
|
||||||
|
|
||||||
|
print total_players
|
||||||
|
|
||||||
|
if 0:
|
||||||
|
print total_players, "on", len(servers), 'servers'
|
||||||
|
print "versions:"
|
||||||
|
for v in versions:
|
||||||
|
print "\t",v, versions[v]
|
||||||
|
|
||||||
|
print "players per version:"
|
||||||
|
for v in players_per_versions:
|
||||||
|
print "\t",v, players_per_versions[v]
|
||||||
|
|
||||||
|
print "gametypes:"
|
||||||
|
for v in gametypes:
|
||||||
|
print "\t",v, gametypes[v]
|
||||||
|
|
||||||
print total_players, "on", len(servers), 'servers'
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <mastersrv/mastersrv.h>
|
#include <mastersrv/mastersrv.h>
|
||||||
#include <versionsrv/versionsrv.h>
|
#include <versionsrv/versionsrv.h>
|
||||||
|
|
||||||
const int prediction_margin = 7; /* magic network prediction value */
|
const int prediction_margin = 1000/50; /* magic network prediction value */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Server Time
|
Server Time
|
||||||
|
@ -103,7 +103,7 @@ static struct /* TODO: handle input better */
|
||||||
{
|
{
|
||||||
int data[MAX_INPUT_SIZE]; /* the input data */
|
int data[MAX_INPUT_SIZE]; /* the input data */
|
||||||
int tick; /* the tick that the input is for */
|
int tick; /* the tick that the input is for */
|
||||||
int64 game_time; /* prediction latency when we sent this input */
|
int64 predicted_time; /* prediction latency when we sent this input */
|
||||||
int64 time;
|
int64 time;
|
||||||
} inputs[200];
|
} inputs[200];
|
||||||
static int current_input = 0;
|
static int current_input = 0;
|
||||||
|
@ -117,6 +117,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
float min, max;
|
float min, max;
|
||||||
float values[GRAPH_MAX];
|
float values[GRAPH_MAX];
|
||||||
|
float colors[GRAPH_MAX][3];
|
||||||
int index;
|
int index;
|
||||||
} GRAPH;
|
} GRAPH;
|
||||||
|
|
||||||
|
@ -127,26 +128,56 @@ static void graph_init(GRAPH *g, float min, float max)
|
||||||
g->index = 0;
|
g->index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void graph_add(GRAPH *g, float v)
|
static void graph_scale_max(GRAPH *g)
|
||||||
{
|
{
|
||||||
g->index = (g->index+1)&(GRAPH_MAX-1);
|
int i = 0;
|
||||||
g->values[g->index] = v;
|
g->max = 0;
|
||||||
|
for(i = 0; i < GRAPH_MAX; i++)
|
||||||
|
{
|
||||||
|
if(g->values[i] > g->max)
|
||||||
|
g->max = g->values[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void graph_render(GRAPH *g, float x, float y, float w, float h)
|
static void graph_scale_min(GRAPH *g)
|
||||||
{
|
{
|
||||||
|
int i = 0;
|
||||||
|
g->min = g->max;
|
||||||
|
for(i = 0; i < GRAPH_MAX; i++)
|
||||||
|
{
|
||||||
|
if(g->values[i] < g->min)
|
||||||
|
g->min = g->values[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void graph_add(GRAPH *graph, float v, float r, float g, float b)
|
||||||
|
{
|
||||||
|
graph->index = (graph->index+1)&(GRAPH_MAX-1);
|
||||||
|
graph->values[graph->index] = v;
|
||||||
|
graph->colors[graph->index][0] = r;
|
||||||
|
graph->colors[graph->index][1] = g;
|
||||||
|
graph->colors[graph->index][2] = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void graph_render(GRAPH *g, float x, float y, float w, float h, const char *description)
|
||||||
|
{
|
||||||
|
char buf[32];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
gfx_blend_normal();
|
||||||
|
|
||||||
|
|
||||||
gfx_texture_set(-1);
|
gfx_texture_set(-1);
|
||||||
|
|
||||||
gfx_quads_begin();
|
gfx_quads_begin();
|
||||||
gfx_setcolor(0, 0, 0, 1);
|
gfx_setcolor(0, 0, 0, 0.75f);
|
||||||
gfx_quads_drawTL(x, y, w, h);
|
gfx_quads_drawTL(x, y, w, h);
|
||||||
gfx_quads_end();
|
gfx_quads_end();
|
||||||
|
|
||||||
gfx_lines_begin();
|
gfx_lines_begin();
|
||||||
gfx_setcolor(0.95f, 0.95f, 0.95f, 1);
|
gfx_setcolor(0.95f, 0.95f, 0.95f, 1.00f);
|
||||||
gfx_lines_draw(x, y+h/2, x+w, y+h/2);
|
gfx_lines_draw(x, y+h/2, x+w, y+h/2);
|
||||||
gfx_setcolor(0.5f, 0.5f, 0.5f, 1);
|
gfx_setcolor(0.5f, 0.5f, 0.5f, 0.75f);
|
||||||
gfx_lines_draw(x, y+(h*3)/4, x+w, y+(h*3)/4);
|
gfx_lines_draw(x, y+(h*3)/4, x+w, y+(h*3)/4);
|
||||||
gfx_lines_draw(x, y+h/4, x+w, y+h/4);
|
gfx_lines_draw(x, y+h/4, x+w, y+h/4);
|
||||||
for(i = 1; i < GRAPH_MAX; i++)
|
for(i = 1; i < GRAPH_MAX; i++)
|
||||||
|
@ -156,13 +187,26 @@ static void graph_render(GRAPH *g, float x, float y, float w, float h)
|
||||||
int i0 = (g->index+i-1)&(GRAPH_MAX-1);
|
int i0 = (g->index+i-1)&(GRAPH_MAX-1);
|
||||||
int i1 = (g->index+i)&(GRAPH_MAX-1);
|
int i1 = (g->index+i)&(GRAPH_MAX-1);
|
||||||
|
|
||||||
float v0 = g->values[i0];
|
float v0 = (g->values[i0]-g->min) / (g->max-g->min);
|
||||||
float v1 = g->values[i1];
|
float v1 = (g->values[i1]-g->min) / (g->max-g->min);
|
||||||
|
|
||||||
gfx_setcolor(0, 1, 0, 1);
|
gfx_setcolorvertex(0, g->colors[i0][0], g->colors[i0][1], g->colors[i0][2], 0.75f);
|
||||||
|
gfx_setcolorvertex(1, g->colors[i1][0], g->colors[i1][1], g->colors[i1][2], 0.75f);
|
||||||
gfx_lines_draw(x+a0*w, y+h-v0*h, x+a1*w, y+h-v1*h);
|
gfx_lines_draw(x+a0*w, y+h-v0*h, x+a1*w, y+h-v1*h);
|
||||||
|
|
||||||
}
|
}
|
||||||
gfx_lines_end();
|
gfx_lines_end();
|
||||||
|
|
||||||
|
|
||||||
|
gfx_texture_set(debug_font);
|
||||||
|
gfx_quads_text(x+2, y+h-16, 16, 1,1,1,1, description);
|
||||||
|
|
||||||
|
str_format(buf, sizeof(buf), "%.2f", g->max);
|
||||||
|
gfx_quads_text(x+w-8*strlen(buf)-8, y+2, 16, 1,1,1,1, buf);
|
||||||
|
|
||||||
|
str_format(buf, sizeof(buf), "%.2f", g->min);
|
||||||
|
gfx_quads_text(x+w-8*strlen(buf)-8, y+h-16, 16, 1,1,1,1, buf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -174,6 +218,9 @@ typedef struct
|
||||||
int64 rlast;
|
int64 rlast;
|
||||||
int64 tlast;
|
int64 tlast;
|
||||||
GRAPH graph;
|
GRAPH graph;
|
||||||
|
|
||||||
|
float up_adjustspeed;
|
||||||
|
float down_adjustspeed;
|
||||||
} SMOOTHTIME;
|
} SMOOTHTIME;
|
||||||
|
|
||||||
static void st_init(SMOOTHTIME *st, int64 target)
|
static void st_init(SMOOTHTIME *st, int64 target)
|
||||||
|
@ -181,7 +228,9 @@ static void st_init(SMOOTHTIME *st, int64 target)
|
||||||
st->snap = time_get();
|
st->snap = time_get();
|
||||||
st->current = target;
|
st->current = target;
|
||||||
st->target = target;
|
st->target = target;
|
||||||
graph_init(&st->graph, 0.0f, 1.0f);
|
st->up_adjustspeed = 1.0f;
|
||||||
|
st->down_adjustspeed = 0.2f;
|
||||||
|
graph_init(&st->graph, 0.0f, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64 st_get(SMOOTHTIME *st, int64 now)
|
static int64 st_get(SMOOTHTIME *st, int64 now)
|
||||||
|
@ -193,9 +242,10 @@ static int64 st_get(SMOOTHTIME *st, int64 now)
|
||||||
|
|
||||||
/* it's faster to adjust upward instead of downward */
|
/* it's faster to adjust upward instead of downward */
|
||||||
/* we might need to adjust these abit */
|
/* we might need to adjust these abit */
|
||||||
adjust_speed = 0.2f; /*0.99f;*/
|
|
||||||
|
adjust_speed = st->down_adjustspeed;
|
||||||
if(t > c)
|
if(t > c)
|
||||||
adjust_speed = 350.0f;
|
adjust_speed = st->up_adjustspeed;
|
||||||
|
|
||||||
a = ((now-st->snap)/(float)time_freq()) * adjust_speed;
|
a = ((now-st->snap)/(float)time_freq()) * adjust_speed;
|
||||||
if(a > 1.0f)
|
if(a > 1.0f)
|
||||||
|
@ -203,7 +253,7 @@ static int64 st_get(SMOOTHTIME *st, int64 now)
|
||||||
|
|
||||||
r = c + (int64)((t-c)*a);
|
r = c + (int64)((t-c)*a);
|
||||||
|
|
||||||
graph_add(&st->graph, a+0.5f);
|
graph_add(&st->graph, a+0.5f,1,1,1);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -216,14 +266,12 @@ static void st_update(SMOOTHTIME *st, int64 target)
|
||||||
st->target = target;
|
st->target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMOOTHTIME game_time;
|
static SMOOTHTIME game_time;
|
||||||
SMOOTHTIME predicted_time;
|
static SMOOTHTIME predicted_time;
|
||||||
|
|
||||||
GRAPH intra_graph;
|
/* graphs */
|
||||||
GRAPH predict_graph;
|
|
||||||
|
|
||||||
/* --- input snapping --- */
|
|
||||||
static GRAPH input_late_graph;
|
static GRAPH input_late_graph;
|
||||||
|
static GRAPH fps_graph;
|
||||||
|
|
||||||
/* -- snapshot handling --- */
|
/* -- snapshot handling --- */
|
||||||
enum
|
enum
|
||||||
|
@ -426,7 +474,7 @@ static void client_send_input()
|
||||||
msg_pack_int(size);
|
msg_pack_int(size);
|
||||||
|
|
||||||
inputs[current_input].tick = current_predtick;
|
inputs[current_input].tick = current_predtick;
|
||||||
inputs[current_input].game_time = st_get(&predicted_time, now);
|
inputs[current_input].predicted_time = st_get(&predicted_time, now);
|
||||||
inputs[current_input].time = now;
|
inputs[current_input].time = now;
|
||||||
|
|
||||||
/* pack it */
|
/* pack it */
|
||||||
|
@ -538,9 +586,7 @@ void client_connect(const char *server_address_str)
|
||||||
netclient_connect(net, &server_address);
|
netclient_connect(net, &server_address);
|
||||||
client_set_state(CLIENTSTATE_CONNECTING);
|
client_set_state(CLIENTSTATE_CONNECTING);
|
||||||
|
|
||||||
graph_init(&intra_graph, 0.0f, 1.0f);
|
|
||||||
graph_init(&input_late_graph, 0.0f, 1.0f);
|
graph_init(&input_late_graph, 0.0f, 1.0f);
|
||||||
graph_init(&predict_graph, 0.0f, 200.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_disconnect_with_reason(const char *reason)
|
void client_disconnect_with_reason(const char *reason)
|
||||||
|
@ -606,6 +652,7 @@ static void client_debug_render()
|
||||||
static NETSTATS prev, current;
|
static NETSTATS prev, current;
|
||||||
static int64 last_snap = 0;
|
static int64 last_snap = 0;
|
||||||
static float frametime_avg = 0;
|
static float frametime_avg = 0;
|
||||||
|
int64 now = time_get();
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
|
|
||||||
if(!config.debug)
|
if(!config.debug)
|
||||||
|
@ -635,7 +682,7 @@ static void client_debug_render()
|
||||||
mem_stats()->total_allocations,
|
mem_stats()->total_allocations,
|
||||||
gfx_memory_usage()/1024,
|
gfx_memory_usage()/1024,
|
||||||
(int)(1.0f/frametime_avg));
|
(int)(1.0f/frametime_avg));
|
||||||
gfx_quads_text(2, 2, 16, buffer);
|
gfx_quads_text(2, 2, 16, 1,1,1,1, buffer);
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -651,7 +698,7 @@ static void client_debug_render()
|
||||||
str_format(buffer, sizeof(buffer), "send: %3d %5d+%4d=%5d (%3d kbps) avg: %5d\nrecv: %3d %5d+%4d=%5d (%3d kbps) avg: %5d",
|
str_format(buffer, sizeof(buffer), "send: %3d %5d+%4d=%5d (%3d kbps) avg: %5d\nrecv: %3d %5d+%4d=%5d (%3d kbps) avg: %5d",
|
||||||
send_packets, send_bytes, send_packets*42, send_total, (send_total*8)/1024, send_bytes/send_packets,
|
send_packets, send_bytes, send_packets*42, send_total, (send_total*8)/1024, send_bytes/send_packets,
|
||||||
recv_packets, recv_bytes, recv_packets*42, recv_total, (recv_total*8)/1024, recv_bytes/recv_packets);
|
recv_packets, recv_bytes, recv_packets*42, recv_total, (recv_total*8)/1024, recv_bytes/recv_packets);
|
||||||
gfx_quads_text(2, 14, 16, buffer);
|
gfx_quads_text(2, 14, 16, 1,1,1,1, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* render rates */
|
/* render rates */
|
||||||
|
@ -664,24 +711,30 @@ static void client_debug_render()
|
||||||
{
|
{
|
||||||
str_format(buffer, sizeof(buffer), "%4d %20s: %8d %8d %8d", i, modc_getitemname(i), snapshot_data_rate[i]/8, snapshot_data_updates[i],
|
str_format(buffer, sizeof(buffer), "%4d %20s: %8d %8d %8d", i, modc_getitemname(i), snapshot_data_rate[i]/8, snapshot_data_updates[i],
|
||||||
(snapshot_data_rate[i]/snapshot_data_updates[i])/8);
|
(snapshot_data_rate[i]/snapshot_data_updates[i])/8);
|
||||||
gfx_quads_text(2, 100+y*12, 16, buffer);
|
gfx_quads_text(2, 100+y*12, 16, 1,1,1,1, buffer);
|
||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
str_format(buffer, sizeof(buffer), "input time left: %d", last_input_timeleft);
|
str_format(buffer, sizeof(buffer), "pred: %d ms %3.2f",
|
||||||
gfx_quads_text(2, 70, 16, buffer);
|
(int)((st_get(&predicted_time, now)-st_get(&game_time, now))*1000/(float)time_freq()),
|
||||||
|
predicted_time.up_adjustspeed);
|
||||||
|
gfx_quads_text(2, 70, 16, 1,1,1,1, buffer);
|
||||||
|
|
||||||
/* render graphs */
|
/* render graphs */
|
||||||
if(config.dbg_graphs)
|
if(config.dbg_graphs)
|
||||||
{
|
{
|
||||||
gfx_mapscreen(0,0,400.0f,300.0f);
|
//gfx_mapscreen(0,0,400.0f,300.0f);
|
||||||
graph_render(&predict_graph, 300, 10, 90, 50);
|
float w = gfx_screenwidth()/4.0f;
|
||||||
graph_render(&predicted_time.graph, 300, 10+50+10, 90, 50);
|
float h = gfx_screenheight()/6.0f;
|
||||||
|
float sp = gfx_screenwidth()/100.0f;
|
||||||
graph_render(&intra_graph, 300, 10+50+10+50+10, 90, 50);
|
float x = gfx_screenwidth()-w-sp;
|
||||||
graph_render(&input_late_graph, 300, 10+50+10+50+10+50+10, 90, 50);
|
|
||||||
|
graph_scale_max(&fps_graph);
|
||||||
|
graph_scale_min(&fps_graph);
|
||||||
|
graph_render(&fps_graph, x, sp*5, w, h, "FPS");
|
||||||
|
graph_render(&input_late_graph, x, sp*5+h+sp, w, h, "Input Margin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,10 +1067,24 @@ static void client_process_packet(NETCHUNK *packet)
|
||||||
/* adjust our prediction time */
|
/* adjust our prediction time */
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
graph_add(&input_late_graph, time_left/100.0f+0.5f);
|
if(time_left < 0)
|
||||||
|
{
|
||||||
if(time_left < 0 && config.debug)
|
graph_add(&input_late_graph, time_left/100.0f+0.5f, 1,0,0);
|
||||||
dbg_msg("client", "input was late with %d ms", time_left);
|
|
||||||
|
if(config.debug)
|
||||||
|
dbg_msg("client", "input was late with %d ms", time_left);
|
||||||
|
|
||||||
|
if(predicted_time.up_adjustspeed < 30.0f)
|
||||||
|
predicted_time.up_adjustspeed *= 2.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
graph_add(&input_late_graph, time_left/100.0f+0.5f, 0,1,0);
|
||||||
|
|
||||||
|
predicted_time.up_adjustspeed *= 0.95f;
|
||||||
|
if(predicted_time.up_adjustspeed < 1.0f)
|
||||||
|
predicted_time.up_adjustspeed = 1.0f;
|
||||||
|
}
|
||||||
last_input_timeleft = time_left;
|
last_input_timeleft = time_left;
|
||||||
|
|
||||||
for(k = 0; k < 200; k++) /* TODO: do this better */
|
for(k = 0; k < 200; k++) /* TODO: do this better */
|
||||||
|
@ -1025,7 +1092,7 @@ static void client_process_packet(NETCHUNK *packet)
|
||||||
if(inputs[k].tick == input_predtick)
|
if(inputs[k].tick == input_predtick)
|
||||||
{
|
{
|
||||||
/*-1000/50 prediction_margin */
|
/*-1000/50 prediction_margin */
|
||||||
int64 target = inputs[k].game_time + (time_get() - inputs[k].time);
|
int64 target = inputs[k].predicted_time + (time_get() - inputs[k].time);
|
||||||
st_update(&predicted_time, target - (int64)(((time_left-prediction_margin)/1000.0f)*time_freq()));
|
st_update(&predicted_time, target - (int64)(((time_left-prediction_margin)/1000.0f)*time_freq()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1201,6 +1268,7 @@ static void client_process_packet(NETCHUNK *packet)
|
||||||
{
|
{
|
||||||
/* start at 200ms and work from there */
|
/* start at 200ms and work from there */
|
||||||
st_init(&predicted_time, game_tick*time_freq()/50);
|
st_init(&predicted_time, game_tick*time_freq()/50);
|
||||||
|
predicted_time.up_adjustspeed = 1000.0f;
|
||||||
st_init(&game_time, (game_tick-1)*time_freq()/50);
|
st_init(&game_time, (game_tick-1)*time_freq()/50);
|
||||||
snapshots[SNAP_PREV] = snapshot_storage.first;
|
snapshots[SNAP_PREV] = snapshot_storage.first;
|
||||||
snapshots[SNAP_CURRENT] = snapshot_storage.last;
|
snapshots[SNAP_CURRENT] = snapshot_storage.last;
|
||||||
|
@ -1208,10 +1276,10 @@ static void client_process_packet(NETCHUNK *packet)
|
||||||
client_set_state(CLIENTSTATE_ONLINE);
|
client_set_state(CLIENTSTATE_ONLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
/*{
|
||||||
int64 now = time_get();
|
int64 now = time_get();
|
||||||
graph_add(&predict_graph, (st_get(&predicted_time, now)-st_get(&game_time, now))/(float)time_freq());
|
graph_add(&predict_graph, (st_get(&predicted_time, now)-st_get(&game_time, now))/(float)time_freq());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
st_update(&game_time, (game_tick-1)*time_freq()/50);
|
st_update(&game_time, (game_tick-1)*time_freq()/50);
|
||||||
|
|
||||||
|
@ -1395,7 +1463,7 @@ static void client_update()
|
||||||
intratick = (now - prevtick_start) / (float)(curtick_start-prevtick_start);
|
intratick = (now - prevtick_start) / (float)(curtick_start-prevtick_start);
|
||||||
ticktime = (now - prevtick_start) / (float)freq; /*(float)SERVER_TICK_SPEED);*/
|
ticktime = (now - prevtick_start) / (float)freq; /*(float)SERVER_TICK_SPEED);*/
|
||||||
|
|
||||||
graph_add(&intra_graph, intratick*0.25f);
|
/*graph_add(&intra_graph, intratick*0.25f);*/
|
||||||
|
|
||||||
curtick_start = new_pred_tick*time_freq()/50;
|
curtick_start = new_pred_tick*time_freq()/50;
|
||||||
prevtick_start = prev_pred_tick*time_freq()/50;
|
prevtick_start = prev_pred_tick*time_freq()/50;
|
||||||
|
@ -1521,7 +1589,7 @@ static void client_run()
|
||||||
snapshot_parts = 0;
|
snapshot_parts = 0;
|
||||||
|
|
||||||
/* init graphics and sound */
|
/* init graphics and sound */
|
||||||
if(!gfx_init())
|
if(gfx_init() != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* start refreshing addresses while we load */
|
/* start refreshing addresses while we load */
|
||||||
|
@ -1551,6 +1619,9 @@ static void client_run()
|
||||||
client_connect(config.cl_connect);
|
client_connect(config.cl_connect);
|
||||||
config.cl_connect[0] = 0;
|
config.cl_connect[0] = 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* */
|
||||||
|
graph_init(&fps_graph, 0.0f, 200.0f);
|
||||||
|
|
||||||
/* never start with the editor */
|
/* never start with the editor */
|
||||||
config.cl_editor = 0;
|
config.cl_editor = 0;
|
||||||
|
@ -1617,6 +1688,12 @@ static void client_run()
|
||||||
if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_pressed('q'))
|
if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_pressed('q'))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_down('d'))
|
||||||
|
config.debug ^= 1;
|
||||||
|
|
||||||
|
if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_down('g'))
|
||||||
|
config.dbg_graphs ^= 1;
|
||||||
|
|
||||||
if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_down('e'))
|
if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_down('e'))
|
||||||
{
|
{
|
||||||
config.cl_editor = config.cl_editor^1;
|
config.cl_editor = config.cl_editor^1;
|
||||||
|
@ -1715,6 +1792,8 @@ static void client_run()
|
||||||
frametime_low = frametime;
|
frametime_low = frametime;
|
||||||
if(frametime > frametime_high)
|
if(frametime > frametime_high)
|
||||||
frametime_high = frametime;
|
frametime_high = frametime;
|
||||||
|
|
||||||
|
graph_add(&fps_graph, 1.0f/frametime, 1,1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
modc_shutdown();
|
modc_shutdown();
|
||||||
|
|
|
@ -328,7 +328,7 @@ int gfx_init()
|
||||||
|
|
||||||
/* set vsync as needed */
|
/* set vsync as needed */
|
||||||
gfx_set_vsync(config.gfx_vsync);
|
gfx_set_vsync(config.gfx_vsync);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float gfx_screenaspect()
|
float gfx_screenaspect()
|
||||||
|
@ -905,11 +905,12 @@ void gfx_quads_draw_freeform(
|
||||||
add_vertices(4);
|
add_vertices(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_quads_text(float x, float y, float size, const char *text)
|
void gfx_quads_text(float x, float y, float size, float r, float g, float b, float a, const char *text)
|
||||||
{
|
{
|
||||||
float startx = x;
|
float startx = x;
|
||||||
|
|
||||||
gfx_quads_begin();
|
gfx_quads_begin();
|
||||||
|
gfx_setcolor(r,g,b,a);
|
||||||
|
|
||||||
while(*text)
|
while(*text)
|
||||||
{
|
{
|
||||||
|
|
|
@ -186,7 +186,7 @@ void gfx_quads_draw_freeform(
|
||||||
See Also:
|
See Also:
|
||||||
<other_func>
|
<other_func>
|
||||||
*/
|
*/
|
||||||
void gfx_quads_text(float x, float y, float size, const char *text);
|
void gfx_quads_text(float x, float y, float size, float r, float g, float b, float a, const char *text);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Group: Lines
|
Group: Lines
|
||||||
|
|
|
@ -152,7 +152,7 @@ int CONTROLS::snapinput(int *data)
|
||||||
else if(input_data.prev_weapon != last_data.prev_weapon) send = true;
|
else if(input_data.prev_weapon != last_data.prev_weapon) send = true;
|
||||||
|
|
||||||
// send at at least 10hz
|
// send at at least 10hz
|
||||||
if(time_get() > last_send_time + time_freq()/10)
|
if(time_get() > last_send_time + time_freq()/25)
|
||||||
send = true;
|
send = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,9 @@ void PLAYERS::render_player(
|
||||||
if(player.health < 0) // dont render dead players
|
if(player.health < 0) // dont render dead players
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//float angle = mix((float)prev.angle, (float)player.angle, intratick)/256.0f;
|
float angle = mix((float)prev.angle, (float)player.angle, intratick)/256.0f;
|
||||||
|
|
||||||
float angle = 0;
|
//float angle = 0;
|
||||||
|
|
||||||
if(info.local && client_state() != CLIENTSTATE_DEMOPLAYBACK)
|
if(info.local && client_state() != CLIENTSTATE_DEMOPLAYBACK)
|
||||||
{
|
{
|
||||||
|
@ -134,6 +134,7 @@ void PLAYERS::render_player(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
float mixspeed = client_frametime()*2.5f;
|
float mixspeed = client_frametime()*2.5f;
|
||||||
if(player.attacktick != prev.attacktick) // shooting boosts the mixing speed
|
if(player.attacktick != prev.attacktick) // shooting boosts the mixing speed
|
||||||
mixspeed *= 15.0f;
|
mixspeed *= 15.0f;
|
||||||
|
@ -151,7 +152,7 @@ void PLAYERS::render_player(
|
||||||
else
|
else
|
||||||
angle = angular_approach(current, target, fabs(delta-new_delta));
|
angle = angular_approach(current, target, fabs(delta-new_delta));
|
||||||
|
|
||||||
gameclient.clients[info.cid].angle = angle;
|
gameclient.clients[info.cid].angle = angle;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// use preditect players if needed
|
// use preditect players if needed
|
||||||
|
|
|
@ -20,11 +20,11 @@ static PACKET *last = (PACKET *)0;
|
||||||
static int current_latency = 0;
|
static int current_latency = 0;
|
||||||
|
|
||||||
static int config_log = 0;
|
static int config_log = 0;
|
||||||
static int config_ping = 150;
|
static int config_ping = 40;
|
||||||
static int config_pingflux = 50;
|
static int config_pingflux = 20;
|
||||||
static int config_pingspike = 0;
|
static int config_pingspike = 0;
|
||||||
static int config_packetloss = 10; // in percent
|
static int config_packetloss = 1; // in percent
|
||||||
static int config_reorder = 1;
|
static int config_reorder = 0;
|
||||||
|
|
||||||
int run(int port, NETADDR dest)
|
int run(int port, NETADDR dest)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue