Skip to content

Commit

Permalink
Revert "- the UDMF health key for actors was not correctly implemente…
Browse files Browse the repository at this point in the history
…d. This addresses the problem by adding a second one and documenting 'Health' as implemented."

This reverts commit e4e023e.

(This was nonsense.)
  • Loading branch information
coelckers committed Feb 27, 2017
1 parent d5d383e commit 3700dea
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions specs/udmf_zdoom.txt
Expand Up @@ -263,8 +263,8 @@ 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 as an absolute value. Default = actor default.
healthfactor = <float>; // Set per-actor health as a factor to the original. Default = 1.
health = <int>; // 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",
// "none", "add" or "additive", "subtract" or "subtractive", "stencil", "translucentstencil",
Expand Down
14 changes: 12 additions & 2 deletions src/dobjtype.cpp
Expand Up @@ -3160,7 +3160,6 @@ 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)
{
Expand All @@ -3174,6 +3173,13 @@ 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)
Expand All @@ -3183,10 +3189,14 @@ void PClass::InitializeDefaults()
if (Defaults != nullptr) ParentClass->InitializeSpecials(Defaults, ParentClass->Defaults);
for (const PField *field : Fields)
{
if (!(field->Flags & VARF_Native))
if (!(field->Flags & VARF_Native) && !(field->Flags & VARF_Meta))
{
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);
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/dobjtype.h
Expand Up @@ -560,8 +560,9 @@ 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) const;
void InitializeSpecials(void *addr, void *defaults, TArray<FTypeAndOffset>* PClass::*Inits);
void SetSuper();
public:
void WriteValue(FSerializer &ar, const char *key,const void *addr) const override;
Expand All @@ -582,6 +583,8 @@ class PClass : public PNativeStruct
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
Expand Down
1 change: 0 additions & 1 deletion src/namedef.h
Expand Up @@ -46,7 +46,6 @@ xx(Shadow)
xx(Subtract)
xx(Subtractive)
xx(FillColor)
xx(HealthFactor)

// Healingradius types
xx(Mana)
Expand Down
16 changes: 0 additions & 16 deletions src/p_udmf.cpp
Expand Up @@ -515,7 +515,6 @@ class UDMFParser : public UDMFParserBase
FString arg0str, arg1str;

memset(th, 0, sizeof(*th));
double healthfactor = 1;
th->Gravity = 1;
th->RenderStyle = STYLE_Count;
th->Alpha = -1;
Expand Down Expand Up @@ -739,52 +738,38 @@ class UDMFParser : public UDMFParserBase
break;

case NAME_Alpha:
CHECK_N(Zd | Zdt)
th->Alpha = CheckFloat(key);
break;

case NAME_FillColor:
CHECK_N(Zd | Zdt)
th->fillcolor = CheckInt(key);
break;

case NAME_Health:
CHECK_N(Zd | Zdt)
th->health = CheckInt(key);
break;

case NAME_HealthFactor:
CHECK_N(Zd | Zdt)
healthfactor = CheckFloat(key);
break;

case NAME_Score:
CHECK_N(Zd | Zdt)
th->score = CheckInt(key);
break;

case NAME_Pitch:
CHECK_N(Zd | Zdt)
th->pitch = (short)CheckInt(key);
break;

case NAME_Roll:
CHECK_N(Zd | Zdt)
th->roll = (short)CheckInt(key);
break;

case NAME_ScaleX:
CHECK_N(Zd | Zdt)
th->Scale.X = CheckFloat(key);
break;

case NAME_ScaleY:
CHECK_N(Zd | Zdt)
th->Scale.Y = CheckFloat(key);
break;

case NAME_Scale:
CHECK_N(Zd | Zdt)
th->Scale.X = th->Scale.Y = CheckFloat(key);
break;

Expand All @@ -808,7 +793,6 @@ class UDMFParser : public UDMFParserBase
{
th->args[1] = -FName(arg1str);
}
th->health = int(th->health * healthfactor);
// Thing specials are only valid in namespaces with Hexen-type specials
// and in ZDoomTranslated - which will use the translator on them.
if (namespc == NAME_ZDoomTranslated)
Expand Down

0 comments on commit 3700dea

Please sign in to comment.