Respect r_maxfps in menus and on startup/bonus/end screens

git-svn-id: https://svn.eduke32.com/eduke32@6237 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2017-06-23 03:59:26 +00:00
parent 4489e110de
commit eae02b26a1
7 changed files with 490 additions and 489 deletions

View file

@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "menus.h"
#include "savegame.h"
#include "input.h"
#include "screens.h"
char g_firstDemoFile[BMAX_PATH];
@ -531,7 +532,6 @@ RECHECK:
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 1); // JBF 20040308
G_DrawBackground();
M_DisplayMenus();
//g_player[myconnectindex].ps->palette = palette;
nextpage();
fadepal(0,0,0, 252,0,-28);
ud.reccnt = 0;
@ -788,6 +788,8 @@ nextdemo_nomenu:
if (Demo_IsProfiling())
totalclock += TICSPERFRAME;
if (G_FPSLimit())
{
if (foundemo == 0)
{
G_DrawBackground();
@ -797,22 +799,11 @@ nextdemo_nomenu:
}
else
{
static uint32_t nextrender = 0, framewaiting = 0;
uint32_t tt;
// NOTE: currently, no key/mouse events will be seen while
// demo-profiling because we need 'totalclock' for ourselves.
// And handleevents() -> sampletimer() would mess that up.
G_HandleLocalKeys();
if (framewaiting)
{
framewaiting--;
nextpage();
}
tt = getticks();
// Render one frame (potentially many if profiling)
if (Demo_IsProfiling())
{
@ -850,13 +841,8 @@ nextdemo_nomenu:
if (handleevents_peekkeys())
Demo_StopProfiling();
}
else if (r_maxfps == 0 || tt >= nextrender)
else
{
if (tt > nextrender+g_frameDelay)
nextrender = tt;
nextrender += g_frameDelay;
j = calc_smoothratio(totalclock, ototalclock);
if (g_demo_paused && g_demo_rewind)
j = 65536-j;
@ -864,10 +850,8 @@ nextdemo_nomenu:
G_DrawRooms(screenpeek, j);
G_DisplayRest(j);
framewaiting++;
}
else
totalclocklock = totalclock;
// totalclocklock = totalclock;
if (!Demo_IsProfiling() && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0)
{
@ -972,15 +956,13 @@ nextdemo_nomenu:
if (ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0)
rotatesprite_fs((320-50)<<16, 9<<16, 65536L, 0, BETAVERSION, 0, 0, 2+8+16+128);
}
}
// NOTE: We must prevent handleevents() and Net_GetPackets() from
// updating totalclock when profiling (both via sampletimer()):
if (!Demo_IsProfiling())
G_HandleAsync();
if (ud.recstat==0)
nextpage();
if (g_player[myconnectindex].ps->gm == MODE_GAME)
{
// user wants to play a game, quit showing demo!

View file

@ -6053,6 +6053,33 @@ void G_MaybeAllocPlayer(int32_t pnum)
#endif
}
int G_FPSLimit(void)
{
static uint32_t nextRender = 0, frameWaiting = 0;
if (frameWaiting)
{
frameWaiting--;
nextpage();
}
uint32_t frameTime = getticks();
if (r_maxfps == 0 || frameTime >= nextRender)
{
if (frameTime > nextRender + g_frameDelay)
nextRender = frameTime;
nextRender += g_frameDelay;
frameWaiting++;
return 1;
}
return 0;
}
// TODO: reorder (net)actor_t to eliminate slop and update assertion
// EDUKE32_STATIC_ASSERT(sizeof(actor_t)==128);
EDUKE32_STATIC_ASSERT(sizeof(DukePlayer_t)%4 == 0);
@ -6571,9 +6598,6 @@ MAIN_LOOP_RESTART:
do //main loop
{
static uint32_t nextRender = 0, frameWaiting = 0;
uint32_t frameTime;
if (handleevents() && quitevent)
{
KB_KeyDown[sc_Escape] = 1;
@ -6700,21 +6724,8 @@ MAIN_LOOP_RESTART:
goto skipframe;
}
if (frameWaiting)
if (G_FPSLimit())
{
frameWaiting--;
nextpage();
}
frameTime = getticks();
if (r_maxfps == 0 || frameTime >= nextRender)
{
if (frameTime > nextRender + g_frameDelay)
nextRender = frameTime;
nextRender += g_frameDelay;
int const smoothRatio
= ((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && !(g_player[myconnectindex].ps->gm & MODE_MENU))
|| (g_netServer || ud.multimode > 1)
@ -6726,8 +6737,6 @@ MAIN_LOOP_RESTART:
if (getrendermode() >= REND_POLYMOST)
G_DrawBackground();
G_DisplayRest(smoothRatio);
frameWaiting++;
}
skipframe:

View file

@ -333,7 +333,7 @@ void G_DrawFrags(void);
void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t smoothratio);
void G_DrawRooms(int32_t snum,int32_t smoothratio);
void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
void G_FadePalette(int32_t r,int32_t g,int32_t b,int32_t e);
int G_FPSLimit(void);
void G_GameExit(const char *t) ATTRIBUTE((noreturn));
void G_GameQuit(void);
void G_GetCrosshairColor(void);

View file

@ -3504,9 +3504,8 @@ nullquote:
time_t timeStruct = time(NULL);
struct tm *pTime = localtime(&timeStruct);
Bsnprintf(ud.savegame[requestedSlot], sizeof(ud.savegame[requestedSlot]),
"Auto %.4d%.2d%.2d %.2d%.2d%.2d", pTime->tm_year + 1900, pTime->tm_mon + 1, pTime->tm_mday,
pTime->tm_hour, pTime->tm_min, pTime->tm_sec);
strftime(ud.savegame[requestedSlot], sizeof(ud.savegame[requestedSlot]),
"%d %b %Y %I:%M%p", pTime);
}
continue;

View file

@ -217,11 +217,13 @@ void Net_WaitForServer(void)
{
if (quitevent || keystatus[1]) G_GameExit("");
if (G_FPSLimit())
{
display_betascreen();
gametext_center_shade(170, "Waiting for server", 14);
nextpage();
}
// XXX: this looks like something that should be rate limited...
packbuf[0] = PACKET_PLAYER_PING;
packbuf[1] = myconnectindex;

View file

@ -1290,11 +1290,10 @@ void G_DisplayRest(int32_t smoothratio)
void G_FadePalette(int32_t r, int32_t g, int32_t b, int32_t e)
{
int32_t tc;
setpalettefade(r, g, b, e);
nextpage();
tc = totalclock;
int32_t tc = totalclock;
while (totalclock < tc + 4)
G_HandleAsync();
}
@ -1480,7 +1479,6 @@ void G_DisplayLogo(void)
if (logoflags & LOGO_3DRSCREEN)
{
if (!I_CheckAllInput() && g_noLogoAnim == 0)
{
int32_t i;
@ -1509,12 +1507,13 @@ void G_DisplayLogo(void)
nextpage();
fadepaltile(0, 0, 0, 252, 0, -28, DREALMS);
totalclock = 0;
while (totalclock < (120 * 7) && !I_CheckAllInput())
{
if (G_FPSLimit())
{
clearallviews(0);
rotatesprite_fs(160 << 16, 100 << 16, 65536L, 0, DREALMS, 0, 0, 2 + 8 + 64 + BGSTRETCH);
G_HandleAsync();
if (g_restorePalette)
@ -1522,8 +1521,9 @@ void G_DisplayLogo(void)
P_SetGamePalette(g_player[myconnectindex].ps, g_player[myconnectindex].ps->palette, 0);
g_restorePalette = 0;
}
nextpage();
}
}
fadepaltile(0, 0, 0, 0, 252, 28, DREALMS);
}
}
@ -1555,9 +1555,10 @@ void G_DisplayLogo(void)
totalclock < (860+120) &&
#endif
!I_CheckAllInput())
{
if (G_FPSLimit())
{
clearallviews(0);
rotatesprite_fs(160<<16, 100<<16, 65536L, 0, BETASCREEN, 0, 0, 2+8+64+BGSTRETCH);
if (logoflags & LOGO_DUKENUKEM)
{
@ -1620,7 +1621,6 @@ void G_DisplayLogo(void)
g_elEventError = 0;
#endif
VM_OnEvent(EVENT_LOGO, -1, screenpeek);
G_HandleAsync();
if (g_restorePalette)
{
@ -1631,9 +1631,12 @@ void G_DisplayLogo(void)
if (g_elEventError)
break;
#endif
nextpage();
}
G_HandleAsync();
}
}
I_ClearAllInput();
}
@ -1706,6 +1709,8 @@ static void G_BonusCutscenes(void)
totalclock = 0;
while (1)
{
if (G_FPSLimit())
{
clearallviews(0L);
rotatesprite_fs(0, 50<<16, 65536L, 0, VICTORY1, 0, 0, 2+8+16+64+128+BGSTRETCH);
@ -1755,10 +1760,10 @@ static void G_BonusCutscenes(void)
rotatesprite_fs(breathe[t+3]<<16, breathe[t+4]<<16, 65536L, 0, breathe[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH);
}
}
}
G_HandleAsync();
nextpage();
if (I_CheckAllInput()) break;
}
@ -2168,12 +2173,13 @@ void G_BonusScreen(int32_t bonusonly)
while (totalclock < TICRATE*10)
{
G_HandleAsync();
MUSIC_Update();
if (G_FPSLimit())
{
clearallviews(0);
G_DisplayMPResultsScreen();
nextpage();
}
if (I_CheckAllInput())
{
@ -2213,13 +2219,13 @@ void G_BonusScreen(int32_t bonusonly)
int32_t yy = 0, zz;
G_HandleAsync();
MUSIC_Update();
if (G_FPSLimit())
{
if (g_player[myconnectindex].ps->gm&MODE_EOL)
{
clearallviews(0);
rotatesprite_fs(160<<16, 100<<16, 65536L, 0, BONUSSCREEN+gfx_offset, 0, 0, 2+8+64+128+BGSTRETCH);
if (totalclock >= 1000000000 && totalclock < 1000000320)
@ -2445,6 +2451,7 @@ void G_BonusScreen(int32_t bonusonly)
}
else
break;
}
VM_OnEvent(EVENT_DISPLAYBONUSSCREEN, g_player[screenpeek].ps->i, screenpeek);
nextpage();

View file

@ -42,3 +42,5 @@ extern sprstat_t g_spriteStat;
extern int32_t dr_yxaspect, dr_viewingrange;
extern int32_t g_noLogoAnim, g_noLogo;
extern void G_FadePalette(int32_t r, int32_t g, int32_t b, int32_t e);