- got rid of FNameNoInit and made the default constructor of FName non-initializing.

This setup has been a constant source of problems so now I reviewed all uses of FName to make sure that everything that needs to be initialized is done manually.
This also merges the player_t constructor into the class definition as default values.
This commit is contained in:
Christoph Oelckers 2018-08-19 01:14:15 +02:00
commit fad406c4c9
47 changed files with 185 additions and 309 deletions

View file

@ -9336,10 +9336,8 @@ ExpEmit FxFlopFunctionCall::Emit(VMFunctionBuilder *build)
//==========================================================================
FxVectorBuiltin::FxVectorBuiltin(FxExpression *self, FName name)
:FxExpression(EFX_VectorBuiltin, self->ScriptPosition)
:FxExpression(EFX_VectorBuiltin, self->ScriptPosition), Function(name), Self(self)
{
Self = self;
Function = name;
}
FxVectorBuiltin::~FxVectorBuiltin()
@ -11136,7 +11134,7 @@ ExpEmit FxRuntimeStateIndex::Emit(VMFunctionBuilder *build)
FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPosition &pos, PClassActor *checkclass)
:FxExpression(EFX_MultiNameState, pos)
{
FName scopename;
FName scopename = NAME_None;
FString statestring = _statestring;
int scopeindex = statestring.IndexOf("::");
@ -11145,10 +11143,6 @@ FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPositi
scopename = FName(statestring, scopeindex, false);
statestring = statestring.Right(statestring.Len() - scopeindex - 2);
}
else
{
scopename = NAME_None;
}
names = MakeStateNameList(statestring);
names.Insert(0, scopename);
scope = checkclass;

View file

@ -369,7 +369,7 @@ public:
class FxIdentifier : public FxExpression
{
public:
FName Identifier;
FName Identifier = NAME_None;
bool noglobal = false;
FxIdentifier(FName i, const FScriptPosition &p);

View file

@ -101,12 +101,11 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
FExtraInfo extra;
PClassActor *type;
PClassActor *parent;
FName typeName;
parent = (def == DEF_Pickup) ? PClass::FindActor("FakeInventory") : RUNTIME_CLASS(AActor);
sc.MustGetString();
typeName = FName(sc.String);
FName typeName = FName(sc.String);
type = DecoDerivedClass(FScriptPosition(sc), parent, typeName);
ResetBaggage(&bag, parent);
bag.Namespace = ns;

View file

@ -421,7 +421,7 @@ static FxExpression *ParseExpression0 (FScanner &sc, PClassActor *cls)
}
else if (sc.CheckToken(TK_NameConst))
{
return new FxConstant(sc.Name, scpos);
return new FxConstant(FName(sc.String), scpos);
}
else if (sc.CheckToken(TK_StringConst))
{

View file

@ -1029,9 +1029,7 @@ PClassActor *CreateNewActor(const FScriptPosition &sc, FName typeName, FName par
//==========================================================================
static PClassActor *ParseActorHeader(FScanner &sc, Baggage *bag)
{
FName typeName;
FName parentName;
FName replaceName;
FName replaceName = NAME_None;
bool native = false;
int DoomEdNum = -1;
@ -1044,7 +1042,7 @@ static PClassActor *ParseActorHeader(FScanner &sc, Baggage *bag)
*colon++ = 0;
}
typeName = sc.String;
FName typeName = sc.String;
// Do some tweaking so that a definition like 'Actor:Parent' which is read as a single token is recognized as well
// without having resort to C-mode (which disallows periods in actor names.)
@ -1071,7 +1069,7 @@ static PClassActor *ParseActorHeader(FScanner &sc, Baggage *bag)
sc.UnGet();
}
parentName = colon;
FName parentName = colon;
// Check for "replaces"
if (sc.CheckString ("replaces"))

View file

@ -569,9 +569,8 @@ DEFINE_PROPERTY(painchance, ZI, Actor)
}
else
{
FName painType;
if (!stricmp(str, "Normal")) painType = NAME_None;
else painType=str;
FName painType = NAME_None;
if (stricmp(str, "Normal")) painType = str;
info->SetPainChance(painType, id);
}
@ -897,15 +896,14 @@ DEFINE_PROPERTY(damagefactor, ZF, Actor)
PROP_STRING_PARM(str, 0);
PROP_DOUBLE_PARM(id, 1);
if (str == NULL)
if (str == nullptr)
{
defaults->DamageFactor = id;
}
else
{
FName dmgType;
if (!stricmp(str, "Normal")) dmgType = NAME_None;
else dmgType=str;
FName dmgType = NAME_None;
if (stricmp(str, "Normal")) dmgType = str;
info->SetDamageFactor(dmgType, id);
}

View file

@ -1593,10 +1593,8 @@ PClassPointer *NewClassPointer(PClass *restrict)
//==========================================================================
PEnum::PEnum(FName name, PTypeBase *outer)
: PInt(4, false)
: PInt(4, false), Outer(outer), EnumName(name)
{
EnumName = name;
Outer = outer;
Flags |= TYPE_IntNotInt;
mDescriptiveName.Format("Enum<%s>", name.GetChars());
}

View file

@ -238,10 +238,10 @@ protected:
class PContainerType : public PCompoundType
{
public:
PTypeBase *Outer; // object this type is contained within
FName TypeName; // this type's name
PTypeBase *Outer = nullptr; // object this type is contained within
FName TypeName = NAME_None; // this type's name
PContainerType() : Outer(NULL)
PContainerType()
{
mDescriptiveName = "ContainerType";
Flags |= TYPE_Container;

View file

@ -274,7 +274,7 @@ static void ParseSingleFile(FScanner *pSC, const char *filename, int lump, void
break;
case TK_NameConst:
value.Int = sc.Name;
value.Int = FName(sc.String).GetIndex();
tokentype = ZCC_NAMECONST;
break;