From f31ddbc57cbbb5ac373a916dc759a16b87dcebde Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 26 Feb 2017 17:05:04 +0100 Subject: [PATCH] - allow specifying specials in ZSDF by name. - allow specifying a decal ID by name in UDMF. --- specs/usdf_zdoom.txt | 2 ++ src/g_shared/a_decals.cpp | 15 ++++++++++++--- src/namedef.h | 1 + src/p_usdf.cpp | 5 +++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/specs/usdf_zdoom.txt b/specs/usdf_zdoom.txt index cd4393351d..2025b06ba6 100644 --- a/specs/usdf_zdoom.txt +++ b/specs/usdf_zdoom.txt @@ -92,6 +92,8 @@ conversation // Starts a dialog. choice { + specialname = ; // Allows specifying a special by name. + // The amount of an item needed for this option to become available. // You can have as many as needed. All require blocks must be satisfied // to show this option. diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index dfa66795ca..3ad19741ad 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -751,14 +751,23 @@ IMPLEMENT_CLASS(ADecal, false, false) void ADecal::BeginPlay () { - const FDecalTemplate *tpl; + const FDecalTemplate *tpl = nullptr; Super::BeginPlay (); - int decalid = args[0] + (args[1] << 8); // [KS] High byte for decals. + if (args[0] < 0) + { + FName name = ENamedName(-args[0]); + tpl = DecalLibrary.GetDecalByName(name.GetChars()); + } + else + { + int decalid = args[0] + (args[1] << 8); // [KS] High byte for decals. + tpl = DecalLibrary.GetDecalByNum(decalid); + } // If no decal is specified, don't try to create one. - if (decalid != 0 && (tpl = DecalLibrary.GetDecalByNum (decalid)) != 0) + if (tpl != nullptr) { if (!tpl->PicNum.Exists()) { diff --git a/src/namedef.h b/src/namedef.h index dd4a4f5e32..9cd0a19ecb 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -360,6 +360,7 @@ xx(CeilingZ) xx(FloorZ) xx(Health) xx(Pitch) +xx(SpecialName) xx(Special) xx(TID) xx(TIDtoHate) diff --git a/src/p_usdf.cpp b/src/p_usdf.cpp index 8c8a0c6e34..3d2c2e010f 100644 --- a/src/p_usdf.cpp +++ b/src/p_usdf.cpp @@ -196,6 +196,11 @@ class USDFParser : public UDMFParserBase reply->ActionSpecial = 0; break; + case NAME_SpecialName: + if (namespace_bits == Zd) + reply->ActionSpecial = P_FindLineSpecial(CheckString(key)); + break; + case NAME_Arg0: case NAME_Arg1: case NAME_Arg2: