Compare commits

..
Author SHA1 Message Date
indev eb04271c83 Actually try to do this with hooks 2025-10-23 22:52:03 +03:00
indev 54e7ad571e Check if mobj is spawned from local addon in most of lua_baselib functions related to mobjs 2025-10-23 22:00:46 +03:00
Alug 27433f6fb5 call R_SetupFreelook in R_ExecuteSetViewSize
to instantly update our now stale yslope pointer!
fixes random crashes when switching numbers of splitviews in replays
2025-10-21 19:26:31 +02:00
Alug f8e5049d76 fix R_MakeSpans accessing "spanstart" out of bounds when in splitscreen
it gets allocated for viewheight not vid.height!
2025-10-21 19:26:27 +02:00
Alug 2009cdeaeb init few more things 2025-10-21 18:36:05 +02:00
Alug 0f43f19b71 remove unused maskdraw_t struct 2025-10-21 18:01:03 +02:00
Alug 1ac7852bd2 initialize a bunch of stuff that gets passed to realloc 2025-10-21 17:52:21 +02:00
indev f5e7b65ae0 Fix replay names not displaying if you have more than INT16_MAX replays 2025-10-21 17:11:45 +03:00
Alug 4c5d34e82c Revert "Fix ghost hitlist causing zone errors (closes #118)"
This reverts commit ab13b28106.
2025-10-21 16:09:02 +02:00
Alug 0dad927c05 fix 4th player background not drawin in gl in 3 player splitscreen 2025-10-21 15:42:33 +02:00
Alug f231417465 fix splitscreen view in gl 2025-10-21 15:27:05 +02:00
Alug 51b8dc9101 m_menu: add textinput special case for playername string
itself it already checks to not write out of bounds, this is mostly just to fix visual issues
kind hacky, but works for now
2025-10-21 14:45:10 +02:00
Alug 71e9c4f5af use "viewssnum" for shadowdir stuff 2025-10-21 14:34:33 +02:00
Alug 1acae3e4af use malloc for spawnstate mapdata copies
they might be somewhat large and get completely overwritten eitherway so save us the 0 init
2025-10-21 14:34:30 +02:00
Alug 4c04d09d18 rename 2025-10-21 14:34:28 +02:00
indev b99cd88947 Fix possible buffer overflow in M_TextInputSetString when string length is greatter than buffer length 2025-10-21 01:46:39 +03:00
Alug 4a786449c4 fix NIGHTS hoop hoopcenter
fixes visual issues when going through them
2025-10-20 19:48:28 +02:00
Alug aef6dcdbc9 handle ceepeepee 2025-10-20 19:25:41 +02:00
Alug 0e9ec096c2 slightly clean up makefile
- pass "-g" on mingw builds generally after everything (needs testing)
-use "libs" instead of "LDFLAGS" (identical purpose)
- pass "mno-ms-bitfields" on gcc, shouldnt be really needed but just in case
2025-10-20 17:02:36 +01:00
Alug 50ce3c4431 R_FlushQuad: dont use 64bit/8byte copy on 32bit targets
on 32bit targets this will just compile into two 32bit copies which gcc cant optimize as well as it can with the byte copy (it seems to love to do some AVX stuff atleast in my tests)
so this is only useful for 64bit capable platforms (compiler does not seem to do 64bit copys for the byte copy case, so this ends up being faster)
2025-10-20 16:32:48 +02:00
Alug c6c1dbd066 R_FlushQuad: also check "source" for alignment 2025-10-20 16:17:01 +02:00
Alug ece8d9e80c R_FlushQuad: fix column flush on odd width resolutions 2025-10-20 00:56:30 +02:00
Alug fdcbd276e9 remove unessecaary template branch in R_DrawColumnPixel 2025-10-19 23:07:21 +02:00
Alug 6d77672ee3 no need to pass anything to R_InitViewBuffer 2025-10-19 22:19:20 +02:00
Alug 28aec6cad5 add USEUBSAN compiler flag
to compile with ubsan duh
2025-10-19 21:59:39 +02:00
Alug 1f028f523e R_FlushQuad: fix unaligned memory access 2025-10-19 21:59:35 +02:00
Alug 349bf06e4b macrofy column function definitions 2025-10-19 21:59:32 +02:00
Alug e044db73f5 those should be initialised to something 2025-10-19 21:59:29 +02:00
Alug 7555d689db clear our column buffer after allocation 2025-10-19 21:59:27 +02:00
Alug a6438da531 use spawn sector and line tags for P_ReloadSaveLevelData
should speed up resynch a little, now that we properly save them
2025-10-18 23:11:00 +02:00
Alug 8c6893cff6 init taglists in P_LoadMapData
no reason to init them in P_SpawnSpecials
fixes join crashes on some maps
2025-10-18 23:04:25 +02:00
Alug af03b51191 add guard to vid.screens free
not super necessary but better safe than sorry
2025-10-18 21:34:23 +02:00
Alug 178d8b7b53 fix demo_slug compiler warning
Zzz....
2025-10-18 16:15:19 +02:00
NepDisk de99a3036d Update Discord RPC
Based on some of the changes from RR.
Accounts for the fact discord does not have tags anymore and makes skin code easier to manage
2025-10-18 16:15:17 +02:00
NepDisk 5c613f6c8f Use a constant for file path stuff 2025-10-18 16:15:14 +02:00
James R 59628377fa Resize menudemo_t filepath to fix -Wformat-truncation 2025-10-18 16:15:11 +02:00
Alug 278f3c3ef6 turnsmoothing splitscreen player support
i hate our menus Zzz....
2025-10-17 09:24:33 +02:00
Alug 3ba1596976 change wheel input "sensitivity"
200 maps perfectly to our turn values
so the wheel now actually better reflects the inputs and does not turn fully super early uhh
2025-10-16 23:15:42 +02:00
Alug 02f6fa0665 HACK: call texture precache when toggling a setting that flushes opengl textures
workaround for batching sort issues
should be good eitherway to reduce stutters after toggling them
2025-10-16 22:21:37 +02:00
Alug f4aec1d591 port "Lite Steer" from RR
took me a while to realize RR makes everything go though "analogue" input handlers
2025-10-16 21:53:40 +02:00
Alug 5c2a87dea6 fix off by one when playing with controller sticks
also simplify driftturn handling
2025-10-16 21:53:37 +02:00
Alug d5aa9ae0f1 fix 32bit windoze compile
again......
2025-10-16 15:07:35 +01:00
indev 6096822cbb Use str.resize(size) instead of str = str.substr(0, size) (ty lug <3) 2025-10-16 15:16:23 +03:00
Alug 0030367649 fix UB in R_PointOnSide
by not shifting a 32bit int by 31 bits
this is more in line with the original function eitherways
2025-10-16 14:08:30 +02:00
Alug 66f67c91e8 G_SaveDemo: fix oob reads/writes for replay names
demo.titlename has a size of 65! not 128!
also handles memory failure and checks bounds for the remaining lenght in the demo slug
2025-10-16 14:01:02 +02:00
Alug c73c1af2d5 let replays with empty name save
this does not crash for us
2025-10-16 14:00:57 +02:00
toaster 638e95325a G_SaveDemo: Resolve memory errors that could result in crashes
- Empty `demo.titlename` case
    - Don't try to save demo of name `.lmp`
    - Doesn't fall back to anything, because emptying out the name field can be reasonably treated as not wanting to save
- `demo.titlename` consists only of invalid characters
    - Don't try to save demo of name `-.lmp`
    - Falls back to the default demo title, because the user clearly wanted to save and just happened to provide invalid text
2025-10-16 14:00:55 +02:00
Alug 66ce745e91 add allocation failure case in R_DrawMasked 2025-10-16 14:00:51 +02:00
Alug 2b39d137b4 guard against null string in stringwidth functions
hud drawlists may actually pass null to them
2025-10-16 14:00:48 +02:00
Alug 1ed616dcef pass rover directly to check_fof_offscreen 2025-10-16 14:00:45 +02:00
indev 24ef2819b0 Merge pull request #205 from Indev450/dsdacol
Software Renderer: Implement Column buffering system
2025-10-15 21:52:45 +03:00
47 changed files with 473 additions and 323 deletions

No files matched your search

+21 -13
View File
@@ -69,6 +69,7 @@
# VALGRIND=1 - Enable Valgrind memory debugging support. # VALGRIND=1 - Enable Valgrind memory debugging support.
# PROFILEMODE=1 - Enable performance profiling (gprof). # PROFILEMODE=1 - Enable performance profiling (gprof).
# USEASAN=1 - Enable building with Address Sanitizer. # USEASAN=1 - Enable building with Address Sanitizer.
# USEUBSAN=1 - Enable building with Undefined Behavior Sanitizer.
# NOLIBBACKTRACE=1 - Disable using Libbacktrace for crashlog traces. # NOLIBBACKTRACE=1 - Disable using Libbacktrace for crashlog traces.
# #
# General flags for building: # General flags for building:
@@ -243,10 +244,14 @@ ifdef STATIC
libs+=-static libs+=-static
endif endif
ifneq (,$(filter $(CC) $(CXX),gcc g++))
opts+=-mno-ms-bitfields
endif
# build with profiling information # build with profiling information
ifdef PROFILEMODE ifdef PROFILEMODE
opts+=-pg opts+=-pg
LDFLAGS+=-pg libs+=-pg
endif endif
ifdef DEBUGMODE ifdef DEBUGMODE
@@ -256,29 +261,32 @@ debug_opts=-DNDEBUG
opts+=-O3 opts+=-O3
ifdef USELTO ifdef USELTO
# compile with LTO # compile with LTO
ifdef MINGW
opts+=-flto=auto -g
LDFLAGS+=-flto=auto -g
else
opts+=-flto=auto opts+=-flto=auto
LDFLAGS+=-flto=auto libs+=-flto=auto
endif
endif endif
endif endif
ifdef USEASAN ifdef USEASAN
# compile with asan # compile with asan
ifdef MINGW
opts+=-fsanitize=address -g
libs+=-fsanitize=address -g
else
opts+=-fsanitize=address opts+=-fsanitize=address
libs+=-fsanitize=address libs+=-fsanitize=address
endif endif
ifdef USEUBSAN
# compile with asan
opts+=-fsanitize=undefined
libs+=-fsanitize=undefined
endif endif
ifeq ($(CC),clang) ifneq (,$(filter $(CC) $(CXX),clang clang++))
LDFLAGS+= -fuse-ld=lld libs+=-fuse-ld=lld
endif
ifdef MINGW
# mingw needs this passed AFTER lto and the likes were passed
# otherwise libbacktrace may break
opts+=-g
libs+=-g
endif endif
# debug_opts also get passed to windres # debug_opts also get passed to windres
+3 -1
View File
@@ -2,6 +2,8 @@
# Mingw, if you don't know, that's Win32/Win64 # Mingw, if you don't know, that's Win32/Win64
# #
sources+=$(call List,win32/Sourcefile)
ifndef MINGW64 ifndef MINGW64
EXENAME?=srb2kart-saturn_32bit.exe EXENAME?=srb2kart-saturn_32bit.exe
else else
@@ -95,7 +97,7 @@ LIBBACKTRACE_libs:=-L$(lib)/lib/x86_64 -lbacktrace
$(eval $(call _set,LIBBACKTRACE)) $(eval $(call _set,LIBBACKTRACE))
else else
lib:=../libs/drmingw lib:=../libs/drmingw
opts+=-I$(lib)/include opts+=-I$(lib)/include -DHAVE_DRMINGW
libs+=-L$(lib)/lib/win32 -lmgwhelp -lexchndl libs+=-L$(lib)/lib/win32 -lmgwhelp -lexchndl
endif endif
+55 -60
View File
@@ -347,11 +347,65 @@ static void D_Renderview(void)
} }
} }
for (i = 0; i <= splitscreen; i++)
{
if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD)
{
viewssnum = i;
switch (i)
{
case 1:
if (splitscreen > 1)
{
viewwindowx = viewwidth;
viewwindowy = 0;
}
else
{
viewwindowx = 0;
viewwindowy = viewheight;
}
break;
case 2:
viewwindowx = 0;
viewwindowy = viewheight;
break;
case 3:
viewwindowx = viewwidth;
viewwindowy = viewheight;
break;
default: // Initialize for P1
viewwindowy = viewwindowx = 0;
objectsdrawn = 0;
break;
}
#ifdef HWRENDER
if (rendermode == render_opengl)
{
HWR_RenderPlayerView();
}
else if (rendermode == render_soft)
#endif
R_RenderPlayerView(&players[displayplayers[i]]);
}
if (rendermode == render_soft)
{
if (i == 0)
R_ApplyViewMorph();
V_DoPostProcessor(i, postimgparam[i]);
}
}
// Draw over the fourth screen so you don't have to stare at a HOM :V // Draw over the fourth screen so you don't have to stare at a HOM :V
if (splitscreen == 2) if (splitscreen == 2)
{ {
// V_DrawPatchFill, but for the fourth screen only // V_DrawPatchFill, but for the fourth screen only
patch_t *pat = W_CachePatchName("SRB2BACK", PU_CACHE); patch_t *pat = W_CachePatchName("SRB2BACK", PU_PATCH);
INT32 x, y, pw = SHORT(pat->width) * vid.dup, ph = SHORT(pat->height) * vid.dup; INT32 x, y, pw = SHORT(pat->width) * vid.dup, ph = SHORT(pat->height) * vid.dup;
for (x = vid.width>>1; x < vid.width; x += pw) for (x = vid.width>>1; x < vid.width; x += pw)
@@ -361,65 +415,6 @@ static void D_Renderview(void)
} }
} }
for (i = 0; i <= splitscreen; i++)
{
const boolean issplitscreen = (i > 0);
if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD)
{
viewssnum = i;
if (!issplitscreen) // Initialize for P1
{
viewwindowy = viewwindowx = 0;
objectsdrawn = 0;
}
#ifdef HWRENDER
if (rendermode == render_opengl)
{
HWR_RenderPlayerView();
R_RestoreLevelInterpolators();
continue;
}
#endif
if (issplitscreen) // Splitscreen-specific
{
switch (i)
{
case 1:
if (splitscreen > 1)
{
viewwindowx = viewwidth;
viewwindowy = 0;
}
else
{
viewwindowx = 0;
viewwindowy = viewheight;
}
break;
case 2:
viewwindowx = 0;
viewwindowy = viewheight;
break;
case 3:
viewwindowx = viewwidth;
viewwindowy = viewheight;
default:
break;
}
}
R_RenderPlayerView(&players[displayplayers[i]]);
}
if (!issplitscreen)
R_ApplyViewMorph();
V_DoPostProcessor(i, postimgparam[i]);
}
R_RestoreLevelInterpolators(); R_RestoreLevelInterpolators();
} }
+4 -6
View File
@@ -964,10 +964,11 @@ void D_RegisterClientCommands(void)
// g_input.c // g_input.c
CV_RegisterVar(&cv_controlperkey); CV_RegisterVar(&cv_controlperkey);
CV_RegisterVar(&cv_turnsmooth);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
CV_RegisterVar(&cv_turnsmooth[i]);
CV_RegisterVar(&cv_turnaxis[i]); CV_RegisterVar(&cv_turnaxis[i]);
CV_RegisterVar(&cv_moveaxis[i]); CV_RegisterVar(&cv_moveaxis[i]);
CV_RegisterVar(&cv_camturnaxis[i]); CV_RegisterVar(&cv_camturnaxis[i]);
@@ -984,6 +985,8 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_xdeadzone[i]); CV_RegisterVar(&cv_xdeadzone[i]);
CV_RegisterVar(&cv_ydeadzone[i]); CV_RegisterVar(&cv_ydeadzone[i]);
CV_RegisterVar(&cv_litesteer[i]);
CV_RegisterVar(&cv_usejoystick[i]); CV_RegisterVar(&cv_usejoystick[i]);
CV_RegisterVar(&cv_joyscale[i]); CV_RegisterVar(&cv_joyscale[i]);
CV_RegisterVar(&cv_rumble[i]); CV_RegisterVar(&cv_rumble[i]);
@@ -1991,11 +1994,6 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
} }
else else
SetPlayerSkinByNum(playernum, skin); SetPlayerSkinByNum(playernum, skin);
#ifdef HAVE_DISCORDRPC
if (playernum == consoleplayer)
DRPC_UpdatePresence();
#endif
} }
void SendWeaponPref(void) void SendWeaponPref(void)
+27 -1
View File
@@ -49,6 +49,27 @@ discordRequest_t *discordRequestList = NULL;
static char self_ip[IP_SIZE+1]; static char self_ip[IP_SIZE+1];
/*--------------------------------------------------
* const char *DRPC_HideUsername(const char *input)
*
* See header file for description.
* --------------------------------------------------*/
const char *DRPC_HideUsername(const char *input)
{
static char buffer[5];
int i;
buffer[0] = input[0];
for (i = 1; i < 4; ++i)
{
buffer[i] = '.';
}
buffer[4] = '\0';
return buffer;
}
boolean drpc_init = false; boolean drpc_init = false;
/*-------------------------------------------------- /*--------------------------------------------------
@@ -105,7 +126,7 @@ static void DRPC_HandleReady(const DiscordUser *user)
} }
else else
{ {
CONS_Printf("Discord: connected to %s#%s (%s)\n", user->username, user->discriminator, user->userId); CONS_Printf("Discord: connected to %s (%s)\n", user->username, user->userId);
} }
} }
@@ -241,8 +262,10 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
newRequest->username = Z_Calloc(344, PU_STATIC, NULL); newRequest->username = Z_Calloc(344, PU_STATIC, NULL);
snprintf(newRequest->username, 344, "%s", requestUser->username); snprintf(newRequest->username, 344, "%s", requestUser->username);
#if 0
newRequest->discriminator = Z_Calloc(8, PU_STATIC, NULL); newRequest->discriminator = Z_Calloc(8, PU_STATIC, NULL);
snprintf(newRequest->discriminator, 8, "%s", requestUser->discriminator); snprintf(newRequest->discriminator, 8, "%s", requestUser->discriminator);
#endif
newRequest->userID = Z_Calloc(32, PU_STATIC, NULL); newRequest->userID = Z_Calloc(32, PU_STATIC, NULL);
snprintf(newRequest->userID, 32, "%s", requestUser->userId); snprintf(newRequest->userID, 32, "%s", requestUser->userId);
@@ -308,6 +331,9 @@ void DRPC_RemoveRequest(discordRequest_t *removeRequest)
} }
Z_Free(removeRequest->username); Z_Free(removeRequest->username);
#if 0
Z_Free(removeRequest->discriminator);
#endif
Z_Free(removeRequest->userID); Z_Free(removeRequest->userID);
Z_Free(removeRequest); Z_Free(removeRequest);
} }
+11
View File
@@ -29,7 +29,9 @@ extern struct discordInfo_s {
typedef struct discordRequest_s { typedef struct discordRequest_s {
char *username; // Discord user name. char *username; // Discord user name.
#if 0 // Good night, sweet prince...
char *discriminator; // Discord discriminator (The little hashtag thing after the username). Separated for a "hide discriminators" cvar. char *discriminator; // Discord discriminator (The little hashtag thing after the username). Separated for a "hide discriminators" cvar.
#endif
char *userID; // The ID of the Discord user, gets used with Discord_Respond() char *userID; // The ID of the Discord user, gets used with Discord_Respond()
// HAHAHA, no. // HAHAHA, no.
@@ -44,6 +46,15 @@ typedef struct discordRequest_s {
extern discordRequest_t *discordRequestList; extern discordRequest_t *discordRequestList;
/*--------------------------------------------------
* const char *DRPC_HideUsername(const char *input);
*
* Handle usernames while cv_discordstreamer is activated.
* (The loss of discriminators is still a dumbass regression
* that I will never forgive the Discord developers for.)
* --------------------------------------------------*/
const char *DRPC_HideUsername(const char *input);
/*-------------------------------------------------- /*--------------------------------------------------
void DRPC_RemoveRequest(void); void DRPC_RemoveRequest(void);
-6
View File
@@ -90,12 +90,6 @@ extern FILE *logstream;
extern char logfilename[1024]; extern char logfilename[1024];
#endif #endif
// not sure if this belongs here lul
// TODO: figure out whats preventing 32bit windows from working with libbacktrace
#if defined(_WIN32) && !defined(__MINGW64__)
#define HAVE_DRMINGW
#endif
#if defined (HAVE_LIBBACKTRACE) #if defined (HAVE_LIBBACKTRACE)
#define CRASH_LOGFILE_NAME "srb2kart-crash-log.txt" #define CRASH_LOGFILE_NAME "srb2kart-crash-log.txt"
#elif defined (HAVE_DRMINGW) #elif defined (HAVE_DRMINGW)
+2 -2
View File
@@ -44,7 +44,7 @@ consvar_t cv_addons_search_case = {"addons_search_case", "No", CV_SAVE, CV_YesNo
static CV_PossibleValue_t addons_search_type_cons_t[] = {{0, "Start"}, {1, "Anywhere"}, {0, NULL}}; static CV_PossibleValue_t addons_search_type_cons_t[] = {{0, "Start"}, {1, "Anywhere"}, {0, NULL}};
consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
char menupath[1024]; char menupath[MAXFILEPATH];
size_t menupathindex[menudepth]; size_t menupathindex[menudepth];
size_t menudepthleft = menudepth; size_t menudepthleft = menudepth;
@@ -111,7 +111,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
int found = 0; int found = 0;
char *searchname; char *searchname;
int depthleft = maxsearchdepth; int depthleft = maxsearchdepth;
char searchpath[1024]; char searchpath[MAXFILEPATH];
size_t *searchpathindex; size_t *searchpathindex;
dirhandle = (DIR**)malloc(maxsearchdepth * sizeof(DIR*)); dirhandle = (DIR**)malloc(maxsearchdepth * sizeof(DIR*));
+2 -1
View File
@@ -34,7 +34,8 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
#define menudepth 20 #define menudepth 20
extern char menupath[1024]; #define MAXFILEPATH 1024
extern char menupath[MAXFILEPATH];
extern size_t menupathindex[menudepth]; extern size_t menupathindex[menudepth];
extern size_t menudepthleft; extern size_t menudepthleft;
+21 -8
View File
@@ -630,7 +630,7 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim)
ghostext[playernum].flags |= EZT_HIT; ghostext[playernum].flags |= EZT_HIT;
ghostext[playernum].hits++; ghostext[playernum].hits++;
Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_STATIC, &ghostext[playernum].hitlist); ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, &ghostext[playernum].hitlist);
P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim);
} }
@@ -3569,7 +3569,8 @@ void G_SaveDemo(void)
size_t i, strindex = 0; size_t i, strindex = 0;
boolean dash = true; boolean dash = true;
for (i = 0; demo.titlename[i] && i < 127; i++) //for (i = 0; demo.titlename[i] && i < 127; i++) ?????
for (i = 0; i < 64 && demo.titlename[i]; i++)
{ {
if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') || if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') ||
(demo.titlename[i] >= '0' && demo.titlename[i] <= '9')) (demo.titlename[i] >= '0' && demo.titlename[i] <= '9'))
@@ -3584,7 +3585,7 @@ void G_SaveDemo(void)
strindex++; strindex++;
dash = false; dash = false;
} }
else if (!dash) else if (strindex && !dash)
{ {
demo_slug[strindex] = '-'; demo_slug[strindex] = '-';
strindex++; strindex++;
@@ -3592,12 +3593,24 @@ void G_SaveDemo(void)
} }
} }
demo_slug[strindex] = 0; if (dash && strindex)
if (dash) demo_slug[strindex-1] = 0; {
strindex--;
}
demo_slug[strindex] = '\0';
writepoint = strstr(demoname, "-") + 1; if (demo_slug[0] != '\0')
demo_slug[128 - (writepoint - demoname) - 4] = 0; {
sprintf(writepoint, "%s.lmp", demo_slug); // Slug is valid, write the chosen filename.
writepoint = strstr(demoname, "-");
if (!writepoint)
return;
writepoint++;
size_t flen = 128 - (writepoint - demoname) - 4;
snprintf(writepoint, flen, "%s.lmp", demo_slug);
}
} }
length = *(UINT32 *)demoinfo_p; length = *(UINT32 *)demoinfo_p;
+1 -1
View File
@@ -67,7 +67,7 @@ typedef enum {
} menudemotype_e; } menudemotype_e;
typedef struct menudemo_s { typedef struct menudemo_s {
char filepath[256]; char filepath[1023 + 256]; // see M_PrepReplayList and sizeof menupath
menudemotype_e type; menudemotype_e type;
char title[65]; // Null-terminated for string prints char title[65]; // Null-terminated for string prints
+23 -16
View File
@@ -452,6 +452,13 @@ consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS] = {
{"joy4_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} {"joy4_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}
}; };
consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = {
{"litesteer", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"litesteer2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"litesteer3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"litesteer4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
};
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -1014,8 +1021,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
else else
th = 0; th = 0;
if (th < SLOWTURNTICS) if (th < (cv_turnsmooth[forplayer].value * 3))
tspeed = cv_turnsmooth.value == 2 ? 2 : 0; // slow turn tspeed = cv_turnsmooth[forplayer].value == 2 ? 2 : 0; // slow turn
else else
tspeed = 1; tspeed = 1;
@@ -1024,30 +1031,32 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// let movement keys cancel each other out // let movement keys cancel each other out
if (turnright && !(turnleft)) if (turnright && !(turnleft))
{ {
cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed])); cmd->angleturn -= angleturn[tspeed];
cmd->driftturn = (INT16)(cmd->driftturn - (angleturn[tspeed]));
side += sidemove[1]; side += sidemove[1];
} }
else if (turnleft && !(turnright)) else if (turnleft && !(turnright))
{ {
cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed])); cmd->angleturn += angleturn[tspeed];
cmd->driftturn = (INT16)(cmd->driftturn + (angleturn[tspeed]));
side -= sidemove[1]; side -= sidemove[1];
} }
if (analogjoystickmove && axis != 0) if (analogjoystickmove && axis != 0)
{ {
// JOYAXISRANGE should be 1023 (divide by 1024) cmd->angleturn -= (axis * KART_FULLTURN) / JOYAXISRANGE;
cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG! side += (axis * sidemove[0]) / JOYAXISRANGE;
cmd->driftturn = (INT16)(cmd->driftturn - (((axis * angleturn[1]) >> 10)));
side += ((axis * sidemove[0]) >> 10);
} }
if (cv_mouseturn.value) if (cv_mouseturn.value)
{ {
//THIS WORKS WTF???????? //THIS WORKS WTF????????
cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); cmd->angleturn -= (mousex*(encoremode ? -1 : 1)*8);
cmd->driftturn = (INT16)(cmd->driftturn - ((mousex*(encoremode ? -1 : 1)*8))); }
// Digital users can input diagonal-back for shallow turns.
if (cv_litesteer[forplayer].value && InputDown(gc_aimbackward, ssplayer)
&& abs(cmd->angleturn) == KART_FULLTURN) // My keyboard hits 1024 but my keyboard only hits 1023, video games
{
cmd->angleturn /= 2;
} }
if (objectplacing) // SRB2Kart: spectators need special controls // not anymore huehuehue if (objectplacing) // SRB2Kart: spectators need special controls // not anymore huehuehue
@@ -1160,10 +1169,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
else if (cmd->angleturn < (-angleturn[1])) else if (cmd->angleturn < (-angleturn[1]))
cmd->angleturn = (-angleturn[1]); cmd->angleturn = (-angleturn[1]);
if (cmd->driftturn > (angleturn[1])) // until here both are the very same
cmd->driftturn = (angleturn[1]); cmd->driftturn = cmd->angleturn;
else if (cmd->driftturn < (-angleturn[1]))
cmd->driftturn = (-angleturn[1]);
if (player->mo) if (player->mo)
cmd->angleturn = K_GetKartTurnValue(player, cmd->angleturn); cmd->angleturn = K_GetKartTurnValue(player, cmd->angleturn);
+2 -1
View File
@@ -72,6 +72,8 @@ extern consvar_t cv_custom3axis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_xdeadzone[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_xdeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff;
// Hud offsets // Hud offsets
@@ -153,7 +155,6 @@ typedef enum
// mouseaiming (looking up/down with the mouse or keyboard) // mouseaiming (looking up/down with the mouse or keyboard)
#define KB_LOOKSPEED (1<<25) #define KB_LOOKSPEED (1<<25)
#define MAXPLMOVE (50) #define MAXPLMOVE (50)
#define SLOWTURNTICS (cv_turnsmooth.value * 3)
// build an internal map name MAPxx from map number // build an internal map name MAPxx from map number
const char *G_BuildMapName(INT32 map); const char *G_BuildMapName(INT32 map);
+7 -1
View File
@@ -37,7 +37,13 @@ static CV_PossibleValue_t turnsmooth_cons_t[] = {{2, "Slow"}, {1, "Fast"}, {0, "
consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_turnsmooth = {"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS] = {
{"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing2", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing3", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing4", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}
};
static void G_ResetPlayerDeviceRumble(INT32 player); static void G_ResetPlayerDeviceRumble(INT32 player);
static void rumble_off_handle(void); static void rumble_off_handle(void);
+2 -1
View File
@@ -110,7 +110,8 @@ typedef enum
// mouse values are used once // mouse values are used once
extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_mousesens, cv_mouseysens;
extern consvar_t cv_controlperkey, cv_turnsmooth; extern consvar_t cv_controlperkey;
extern consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
+1 -1
View File
@@ -804,7 +804,7 @@ static void HWR_PrecacheLevelSprites(void)
void HWR_PrecacheLevel(void) void HWR_PrecacheLevel(void)
{ {
if (rendermode != render_opengl) if (gamestate != GS_LEVEL)
return; return;
// Precache flats. // Precache flats.
+26 -26
View File
@@ -277,6 +277,7 @@ static void CV_glshaders_OnChange(void)
{ {
// can't do palette rendering without shaders, so update the state if needed // can't do palette rendering without shaders, so update the state if needed
HWR_TogglePaletteRendering(); HWR_TogglePaletteRendering();
HWR_PrecacheLevel();
} }
M_UpdateOGLMenu(); M_UpdateOGLMenu();
} }
@@ -294,18 +295,21 @@ static void CV_gltextureformat_OnChange(void)
{ {
ONLY_IF_GL_LOADED ONLY_IF_GL_LOADED
GL_SetSpecialState(HWD_SET_TEXTURE_FORMAT, cv_gltexturedepth.value); GL_SetSpecialState(HWD_SET_TEXTURE_FORMAT, cv_gltexturedepth.value);
HWR_PrecacheLevel();
} }
static void CV_filtermode_OnChange(void) static void CV_filtermode_OnChange(void)
{ {
ONLY_IF_GL_LOADED ONLY_IF_GL_LOADED
GL_SetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); GL_SetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value);
HWR_PrecacheLevel();
} }
static void CV_anisotropic_OnChange(void) static void CV_anisotropic_OnChange(void)
{ {
ONLY_IF_GL_LOADED ONLY_IF_GL_LOADED
GL_SetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value); GL_SetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value);
HWR_PrecacheLevel();
} }
static void CV_glpaletterendering_OnChange(void) static void CV_glpaletterendering_OnChange(void)
@@ -318,7 +322,9 @@ static void CV_glpaletterendering_OnChange(void)
{ {
HWR_CompileShaders(); HWR_CompileShaders();
HWR_TogglePaletteRendering(); HWR_TogglePaletteRendering();
HWR_PrecacheLevel();
} }
M_UpdateOGLMenu(); M_UpdateOGLMenu();
} }
@@ -3370,6 +3376,9 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
fixed_t slopez; fixed_t slopez;
float offset = 0; float offset = 0;
if (!spr->mobj)
return;
R_GetShadowZ(spr->mobj, &floorslope); R_GetShadowZ(spr->mobj, &floorslope);
mobjfloor = HWR_OpaqueFloorAtPos( mobjfloor = HWR_OpaqueFloorAtPos(
@@ -3381,14 +3390,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
angle_t shadowdir; angle_t shadowdir;
// Set direction // Set direction
if (splitscreen && R_GetViewNumber() == 1) shadowdir = localangle[viewssnum] + FixedAngle(cv_cam_rotate[viewssnum].value);
shadowdir = localangle[1] + FixedAngle(cv_cam_rotate[1].value);
else if (splitscreen > 1 && R_GetViewNumber() == 2)
shadowdir = localangle[2] + FixedAngle(cv_cam_rotate[2].value);
else if (splitscreen > 2 && R_GetViewNumber() == 3)
shadowdir = localangle[3] + FixedAngle(cv_cam_rotate[3].value);
else
shadowdir = localangle[0] + FixedAngle(cv_cam_rotate[0].value);
// Find floorheight // Find floorheight
floorheight = HWR_OpaqueFloorAtPos( floorheight = HWR_OpaqueFloorAtPos(
@@ -3400,18 +3402,17 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
// Don't draw it, then! // Don't draw it, then!
if (spr->mobj->z < floorheight) if (spr->mobj->z < floorheight)
return; return;
else
{ fixed_t floorz;
fixed_t floorz; floorz = HWR_OpaqueFloorAtPos(
floorz = HWR_OpaqueFloorAtPos( spr->mobj->x + P_ReturnThrustX(spr->mobj, shadowdir, spr->mobj->z - floorheight),
spr->mobj->x + P_ReturnThrustX(spr->mobj, shadowdir, spr->mobj->z - floorheight), spr->mobj->y + P_ReturnThrustY(spr->mobj, shadowdir, spr->mobj->z - floorheight),
spr->mobj->y + P_ReturnThrustY(spr->mobj, shadowdir, spr->mobj->z - floorheight), spr->mobj->z, spr->mobj->height);
spr->mobj->z, spr->mobj->height);
// The shadow would be falling on a wall? Don't draw it, then. // The shadow would be falling on a wall? Don't draw it, then.
// Would draw midair otherwise. // Would draw midair otherwise.
if (floorz < floorheight) if (floorz < floorheight)
return; return;
}
floorheight = FixedInt(spr->mobj->z - floorheight); floorheight = FixedInt(spr->mobj->z - floorheight);
@@ -3421,12 +3422,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
floorheight = FixedInt(spr->mobj->z - mobjfloor); floorheight = FixedInt(spr->mobj->z - mobjfloor);
// technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again
const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); this_scale = FixedToFloat(spr->mobj->scale);
if (spr->mobj) const skin_t *moskin = K_GetMobjSkin(spr->mobj);
this_scale = FixedToFloat(spr->mobj->scale); if (moskin && moskin->flags & SF_HIRES)
if (hires) this_scale *= FixedToFloat(moskin->highresscale);
this_scale = this_scale * FixedToFloat(K_GetMobjSkin(spr->mobj)->highresscale);
// create the sprite billboard // create the sprite billboard
// //
@@ -4047,7 +4047,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
const precipmobj_t *sprmo = spr->precip; const precipmobj_t *sprmo = spr->precip;
if (UNLIKELY(!sprmo || !sprmo->subsector)) if (UNLIKELY(!sprmo->subsector))
return; return;
// cache sprite graphics // cache sprite graphics
+1 -1
View File
@@ -4333,7 +4333,7 @@ static void K_drawInput(void)
target = 0; target = 0;
else // turning of multiple strengths! else // turning of multiple strengths!
{ {
target = ((abs(cmd->driftturn) - 1)/125)+1; target = ((abs(cmd->driftturn) - 1)/200)+1; // was 125, do we need another toggle for this? Zzz...
if (target > 4) if (target > 4)
target = 4; target = 4;
if (cmd->driftturn < 0) if (cmd->driftturn < 0)
+21 -7
View File
@@ -377,7 +377,9 @@ static int lib_pSpawnMobj(lua_State *L)
NOHUD NOHUD
if (type >= NUMMOBJTYPES) if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnMobj(x, y, z, type), META_MOBJ); mobj_t *th = P_SpawnMobj(x, y, z, type);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
return 1; return 1;
} }
@@ -403,7 +405,9 @@ static int lib_pSpawnMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES) if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnMissile(source, dest, type), META_MOBJ); mobj_t *th = P_SpawnMissile(source, dest, type);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
return 1; return 1;
} }
@@ -420,7 +424,9 @@ static int lib_pSpawnXYZMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES) if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnXYZMissile(source, dest, type, x, y, z), META_MOBJ); mobj_t *th = P_SpawnXYZMissile(source, dest, type, x, y, z);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
return 1; return 1;
} }
@@ -439,7 +445,9 @@ static int lib_pSpawnPointMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES) if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnPointMissile(source, xa, ya, za, type, x, y, z), META_MOBJ); mobj_t *th = P_SpawnPointMissile(source, xa, ya, za, type, x, y, z);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
return 1; return 1;
} }
@@ -456,7 +464,9 @@ static int lib_pSpawnAlteredDirectionMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES) if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnAlteredDirectionMissile(source, type, x, y, z, shiftingAngle), META_MOBJ); mobj_t *th = P_SpawnAlteredDirectionMissile(source, type, x, y, z, shiftingAngle);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
return 1; return 1;
} }
@@ -485,7 +495,9 @@ static int lib_pSPMAngle(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES) if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SPMAngle(source, type, angle, allowaim, flags2), META_MOBJ); mobj_t *th = P_SPMAngle(source, type, angle, allowaim, flags2);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
return 1; return 1;
} }
@@ -499,7 +511,9 @@ static int lib_pSpawnPlayerMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES) if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
LUA_PushUserdata(L, P_SpawnPlayerMissile(source, type, flags2), META_MOBJ); mobj_t *th = P_SpawnPlayerMissile(source, type, flags2);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
return 1; return 1;
} }
+1
View File
@@ -109,6 +109,7 @@ ENUM (STRING_HOOK);
extern boolean hook_cmd_running; // This is used by PlayerCmd and lua_playerlib to prevent anything from being wirtten to player while we run PlayerCmd. extern boolean hook_cmd_running; // This is used by PlayerCmd and lua_playerlib to prevent anything from being wirtten to player while we run PlayerCmd.
extern int hook_defrosting; extern int hook_defrosting;
extern bool hook_important;
void LUA_HookVoid(int hook); void LUA_HookVoid(int hook);
void LUA_HookHUD(int hook, huddrawlist_h drawlist); void LUA_HookHUD(int hook, huddrawlist_h drawlist);
+26 -4
View File
@@ -19,6 +19,7 @@
#include "b_bot.h" #include "b_bot.h"
#include "z_zone.h" #include "z_zone.h"
#include "m_perfstats.h" #include "m_perfstats.h"
#include "w_wad.h"
#include "lua_script.h" #include "lua_script.h"
#include "lua_libs.h" #include "lua_libs.h"
@@ -39,14 +40,20 @@ LIST (stringHookNames, STRING_HOOK_LIST);
#undef LIST #undef LIST
typedef struct {
int id;
bool important;
} hookinfo_t;
typedef struct { typedef struct {
int numHooks; int numHooks;
int *ids; hookinfo_t *ids;
} hook_t; } hook_t;
typedef struct { typedef struct {
int numGeneric; int numGeneric;
int ref; int ref;
bool important;
} stringhook_t; } stringhook_t;
static hook_t hookIds[HOOK(MAX)]; static hook_t hookIds[HOOK(MAX)];
@@ -56,6 +63,8 @@ static hook_t mobjHookIds[NUMMOBJTYPES][MOBJ_HOOK(MAX)];
// Lua tables are used to lookup string hook ids. // Lua tables are used to lookup string hook ids.
static stringhook_t stringHooks[STRING_HOOK(MAX)]; static stringhook_t stringHooks[STRING_HOOK(MAX)];
bool hook_important = true;
// This will be indexed by hook id, the value of which fetches the registry. // This will be indexed by hook id, the value of which fetches the registry.
static int * hookRefs; static int * hookRefs;
static int nextid; static int nextid;
@@ -109,7 +118,11 @@ static void get_table(lua_State *L)
FUNCINLINE static ATTRINLINE void add_hook_to_table(lua_State *L, int n) FUNCINLINE static ATTRINLINE void add_hook_to_table(lua_State *L, int n)
{ {
lua_newtable(L);
lua_pushnumber(L, nextid); lua_pushnumber(L, nextid);
lua_rawseti(L, -2, 1);
lua_pushboolean(L, wadfiles[numwadfiles-1]->important);
lua_rawseti(L, -2, 2);
lua_rawseti(L, -2, n); lua_rawseti(L, -2, n);
} }
@@ -180,7 +193,8 @@ FUNCINLINE static ATTRINLINE void add_hook(hook_t *map)
{ {
Z_Realloc(map->ids, (map->numHooks + 1) * sizeof *map->ids, Z_Realloc(map->ids, (map->numHooks + 1) * sizeof *map->ids,
PU_STATIC, &map->ids); PU_STATIC, &map->ids);
map->ids[map->numHooks++] = nextid; map->ids[map->numHooks].important = wadfiles[numwadfiles-1]->important;
map->ids[map->numHooks++].id = nextid;
} }
FUNCINLINE static ATTRINLINE void add_mobj_hook(lua_State *L, int hook_type) FUNCINLINE static ATTRINLINE void add_mobj_hook(lua_State *L, int hook_type)
@@ -287,6 +301,7 @@ struct Hook_State {
const char * string;/* used to fetch table, ran first if set */ const char * string;/* used to fetch table, ran first if set */
int top;/* index of last argument passed to hook */ int top;/* index of last argument passed to hook */
int id;/* id to fetch ref */ int id;/* id to fetch ref */
boolean important;/* is this hook from local addon */
int values;/* num arguments passed to hook */ int values;/* num arguments passed to hook */
int results;/* num values returned by hook */ int results;/* num values returned by hook */
Hook_Callback results_handler;/* callback when hook successfully returns */ Hook_Callback results_handler;/* callback when hook successfully returns */
@@ -416,22 +431,29 @@ FUNCINLINE static ATTRINLINE void init_hook_call
hook->results_handler = results_handler; hook->results_handler = results_handler;
} }
FUNCINLINE static ATTRINLINE void get_hook(Hook_State *hook, const int *ids, int n) FUNCINLINE static ATTRINLINE void get_hook(Hook_State *hook, const hookinfo_t *ids, int n)
{ {
hook->id = ids[n]; hook->id = ids[n].id;
hook->important = ids[n].important;
lua_getref(gL, hookRefs[hook->id]); lua_getref(gL, hookRefs[hook->id]);
} }
FUNCINLINE static ATTRINLINE void get_hook_from_table(Hook_State *hook, int n) FUNCINLINE static ATTRINLINE void get_hook_from_table(Hook_State *hook, int n)
{ {
lua_rawgeti(gL, -1, n); lua_rawgeti(gL, -1, n);
lua_rawgeti(gL, -1, 1);
hook->id = lua_tonumber(gL, -1); hook->id = lua_tonumber(gL, -1);
lua_pop(gL, 1); lua_pop(gL, 1);
lua_rawgeti(gL, -2, 2);
hook->important = lua_toboolean(gL, -1);
lua_pop(gL, 2);
lua_getref(gL, hookRefs[hook->id]); lua_getref(gL, hookRefs[hook->id]);
} }
static int call_single_hook_no_copy(Hook_State *hook) static int call_single_hook_no_copy(Hook_State *hook)
{ {
hook_important = hook->important;
if (lua_pcall(gL, hook->values, hook->results, EINDEX) == 0) if (lua_pcall(gL, hook->values, hook->results, EINDEX) == 0)
{ {
if (hook->results > 0) if (hook->results > 0)
+2 -2
View File
@@ -92,7 +92,7 @@ void M_LoadEmotes(UINT16 wadnum)
if (emote_name.size() > MAXEMOTENAME) if (emote_name.size() > MAXEMOTENAME)
{ {
CONS_Alert(CONS_WARNING, "EMOTES: Emote name is too long, truncating. (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum); CONS_Alert(CONS_WARNING, "EMOTES: Emote name is too long, truncating. (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
emote_name = emote_name.substr(0, MAXEMOTENAME); emote_name.resize(MAXEMOTENAME);
} }
emote = &emotes[emote_name]; emote = &emotes[emote_name];
@@ -139,7 +139,7 @@ void M_LoadEmotes(UINT16 wadnum)
if (framelumpname.size() > 8) if (framelumpname.size() > 8)
{ {
CONS_Alert(CONS_WARNING, "EMOTES: Frame %d name is too long. (file %s, line %d)", numframes, wadfiles[wadnum]->filename, linenum); CONS_Alert(CONS_WARNING, "EMOTES: Frame %d name is too long. (file %s, line %d)", numframes, wadfiles[wadnum]->filename, linenum);
framelumpname = framelumpname.substr(0, 8); framelumpname.resize(8);
} }
std::strncpy(emote->frames[numframes], framelumpname.c_str(), framelumpname.size()+1); std::strncpy(emote->frames[numframes], framelumpname.c_str(), framelumpname.size()+1);
+18 -14
View File
@@ -702,7 +702,13 @@ static void M_CheckStringItem(void)
// Just in case // Just in case
memset(menu_text_input_buf, 0, sizeof menu_text_input_buf); memset(menu_text_input_buf, 0, sizeof menu_text_input_buf);
M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf);
// special case: name input, cap it to prevent writing outside the textbox
// kinda ugly but itll work
if (cv == &cv_playername)
M_TextInputInit(&menuinput, menu_text_input_buf, MAXPLAYERNAME +1);
else
M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf);
M_TextInputSetString(&menuinput, cv->string); M_TextInputSetString(&menuinput, cv->string);
} }
@@ -3107,7 +3113,7 @@ static void M_AddonsInternal(void)
break; break;
} }
strlcpy(menupath, pathname, 1024); strlcpy(menupath, pathname, MAXFILEPATH);
menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath) + 1; menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath) + 1;
if (menupath[menupathindex[menudepthleft]-2] != PATHSEP[0]) if (menupath[menupathindex[menudepthleft]-2] != PATHSEP[0])
@@ -3220,9 +3226,9 @@ static void M_DrawTemperature(INT32 x, fixed_t t)
static char *M_AddonsHeaderPath(void) static char *M_AddonsHeaderPath(void)
{ {
UINT32 len; UINT32 len;
static char header[1024]; static char header[MAXFILEPATH];
strlcpy(header, va("%s folder%s", cv_addons_option.string, menupath+menupathindex[menudepth-1]-1), 1024); strlcpy(header, va("%s folder%s", cv_addons_option.string, menupath+menupathindex[menudepth-1]-1), MAXFILEPATH);
len = strlen(header); len = strlen(header);
if (len > 34) if (len > 34)
{ {
@@ -3958,9 +3964,7 @@ static void PrepReplayList(boolean reset)
Lock_search_state(); Lock_search_state();
if (demolist_all) Z_Free(demolist_all);
Z_Free(demolist_all);
demolist_all = Z_Calloc(sizeof(menudemo_t) * sizedirmenu, PU_STATIC, NULL); demolist_all = Z_Calloc(sizeof(menudemo_t) * sizedirmenu, PU_STATIC, NULL);
for (i = 0; i < sizedirmenu; i++) for (i = 0; i < sizedirmenu; i++)
@@ -3978,9 +3982,9 @@ static void PrepReplayList(boolean reset)
else else
{ {
demolist_all[i].type = MD_NOTLOADED; demolist_all[i].type = MD_NOTLOADED;
// FIXME - do something with buffer sizes. menupath is 1024 chars but filepath is only snprintf(demolist_all[i].filepath, sizeof(demolist_all[i].filepath),
// 256. I'm not really sure what to do here but don't want to leave warnings... // 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN).
snprintf(demolist_all[i].filepath, 255, "%.254s%s", menupath, dirmenu[i] + DIR_STRING); "%s%.255s", menupath, dirmenu[i] + DIR_STRING);
sprintf(demolist_all[i].title, "....."); sprintf(demolist_all[i].title, ".....");
} }
} }
@@ -4335,7 +4339,7 @@ static void DrawReplayHutReplayInfo(void)
static void M_DrawReplayHut(void) static void M_DrawReplayHut(void)
{ {
INT32 x, y, cursory = 0; INT32 x, y, cursory = 0;
INT16 i; INT32 i;
INT16 replaylistitem = currentMenu->numitems-2; INT16 replaylistitem = currentMenu->numitems-2;
boolean processed_one_this_frame = false; boolean processed_one_this_frame = false;
const INT32 scaledviewheight = (vid.height/vid.dup); const INT32 scaledviewheight = (vid.height/vid.dup);
@@ -4408,7 +4412,7 @@ static void M_DrawReplayHut(void)
V_DrawCenteredString(160, 100, V_ALLOWLOWERCASE, msg); V_DrawCenteredString(160, 100, V_ALLOWLOWERCASE, msg);
} }
for (i = 0; i < (INT16)replayqueryfound; i++) for (i = 0; i < (INT32)replayqueryfound; i++)
{ {
INT32 localy = y+i*10; INT32 localy = y+i*10;
INT32 localx = x; INT32 localx = x;
@@ -10334,9 +10338,9 @@ static const char *M_GetDiscordName(discordRequest_t *r)
return ""; return "";
if (cv_discordstreamer.value) if (cv_discordstreamer.value)
return r->username; return DRPC_HideUsername(r->username);
return va("%s#%s", r->username, r->discriminator); return r->username;
} }
// (this goes in k_hud.c when merged into v2) // (this goes in k_hud.c when merged into v2)
+23 -5
View File
@@ -645,10 +645,20 @@ static menuitem_t OP_ControlsMenu[] =
{IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30}, {IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30},
{IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40}, {IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40},
{IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60}, {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 55},
{IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80}, {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 75},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P1)", &cv_turnsmooth[0], 85},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P2)", &cv_turnsmooth[1], 95},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P3)", &cv_turnsmooth[2], 105},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P4)", &cv_turnsmooth[3], 115},
// i hate our menus sincerly
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P1)", &cv_litesteer[0], 135},
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P2)", &cv_litesteer[1], 145},
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P3)", &cv_litesteer[2], 155},
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P4)", &cv_litesteer[3], 165},
}; };
static const char* OP_ControlsTooltips[] = static const char* OP_ControlsTooltips[] =
@@ -659,7 +669,15 @@ static const char* OP_ControlsTooltips[] =
"Setup player 4 controls.", "Setup player 4 controls.",
"Options for mouse control.", "Options for mouse control.",
"Allowed amount of controls per key.", "Allowed amount of controls per key.",
"Turn smoothing for non-analog turning.", "Turn smoothing for non-analog turning (Player 1).",
"Turn smoothing for non-analog turning (Player 2).",
"Turn smoothing for non-analog turning (Player 3).",
"Turn smoothing for non-analog turning (Player 4).",
"Hold DOWN on d-pad/keyboard for shallow turns (Player 1).",
"Hold DOWN on d-pad/keyboard for shallow turns (Player 2).",
"Hold DOWN on d-pad/keyboard for shallow turns (Player 3).",
"Hold DOWN on d-pad/keyboard for shallow turns (Player 4).",
}; };
static menuitem_t OP_AllControlsMenu[] = static menuitem_t OP_AllControlsMenu[] =
@@ -2424,7 +2442,7 @@ menu_t OP_MainDef =
NULL NULL
}; };
menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30, OP_ControlsTooltips); menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 40, 15, OP_ControlsTooltips);
//WTF //WTF
menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30, OP_MouseTooltips); menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30, OP_MouseTooltips);
menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef); menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef);
+2 -2
View File
@@ -239,8 +239,8 @@ void M_TextInputClear(textinput_t *input)
void M_TextInputSetString(textinput_t *input, const char *c) void M_TextInputSetString(textinput_t *input, const char *c)
{ {
memset(input->buffer, 0, input->buffer_size); memset(input->buffer, 0, input->buffer_size);
strcpy(input->buffer, c); strncpy(input->buffer, c, input->buffer_size);
input->cursor = input->select = input->length = strlen(c); input->cursor = input->select = input->length = strlen(input->buffer);
} }
static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emotes) static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emotes)
+1 -1
View File
@@ -11889,7 +11889,7 @@ void P_SpawnHoops(mapthing_t *mthing)
z += P_GetSectorFloorZAt(sec, x, y); z += P_GetSectorFloorZAt(sec, x, y);
hoopcenter->z -= hoopcenter->height/2; hoopcenter->z = z - hoopcenter->height/2;
P_UnsetThingPosition(hoopcenter); P_UnsetThingPosition(hoopcenter);
hoopcenter->x = x; hoopcenter->x = x;
+4 -4
View File
@@ -3531,7 +3531,8 @@ static void P_ReloadSaveLevelData(void)
ss->floorpic_angle = spawnss->floorpic_angle; ss->floorpic_angle = spawnss->floorpic_angle;
ss->ceilingpic_angle = spawnss->ceilingpic_angle; ss->ceilingpic_angle = spawnss->ceilingpic_angle;
ss->tag = spawnss->tag; ss->tag = spawnss->tag;
ss->firsttag = ss->nexttag = -1; ss->firsttag = spawnss->firsttag;
ss->nexttag = spawnss->nexttag;
if (ss->ffloors) if (ss->ffloors)
{ {
@@ -3556,7 +3557,8 @@ static void P_ReloadSaveLevelData(void)
li->callcount = 0; li->callcount = 0;
li->tag = spawnli->tag; li->tag = spawnli->tag;
li->firsttag = li->nexttag = -1; li->firsttag = spawnli->firsttag;
li->nexttag = spawnli->nexttag;
if (li->sidenum[0] != 0xffff) if (li->sidenum[0] != 0xffff)
{ {
@@ -3580,8 +3582,6 @@ static void P_ReloadSaveLevelData(void)
si->midtexture = spawnsi->midtexture; si->midtexture = spawnsi->midtexture;
} }
} }
P_InitTagLists();
} }
FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, boolean reloading) FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, boolean reloading)
+4 -3
View File
@@ -1983,11 +1983,12 @@ static void P_LoadMapData(const virtres_t* virt)
P_LoadLinedefs(virtlinedefs->data); P_LoadLinedefs(virtlinedefs->data);
P_LoadSidedefs(virtsidedefs->data); P_LoadSidedefs(virtsidedefs->data);
P_LoadThings(virtthings->data); P_LoadThings(virtthings->data);
P_InitTagLists(); // Create xref tables for tags
// Copy relevant map data for NetArchive purposes. // Copy relevant map data for NetArchive purposes.
spawnsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL); spawnsectors = Z_Malloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
spawnlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL); spawnlines = Z_Malloc(numlines * sizeof(*lines), PU_LEVEL, NULL);
spawnsides = Z_Calloc(numsides * sizeof(*sides), PU_LEVEL, NULL); spawnsides = Z_Malloc(numsides * sizeof(*sides), PU_LEVEL, NULL);
memcpy(spawnsectors, sectors, numsectors * sizeof(*sectors)); memcpy(spawnsectors, sectors, numsectors * sizeof(*sectors));
memcpy(spawnlines, lines, numlines * sizeof(*lines)); memcpy(spawnlines, lines, numlines * sizeof(*lines));
-1
View File
@@ -5387,7 +5387,6 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
// set current weather // set current weather
curWeather = mapheaderinfo[gamemap-1]->weather; curWeather = mapheaderinfo[gamemap-1]->weather;
P_InitTagLists(); // Create xref tables for tags
P_SearchForDisableLinedefs(); // Disable linedefs are now allowed to disable *any* line P_SearchForDisableLinedefs(); // Disable linedefs are now allowed to disable *any* line
P_SpawnScrollers(); // Add generalized scrollers P_SpawnScrollers(); // Add generalized scrollers
+1 -1
View File
@@ -77,7 +77,7 @@ void R_ClearDrawSegs(void)
// CPhipps - // CPhipps -
// Instead of clipsegs, let's try using an array with one entry for each column, // Instead of clipsegs, let's try using an array with one entry for each column,
// indicating whether it's blocked by a solid wall yet or not. // indicating whether it's blocked by a solid wall yet or not.
UINT8 *solidcol; UINT8 *solidcol = NULL;
void R_AllocClipSegMemory(void) void R_AllocClipSegMemory(void)
{ {
+8 -8
View File
@@ -90,21 +90,21 @@ INT32 numtextures = 0; // total number of textures found,
// size of following tables // size of following tables
texture_t **textures = NULL; texture_t **textures = NULL;
static UINT32 **texturecolumnofs; // column offset lookup table for each texture static UINT32 **texturecolumnofs = NULL; // column offset lookup table for each texture
UINT8 **texturecache; // graphics data for each generated full-size texture UINT8 **texturecache = NULL; // graphics data for each generated full-size texture
// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask // texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask
static INT32 *texturewidth; static INT32 *texturewidth = NULL;
fixed_t *textureheight; // needed for texture pegging fixed_t *textureheight = NULL; // needed for texture pegging
INT32 *texturetranslation; INT32 *texturetranslation = NULL;
// needed for pre rendering // needed for pre rendering
sprcache_t *spritecachedinfo; sprcache_t *spritecachedinfo = NULL;
lighttable_t *colormaps; lighttable_t *colormaps = NULL;
UINT8 *encoremap; UINT8 *encoremap = NULL;
#ifdef HASINVERT #ifdef HASINVERT
UINT8 invertmap[256]; UINT8 invertmap[256];
#endif #endif
+4 -7
View File
@@ -606,13 +606,8 @@ static void R_AllocViewMemory(void)
R_AllocVisSpriteMemory(); R_AllocVisSpriteMemory();
} }
void R_InitViewBuffer(INT32 width, INT32 height) void R_InitViewBuffer(void)
{ {
if (width > MAXVIDWIDTH)
width = MAXVIDWIDTH;
if (height > MAXVIDHEIGHT)
height = MAXVIDHEIGHT;
R_AllocViewMemory(); R_AllocViewMemory();
viewwindowx = 0; viewwindowx = 0;
@@ -636,8 +631,10 @@ void R_InitViewBuffer(INT32 width, INT32 height)
bufsize++; bufsize++;
temp_dc.buf = static_cast<UINT8*>(aligned_alloc(16, bufsize)); temp_dc.buf = static_cast<UINT8*>(aligned_alloc(16, bufsize));
#else #else
temp_dc.buf = static_cast<UINT8*>(Z_Calloc(bufsize, PU_STATIC, NULL)); temp_dc.buf = static_cast<UINT8*>(Z_Malloc(bufsize, PU_STATIC, NULL));
#endif #endif
memset(temp_dc.buf, 0, bufsize);
} }
/** \brief The R_VideoErase function /** \brief The R_VideoErase function
+10 -11
View File
@@ -31,7 +31,6 @@ FUNCINLINE static ATTRINLINE UINT8 *R_Address(INT32 px, INT32 py)
return vid.screens[0] + (py + viewwindowy) * vid.width + (viewwindowx + px); return vid.screens[0] + (py + viewwindowy) * vid.width + (viewwindowx + px);
} }
typedef struct { typedef struct {
float x, y, z; float x, y, z;
} floatv3_t; } floatv3_t;
@@ -164,6 +163,8 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column);
// r_draw.c // r_draw.c
// ------------------------------------------------ // ------------------------------------------------
// Custom player skin translation
#define GTC_CACHE 1 #define GTC_CACHE 1
#define GTC_MENUCACHE GTC_CACHE #define GTC_MENUCACHE GTC_CACHE
//@TODO Add a separate caching mechanism for menu colormaps distinct from in-level GTC_CACHE. For now this is still preferable to memory leaks... //@TODO Add a separate caching mechanism for menu colormaps distinct from in-level GTC_CACHE. For now this is still preferable to memory leaks...
@@ -208,8 +209,7 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel);
boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel); boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel);
// Custom player skin translation void R_InitViewBuffer(void);
void R_InitViewBuffer(INT32 width, INT32 height);
void R_VideoErase(size_t ofs, INT32 count); void R_VideoErase(size_t ofs, INT32 count);
#define TRANSPARENTPIXEL 247 #define TRANSPARENTPIXEL 247
@@ -231,17 +231,16 @@ void R_Draw2sMultiPatchColumn(drawcolumndata_t* dc);
void R_Draw2sMultiPatchTranslucentColumn(drawcolumndata_t* dc); void R_Draw2sMultiPatchTranslucentColumn(drawcolumndata_t* dc);
// column drawers which use buffered drawing with flush // column drawers which use buffered drawing with flush
void R_DrawColumnFlush(drawcolumndata_t* dc); void R_DrawColumn_Flush(drawcolumndata_t* dc);
void R_DrawTranslucentColumnFlush(drawcolumndata_t* dc); void R_DrawTranslucentColumn_Flush(drawcolumndata_t* dc);
void R_DrawTranslatedColumnFlush(drawcolumndata_t* dc); void R_DrawTranslatedColumn_Flush(drawcolumndata_t* dc);
void R_DrawColumnShadowedFlush(drawcolumndata_t* dc); void R_DrawColumnShadowed_Flush(drawcolumndata_t* dc);
void R_DrawTranslatedTranslucentColumnFlush(drawcolumndata_t* dc); void R_DrawTranslatedTranslucentColumn_Flush(drawcolumndata_t* dc);
void R_Draw2sMultiPatchColumnFlush(drawcolumndata_t* dc); void R_Draw2sMultiPatchColumn_Flush(drawcolumndata_t* dc);
void R_Draw2sMultiPatchTranslucentColumnFlush(drawcolumndata_t* dc); void R_Draw2sMultiPatchTranslucentColumn_Flush(drawcolumndata_t* dc);
void R_DrawFogColumn(drawcolumndata_t* dc); void R_DrawFogColumn(drawcolumndata_t* dc);
// span drawers // span drawers
void R_DrawSpan(drawspandata_t* ds); void R_DrawSpan(drawspandata_t* ds);
+12 -24
View File
@@ -76,14 +76,8 @@ R_DrawColumnPixel(const drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit,
} }
} }
if constexpr (Type & DrawColumnType::DC_DIRECT) // if we dont buffer our columns, we need to handle translucency again
{ // if we dont buffer our columns, we need to handle translucency again return R_GetColumnTranslucent<Type>(dc, dest, col, colormap);
return R_GetColumnTranslucent<Type>(dc, dest, col, colormap);
}
else
{
return R_GetColumnTranslated<Type>(dc, col, colormap);
}
} }
/** \brief The R_DrawColumn function /** \brief The R_DrawColumn function
@@ -358,24 +352,18 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
R_DrawColumnTemplate<opt>(dc); \ R_DrawColumnTemplate<opt>(dc); \
} }
DEFINE_COLUMN_FUNC(R_DrawColumn, DC_DIRECT|DC_BASIC) #define DEFINE_COLUMN_COMBO(name, flags) \
DEFINE_COLUMN_FUNC(R_DrawTranslucentColumn, DC_DIRECT|DC_TRANSMAP) DEFINE_COLUMN_FUNC(name, flags|DC_DIRECT) \
DEFINE_COLUMN_FUNC(R_DrawTranslatedColumn, DC_DIRECT|DC_COLORMAP) DEFINE_COLUMN_FUNC(name ## _Flush, flags)
DEFINE_COLUMN_FUNC(R_DrawColumnShadowed, DC_DIRECT|DC_LIGHTLIST)
DEFINE_COLUMN_FUNC(R_DrawTranslatedTranslucentColumn, DC_DIRECT|DC_COLORMAP|DC_TRANSMAP)
DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchColumn, DC_DIRECT|DC_HOLES)
DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchTranslucentColumn, DC_DIRECT|DC_HOLES|DC_TRANSMAP)
DEFINE_COLUMN_FUNC(R_DrawColumnFlush, DC_BASIC) DEFINE_COLUMN_COMBO(R_DrawColumn, DC_BASIC)
DEFINE_COLUMN_FUNC(R_DrawTranslucentColumnFlush, DC_TRANSMAP) DEFINE_COLUMN_COMBO(R_DrawTranslucentColumn, DC_TRANSMAP)
DEFINE_COLUMN_FUNC(R_DrawTranslatedColumnFlush, DC_COLORMAP) DEFINE_COLUMN_COMBO(R_DrawTranslatedColumn, DC_COLORMAP)
DEFINE_COLUMN_FUNC(R_DrawColumnShadowedFlush, DC_LIGHTLIST) DEFINE_COLUMN_COMBO(R_DrawColumnShadowed, DC_LIGHTLIST)
DEFINE_COLUMN_FUNC(R_DrawTranslatedTranslucentColumnFlush, DC_COLORMAP|DC_TRANSMAP) DEFINE_COLUMN_COMBO(R_DrawTranslatedTranslucentColumn, DC_COLORMAP|DC_TRANSMAP)
DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchColumnFlush, DC_HOLES) DEFINE_COLUMN_COMBO(R_Draw2sMultiPatchColumn, DC_HOLES)
DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchTranslucentColumnFlush, DC_HOLES|DC_TRANSMAP) DEFINE_COLUMN_COMBO(R_Draw2sMultiPatchTranslucentColumn, DC_HOLES|DC_TRANSMAP)
//skymyass
//DEFINE_COLUMN_FUNC(R_DrawSkyColumn, DC_SKY)
/** \brief The R_DrawFogColumn function /** \brief The R_DrawFogColumn function
Fog wall. Fog wall.
+32 -10
View File
@@ -151,23 +151,45 @@ static void R_FlushQuad(void)
INT32 count = t_dc->commonbot - t_dc->commontop + 1; INT32 count = t_dc->commonbot - t_dc->commontop + 1;
const UINT8 *restrict buf = t_dc->buf; const UINT8 *restrict buf = t_dc->buf;
const UINT8 * restrict source = buf + (t_dc->commontop << 3);
UINT8 * restrict dest = R_Address(t_dc->startx, t_dc->commontop);
if constexpr (Type & ColumnFlushType::FLUSH_OPAQUE) if constexpr (Type & ColumnFlushType::FLUSH_OPAQUE)
{ {
const INT64 *source = reinterpret_cast<const INT64 *>(buf + (t_dc->commontop << 3)); #if __SIZEOF_POINTER__ >= 8 // does not make much sense on 32bit targets
INT64 *dest = reinterpret_cast<INT64 *>(R_Address(t_dc->startx, t_dc->commontop)); // 8 byte aligned copy -- make sure our dest ptr, source ptr AND stride are a multiple of 8!
const INT32 deststep = stride / 8; if ((((uintptr_t)dest | (uintptr_t)source | stride) & 7) == 0)
while (--count >= 0)
{ {
*dest = *source++; const INT64 *source64 = reinterpret_cast<const INT64 *>(source);
dest += deststep; INT64 *dest64 = reinterpret_cast<INT64 *>(dest);
const INT32 deststep = stride / 8;
while (--count >= 0)
{
*dest64 = *source64++;
dest64 += deststep;
}
}
else
#endif
{
while (--count >= 0)
{
dest[0] = source[0];
dest[1] = source[1];
dest[2] = source[2];
dest[3] = source[3];
dest[4] = source[4];
dest[5] = source[5];
dest[6] = source[6];
dest[7] = source[7];
source += 8;
dest += stride;
}
} }
} }
else else
{ {
const UINT8 * restrict source = buf + (t_dc->commontop << 3);
UINT8 * restrict dest = R_Address(t_dc->startx, t_dc->commontop);
while (--count >= 0) while (--count >= 0)
{ {
dest[0] = R_DrawFlushPixel<Type>(t_dc, &dest[0], &source[0]); dest[0] = R_DrawFlushPixel<Type>(t_dc, &dest[0], &source[0]);
+1 -1
View File
@@ -172,7 +172,7 @@ static vector3_t *R_LerpVector3(const vector3_t *from, const vector3_t *to, fixe
// recalc necessary stuff for mouseaiming // recalc necessary stuff for mouseaiming
// slopes are already calculated for the full possible view (which is 4*viewheight). // slopes are already calculated for the full possible view (which is 4*viewheight).
// 18/08/18: (No it's actually 16*viewheight, thanks Lactozilla for finding this out) // 18/08/18: (No it's actually 16*viewheight, thanks Lactozilla for finding this out)
static void R_SetupFreelook(void) void R_SetupFreelook(void)
{ {
// clip it in the case we are looking a hardware 90 degrees full aiming // clip it in the case we are looking a hardware 90 degrees full aiming
// (lmps, network and use F12...) // (lmps, network and use F12...)
+1
View File
@@ -151,6 +151,7 @@ typedef struct levelinterpolator_s {
}; };
} levelinterpolator_t; } levelinterpolator_t;
void R_SetupFreelook(void);
// Interpolates the current view variables (r_state.h) against the selected view context in R_SetViewContext // Interpolates the current view variables (r_state.h) against the selected view context in R_SetViewContext
void R_InterpolateView(fixed_t frac, boolean forceinvalid); void R_InterpolateView(fixed_t frac, boolean forceinvalid);
// Special function just for software // Special function just for software
+5 -3
View File
@@ -63,7 +63,7 @@ size_t loopcount;
fixed_t viewx, viewy, viewz; fixed_t viewx, viewy, viewz;
angle_t viewangle, aimingangle, viewroll; angle_t viewangle, aimingangle, viewroll;
UINT8 viewssnum; UINT8 viewssnum = 0;
fixed_t viewcos, viewsin; fixed_t viewcos, viewsin;
boolean skyVisible; boolean skyVisible;
boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible for each splitscreen player boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible for each splitscreen player
@@ -88,7 +88,7 @@ INT32 viewangletox[FINEANGLES/2];
// The xtoviewangleangle[] table maps a screen pixel // The xtoviewangleangle[] table maps a screen pixel
// to the lowest viewangle that maps back to x ranges // to the lowest viewangle that maps back to x ranges
// from clipangle to -clipangle. // from clipangle to -clipangle.
angle_t *xtoviewangle; angle_t *xtoviewangle = NULL;
lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
lighttable_t *scalelightfixed[MAXLIGHTSCALE]; lighttable_t *scalelightfixed[MAXLIGHTSCALE];
@@ -960,6 +960,8 @@ void R_ExecuteSetViewSize(void)
} }
} }
R_SetupFreelook();
am_recalc = true; am_recalc = true;
} }
@@ -1003,7 +1005,7 @@ static void R_InitViewMapping(void)
static void R_SetupViewBuffers(void) static void R_SetupViewBuffers(void)
{ {
R_CalcFov(cv_fov.value); R_CalcFov(cv_fov.value);
R_InitViewBuffer(viewwidth, viewheight); R_InitViewBuffer();
R_InitViewMapping(); R_InitViewMapping();
} }
+1 -1
View File
@@ -97,7 +97,7 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y,
// Try to quickly decide by looking at sign bits. // Try to quickly decide by looking at sign bits.
// also use a mask to avoid branch prediction // also use a mask to avoid branch prediction
INT32 mask = (node->dy ^ node->dx ^ x ^ y) >> 31; INT32 mask = (((node->dy ^ node->dx ^ x ^ y) < 0) ? -1 : 0);
return (mask & ((node->dy ^ x) < 0)) | // (left is negative) return (mask & ((node->dy ^ x) < 0)) | // (left is negative)
(~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x))); (~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x)));
} }
+22 -25
View File
@@ -46,15 +46,15 @@
// good night sweet prince // good night sweet prince
//#define SHITPLANESPARENCY //#define SHITPLANESPARENCY
visplane_t *visplanes[MAXVISPLANES]; visplane_t *visplanes[MAXVISPLANES] = {};
static visplane_t *freetail; static visplane_t *freetail;
static visplane_t **freehead = &freetail; static visplane_t **freehead = &freetail;
visplane_t *floorplane; visplane_t *floorplane = NULL;
visplane_t *ceilingplane; visplane_t *ceilingplane = NULL;
visffloor_t visffloor[MAXFFLOORS]; visffloor_t visffloor[MAXFFLOORS] = {};
INT32 numffloors; INT32 numffloors = 0;
//SoM: 3/23/2000: Boom visplane hashing routine. //SoM: 3/23/2000: Boom visplane hashing routine.
#define visplane_hash(picnum,lightlevel,height) \ #define visplane_hash(picnum,lightlevel,height) \
@@ -65,8 +65,8 @@ INT32 numffloors;
// floorclip starts out SCREENHEIGHT // floorclip starts out SCREENHEIGHT
// ceilingclip starts out -1 // ceilingclip starts out -1
// //
INT16 *floorclip, *ceilingclip; INT16 *floorclip = NULL, *ceilingclip = NULL;
fixed_t *frontscale; fixed_t *frontscale = NULL;
// //
// spanstart holds the start of a plane span // spanstart holds the start of a plane span
@@ -81,13 +81,13 @@ static INT32 *spanstart;
// (this is to calculate yslopes only when really needed) // (this is to calculate yslopes only when really needed)
// (when mouselookin', yslope is moving into yslopetab) // (when mouselookin', yslope is moving into yslopetab)
// Check R_SetupFrame, R_SetViewSize for more... // Check R_SetupFrame, R_SetViewSize for more...
fixed_t *yslopetab; fixed_t *yslopetab = NULL;
fixed_t *yslope; fixed_t *yslope = NULL;
fixed_t basexscale, baseyscale; fixed_t basexscale = 0, baseyscale = 0;
static INT16 *ffloor_f_clip; static INT16 *ffloor_f_clip = NULL;
static INT16 *ffloor_c_clip; static INT16 *ffloor_c_clip = NULL;
static void R_SetTiltedSpan(drawspandata_t* ds, INT32 span); static void R_SetTiltedSpan(drawspandata_t* ds, INT32 span);
static void R_SetSlopePlaneVectors(drawspandata_t* ds, visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff); static void R_SetSlopePlaneVectors(drawspandata_t* ds, visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff);
@@ -616,14 +616,12 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop)
// //
static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(drawspandata_t*), INT32, INT32, INT32, boolean), spandrawfunc_t* localspanfunc, drawspandata_t* ds, INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2, boolean allow_parallel) static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(drawspandata_t*), INT32, INT32, INT32, boolean), spandrawfunc_t* localspanfunc, drawspandata_t* ds, INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2, boolean allow_parallel)
{ {
const INT32 vidheight = vid.height;
// Alam: from r_splats's R_RenderFloorSplat // Alam: from r_splats's R_RenderFloorSplat
if (t1 >= vidheight) t1 = vidheight-1; if (t1 >= viewheight) t1 = viewheight-1;
if (b1 >= vidheight) b1 = vidheight-1; if (b1 >= viewheight) b1 = viewheight-1;
if (t2 >= vidheight) t2 = vidheight-1; if (t2 >= viewheight) t2 = viewheight-1;
if (b2 >= vidheight) b2 = vidheight-1; if (b2 >= viewheight) b2 = viewheight-1;
if (x-1 >= vid.width) x = vid.width; if (x-1 >= viewwidth) x = viewwidth;
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
// We want to draw N spans per subtask to ensure the work is // We want to draw N spans per subtask to ensure the work is
@@ -739,7 +737,7 @@ void R_DrawPlanes(void)
#endif #endif
} }
static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), boolean allow_parallel); static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), boolean allow_parallel);
void R_DrawSkyPlanes(void) void R_DrawSkyPlanes(void)
{ {
@@ -774,7 +772,7 @@ void R_DrawSkyPlanes(void)
#endif #endif
} }
static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), boolean allow_parallel) static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), boolean allow_parallel)
{ {
INT32 x; INT32 x;
@@ -834,7 +832,7 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), b
dc.x = x + i; dc.x = x + i;
dc.source = R_GetColumn(texture, -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 dc.source = R_GetColumn(texture, -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
colfunc2(&dc); skycolfunc(&dc);
} }
}; };
@@ -868,10 +866,9 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), b
dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT));
dc.x = x; dc.x = x;
dc.source = dc.source =
R_GetColumn(texturetranslation[skytexture], R_GetColumn(texturetranslation[skytexture], -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
-angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
colfunc2(&dc); skycolfunc(&dc);
} }
#endif #endif
} }
+4 -4
View File
@@ -2236,7 +2236,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz; lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz;
highcutslope = std::min(worldtopslope, worldhighslope) + viewz; highcutslope = std::min(worldtopslope, worldhighslope) + viewz;
auto check_fof_offscreen = [&](INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope) auto check_fof_offscreen = [&](ffloor_t* rover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope)
{ {
return ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= bottom + viewz return ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= bottom + viewz
&& P_GetFFloorTopZAt (rover, segright.x, segright.y) <= bottomslope + viewz) && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= bottomslope + viewz)
@@ -2376,7 +2376,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
continue; continue;
// Oy vey. // Oy vey.
if (check_fof_offscreen(worldbottom, worldbottomslope, worldtop, worldtopslope)) if (check_fof_offscreen(rover, worldbottom, worldbottomslope, worldtop, worldtopslope))
continue; continue;
ds_p->thicksides[i] = rover; ds_p->thicksides[i] = rover;
@@ -2394,10 +2394,10 @@ void R_StoreWallRange(INT32 start, INT32 stop)
continue; continue;
// Oy vey. // Oy vey.
if (check_fof_offscreen(worldbottom, worldbottomslope, worldtop, worldtopslope)) if (check_fof_offscreen(rover, worldbottom, worldbottomslope, worldtop, worldtopslope))
continue; continue;
if (check_fof_offscreen(worldlow, worldlowslope, worldhigh, worldhighslope)) if (check_fof_offscreen(rover, worldlow, worldlowslope, worldhigh, worldhighslope))
continue; continue;
ds_p->thicksides[i] = rover; ds_p->thicksides[i] = rover;
+8
View File
@@ -35,6 +35,8 @@
CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2];
#include "discord.h"
INT32 numskins = 0; INT32 numskins = 0;
INT32 numallskins = 0; INT32 numallskins = 0;
INT32 numlocalskins = 0; INT32 numlocalskins = 0;
@@ -328,8 +330,14 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
if (player->mo) if (player->mo)
P_SetScale(player->mo, player->mo->scale); P_SetScale(player->mo, player->mo->scale);
// for replays: We have changed our skin mid-game; let the game know so it can do the same in the replay!
demo_extradata[playernum] |= DXD_SKIN; demo_extradata[playernum] |= DXD_SKIN;
#ifdef HAVE_DISCORDRPC
if (player - players == consoleplayer)
DRPC_UpdatePresence();
#endif
return; return;
} }
+22 -27
View File
@@ -43,13 +43,6 @@
#define MINZ (FRACUNIT*16) #define MINZ (FRACUNIT*16)
#define BASEYCENTER (BASEVIDHEIGHT/2) #define BASEYCENTER (BASEVIDHEIGHT/2)
typedef struct
{
INT32 x1, x2;
INT32 column;
INT32 topclip, bottomclip;
} maskdraw_t;
// //
// Sprite rotation 0 is facing the viewer, // Sprite rotation 0 is facing the viewer,
// rotation 1 is one angle turn CLOCKWISE around the axis. // rotation 1 is one angle turn CLOCKWISE around the axis.
@@ -60,8 +53,8 @@ typedef struct
static lighttable_t **spritelights; static lighttable_t **spritelights;
// constant arrays used for psprite clipping and initializing clipping // constant arrays used for psprite clipping and initializing clipping
INT16 *negonearray; INT16 *negonearray = NULL;
INT16 *screenheightarray; INT16 *screenheightarray = NULL;
// //
// INITIALIZATION FUNCTIONS // INITIALIZATION FUNCTIONS
@@ -539,8 +532,8 @@ void R_ClearSprites(void)
visspritecount = numvisiblesprites = clippedvissprites = 0; visspritecount = numvisiblesprites = clippedvissprites = 0;
} }
static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS]; static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0};
static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS]; static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0};
static void R_AllocVisSpriteChunkMemory(UINT32 chunk) static void R_AllocVisSpriteChunkMemory(UINT32 chunk)
{ {
@@ -574,16 +567,16 @@ static vissprite_t overflowsprite;
static vissprite_t *R_GetVisSprite(UINT32 num) static vissprite_t *R_GetVisSprite(UINT32 num)
{ {
UINT32 chunk = num >> VISSPRITECHUNKBITS; UINT32 chunk = num >> VISSPRITECHUNKBITS;
// Allocate chunk if necessary // Allocate chunk if necessary
if (!visspritechunks[chunk]) if (!visspritechunks[chunk])
{ {
Z_Malloc(sizeof(vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &visspritechunks[chunk]); Z_Malloc(sizeof(vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &visspritechunks[chunk]);
R_AllocVisSpriteChunkMemory(chunk); R_AllocVisSpriteChunkMemory(chunk);
} }
return visspritechunks[chunk] + (num & VISSPRITEINDEXMASK); return visspritechunks[chunk] + (num & VISSPRITEINDEXMASK);
} }
static vissprite_t *R_NewVisSprite(void) static vissprite_t *R_NewVisSprite(void)
@@ -600,8 +593,8 @@ static vissprite_t *R_NewVisSprite(void)
// Masked means: partly transparent, i.e. stored // Masked means: partly transparent, i.e. stored
// in posts/runs of opaque pixels. // in posts/runs of opaque pixels.
// //
INT16 *mfloorclip; INT16 *mfloorclip = NULL;
INT16 *mceilingclip; INT16 *mceilingclip = NULL;
fixed_t spryscale = 0, sprtopscreen = 0, sprbotscreen = 0; fixed_t spryscale = 0, sprtopscreen = 0, sprbotscreen = 0;
fixed_t windowtop = 0, windowbottom = 0; fixed_t windowtop = 0, windowbottom = 0;
@@ -730,7 +723,6 @@ static void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column)
dc->texturemid = basetexturemid; dc->texturemid = basetexturemid;
} }
// Based off of R_GetLinedefTransTable // Based off of R_GetLinedefTransTable
transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap) transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap)
{ {
@@ -2801,11 +2793,6 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal)
drawseg_t* ds; drawseg_t* ds;
INT32 i; INT32 i;
if (visspritecount - clippedvissprites <= 0)
{
return;
}
// e6y // e6y
// Reducing of cache misses in the following R_DrawSprite() // Reducing of cache misses in the following R_DrawSprite()
// Makes sense for scenes with huge amount of drawsegs. // Makes sense for scenes with huge amount of drawsegs.
@@ -2815,6 +2802,11 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal)
drawsegs_xranges[i].count = 0; drawsegs_xranges[i].count = 0;
} }
if (visspritecount - clippedvissprites <= 0)
{
return;
}
if (drawsegs_xrange_size < maxdrawsegs) if (drawsegs_xrange_size < maxdrawsegs)
{ {
// haleyjd: fix reallocation to track 2x size // haleyjd: fix reallocation to track 2x size
@@ -3064,6 +3056,9 @@ void R_DrawMasked(maskcount_t* masks, INT32 nummasks)
heads = static_cast<drawnode_t*>(calloc(nummasks, sizeof(drawnode_t))); heads = static_cast<drawnode_t*>(calloc(nummasks, sizeof(drawnode_t)));
if (!heads)
I_Error("R_DrawMasked: No more free memory\n");
for (i = 0; i < nummasks; i++) for (i = 0; i < nummasks; i++)
{ {
heads[i].next = heads[i].prev = &heads[i]; heads[i].next = heads[i].prev = &heads[i];
+7 -7
View File
@@ -101,13 +101,13 @@ static void SCR_SetDrawFuncs(enum columncontext_e _columncontext)
if (_columncontext == COLUMNCONTEXT_FLUSH) if (_columncontext == COLUMNCONTEXT_FLUSH)
{ {
colfuncs[BASEDRAWFUNC] = R_DrawColumnFlush; colfuncs[BASEDRAWFUNC] = R_DrawColumn_Flush;
colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumnFlush; colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_Flush;
colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumnFlush; colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn_Flush;
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowedFlush; colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed_Flush;
colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumnFlush; colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn_Flush;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumnFlush; colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_Flush;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumnFlush; colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn_Flush;
} }
else else
{ {
+2 -2
View File
@@ -790,7 +790,7 @@ void ST_Drawer(void)
LUA_HUD_DrawList(luahuddrawlist_game[i]); LUA_HUD_DrawList(luahuddrawlist_game[i]);
// draw Midnight Channel's overlay ontop // draw Midnight Channel's overlay ontop
if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff. if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff.
ST_MayonakaStatic(); ST_MayonakaStatic();
} }
@@ -798,7 +798,7 @@ void ST_Drawer(void)
if (timeinmap < 15) if (timeinmap < 15)
{ {
if (timeinmap <= 5) if (timeinmap <= 5)
V_DrawFill(0,0,BASEVIDWIDTH,BASEVIDHEIGHT,120); // Pure white on first few frames, to hide SRB2's awful level load artifacts V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 120); // Pure white on first few frames, to hide SRB2's awful level load artifacts
else else
V_DrawFadeScreen(120, 15-timeinmap); // Then gradually fade out from there V_DrawFadeScreen(120, 15-timeinmap); // Then gradually fade out from there
} }
+21 -3
View File
@@ -3094,6 +3094,9 @@ INT32 V_SubStringWidth(const char *string, INT32 length, INT32 option)
INT32 spacewidth = 4, charwidth = 0; INT32 spacewidth = 4, charwidth = 0;
ssize_t i; ssize_t i;
if (!string)
return 0;
if (length < 0) if (length < 0)
length = strlen(string); length = strlen(string);
@@ -3136,6 +3139,9 @@ INT32 V_SmallSubStringWidth(const char *string, INT32 length, INT32 option)
INT32 spacewidth = 2, charwidth = 0; INT32 spacewidth = 2, charwidth = 0;
ssize_t i; ssize_t i;
if (!string)
return 0;
if (length < 0) if (length < 0)
length = strlen(string); length = strlen(string);
@@ -3176,9 +3182,14 @@ INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option)
{ {
INT32 c, w = 0; INT32 c, w = 0;
INT32 spacewidth = 2, charwidth = 0; INT32 spacewidth = 2, charwidth = 0;
boolean lowercase = (option & V_ALLOWLOWERCASE); boolean lowercase;
ssize_t i; ssize_t i;
if (!string)
return 0;
lowercase = (option & V_ALLOWLOWERCASE);
if (length < 0) if (length < 0)
length = strlen(string); length = strlen(string);
@@ -3233,6 +3244,9 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option)
INT32 spacewidth = 4, charwidth = 0; INT32 spacewidth = 4, charwidth = 0;
INT32 i; INT32 i;
if (!string)
return 0;
switch (option & V_SPACINGMASK) switch (option & V_SPACINGMASK)
{ {
case V_MONOSPACE: case V_MONOSPACE:
@@ -3814,11 +3828,15 @@ void V_Init(void)
for (i = 0; i < NUMSCREENS; i++) for (i = 0; i < NUMSCREENS; i++)
{ {
if (vid.screens[i])
{
#if defined(__SSE__) #if defined(__SSE__)
aligned_free(vid.screens[i]); aligned_free(vid.screens[i]);
#else #else
free(vid.screens[i]); free(vid.screens[i]);
#endif #endif
}
vid.screens[i] = NULL; vid.screens[i] = NULL;
} }
+1
View File
@@ -0,0 +1 @@
win_dbg.c