mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
-let's hope this will solve the pausing problem for good.
The checks for game pause were totally inconsistent, so now there is a utility function that tells whether the game is supposed to run or not. pause can also take 3 values now - 0 for no pause, 1 for pause from opening the menu or console or 2 for hitting the pause button.
This commit is contained in:
parent
6227f9f7fd
commit
61f5247b71
13 changed files with 41 additions and 43 deletions
|
@ -1103,11 +1103,12 @@ bool CheckCheatmode(bool printmsg)
|
|||
void updatePauseStatus()
|
||||
{
|
||||
bool GUICapture = System_WantGuiCapture();
|
||||
if ( GUICapture)
|
||||
if (M_Active() || ConsoleState != c_up)
|
||||
{
|
||||
paused = 1;
|
||||
return;
|
||||
}
|
||||
else if ((!M_Active() || !GUICapture) && !pausedWithKey)
|
||||
else if (!pausedWithKey)
|
||||
{
|
||||
paused = 0;
|
||||
}
|
||||
|
@ -1115,7 +1116,7 @@ void updatePauseStatus()
|
|||
if (inputState.GetKeyStatus(sc_Pause))
|
||||
{
|
||||
inputState.ClearKeyStatus(sc_Pause);
|
||||
paused = !paused;
|
||||
paused = pausedWithKey ? 0 : 2;
|
||||
|
||||
if (paused)
|
||||
{
|
||||
|
@ -1123,10 +1124,10 @@ void updatePauseStatus()
|
|||
}
|
||||
else
|
||||
{
|
||||
S_ResumeSound(paused);
|
||||
S_ResumeSound(!!paused);
|
||||
}
|
||||
|
||||
pausedWithKey = paused;
|
||||
pausedWithKey = !!paused;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,6 +202,7 @@ enum
|
|||
PAUSESFX_CONSOLE = 2
|
||||
};
|
||||
|
||||
bool UIActive();
|
||||
void updatePauseStatus();
|
||||
void updatePauseStatus(bool state, bool multiplayer);
|
||||
extern int paused;
|
||||
|
|
|
@ -483,7 +483,6 @@ enum EFlamethrowerState
|
|||
};
|
||||
|
||||
enum gamemode_t {
|
||||
MODE_MENU = 0x00000001,
|
||||
MODE_DEMO = 0x00000002,
|
||||
MODE_GAME = 0x00000004,
|
||||
MODE_EOL = 0x00000008,
|
||||
|
|
|
@ -221,12 +221,6 @@ void GameInterface::MenuOpened()
|
|||
totalclock = ototalclock;
|
||||
screenpeek = myconnectindex;
|
||||
}
|
||||
|
||||
auto& gm = ps[myconnectindex].gm;
|
||||
if (gm & MODE_GAME)
|
||||
{
|
||||
gm |= MODE_MENU;
|
||||
}
|
||||
}
|
||||
|
||||
void GameInterface::MenuSound(EMenuSounds snd)
|
||||
|
@ -260,7 +254,6 @@ void GameInterface::MenuClosed()
|
|||
if (gm & MODE_GAME)
|
||||
{
|
||||
// The following lines are here so that you cannot close the menu when no game is running.
|
||||
gm &= ~MODE_MENU;
|
||||
|
||||
if (ud.multimode < 2 && ud.recstat != 2)
|
||||
{
|
||||
|
|
|
@ -40,6 +40,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
#include "i_interface.h"
|
||||
#include "prediction.h"
|
||||
#include "glbackend/glbackend.h"
|
||||
#include "gamestate.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
@ -282,7 +283,7 @@ static void ticker(void)
|
|||
S_Update();
|
||||
|
||||
// we need CONTROL_GetInput in order to pick up joystick button presses
|
||||
if (!(ps[myconnectindex].gm & MODE_GAME) || (paused && !System_WantGuiCapture()))
|
||||
if (gamestate != GS_LEVEL || (paused && !System_WantGuiCapture()))
|
||||
{
|
||||
ControlInfo noshareinfo;
|
||||
CONTROL_GetInput(&noshareinfo);
|
||||
|
|
|
@ -174,17 +174,13 @@ void FTA(int q, struct player_struct* p)
|
|||
|
||||
void drawbackground(void)
|
||||
{
|
||||
if ((ps[myconnectindex].gm & MODE_GAME) == 0 && ud.recstat != 2)
|
||||
{
|
||||
twod->ClearScreen();
|
||||
auto tex = tileGetTexture(TILE_MENUSCREEN);
|
||||
PalEntry color = 0xff808080;
|
||||
if (!hud_bgstretch)
|
||||
DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, DTA_Color, color, TAG_DONE);
|
||||
else
|
||||
DrawTexture(twod, tex, 0, 0, DTA_VirtualWidth, twod->GetWidth(), DTA_VirtualHeight, twod->GetHeight(), DTA_KeepRatio, true, DTA_Color, color, TAG_DONE);
|
||||
return;
|
||||
}
|
||||
twod->ClearScreen();
|
||||
auto tex = tileGetTexture(TILE_MENUSCREEN);
|
||||
PalEntry color = 0xff808080;
|
||||
if (!hud_bgstretch)
|
||||
DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, DTA_Color, color, TAG_DONE);
|
||||
else
|
||||
DrawTexture(twod, tex, 0, 0, DTA_VirtualWidth, twod->GetWidth(), DTA_VirtualHeight, twod->GetHeight(), DTA_KeepRatio, true, DTA_Color, color, TAG_DONE);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -304,7 +300,7 @@ void displayrest(int smoothratio)
|
|||
|
||||
if (ud.scrollmode == 0)
|
||||
{
|
||||
if (pp->newowner == -1 && !paused)
|
||||
if (pp->newowner == -1 && playrunning())
|
||||
{
|
||||
if (screenpeek == myconnectindex && numplayers > 1)
|
||||
{
|
||||
|
@ -328,7 +324,7 @@ void displayrest(int smoothratio)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!paused)
|
||||
if (playrunning())
|
||||
{
|
||||
ud.fola += ud.folavel >> 3;
|
||||
ud.folx += (ud.folfvel * sintable[(512 + 2048 - ud.fola) & 2047]) >> 14;
|
||||
|
@ -371,7 +367,7 @@ void displayrest(int smoothratio)
|
|||
}
|
||||
}
|
||||
|
||||
if (paused == 1 && (ps[myconnectindex].gm & MODE_MENU) == 0)
|
||||
if (paused == 2)
|
||||
fi.PrintPaused();
|
||||
}
|
||||
|
||||
|
|
|
@ -961,7 +961,6 @@ int ParseState::parse(void)
|
|||
#if 0
|
||||
if( lastsavedpos >= 0 && ud.recstat != 2 )
|
||||
{
|
||||
ps[g_p].gm = MODE_MENU;
|
||||
KB_ClearKeyDown(sc_Space);
|
||||
cmenu(15000);
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ int domovethings()
|
|||
|
||||
//if(ud.recstat == 1) record();
|
||||
|
||||
if (paused == 0)
|
||||
if (playrunning())
|
||||
{
|
||||
global_random = krand();
|
||||
movedummyplayers();//ST 13
|
||||
|
@ -241,7 +241,7 @@ int domovethings()
|
|||
|
||||
for (i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
{
|
||||
if (paused == 0)
|
||||
if (playrunning())
|
||||
{
|
||||
auto p = &ps[i];
|
||||
if (p->pals.a > 0)
|
||||
|
@ -253,7 +253,7 @@ int domovethings()
|
|||
}
|
||||
}
|
||||
|
||||
if (paused == 0)
|
||||
if (playrunning())
|
||||
{
|
||||
if (levelTextTime > 0)
|
||||
levelTextTime--;
|
||||
|
@ -317,12 +317,11 @@ bool GameTicker()
|
|||
gameupdatetime.Reset();
|
||||
gameupdatetime.Clock();
|
||||
|
||||
while ((!(ps[myconnectindex].gm & (MODE_MENU | MODE_DEMO))) && (int)(totalclock - ototalclock) >= TICSPERFRAME)
|
||||
while (playrunning() && (int)(totalclock - ototalclock) >= TICSPERFRAME)
|
||||
{
|
||||
ototalclock += TICSPERFRAME;
|
||||
|
||||
GetInput();
|
||||
// this is where we fill the input_t struct that is actually processed by P_ProcessInput()
|
||||
auto const pPlayer = &ps[myconnectindex];
|
||||
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
||||
auto& input = nextinput(myconnectindex);
|
||||
|
@ -338,12 +337,15 @@ bool GameTicker()
|
|||
|
||||
advancequeue(myconnectindex);
|
||||
|
||||
if (((!System_WantGuiCapture() && (ps[myconnectindex].gm & MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (ud.multimode > 1)) &&
|
||||
(ps[myconnectindex].gm & MODE_GAME))
|
||||
if (playrunning())
|
||||
{
|
||||
moveloop();
|
||||
}
|
||||
}
|
||||
if (!playrunning())
|
||||
{
|
||||
ototalclock = totalclock - 1;
|
||||
}
|
||||
|
||||
gameUpdate = true;
|
||||
gameupdatetime.Unclock();
|
||||
|
@ -394,6 +396,7 @@ void app_loop()
|
|||
while (true)
|
||||
{
|
||||
handleevents();
|
||||
updatePauseStatus();
|
||||
switch (gamestate)
|
||||
{
|
||||
default:
|
||||
|
|
|
@ -164,10 +164,14 @@ inline void SetPlayerPal(player_struct* p, PalEntry pe)
|
|||
p->pals = pe;
|
||||
}
|
||||
|
||||
inline bool playrunning()
|
||||
{
|
||||
return (paused == 0 || (paused == 1 && (ud.recstat == 2 || ud.multimode > 1)));
|
||||
}
|
||||
|
||||
inline int calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
|
||||
{
|
||||
if (!((ud.multimode < 2 && ((ps[myconnectindex].gm & MODE_MENU) == 0)) ||
|
||||
ud.multimode > 1 || ud.recstat == 2) || paused)
|
||||
if (!playrunning())
|
||||
{
|
||||
return 65536;
|
||||
}
|
||||
|
|
|
@ -1227,7 +1227,6 @@ void GetInput()
|
|||
{
|
||||
double elapsedInputTicks;
|
||||
auto const p = &ps[myconnectindex];
|
||||
updatePauseStatus();
|
||||
|
||||
auto now = I_msTimeF();
|
||||
// do not let this become too large - it would create overflows resulting in undefined behavior. The very first tic must not use the timer difference at all because the timer has not been set yet.
|
||||
|
|
|
@ -293,9 +293,9 @@ void animatecamsprite(int smoothRatio)
|
|||
|
||||
void setdrugmode(player_struct *p, int oyrepeat)
|
||||
{
|
||||
if (!paused)
|
||||
if (playrunning())
|
||||
{
|
||||
if (p->DrugMode > 0 && !(p->gm & MODE_TYPE) && !paused)
|
||||
if (p->DrugMode > 0 && !(p->gm & MODE_TYPE))
|
||||
{
|
||||
int var_8c;
|
||||
if (p->drug_stat[0] == 0)
|
||||
|
@ -491,7 +491,7 @@ void displayrooms(int snum, int smoothratio)
|
|||
videoSetCorrectedAspect();
|
||||
|
||||
smoothratio = min(max(smoothratio, 0), 65536);
|
||||
if (paused || ps[snum].on_crane > -1) smoothratio = 65536;
|
||||
if (!playrunning() || ps[snum].on_crane > -1) smoothratio = 65536;
|
||||
|
||||
sect = p->cursectnum;
|
||||
if (sect < 0 || sect >= MAXSECTORS) return;
|
||||
|
|
|
@ -29,6 +29,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
#include "serializer.h"
|
||||
#include "mapinfo.h"
|
||||
#include "duke3d.h"
|
||||
#include "gamestate.h"
|
||||
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
@ -483,6 +484,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
|||
{
|
||||
screenpeek = myconnectindex;
|
||||
ps[myconnectindex].gm = MODE_GAME;
|
||||
gamestate = GS_LEVEL;
|
||||
ud.recstat = 0;
|
||||
|
||||
ud.m_player_skill = ud.player_skill;
|
||||
|
|
|
@ -375,7 +375,7 @@ void S_Update(void)
|
|||
int S_PlaySound3D(int sndnum, int spriteNum, const vec3_t* pos, int channel, EChanFlags flags)
|
||||
{
|
||||
auto const pl = &ps[myconnectindex];
|
||||
if (!soundEngine->isValidSoundId(sndnum+1) || !SoundEnabled() || (unsigned)spriteNum >= MAXSPRITES || (pl->gm & MODE_MENU) ||
|
||||
if (!soundEngine->isValidSoundId(sndnum+1) || !SoundEnabled() || (unsigned)spriteNum >= MAXSPRITES || !playrunning() ||
|
||||
(pl->timebeforeexit > 0 && pl->timebeforeexit <= REALGAMETICSPERSEC * 3)) return -1;
|
||||
|
||||
int userflags = S_GetUserFlags(sndnum);
|
||||
|
|
Loading…
Reference in a new issue