diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-02-24 18:41:02 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-02-24 18:41:02 +0000 |
| commit | 91eda24ddc8b56c6022a4d99519f28230e6b3bbf (patch) | |
| tree | fc9e9313ee26cd9f87a2be7d35be989907ef02e1 | |
| parent | 4739966e14ca2df24d4f44fb814b6275b9bf2a3c (diff) | |
| download | zcatch-91eda24ddc8b56c6022a4d99519f28230e6b3bbf.tar.gz zcatch-91eda24ddc8b56c6022a4d99519f28230e6b3bbf.zip | |
fixed correction count. fixed miss-behaving server
| -rw-r--r-- | scripts/netobj.py | 11 | ||||
| -rw-r--r-- | src/game/client/gc_client.cpp | 2 | ||||
| -rw-r--r-- | src/game/g_game.cpp | 14 | ||||
| -rw-r--r-- | src/game/g_game.h | 1 | ||||
| -rw-r--r-- | src/game/g_protocol.def | 2 | ||||
| -rw-r--r-- | src/game/server/gs_server.cpp | 6 |
6 files changed, 30 insertions, 6 deletions
diff --git a/scripts/netobj.py b/scripts/netobj.py index 107f49c4..03228e34 100644 --- a/scripts/netobj.py +++ b/scripts/netobj.py @@ -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, "" diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp index 8446d729..fae66cf0 100644 --- a/src/game/client/gc_client.cpp +++ b/src/game/client/gc_client.cpp @@ -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); } diff --git a/src/game/g_game.cpp b/src/game/g_game.cpp index c217b5a3..c87da2d4 100644 --- a/src/game/g_game.cpp +++ b/src/game/g_game.cpp @@ -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; diff --git a/src/game/g_game.h b/src/game/g_game.h index 00870319..3cb6639b 100644 --- a/src/game/g_game.h +++ b/src/game/g_game.h @@ -137,6 +137,7 @@ public: int triggered_events; + void reset(); void tick(); void move(); diff --git a/src/game/g_protocol.def b/src/game/g_protocol.def index 8df707c3..7d24ebb4 100644 --- a/src/game/g_protocol.def +++ b/src/game/g_protocol.def @@ -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 diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp index 514850a0..b95eae97 100644 --- a/src/game/server/gs_server.cpp +++ b/src/game/server/gs_server.cpp @@ -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; |