From 3700dea3361361999d6b4102a0551faa42783c53 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Feb 2017 22:05:20 +0100 Subject: [PATCH] Revert "- the UDMF health key for actors was not correctly implemented. This addresses the problem by adding a second one and documenting 'Health' as implemented." This reverts commit e4e023e59a516aa8d74b7db02b27dbe6c45fa542. (This was nonsense.) --- specs/udmf_zdoom.txt | 4 ++-- src/dobjtype.cpp | 14 ++++++++++++-- src/dobjtype.h | 5 ++++- src/namedef.h | 1 - src/p_udmf.cpp | 16 ---------------- 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/specs/udmf_zdoom.txt b/specs/udmf_zdoom.txt index 553c753603..f4af55f2df 100644 --- a/specs/udmf_zdoom.txt +++ b/specs/udmf_zdoom.txt @@ -263,8 +263,8 @@ Note: All fields default to false unless mentioned otherwise. gravity = ; // Set per-actor gravity. Positive values are multiplied with the class's property, // negative values are used as their absolute. Default = 1.0. - health = ; // Set per-actor health as an absolute value. Default = actor default. - healthfactor = ; // Set per-actor health as a factor to the original. Default = 1. + health = ; // Set per-actor health. Positive values are multiplied with the class's property, + // negative values are used as their absolute. Default = 1. renderstyle = ; // Set per-actor render style, overriding the class default. Possible values can be "normal", // "none", "add" or "additive", "subtract" or "subtractive", "stencil", "translucentstencil", diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 75193b868b..97d154a3b8 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -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) { @@ -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) @@ -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); + } } } } diff --git a/src/dobjtype.h b/src/dobjtype.h index 0151e6c119..24951c9d89 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -560,8 +560,9 @@ class PClass : public PNativeStruct protected: // We unravel _WITH_META here just as we did for PType. TArray SpecialInits; + TArray MetaInits; void Derive(PClass *newclass, FName name); - void InitializeSpecials(void *addr, void *defaults) const; + void InitializeSpecials(void *addr, void *defaults, TArray* PClass::*Inits); void SetSuper(); public: void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; @@ -582,6 +583,8 @@ 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 diff --git a/src/namedef.h b/src/namedef.h index 28de568183..bb42fc76df 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -46,7 +46,6 @@ xx(Shadow) xx(Subtract) xx(Subtractive) xx(FillColor) -xx(HealthFactor) // Healingradius types xx(Mana) diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index b9300f6543..27293b9188 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -515,7 +515,6 @@ public: FString arg0str, arg1str; memset(th, 0, sizeof(*th)); - double healthfactor = 1; th->Gravity = 1; th->RenderStyle = STYLE_Count; th->Alpha = -1; @@ -739,52 +738,38 @@ public: 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; @@ -808,7 +793,6 @@ public: { 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)