Blood: Amend how game pauses.

This commit is contained in:
Mitchell Richters 2020-05-29 11:20:40 +10:00 committed by Christoph Oelckers
parent ce48f081fc
commit daa862240d
5 changed files with 28 additions and 26 deletions

View file

@ -104,7 +104,6 @@ double g_gameUpdateAvgTime = 0.001;
bool gQuitGame;
int gQuitRequest;
bool gPaused;
enum gametokens
{
@ -663,7 +662,7 @@ void StartLevel(GAMEOPTIONS *gameOptions)
gGameMessageMgr.SetCoordinates(gViewX0S+1,gViewY0S+15);
netWaitForEveryone(0);
totalclock = 0;
gPaused = 0;
paused = 0;
gGameStarted = 1;
ready2send = 1;
}
@ -823,8 +822,7 @@ void ProcessFrame(void)
if (gPlayer[i].input.keyFlags.pause)
{
gPlayer[i].input.keyFlags.pause = 0;
gPaused = !gPaused;
if (gPaused && gGameOptions.nGameType > 0 && numplayers > 1)
if (paused && gGameOptions.nGameType > 0 && numplayers > 1)
{
sprintf(buffer,"%s paused the game",gProfile[i].name);
viewSetMessage(buffer);
@ -834,7 +832,7 @@ void ProcessFrame(void)
viewClearInterpolations();
if (!gDemo.at1)
{
if (gPaused || gEndGameMgr.at0 || (gGameOptions.nGameType == 0 && M_Active()))
if (paused || gEndGameMgr.at0 || (gGameOptions.nGameType == 0 && M_Active()))
return;
if (gDemo.at0)
gDemo.Write(gFifoInput[(gNetFifoTail-1)&255]);
@ -1214,7 +1212,7 @@ RESTART:
{
char gameUpdate = false;
double const gameUpdateStartTime = timerGetHiTicks();
while (gPredictTail < gNetFifoHead[myconnectindex] && !gPaused)
while (gPredictTail < gNetFifoHead[myconnectindex] && !paused)
{
viewUpdatePrediction(&gFifoInput[gPredictTail&255][myconnectindex]);
}

View file

@ -121,7 +121,6 @@ extern double g_gameUpdateTime, g_gameUpdateAndDrawTime;
extern double g_gameUpdateAvgTime;
extern int blood_globalflags;
extern bool gPaused;
extern bool gSavingGame;
extern bool gQuitGame;
extern int gQuitRequest;

View file

@ -78,8 +78,17 @@ int gViewLookRecenter;
void ctrlGetInput(void)
{
int prevPauseState = paused;
ControlInfo info;
static double lastInputTicks;
auto const currentHiTicks = timerGetHiTicks();
double const elapsedInputTicks = currentHiTicks - lastInputTicks;
lastInputTicks = currentHiTicks;
auto scaleAdjustmentToInterval = [=](double x) { return x * kTicsPerSec / (1000.0 / elapsedInputTicks); };
if (!gGameStarted || gInputMode != kInputGame)
{
gInput = {};
@ -87,14 +96,16 @@ void ctrlGetInput(void)
return;
}
updatePauseStatus();
if (paused != prevPauseState)
{
gInput.keyFlags.pause = 1;
}
if (paused)
return;
GINPUT input = {};
static double lastInputTicks;
auto const currentHiTicks = timerGetHiTicks();
double const elapsedInputTicks = currentHiTicks - lastInputTicks;
lastInputTicks = currentHiTicks;
auto scaleAdjustmentToInterval = [=](double x) { return x * kTicsPerSec / (1000.0 / elapsedInputTicks); };
D_ProcessEvents();
@ -366,12 +377,6 @@ void ctrlGetInput(void)
if (!in_mouseflip)
input.q16mlook = -input.q16mlook;
if (inputState.GetKeyStatus(sc_Pause)) // 0xc5 in disassembly
{
gInput.keyFlags.pause = 1;
inputState.ClearKeyStatus(sc_Pause);
}
if (!gViewMap.bFollowMode && gViewMode == 4)
{
gViewMap.turn += input.q16turn<<2;
@ -385,7 +390,7 @@ void ctrlGetInput(void)
gInput.strafe = clamp(gInput.strafe + input.strafe, -2048, 2048);
gInput.q16turn = fix16_sadd(gInput.q16turn, input.q16turn);
gInput.q16mlook = fix16_clamp(fix16_sadd(gInput.q16mlook, input.q16mlook), fix16_from_int(-127)>>2, fix16_from_int(127)>>2);
if (gMe && gMe->pXSprite->health != 0 && !gPaused)
if (gMe && gMe->pXSprite->health != 0 && !paused)
{
int upAngle = 289;
int downAngle = -347;

View file

@ -561,7 +561,7 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
gFrame = 0;
gFrameRate = 0;
totalclock = 0;
gPaused = 0;
paused = 0;
gGameStarted = 1;
bVanilla = false;
@ -662,7 +662,7 @@ void MyLoadSave::Load(void)
Read(&totalclock, sizeof(totalclock));
totalclock = nGameClock;
Read(&gLevelTime, sizeof(gLevelTime));
Read(&gPaused, sizeof(gPaused));
Read(&paused, sizeof(paused));
Read(baseWall, sizeof(baseWall[0])*numwalls);
Read(baseSprite, sizeof(baseSprite[0])*nNumSprites);
Read(baseFloor, sizeof(baseFloor[0])*numsectors);
@ -755,7 +755,7 @@ void MyLoadSave::Save(void)
ClockTicks nGameClock = totalclock;
Write(&nGameClock, sizeof(nGameClock));
Write(&gLevelTime, sizeof(gLevelTime));
Write(&gPaused, sizeof(gPaused));
Write(&paused, sizeof(paused));
Write(baseWall, sizeof(baseWall[0])*numwalls);
Write(baseSprite, sizeof(baseSprite[0])*nNumSprites);
Write(baseFloor, sizeof(baseFloor[0])*numsectors);

View file

@ -3088,7 +3088,7 @@ void viewDrawScreen(bool sceneonly)
if (delta < 0)
delta = 0;
lastUpdate = totalclock;
if (!gPaused && (!M_Active() || gGameOptions.nGameType != 0))
if (!paused && (!M_Active() || gGameOptions.nGameType != 0))
{
gInterpolate = ((totalclock-gNetFifoClock)+4).toScale16()/4;
}
@ -3558,7 +3558,7 @@ void viewDrawScreen(bool sceneonly)
viewDrawMapTitle();
viewDrawAimedPlayerName();
if (gPaused)
if (paused)
{
viewDrawText(1, GStrings("TXTB_PAUSED"), 160, 10, 0, 0, 1, 0);
}