fixed issues when pausing the game and added pause and unpause console commands

This commit is contained in:
Magnus Auvinen 2008-11-16 15:10:57 +00:00
parent d640ede2a6
commit b6f6f47997
3 changed files with 31 additions and 4 deletions

View file

@ -638,6 +638,16 @@ void GAMECLIENT::on_predict()
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;
world.tuning = tuning;

View file

@ -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
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())

View file

@ -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);
}