diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/client/game_client.cpp | 37 | ||||
| -rw-r--r-- | src/game/server/game_server.cpp | 51 |
2 files changed, 43 insertions, 45 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp index 30cad6c0..bdd42240 100644 --- a/src/game/client/game_client.cpp +++ b/src/game/client/game_client.cpp @@ -761,18 +761,11 @@ extern "C" void modc_predict() } // predict - int num_predicted = 0; - int got = 0; for(int tick = client_tick()+1; tick <= client_predtick(); tick++) { - num_predicted++; - // fetch the local if(tick == client_predtick() && world.players[local_cid]) - { - got|=1; predicted_prev_player = *world.players[local_cid]; - } // first calculate where everyone should move for(int c = 0; c < MAX_CLIENTS; c++) @@ -837,14 +830,19 @@ extern "C" void modc_predict() } if(tick == client_predtick() && world.players[local_cid]) - { - got|=2; predicted_player = *world.players[local_cid]; - } } - - if(got!=3) - dbg_msg("predict", "way few predictions %d %d", num_predicted, got); +} + +static void clear_object_pointers() +{ + // clear out the invalid pointers + local_character = 0; + local_prev_character = 0; + local_info = 0; + flags[0] = 0; + flags[1] = 0; + gameobj = 0; } extern "C" void modc_newsnapshot() @@ -863,13 +861,7 @@ extern "C" void modc_newsnapshot() } } - // clear out the invalid pointers - local_character = 0; - local_prev_character = 0; - local_info = 0; - flags[0] = 0; - flags[1] = 0; - gameobj = 0; + clear_object_pointers(); // setup world view { @@ -2753,6 +2745,8 @@ void menu_do_connected(); extern "C" void modc_statechange(int state, int old) { + clear_object_pointers(); + if(state == CLIENTSTATE_OFFLINE) { menu_do_disconnected(); @@ -2853,6 +2847,9 @@ extern "C" void modc_connected() chat_reset(); proj_particles.reset(); + + clear_object_pointers(); + last_new_predicted_tick = -1; for(int i = 0; i < MAX_CLIENTS; i++) { 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); |