From 4d3f43b8e4d6ce191bf717871d1c8a972993d2cf Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Mon, 19 May 2025 17:28:53 +0200 Subject: [PATCH] Move skincolors definition from doomdef.h to info.h Recompiling 80% of the codebase every time was getting on my nerves... also clean up initialization a bit --- src/d_main.cpp | 5 ----- src/doomdef.h | 30 ------------------------------ src/info.c | 2 ++ src/info.h | 29 +++++++++++++++++++++++++++++ src/k_color.h | 2 +- src/m_cond.h | 2 +- src/m_menu.c | 1 - 7 files changed, 33 insertions(+), 38 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 59ba45c8a..ba167ed66 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1392,10 +1392,6 @@ void D_SRB2Main(void) if (M_CheckParm("-password") && M_IsNextParm()) D_SetPassword(M_GetNextParm()); - // player setup menu colors must be initialized before - // any wad file is added, as they may contain colors themselves - M_InitPlayerSetupColors(); - CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n"); Z_Init(); CON_SetLoadingProgress(LOADED_ZINIT); @@ -1504,7 +1500,6 @@ void D_SRB2Main(void) R_InitPaletteRemap(); - // now do it again for the SOC colors in main.pk3! M_InitPlayerSetupColors(); // Do it before P_InitMapData because PNG patch diff --git a/src/doomdef.h b/src/doomdef.h index 5622a0021..d4658569b 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -220,36 +220,6 @@ extern char logfilename[1024]; // Master Server compatibility ONLY #define MSCOMPAT_MAXPLAYERS (32) -struct skincolor_t -{ - UINT32 namehash; // Hash for internal name - UINT32 nameofs; // Offset for internal name - char name[MAXCOLORNAME+1]; // Skincolor name - UINT8 ramp[COLORRAMPSIZE]; // Colormap ramp - UINT16 invcolor; // Signpost color - UINT8 invshade; // Signpost color shade - UINT16 chatcolor; // Chat color - boolean accessible; // Accessible by the color command + setup menu -}; - -typedef enum -{ -#define _(name, ...) SKINCOLOR_##name, -#include "info/skincolors.h" -#undef _ - SKINCOLOR_FIRSTFREESLOT, - SKINCOLOR_LASTFREESLOT = SKINCOLOR_FIRSTFREESLOT + NUMCOLORFREESLOTS - 1, - MAXSKINCOLORS, - - FIRSTRAINBOWCOLOR = SKINCOLOR_PINK, - FIRSTSUPERCOLOR = SKINCOLOR_SUPER1, - NUMSUPERCOLORS = ((SKINCOLOR_FIRSTFREESLOT - FIRSTSUPERCOLOR)/5) -} skincolornum_t; - -extern UINT16 numskincolors; - -extern skincolor_t skincolors[MAXSKINCOLORS]; - // State updates, number of tics / second. // NOTE: used to setup the timer rate, see I_StartupTimer(). #define TICRATE 35 diff --git a/src/info.c b/src/info.c index 7ad593a1c..c7c4ef776 100644 --- a/src/info.c +++ b/src/info.c @@ -198,6 +198,8 @@ void P_ResetData(INT32 flags) if (!init) memset(skincolors, 0, sizeof(skincolors)); + numskincolors = SKINCOLOR_FIRSTFREESLOT; + if (skincolornames) Z_Free(skincolornames); skincolornames = strbuf_alloc(); diff --git a/src/info.h b/src/info.h index e6a716483..9b40b7e1d 100644 --- a/src/info.h +++ b/src/info.h @@ -141,6 +141,35 @@ struct mobjinfo_t extern mobjinfo_t mobjinfo[NUMMOBJTYPES]; extern size_t nummobjtypes; +typedef enum +{ +#define _(name, ...) SKINCOLOR_##name, +#include "info/skincolors.h" +#undef _ + SKINCOLOR_FIRSTFREESLOT, + SKINCOLOR_LASTFREESLOT = SKINCOLOR_FIRSTFREESLOT + NUMCOLORFREESLOTS - 1, + MAXSKINCOLORS, + + FIRSTRAINBOWCOLOR = SKINCOLOR_PINK, + FIRSTSUPERCOLOR = SKINCOLOR_SUPER1, + NUMSUPERCOLORS = ((SKINCOLOR_FIRSTFREESLOT - FIRSTSUPERCOLOR)/5) +} skincolornum_t; + +struct skincolor_t +{ + UINT32 namehash; // Hash for internal name + UINT32 nameofs; // Offset for internal name + char name[MAXCOLORNAME+1]; // Skincolor name + UINT8 ramp[COLORRAMPSIZE]; // Colormap ramp + UINT16 invcolor; // Signpost color + UINT8 invshade; // Signpost color shade + UINT16 chatcolor; // Chat color + boolean accessible; // Accessible by the color command + setup menu +}; + +extern skincolor_t skincolors[MAXSKINCOLORS]; +extern UINT16 numskincolors; + void P_ResetData(INT32 flags); #ifdef __cplusplus diff --git a/src/k_color.h b/src/k_color.h index 2f002c6e6..bd208a985 100644 --- a/src/k_color.h +++ b/src/k_color.h @@ -12,7 +12,7 @@ #ifndef __K_COLOR__ #define __K_COLOR__ -#include "doomdef.h" +#include "info.h" #include "doomtype.h" #ifdef __cplusplus diff --git a/src/m_cond.h b/src/m_cond.h index 636726019..d4c3e116b 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -13,7 +13,7 @@ #ifndef __M_COND_H__ #define __M_COND_H__ -#include "doomdef.h" +#include "info.h" #ifdef __cplusplus extern "C" { diff --git a/src/m_menu.c b/src/m_menu.c index 55b416226..8c7281e8a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7994,7 +7994,6 @@ UINT16 M_GetColorAfter(UINT16 color) { void M_InitPlayerSetupColors(void) { UINT16 i; - numskincolors = SKINCOLOR_FIRSTFREESLOT; menucolorhead = menucolortail = NULL; for (i=0; i