From 109069f718a6289446fc0510d565df38ff7a1109 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 14 Aug 2021 09:56:27 +0200 Subject: [PATCH] - removed the unused palette parameter from the V_GetColor family of functions. --- src/am_map.cpp | 2 +- src/common/console/c_cvars.cpp | 4 ++-- src/common/fonts/v_font.cpp | 6 +++--- src/common/menu/menudef.cpp | 6 +++--- src/common/scripting/backend/codegen.cpp | 2 +- src/common/scripting/jit/jit_move.cpp | 2 +- src/common/scripting/vm/vmexec.h | 2 +- .../textures/multipatchtexturebuilder.cpp | 2 +- src/common/utility/palette.cpp | 17 +++++++---------- src/common/utility/palutil.h | 6 +++--- src/d_iwad.cpp | 4 ++-- src/d_main.cpp | 4 ++-- src/gamedata/decallib.cpp | 8 ++++---- src/gamedata/g_mapinfo.cpp | 8 ++++---- src/gamedata/gi.cpp | 2 +- src/gamedata/teaminfo.cpp | 2 +- src/playsim/p_mobj.cpp | 2 +- src/r_data/gldefs.cpp | 8 ++++---- src/r_data/v_palette.cpp | 4 ++-- src/rendering/swrenderer/r_swcolormaps.cpp | 8 ++++---- src/scripting/decorate/thingdef_parse.cpp | 4 ++-- src/scripting/thingdef.h | 2 +- src/scripting/thingdef_properties.cpp | 2 +- src/scripting/zscript/zcc_compile_doom.cpp | 2 +- 24 files changed, 53 insertions(+), 56 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index dbfe6bae6b..d2b225f4bc 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -791,7 +791,7 @@ void FMapInfoParser::ParseAMColors(bool overlay) FString color = sc.String; FString colorName = V_GetColorStringByName(color); if(!colorName.IsEmpty()) color = colorName; - int colorval = V_GetColorFromString(nullptr, color); + int colorval = V_GetColorFromString(color); cset.c[i].FromRGB(RPART(colorval), GPART(colorval), BPART(colorval)); colorset = true; break; diff --git a/src/common/console/c_cvars.cpp b/src/common/console/c_cvars.cpp index 1c6df1e246..7e5bd94ba3 100644 --- a/src/common/console/c_cvars.cpp +++ b/src/common/console/c_cvars.cpp @@ -839,11 +839,11 @@ int FColorCVar::ToInt2 (UCVarValue value, ECVarType type) if (string.IsNotEmpty()) { - ret = V_GetColorFromString (NULL, string); + ret = V_GetColorFromString (string); } else { - ret = V_GetColorFromString (NULL, value.String); + ret = V_GetColorFromString (value.String); } } else diff --git a/src/common/fonts/v_font.cpp b/src/common/fonts/v_font.cpp index 750bb5d95d..1305fc413b 100644 --- a/src/common/fonts/v_font.cpp +++ b/src/common/fonts/v_font.cpp @@ -415,19 +415,19 @@ void V_InitFontColors () else if (sc.Compare ("Flat:")) { sc.MustGetString(); - logcolor = V_GetColor (nullptr, sc); + logcolor = V_GetColor (sc); } else { // Get first color - c = V_GetColor (nullptr, sc); + c = V_GetColor (sc); tparm.Start[0] = RPART(c); tparm.Start[1] = GPART(c); tparm.Start[2] = BPART(c); // Get second color sc.MustGetString(); - c = V_GetColor (nullptr, sc); + c = V_GetColor (sc); tparm.End[0] = RPART(c); tparm.End[1] = GPART(c); tparm.End[2] = BPART(c); diff --git a/src/common/menu/menudef.cpp b/src/common/menu/menudef.cpp index da73517b0a..b6ebefc156 100644 --- a/src/common/menu/menudef.cpp +++ b/src/common/menu/menudef.cpp @@ -459,7 +459,7 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s } else if (args[i] == TypeColor) { - params.Push(V_GetColor(nullptr, sc)); + params.Push(V_GetColor(sc)); } else if (args[i] == TypeFont) { @@ -1028,7 +1028,7 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc, int i } else if (args[i] == TypeColor) { - params.Push(V_GetColor(nullptr, sc)); + params.Push(V_GetColor(sc)); } else if (args[i]->isIntCompatible()) { @@ -1274,7 +1274,7 @@ static void ParseImageScrollerBody(FScanner& sc, DImageScrollerDescriptor* desc) } else if (args[i] == TypeColor) { - params.Push(V_GetColor(nullptr, sc)); + params.Push(V_GetColor(sc)); } else if (args[i]->isIntCompatible()) { diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 17e1483358..5be4b48be6 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -1328,7 +1328,7 @@ FxExpression *FxColorCast::Resolve(FCompileContext &ctx) } else { - FxExpression *x = new FxConstant(V_GetColor(nullptr, constval.GetString(), &ScriptPosition), ScriptPosition); + FxExpression *x = new FxConstant(V_GetColor(constval.GetString(), &ScriptPosition), ScriptPosition); delete this; return x; } diff --git a/src/common/scripting/jit/jit_move.cpp b/src/common/scripting/jit/jit_move.cpp index 53644568c3..63f6158e39 100644 --- a/src/common/scripting/jit/jit_move.cpp +++ b/src/common/scripting/jit/jit_move.cpp @@ -49,7 +49,7 @@ static int CastS2I(FString *b) { return (int)b->ToLong(); } static double CastS2F(FString *b) { return b->ToDouble(); } static int CastS2N(FString *b) { return b->Len() == 0 ? NAME_None : FName(*b).GetIndex(); } static void CastN2S(FString *a, int b) { FName name = FName(ENamedName(b)); *a = name.IsValidName() ? name.GetChars() : ""; } -static int CastS2Co(FString *b) { return V_GetColor(nullptr, *b); } +static int CastS2Co(FString *b) { return V_GetColor(*b); } static void CastCo2S(FString *a, int b) { PalEntry c(b); a->Format("%02x %02x %02x", c.r, c.g, c.b); } static int CastS2So(FString *b) { return FSoundID(*b); } static void CastSo2S(FString* a, int b) { *a = soundEngine->GetSoundName(b); } diff --git a/src/common/scripting/vm/vmexec.h b/src/common/scripting/vm/vmexec.h index dc32d86c0e..defbcdf6d6 100644 --- a/src/common/scripting/vm/vmexec.h +++ b/src/common/scripting/vm/vmexec.h @@ -1826,7 +1826,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c case CAST_S2Co: ASSERTD(a); ASSERTS(b); - reg.d[a] = V_GetColor(NULL, reg.s[b]); + reg.d[a] = V_GetColor(reg.s[b]); break; case CAST_Co2S: diff --git a/src/common/textures/multipatchtexturebuilder.cpp b/src/common/textures/multipatchtexturebuilder.cpp index 2557d848c0..000af17e20 100644 --- a/src/common/textures/multipatchtexturebuilder.cpp +++ b/src/common/textures/multipatchtexturebuilder.cpp @@ -542,7 +542,7 @@ void FMultipatchTextureBuilder::ParsePatch(FScanner &sc, BuildInfo &info, TexPar if (!sc.CheckNumber()) { sc.MustGetString(); - part.Blend = V_GetColor(NULL, sc); + part.Blend = V_GetColor(sc); } else { diff --git a/src/common/utility/palette.cpp b/src/common/utility/palette.cpp index f2a2987b3c..28a3cf35c6 100644 --- a/src/common/utility/palette.cpp +++ b/src/common/utility/palette.cpp @@ -523,7 +523,7 @@ PalEntry averageColor(const uint32_t* data, int size, int maxout) // //========================================================================== -int V_GetColorFromString(const uint32_t* palette, const char* cstr, FScriptPosition* sc) +int V_GetColorFromString(const char* cstr, FScriptPosition* sc) { int c[3], i, p; char val[3]; @@ -609,10 +609,7 @@ int V_GetColorFromString(const uint32_t* palette, const char* cstr, FScriptPosit } } } - if (palette) - return BestColor(palette, c[0], c[1], c[2]); - else - return MAKERGB(c[0], c[1], c[2]); + return MAKERGB(c[0], c[1], c[2]); } //========================================================================== @@ -715,26 +712,26 @@ FString V_GetColorStringByName(const char* name, FScriptPosition* sc) // //========================================================================== -int V_GetColor(const uint32_t* palette, const char* str, FScriptPosition* sc) +int V_GetColor(const char* str, FScriptPosition* sc) { FString string = V_GetColorStringByName(str, sc); int res; if (!string.IsEmpty()) { - res = V_GetColorFromString(palette, string, sc); + res = V_GetColorFromString(string, sc); } else { - res = V_GetColorFromString(palette, str, sc); + res = V_GetColorFromString(str, sc); } return res; } -int V_GetColor(const uint32_t* palette, FScanner& sc) +int V_GetColor(FScanner& sc) { FScriptPosition scc = sc; - return V_GetColor(palette, sc.String, &scc); + return V_GetColor(sc.String, &scc); } //========================================================================== diff --git a/src/common/utility/palutil.h b/src/common/utility/palutil.h index 07f796f8e0..a2bdeb4465 100644 --- a/src/common/utility/palutil.h +++ b/src/common/utility/palutil.h @@ -22,14 +22,14 @@ void HSVtoRGB (float *r, float *g, float *b, float h, float s, float v); // Returns the closest color to the one desired. String // should be of the form "rr gg bb". -int V_GetColorFromString(const uint32_t* palette, const char* colorstring, FScriptPosition* sc = nullptr); +int V_GetColorFromString(const char* colorstring, FScriptPosition* sc = nullptr); // Scans through the X11R6RGB lump for a matching color // and returns a color string suitable for V_GetColorFromString. FString V_GetColorStringByName(const char* name, FScriptPosition* sc = nullptr); // Tries to get color by name, then by string -int V_GetColor(const uint32_t* palette, const char* str, FScriptPosition* sc = nullptr); -int V_GetColor(const uint32_t* palette, FScanner& sc); +int V_GetColor(const char* str, FScriptPosition* sc = nullptr); +int V_GetColor(FScanner& sc); PalEntry averageColor(const uint32_t* data, int size, int maxout); enum diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index ca0f50f878..99234f612f 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -172,10 +172,10 @@ void FIWadManager::ParseIWadInfo(const char *fn, const char *data, int datasize, { sc.MustGetStringName("="); sc.MustGetString(); - iwad->FgColor = V_GetColor(NULL, sc); + iwad->FgColor = V_GetColor(sc); sc.MustGetStringName(","); sc.MustGetString(); - iwad->BkColor = V_GetColor(NULL, sc); + iwad->BkColor = V_GetColor(sc); } else if (sc.Compare("IgnoreTitlePatches")) { diff --git a/src/d_main.cpp b/src/d_main.cpp index 1b77b57d87..6089e90b6a 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1911,10 +1911,10 @@ static FString ParseGameInfo(TArray &pwads, const char *fn, const char else if (!nextKey.CompareNoCase("STARTUPCOLORS")) { sc.MustGetString(); - GameStartupInfo.FgColor = V_GetColor(NULL, sc); + GameStartupInfo.FgColor = V_GetColor(sc); sc.MustGetStringName(","); sc.MustGetString(); - GameStartupInfo.BkColor = V_GetColor(NULL, sc); + GameStartupInfo.BkColor = V_GetColor(sc); } else if (!nextKey.CompareNoCase("STARTUPTYPE")) { diff --git a/src/gamedata/decallib.cpp b/src/gamedata/decallib.cpp index 4c22232505..2d435da247 100644 --- a/src/gamedata/decallib.cpp +++ b/src/gamedata/decallib.cpp @@ -443,7 +443,7 @@ void FDecalLib::ParseDecal (FScanner &sc) sc.MustGetString (); if (!sc.Compare("BloodDefault")) { - newdecal.ShadeColor = V_GetColor (NULL, sc); + newdecal.ShadeColor = V_GetColor (sc); } else { @@ -458,8 +458,8 @@ void FDecalLib::ParseDecal (FScanner &sc) case DECAL_COLORS: uint32_t startcolor, endcolor; - sc.MustGetString (); startcolor = V_GetColor (NULL, sc); - sc.MustGetString (); endcolor = V_GetColor (NULL, sc); + sc.MustGetString (); startcolor = V_GetColor (sc); + sc.MustGetString (); endcolor = V_GetColor (sc); newdecal.Translation = GenerateTranslation (startcolor, endcolor)->Index; break; @@ -739,7 +739,7 @@ void FDecalLib::ParseColorchanger (FScanner &sc) else if (sc.Compare ("Color")) { sc.MustGetString (); - goal = V_GetColor (NULL, sc); + goal = V_GetColor (sc); } else { diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index 28b83f3088..30b4c09ce7 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -1015,14 +1015,14 @@ DEFINE_MAP_OPTION(fade, true) { parse.ParseAssign(); parse.sc.MustGetString(); - info->fadeto = V_GetColor(NULL, parse.sc); + info->fadeto = V_GetColor(parse.sc); } DEFINE_MAP_OPTION(outsidefog, true) { parse.ParseAssign(); parse.sc.MustGetString(); - info->outsidefog = V_GetColor(NULL, parse.sc); + info->outsidefog = V_GetColor(parse.sc); } DEFINE_MAP_OPTION(titlepatch, true) @@ -1398,14 +1398,14 @@ DEFINE_MAP_OPTION(hazardcolor, true) { parse.ParseAssign(); parse.sc.MustGetString(); - info->hazardcolor = V_GetColor(NULL, parse.sc); + info->hazardcolor = V_GetColor(parse.sc); } DEFINE_MAP_OPTION(hazardflash, true) { parse.ParseAssign(); parse.sc.MustGetString(); - info->hazardflash = V_GetColor(NULL, parse.sc); + info->hazardflash = V_GetColor(parse.sc); } DEFINE_MAP_OPTION(fogdensity, false) diff --git a/src/gamedata/gi.cpp b/src/gamedata/gi.cpp index 4524929aba..667e0d136f 100644 --- a/src/gamedata/gi.cpp +++ b/src/gamedata/gi.cpp @@ -215,7 +215,7 @@ const char* GameInfoBorders[] = FString colorName = V_GetColorStringByName(color); \ if(!colorName.IsEmpty()) \ color = colorName; \ - gameinfo.key = V_GetColorFromString(NULL, color); \ + gameinfo.key = V_GetColorFromString(color); \ } #define GAMEINFOKEY_BOOL(key, variable) \ diff --git a/src/gamedata/teaminfo.cpp b/src/gamedata/teaminfo.cpp index bd836ab08d..629d110b98 100644 --- a/src/gamedata/teaminfo.cpp +++ b/src/gamedata/teaminfo.cpp @@ -183,7 +183,7 @@ void FTeam::ParseTeamDefinition (FScanner &Scan) case TEAMINFO_PlayerColor: Scan.MustGetString (); - Team.m_iPlayerColor = V_GetColor (NULL, Scan); + Team.m_iPlayerColor = V_GetColor (Scan); break; case TEAMINFO_TextColor: diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 324efe9698..cba3950d7b 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -5728,7 +5728,7 @@ AActor *FLevelLocals::SpawnMapThing (FMapThing *mthing, int position) { if (mthing->arg0str != NAME_None) { - PalEntry color = V_GetColor(nullptr, mthing->arg0str.GetChars()); + PalEntry color = V_GetColor(mthing->arg0str.GetChars()); mobj->args[0] = color.r; mobj->args[1] = color.g; mobj->args[2] = color.b; diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index b377963328..6be82c77da 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -1057,7 +1057,7 @@ class GLDefsParser auto tex = TexMan.GetGameTexture(flump); sc.MustGetStringName(","); sc.MustGetString(); - PalEntry color = V_GetColor(NULL, sc.String); + PalEntry color = V_GetColor(sc.String); //sc.MustGetStringName(","); //sc.MustGetNumber(); if (sc.CheckString(",")) @@ -1671,12 +1671,12 @@ class GLDefsParser else if (sc.Compare("AddColor")) { sc.MustGetString(); - tm.AddColor = (tm.AddColor & 0xff000000) | (V_GetColor(NULL, sc) & 0xffffff); + tm.AddColor = (tm.AddColor & 0xff000000) | (V_GetColor(sc) & 0xffffff); } else if (sc.Compare("ModulateColor")) { sc.MustGetString(); - tm.ModulateColor = V_GetColor(NULL, sc) & 0xffffff; + tm.ModulateColor = V_GetColor(sc) & 0xffffff; if (sc.CheckToken(',')) { sc.MustGetNumber(); @@ -1687,7 +1687,7 @@ class GLDefsParser else if (sc.Compare("BlendColor")) { sc.MustGetString(); - tm.BlendColor = V_GetColor(NULL, sc) & 0xffffff; + tm.BlendColor = V_GetColor(sc) & 0xffffff; sc.MustGetToken(','); sc.MustGetString(); static const char* opts[] = { "none", "alpha", "screen", "overlay", "hardlight", nullptr }; diff --git a/src/r_data/v_palette.cpp b/src/r_data/v_palette.cpp index a78184f7e7..9f16d34cb0 100644 --- a/src/r_data/v_palette.cpp +++ b/src/r_data/v_palette.cpp @@ -98,11 +98,11 @@ CCMD (testblend) { if ( !(colorstring = V_GetColorStringByName (argv[1])).IsEmpty() ) { - color = V_GetColorFromString (NULL, colorstring); + color = V_GetColorFromString (colorstring); } else { - color = V_GetColorFromString (NULL, argv[1]); + color = V_GetColorFromString (argv[1]); } amt = (float)atof (argv[2]); if (amt > 1.0f) diff --git a/src/rendering/swrenderer/r_swcolormaps.cpp b/src/rendering/swrenderer/r_swcolormaps.cpp index 6e6440f3e6..f488e4e82d 100644 --- a/src/rendering/swrenderer/r_swcolormaps.cpp +++ b/src/rendering/swrenderer/r_swcolormaps.cpp @@ -516,11 +516,11 @@ CCMD (testfade) { if ( !(colorstring = V_GetColorStringByName (argv[1])).IsEmpty() ) { - color = V_GetColorFromString (NULL, colorstring); + color = V_GetColorFromString (colorstring); } else { - color = V_GetColorFromString (NULL, argv[1]); + color = V_GetColorFromString (argv[1]); } for (auto Level : AllLevels()) { @@ -550,11 +550,11 @@ CCMD (testcolor) { if ( !(colorstring = V_GetColorStringByName (argv[1])).IsEmpty() ) { - color = V_GetColorFromString (NULL, colorstring); + color = V_GetColorFromString (colorstring); } else { - color = V_GetColorFromString (NULL, argv[1]); + color = V_GetColorFromString (argv[1]); } if (argv.argc() > 2) { diff --git a/src/scripting/decorate/thingdef_parse.cpp b/src/scripting/decorate/thingdef_parse.cpp index 0f0a5d8286..96c654e3b5 100644 --- a/src/scripting/decorate/thingdef_parse.cpp +++ b/src/scripting/decorate/thingdef_parse.cpp @@ -190,7 +190,7 @@ FxExpression *ParseParameter(FScanner &sc, PClassActor *cls, PType *type) } else { - int c = V_GetColor (NULL, sc); + int c = V_GetColor (sc); // 0 needs to be the default so we have to mark the color. v = MAKEARGB(1, RPART(c), GPART(c), BPART(c)); } @@ -884,7 +884,7 @@ static void DispatchScriptProperty(FScanner &sc, PProperty *prop, AActor *defaul else if (f->Type == TypeColor) { if (sc.CheckNumber()) *(int*)addr = sc.Number; - else *(PalEntry*)addr = V_GetColor(nullptr, sc); + else *(PalEntry*)addr = V_GetColor(sc); } else if (f->Type->isIntCompatible()) { diff --git a/src/scripting/thingdef.h b/src/scripting/thingdef.h index 8d0c044613..320c28cd40 100644 --- a/src/scripting/thingdef.h +++ b/src/scripting/thingdef.h @@ -326,6 +326,6 @@ int MatchString (const char *in, const char **strings); double var = params[(no)+1].d; #define PROP_COLOR_PARM(var, no, scriptpos) \ - int var = params[(no)+1].i== 0? params[(no)+2].i : V_GetColor(NULL, params[(no)+2].s, scriptpos); + int var = params[(no)+1].i== 0? params[(no)+2].i : V_GetColor(params[(no)+2].s, scriptpos); #endif diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 0b5e306ecb..48db073d07 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -1291,7 +1291,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory) *pBlendColor = MakeSpecialColormap(65535); return; } - color = V_GetColor(NULL, name, &bag.ScriptPosition); + color = V_GetColor(name, &bag.ScriptPosition); } if (PROP_PARM_COUNT > 2) { diff --git a/src/scripting/zscript/zcc_compile_doom.cpp b/src/scripting/zscript/zcc_compile_doom.cpp index d428627a22..cc19533a17 100644 --- a/src/scripting/zscript/zcc_compile_doom.cpp +++ b/src/scripting/zscript/zcc_compile_doom.cpp @@ -471,7 +471,7 @@ void ZCCDoomCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt * } else if (f->Type == TypeColor && ex->ValueType == TypeString) // colors can also be specified as ints. { - *(PalEntry*)addr = V_GetColor(nullptr, GetStringConst(ex, ctx), &ex->ScriptPosition); + *(PalEntry*)addr = V_GetColor(GetStringConst(ex, ctx), &ex->ScriptPosition); } else if (f->Type->isIntCompatible()) {