- SW: Migrate to GZDoom time code like Duke.

This commit is contained in:
Mitchell Richters 2020-08-25 21:46:52 +10:00 committed by Christoph Oelckers
parent d04aa603dd
commit 386661f1ba
11 changed files with 45 additions and 47 deletions

View file

@ -939,7 +939,7 @@ post_analyzesprites(void)
}
#endif
static ClockTicks mapzoomclock;
static int mapzoomclock;
void
ResizeView(PLAYERp pp)
@ -949,7 +949,7 @@ ResizeView(PLAYERp pp)
if (automapMode != am_off)
{
int32_t timepassed = (int32_t)(totalclock - mapzoomclock);
int32_t timepassed = gameclock - mapzoomclock;
mapzoomclock += timepassed;
if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
zoom = max<int32_t>(zoom - mulscale7(timepassed * synctics, zoom), 48);
@ -1199,7 +1199,7 @@ FString GameInterface::statFPS()
//if (LocationInfo)
{
i = (int32_t)totalclock;
i = gameclock;
if (i != frameval[framecnt])
{
out.AppendFormat("FPS: %d\n", ((120 * AVERAGEFRAMES) / (i - frameval[framecnt])) + f_c);
@ -1656,7 +1656,7 @@ void DoPlayerDiveMeter(PLAYERp pp);
void MoveScrollMode2D(PLAYERp pp);
void
drawscreen(PLAYERp pp)
drawscreen(PLAYERp pp, double smoothratio)
{
extern SWBOOL CameraTestMode;
int tx, ty, tz;
@ -1678,10 +1678,6 @@ drawscreen(PLAYERp pp)
DrawScreen = TRUE;
PreDraw();
smoothratio = CalcSmoothRatio(totalclock, ototalclock, 120 / synctics);
if (paused && !ReloadPrompt) // The checks were brought over from domovethings
smoothratio = 65536;
PreUpdatePanel(smoothratio);
if (!ScreenSavePic)
@ -1921,7 +1917,7 @@ drawscreen(PLAYERp pp)
SyncStatMessage();
#endif
UpdateStatusBar(totalclock);
UpdateStatusBar(gameclock);
DrawCrosshair(pp);
DoPlayerDiveMeter(pp); // Do the underwater breathing bar
@ -1960,7 +1956,7 @@ drawscreen(PLAYERp pp)
bool GameInterface::GenerateSavePic()
{
ScreenSavePic = TRUE;
drawscreen(Player + myconnectindex);
drawscreen(Player + myconnectindex, 65536);
ScreenSavePic = FALSE;
return true;
}

View file

@ -316,7 +316,7 @@ void DrawMenuLevelScreen(void)
{
const int TITLE_PIC = 2324;
twod->ClearScreen();
totalclocklock = totalclock;
totalclocklock = gameclock;
DrawTexture(twod, tileGetTexture(TITLE_PIC), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal,
DTA_Color, shadeToLight(20), TAG_DONE);
@ -713,7 +713,7 @@ void EndOfLevel()
COVER_SetReverb(0); // Reset reverb
Player[myconnectindex].Reverb = 0;
StopSound();
soundEngine->UpdateSounds((int)totalclock);
soundEngine->UpdateSounds(gameclock);
// NextLevel must be null while the intermission is running, but we still need the value for later
auto localNextLevel = NextLevel;
NextLevel = nullptr;
@ -773,26 +773,31 @@ void GameTicker(void)
ready2send = 1;
int const currentTic = I_GetTime();
gameclock = I_GetBuildTime();
if (paused)
{
ototalclock = (int)totalclock - (120 / synctics);
buttonMap.ResetButtonStates();
smoothratio = MaxSmoothRatio;
}
else
{
while (ready2send && (totalclock >= ototalclock + synctics))
while (ready2send && currentTic - lastTic >= 1)
{
lastTic = currentTic;
UpdateInputs();
MoveTicker();
}
smoothratio = I_GetTimeFrac() * MaxSmoothRatio;
// Get input again to update q16ang/q16horiz.
if (!PedanticMode)
getinput(&loc, TRUE);
}
drawscreen(Player + screenpeek);
drawscreen(Player + screenpeek, smoothratio);
ready2send = 0;
}
if (ExitLevel)
@ -818,8 +823,9 @@ void GameInterface::RunGameFrame()
{
default:
case GS_STARTUP:
totalclock = 0;
ototalclock = 0;
I_ResetTime();
lastTic = -1;
gameclock = 0;
if (userConfig.CommandMap.IsNotEmpty())
{

View file

@ -2198,7 +2198,9 @@ extern USER puser[MAX_SW_PLAYERS_REG];
//
///////////////////////////
extern int ototalclock, save_totalclock, gotlastpacketclock;
extern int gotlastpacketclock;
extern int gameclock;
extern int lastTic;
extern SWBOOL ready2send;
extern double smoothratio;
@ -2259,7 +2261,7 @@ void DebugWriteString(char *string); // game.c
void getsyncstat(void); // sync.c
void SyncStatMessage(void); // sync.c
void drawscreen(PLAYERp pp); // draw.c
void drawscreen(PLAYERp pp, double smoothratio); // draw.c
void post_analyzesprites(void); // draw.c
int COVERsetgamemode(int mode, int xdim, int ydim, int bpp); // draw.c
void ScreenCaptureKeys(void); // draw.c

View file

@ -300,7 +300,7 @@ void JS_InitMirrors(void)
// Scan wall tags for mirrors
mirrorcnt = 0;
tileDelete(MIRROR);
oscilationclock = ototalclock;
oscilationclock = gameclock;
for (i = 0; i < MAXMIRRORS; i++)
{
@ -532,7 +532,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
SWBOOL bIsWallMirror = FALSE;
camloopcnt += (int32_t) (totalclock - ototalclock);
camloopcnt += gameclock - gameclock;
if (camloopcnt > (60 * 5)) // 5 seconds per player view
{
camloopcnt = 0;
@ -545,7 +545,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
longptr = (int*)&gotpic[MIRRORLABEL >> 3];
if (longptr && (longptr[0] || longptr[1]))
{
uint32_t oscilation_delta = ototalclock - oscilationclock;
uint32_t oscilation_delta = gameclock - oscilationclock;
oscilation_delta -= oscilation_delta % 4;
oscilationclock += oscilation_delta;
oscilation_delta *= 2;

View file

@ -139,7 +139,7 @@ void drawoverheadmap(int cposx, int cposy, int czoom, short cang)
if (Player[p].PlayerSprite == j)
{
if (sprite[Player[p].PlayerSprite].xvel > 16)
pspr_ndx[myconnectindex] = (((int32_t) totalclock>>4)&3);
pspr_ndx[myconnectindex] = ((gameclock >> 4)&3);
sprisplayer = TRUE;
goto SHOWSPRITE;

View file

@ -95,9 +95,8 @@ uint8_t syncstat[MAXSYNCBYTES];
int syncvaltail, syncvaltottail;
void GetSyncInfoFromPacket(uint8_t *packbuf, int packbufleng, int *j, int otherconnectindex);
// when you set totalclock to 0 also set this one
int ototalclock;
int save_totalclock;
int gameclock;
int lastTic;
double smoothratio;
// must start out as 0
@ -166,8 +165,9 @@ InitTimingVars(void)
// resettiming();
totalsynctics = 0;
totalclock = 0;
ototalclock = 0;
I_ResetTime();
lastTic = -1;
gameclock = 0;
randomseed = 17L;
MoveSkip8 = 2;
@ -191,8 +191,6 @@ UpdateInputs(void)
int i, j, k;
PLAYERp pp;
ototalclock += synctics;
//getpackets();
if (Player[myconnectindex].movefifoend - movefifoplc >= 100)

View file

@ -978,7 +978,7 @@ InitWeaponSword(PLAYERp pp)
PlaySound(DIGI_SWORD_UP, pp, v3df_follow|v3df_dontpan);
if (pp == Player+myconnectindex && totalclock > 0)
if (pp == Player+myconnectindex && gameclock > 0)
{
rnd_num = STD_RANDOM_RANGE(1024);
if (rnd_num > 900)

View file

@ -562,7 +562,7 @@ bool GameInterface::SaveGame(FSaveGameNode *sv)
#endif
#endif
MWRITE(&totalclock,sizeof(totalclock),1,fil);
MWRITE(&gameclock,sizeof(gameclock),1,fil);
MWRITE(&NormalVisibility,sizeof(NormalVisibility),1,fil);
MWRITE(&MoveSkip2,sizeof(MoveSkip2),1,fil);
@ -936,7 +936,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
#endif
#endif
MREAD(&totalclock,sizeof(totalclock),1,fil);
MREAD(&gameclock,sizeof(gameclock),1,fil);
MREAD(&NormalVisibility,sizeof(NormalVisibility),1,fil);
@ -1055,10 +1055,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
SetupPreCache();
DoTheCache();
// what is this for? don't remember
totalclock = totalsynctics;
ototalclock = totalsynctics;
// this is ok - just duplicating sector list with pointers
for (sop = SectorObject; sop < &SectorObject[SIZ(SectorObject)]; sop++)
{

View file

@ -770,11 +770,11 @@ private:
imgScale = baseScale / img->GetDisplayHeight();
DrawGraphic(img, 1.5, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale);
if (!althud_flashing || u->Health > (u->MaxHealth >> 2) || ((int)totalclock & 32))
if (!althud_flashing || u->Health > (u->MaxHealth >> 2) || (gameclock & 32))
{
int s = -8;
if (althud_flashing && u->Health > u->MaxHealth)
s += (sintable[((int)totalclock << 5) & 2047] >> 10);
s += (sintable[(gameclock << 5) & 2047] >> 10);
int intens = clamp(255 - 4 * s, 0, 255);
auto pe = PalEntry(255, intens, intens, intens);
format.Format("%d", u->Health);
@ -812,7 +812,7 @@ private:
imgX += (imgX * 0.855) * (strlen - 1);
}
if ((!althud_flashing || (int)totalclock & 32 || pp->WpnAmmo[weapon] > (DamageData[weapon].max_ammo / 10)))
if ((!althud_flashing || gameclock & 32 || pp->WpnAmmo[weapon] > (DamageData[weapon].max_ammo / 10)))
{
SBar_DrawString(this, &numberFont, format, -1.5, -numberFont.mFont->GetHeight(), DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
}

View file

@ -304,7 +304,7 @@ static void RestartAmbient(AmbientSound* amb)
int pitch = 0;
if (vp.pitch_hi <= vp.pitch_lo) pitch = vp.pitch_lo;
else pitch = vp.pitch_lo + (STD_RANDOM_RANGE(vp.pitch_hi - vp.pitch_lo));
amb->curIndex = (int)totalclock;
amb->curIndex = gameclock;
if (!soundEngine->IsSourcePlayingSomething(SOURCE_Ambient, amb, CHAN_BODY, amb->vocIndex))
soundEngine->StartSound(SOURCE_Ambient, amb, nullptr, CHAN_BODY, EChanFlags::FromInt(amb->ChanFlags), amb->vocIndex, 1.f, ATTN_NORM, &rolloff, S_ConvertPitch(pitch));
@ -343,7 +343,7 @@ static int RandomizeAmbientSpecials(int handle)
static void DoTimedSound(AmbientSound* amb)
{
if ((int)totalclock >= amb->curIndex + amb->maxIndex)
if (gameclock >= amb->curIndex + amb->maxIndex)
{
if (!soundEngine->IsSourcePlayingSomething(SOURCE_Ambient, amb, CHAN_BODY))
{
@ -604,7 +604,7 @@ void DoUpdateSounds(void)
soundEngine->SetListener(listener);
UpdateAmbients();
soundEngine->UpdateSounds((int)totalclock);
soundEngine->UpdateSounds(gameclock);
}
//==========================================================================

View file

@ -17798,16 +17798,16 @@ InitUzi(PLAYERp pp)
PlayerUpdateAmmo(pp, u->WeaponNum, -1);
if (uziclock > totalclock)
if (uziclock > gameclock)
{
uziclock = (int32_t) totalclock;
uziclock = gameclock;
FireSnd = TRUE;
}
clockdiff = (int32_t) totalclock - uziclock;
clockdiff = gameclock - uziclock;
if (clockdiff > UZIFIRE_WAIT)
{
uziclock = (int32_t) totalclock;
uziclock = gameclock;
FireSnd = TRUE;
}