- removed the unused palette parameter from the V_GetColor family of functions.

This commit is contained in:
Christoph Oelckers 2021-08-14 09:56:27 +02:00
parent d64dd1f631
commit 109069f718
24 changed files with 53 additions and 56 deletions

View file

@ -791,7 +791,7 @@ void FMapInfoParser::ParseAMColors(bool overlay)
FString color = sc.String; FString color = sc.String;
FString colorName = V_GetColorStringByName(color); FString colorName = V_GetColorStringByName(color);
if(!colorName.IsEmpty()) color = colorName; 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)); cset.c[i].FromRGB(RPART(colorval), GPART(colorval), BPART(colorval));
colorset = true; colorset = true;
break; break;

View file

@ -839,11 +839,11 @@ int FColorCVar::ToInt2 (UCVarValue value, ECVarType type)
if (string.IsNotEmpty()) if (string.IsNotEmpty())
{ {
ret = V_GetColorFromString (NULL, string); ret = V_GetColorFromString (string);
} }
else else
{ {
ret = V_GetColorFromString (NULL, value.String); ret = V_GetColorFromString (value.String);
} }
} }
else else

View file

@ -415,19 +415,19 @@ void V_InitFontColors ()
else if (sc.Compare ("Flat:")) else if (sc.Compare ("Flat:"))
{ {
sc.MustGetString(); sc.MustGetString();
logcolor = V_GetColor (nullptr, sc); logcolor = V_GetColor (sc);
} }
else else
{ {
// Get first color // Get first color
c = V_GetColor (nullptr, sc); c = V_GetColor (sc);
tparm.Start[0] = RPART(c); tparm.Start[0] = RPART(c);
tparm.Start[1] = GPART(c); tparm.Start[1] = GPART(c);
tparm.Start[2] = BPART(c); tparm.Start[2] = BPART(c);
// Get second color // Get second color
sc.MustGetString(); sc.MustGetString();
c = V_GetColor (nullptr, sc); c = V_GetColor (sc);
tparm.End[0] = RPART(c); tparm.End[0] = RPART(c);
tparm.End[1] = GPART(c); tparm.End[1] = GPART(c);
tparm.End[2] = BPART(c); tparm.End[2] = BPART(c);

View file

@ -459,7 +459,7 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s
} }
else if (args[i] == TypeColor) else if (args[i] == TypeColor)
{ {
params.Push(V_GetColor(nullptr, sc)); params.Push(V_GetColor(sc));
} }
else if (args[i] == TypeFont) else if (args[i] == TypeFont)
{ {
@ -1028,7 +1028,7 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc, int i
} }
else if (args[i] == TypeColor) else if (args[i] == TypeColor)
{ {
params.Push(V_GetColor(nullptr, sc)); params.Push(V_GetColor(sc));
} }
else if (args[i]->isIntCompatible()) else if (args[i]->isIntCompatible())
{ {
@ -1274,7 +1274,7 @@ static void ParseImageScrollerBody(FScanner& sc, DImageScrollerDescriptor* desc)
} }
else if (args[i] == TypeColor) else if (args[i] == TypeColor)
{ {
params.Push(V_GetColor(nullptr, sc)); params.Push(V_GetColor(sc));
} }
else if (args[i]->isIntCompatible()) else if (args[i]->isIntCompatible())
{ {

View file

@ -1328,7 +1328,7 @@ FxExpression *FxColorCast::Resolve(FCompileContext &ctx)
} }
else else
{ {
FxExpression *x = new FxConstant(V_GetColor(nullptr, constval.GetString(), &ScriptPosition), ScriptPosition); FxExpression *x = new FxConstant(V_GetColor(constval.GetString(), &ScriptPosition), ScriptPosition);
delete this; delete this;
return x; return x;
} }

View file

@ -49,7 +49,7 @@ static int CastS2I(FString *b) { return (int)b->ToLong(); }
static double CastS2F(FString *b) { return b->ToDouble(); } static double CastS2F(FString *b) { return b->ToDouble(); }
static int CastS2N(FString *b) { return b->Len() == 0 ? NAME_None : FName(*b).GetIndex(); } 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 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 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 int CastS2So(FString *b) { return FSoundID(*b); }
static void CastSo2S(FString* a, int b) { *a = soundEngine->GetSoundName(b); } static void CastSo2S(FString* a, int b) { *a = soundEngine->GetSoundName(b); }

View file

@ -1826,7 +1826,7 @@ static void DoCast(const VMRegisters &reg, const VMFrame *f, int a, int b, int c
case CAST_S2Co: case CAST_S2Co:
ASSERTD(a); ASSERTS(b); ASSERTD(a); ASSERTS(b);
reg.d[a] = V_GetColor(NULL, reg.s[b]); reg.d[a] = V_GetColor(reg.s[b]);
break; break;
case CAST_Co2S: case CAST_Co2S:

View file

@ -542,7 +542,7 @@ void FMultipatchTextureBuilder::ParsePatch(FScanner &sc, BuildInfo &info, TexPar
if (!sc.CheckNumber()) if (!sc.CheckNumber())
{ {
sc.MustGetString(); sc.MustGetString();
part.Blend = V_GetColor(NULL, sc); part.Blend = V_GetColor(sc);
} }
else else
{ {

View file

@ -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; int c[3], i, p;
char val[3]; char val[3];
@ -609,10 +609,7 @@ int V_GetColorFromString(const uint32_t* palette, const char* cstr, FScriptPosit
} }
} }
} }
if (palette) return MAKERGB(c[0], c[1], c[2]);
return BestColor(palette, c[0], c[1], c[2]);
else
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); FString string = V_GetColorStringByName(str, sc);
int res; int res;
if (!string.IsEmpty()) if (!string.IsEmpty())
{ {
res = V_GetColorFromString(palette, string, sc); res = V_GetColorFromString(string, sc);
} }
else else
{ {
res = V_GetColorFromString(palette, str, sc); res = V_GetColorFromString(str, sc);
} }
return res; return res;
} }
int V_GetColor(const uint32_t* palette, FScanner& sc) int V_GetColor(FScanner& sc)
{ {
FScriptPosition scc = sc; FScriptPosition scc = sc;
return V_GetColor(palette, sc.String, &scc); return V_GetColor(sc.String, &scc);
} }
//========================================================================== //==========================================================================

View file

@ -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 // Returns the closest color to the one desired. String
// should be of the form "rr gg bb". // 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 // Scans through the X11R6RGB lump for a matching color
// and returns a color string suitable for V_GetColorFromString. // and returns a color string suitable for V_GetColorFromString.
FString V_GetColorStringByName(const char* name, FScriptPosition* sc = nullptr); FString V_GetColorStringByName(const char* name, FScriptPosition* sc = nullptr);
// Tries to get color by name, then by string // 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 char* str, FScriptPosition* sc = nullptr);
int V_GetColor(const uint32_t* palette, FScanner& sc); int V_GetColor(FScanner& sc);
PalEntry averageColor(const uint32_t* data, int size, int maxout); PalEntry averageColor(const uint32_t* data, int size, int maxout);
enum enum

View file

@ -172,10 +172,10 @@ void FIWadManager::ParseIWadInfo(const char *fn, const char *data, int datasize,
{ {
sc.MustGetStringName("="); sc.MustGetStringName("=");
sc.MustGetString(); sc.MustGetString();
iwad->FgColor = V_GetColor(NULL, sc); iwad->FgColor = V_GetColor(sc);
sc.MustGetStringName(","); sc.MustGetStringName(",");
sc.MustGetString(); sc.MustGetString();
iwad->BkColor = V_GetColor(NULL, sc); iwad->BkColor = V_GetColor(sc);
} }
else if (sc.Compare("IgnoreTitlePatches")) else if (sc.Compare("IgnoreTitlePatches"))
{ {

View file

@ -1911,10 +1911,10 @@ static FString ParseGameInfo(TArray<FString> &pwads, const char *fn, const char
else if (!nextKey.CompareNoCase("STARTUPCOLORS")) else if (!nextKey.CompareNoCase("STARTUPCOLORS"))
{ {
sc.MustGetString(); sc.MustGetString();
GameStartupInfo.FgColor = V_GetColor(NULL, sc); GameStartupInfo.FgColor = V_GetColor(sc);
sc.MustGetStringName(","); sc.MustGetStringName(",");
sc.MustGetString(); sc.MustGetString();
GameStartupInfo.BkColor = V_GetColor(NULL, sc); GameStartupInfo.BkColor = V_GetColor(sc);
} }
else if (!nextKey.CompareNoCase("STARTUPTYPE")) else if (!nextKey.CompareNoCase("STARTUPTYPE"))
{ {

View file

@ -443,7 +443,7 @@ void FDecalLib::ParseDecal (FScanner &sc)
sc.MustGetString (); sc.MustGetString ();
if (!sc.Compare("BloodDefault")) if (!sc.Compare("BloodDefault"))
{ {
newdecal.ShadeColor = V_GetColor (NULL, sc); newdecal.ShadeColor = V_GetColor (sc);
} }
else else
{ {
@ -458,8 +458,8 @@ void FDecalLib::ParseDecal (FScanner &sc)
case DECAL_COLORS: case DECAL_COLORS:
uint32_t startcolor, endcolor; uint32_t startcolor, endcolor;
sc.MustGetString (); startcolor = V_GetColor (NULL, sc); sc.MustGetString (); startcolor = V_GetColor (sc);
sc.MustGetString (); endcolor = V_GetColor (NULL, sc); sc.MustGetString (); endcolor = V_GetColor (sc);
newdecal.Translation = GenerateTranslation (startcolor, endcolor)->Index; newdecal.Translation = GenerateTranslation (startcolor, endcolor)->Index;
break; break;
@ -739,7 +739,7 @@ void FDecalLib::ParseColorchanger (FScanner &sc)
else if (sc.Compare ("Color")) else if (sc.Compare ("Color"))
{ {
sc.MustGetString (); sc.MustGetString ();
goal = V_GetColor (NULL, sc); goal = V_GetColor (sc);
} }
else else
{ {

View file

@ -1015,14 +1015,14 @@ DEFINE_MAP_OPTION(fade, true)
{ {
parse.ParseAssign(); parse.ParseAssign();
parse.sc.MustGetString(); parse.sc.MustGetString();
info->fadeto = V_GetColor(NULL, parse.sc); info->fadeto = V_GetColor(parse.sc);
} }
DEFINE_MAP_OPTION(outsidefog, true) DEFINE_MAP_OPTION(outsidefog, true)
{ {
parse.ParseAssign(); parse.ParseAssign();
parse.sc.MustGetString(); parse.sc.MustGetString();
info->outsidefog = V_GetColor(NULL, parse.sc); info->outsidefog = V_GetColor(parse.sc);
} }
DEFINE_MAP_OPTION(titlepatch, true) DEFINE_MAP_OPTION(titlepatch, true)
@ -1398,14 +1398,14 @@ DEFINE_MAP_OPTION(hazardcolor, true)
{ {
parse.ParseAssign(); parse.ParseAssign();
parse.sc.MustGetString(); parse.sc.MustGetString();
info->hazardcolor = V_GetColor(NULL, parse.sc); info->hazardcolor = V_GetColor(parse.sc);
} }
DEFINE_MAP_OPTION(hazardflash, true) DEFINE_MAP_OPTION(hazardflash, true)
{ {
parse.ParseAssign(); parse.ParseAssign();
parse.sc.MustGetString(); parse.sc.MustGetString();
info->hazardflash = V_GetColor(NULL, parse.sc); info->hazardflash = V_GetColor(parse.sc);
} }
DEFINE_MAP_OPTION(fogdensity, false) DEFINE_MAP_OPTION(fogdensity, false)

View file

@ -215,7 +215,7 @@ const char* GameInfoBorders[] =
FString colorName = V_GetColorStringByName(color); \ FString colorName = V_GetColorStringByName(color); \
if(!colorName.IsEmpty()) \ if(!colorName.IsEmpty()) \
color = colorName; \ color = colorName; \
gameinfo.key = V_GetColorFromString(NULL, color); \ gameinfo.key = V_GetColorFromString(color); \
} }
#define GAMEINFOKEY_BOOL(key, variable) \ #define GAMEINFOKEY_BOOL(key, variable) \

View file

@ -183,7 +183,7 @@ void FTeam::ParseTeamDefinition (FScanner &Scan)
case TEAMINFO_PlayerColor: case TEAMINFO_PlayerColor:
Scan.MustGetString (); Scan.MustGetString ();
Team.m_iPlayerColor = V_GetColor (NULL, Scan); Team.m_iPlayerColor = V_GetColor (Scan);
break; break;
case TEAMINFO_TextColor: case TEAMINFO_TextColor:

View file

@ -5728,7 +5728,7 @@ AActor *FLevelLocals::SpawnMapThing (FMapThing *mthing, int position)
{ {
if (mthing->arg0str != NAME_None) 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[0] = color.r;
mobj->args[1] = color.g; mobj->args[1] = color.g;
mobj->args[2] = color.b; mobj->args[2] = color.b;

View file

@ -1057,7 +1057,7 @@ class GLDefsParser
auto tex = TexMan.GetGameTexture(flump); auto tex = TexMan.GetGameTexture(flump);
sc.MustGetStringName(","); sc.MustGetStringName(",");
sc.MustGetString(); sc.MustGetString();
PalEntry color = V_GetColor(NULL, sc.String); PalEntry color = V_GetColor(sc.String);
//sc.MustGetStringName(","); //sc.MustGetStringName(",");
//sc.MustGetNumber(); //sc.MustGetNumber();
if (sc.CheckString(",")) if (sc.CheckString(","))
@ -1671,12 +1671,12 @@ class GLDefsParser
else if (sc.Compare("AddColor")) else if (sc.Compare("AddColor"))
{ {
sc.MustGetString(); 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")) else if (sc.Compare("ModulateColor"))
{ {
sc.MustGetString(); sc.MustGetString();
tm.ModulateColor = V_GetColor(NULL, sc) & 0xffffff; tm.ModulateColor = V_GetColor(sc) & 0xffffff;
if (sc.CheckToken(',')) if (sc.CheckToken(','))
{ {
sc.MustGetNumber(); sc.MustGetNumber();
@ -1687,7 +1687,7 @@ class GLDefsParser
else if (sc.Compare("BlendColor")) else if (sc.Compare("BlendColor"))
{ {
sc.MustGetString(); sc.MustGetString();
tm.BlendColor = V_GetColor(NULL, sc) & 0xffffff; tm.BlendColor = V_GetColor(sc) & 0xffffff;
sc.MustGetToken(','); sc.MustGetToken(',');
sc.MustGetString(); sc.MustGetString();
static const char* opts[] = { "none", "alpha", "screen", "overlay", "hardlight", nullptr }; static const char* opts[] = { "none", "alpha", "screen", "overlay", "hardlight", nullptr };

View file

@ -98,11 +98,11 @@ CCMD (testblend)
{ {
if ( !(colorstring = V_GetColorStringByName (argv[1])).IsEmpty() ) if ( !(colorstring = V_GetColorStringByName (argv[1])).IsEmpty() )
{ {
color = V_GetColorFromString (NULL, colorstring); color = V_GetColorFromString (colorstring);
} }
else else
{ {
color = V_GetColorFromString (NULL, argv[1]); color = V_GetColorFromString (argv[1]);
} }
amt = (float)atof (argv[2]); amt = (float)atof (argv[2]);
if (amt > 1.0f) if (amt > 1.0f)

View file

@ -516,11 +516,11 @@ CCMD (testfade)
{ {
if ( !(colorstring = V_GetColorStringByName (argv[1])).IsEmpty() ) if ( !(colorstring = V_GetColorStringByName (argv[1])).IsEmpty() )
{ {
color = V_GetColorFromString (NULL, colorstring); color = V_GetColorFromString (colorstring);
} }
else else
{ {
color = V_GetColorFromString (NULL, argv[1]); color = V_GetColorFromString (argv[1]);
} }
for (auto Level : AllLevels()) for (auto Level : AllLevels())
{ {
@ -550,11 +550,11 @@ CCMD (testcolor)
{ {
if ( !(colorstring = V_GetColorStringByName (argv[1])).IsEmpty() ) if ( !(colorstring = V_GetColorStringByName (argv[1])).IsEmpty() )
{ {
color = V_GetColorFromString (NULL, colorstring); color = V_GetColorFromString (colorstring);
} }
else else
{ {
color = V_GetColorFromString (NULL, argv[1]); color = V_GetColorFromString (argv[1]);
} }
if (argv.argc() > 2) if (argv.argc() > 2)
{ {

View file

@ -190,7 +190,7 @@ FxExpression *ParseParameter(FScanner &sc, PClassActor *cls, PType *type)
} }
else 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. // 0 needs to be the default so we have to mark the color.
v = MAKEARGB(1, RPART(c), GPART(c), BPART(c)); 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) else if (f->Type == TypeColor)
{ {
if (sc.CheckNumber()) *(int*)addr = sc.Number; 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()) else if (f->Type->isIntCompatible())
{ {

View file

@ -326,6 +326,6 @@ int MatchString (const char *in, const char **strings);
double var = params[(no)+1].d; double var = params[(no)+1].d;
#define PROP_COLOR_PARM(var, no, scriptpos) \ #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 #endif

View file

@ -1291,7 +1291,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory)
*pBlendColor = MakeSpecialColormap(65535); *pBlendColor = MakeSpecialColormap(65535);
return; return;
} }
color = V_GetColor(NULL, name, &bag.ScriptPosition); color = V_GetColor(name, &bag.ScriptPosition);
} }
if (PROP_PARM_COUNT > 2) if (PROP_PARM_COUNT > 2)
{ {

View file

@ -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. 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()) else if (f->Type->isIntCompatible())
{ {