- do floatification of the UDMF Health property as it should have been.

This commit is contained in:
Christoph Oelckers 2017-02-28 00:59:09 +01:00
parent 3700dea336
commit 4a87a598fb
7 changed files with 14 additions and 27 deletions

View File

@ -263,7 +263,7 @@ Note: All <bool> fields default to false unless mentioned otherwise.
gravity = <float>; // Set per-actor gravity. Positive values are multiplied with the class's property,
// negative values are used as their absolute. Default = 1.0.
health = <int>; // Set per-actor health. Positive values are multiplied with the class's property,
health = <float>; // Set per-actor health. Positive values are multiplied with the class's property,
// negative values are used as their absolute. Default = 1.
renderstyle = <string>; // Set per-actor render style, overriding the class default. Possible values can be "normal",

View File

@ -3160,6 +3160,7 @@ void PClass::InitializeDefaults()
optr->ObjNext = nullptr;
optr->SetClass(this);
// Copy the defaults from the parent but leave the DObject part alone because it contains important data.
if (ParentClass->Defaults != nullptr)
{
@ -3173,13 +3174,6 @@ void PClass::InitializeDefaults()
{
memset(Defaults + sizeof(DObject), 0, Size - sizeof(DObject));
}
if (MetaSize != 0)
{
Meta = (BYTE*)ClassDataAllocator.Alloc(MetaSize);
memset(Meta, 0, MetaSize);
if (ParentClass->MetaSize > 0) memcpy(Meta, ParentClass->Meta, ParentClass->MetaSize);
}
}
if (bRuntimeClass)
@ -3189,14 +3183,10 @@ void PClass::InitializeDefaults()
if (Defaults != nullptr) ParentClass->InitializeSpecials(Defaults, ParentClass->Defaults);
for (const PField *field : Fields)
{
if (!(field->Flags & VARF_Native) && !(field->Flags & VARF_Meta))
if (!(field->Flags & VARF_Native))
{
field->Type->SetDefaultValue(Defaults, unsigned(field->Offset), &SpecialInits);
}
if (!(field->Flags & VARF_Native) && (field->Flags & VARF_Meta))
{
field->Type->SetDefaultValue(Meta, unsigned(field->Offset), &MetaInits);
}
}
}
}

View File

@ -560,9 +560,8 @@ class PClass : public PNativeStruct
protected:
// We unravel _WITH_META here just as we did for PType.
TArray<FTypeAndOffset> SpecialInits;
TArray<FTypeAndOffset> MetaInits;
void Derive(PClass *newclass, FName name);
void InitializeSpecials(void *addr, void *defaults, TArray<FTypeAndOffset>* PClass::*Inits);
void InitializeSpecials(void *addr, void *defaults) const;
void SetSuper();
public:
void WriteValue(FSerializer &ar, const char *key,const void *addr) const override;
@ -583,8 +582,6 @@ public:
const size_t *FlatPointers; // object pointers defined by this class and all its superclasses; not initialized by default
const size_t *ArrayPointers; // dynamic arrays containing object pointers.
BYTE *Defaults;
BYTE *Meta; // Per-class static script data
unsigned MetaSize;
bool bRuntimeClass; // class was defined at run-time, not compile-time
bool bExported; // This type has been declared in a script
bool bDecorateClass; // may be subject to some idiosyncracies due to DECORATE backwards compatibility

View File

@ -359,7 +359,7 @@ struct FMapThing
double Alpha;
DWORD fillcolor;
DVector2 Scale;
int health;
double Health;
int score;
short pitch;
short roll;

View File

@ -5930,13 +5930,13 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
mobj->LevelSpawned ();
}
if (mthing->health > 0)
mobj->health *= mthing->health;
if (mthing->Health > 0)
mobj->health = int(mobj->health * mthing->Health);
else
mobj->health = -mthing->health;
if (mthing->health == 0)
mobj->health = -int(mthing->Health);
if (mthing->Health == 0)
mobj->CallDie(NULL, NULL);
else if (mthing->health != 1)
else if (mthing->Health != 1)
mobj->StartHealth = mobj->health;
return mobj;

View File

@ -1741,7 +1741,7 @@ void P_LoadThings (MapData * map)
mti[i].ClassFilter = 0xffff; // Doom map format doesn't have class flags so spawn for all player classes
mti[i].RenderStyle = STYLE_Count;
mti[i].Alpha = -1;
mti[i].health = 1;
mti[i].Health = 1;
mti[i].FloatbobPhase = -1;
mti[i].pos.X = LittleShort(mt->x);
@ -1837,7 +1837,7 @@ void P_LoadThings2 (MapData * map)
mti[i].Gravity = 1;
mti[i].RenderStyle = STYLE_Count;
mti[i].Alpha = -1;
mti[i].health = 1;
mti[i].Health = 1;
mti[i].FloatbobPhase = -1;
}
delete[] mtp;

View File

@ -518,7 +518,7 @@ public:
th->Gravity = 1;
th->RenderStyle = STYLE_Count;
th->Alpha = -1;
th->health = 1;
th->Health = 1;
th->FloatbobPhase = -1;
sc.MustGetToken('{');
while (!sc.CheckToken('}'))
@ -746,7 +746,7 @@ public:
break;
case NAME_Health:
th->health = CheckInt(key);
th->Health = CheckFloat(key);
break;
case NAME_Score: