mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed issues when pausing the game and added pause and unpause console commands
This commit is contained in:
parent
d640ede2a6
commit
b6f6f47997
|
@ -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;
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue