From 66b789376bdd3788260b343be75184435d68d230 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 19 Apr 2014 22:42:21 +0000 Subject: [PATCH] In G_SavePlayer(), save timers at beginning and restore when finished. This makes the game not process as many ticks as have elapsed during the saving afterwards. git-svn-id: https://svn.eduke32.com/eduke32@4450 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 4 +++- polymer/eduke32/build/src/build.c | 1 - polymer/eduke32/build/src/engine.c | 2 -- polymer/eduke32/source/savegame.c | 29 +++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 5924fa110..5ce873596 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -760,7 +760,9 @@ EXTERN int16_t headsectbunch[2][YAX_MAXBUNCHES], nextsectbunch[2][MAXSECTORS]; EXTERN int32_t Numsprites; EXTERN int16_t numsectors, numwalls; EXTERN char display_mirror; -EXTERN int32_t totalclock; +// totalclocklock: the totalclock value that is backed up once on each +// drawrooms() and is used for animateoffs(). +EXTERN int32_t totalclock, totalclocklock; EXTERN int32_t numframes, randomseed; EXTERN int16_t sintable[2048]; EXTERN uint8_t palette[768]; diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 3a3d4ea54..80fc6c7ef 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -62,7 +62,6 @@ static int32_t mousexsurp = 0, mouseysurp = 0; int32_t grponlymode = 0; int32_t graphicsmode = 0; -extern int32_t totalclocklock; int32_t synctics = 0, lockclock = 0; diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index eb92b5652..78a536e1f 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -2447,8 +2447,6 @@ static int32_t bakwindowx2[4], bakwindowy2[4]; static int32_t bakrendmode,baktile; #endif -int32_t totalclocklock; - char apptitle[256] = "Build Engine"; static uint8_t basepalreset=1; diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 3fe8cc549..65f5f498c 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -314,6 +314,32 @@ int32_t G_LoadPlayer(int32_t spot) return 0; } +////////// TIMER SAVING/RESTORING ////////// + +static struct { + int32_t totalclock, totalclocklock; // engine + int32_t ototalclock, lockclock; // game +} g_timers; + +static void G_SaveTimers(void) +{ + g_timers.totalclock = totalclock; + g_timers.totalclocklock = totalclocklock; + g_timers.ototalclock = ototalclock; + g_timers.lockclock = lockclock; +} + +static void G_RestoreTimers(void) +{ + sampletimer(); + + totalclock = g_timers.totalclock; + totalclocklock = g_timers.totalclocklock; + ototalclock = g_timers.ototalclock; + lockclock = g_timers.lockclock; +} + +////////// int32_t G_SavePlayer(int32_t spot) { @@ -321,6 +347,8 @@ int32_t G_SavePlayer(int32_t spot) // char mpfn[16]; FILE *fil; + G_SaveTimers(); + Bstrcpy(fn, "dukesav0.esv"); fn[7] = spot + '0'; @@ -374,6 +402,7 @@ int32_t G_SavePlayer(int32_t spot) ready2send = 1; Net_WaitForServer(); + G_RestoreTimers(); ototalclock = totalclock; return 0;