mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38: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
|
@ -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;
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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