mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
fixed correction count. fixed miss-behaving server
This commit is contained in:
parent
4739966e14
commit
91eda24ddc
|
@ -184,6 +184,7 @@ def emit_header_file(f, p):
|
|||
|
||||
print >>f, "int netobj_secure(int type, void *data, int size);"
|
||||
print >>f, "const char *netobj_get_name(int type);"
|
||||
print >>f, "int netobj_num_corrections();"
|
||||
print >>f, ""
|
||||
|
||||
for obj in p.objects:
|
||||
|
@ -199,11 +200,15 @@ def emit_source_file(f, p, protofilename):
|
|||
for l in p.source_raw:
|
||||
print >>f, l
|
||||
|
||||
print >>f, ""
|
||||
print >>f, "static int num_corrections = 0;"
|
||||
print >>f, "int netobj_num_corrections() { return num_corrections; }"
|
||||
print >>f, ""
|
||||
print >>f, "static int netobj_clamp_int(int v, int min, int max)"
|
||||
print >>f, "{"
|
||||
print >>f, "if(v<min) return min;"
|
||||
print >>f, "if(v>max) return max;"
|
||||
print >>f, "return v;"
|
||||
print >>f, "\tif(v<min) { num_corrections++; return min; }"
|
||||
print >>f, "\tif(v>max) { num_corrections++; return max; }"
|
||||
print >>f, "\treturn v;"
|
||||
print >>f, "}"
|
||||
print >>f, ""
|
||||
|
||||
|
|
|
@ -1448,7 +1448,7 @@ void render_game()
|
|||
vec2(netobjects.local_character->x, netobjects.local_character->y));
|
||||
|
||||
char buf[512];
|
||||
str_format(buf, sizeof(buf), "%.2f", speed/2);
|
||||
str_format(buf, sizeof(buf), "%.2f %d", speed/2, netobj_num_corrections());
|
||||
gfx_text(0, 150, 50, 12, buf, -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -154,6 +154,20 @@ void move_box(vec2 *inout_pos, vec2 *inout_vel, vec2 size, float elasticity)
|
|||
*inout_vel = vel;
|
||||
}
|
||||
|
||||
|
||||
void player_core::reset()
|
||||
{
|
||||
pos = vec2(0,0);
|
||||
vel = vec2(0,0);
|
||||
hook_pos = vec2(0,0);
|
||||
hook_dir = vec2(0,0);
|
||||
hook_tick = 0;
|
||||
hook_state = HOOK_IDLE;
|
||||
hooked_player = -1;
|
||||
jumped = 0;
|
||||
triggered_events = 0;
|
||||
}
|
||||
|
||||
void player_core::tick()
|
||||
{
|
||||
float phys_size = 28.0f;
|
||||
|
|
|
@ -137,6 +137,7 @@ public:
|
|||
|
||||
int triggered_events;
|
||||
|
||||
void reset();
|
||||
void tick();
|
||||
void move();
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ object player_core
|
|||
any vx, vy
|
||||
|
||||
any angle
|
||||
range(0, 2) jumped
|
||||
range(0, 3) jumped
|
||||
|
||||
clientid hooked_player
|
||||
range(0, 3) hook_state
|
||||
|
|
|
@ -595,7 +595,11 @@ void player::init()
|
|||
void player::reset()
|
||||
{
|
||||
pos = vec2(0.0f, 0.0f);
|
||||
core.vel = vec2(0.0f, 0.0f);
|
||||
core.reset();
|
||||
|
||||
emote_type = 0;
|
||||
emote_stop = -1;
|
||||
|
||||
//direction = vec2(0.0f, 1.0f);
|
||||
score = 0;
|
||||
dead = true;
|
||||
|
|
Loading…
Reference in a new issue