mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
Duke3D: Amend how game pauses.
- M_Active or GUICapture properly pause game using game's pause mechanisms. - Pausing game with Pause key now works again. - Pausing game with Pause key now properly stops all sounds as per upstream.
This commit is contained in:
parent
7ed9f4fa8c
commit
65265594e5
13 changed files with 59 additions and 95 deletions
|
@ -425,7 +425,7 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, double xpos, doub
|
|||
|
||||
void GameInterface::MenuOpened()
|
||||
{
|
||||
S_PauseSounds(true);
|
||||
S_PauseSound(true, false);
|
||||
if ((!g_netServer && ud.multimode < 2))
|
||||
{
|
||||
ready2send = 0;
|
||||
|
@ -491,7 +491,7 @@ void GameInterface::MenuClosed()
|
|||
}
|
||||
|
||||
G_UpdateScreenArea();
|
||||
S_PauseSounds(false);
|
||||
S_ResumeSound(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine
|
|||
ud.reccnt = 0;
|
||||
|
||||
ud.god = ud.cashman = ud.eog = gFullMap = 0;
|
||||
ud.noclip = ud.scrollmode = ud.overhead_on = 0; //= ud.pause_on = 0;
|
||||
ud.noclip = ud.scrollmode = ud.overhead_on = 0; //= paused = 0;
|
||||
|
||||
totalclock = ototalclock = lockclock = 0;
|
||||
|
||||
|
@ -588,7 +588,7 @@ RECHECK:
|
|||
Demo_FinishProfile();
|
||||
|
||||
while (totalclock >= (lockclock+TICSPERFRAME)
|
||||
// || (ud.reccnt > REALGAMETICSPERSEC*2 && ud.pause_on)
|
||||
// || (ud.reccnt > REALGAMETICSPERSEC*2 && paused)
|
||||
|| (g_demo_goalCnt>0 && g_demo_cnt<g_demo_goalCnt))
|
||||
{
|
||||
if (ud.reccnt<=0)
|
||||
|
|
|
@ -3745,7 +3745,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
|
|||
spritesortcnt++;
|
||||
}
|
||||
|
||||
if (g_player[playerNum].input->extbits & (1 << 7) && !ud.pause_on && spritesortcnt < maxspritesonscreen)
|
||||
if (g_player[playerNum].input->extbits & (1 << 7) && !paused && spritesortcnt < maxspritesonscreen)
|
||||
{
|
||||
auto const playerTyping = &tsprite[spritesortcnt];
|
||||
|
||||
|
@ -5913,7 +5913,9 @@ MAIN_LOOP_RESTART:
|
|||
bool gameUpdate = false;
|
||||
double gameUpdateStartTime = timerGetHiTicks();
|
||||
|
||||
if (M_Active() || GUICapture || ud.pause_on != 0)
|
||||
updatePauseStatus();
|
||||
|
||||
if (paused)
|
||||
{
|
||||
ototalclock = totalclock - TICSPERFRAME;
|
||||
buttonMap.ResetButtonStates();
|
||||
|
@ -5922,30 +5924,33 @@ MAIN_LOOP_RESTART:
|
|||
{
|
||||
while (((g_netClient || g_netServer) || (myplayer.gm & (MODE_MENU | MODE_DEMO)) == 0) && (int)(totalclock - ototalclock) >= TICSPERFRAME)
|
||||
{
|
||||
ototalclock += TICSPERFRAME;
|
||||
|
||||
P_GetInput(myconnectindex);
|
||||
|
||||
// this is where we fill the input_t struct that is actually processed by P_ProcessInput()
|
||||
auto const pPlayer = g_player[myconnectindex].ps;
|
||||
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
||||
auto & input = inputfifo[0][myconnectindex];
|
||||
|
||||
input = localInput;
|
||||
input.fvel = mulscale9(localInput.fvel, sintable[(q16ang + 2560) & 2047]) +
|
||||
mulscale9(localInput.svel, sintable[(q16ang + 2048) & 2047]);
|
||||
input.svel = mulscale9(localInput.fvel, sintable[(q16ang + 2048) & 2047]) +
|
||||
mulscale9(localInput.svel, sintable[(q16ang + 1536) & 2047]);
|
||||
|
||||
if (!FURY)
|
||||
if (g_networkMode != NET_DEDICATED_SERVER)
|
||||
{
|
||||
input.fvel += pPlayer->fric.x;
|
||||
input.svel += pPlayer->fric.y;
|
||||
P_GetInput(myconnectindex);
|
||||
|
||||
// this is where we fill the input_t struct that is actually processed by P_ProcessInput()
|
||||
auto const pPlayer = g_player[myconnectindex].ps;
|
||||
auto const q16ang = fix16_to_int(pPlayer->q16ang);
|
||||
auto & input = inputfifo[0][myconnectindex];
|
||||
|
||||
input = localInput;
|
||||
input.fvel = mulscale9(localInput.fvel, sintable[(q16ang + 2560) & 2047]) +
|
||||
mulscale9(localInput.svel, sintable[(q16ang + 2048) & 2047]);
|
||||
input.svel = mulscale9(localInput.fvel, sintable[(q16ang + 2048) & 2047]) +
|
||||
mulscale9(localInput.svel, sintable[(q16ang + 1536) & 2047]);
|
||||
|
||||
if (!FURY)
|
||||
{
|
||||
input.fvel += pPlayer->fric.x;
|
||||
input.svel += pPlayer->fric.y;
|
||||
}
|
||||
|
||||
localInput = {};
|
||||
}
|
||||
|
||||
localInput = {};
|
||||
ototalclock += TICSPERFRAME;
|
||||
|
||||
if (((myplayer.gm & MODE_MENU) != MODE_MENU || ud.recstat == 2 || (g_netServer || ud.multimode > 1))
|
||||
if (paused == 0 && ((myplayer.gm & MODE_MENU) != MODE_MENU || ud.recstat == 2 || (g_netServer || ud.multimode > 1))
|
||||
&& (myplayer.gm & MODE_GAME))
|
||||
{
|
||||
Net_GetPackets();
|
||||
|
@ -6121,11 +6126,8 @@ int G_DoMoveThings(void)
|
|||
everyothertime++;
|
||||
if (g_earthquakeTime > 0) g_earthquakeTime--;
|
||||
|
||||
if (ud.pause_on == 0)
|
||||
{
|
||||
g_globalRandom = krand();
|
||||
A_MoveDummyPlayers();//ST 13
|
||||
}
|
||||
g_globalRandom = krand();
|
||||
A_MoveDummyPlayers();//ST 13
|
||||
|
||||
for (bssize_t TRAVERSE_CONNECT(i))
|
||||
{
|
||||
|
@ -6144,15 +6146,11 @@ int G_DoMoveThings(void)
|
|||
|
||||
P_HandleSharedKeys(i);
|
||||
|
||||
if (ud.pause_on == 0)
|
||||
{
|
||||
P_ProcessInput(i);
|
||||
P_CheckSectors(i);
|
||||
}
|
||||
P_ProcessInput(i);
|
||||
P_CheckSectors(i);
|
||||
}
|
||||
|
||||
if (ud.pause_on == 0)
|
||||
G_MoveWorld();
|
||||
G_MoveWorld();
|
||||
|
||||
// Net_CorrectPrediction();
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk
|
|||
if (!(((!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) ||
|
||||
(g_netServer || ud.multimode > 1) ||
|
||||
ud.recstat == 2) ||
|
||||
ud.pause_on)
|
||||
paused)
|
||||
{
|
||||
return 65536;
|
||||
}
|
||||
|
|
|
@ -1394,7 +1394,7 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2)
|
|||
case USERDEFS_OVERHEAD_ON: labelNum = ud.overhead_on; break;
|
||||
case USERDEFS_LAST_OVERHEAD: labelNum = ud.last_overhead; break;
|
||||
case USERDEFS_SHOWWEAPONS: labelNum = ud.showweapons; break;
|
||||
case USERDEFS_PAUSE_ON: labelNum = ud.pause_on; break;
|
||||
case USERDEFS_PAUSE_ON: labelNum = paused; break;
|
||||
case USERDEFS_FROM_BONUS: labelNum = ud.from_bonus; break;
|
||||
case USERDEFS_CAMERASPRITE: labelNum = ud.camerasprite; break;
|
||||
case USERDEFS_LAST_CAMSPRITE: labelNum = ud.last_camsprite; break;
|
||||
|
@ -1582,7 +1582,7 @@ void __fastcall VM_SetUserdef(int const labelNum, int const lParm2, int32_t cons
|
|||
case USERDEFS_OVERHEAD_ON: ud.overhead_on = iSet; break;
|
||||
case USERDEFS_LAST_OVERHEAD: ud.last_overhead = iSet; break;
|
||||
case USERDEFS_SHOWWEAPONS: ud.showweapons = iSet; break;
|
||||
case USERDEFS_PAUSE_ON: ud.pause_on = iSet; break;
|
||||
case USERDEFS_PAUSE_ON: paused = iSet; break;
|
||||
case USERDEFS_FROM_BONUS: ud.from_bonus = iSet; break;
|
||||
case USERDEFS_CAMERASPRITE: ud.camerasprite = iSet; break;
|
||||
case USERDEFS_LAST_CAMSPRITE: ud.last_camsprite = iSet; break;
|
||||
|
|
|
@ -2275,7 +2275,7 @@ static void Net_ReceiveServerUpdate(ENetEvent *event)
|
|||
Bmemcpy(&serverupdate, updatebuf, sizeof(serverupdate_t));
|
||||
updatebuf += sizeof(serverupdate_t);
|
||||
inputfifo[0][0] = serverupdate.nsyn;
|
||||
ud.pause_on = serverupdate.pause_on;
|
||||
paused = serverupdate.pause_on;
|
||||
|
||||
ticrandomseed = serverupdate.seed;
|
||||
|
||||
|
@ -4945,7 +4945,7 @@ void Net_SendServerUpdates(void)
|
|||
serverupdate.header = PACKET_MASTER_TO_SLAVE;
|
||||
serverupdate.seed = ticrandomseed;
|
||||
serverupdate.nsyn = *nsyn;
|
||||
serverupdate.pause_on = ud.pause_on;
|
||||
serverupdate.pause_on = paused;
|
||||
|
||||
serverupdate.numplayers = 0;
|
||||
updatebuf = tempnetbuf.Data() + sizeof(serverupdate_t);
|
||||
|
|
|
@ -2364,7 +2364,7 @@ void P_DisplayWeapon(void)
|
|||
goto enddisplayweapon;
|
||||
|
||||
#ifndef EDUKE32_STANDALONE
|
||||
int const doAnim = !(sprite[pPlayer->i].pal == 1 || ud.pause_on || g_player[myconnectindex].ps->gm & MODE_MENU);
|
||||
int const doAnim = !(sprite[pPlayer->i].pal == 1 || paused || g_player[myconnectindex].ps->gm & MODE_MENU);
|
||||
int const halfLookAng = fix16_to_int(pPlayer->q16look_ang) >> 1;
|
||||
|
||||
int const weaponPal = P_GetHudPal(pPlayer);
|
||||
|
@ -3073,7 +3073,15 @@ void P_GetInput(int const playerNum)
|
|||
auto const pSprite = &sprite[pPlayer->i];
|
||||
ControlInfo info;
|
||||
|
||||
if (g_cheatBufLen > 1 || (pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause)))
|
||||
auto const currentHiTicks = timerGetHiTicks();
|
||||
double const elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks;
|
||||
|
||||
thisPlayer.lastInputTicks = currentHiTicks;
|
||||
|
||||
if (elapsedInputTicks == currentHiTicks)
|
||||
return;
|
||||
|
||||
if (g_cheatBufLen > 1 || (pPlayer->gm & (MODE_MENU|MODE_TYPE)) || paused)
|
||||
{
|
||||
if (!(pPlayer->gm&MODE_MENU))
|
||||
CONTROL_GetInput(&info);
|
||||
|
@ -3134,14 +3142,6 @@ void P_GetInput(int const playerNum)
|
|||
input.svel -= info.dx * keyMove / analogExtent;
|
||||
input.fvel -= info.dz * keyMove / analogExtent;
|
||||
|
||||
auto const currentHiTicks = timerGetHiTicks();
|
||||
double const elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks;
|
||||
|
||||
thisPlayer.lastInputTicks = currentHiTicks;
|
||||
|
||||
if (elapsedInputTicks == currentHiTicks)
|
||||
return;
|
||||
|
||||
auto scaleAdjustmentToInterval = [=](double x) { return x * REALGAMETICSPERSEC / (1000.0 / elapsedInputTicks); };
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
|
@ -3274,7 +3274,6 @@ void P_GetInput(int const playerNum)
|
|||
|
||||
localInput.bits |= (mouseaim << SK_AIMMODE);
|
||||
localInput.bits |= (g_gameQuit << SK_GAMEQUIT);
|
||||
localInput.bits |= inputState.GetKeyStatus(sc_Pause) << SK_PAUSE;
|
||||
//localInput.bits |= ((uint32_t)inputState.GetKeyStatus(sc_Escape)) << SK_ESCAPE; fixme.This needs to be done differently
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Select))
|
||||
|
|
|
@ -871,7 +871,7 @@ static void P_PrepForNewLevel(int playerNum, int gameMode)
|
|||
|
||||
ud.camerasprite = -1;
|
||||
ud.eog = 0;
|
||||
ud.pause_on = 0;
|
||||
paused = 0;
|
||||
|
||||
if (((gameMode & MODE_EOL) != MODE_EOL && numplayers < 2 && !g_netServer)
|
||||
|| (!(g_gametypeFlags[ud.coop] & GAMETYPE_PRESERVEINVENTORYDEATH) && numplayers > 1))
|
||||
|
@ -1728,7 +1728,7 @@ int G_EnterLevel(int gameMode)
|
|||
|
||||
if (g_networkMode != NET_DEDICATED_SERVER)
|
||||
{
|
||||
S_PauseSounds(false);
|
||||
S_ResumeSound(false);
|
||||
FX_StopAllSounds();
|
||||
S_ClearSoundLocks();
|
||||
FX_SetReverb(0);
|
||||
|
|
|
@ -1093,7 +1093,7 @@ static const dataspec_t svgm_udnetw[] =
|
|||
{ DS_NOCHK, &ud.ffire, sizeof(ud.ffire), 1 },
|
||||
{ DS_NOCHK, &ud.noexits, sizeof(ud.noexits), 1 },
|
||||
{ DS_NOCHK, &ud.playerai, sizeof(ud.playerai), 1 },
|
||||
{ 0, &ud.pause_on, sizeof(ud.pause_on), 1 },
|
||||
{ 0, &paused, sizeof(paused), 1 },
|
||||
{ 0, connectpoint2, sizeof(connectpoint2), 1 },
|
||||
{ 0, &randomseed, sizeof(randomseed), 1 },
|
||||
{ 0, &g_globalRandom, sizeof(g_globalRandom), 1 },
|
||||
|
|
|
@ -784,7 +784,7 @@ void G_DisplayRest(int32_t smoothratio)
|
|||
|
||||
if (ud.scrollmode == 0)
|
||||
{
|
||||
if (pp->newowner == -1 && !ud.pause_on)
|
||||
if (pp->newowner == -1 && !paused)
|
||||
{
|
||||
cposx = pp->opos.x + mulscale16(pp->pos.x-pp->opos.x, smoothratio);
|
||||
cposy = pp->opos.y + mulscale16(pp->pos.y-pp->opos.y, smoothratio);
|
||||
|
@ -799,7 +799,7 @@ void G_DisplayRest(int32_t smoothratio)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!ud.pause_on)
|
||||
if (!paused)
|
||||
{
|
||||
ud.fola += ud.folavel>>3;
|
||||
ud.folx += (ud.folfvel*sintable[(512+2048-ud.fola)&2047])>>14;
|
||||
|
@ -898,10 +898,10 @@ void G_DisplayRest(int32_t smoothratio)
|
|||
renderSetAspect(vr, asp);
|
||||
}
|
||||
|
||||
if (ud.pause_on==1 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0)
|
||||
if (paused==1 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0)
|
||||
menutext_center(100, GStrings("Game Paused"));
|
||||
|
||||
mdpause = (ud.pause_on || (ud.recstat==2 && (g_demo_paused && g_demo_goalCnt==0)) || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2));
|
||||
mdpause = (paused || (ud.recstat==2 && (g_demo_paused && g_demo_goalCnt==0)) || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2));
|
||||
|
||||
// JBF 20040124: display level stats in screen corner
|
||||
if (ud.overhead_on != 2 && hud_stats && VM_OnEvent(EVENT_DISPLAYLEVELSTATS, g_player[screenpeek].ps->i, screenpeek) == 0)
|
||||
|
|
|
@ -2628,28 +2628,7 @@ void P_HandleSharedKeys(int playerNum)
|
|||
|
||||
if (playerBits && TEST_SYNC_KEY(playerBits, SK_MULTIFLAG) == 0)
|
||||
{
|
||||
if (TEST_SYNC_KEY(playerBits, SK_PAUSE))
|
||||
{
|
||||
inputState.ClearKeyStatus(sc_Pause);
|
||||
if (ud.pause_on)
|
||||
ud.pause_on = 0;
|
||||
else ud.pause_on = 1+SHIFTS_IS_PRESSED;
|
||||
if (ud.pause_on)
|
||||
{
|
||||
Mus_SetPaused(true);
|
||||
S_PauseSounds(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mus_SetPaused(false);
|
||||
S_PauseSounds(false);
|
||||
|
||||
pub = NUMPAGES;
|
||||
pus = NUMPAGES;
|
||||
}
|
||||
}
|
||||
|
||||
if (ud.pause_on) return;
|
||||
if (paused) return;
|
||||
|
||||
if (sprite[pPlayer->i].extra <= 0) return; // if dead...
|
||||
|
||||
|
|
|
@ -80,17 +80,6 @@ TArray<uint8_t> DukeSoundEngine::ReadSound(int lumpnum)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void S_PauseSounds(bool paused)
|
||||
{
|
||||
soundEngine->SetPaused(paused);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void cacheAllSounds(void)
|
||||
{
|
||||
auto& sfx = soundEngine->GetSounds();
|
||||
|
|
|
@ -58,7 +58,6 @@ inline void S_ClearSoundLocks(void) {}
|
|||
void cacheAllSounds(void);
|
||||
void S_MenuSound(void);
|
||||
void S_PauseMusic(bool paused);
|
||||
void S_PauseSounds(bool paused);
|
||||
void S_PlayLevelMusicOrNothing(unsigned int);
|
||||
int S_TryPlaySpecialMusic(unsigned int);
|
||||
void S_PlaySpecialMusicOrNothing(unsigned int);
|
||||
|
|
Loading…
Reference in a new issue