- cleanup.

This commit is contained in:
Christoph Oelckers 2020-09-02 18:59:56 +02:00
parent 4d5e2f5bda
commit 141b5c00cd
11 changed files with 44 additions and 38 deletions

View file

@ -939,24 +939,36 @@ post_analyzesprites(void)
} }
#endif #endif
static int mapzoomclock; static int nonsharedtimer;
void void
ResizeView(PLAYERp pp) ResizeView(PLAYERp pp)
{ {
if (M_Active() || paused) int ms = screen->FrameTime;
int interval;
if (nonsharedtimer > 0 || ms < nonsharedtimer)
{
interval = ms - nonsharedtimer;
}
else
{
interval = 0;
}
nonsharedtimer = screen->FrameTime;
if (System_WantGuiCapture())
return; return;
if (automapMode != am_off) if (automapMode != am_off)
{ {
int32_t timepassed = gameclock - mapzoomclock; double j = interval * (120. / 1000);
mapzoomclock += timepassed;
if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
zoom = max<int32_t>(zoom - mulscale7(timepassed * synctics, zoom), 48);
if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen)) if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
zoom = min<int32_t>(zoom + mulscale7(timepassed * synctics, zoom), 4096); zoom += (int)fmulscale6(j, max(zoom, 256));
if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
zoom -= (int)fmulscale6(j, max(zoom, 256));
zoom = clamp(zoom, 48, 2048);
} }
} }
@ -1859,11 +1871,11 @@ drawscreen(PLAYERp pp, double smoothratio)
{ {
// only clear the actual window. // only clear the actual window.
twod->AddColorOnlyQuad(windowxy1.x, windowxy1.y, (windowxy2.x + 1) - windowxy1.x, (windowxy2.y + 1) - windowxy1.y, 0xff000000); twod->AddColorOnlyQuad(windowxy1.x, windowxy1.y, (windowxy2.x + 1) - windowxy1.x, (windowxy2.y + 1) - windowxy1.y, 0xff000000);
renderDrawMapView(tx, ty, zoom, FixedToInt(tq16ang)); renderDrawMapView(tx, ty, zoom*2, FixedToInt(tq16ang));
} }
// Draw the line map on top of texture 2d map or just stand alone // Draw the line map on top of texture 2d map or just stand alone
drawoverheadmap(tx, ty, zoom, FixedToInt(tq16ang)); drawoverheadmap(tx, ty, zoom*2, FixedToInt(tq16ang));
} }
for (j = 0; j < MAXSPRITES; j++) for (j = 0; j < MAXSPRITES; j++)
@ -1888,7 +1900,7 @@ drawscreen(PLAYERp pp, double smoothratio)
SyncStatMessage(); SyncStatMessage();
#endif #endif
UpdateStatusBar(gameclock); UpdateStatusBar();
DrawCrosshair(pp); DrawCrosshair(pp);
DoPlayerDiveMeter(pp); // Do the underwater breathing bar DoPlayerDiveMeter(pp); // Do the underwater breathing bar

View file

@ -291,7 +291,7 @@ void InitLevelGlobals(void)
{ {
ChopTics = 0; ChopTics = 0;
automapMode = am_off; automapMode = am_off;
zoom = 768; zoom = 768 / 2;
PlayerGravity = 24; PlayerGravity = 24;
wait_active_check_offset = 0; wait_active_check_offset = 0;
PlaxCeilGlobZadjust = PlaxFloorGlobZadjust = Z(500); PlaxCeilGlobZadjust = PlaxFloorGlobZadjust = Z(500);
@ -725,11 +725,9 @@ void GameTicker(void)
ready2send = 1; ready2send = 1;
int const currentTic = I_GetTime(); int const currentTic = I_GetTime();
updateGameClock();
if (paused) if (paused)
{ {
buttonMap.ResetButtonStates();
smoothratio = MaxSmoothRatio; smoothratio = MaxSmoothRatio;
} }
else else
@ -740,7 +738,6 @@ void GameTicker(void)
while (ready2send && currentTic - lastTic >= 1) while (ready2send && currentTic - lastTic >= 1)
{ {
lastTic = currentTic; lastTic = currentTic;
ogameclock = gameclock;
UpdateInputs(); UpdateInputs();
MoveTicker(); MoveTicker();
} }

View file

@ -2053,7 +2053,6 @@ extern USER puser[MAX_SW_PLAYERS_REG];
/////////////////////////// ///////////////////////////
extern int gotlastpacketclock; extern int gotlastpacketclock;
extern int ogameclock;
extern SWBOOL ready2send; extern SWBOOL ready2send;
extern double smoothratio; extern double smoothratio;
@ -2181,7 +2180,7 @@ void AudioUpdate(void); // stupid
extern short LastSaveNum; extern short LastSaveNum;
void LoadSaveMsg(const char *msg); void LoadSaveMsg(const char *msg);
void UpdateStatusBar(int arg); void UpdateStatusBar();
void InitFonts(); void InitFonts();
int32_t registerosdcommands(void); int32_t registerosdcommands(void);
void SW_InitMultiPsky(void); void SW_InitMultiPsky(void);

View file

@ -300,7 +300,7 @@ void JS_InitMirrors(void)
// Scan wall tags for mirrors // Scan wall tags for mirrors
mirrorcnt = 0; mirrorcnt = 0;
tileDelete(MIRROR); tileDelete(MIRROR);
oscilationclock = ogameclock; oscilationclock = I_GetBuildTime();
for (i = 0; i < MAXMIRRORS; i++) for (i = 0; i < MAXMIRRORS; i++)
{ {
@ -517,6 +517,7 @@ JS_ProcessEchoSpot()
#define MAXCAMDIST 8000 #define MAXCAMDIST 8000
int camloopcnt = 0; // Timer to cycle through player int camloopcnt = 0; // Timer to cycle through player
int lastcamclock;
// views // views
short camplayerview = 1; // Don't show yourself! short camplayerview = 1; // Don't show yourself!
@ -531,8 +532,9 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
int* longptr; int* longptr;
SWBOOL bIsWallMirror = FALSE; SWBOOL bIsWallMirror = FALSE;
int camclock = I_GetBuildTime();
camloopcnt += gameclock - ogameclock; camloopcnt += camclock - lastcamclock;
if (camloopcnt > (60 * 5)) // 5 seconds per player view if (camloopcnt > (60 * 5)) // 5 seconds per player view
{ {
camloopcnt = 0; camloopcnt = 0;
@ -540,12 +542,13 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
if (camplayerview >= numplayers) if (camplayerview >= numplayers)
camplayerview = 1; camplayerview = 1;
} }
lastcamclock = camclock;
// WARNING! Assuming (MIRRORLABEL&31) = 0 and MAXMIRRORS = 64 <-- JBF: wrong // WARNING! Assuming (MIRRORLABEL&31) = 0 and MAXMIRRORS = 64 <-- JBF: wrong
longptr = (int*)&gotpic[MIRRORLABEL >> 3]; longptr = (int*)&gotpic[MIRRORLABEL >> 3];
if (longptr && (longptr[0] || longptr[1])) if (longptr && (longptr[0] || longptr[1]))
{ {
uint32_t oscilation_delta = ogameclock - oscilationclock; uint32_t oscilation_delta = camclock - oscilationclock;
oscilation_delta -= oscilation_delta % 4; oscilation_delta -= oscilation_delta % 4;
oscilationclock += oscilation_delta; oscilationclock += oscilation_delta;
oscilation_delta *= 2; 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 (Player[p].PlayerSprite == j)
{ {
if (sprite[Player[p].PlayerSprite].xvel > 16) if (sprite[Player[p].PlayerSprite].xvel > 16)
pspr_ndx[myconnectindex] = ((gameclock >> 4)&3); pspr_ndx[myconnectindex] = ((PlayClock >> 4)&3);
sprisplayer = TRUE; sprisplayer = TRUE;
goto SHOWSPRITE; goto SHOWSPRITE;

View file

@ -67,7 +67,6 @@ int movefifoplc, movefifosendplc; //, movefifoend[MAX_SW_PLAYERS];
int bufferjitter = 1; int bufferjitter = 1;
int ogameclock;
double smoothratio; double smoothratio;
// must start out as 0 // must start out as 0

View file

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

View file

@ -562,8 +562,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv)
#endif #endif
#endif #endif
MWRITE(&gameclock,sizeof(gameclock),1,fil);
MWRITE(&NormalVisibility,sizeof(NormalVisibility),1,fil); MWRITE(&NormalVisibility,sizeof(NormalVisibility),1,fil);
MWRITE(&MoveSkip2,sizeof(MoveSkip2),1,fil); MWRITE(&MoveSkip2,sizeof(MoveSkip2),1,fil);
MWRITE(&MoveSkip4,sizeof(MoveSkip4),1,fil); MWRITE(&MoveSkip4,sizeof(MoveSkip4),1,fil);
@ -936,8 +934,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
#endif #endif
#endif #endif
MREAD(&gameclock,sizeof(gameclock),1,fil);
MREAD(&NormalVisibility,sizeof(NormalVisibility),1,fil); MREAD(&NormalVisibility,sizeof(NormalVisibility),1,fil);
MREAD(&MoveSkip2,sizeof(MoveSkip2),1,fil); MREAD(&MoveSkip2,sizeof(MoveSkip2),1,fil);

View file

@ -792,11 +792,11 @@ private:
imgScale = baseScale / img->GetDisplayHeight(); imgScale = baseScale / img->GetDisplayHeight();
DrawGraphic(img, 1.5, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); DrawGraphic(img, 1.5, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale);
if (!althud_flashing || u->Health > (u->MaxHealth >> 2) || (gameclock & 32)) if (!althud_flashing || u->Health > (u->MaxHealth >> 2) || (PlayClock & 32))
{ {
int s = -8; int s = -8;
if (althud_flashing && u->Health > u->MaxHealth) if (althud_flashing && u->Health > u->MaxHealth)
s += (sintable[(gameclock << 5) & 2047] >> 10); s += (sintable[(PlayClock << 5) & 2047] >> 10);
int intens = clamp(255 - 4 * s, 0, 255); int intens = clamp(255 - 4 * s, 0, 255);
auto pe = PalEntry(255, intens, intens, intens); auto pe = PalEntry(255, intens, intens, intens);
format.Format("%d", u->Health); format.Format("%d", u->Health);
@ -854,7 +854,7 @@ private:
imgX += (imgX * 0.855) * (strlen - 1); imgX += (imgX * 0.855) * (strlen - 1);
} }
if ((!althud_flashing || gameclock & 32 || ammo > (DamageData[weapon].max_ammo / 10))) if ((!althud_flashing || PlayClock & 32 || ammo > (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); SBar_DrawString(this, &numberFont, format, -1.5, -numberFont.mFont->GetHeight(), DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1);
} }
@ -982,7 +982,7 @@ private:
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
public: public:
void UpdateStatusBar(int arg) void UpdateStatusBar()
{ {
int nPalette = 0; int nPalette = 0;
double inv_x, inv_y; double inv_x, inv_y;
@ -1049,7 +1049,7 @@ static void UpdateFrame(void)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void UpdateStatusBar(int arg) void UpdateStatusBar()
{ {
DSWStatusBar sbar; DSWStatusBar sbar;
@ -1058,7 +1058,7 @@ void UpdateStatusBar(int arg)
UpdateFrame(); UpdateFrame();
} }
sbar.UpdateStatusBar(arg); sbar.UpdateStatusBar();
PLAYERp pp = &Player[screenpeek]; PLAYERp pp = &Player[screenpeek];
if (pp->cookieTime > 0) if (pp->cookieTime > 0)
{ {

View file

@ -304,7 +304,7 @@ static void RestartAmbient(AmbientSound* amb)
int pitch = 0; int pitch = 0;
if (vp.pitch_hi <= vp.pitch_lo) pitch = vp.pitch_lo; 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)); else pitch = vp.pitch_lo + (STD_RANDOM_RANGE(vp.pitch_hi - vp.pitch_lo));
amb->curIndex = gameclock; amb->curIndex = PlayClock;
if (!soundEngine->IsSourcePlayingSomething(SOURCE_Ambient, amb, CHAN_BODY, amb->vocIndex)) 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)); 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) static void DoTimedSound(AmbientSound* amb)
{ {
if (gameclock >= amb->curIndex + amb->maxIndex) if (PlayClock >= amb->curIndex + amb->maxIndex)
{ {
if (!soundEngine->IsSourcePlayingSomething(SOURCE_Ambient, amb, CHAN_BODY)) if (!soundEngine->IsSourcePlayingSomething(SOURCE_Ambient, amb, CHAN_BODY))
{ {

View file

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