From b6f6f4799747636acb1e2da029f44a2d3d155f62 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sun, 16 Nov 2008 15:10:57 +0000 Subject: [PATCH] fixed issues when pausing the game and added pause and unpause console commands --- src/game/client/gameclient.cpp | 12 +++++++++++- src/game/server/entities/character.cpp | 16 +++++++++++++--- src/game/server/hooks.cpp | 7 +++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 4ee924600..74b949d77 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -333,7 +333,7 @@ static void evolve(NETOBJ_CHARACTER *character, int tick) tempcore.move(); tempcore.quantize(); } - + tempcore.write(character); } @@ -637,6 +637,16 @@ void GAMECLIENT::on_predict() // we can't predict without our own id or own character if(snap.local_cid == -1 || !snap.characters[snap.local_cid].active) return; + + // don't predict anything if we are paused + if(snap.gameobj && snap.gameobj->paused) + { + if(snap.local_character) + predicted_char.read(snap.local_character); + if(snap.local_prev_character) + predicted_prev_char.read(snap.local_prev_character); + return; + } // repredict character WORLD_CORE world; diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index c0bc33462..b3005a676 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -683,7 +683,7 @@ void CHARACTER::tick_defered() mem_zero(¤t, sizeof(current)); reckoningcore.write(&predicted); core.write(¤t); - + // only allow dead reackoning for a top of 3 seconds if(reckoning_tick+server_tickspeed()*3 < server_tick() || mem_comp(&predicted, ¤t, sizeof(NETOBJ_CHARACTER)) != 0) { @@ -846,8 +846,18 @@ void CHARACTER::snap(int snapping_client) NETOBJ_CHARACTER *character = (NETOBJ_CHARACTER *)snap_new_item(NETOBJTYPE_CHARACTER, player->client_id, sizeof(NETOBJ_CHARACTER)); // write down the core - character->tick = reckoning_tick; - sendcore.write(character); + if(game.world.paused) + { + // no dead reckoning when paused because the client doesn't know + // how far to perform the reckoning + character->tick = 0; + core.write(character); + } + else + { + character->tick = reckoning_tick; + sendcore.write(character); + } // set emote if (emote_stop < server_tick()) diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp index 1c89b4c8b..fa6db69df 100644 --- a/src/game/server/hooks.cpp +++ b/src/game/server/hooks.cpp @@ -470,6 +470,10 @@ static void con_addvote(void *result, void *user_data) dbg_msg("server", "added option '%s'", option->command); } + +static void con_pause(void *result, void *user_data) { game.world.paused = true; } +static void con_unpause(void *result, void *user_data) { game.world.paused = false; } + void mods_console_init() { MACRO_REGISTER_COMMAND("tune", "si", con_tune_param, 0); @@ -482,6 +486,9 @@ void mods_console_init() MACRO_REGISTER_COMMAND("say", "r", con_say, 0); MACRO_REGISTER_COMMAND("set_team", "ii", con_set_team, 0); + MACRO_REGISTER_COMMAND("pause", "", con_pause, 0); + MACRO_REGISTER_COMMAND("unpause", "", con_unpause, 0); + MACRO_REGISTER_COMMAND("addvote", "r", con_addvote, 0); }