From a5ee673c915424a86d50d87332884ac303b78543 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 19 Nov 2018 17:54:38 +0100 Subject: [PATCH] - exported ADecal to ZScript as a non-native class. Its one function is still native but this was by far the easiest of the remaining actor classes to export. --- src/g_shared/a_decals.cpp | 31 +++++++++----------------- wadsrc/static/zscript/shared/decal.txt | 10 ++++++++- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index 19216ecd2..bb503fec0 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -43,6 +43,7 @@ #include "serializer.h" #include "doomdata.h" #include "g_levellocals.h" +#include "vm.h" static double DecalWidth, DecalLeft, DecalRight; static double SpreadZ; @@ -753,29 +754,20 @@ DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t * return NULL; } -class ADecal : public AActor +DEFINE_ACTION_FUNCTION(ADecal, SpawnDecal) { - DECLARE_CLASS (ADecal, AActor); -public: - void BeginPlay (); -}; + PARAM_SELF_PROLOGUE(AActor); -IMPLEMENT_CLASS(ADecal, false, false) - -void ADecal::BeginPlay () -{ const FDecalTemplate *tpl = nullptr; - Super::BeginPlay (); - - if (args[0] < 0) + if (self->args[0] < 0) { - FName name = ENamedName(-args[0]); + FName name = ENamedName(-self->args[0]); tpl = DecalLibrary.GetDecalByName(name.GetChars()); } else { - int decalid = args[0] + (args[1] << 8); // [KS] High byte for decals. + int decalid = self->args[0] + (self->args[1] << 8); // [KS] High byte for decals. tpl = DecalLibrary.GetDecalByNum(decalid); } @@ -784,23 +776,22 @@ void ADecal::BeginPlay () { if (!tpl->PicNum.Exists()) { - Printf("Decal actor at (%f,%f) does not have a valid texture\n", X(), Y()); + Printf("Decal actor at (%f,%f) does not have a valid texture\n", self->X(), self->Y()); } else { // Look for a wall within 64 units behind the actor. If none can be // found, then no decal is created, and this actor is destroyed // without effectively doing anything. - if (NULL == ShootDecal(tpl, this, Sector, X(), Y(), Z(), Angles.Yaw + 180, 64., true)) + if (NULL == ShootDecal(tpl, self, self->Sector, self->X(), self->Y(), self->Z(), self->Angles.Yaw + 180, 64., true)) { - DPrintf (DMSG_WARNING, "Could not find a wall to stick decal to at (%f,%f)\n", X(), Y()); + DPrintf (DMSG_WARNING, "Could not find a wall to stick decal to at (%f,%f)\n", self->X(), self->Y()); } } } else { - DPrintf (DMSG_ERROR, "Decal actor at (%f,%f) does not have a good template\n", X(), Y()); + DPrintf (DMSG_ERROR, "Decal actor at (%f,%f) does not have a good template\n", self->X(), self->Y()); } - // This actor doesn't need to stick around anymore. - Destroy(); + return 0; } diff --git a/wadsrc/static/zscript/shared/decal.txt b/wadsrc/static/zscript/shared/decal.txt index 0614f6235..7317ecce1 100644 --- a/wadsrc/static/zscript/shared/decal.txt +++ b/wadsrc/static/zscript/shared/decal.txt @@ -1,3 +1,11 @@ -class Decal : Actor native +class Decal : Actor { + native void SpawnDecal(); + + override void BeginPlay() + { + Super.BeginPlay(); + SpawnDecal(); + Destroy(); + } }