diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-12-09 15:38:19 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-12-09 15:38:19 +0000 |
| commit | 8854bacf6d24cbb3ade4f86a1a8c848e08ceb32b (patch) | |
| tree | 467c558f8b087d1d4d410fd5d361479fc467bd8f /src/game/server | |
| parent | fef40c16cc8910d96f2e21e2258dd02cd23a90fa (diff) | |
| download | zcatch-8854bacf6d24cbb3ade4f86a1a8c848e08ceb32b.tar.gz zcatch-8854bacf6d24cbb3ade4f86a1a8c848e08ceb32b.zip | |
fixed crashbug, fixed ninja, fixed predicted sounds
Diffstat (limited to 'src/game/server')
| -rw-r--r-- | src/game/server/game_server.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp index 0cfcb0c8..aaabdbc3 100644 --- a/src/game/server/game_server.cpp +++ b/src/game/server/game_server.cpp @@ -519,6 +519,31 @@ bool player::is_grounded() return false; } +struct input_count +{ + int presses; + int releases; +}; + +static input_count count_input(int prev, int cur) +{ + input_count c = {0,0}; + prev &= INPUT_STATE_MASK; + cur &= INPUT_STATE_MASK; + int i = prev; + while(i != cur) + { + i = (i+1)&INPUT_STATE_MASK; + if(i&1) + c.presses++; + else + c.releases++; + } + + return c; +} + + int player::handle_ninja() { vec2 direction = normalize(vec2(input.target_x, input.target_y)); @@ -531,7 +556,7 @@ int player::handle_ninja() } // Check if it should activate - if ((input.fire && !(previnput.fire)) && (server_tick() > currentcooldown)) + if (count_input(previnput.fire, input.fire).presses && (server_tick() > currentcooldown)) { // ok then, activate ninja attack_tick = server_tick(); @@ -610,30 +635,6 @@ int player::handle_ninja() return 0; } -struct input_count -{ - int presses; - int releases; -}; - -static input_count count_input(int prev, int cur) -{ - input_count c = {0,0}; - prev &= INPUT_STATE_MASK; - cur &= INPUT_STATE_MASK; - int i = prev; - while(i != cur) - { - i = (i+1)&INPUT_STATE_MASK; - if(i&1) - c.presses++; - else - c.releases++; - } - - return c; -} - int player::handle_sniper() { struct input_count button = count_input(previnput.fire, input.fire); |