From 819b171d903c30e7145bda9615996b8c66c2c3f7 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 28 Aug 2026 00:44:44 +0300 Subject: [PATCH 1/8] Do a full garbage collection after LUA_InvalidateLevel --- src/lua_script.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 14cdee2d7..0db0bd1e0 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -623,6 +623,10 @@ void LUA_InvalidateLevel(void) LUA_InvalidateUserdata(&slope->o); LUA_InvalidateUserdata(&slope->d); } + + // We invalidated a lot of userdata objects, a lot of them probably ended up unreachable so they can be + // GC'd right away + lua_gc(gL, LUA_GCCOLLECT, 0); } void LUA_InvalidateMapthings(void) From ade7db900429ff7011f286aea6ee9a10db413bc5 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Sep 2026 14:09:23 +0200 Subject: [PATCH 2/8] fix replayhut exploding due to sega fishe "sega_bass_fishin" is exactly 16 characters which caused stuff to not be terminated --- src/g_demo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/g_demo.c b/src/g_demo.c index 049cf4bfd..d39bbaec7 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2335,7 +2335,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) while (READUINT8(extrainfo_p) == DW_STANDING) // Assume standings are always first in the extrainfo { INT32 i; - char temp[16]; + char temp[17]; pdemo->standings[count].ranking = READUINT8(extrainfo_p); @@ -2345,6 +2345,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) // Skin memcpy(temp, extrainfo_p, 16); + temp[16] = '\0'; extrainfo_p += 16; pdemo->standings[count].skin = UINT8_MAX; @@ -2359,6 +2360,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) // Color memcpy(temp, extrainfo_p, 16); + temp[16] = '\0'; extrainfo_p += 16; for (i = 0; i < MAXSKINCOLORS; i++) From 24e5b1d84bb6c7199fc4912163f2b2e2bc293c4c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Sep 2026 14:40:40 +0200 Subject: [PATCH 3/8] fix buffer overflow when opening "Advanced Color Options" idk if this is the intended thing, but works fine --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 3c9779d65..d0a2b661e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10060,7 +10060,7 @@ static void M_DrawColorMenu(void) for (max = currentMenu->numitems; max > 0; max--) { - if (currentMenu->menuitems[max].status != IT_DISABLED && currentMenu->menuitems[max-1].alphaKey*2 + tempcentery <= (currentMenu->y + 2*scrollareaheight)) + if (currentMenu->menuitems[max-1].status != IT_DISABLED && currentMenu->menuitems[max-1].alphaKey*2 + tempcentery <= (currentMenu->y + 2*scrollareaheight)) break; } From a6e5edabd2adb75dc068b72c77ca4056ccfd96df Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Sep 2026 15:05:32 +0200 Subject: [PATCH 4/8] fix M_TextInputSetString not null terminating in some cases if input string is longer than the buffer this may never be null terminated properly --- src/m_textinput.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_textinput.c b/src/m_textinput.c index 0d68b2b5d..9e1819b6a 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -238,8 +238,8 @@ void M_TextInputClear(textinput_t *input) void M_TextInputSetString(textinput_t *input, const char *c) { - memset(input->buffer, 0, input->buffer_size); - strncpy(input->buffer, c, input->buffer_size); + strncpy(input->buffer, c, input->buffer_size-1); + input->buffer[input->buffer_size-1] = '\0'; input->cursor = input->select = input->length = strlen(input->buffer); } From ac87678708072452e0e4876a5b5a0761c18855e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Sep 2026 18:46:44 +0200 Subject: [PATCH 5/8] rename COMPAT_VANILLA to PHOBOS_BUILD have a distinct name for that build "Phobos", as a nod to Doom also invert the flag, as it should make adding stuff less headachey will make this a compiler flag later but too lazy atm --- src/doomdef.h | 39 +++++++++++++++++++++++++-------------- src/info.h | 6 +++--- src/p_local.h | 6 +++--- src/p_saveg.c | 10 +++++----- src/p_setup.c | 8 ++++---- src/p_spec.c | 2 +- src/p_tick.c | 2 +- 7 files changed, 42 insertions(+), 31 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index e4dd2ba65..269e9a416 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -130,8 +130,17 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Saturn v10" -#define VERSIONSTRINGW L"Saturn v10" + +#ifdef PHOBOS_BUILD +#define CLIENTNAME "Phobos" +#define CLIENTNAMEW L"Phobos" +#else +#define CLIENTNAME "Saturn" +#define CLIENTNAMEW L"Saturn" +#endif + +#define VERSIONSTRING CLIENTNAME " v10" +#define VERSIONSTRINGW CLIENTNAMEW L" v10" #define SATURN_TESTING // comment out for saturn release builds! @@ -602,11 +611,20 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! -// undefine to enable fixes and features that are not vanilla compatible -#define COMPAT_VANILLA -// if we build with 32 player (or more or less!) support we dont need to care about vanilla compat -#if MAXPLAYERS != 16 -#undef COMPAT_VANILLA +// TODO: make this a compile flag! +// define to enable fixes and features that are not vanilla compatible +//#define PHOBOS_BUILD + +#ifdef PHOBOS_BUILD +// compiler cries otherwise :chaosleep: +#undef MAXPLAYERS +// we want 32 players yesss +#define MAXPLAYERS 32 + +// overwrite some of those +// when not compiling in vanilla compat mode +#define SATURNJOIN +#define SATURNPAK #endif //-- SATURN __ @@ -673,13 +691,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #undef UPDATE_ALERT #endif -// overwrite some of those -// when not compiling in vanilla compat mode -#ifndef COMPAT_VANILLA - #define SATURNJOIN - #define SATURNPAK -#endif - #ifdef __cplusplus } // extern "C" #endif diff --git a/src/info.h b/src/info.h index 59dd2daca..2baae10c2 100644 --- a/src/info.h +++ b/src/info.h @@ -452,10 +452,10 @@ void A_SpawnFreshCopy(void *actor); extern boolean actionsoverridden[NUMACTIONS]; // ratio of states to sprites to mobj types is roughly 6 : 1 : 1 -#ifdef COMPAT_VANILLA -#define NUMMOBJFREESLOTS 1024 -#else +#ifdef PHOBOS_BUILD #define NUMMOBJFREESLOTS 4096 // should be sufficient +#else +#define NUMMOBJFREESLOTS 1024 #endif #define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS #define NUMSTATEFREESLOTS (NUMMOBJFREESLOTS*8) diff --git a/src/p_local.h b/src/p_local.h index 1198335ec..4f59246fc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -295,10 +295,10 @@ FUNCINLINE static ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj) // so can only check if its not NULL in vanilla compat mode FUNCINLINE static ATTRINLINE boolean P_MobjWasRemovedCompat(const mobj_t *mobj) { -#ifdef COMPAT_VANILLA - return (!mobj); -#else +#ifdef PHOBOS_BUILD return P_MobjWasRemoved(mobj); +#else + return !mobj; #endif } diff --git a/src/p_saveg.c b/src/p_saveg.c index 8c69d58c6..23967cab1 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1108,10 +1108,10 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 diff2 = 0; // not the default but the most probable -#ifdef COMPAT_VANILLA - if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0) -#else +#ifdef PHOBOS_BUILD if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0 || mobj->pmomz !=0) +#else + if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0) #endif diff |= MD_MOM; if (mobj->radius != mobj->info->radius) @@ -1240,7 +1240,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 WRITEFIXED(save->p, mobj->momx); WRITEFIXED(save->p, mobj->momy); WRITEFIXED(save->p, mobj->momz); -#ifndef COMPAT_VANILLA +#ifdef PHOBOS_BUILD WRITEFIXED(save->p, mobj->pmomz); #endif } @@ -2062,7 +2062,7 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->momx = READFIXED(save->p); mobj->momy = READFIXED(save->p); mobj->momz = READFIXED(save->p); -#ifndef COMPAT_VANILLA +#ifdef PHOBOS_BUILD mobj->pmomz = READFIXED(save->p); #endif } // otherwise they're zero, and the memset took care of it diff --git a/src/p_setup.c b/src/p_setup.c index 8dc28f359..2201c0b9f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2074,14 +2074,14 @@ static void P_LoadReject(UINT8 *data, size_t rejectsize) if (rejectsize < neededsize) { CorruptMapWarning(va("P_LoadReject: REJECT is %s byte%s too small. REJECT might be invalid!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s")); -#ifdef COMPAT_VANILLA +#ifdef PHOBOS_BUILD + rejectmatrix = NULL; + return; +#else // we can pad this and somewhat prevent desyncs // probs not cool if the reject is from a completely different map // but whatever allocsize = neededsize; -#else - rejectmatrix = NULL; - return; #endif } diff --git a/src/p_spec.c b/src/p_spec.c index 1ae50c614..8b526798e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4604,7 +4604,7 @@ void P_UpdateSpecials(void) // POINT LIMIT P_CheckPointLimit(); -#ifdef COMPAT_VANILLA +#ifndef PHOBOS_BUILD // Dynamic slopeness // we run this here only when not joined midrace // for vanilla compat reasons :chaosleep: diff --git a/src/p_tick.c b/src/p_tick.c index 455a8d5ac..645d7dd31 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -651,7 +651,7 @@ void P_Ticker(boolean run) if (run) { // Dynamic slopeness -#ifdef COMPAT_VANILLA +#ifndef PHOBOS_BUILD if (midgamejoin) // only run here if we joined midgame to fix some desynchs #endif P_RunDynamicSlopes(); From 4c3fa7d8260c3eefeab7ebab9594b19c303fd339 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Sep 2026 19:21:18 +0200 Subject: [PATCH 6/8] raise numlap limit to 255 for phobos client idk but this was wanted --- src/d_netcmd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f05668c8f..f68837052 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -435,10 +435,18 @@ consvar_t cv_pointlimit = {"pointlimit", "0", CV_NETVAR|CV_CALL|CV_NOINIT, point static CV_PossibleValue_t timelimit_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; consvar_t cv_timelimit = {"timelimit", "0", CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, TimeLimit_OnChange, 0, NULL, NULL, 0, 0, NULL}; +#ifdef PHOBOS_BUILD +static CV_PossibleValue_t numlaps_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; +#else static CV_PossibleValue_t numlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, NULL}}; +#endif consvar_t cv_numlaps = {"numlaps", "3", CV_NETVAR|CV_CALL|CV_NOINIT, numlaps_cons_t, NumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL}; +#ifdef PHOBOS_BUILD +static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, "Map default"}, {0, NULL}}; +#else static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, "Map default"}, {0, NULL}}; +#endif consvar_t cv_basenumlaps = {"basenumlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_forceskin = {"forceskin", "Off", CV_NETVAR|CV_CALL|CV_CHEAT, Forceskin_cons_t, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL}; From efc0681e0144b5a34ccac1db9b4c059deb89e589 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Sep 2026 19:29:32 +0200 Subject: [PATCH 7/8] make PHOBOS_BUILD a compile flag pass PHOBOS_BUILD=1 to build --- src/CMakeLists.txt | 7 +++++++ src/Makefile | 4 ++++ src/Makefile.d/features.mk | 1 + src/doomdef.h | 8 ++------ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 28f48cdad..c763ab3b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -257,6 +257,9 @@ set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL "Enable hardware renderer (OpenGL) FBO downsampling support") +set(SRB2_CONFIG_PHOBOS ON CACHE BOOL + " Compile the Phobos client. Which contains things not compatible with vanilla, such as raised skinlimits, 32 player support, bugfixes, etc.") + if(${SRB2_CONFIG_DEDICATED}) set(SRB2_CONFIG_HAVE_GME NO) set(SRB2_CONFIG_HAVE_OPENMPT NO) @@ -583,6 +586,10 @@ if(${SRB2_CONFIG_SATURNJOIN}) add_definitions(-DDOSATURNJOIN) endif() +if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_SCREENFBO}) + add_definitions(-DPHOBOS_BUILD) +endif() + # Targets # Compatibility flag with later versions of GCC diff --git a/src/Makefile b/src/Makefile index 5b1f9f0fa..27831946a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -65,6 +65,10 @@ # DEBUGMODE=1 - Enable various debugging capabilities. # Also disables optimizations. # +# PHOBOS_BUILD=1 - Compile the Phobos client. +# Contains things not compatible with vanilla. +# such as raised skinlimits, 32 player support, bugfixes, etc. +# # Development flags: # # VALGRIND=1 - Enable Valgrind memory debugging support. diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index af67a5494..6a63c9972 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -9,6 +9,7 @@ passthru_opts+=\ HAVE_DISCORDRPC DEVELOP\ NOHOLEPUNCH\ HAVE_IPV6\ + PHOBOS_BUILD\ # build with debugging information ifdef DEBUGMODE diff --git a/src/doomdef.h b/src/doomdef.h index 269e9a416..8b205cf51 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -611,16 +611,12 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! -// TODO: make this a compile flag! -// define to enable fixes and features that are not vanilla compatible -//#define PHOBOS_BUILD - #ifdef PHOBOS_BUILD -// compiler cries otherwise :chaosleep: -#undef MAXPLAYERS // we want 32 players yesss +#undef MAXPLAYERS #define MAXPLAYERS 32 + // overwrite some of those // when not compiling in vanilla compat mode #define SATURNJOIN From 521544f6ba2b4817d86975f1decb8ca8566ac942 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Sep 2026 19:32:48 +0200 Subject: [PATCH 8/8] raise skinlimit to 1024 for phobos build not thoroughly tested by me, so might still be incomplete --- src/byteptr.h | 9 +++++++++ src/d_clisrv.c | 21 ++++++++++++++++++--- src/d_clisrv.h | 10 ++++++++-- src/d_netcmd.c | 8 +++++--- src/doomdef.h | 3 +++ src/doomtype.h | 6 ++++++ src/g_demo.h | 3 ++- src/g_game.c | 2 +- src/g_state.h | 3 ++- src/m_menu.c | 28 ++++++++++++++-------------- src/m_menu.h | 4 ++-- src/p_saveg.c | 32 ++++++++++++++++++++++++++------ src/p_saveg.h | 4 ++-- src/r_skins.c | 12 ++++++------ src/r_skins.h | 6 +++--- 15 files changed, 107 insertions(+), 44 deletions(-) diff --git a/src/byteptr.h b/src/byteptr.h index 0c82e6f40..558235a44 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -206,6 +206,15 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) p += n; \ } while (0) + +#ifdef PHOBOS_BUILD +#define WRITESKIN(p,b) WRITEUINT16(p,b) +#define READSKIN(p) READUINT16(p) +#else +#define WRITESKIN(p,b) WRITEUINT8(p,b) +#define READSKIN(p) READUINT8(p) +#endif + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c61ef182d..5a87b6da0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1125,7 +1125,7 @@ static cl_mode_t cl_mode = CL_SEARCHING; static UINT16 cl_lastcheckedfilecount = 0; // used for full file list // Player name send/load - +#ifndef PHOBOS_BUILD static void CV_SavePlayerNames(UINT8 **p) { INT32 i = 0; @@ -1161,6 +1161,7 @@ static void CV_LoadPlayerNames(UINT8 **p) memcpy(player_names[i], tmp_name, MAXPLAYERNAME+1); } } +#endif static void CL_DrawAddonTypes(void) { @@ -1772,7 +1773,7 @@ static void SV_SendPlayerInfo(INT32 node) // doesent really matter what we put here lel netbuffer->u.playerinfo[0].score = LONG(42069); netbuffer->u.playerinfo[0].timeinserver = SHORT(42069); - netbuffer->u.playerinfo[0].skin = (UINT8)1; // no clue wtf skin 1 is, tails maybe? + netbuffer->u.playerinfo[0].skin = (skinnum_t)1; // no clue wtf skin 1 is, tails maybe? netbuffer->u.playerinfo[0].data = 0; @@ -1817,7 +1818,7 @@ static void SV_SendPlayerInfo(INT32 node) netbuffer->u.playerinfo[i].score = LONG(players[i].score); netbuffer->u.playerinfo[i].timeinserver = SHORT((UINT16)(players[i].jointime / TICRATE)); - netbuffer->u.playerinfo[i].skin = (UINT8)players[i].skin; + netbuffer->u.playerinfo[i].skin = (skinnum_t)players[i].skin; // Extra data // Kart has extra skincolors, so we can't use this @@ -1927,8 +1928,10 @@ static void SV_SendMapIcon(INT32 node) */ static boolean SV_SendServerConfig(INT32 node) { +#ifndef PHOBOS_BUILD INT32 i; UINT8 *p, *op; +#endif boolean waspacketsent; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); @@ -1946,6 +1949,7 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.gametype = (UINT8)gametype; netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; +#ifndef PHOBOS_BUILD // we fill these structs with FFs so that any players not in game get sent as 0xFFFF // which is nice and easy for us to detect memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); @@ -1961,6 +1965,7 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; } +#endif netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); netbuffer->u.servercfg.allownewplayer = cv_allownewplayer.value; @@ -1968,12 +1973,16 @@ static boolean SV_SendServerConfig(INT32 node) memcpy(netbuffer->u.servercfg.server_context, server_context, 8); +#ifdef PHOBOS_BUILD + const size_t len = sizeof(serverconfig_pak); +#else op = p = netbuffer->u.servercfg.varlengthinputs; CV_SavePlayerNames(&p); CV_SaveNetVars(&p, false); const size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); +#endif #ifdef DEBUGFILE if (debugfile) @@ -5414,8 +5423,10 @@ static void PT_ServerRefuse(SINT8 node) // Positive response of client join request static void PT_ServerCFG(SINT8 node) { +#ifndef PHOBOS_BUILD INT32 j; UINT8 *scp; +#endif if (server && serverrunning && node != servernode) { // but wait I thought I'm the server? @@ -5438,8 +5449,10 @@ static void PT_ServerCFG(SINT8 node) if ((gametype = netbuffer->u.servercfg.gametype) >= NUMGAMETYPES) I_Error("Bad gametype %d in cliserv!", gametype); modifiedgame = netbuffer->u.servercfg.modifiedgame; +#ifndef PHOBOS_BUILD for (j = 0; j < MAXPLAYERS; j++) adminplayers[j] = netbuffer->u.servercfg.adminplayers[j]; +#endif memcpy(server_context, netbuffer->u.servercfg.server_context, 8); } @@ -5465,6 +5478,7 @@ static void PT_ServerCFG(SINT8 node) SendSaturnInfo(node); #endif +#ifndef PHOBOS_BUILD memset(playeringame, 0, sizeof(playeringame)); for (j = 0; j < MAXPLAYERS; j++) @@ -5481,6 +5495,7 @@ static void PT_ServerCFG(SINT8 node) scp = netbuffer->u.servercfg.varlengthinputs; CV_LoadPlayerNames(&scp); scp += CV_LoadNetVars(scp); +#endif /// \note Wait. What if a Lua script uses some global custom variables synched with the NetVars hook? /// Shouldn't them be downloaded even at intermission time? diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 29a33e351..16602976c 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -339,13 +339,17 @@ typedef struct UINT8 clientnode; UINT8 gamestate; +#ifndef PHOBOS_BUILD // 0xFF == not in game; else player skin num UINT8 playerskins[MAXPLAYERS]; UINT8 playercolor[MAXPLAYERS]; +#endif UINT8 gametype; UINT8 modifiedgame; +#ifndef PHOBOS_BUILD SINT8 adminplayers[MAXPLAYERS]; // Needs to be signed +#endif char server_context[8]; // Unique context id, generated at server startup. @@ -354,7 +358,9 @@ typedef struct boolean allownewplayer; boolean discordinvites; +#ifndef PHOBOS_BUILD UINT8 varlengthinputs[0]; // Playernames and netvars +#endif } ATTRPACK serverconfig_pak; typedef struct { @@ -444,7 +450,7 @@ typedef struct char name[MAXPLAYERNAME+1]; UINT8 address[4]; // sending another string would run us up against MAXPACKETLENGTH UINT8 team; - UINT8 skin; + skinnum_t skin; UINT8 data; // Color is first four bits, hasflag, isit and issuper have one bit each, the last is unused. UINT32 score; UINT16 timeinserver; // In seconds. @@ -454,7 +460,7 @@ typedef struct typedef struct { char name[MAXPLAYERNAME+1]; - UINT8 skin; + skinnum_t skin; UINT8 color; UINT32 pflags; UINT32 score; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f68837052..f0ebc5fc4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1689,7 +1689,8 @@ static void SendNameAndColor(UINT8 splitplayer) // Finally write out the complete packet and send it off. WRITESTRINGN(p, playername->zstring, MAXPLAYERNAME); WRITEUINT8(p, (UINT8)playercolor->value); - WRITEUINT8(p, (UINT8)playerskin->value); + WRITESKIN(p, (skinnum_t)playerskin->value); + SendNetXCmdForPlayer(splitplayer, XD_NAMEANDCOLOR, buf, p - buf); } @@ -1697,7 +1698,8 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) { player_t *player; char name[MAXPLAYERNAME+1] = {}; - UINT8 color, skin; + UINT8 color; + skinnum_t skin; #ifdef PARANOIA if (playernum < 0 || playernum > MAXPLAYERS) @@ -1719,7 +1721,7 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) READSTRINGN(*cp, name, MAXPLAYERNAME); color = READUINT8(*cp); - skin = READUINT8(*cp); + skin = READSKIN(*cp); // set name if (player_name_changes[playernum] < MAXNAMECHANGES) diff --git a/src/doomdef.h b/src/doomdef.h index 8b205cf51..5a62d0a86 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -616,6 +616,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #undef MAXPLAYERS #define MAXPLAYERS 32 +// raise skinlimit to 1024 +#undef MAXSKINS +#define MAXSKINS 1024 // overwrite some of those // when not compiling in vanilla compat mode diff --git a/src/doomtype.h b/src/doomtype.h index 7d6017e27..2b5319bc2 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -42,6 +42,12 @@ extern "C" { #define INT64 int64_t #define UINT64 uint64_t +#ifdef PHOBOS_BUILD +typedef uint16_t skinnum_t; +#else +typedef uint8_t skinnum_t; +#endif + #ifdef __APPLE_CC__ #define DEBUG_LOG #define NOIPX diff --git a/src/g_demo.h b/src/g_demo.h index 5e430a2e8..280185ce6 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -82,7 +82,8 @@ typedef struct menudemo_s { struct { UINT8 ranking; char name[17]; - UINT8 skin, color; + skinnum_t skin; + UINT8 color; UINT32 timeorscore; } standings[MAXPLAYERS]; } menudemo_t; diff --git a/src/g_game.c b/src/g_game.c index c133050d8..b8c9a2530 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -63,7 +63,7 @@ gameaction_t gameaction = 0; gamestate_t gamestate = GS_NULL; boolean botingame = false; -UINT8 botskin = 0; +skinnum_t botskin = 0; UINT8 botcolor = 0; // SRB2kart diff --git a/src/g_state.h b/src/g_state.h index 02d876d49..fd3d7f062 100644 --- a/src/g_state.h +++ b/src/g_state.h @@ -55,6 +55,7 @@ extern gamestate_t gamestate; extern gameaction_t gameaction; extern boolean botingame; -extern UINT8 botskin, botcolor; +extern skinnum_t botskin; +extern UINT8 botcolor; #endif //__G_STATE__ diff --git a/src/m_menu.c b/src/m_menu.c index d0a2b661e..4a8344b3d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6451,7 +6451,7 @@ static void M_ChooseTimeAttack(INT32 choice) else G_RecordDemo(nameofdemo); - G_DeferedInitNew(false, mapname, (UINT8)(cv_chooseskin.value-1), 0, false); + G_DeferedInitNew(false, mapname, (skinnum_t)(cv_chooseskin.value-1), 0, false); } static void M_HandleStaffReplay(INT32 choice) @@ -7677,7 +7677,7 @@ static void M_DrawMPMainMenu(void) #define iconwidth 32 #define spacingwidth 32 #define incrwidth (iconwidth + spacingwidth) - UINT8 i = 0, pskin, pcol; + UINT16 i = 0, pskin, pcol; // player arrangement width, but there's also a chance i'm a furry, shhhhhh const INT32 paw = iconwidth + 3*incrwidth; INT32 trans = 0; @@ -7930,16 +7930,16 @@ static void M_DrawSetupMultiPlayerMenu(void) spritedef_t *sprdef; spriteframe_t *sprframe; patch_t *patch; - UINT8 frame; - UINT8 speed; - UINT8 weight; - UINT8 i; - UINT8 s, w; + UINT16 frame; + UINT16 speed; + UINT16 weight; + UINT16 i; + UINT16 s, w; INT32 skinnum = 0; INT32 statx, staty; UINT32 speenframe; INT32 sltw, actw, hetw; - UINT8 skintodisplay; + skinnum_t skintodisplay; INT32 nameboxaddy = 0; const UINT8 *flashcol = V_GetStringColormap(highlightflags); @@ -7996,7 +7996,7 @@ static void M_DrawSetupMultiPlayerMenu(void) break; case SKINMENUTYPE_2D: - skintodisplay = setupm_fakeskin; + skintodisplay = (skinnum_t)setupm_fakeskin; if (setupm_skinlockedselect) //show the skin we are trying to select skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect]; else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1) @@ -8376,7 +8376,7 @@ static void M_DrawSetupMultiPlayerMenu(void) colwidth = colwidth - 10; INT32 j = -colwidth; - INT16 col = setupm_fakecolor - colwidth; + INT32 col = setupm_fakecolor - colwidth; INT32 x = mx; INT32 cw = indexwidth; UINT8 ch; @@ -8404,7 +8404,7 @@ static void M_DrawSetupMultiPlayerMenu(void) { const INT32 icons = 4; INT32 k = -icons; - INT16 col = setupm_fakeskin - icons; + INT32 col = setupm_fakeskin - icons; INT32 x = BASEVIDWIDTH/2 - ((icons+1)*24) - 4; fixed_t scale = FRACUNIT/2; INT32 offx = 8, offy = 8; @@ -8467,7 +8467,7 @@ static void M_DrawSetupMultiPlayerMenu(void) switch (cv_skinselectmenu.value) { case SKINMENUTYPE_2D: - skintodisplay = (UINT8)setupm_fakeskin; + skintodisplay = (skinnum_t)setupm_fakeskin; if (setupm_skinlockedselect) // show the skin we are trying to select skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect]; else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1) @@ -8475,10 +8475,10 @@ static void M_DrawSetupMultiPlayerMenu(void) break; case SKINMENUTYPE_EXTENDED: case SKINMENUTYPE_GRID: - skintodisplay = ((itemOn == 1 && (setupm_skinselect < numskins)) ? skinsorted[setupm_skinselect] : (UINT8)setupm_fakeskin); + skintodisplay = ((itemOn == 1 && (setupm_skinselect < numskins)) ? skinsorted[setupm_skinselect] : (skinnum_t)setupm_fakeskin); break; default: - skintodisplay = (UINT8)setupm_fakeskin; + skintodisplay = (skinnum_t)setupm_fakeskin; break; } diff --git a/src/m_menu.h b/src/m_menu.h index c8fe7b4c2..2089900e3 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -230,8 +230,8 @@ typedef struct char levelname[32]; UINT8 actnum; UINT8 skincolor; - UINT8 skinnum; - UINT8 botskin; + skinnum_t skinnum; + skinnum_t botskin; UINT8 botcolor; UINT8 numemeralds; INT32 lives; diff --git a/src/p_saveg.c b/src/p_saveg.c index 23967cab1..cde5765c4 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -69,7 +69,7 @@ FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save) pllives = 3; // has less than that. WRITEUINT8(save->p, player->skincolor); - WRITEUINT8(save->p, player->skin); + WRITESKIN(save->p, player->skin); WRITEUINT32(save->p, player->score); WRITEINT32(save->p, pllives); @@ -77,7 +77,7 @@ FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save) if (botskin) { - WRITEUINT8(save->p, botskin); + WRITESKIN(save->p, botskin); WRITEUINT8(save->p, botcolor); } } @@ -88,7 +88,7 @@ FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save) FUNCINLINE static ATTRINLINE void P_UnArchivePlayer(savebuffer_t *save) { savedata.skincolor = READUINT8(save->p); - savedata.skin = READUINT8(save->p); + savedata.skin = READSKIN(save->p); savedata.score = READINT32(save->p); savedata.lives = READINT32(save->p); @@ -96,9 +96,11 @@ FUNCINLINE static ATTRINLINE void P_UnArchivePlayer(savebuffer_t *save) if (savedata.botcolor) { - savedata.botskin = READUINT8(save->p); + savedata.botskin = READSKIN(save->p); + if (savedata.botskin-1 >= numskins) savedata.botskin = 0; + savedata.botcolor = READUINT8(save->p); } else @@ -117,7 +119,9 @@ static void P_NetArchivePlayers(savebuffer_t *save, boolean resending) for (i = 0; i < MAXPLAYERS; i++) { +#ifndef PHOBOS_BUILD if (resending) +#endif WRITESINT8(save->p, (SINT8)adminplayers[i]); if (!playeringame[i]) @@ -127,7 +131,9 @@ static void P_NetArchivePlayers(savebuffer_t *save, boolean resending) // no longer send ticcmds +#ifndef PHOBOS_BUILD if (resending) +#endif WRITESTRINGN(save->p, player_names[i], MAXPLAYERNAME); const player_t *player = &players[i]; @@ -156,11 +162,16 @@ static void P_NetArchivePlayers(savebuffer_t *save, boolean resending) WRITEUINT16(save->p, player->flashpal); WRITEUINT16(save->p, player->flashcount); +#ifdef PHOBOS_BUILD + WRITEUINT8(save->p, player->skincolor); + WRITEINT32(save->p, player->skin); +#else if (resending) { WRITEUINT8(save->p, player->skincolor); WRITEINT32(save->p, player->skin); } +#endif WRITEUINT32(save->p, player->score); WRITEFIXED(save->p, player->dashspeed); @@ -309,7 +320,9 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean reloading) for (i = 0; i < MAXPLAYERS; i++) { +#ifndef PHOBOS_BUILD if (reloading) +#endif adminplayers[i] = (INT32)READSINT8(save->p); // Do NOT memset player struct to 0 @@ -320,7 +333,9 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean reloading) // NOTE: sending tics should (hopefully) no longer be necessary +#ifndef PHOBOS_BUILD if (reloading) +#endif READSTRINGN(save->p, player_names[i], MAXPLAYERNAME); player_t *player = &players[i]; @@ -349,11 +364,16 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean reloading) player->flashpal = READUINT16(save->p); player->flashcount = READUINT16(save->p); +#ifdef PHOBOS_BUILD + player->skincolor = READUINT8(save->p); + player->skin = READINT32(save->p); +#else if (reloading) { player->skincolor = READUINT8(save->p); player->skin = READINT32(save->p); } +#endif player->score = READUINT32(save->p); player->dashspeed = READFIXED(save->p); // dashing speed @@ -1304,7 +1324,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 if (diff2 & MD2_CVMEM) WRITEINT32(save->p, mobj->cvmem); if (diff2 & MD2_SKIN) - WRITEUINT8(save->p, (UINT8)((skin_t *)mobj->skin - skins)); + WRITESKIN(save->p, (skinnum_t)((skin_t *)mobj->skin - skins)); if (diff2 & MD2_COLOR) WRITEUINT8(save->p, mobj->color); if (diff2 & MD2_EXTVAL1) @@ -2165,7 +2185,7 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) if (diff2 & MD2_CVMEM) mobj->cvmem = READINT32(save->p); if (diff2 & MD2_SKIN) - mobj->skin = &skins[READUINT8(save->p)]; + mobj->skin = &skins[READSKIN(save->p)]; if (diff2 & MD2_COLOR) mobj->color = READUINT8(save->p); if (diff2 & MD2_EXTVAL1) diff --git a/src/p_saveg.h b/src/p_saveg.h index 9a0e26c39..5aaece4e9 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -24,8 +24,8 @@ typedef struct { UINT8 skincolor; - UINT8 skin; - UINT8 botskin; + skinnum_t skin; + skinnum_t botskin; UINT8 botcolor; INT32 score; INT32 lives; diff --git a/src/r_skins.c b/src/r_skins.c index 181fd3319..a8496c7f5 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -42,8 +42,8 @@ INT32 numallskins = 0; INT32 numlocalskins = 0; skin_t skins[MAXSKINS]; -UINT8 skinstats[9][9][MAXSKINS]; -UINT8 skinstatscount[9][9] = { +skinnum_t skinstats[9][9][MAXSKINS]; +skinnum_t skinstatscount[9][9] = { {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, @@ -55,7 +55,7 @@ UINT8 skinstatscount[9][9] = { {0, 0, 0, 0, 0, 0, 0, 0, 0} }; -UINT8 skinsorted[MAXSKINS] = {}; +skinnum_t skinsorted[MAXSKINS] = {}; skin_t localskins[MAXLOCALSKINS] = {}; skin_t allskins[MAXSKINS+MAXLOCALSKINS] = {}; @@ -398,8 +398,8 @@ static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) static int skinSortFunc(const void *a, const void *b) // tbh i have no clue what the naming conventions for local functions are { int diff = 0; - const UINT8 val_a = *(const UINT8 *)a; - const UINT8 val_b = *(const UINT8 *)b; + const skinnum_t val_a = *(const skinnum_t *)a; + const skinnum_t val_b = *(const skinnum_t *)b; const skin_t *in1 = &skins[val_a]; const skin_t *in2 = &skins[val_b]; @@ -474,7 +474,7 @@ static int skinSortFunc(const void *a, const void *b) // tbh i have no clue what void sortSkinGrid(void) { //CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); - qs22j(skinsorted, numskins, sizeof(UINT8), skinSortFunc); + qs22j(skinsorted, numskins, sizeof(skinnum_t), skinSortFunc); } // diff --git a/src/r_skins.h b/src/r_skins.h index 929753855..d3e196827 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -71,9 +71,9 @@ extern INT32 numskins; extern INT32 numlocalskins; extern INT32 numallskins; extern skin_t skins[MAXSKINS]; -extern UINT8 skinstats[9][9][MAXSKINS]; -extern UINT8 skinstatscount[9][9]; -extern UINT8 skinsorted[MAXSKINS]; +extern skinnum_t skinstats[9][9][MAXSKINS]; +extern skinnum_t skinstatscount[9][9]; +extern skinnum_t skinsorted[MAXSKINS]; extern skin_t localskins[MAXLOCALSKINS]; extern skin_t allskins[MAXSKINS+MAXLOCALSKINS];