Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3105e18d45 | ||
|
|
6c6de42601 | ||
|
|
af9a46d24a |
No files matched your search
+96
-20
@@ -350,6 +350,8 @@ static void D_Renderview(void)
|
|||||||
// added comment : there is a wipe eatch change of the gamestate
|
// added comment : there is a wipe eatch change of the gamestate
|
||||||
gamestate_t wipegamestate = GS_LEVEL;
|
gamestate_t wipegamestate = GS_LEVEL;
|
||||||
|
|
||||||
|
static void D_LimitFps(void);
|
||||||
|
|
||||||
static void D_MakeIntermissionBG(void)
|
static void D_MakeIntermissionBG(void)
|
||||||
{
|
{
|
||||||
if (!lastdraw)
|
if (!lastdraw)
|
||||||
@@ -645,6 +647,10 @@ static boolean D_Display(void)
|
|||||||
|
|
||||||
CON_Drawer(); // Ha, i LIED!
|
CON_Drawer(); // Ha, i LIED!
|
||||||
|
|
||||||
|
// be sure to limit our fps *before* drawing
|
||||||
|
// so we can properly "pace" our frames
|
||||||
|
D_LimitFps();
|
||||||
|
|
||||||
if (cv_lua_profile.value > 0)
|
if (cv_lua_profile.value > 0)
|
||||||
{
|
{
|
||||||
LUA_RenderTimers();
|
LUA_RenderTimers();
|
||||||
@@ -658,6 +664,78 @@ static boolean D_Display(void)
|
|||||||
return ranwipe;
|
return ranwipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static precise_t sleeptime = 0;
|
||||||
|
|
||||||
|
static boolean D_UseNewFramelimiter(void)
|
||||||
|
{
|
||||||
|
//if (!cv_newframelimiter.value) return false;
|
||||||
|
return (rendermode != render_none && !dedicated && (R_GetFramerateCap() >= 45) && R_UsingFrameInterpolation());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void D_LimitFps(void)
|
||||||
|
{
|
||||||
|
precise_t curtime, start;
|
||||||
|
static precise_t lasttime = 0;
|
||||||
|
|
||||||
|
// timedemo runs uncapped!
|
||||||
|
if (singletics)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!D_UseNewFramelimiter())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const UINT32 framecap = R_GetFramerateCap();
|
||||||
|
|
||||||
|
// uncapped obviously does not need to be... capped...
|
||||||
|
if (framecap == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// dont need to sleep if we vsync and our framecap is set to refresh rate or higher
|
||||||
|
if (cv_vidwait.value && (cv_fpscap.value == 0 || framecap > I_GetRefreshRate()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
start = I_GetPreciseTime();
|
||||||
|
|
||||||
|
const UINT64 precision = I_GetPrecisePrecision();
|
||||||
|
|
||||||
|
// frametarget in precise_t ticks (ex. 60fps = ~16,666,666)
|
||||||
|
const precise_t frametarget = precision / framecap;
|
||||||
|
|
||||||
|
lasttime += frametarget;
|
||||||
|
|
||||||
|
// just sync this up if we missed the target
|
||||||
|
if ((INT64)(start - lasttime) >= 0)
|
||||||
|
lasttime = start;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
// check the current time against the "time of the old frame"
|
||||||
|
curtime = I_GetPreciseTime();
|
||||||
|
|
||||||
|
// done waiting!
|
||||||
|
// continue as normal
|
||||||
|
if ((INT64)(curtime - lasttime) >= 0)
|
||||||
|
{
|
||||||
|
// time we spent :chaosleep:ing or doing absolutely nothing
|
||||||
|
// for frameskip calculations
|
||||||
|
sleeptime = curtime - start;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we have more than 1ms to wait
|
||||||
|
// sleep for a bit to not trash the cpu lul
|
||||||
|
precise_t remaining = lasttime - curtime;
|
||||||
|
|
||||||
|
if (remaining > (precise_t)(precision / 1000))
|
||||||
|
{
|
||||||
|
// sleep for 90% of the time we gotta wait for the next frame
|
||||||
|
// since we dont wanna oversleep :chaosleep:
|
||||||
|
I_SleepDuration(9 * remaining / 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// the rest we just be waitin until we meet our frametime target
|
||||||
|
}
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// D_SRB2Loop
|
// D_SRB2Loop
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
@@ -709,13 +787,13 @@ void D_SRB2Loop(void)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
// capbudget is the minimum precise_t duration of a single loop iteration
|
|
||||||
precise_t capbudget;
|
|
||||||
precise_t elapsed;
|
precise_t elapsed;
|
||||||
precise_t enterprecise, finishprecise;
|
precise_t enterprecise, finishprecise;
|
||||||
|
|
||||||
boolean ranwipe = false;
|
boolean ranwipe = false;
|
||||||
|
|
||||||
|
sleeptime = 0;
|
||||||
|
|
||||||
enterprecise = I_GetPreciseTime();
|
enterprecise = I_GetPreciseTime();
|
||||||
|
|
||||||
I_HandleInterrupt();
|
I_HandleInterrupt();
|
||||||
@@ -723,10 +801,6 @@ void D_SRB2Loop(void)
|
|||||||
memset(&g_dc, 0, sizeof(g_dc));
|
memset(&g_dc, 0, sizeof(g_dc));
|
||||||
Z_Frame_Reset();
|
Z_Frame_Reset();
|
||||||
|
|
||||||
// Casting the return value of a function is bad practice (apparently)
|
|
||||||
const UINT32 framecap = R_GetFramerateCap();
|
|
||||||
capbudget = (framecap == 0) ? 0 : (precise_t)((double)precision / (double)framecap + 0.5); // + 0.5 instead of round
|
|
||||||
|
|
||||||
I_UpdateTime(cv_timescale.value);
|
I_UpdateTime(cv_timescale.value);
|
||||||
|
|
||||||
if (lastwipetic)
|
if (lastwipetic)
|
||||||
@@ -747,11 +821,9 @@ void D_SRB2Loop(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUGFILE
|
#ifdef DEBUGFILE
|
||||||
if (!realtics)
|
if (!realtics && debugload)
|
||||||
if (debugload)
|
debugload--;
|
||||||
debugload--;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
interp = !dedicated && R_UsingFrameInterpolation();
|
interp = !dedicated && R_UsingFrameInterpolation();
|
||||||
doDisplay = false;
|
doDisplay = false;
|
||||||
|
|
||||||
@@ -785,6 +857,7 @@ void D_SRB2Loop(void)
|
|||||||
{
|
{
|
||||||
P_RunChaseCameras();
|
P_RunChaseCameras();
|
||||||
}
|
}
|
||||||
|
|
||||||
R_UpdateViewInterpolation();
|
R_UpdateViewInterpolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,7 +903,6 @@ void D_SRB2Loop(void)
|
|||||||
M_SaveFrame();
|
M_SaveFrame();
|
||||||
if (takescreenshot)
|
if (takescreenshot)
|
||||||
M_DoScreenShot();
|
M_DoScreenShot();
|
||||||
|
|
||||||
#ifndef DEDICATED
|
#ifndef DEDICATED
|
||||||
if (!dedicated && renderisnewtic)
|
if (!dedicated && renderisnewtic)
|
||||||
{
|
{
|
||||||
@@ -852,9 +924,9 @@ void D_SRB2Loop(void)
|
|||||||
// Fully completed frame made.
|
// Fully completed frame made.
|
||||||
finishprecise = I_GetPreciseTime();
|
finishprecise = I_GetPreciseTime();
|
||||||
|
|
||||||
// Use the time before sleep for frameskip calculations:
|
// Use the time without sleep for frameskip calculations:
|
||||||
// post-sleep time is literally being intentionally wasted
|
// post-sleep time is literally being intentionally wasted
|
||||||
elapsed = finishprecise - enterprecise;
|
elapsed = (finishprecise - enterprecise) - sleeptime;
|
||||||
deltasecs = (double)elapsed / (double)precision;
|
deltasecs = (double)elapsed / (double)precision;
|
||||||
deltatics = deltasecs * (double)NEWTICRATE;
|
deltatics = deltasecs * (double)NEWTICRATE;
|
||||||
|
|
||||||
@@ -882,8 +954,12 @@ void D_SRB2Loop(void)
|
|||||||
frameskip = 0;
|
frameskip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!singletics)
|
// old fps limiter
|
||||||
|
if (!singletics && !D_UseNewFramelimiter())
|
||||||
{
|
{
|
||||||
|
const UINT32 framecap = R_GetFramerateCap();
|
||||||
|
const precise_t capbudget = (framecap == 0) ? 0 : (precise_t)((double)precision / (double)framecap + 0.5); // + 0.5 instead of round
|
||||||
|
|
||||||
// in the case of "match refresh rate" + vsync, don't sleep at all
|
// in the case of "match refresh rate" + vsync, don't sleep at all
|
||||||
const boolean vsync_with_match_refresh = cv_vidwait.value && cv_fpscap.value == 0;
|
const boolean vsync_with_match_refresh = cv_vidwait.value && cv_fpscap.value == 0;
|
||||||
|
|
||||||
@@ -891,13 +967,13 @@ void D_SRB2Loop(void)
|
|||||||
{
|
{
|
||||||
I_SleepDuration(capbudget - elapsed);
|
I_SleepDuration(capbudget - elapsed);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Capture the time once more to get the real delta time.
|
// Capture the time once more to get the real delta time.
|
||||||
finishprecise = I_GetPreciseTime();
|
finishprecise = I_GetPreciseTime();
|
||||||
elapsed = finishprecise - enterprecise;
|
elapsed = finishprecise - enterprecise;
|
||||||
deltasecs = (double)elapsed / (double)precision;
|
deltasecs = (double)elapsed / (double)precision;
|
||||||
deltatics = deltasecs * (double)NEWTICRATE;
|
deltatics = deltasecs * (double)NEWTICRATE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-34
@@ -752,14 +752,9 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr
|
|||||||
|
|
||||||
static void SOCK_Send(void)
|
static void SOCK_Send(void)
|
||||||
{
|
{
|
||||||
|
ssize_t c = ERRSOCKET;
|
||||||
|
int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
int retrycount = 0;
|
|
||||||
ssize_t c;
|
|
||||||
int e; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once
|
|
||||||
|
|
||||||
retry:
|
|
||||||
c = ERRSOCKET;
|
|
||||||
e = 0;
|
|
||||||
|
|
||||||
if (doomcom->remotenode < 0 || !nodeconnected[doomcom->remotenode])
|
if (doomcom->remotenode < 0 || !nodeconnected[doomcom->remotenode])
|
||||||
return;
|
return;
|
||||||
@@ -813,35 +808,10 @@ retry:
|
|||||||
|
|
||||||
if (c == ERRSOCKET && e != 0) // 0 means no socket for the address family was found
|
if (c == ERRSOCKET && e != 0) // 0 means no socket for the address family was found
|
||||||
{
|
{
|
||||||
if (ALLOWEDERROR(e))
|
if (!ALLOWEDERROR(e))
|
||||||
return;
|
I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode,
|
||||||
|
|
||||||
//if (!ALLOWEDERROR(e))
|
|
||||||
//I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode,
|
|
||||||
//SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
|
|
||||||
|
|
||||||
// no need to spam this on retries
|
|
||||||
if (retrycount == 0)
|
|
||||||
CONS_Alert(CONS_ERROR, "SOCK_Send, error sending to node %d (%s) #%u, %s\n", doomcom->remotenode,
|
|
||||||
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
|
|
||||||
|
|
||||||
// retry sending it
|
|
||||||
if (retrycount <= 3)
|
|
||||||
{
|
|
||||||
CONS_Printf("SOCK_Send: retrying... Attempt %d\n", retrycount+1);
|
|
||||||
retrycount++;
|
|
||||||
// wait quarter of a second or smth
|
|
||||||
I_Sleep(250);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
// no recovery, guess we die
|
|
||||||
I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode,
|
|
||||||
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
|
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retrycount > 0)
|
|
||||||
CONS_Alert(CONS_NOTICE, "SOCK_Send: successfully reconnected on Attempt %d\n", retrycount);
|
|
||||||
}
|
}
|
||||||
#undef ALLOWEDERROR
|
#undef ALLOWEDERROR
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -217,7 +217,11 @@ static int mobj_get(lua_State *L)
|
|||||||
case mobj_skin: // skin name or nil, not struct
|
case mobj_skin: // skin name or nil, not struct
|
||||||
if (!mo->skin)
|
if (!mo->skin)
|
||||||
return 0;
|
return 0;
|
||||||
lua_pushstring(L, ((skin_t *)mo->skin)->name);
|
// HUD ONLY!!!!!!!!!!
|
||||||
|
if (hud_running && cv_luaimmersion.value)
|
||||||
|
lua_pushstring(L, K_GetMobjSkin(mo)->name);
|
||||||
|
else
|
||||||
|
lua_pushstring(L, ((skin_t *)mo->skin)->name);
|
||||||
break;
|
break;
|
||||||
case mobj_color:
|
case mobj_color:
|
||||||
lua_pushinteger(L, mo->color);
|
lua_pushinteger(L, mo->color);
|
||||||
|
|||||||
+2
-2
@@ -262,9 +262,9 @@ void OglSdlFinishUpdate(SDL_Window *window)
|
|||||||
// Sryder: We need to draw the final screen texture again into the other buffer in the original position so that
|
// Sryder: We need to draw the final screen texture again into the other buffer in the original position so that
|
||||||
// effects that want to take the old screen can do so after this
|
// effects that want to take the old screen can do so after this
|
||||||
#ifdef USE_FBO_OGL
|
#ifdef USE_FBO_OGL
|
||||||
if (!usefbo && (realwidth != sdlw || realheight != sdlh)) // not needed if fbo is in use
|
if (!usefbo && (realwidth != sdlw || realheight != sdlh || WipeInAction)) // not needed if fbo is in use
|
||||||
#else
|
#else
|
||||||
if (realwidth != sdlw || realheight != sdlh) // this is not needed if the render size matches window size
|
if (realwidth != sdlw || realheight != sdlh || WipeInAction) // this is not needed if the render size matches window size
|
||||||
#endif
|
#endif
|
||||||
HWR_DrawScreenFinalTexture(realwidth, realheight);
|
HWR_DrawScreenFinalTexture(realwidth, realheight);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user