- removed unused CVAR_GUID type

This commit is contained in:
Christoph Oelckers 2019-06-27 09:16:34 +02:00
parent 3810d9beb3
commit 5ef43143f8
6 changed files with 7 additions and 230 deletions

View file

@ -293,9 +293,6 @@ bool FBaseCVar::ToBool (UCVarValue value, ECVarType type)
else else
return !!strtoll (value.String, NULL, 0); return !!strtoll (value.String, NULL, 0);
case CVAR_GUID:
return false;
default: default:
return false; return false;
} }
@ -327,7 +324,6 @@ int FBaseCVar::ToInt (UCVarValue value, ECVarType type)
res = (int)strtoll (value.String, NULL, 0); res = (int)strtoll (value.String, NULL, 0);
break; break;
} }
case CVAR_GUID: res = 0; break;
default: res = 0; break; default: res = 0; break;
} }
return res; return res;
@ -349,9 +345,6 @@ float FBaseCVar::ToFloat (UCVarValue value, ECVarType type)
case CVAR_String: case CVAR_String:
return (float)strtod (value.String, NULL); return (float)strtod (value.String, NULL);
case CVAR_GUID:
return 0.f;
default: default:
return 0.f; return 0.f;
} }
@ -382,10 +375,6 @@ const char *FBaseCVar::ToString (UCVarValue value, ECVarType type)
IGNORE_FORMAT_POST IGNORE_FORMAT_POST
break; break;
case CVAR_GUID:
FormatGUID (cstrbuf, countof(cstrbuf), *value.pGUID);
break;
default: default:
strcpy (cstrbuf, "<huh?>"); strcpy (cstrbuf, "<huh?>");
break; break;
@ -393,24 +382,6 @@ const char *FBaseCVar::ToString (UCVarValue value, ECVarType type)
return cstrbuf; return cstrbuf;
} }
const GUID *FBaseCVar::ToGUID (UCVarValue value, ECVarType type)
{
UCVarValue trans;
switch (type)
{
case CVAR_String:
trans = FromString (value.String, CVAR_GUID);
return trans.pGUID;
case CVAR_GUID:
return value.pGUID;
default:
return NULL;
}
}
UCVarValue FBaseCVar::FromBool (bool value, ECVarType type) UCVarValue FBaseCVar::FromBool (bool value, ECVarType type)
{ {
UCVarValue ret; UCVarValue ret;
@ -433,10 +404,6 @@ UCVarValue FBaseCVar::FromBool (bool value, ECVarType type)
ret.String = value ? truestr : falsestr; ret.String = value ? truestr : falsestr;
break; break;
case CVAR_GUID:
ret.pGUID = NULL;
break;
default: default:
break; break;
} }
@ -467,10 +434,6 @@ UCVarValue FBaseCVar::FromInt (int value, ECVarType type)
ret.String = cstrbuf; ret.String = cstrbuf;
break; break;
case CVAR_GUID:
ret.pGUID = NULL;
break;
default: default:
break; break;
} }
@ -503,10 +466,6 @@ UCVarValue FBaseCVar::FromFloat (float value, ECVarType type)
ret.String = cstrbuf; ret.String = cstrbuf;
break; break;
case CVAR_GUID:
ret.pGUID = NULL;
break;
default: default:
break; break;
} }
@ -569,57 +528,6 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type)
ret.String = const_cast<char *>(value); ret.String = const_cast<char *>(value);
break; break;
case CVAR_GUID:
// {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
// 01234567890123456789012345678901234567
// 0 1 2 3
ret.pGUID = NULL;
if (value == NULL)
{
break;
}
for (i = 0; value[i] != 0 && i < 38; i++)
{
switch (i)
{
case 0:
if (value[i] != '{')
break;
case 9:
case 14:
case 19:
case 24:
if (value[i] != '-')
break;
case 37:
if (value[i] != '}')
break;
default:
if (value[i] < '0' ||
(value[i] > '9' && value[i] < 'A') ||
(value[i] > 'F' && value[i] < 'a') ||
value[i] > 'f')
break;
}
}
if (i == 38 && value[i] == 0)
{
cGUID.Data1 = strtoul (value + 1, NULL, 16);
cGUID.Data2 = (uint16_t)strtoul (value + 10, NULL, 16);
cGUID.Data3 = (uint16_t)strtoul (value + 15, NULL, 16);
cGUID.Data4[0] = HexToByte (value + 20);
cGUID.Data4[1] = HexToByte (value + 22);
cGUID.Data4[2] = HexToByte (value + 25);
cGUID.Data4[3] = HexToByte (value + 27);
cGUID.Data4[4] = HexToByte (value + 29);
cGUID.Data4[5] = HexToByte (value + 31);
cGUID.Data4[6] = HexToByte (value + 33);
cGUID.Data4[7] = HexToByte (value + 35);
ret.pGUID = &cGUID;
}
break;
default: default:
break; break;
} }
@ -627,39 +535,6 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type)
return ret; return ret;
} }
UCVarValue FBaseCVar::FromGUID (const GUID &guid, ECVarType type)
{
UCVarValue ret;
switch (type)
{
case CVAR_Bool:
ret.Bool = false;
break;
case CVAR_Int:
ret.Int = 0;
break;
case CVAR_Float:
ret.Float = 0.f;
break;
case CVAR_String:
ret.pGUID = &guid;
ret.String = ToString (ret, CVAR_GUID);
break;
case CVAR_GUID:
ret.pGUID = &guid;
break;
default:
break;
}
return ret;
}
FBaseCVar *cvar_set (const char *var_name, const char *val) FBaseCVar *cvar_set (const char *var_name, const char *val)
{ {
FBaseCVar *var; FBaseCVar *var;
@ -1053,80 +928,6 @@ int FColorCVar::ToInt2 (UCVarValue value, ECVarType type)
return ret; return ret;
} }
//
// GUID cvar implementation
//
FGUIDCVar::FGUIDCVar (const char *name, const GUID *def, uint32_t flags, void (*callback)(FGUIDCVar &))
: FBaseCVar (name, flags, reinterpret_cast<void (*)(FBaseCVar &)>(callback))
{
if (def != NULL)
{
DefaultValue = *def;
if (Flags & CVAR_ISDEFAULT)
Value = *def;
}
else
{
memset (&Value, 0, sizeof(DefaultValue));
memset (&DefaultValue, 0, sizeof(DefaultValue));
}
}
ECVarType FGUIDCVar::GetRealType () const
{
return CVAR_GUID;
}
UCVarValue FGUIDCVar::GetGenericRep (ECVarType type) const
{
return FromGUID (Value, type);
}
UCVarValue FGUIDCVar::GetFavoriteRep (ECVarType *type) const
{
UCVarValue ret;
*type = CVAR_GUID;
ret.pGUID = &Value;
return ret;
}
UCVarValue FGUIDCVar::GetGenericRepDefault (ECVarType type) const
{
return FromGUID (DefaultValue, type);
}
UCVarValue FGUIDCVar::GetFavoriteRepDefault (ECVarType *type) const
{
UCVarValue ret;
*type = CVAR_GUID;
ret.pGUID = &DefaultValue;
return ret;
}
void FGUIDCVar::SetGenericRepDefault (UCVarValue value, ECVarType type)
{
const GUID *guid = ToGUID (value, type);
if (guid != NULL)
{
Value = *guid;
if (Flags & CVAR_ISDEFAULT)
{
SetGenericRep (value, type);
Flags |= CVAR_ISDEFAULT;
}
}
}
void FGUIDCVar::DoSet (UCVarValue value, ECVarType type)
{
const GUID *guid = ToGUID (value, type);
if (guid != NULL)
{
Value = *guid;
}
}
// //
// More base cvar stuff // More base cvar stuff
// //

View file

@ -34,7 +34,7 @@
#ifndef __C_CVARS_H__ #ifndef __C_CVARS_H__
#define __C_CVARS_H__ #define __C_CVARS_H__
#include "doomtype.h" #include "zstring.h"
#include "tarray.h" #include "tarray.h"
/* /*
@ -73,7 +73,6 @@ union UCVarValue
int Int; int Int;
float Float; float Float;
const char *String; const char *String;
const GUID *pGUID;
}; };
enum ECVarType enum ECVarType
@ -85,8 +84,7 @@ enum ECVarType
CVAR_Color, // stored as CVAR_Int CVAR_Color, // stored as CVAR_Int
CVAR_DummyBool, // just redirects to another cvar CVAR_DummyBool, // just redirects to another cvar
CVAR_DummyInt, // just redirects to another cvar CVAR_DummyInt, // just redirects to another cvar
CVAR_Dummy, // Unknown CVAR_Dummy // Unknown
CVAR_GUID
}; };
class FConfigFile; class FConfigFile;
@ -140,12 +138,10 @@ protected:
static int ToInt (UCVarValue value, ECVarType type); static int ToInt (UCVarValue value, ECVarType type);
static float ToFloat (UCVarValue value, ECVarType type); static float ToFloat (UCVarValue value, ECVarType type);
static const char *ToString (UCVarValue value, ECVarType type); static const char *ToString (UCVarValue value, ECVarType type);
static const GUID *ToGUID (UCVarValue value, ECVarType type);
static UCVarValue FromBool (bool value, ECVarType type); static UCVarValue FromBool (bool value, ECVarType type);
static UCVarValue FromInt (int value, ECVarType type); static UCVarValue FromInt (int value, ECVarType type);
static UCVarValue FromFloat (float value, ECVarType type); static UCVarValue FromFloat (float value, ECVarType type);
static UCVarValue FromString (const char *value, ECVarType type); static UCVarValue FromString (const char *value, ECVarType type);
static UCVarValue FromGUID (const GUID &value, ECVarType type);
char *Name; char *Name;
FString SafeValue; FString SafeValue;
@ -403,31 +399,6 @@ protected:
int BitNum; int BitNum;
}; };
class FGUIDCVar : public FBaseCVar
{
public:
FGUIDCVar (const char *name, const GUID *defguid, uint32_t flags, void (*callback)(FGUIDCVar &)=NULL);
virtual ECVarType GetRealType () const;
virtual UCVarValue GetGenericRep (ECVarType type) const;
virtual UCVarValue GetFavoriteRep (ECVarType *type) const;
virtual UCVarValue GetGenericRepDefault (ECVarType type) const;
virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const;
virtual void SetGenericRepDefault (UCVarValue value, ECVarType type);
const GUID &operator= (const GUID &guidval)
{ UCVarValue val; val.pGUID = &guidval; SetGenericRep (val, CVAR_GUID); return guidval; }
inline operator const GUID & () const { return Value; }
inline const GUID &operator *() const { return Value; }
protected:
virtual void DoSet (UCVarValue value, ECVarType type);
GUID Value;
GUID DefaultValue;
};
extern int cvar_defflags; extern int cvar_defflags;
FBaseCVar *cvar_set (const char *var_name, const char *value); FBaseCVar *cvar_set (const char *var_name, const char *value);

View file

@ -36,6 +36,7 @@
#import <Foundation/NSRunLoop.h> #import <Foundation/NSRunLoop.h>
#include "c_cvars.h" #include "c_cvars.h"
#include "doomtype.h"
#include "st_console.h" #include "st_console.h"
#include "st_start.h" #include "st_start.h"

View file

@ -1,6 +1,8 @@
#ifndef __RES_CMAP_H #ifndef __RES_CMAP_H
#define __RES_CMAP_H #define __RES_CMAP_H
#include "doomtype.h"
struct lightlist_t; struct lightlist_t;
void R_InitColormaps (); void R_InitColormaps ();

View file

@ -29,6 +29,7 @@
#include "gl_load/gl_system.h" #include "gl_load/gl_system.h"
#include "templates.h" #include "templates.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "doomtype.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "hwrenderer/textures/hw_material.h" #include "hwrenderer/textures/hw_material.h"

View file

@ -39,6 +39,7 @@
#include "doomdef.h" #include "doomdef.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "doomstat.h" #include "doomstat.h"
#include "doomtype.h"
//========================================================================== //==========================================================================
// //