Compare commits

...
14 Commits
Author SHA1 Message Date
alufolie91 3105e18d45 New framelimiter
rewritten for much better frametimes and less jitter during heavy gameplay
still needs a toggle, currently this only applies to fpscaps from 60fps and up, dedi always uses the old one 
this now uses an accumilator to check how much time passed since the last frame present and waits accordingly before presenting the new frame
capping is done just before blit, after rendering and gamelogic and not at the end of the current frame anymore, which often caused to erroneausly sleep to much in "tic frames"
it also now does not exclusively sleep to avoid oversleeping the target, it sleeps per 90% the frametarget remainder the rest we wait per spinlooping
needs a bunch of testing as in theory this may slightly raise input lag (tho this shouldnt matter much here due to interp eitherways)
all this gives an almost dead flat graph on my usual timedemo, the vanilla limiter jitters massively through the whole demo (noticable as a sawwave pattern per 35hz)
2026-11-26 16:32:55 +01:00
alufolie91 6c6de42601 fix wipes on native res gl 2026-11-22 15:18:07 +00:00
indev af9a46d24a Fix 'localskin lua immersion' not working for mobj.skin 2026-11-20 21:18:30 +03:00
alufolie91 86976192f1 fix gl skydome "cap"
so turns out the texture coords for the dome cap were never initialized at all, which is what caused the weird "stripey" effect at times
just set it to the sky textures middle for the cap
2026-11-19 14:45:32 +01:00
alufolie91 67bac0aa88 fix zero division in HWR_SplitSprite
same fix as HWR_SplitWall
this may throw nan texture uv coords into gl which may be uncool
2026-11-19 14:44:52 +01:00
alufolie91 033e0cd416 match software slope contrast inversal in opengl 2026-11-19 14:44:48 +01:00
alufolie91 18a72d617d smol controller rumble tweaks
-Grow makes rumble twice as strong, while shrink halves its intensity, thought this be funny
-increase rumble length of first drift level slightly
-reduce rumble length of stairjank a little
- remove intensity clamps from ticker as G_PlayerDeviceRumble will already clamp it anyways
2026-11-19 14:44:42 +01:00
alufolie91 f0667895eb prefer statvfs over statfs for unix (from srb2classic) + other haiku stuff
should make I_GetDiskFreeSpace work on haiku
statvfs is the posix variant of statfs apparently so all nice there
2026-11-16 00:40:02 +01:00
alufolie91 b58bc02940 scale software vhs offset by udup
missed that when i added this oopsie
2026-11-16 00:05:00 +01:00
alufolie91 6b84c86197 fix vhs effect bars when rewinding
noticed while doing the shader thing
basically the effect is supposed to stack
but both calls being recursive, updated just the same bar positions, so both sets of bars would just draw over each other
this basically just like, keeps seperate positions for when rewind it true
this is probably how it was intended to work, otherwise that code makes not much sense
2026-11-15 01:26:57 +01:00
alufolie91 cc952dfd52 use software wall/slope contrast checks in gl paletterendering mode
simple enough change which should make this match up more, tho shouldnt be super different
2026-11-14 06:40:07 +01:00
alufolie91 063f94da8b fix slope contrast
missed a fix when ported it so the contrast direction was off by 90 degrees
also apparently i moved the software contrast part to never apply to fofs for some reason?
rechecked against the srb2 code for this and now properly matches up
2026-11-14 06:40:07 +01:00
alufolie91 457cae0ed9 adjust floor fudge for palette render
this significantly more matches software especially when drawing horizonlines
as gl was too dark in the distance compared to software
theres still some things left to recheck to better match software lighting (ex. wallcontrast) but too lazy atm
2026-11-14 06:40:07 +01:00
alufolie91 b990589e66 smol style fixes lua mobj and player lib 2026-11-14 06:40:07 +01:00
16 changed files with 421 additions and 314 deletions

No files matched your search

-1
View File
@@ -61,7 +61,6 @@
# NOPOSTPROCESSING=1 - ? # NOPOSTPROCESSING=1 - ?
# MOBJCONSISTANCY=1 - ?? # MOBJCONSISTANCY=1 - ??
# PACKETDROP=1 - ?? # PACKETDROP=1 - ??
# NOEXECINFO=1 - Disable stack trace dump support
# DEBUGMODE=1 - Enable various debugging capabilities. # DEBUGMODE=1 - Enable various debugging capabilities.
# Also disables optimizations. # Also disables optimizations.
# #
-2
View File
@@ -11,8 +11,6 @@ DEDICATED?=0
endif endif
endif endif
NOEXECINFO=1
ifeq (${SDL},1) ifeq (${SDL},1)
EXENAME?=srb2haiku EXENAME?=srb2haiku
else ifeq (${DEDICATED},1) else ifeq (${DEDICATED},1)
+96 -20
View File
@@ -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;
}
} }
} }
+13 -12
View File
@@ -64,10 +64,9 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <conio.h> #include <conio.h>
#endif #endif
#if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (__HAIKU__)) #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#include <time.h> #if defined (__linux__) || defined (__HAIKU__)
#if defined (__linux__) #include <sys/statvfs.h>
#include <sys/vfs.h>
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <sys/param.h> #include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
@@ -75,6 +74,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <mach/mach.h> #include <mach/mach.h>
#else #else
#include <sys/statvfs.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
/*For meminfo*/ /*For meminfo*/
@@ -87,7 +87,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#endif #endif
#endif #endif
#if defined (__linux__) || (defined (UNIXCOMMON) && !defined (__HAIKU__)) #if defined (__linux__) || defined (UNIXCOMMON)
#ifndef NOTERMIOS #ifndef NOTERMIOS
#include <termios.h> #include <termios.h>
#include <sys/ioctl.h> // ioctl #include <sys/ioctl.h> // ioctl
@@ -99,8 +99,10 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <poll.h> #include <poll.h>
#include <errno.h> #include <errno.h>
#include <sys/wait.h> #include <sys/wait.h>
#ifndef __HAIKU__ // haiku's crash dialog is just objectively better
#define NEWSIGNALHANDLER #define NEWSIGNALHANDLER
#endif #endif
#endif
#ifndef NOMUMBLE #ifndef NOMUMBLE
#ifdef __linux__ // need -lrt #ifdef __linux__ // need -lrt
@@ -131,7 +133,9 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <errno.h> #include <errno.h>
#endif #endif
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#include <time.h> #include <time.h>
#endif
/// Locations to directly check for srb2.srb in /// Locations to directly check for srb2.srb in
const char *wadDefaultPaths[] = { const char *wadDefaultPaths[] = {
@@ -1688,6 +1692,7 @@ void I_ShutdownSystem(void)
for (c = MAX_QUIT_FUNCS-1; c >= 0; c--) for (c = MAX_QUIT_FUNCS-1; c >= 0; c--)
if (quit_funcs[c]) if (quit_funcs[c])
(*quit_funcs[c])(); (*quit_funcs[c])();
#ifdef LOGMESSAGES #ifdef LOGMESSAGES
if (logstream) if (logstream)
{ {
@@ -1704,18 +1709,13 @@ void I_ShutdownSystem(void)
void I_GetDiskFreeSpace(INT64 *freespace) void I_GetDiskFreeSpace(INT64 *freespace)
{ {
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#if defined (SOLARIS) || defined (__HAIKU__) struct statvfs stfs;
*freespace = INT32_MAX; if (statvfs(srb2home, &stfs) == -1)
return;
#else // Both Linux and BSD have this, apparently.
struct statfs stfs;
if (statfs(".", &stfs) == -1)
{ {
*freespace = INT32_MAX; *freespace = INT32_MAX;
return; return;
} }
*freespace = stfs.f_bavail * stfs.f_bsize; *freespace = stfs.f_bavail * stfs.f_bsize;
#endif
#elif defined (_WIN32) #elif defined (_WIN32)
static p_GetDiskFreeSpaceExA pfnGetDiskFreeSpaceEx = NULL; static p_GetDiskFreeSpaceExA pfnGetDiskFreeSpaceEx = NULL;
static boolean testwin95 = false; static boolean testwin95 = false;
@@ -1726,6 +1726,7 @@ void I_GetDiskFreeSpace(INT64 *freespace)
pfnGetDiskFreeSpaceEx = (p_GetDiskFreeSpaceExA)(LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA"); pfnGetDiskFreeSpaceEx = (p_GetDiskFreeSpaceExA)(LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA");
testwin95 = true; testwin95 = true;
} }
if (pfnGetDiskFreeSpaceEx) if (pfnGetDiskFreeSpaceEx)
{ {
if (pfnGetDiskFreeSpaceEx(NULL, &lfreespace, &usedbytes, NULL)) if (pfnGetDiskFreeSpaceEx(NULL, &lfreespace, &usedbytes, NULL))
+27 -10
View File
@@ -1027,20 +1027,22 @@ void G_ResetAllDeviceRumbles(void)
} }
} }
void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) void G_PlayerDeviceRumble(INT32 playernum, UINT32 low_strength, UINT32 high_strength, UINT32 duration)
{ {
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0)) if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0))
return; return;
UINT16 lo, hi;
// doesent need to be super precise // doesent need to be super precise
// but ensure this is within range (0-65535) // but ensure this is within range (0-65535)
// placed here so it applies to lua aswell // placed here so it applies to lua aswell
low_strength = (UINT16)min(FixedMul(low_strength, cv_rumble_strength[playernum].value), UINT16_MAX); lo = (UINT16)min(FixedMul(low_strength, cv_rumble_strength[playernum].value), UINT16_MAX);
high_strength = (UINT16)min(FixedMul(high_strength, cv_rumble_strength[playernum].value), UINT16_MAX); hi = (UINT16)min(FixedMul(high_strength, cv_rumble_strength[playernum].value), UINT16_MAX);
I_GamepadRumble(playernum, low_strength, high_strength, duration); I_GamepadRumble(playernum, lo, hi, duration);
} }
// rumble strengths // rumble strengths
@@ -1077,9 +1079,9 @@ void G_DeviceRumbleTick(void)
// SDL rumble strength goes from a range or 0-65535 respectively // SDL rumble strength goes from a range or 0-65535 respectively
// the higher, the stronger it is // the higher, the stronger it is
UINT16 low = 0, high = 0; UINT32 low = 0, high = 0;
// for how long the action should rumble, in ms // for how long the action should rumble, in ms
UINT16 length = 57; // 57ms is a short pulse, matches super well with this updating once per tic UINT32 length = 57; // 57ms is a short pulse, matches super well with this updating once per tic
const player_t *player = P_GetLocalPlayerForNum(i); const player_t *player = P_GetLocalPlayerForNum(i);
@@ -1095,7 +1097,7 @@ void G_DeviceRumbleTick(void)
player->playerstate == PST_DEAD || player->playerstate == PST_DEAD ||
player->kartstuff[k_respawn] > 1) player->kartstuff[k_respawn] > 1)
{ {
G_PlayerDeviceRumble(i, low, high, 0); G_PlayerDeviceRumble(i, 0, 0, 0);
continue; continue;
} }
@@ -1150,27 +1152,42 @@ void G_DeviceRumbleTick(void)
P_IsObjectOnGround(player->mo)) P_IsObjectOnGround(player->mo))
{ {
low = high = RUMBLE_VERYWEAK; low = high = RUMBLE_VERYWEAK;
length = 43;
} }
if (cv_rumble_brakedrift[i].value && if (cv_rumble_brakedrift[i].value &&
player->kartstuff[k_brakedrift]) player->kartstuff[k_brakedrift])
{ {
high = CLAMP((high + RUMBLE_VERYWEAK), 0, UINT16_MAX); high += RUMBLE_VERYWEAK;
} }
// pulse when gettin new driftlevel // pulse when gettin new driftlevel
// let this come last
if (cv_rumble_driftcharge[i].value && if (cv_rumble_driftcharge[i].value &&
player->kartstuff[k_driftcharge] && player->kartstuff[k_driftcharge] &&
player->driftlevel) player->driftlevel)
{ {
high = CLAMP((high + RUMBLE_VERYWEAK), 0, UINT16_MAX); high += RUMBLE_VERYWEAK;
// make it rumble slightly longer the higher your driftlevel! // make it rumble slightly longer the higher your driftlevel!
if (player->driftlevel == 2) if (player->driftlevel == 2)
length = 114; length = 114;
else if (player->driftlevel == 3) else if (player->driftlevel == 3)
length = 174; length = 174;
else
length = 71;
}
// grow makes rumble more intense >:3
if (player->kartstuff[k_growshrinktimer] > 0)
{
high *= 2;
low *= 2;
}
// shrink does the opposite uwu
else if (player->kartstuff[k_growshrinktimer] < 0)
{
high /= 2;
low /= 2;
} }
// hack alert! i just dont want this thing constantly resetting the rumble lol // hack alert! i just dont want this thing constantly resetting the rumble lol
+1 -1
View File
@@ -153,7 +153,7 @@ void G_DeviceLEDTick(void);
void G_ResetDeviceLED(void); void G_ResetDeviceLED(void);
void G_ResetAllDeviceRumbles(void); void G_ResetAllDeviceRumbles(void);
void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration); void G_PlayerDeviceRumble(INT32 playernum, UINT32 low_strength, UINT32 high_strength, UINT32 duration);
void G_DeviceRumbleTick(void); void G_DeviceRumbleTick(void);
// peace to my little coder fingers! // peace to my little coder fingers!
+30 -10
View File
@@ -504,6 +504,13 @@ static UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's
return surfcolor.s.alpha; return surfcolor.s.alpha;
} }
static boolean HWR_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector)
{
if (HWR_ShouldUsePaletteRendering())
return P_ApplyLightOffset(baselightnum >> LIGHTSEGSHIFT, sector);
return P_ApplyLightOffsetFine(baselightnum, sector);
}
static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colormap) static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colormap)
{ {
INT16 finallight = lightnum; INT16 finallight = lightnum;
@@ -511,7 +518,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colo
if (cv_glfakecontrast.value == 0 || (colormap && HWR_ShouldUsePaletteRendering())) if (cv_glfakecontrast.value == 0 || (colormap && HWR_ShouldUsePaletteRendering()))
return (FUINT)finallight; return (FUINT)finallight;
if (seg != NULL && P_ApplyLightOffsetFine(lightnum, seg->frontsector)) if (seg != NULL && HWR_ApplyLightOffset(lightnum, seg->frontsector))
{ {
const INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8); const INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8);
@@ -522,18 +529,17 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colo
return (FUINT)finallight; return (FUINT)finallight;
} }
static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t *sector, const boolean fof) static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t *sector, const boolean reverseLight)
{ {
INT16 finallight = lightnum; INT16 finallight = lightnum;
if (cv_glfakecontrast.value == 0 || cv_glslopecontrast.value == 0) if (cv_glfakecontrast.value == 0 || cv_glslopecontrast.value == 0)
return (FUINT)finallight; return (FUINT)finallight;
if (slope != NULL && sector != NULL && P_ApplyLightOffsetFine(lightnum, sector)) if (slope != NULL && sector != NULL && HWR_ApplyLightOffset(lightnum, sector))
{ {
const INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8); const INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8);
finallight += ((reverseLight && maplighting.directional) ? -offset : offset);
finallight += (fof ? -offset : offset);
finallight = CLAMP(finallight, 0, 255); finallight = CLAMP(finallight, 0, 255);
} }
@@ -697,7 +703,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
SETUP3DVERT(v3d, pv->x, pv->y); SETUP3DVERT(v3d, pv->x, pv->y);
if (slope) if (slope)
lightlevel = HWR_CalcSlopeLight(lightlevel, slope, gl_frontsector, (FOFsector != NULL)); lightlevel = HWR_CalcSlopeLight(lightlevel, slope, gl_frontsector, (FOFsector && !isceiling) || (!FOFsector && isceiling));
HWR_Lighting(&Surf, lightlevel, planecolormap, P_SectorUsesDirectionalLighting(gl_frontsector)); HWR_Lighting(&Surf, lightlevel, planecolormap, P_SectorUsesDirectionalLighting(gl_frontsector));
@@ -1274,7 +1280,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
// To avoid division by zero, which would result in a NaN, we check if the vertical difference // To avoid division by zero, which would result in a NaN, we check if the vertical difference
// between the two vertices is not zero. // between the two vertices is not zero.
if (std::fpclassify(diff) == FP_ZERO) if (std::fpclassify(diff) == FP_ZERO)
pegmul = 0.0; pegmul = 0.0f;
else else
pegmul = (pegb - pegt) / diff; pegmul = (pegb - pegt) / diff;
@@ -1286,7 +1292,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
endpegb = wallVerts[1].t; endpegb = wallVerts[1].t;
if (std::fpclassify(diff) == FP_ZERO) if (std::fpclassify(diff) == FP_ZERO)
endpegmul = 0.0; endpegmul = 0.0f;
else else
endpegmul = (endpegb - endpegt) / diff; endpegmul = (endpegb - endpegt) / diff;
@@ -3850,7 +3856,16 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
realbot = bot = baseWallVerts[0].y; realbot = bot = baseWallVerts[0].y;
towtop = baseWallVerts[3].t; towtop = baseWallVerts[3].t;
towbot = baseWallVerts[0].t; towbot = baseWallVerts[0].t;
towmult = (towbot - towtop) / (top - bot);
float diff = (top - bot);
// If both heights of a side lay on the same position, then this sprite is a triangle.
// To avoid division by zero, which would result in a NaN, we check if the vertical difference
// between the two vertices is not zero.
if (std::fpclassify(diff) == FP_ZERO)
towmult = 0.0f;
else
towmult = (towbot - towtop) / diff;
endrealtop = endtop = baseWallVerts[2].y; endrealtop = endtop = baseWallVerts[2].y;
endrealbot = baseWallVerts[1].y; endrealbot = baseWallVerts[1].y;
@@ -4021,7 +4036,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
if ((endtop <= endrealbot) && (top <= realbot)) if ((endtop <= endrealbot) && (top <= realbot))
return; return;
// If we're ever down here, somehow the above loop hasn't draw all the light levels of sprite // If we're ever down here, somehow the above loop hasn't drawn all the light levels of sprite
wallVerts[3].t = towtop + ((realtop - top) * towmult); wallVerts[3].t = towtop + ((realtop - top) * towmult);
wallVerts[2].t = towtop + ((endrealtop - endtop) * towmult); wallVerts[2].t = towtop + ((endrealtop - endtop) * towmult);
wallVerts[0].t = towtop + ((realtop - bot) * towmult); wallVerts[0].t = towtop + ((realtop - bot) * towmult);
@@ -5377,6 +5392,11 @@ static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c,
else else
vbo->v = 1.0f + ((float)(sky->rows - r) / (float)sky->rows) + 0.5f; vbo->v = 1.0f + ((float)(sky->rows - r) / (float)sky->rows) + 0.5f;
} }
else
{
vbo->u = 0.5f / sky->width;
vbo->v = 0.5f / sky->height;
}
if (r != 4) if (r != 4)
{ {
+5 -1
View File
@@ -196,7 +196,11 @@
// hand tuned adjustments for light level calculation // hand tuned adjustments for light level calculation
#define GLSL_FLOOR_FUDGES \ #define GLSL_FLOOR_FUDGES \
"#define STARTMAP_FUDGE 1.06\n" \ "#define STARTMAP_FUDGE 1.06\n" \
"#define SCALE_FUDGE 1.15\n" "#ifdef SRB2_PALETTE_RENDERING\n" \
"#define SCALE_FUDGE 1.3\n" \
"#else\n" \
"#define SCALE_FUDGE 1.15\n" \
"#endif\n"
#define GLSL_WALL_FUDGES \ #define GLSL_WALL_FUDGES \
"#define STARTMAP_FUDGE 1.05\n" \ "#define STARTMAP_FUDGE 1.05\n" \
+2 -2
View File
@@ -3080,8 +3080,8 @@ static int lib_gPlayerDeviceRumble(lua_State *L)
{ {
INT32 pnum = -1; INT32 pnum = -1;
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player
UINT16 low_strength = (UINT16)luaL_checkinteger(L, 2); // low frequency rumble motor strenght UINT32 low_strength = (UINT32)luaL_checkinteger(L, 2); // low frequency rumble motor strength
UINT16 high_strength = (UINT16)luaL_checkinteger(L, 3); // high frequency rumble motor strenght UINT32 high_strength = (UINT32)luaL_checkinteger(L, 3); // high frequency rumble motor strength
UINT32 duration = (UINT32)luaL_optinteger(L, 4, 84); // duration of rumble in ms UINT32 duration = (UINT32)luaL_optinteger(L, 4, 84); // duration of rumble in ms
if (!player) if (!player)
+146 -149
View File
@@ -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);
@@ -344,19 +348,16 @@ static int mobj_get(lua_State *L)
lua_pushangle(L, mo->slopepitch); lua_pushangle(L, mo->slopepitch);
break; break;
case mobj_rollsum: case mobj_rollsum:
{
angle_t pitchnroll = P_MobjPitchAndRoll(mo);
angle_t rollsum = mo->rollangle + pitchnroll;
if (mo->player)
{ {
rollsum += R_PlayerSliptideAngle(mo->player); angle_t pitchnroll = P_MobjPitchAndRoll(mo);
angle_t rollsum = mo->rollangle + pitchnroll;
if (mo->player)
{
rollsum += R_PlayerSliptideAngle(mo->player);
}
lua_pushangle(L, rollsum);
} }
lua_pushangle(L, rollsum);
break; break;
}
case mobj_spritexscale: case mobj_spritexscale:
lua_pushfixed(L, mo->spritexscale); lua_pushfixed(L, mo->spritexscale);
break; break;
@@ -431,30 +432,24 @@ static int mobj_set(lua_State *L)
case mobj_y: case mobj_y:
return NOSETPOS; return NOSETPOS;
case mobj_z: case mobj_z:
{ {
// z doesn't cross sector bounds so it's okay. // z doesn't cross sector bounds so it's okay.
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mo->z = luaL_checkfixed(L, 3); mo->z = luaL_checkfixed(L, 3);
P_CheckPosition(mo, mo->x, mo->y); P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz; mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz; mo->ceilingz = tmceilingz;
P_SetTarget(&tmthing, ptmthing); P_SetTarget(&tmthing, ptmthing);
}
break; break;
}
case mobj_snext: case mobj_snext:
return NOSETPOS; return NOSETPOS;
case mobj_sprev: case mobj_sprev:
return UNIMPLEMENTED; return UNIMPLEMENTED;
case mobj_angle: case mobj_angle:
mo->angle = luaL_checkangle(L, 3); mo->angle = luaL_checkangle(L, 3);
if (mo->player == &players[consoleplayer]) if (mo->player)
localangle[0] = mo->angle; P_ForceLocalAngle(mo->player, mo->angle);
else if (mo->player == &players[displayplayers[1]])
localangle[1] = mo->angle;
else if (mo->player == &players[displayplayers[2]])
localangle[2] = mo->angle;
else if (mo->player == &players[displayplayers[3]])
localangle[3] = mo->angle;
break; break;
case mobj_sprite: case mobj_sprite:
mo->sprite = luaL_checkinteger(L, 3); mo->sprite = luaL_checkinteger(L, 3);
@@ -474,29 +469,29 @@ static int mobj_set(lua_State *L)
case mobj_ceilingz: case mobj_ceilingz:
return NOSETPOS; return NOSETPOS;
case mobj_radius: case mobj_radius:
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mo->radius = luaL_checkfixed(L, 3); mo->radius = luaL_checkfixed(L, 3);
if (mo->radius < 0) if (mo->radius < 0)
mo->radius = 0; mo->radius = 0;
P_CheckPosition(mo, mo->x, mo->y); P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz; mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz; mo->ceilingz = tmceilingz;
P_SetTarget(&tmthing, ptmthing); P_SetTarget(&tmthing, ptmthing);
}
break; break;
}
case mobj_height: case mobj_height:
{ {
mobj_t *ptmthing = tmthing; mobj_t *ptmthing = tmthing;
mo->height = luaL_checkfixed(L, 3); mo->height = luaL_checkfixed(L, 3);
if (mo->height < 0) if (mo->height < 0)
mo->height = 0; mo->height = 0;
P_CheckPosition(mo, mo->x, mo->y); P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz; mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz; mo->ceilingz = tmceilingz;
P_SetTarget(&tmthing, ptmthing); P_SetTarget(&tmthing, ptmthing);
}
break; break;
}
case mobj_momx: case mobj_momx:
mo->momx = luaL_checkfixed(L, 3); mo->momx = luaL_checkfixed(L, 3);
break; break;
@@ -520,25 +515,25 @@ static int mobj_set(lua_State *L)
P_SetMobjState(mo, luaL_checkinteger(L, 3)); P_SetMobjState(mo, luaL_checkinteger(L, 3));
break; break;
case mobj_flags: // special handling for MF_NOBLOCKMAP and MF_NOSECTOR case mobj_flags: // special handling for MF_NOBLOCKMAP and MF_NOSECTOR
{
UINT32 flags = luaL_checkinteger(L, 3);
if ((flags & (MF_NOBLOCKMAP|MF_NOSECTOR)) != (mo->flags & (MF_NOBLOCKMAP|MF_NOSECTOR)))
{ {
P_UnsetThingPosition(mo); UINT32 flags = luaL_checkinteger(L, 3);
mo->flags = flags; if ((flags & (MF_NOBLOCKMAP|MF_NOSECTOR)) != (mo->flags & (MF_NOBLOCKMAP|MF_NOSECTOR)))
if (flags & MF_NOSECTOR && sector_list)
{ {
P_DelSeclist(sector_list); P_UnsetThingPosition(mo);
sector_list = NULL; mo->flags = flags;
if (flags & MF_NOSECTOR && sector_list)
{
P_DelSeclist(sector_list);
sector_list = NULL;
}
mo->snext = NULL, mo->sprev = NULL;
mo->bnext = NULL, mo->bprev = NULL;
P_SetThingPosition(mo);
} }
mo->snext = NULL, mo->sprev = NULL; else
mo->bnext = NULL, mo->bprev = NULL; mo->flags = flags;
P_SetThingPosition(mo);
} }
else
mo->flags = flags;
break; break;
}
case mobj_flags2: case mobj_flags2:
mo->flags2 = (UINT32)luaL_checkinteger(L, 3); mo->flags2 = (UINT32)luaL_checkinteger(L, 3);
break; break;
@@ -546,27 +541,29 @@ static int mobj_set(lua_State *L)
mo->eflags = (UINT32)luaL_checkinteger(L, 3); mo->eflags = (UINT32)luaL_checkinteger(L, 3);
break; break;
case mobj_skin: // set skin by name case mobj_skin: // set skin by name
{ {
INT32 i; INT32 i;
char skin[SKINNAMESIZE+1]; // all skin names are limited to this length char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
strlcpy(skin, luaL_checkstring(L, 3), sizeof skin); strlcpy(skin, luaL_checkstring(L, 3), sizeof skin);
strlwr(skin); // all skin names are lowercase strlwr(skin); // all skin names are lowercase
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
if (fastcmp(skins[i].name, skin))
{ {
mo->skin = &skins[i]; if (fastcmp(skins[i].name, skin))
return 0; {
mo->skin = &skins[i];
return 0;
}
} }
return luaL_error(L, "mobj.skin '%s' not found!", skin); return luaL_error(L, "mobj.skin '%s' not found!", skin);
} }
case mobj_color: case mobj_color:
{ {
UINT8 newcolor = (UINT8)luaL_checkinteger(L,3); UINT8 newcolor = (UINT8)luaL_checkinteger(L,3);
if (newcolor >= MAXTRANSLATIONS) if (newcolor >= MAXTRANSLATIONS)
return luaL_error(L, "mobj.color %d out of range (0 - %d).", newcolor, MAXTRANSLATIONS-1); return luaL_error(L, "mobj.color %d out of range (0 - %d).", newcolor, MAXTRANSLATIONS-1);
mo->color = newcolor; mo->color = newcolor;
}
break; break;
}
case mobj_bnext: case mobj_bnext:
return NOSETPOS; return NOSETPOS;
case mobj_bprev: case mobj_bprev:
@@ -590,15 +587,15 @@ static int mobj_set(lua_State *L)
} }
break; break;
case mobj_type: // yeah sure, we'll let you change the mobj's type. case mobj_type: // yeah sure, we'll let you change the mobj's type.
{ {
mobjtype_t newtype = luaL_checkinteger(L, 3); mobjtype_t newtype = luaL_checkinteger(L, 3);
if (newtype >= NUMMOBJTYPES) if (newtype >= NUMMOBJTYPES)
return luaL_error(L, "mobj.type %d out of range (0 - %d).", newtype, NUMMOBJTYPES-1); return luaL_error(L, "mobj.type %d out of range (0 - %d).", newtype, NUMMOBJTYPES-1);
mo->type = newtype; mo->type = newtype;
mo->info = &mobjinfo[newtype]; mo->info = &mobjinfo[newtype];
P_SetScale(mo, mo->scale); P_SetScale(mo, mo->scale);
}
break; break;
}
case mobj_info: case mobj_info:
return NOSET; return NOSET;
case mobj_health: case mobj_health:
@@ -666,23 +663,23 @@ static int mobj_set(lua_State *L)
case mobj_mobjnum: case mobj_mobjnum:
return UNIMPLEMENTED; return UNIMPLEMENTED;
case mobj_scale: case mobj_scale:
{ {
fixed_t scale = luaL_checkfixed(L, 3); fixed_t scale = luaL_checkfixed(L, 3);
if (scale < FRACUNIT/100) if (scale < FRACUNIT/100)
scale = FRACUNIT/100; scale = FRACUNIT/100;
mo->destscale = scale; mo->destscale = scale;
P_SetScale(mo, scale); P_SetScale(mo, scale);
mo->old_scale = scale; mo->old_scale = scale;
}
break; break;
}
case mobj_destscale: case mobj_destscale:
{ {
fixed_t scale = luaL_checkfixed(L, 3); fixed_t scale = luaL_checkfixed(L, 3);
if (scale < FRACUNIT/100) if (scale < FRACUNIT/100)
scale = FRACUNIT/100; scale = FRACUNIT/100;
mo->destscale = scale; mo->destscale = scale;
}
break; break;
}
case mobj_scalespeed: case mobj_scalespeed:
mo->scalespeed = luaL_checkfixed(L, 3); mo->scalespeed = luaL_checkfixed(L, 3);
break; break;
@@ -747,58 +744,58 @@ static int mobj_set(lua_State *L)
mo->lightlevel = (INT16)luaL_checkinteger(L, 3); mo->lightlevel = (INT16)luaL_checkinteger(L, 3);
break; break;
case mobj_localskin: case mobj_localskin:
{
if (mo->player)
{ {
SetLocalPlayerSkin(mo->player - players, luaL_optstring(L, 3, "none"), NULL); if (mo->player)
}
else
{
INT32 i;
char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
strlcpy(skin, luaL_optstring(L, 3, "none"), sizeof skin);
strlwr(skin); // all skin names are lowercase
if (!fasticmp(skin, "none"))
{ {
// Try localskins SetLocalPlayerSkin(mo->player - players, luaL_optstring(L, 3, "none"), NULL);
for (i = 0; i < numlocalskins; i++)
{
if (fasticmp(localskins[i].name, skin))
{
mo->localskin = &localskins[i];
mo->skinlocal = true;
return 0;
}
}
// Try other skins
for (i = 0; i < numskins; i++)
{
if (fasticmp(skins[i].name, skin))
{
mo->localskin = &skins[i];
mo->skinlocal = false;
return 0;
}
}
} }
else else
{ {
mo->localskin = NULL; INT32 i;
mo->skinlocal = false; char skin[SKINNAMESIZE+1]; // all skin names are limited to this length
strlcpy(skin, luaL_optstring(L, 3, "none"), sizeof skin);
strlwr(skin); // all skin names are lowercase
if (!fasticmp(skin, "none"))
{
// Try localskins
for (i = 0; i < numlocalskins; i++)
{
if (fasticmp(localskins[i].name, skin))
{
mo->localskin = &localskins[i];
mo->skinlocal = true;
return 0;
}
}
// Try other skins
for (i = 0; i < numskins; i++)
{
if (fasticmp(skins[i].name, skin))
{
mo->localskin = &skins[i];
mo->skinlocal = false;
return 0;
}
}
}
else
{
mo->localskin = NULL;
mo->skinlocal = false;
}
} }
} }
break; break;
}
case mobj_blendmode: case mobj_blendmode:
{ {
INT32 blendmode = (INT32)luaL_checkinteger(L, 3); INT32 blendmode = (INT32)luaL_checkinteger(L, 3);
if (blendmode < 0 || blendmode > AST_OVERLAY) if (blendmode < 0 || blendmode > AST_OVERLAY)
return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY); return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY);
mo->blendmode = blendmode; mo->blendmode = blendmode;
}
break; break;
}
case mobj_mirrored: case mobj_mirrored:
mo->mirrored = luaL_checkboolean(L, 3); mo->mirrored = luaL_checkboolean(L, 3);
break; break;
@@ -950,13 +947,13 @@ static int mapthing_set(lua_State *L)
mt->z = (INT16)luaL_checkinteger(L, 3); mt->z = (INT16)luaL_checkinteger(L, 3);
break; break;
case mapthing_extrainfo: case mapthing_extrainfo:
{ {
INT32 extrainfo = luaL_checkinteger(L, 3); INT32 extrainfo = luaL_checkinteger(L, 3);
if (extrainfo & ~15) if (extrainfo & ~15)
return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15); return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15);
mt->extrainfo = (UINT8)extrainfo; mt->extrainfo = (UINT8)extrainfo;
}
break; break;
}
case mapthing_mobj: case mapthing_mobj:
mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
break; break;
+45 -45
View File
@@ -298,12 +298,12 @@ static int player_get(lua_State *L)
lua_pushstring(L, player_names[plr-players]); lua_pushstring(L, player_names[plr-players]);
break; break;
case player_mo: case player_mo:
{ {
if (plr->spectator) if (plr->spectator)
lua_pushnil(L); lua_pushnil(L);
else else
LUA_PushUserdata(L, plr->mo, META_MOBJ); LUA_PushUserdata(L, plr->mo, META_MOBJ);
} }
break; break;
case player_cmd: case player_cmd:
LUA_PushUserdata(L, &plr->cmd, META_TICCMD); LUA_PushUserdata(L, &plr->cmd, META_TICCMD);
@@ -668,11 +668,11 @@ static int player_set(lua_State *L)
return 0; // In vanilla those are not handled and are added into player fields table, but they aren't accessible anyway so we can just ignore them return 0; // In vanilla those are not handled and are added into player fields table, but they aren't accessible anyway so we can just ignore them
break; break;
case player_mo: case player_mo:
{ {
mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
plr->mo->player = NULL; // remove player pointer from old mobj plr->mo->player = NULL; // remove player pointer from old mobj
(newmo->player = plr)->mo = newmo; // set player pointer for new mobj, and set new mobj as the player's mobj (newmo->player = plr)->mo = newmo; // set player pointer for new mobj, and set new mobj as the player's mobj
} }
break; break;
case player_cmd: case player_cmd:
return NOSET; return NOSET;
@@ -692,17 +692,17 @@ static int player_set(lua_State *L)
case player_bob: case player_bob:
plr->bob = luaL_checkfixed(L, 3);*/ plr->bob = luaL_checkfixed(L, 3);*/
break; break;
case player_aiming: { case player_aiming:
plr->aiming = luaL_checkangle(L, 3); {
if (plr == &players[consoleplayer]) plr->aiming = luaL_checkangle(L, 3);
localaiming[0] = plr->aiming; for (UINT8 i = 0; i <= splitscreen; i++)
else if (plr == &players[displayplayers[1]]) {
localaiming[1] = plr->aiming; if (plr == &players[displayplayers[i]])
else if (plr == &players[displayplayers[2]]) {
localaiming[2] = plr->aiming; localaiming[i] = plr->aiming;
else if (plr == &players[displayplayers[3]]) }
localaiming[3] = plr->aiming; }
} }
break; break;
case player_health: case player_health:
plr->health = (INT32)luaL_checkinteger(L, 3); plr->health = (INT32)luaL_checkinteger(L, 3);
@@ -732,12 +732,12 @@ static int player_set(lua_State *L)
plr->flashpal = (UINT16)luaL_checkinteger(L, 3); plr->flashpal = (UINT16)luaL_checkinteger(L, 3);
break; break;
case player_skincolor: case player_skincolor:
{ {
UINT8 newcolor = (UINT8)luaL_checkinteger(L,3); UINT8 newcolor = (UINT8)luaL_checkinteger(L,3);
if (newcolor >= MAXSKINCOLORS) if (newcolor >= MAXSKINCOLORS)
return luaL_error(L, "player.skincolor %d out of range (0 - %d).", newcolor, MAXSKINCOLORS-1); return luaL_error(L, "player.skincolor %d out of range (0 - %d).", newcolor, MAXSKINCOLORS-1);
plr->skincolor = newcolor; plr->skincolor = newcolor;
} }
break; break;
case player_score: case player_score:
plr->score = (UINT32)luaL_checkinteger(L, 3); plr->score = (UINT32)luaL_checkinteger(L, 3);
@@ -907,12 +907,12 @@ static int player_set(lua_State *L)
plr->bonustime = luaL_checkboolean(L, 3); plr->bonustime = luaL_checkboolean(L, 3);
break; break;
case player_capsule: case player_capsule:
{ {
mobj_t *mo = NULL; mobj_t *mo = NULL;
if (!lua_isnil(L, 3)) if (!lua_isnil(L, 3))
mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
P_SetTarget(&plr->capsule, mo); P_SetTarget(&plr->capsule, mo);
} }
break; break;
case player_mare: case player_mare:
plr->mare = (UINT8)luaL_checkinteger(L, 3); plr->mare = (UINT8)luaL_checkinteger(L, 3);
@@ -963,19 +963,19 @@ static int player_set(lua_State *L)
plr->onconveyor = (INT32)luaL_checkinteger(L, 3); plr->onconveyor = (INT32)luaL_checkinteger(L, 3);
break; break;
case player_awayviewmobj: case player_awayviewmobj:
{ {
mobj_t *mo = NULL; mobj_t *mo = NULL;
if (!lua_isnil(L, 3)) if (!lua_isnil(L, 3))
mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
P_SetTarget(&plr->awayviewmobj, mo); P_SetTarget(&plr->awayviewmobj, mo);
} }
break; break;
case player_awayviewtics: case player_awayviewtics:
{ {
plr->awayviewtics = (INT32)luaL_checkinteger(L, 3); plr->awayviewtics = (INT32)luaL_checkinteger(L, 3);
if (plr->awayviewtics && !plr->awayviewmobj) // awayviewtics must ALWAYS have an awayviewmobj set!! if (plr->awayviewtics && !plr->awayviewmobj) // awayviewtics must ALWAYS have an awayviewmobj set!!
P_SetTarget(&plr->awayviewmobj, plr->mo); // but since the script might set awayviewmobj immediately AFTER setting awayviewtics, use player mobj as filler for now. P_SetTarget(&plr->awayviewmobj, plr->mo); // but since the script might set awayviewmobj immediately AFTER setting awayviewtics, use player mobj as filler for now.
} }
break; break;
case player_awayviewaiming: case player_awayviewaiming:
plr->awayviewaiming = luaL_checkangle(L, 3); plr->awayviewaiming = luaL_checkangle(L, 3);
+10 -10
View File
@@ -66,22 +66,22 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope)
nY = FixedDiv(nY, nLen); nY = FixedDiv(nY, nLen);
/* /*
* if (slope is ceiling) if (slope is ceiling)
* { {
* // There is no good way to calculate this condition here. // There is no good way to calculate this condition here.
* // We reverse it in R_FindPlane now. // We reverse it in R_FindPlane now.
* nX = -nX; nX = -nX;
* nY = -nY; nY = -nY;
* } }
*/ */
light = FixedMul(nX, FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT)) light = FixedMul(nX, FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT))
+ FixedMul(nY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); + FixedMul(nY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT));
light = (light + FRACUNIT) / 2; light = (light + FRACUNIT) / 2;
} }
else else
{ {
light = FixedDiv(R_PointToAngle2(0, 0, abs(slope->d.x), abs(slope->d.y)), ANGLE_90); light = FixedDiv(R_PointToAngle2(0, 0, abs(slope->normal.y), abs(slope->normal.x)), ANGLE_90);
} }
const int delta = abs(slope->zdelta)*3/2; // *3/2, to make 60 degree slopes match walls. const int delta = abs(slope->zdelta)*3/2; // *3/2, to make 60 degree slopes match walls.
+14 -14
View File
@@ -350,8 +350,8 @@ void R_ClearPlanes(void)
angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT; angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT;
// scale will be unit scale at SCREENWIDTH/2 distance // scale will be unit scale at SCREENWIDTH/2 distance
basexscale = FixedDiv (FINECOSINE(angle), centerxfrac); basexscale = FixedDiv(FINECOSINE(angle), centerxfrac);
baseyscale = -FixedDiv (FINESINE(angle), centerxfrac); baseyscale = -FixedDiv(FINESINE(angle), centerxfrac);
} }
static visplane_t *new_visplane(unsigned hash) static visplane_t *new_visplane(unsigned hash)
@@ -440,20 +440,20 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
} }
} }
if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector))
{
if (reverseLight && maplighting.directional == true)
{
lightlevel -= slope->lightOffset * 8;
}
else
{
lightlevel += slope->lightOffset * 8;
}
}
if (!pfloor) if (!pfloor)
{ {
if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector))
{
if (reverseLight)
{
lightlevel -= slope->lightOffset * 8;
}
else
{
lightlevel += slope->lightOffset * 8;
}
}
hash = visplane_hash(picnum, lightlevel, height >> FRACBITS); hash = visplane_hash(picnum, lightlevel, height >> FRACBITS);
for (check = visplanes[hash]; check; check = check->next) for (check = visplanes[hash]; check; check = check->next)
+11 -19
View File
@@ -80,12 +80,9 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include "i_ttf.h" #include "i_ttf.h"
#endif #endif
#include "SDL_cpuinfo.h" #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#define HAVE_SDLCPUINFO #if defined (__linux__) || defined (__HAIKU__)
#include <sys/statvfs.h>
#if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (__HAIKU__))
#if defined (__linux__)
#include <sys/vfs.h>
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <sys/param.h> #include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
@@ -93,6 +90,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <mach/mach.h> #include <mach/mach.h>
#else #else
#include <sys/statvfs.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
/*For meminfo*/ /*For meminfo*/
@@ -105,7 +103,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#endif #endif
#endif #endif
#if defined (__linux__) || (defined (UNIXCOMMON) && !defined (__HAIKU__)) #if defined (__linux__) || defined (UNIXCOMMON)
#ifndef NOTERMIOS #ifndef NOTERMIOS
#include <termios.h> #include <termios.h>
#include <sys/ioctl.h> // ioctl #include <sys/ioctl.h> // ioctl
@@ -120,8 +118,10 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#if defined (__unix__) || (defined (UNIXCOMMON) && !defined (__APPLE__)) #if defined (__unix__) || (defined (UNIXCOMMON) && !defined (__APPLE__))
#include <errno.h> #include <errno.h>
#include <sys/wait.h> #include <sys/wait.h>
#ifndef __HAIKU__ // haiku's crash dialog is just objectively better
#define NEWSIGNALHANDLER #define NEWSIGNALHANDLER
#endif #endif
#endif
#ifndef NOMUMBLE #ifndef NOMUMBLE
#ifdef __linux__ // need -lrt #ifdef __linux__ // need -lrt
@@ -195,7 +195,6 @@ static char returnWadPath[256];
#include "../i_sound.h" #include "../i_sound.h"
#include "../i_system.h" #include "../i_system.h"
#include "../i_threads.h" #include "../i_threads.h"
#include "../screen.h" //vid.WndParent
#include "../d_net.h" #include "../d_net.h"
#include "../g_game.h" #include "../g_game.h"
#include "../g_demo.h" #include "../g_demo.h"
@@ -208,9 +207,6 @@ static char returnWadPath[256];
#include "../m_argv.h" #include "../m_argv.h"
#include "../r_main.h" // Frame interpolation/uncapped
#include "../r_fps.h"
#include "../s_sound.h" #include "../s_sound.h"
#include "../d_main.h" #include "../d_main.h"
@@ -274,7 +270,7 @@ static void tty_Clear(void)
write(STDOUT_FILENO, "\r", 1); write(STDOUT_FILENO, "\r", 1);
if (tty_con.cursor>0) if (tty_con.cursor>0)
{ {
for (i=0; i<tty_con.cursor; i++) for (i = 0; i < tty_con.cursor; i++)
{ {
write(STDOUT_FILENO, " ", 1); write(STDOUT_FILENO, " ", 1);
} }
@@ -2291,18 +2287,13 @@ void I_ShutdownSystem(void)
void I_GetDiskFreeSpace(INT64 *freespace) void I_GetDiskFreeSpace(INT64 *freespace)
{ {
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#if defined (SOLARIS) || defined (__HAIKU__) struct statvfs stfs;
*freespace = INT32_MAX; if (statvfs(srb2home, &stfs) == -1)
return;
#else // Both Linux and BSD have this, apparently.
struct statfs stfs;
if (statfs(".", &stfs) == -1)
{ {
*freespace = INT32_MAX; *freespace = INT32_MAX;
return; return;
} }
*freespace = stfs.f_bavail * stfs.f_bsize; *freespace = stfs.f_bavail * stfs.f_bsize;
#endif
#elif defined (_WIN32) #elif defined (_WIN32)
static p_GetDiskFreeSpaceExA pfnGetDiskFreeSpaceEx = NULL; static p_GetDiskFreeSpaceExA pfnGetDiskFreeSpaceEx = NULL;
static boolean testwin95 = false; static boolean testwin95 = false;
@@ -2313,6 +2304,7 @@ void I_GetDiskFreeSpace(INT64 *freespace)
pfnGetDiskFreeSpaceEx = (p_GetDiskFreeSpaceExA)(LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA"); pfnGetDiskFreeSpaceEx = (p_GetDiskFreeSpaceExA)(LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA");
testwin95 = true; testwin95 = true;
} }
if (pfnGetDiskFreeSpaceEx) if (pfnGetDiskFreeSpaceEx)
{ {
if (pfnGetDiskFreeSpaceEx(NULL, &lfreespace, &usedbytes, NULL)) if (pfnGetDiskFreeSpaceEx(NULL, &lfreespace, &usedbytes, NULL))
+2 -2
View File
@@ -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);
} }
+19 -16
View File
@@ -1839,8 +1839,11 @@ void V_DrawHorizontallyScaledFullScreenPatch(patch_t *patch)
void V_DrawVhsEffect(boolean rewind) void V_DrawVhsEffect(boolean rewind)
{ {
fixed_t uby, dby; fixed_t uby, dby;
// upbary is the bar going from top to bottom for some reason static fixed_t upbary_normal = 100*FRACUNIT, downbary_normal = 150*FRACUNIT;
static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT; static fixed_t upbary_rewind = 100*FRACUNIT, downbary_rewind = 150*FRACUNIT;
fixed_t *upbary = rewind ? &upbary_rewind : &upbary_normal;
fixed_t *downbary = rewind ? &downbary_rewind : &downbary_normal;
UINT8 barsize, updistort, downdistort; UINT8 barsize, updistort, downdistort;
@@ -1864,20 +1867,20 @@ void V_DrawVhsEffect(boolean rewind)
if (rewind) if (rewind)
V_DrawVhsEffect(false); // experimentation V_DrawVhsEffect(false); // experimentation
upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f)); *upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f));
downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1)); *downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1));
if (upbary < -barsize*FRACUNIT) if (*upbary < -barsize*FRACUNIT)
upbary = vid.height << FRACBITS; *upbary = vid.height << FRACBITS;
if (upbary > vid.height << FRACBITS) if (*upbary > vid.height << FRACBITS)
upbary = -barsize*FRACUNIT; *upbary = -barsize*FRACUNIT;
if (downbary > vid.height << FRACBITS) if (*downbary > vid.height << FRACBITS)
downbary = -barsize*FRACUNIT; *downbary = -barsize*FRACUNIT;
if (downbary < -barsize*FRACUNIT) if (*downbary < -barsize*FRACUNIT)
downbary = vid.height << FRACBITS; *downbary = vid.height << FRACBITS;
uby = upbary >> FRACBITS; uby = *upbary >> FRACBITS;
dby = downbary >> FRACBITS; dby = *downbary >> FRACBITS;
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode == render_opengl) if (rendermode == render_opengl)
@@ -1897,7 +1900,7 @@ void V_DrawVhsEffect(boolean rewind)
pos = 0; pos = 0;
for (y = 0; y < vid.height; y+=2) for (y = 0; y < vid.height; y += 2)
{ {
thismapstart = normalmapstart; thismapstart = normalmapstart;
offs = 0; offs = 0;
@@ -1914,7 +1917,7 @@ void V_DrawVhsEffect(boolean rewind)
offs -= downdistort * 2.0f * min(y-dby, dby+barsize-y) / barsize; offs -= downdistort * 2.0f * min(y-dby, dby+barsize-y) / barsize;
} }
offs += M_RandomKey(vid.dup<<1); offs += M_RandomKey(vid.udup<<1);
// lazy way to avoid crashes // lazy way to avoid crashes
if ((y == 0 && offs < 0) || (y >= vid.height-2 && offs > 0)) if ((y == 0 && offs < 0) || (y >= vid.height-2 && offs > 0))