From c5237ce58f5c69613af9d6091d33094ab3bde18f Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 27 Oct 2019 16:29:00 +0200 Subject: [PATCH] - level post-processor can now add new things --- src/maploader/maploader.cpp | 36 ++++++++++++++++++++ wadsrc/static/zscript/level_postprocessor.zs | 4 +++ 2 files changed, 40 insertions(+) diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index efc873475..65d7201b7 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -3381,6 +3381,42 @@ DEFINE_ACTION_FUNCTION(DLevelPostProcessor, GetThingCount) ACTION_RETURN_INT(self->loader->MapThingsConverted.Size()); } +DEFINE_ACTION_FUNCTION(DLevelPostProcessor, AddThing) +{ + PARAM_SELF_PROLOGUE(DLevelPostProcessor); + PARAM_UINT(ednum); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_INT(angle); + PARAM_UINT(skills); + PARAM_UINT(flags); + + auto &things = self->loader->MapThingsConverted; + const unsigned newindex = things.Size(); + things.Resize(newindex + 1); + + auto &newthing = things.Last(); + memset(&newthing, 0, sizeof newthing); + + newthing.Gravity = 1; + newthing.SkillFilter = skills; + newthing.ClassFilter = 0xFFFF; + newthing.RenderStyle = STYLE_Count; + newthing.Alpha = -1; + newthing.Health = 1; + newthing.FloatbobPhase = -1; + newthing.pos.X = x; + newthing.pos.Y = y; + newthing.pos.Z = z; + newthing.angle = angle; + newthing.EdNum = ednum; + newthing.info = DoomEdMap.CheckKey(ednum); + newthing.flags = flags; + + ACTION_RETURN_INT(newindex); +} + DEFINE_ACTION_FUNCTION(DLevelPostProcessor, GetThingEdNum) { PARAM_SELF_PROLOGUE(DLevelPostProcessor); diff --git a/wadsrc/static/zscript/level_postprocessor.zs b/wadsrc/static/zscript/level_postprocessor.zs index 3c38da6b0..cbea8504d 100644 --- a/wadsrc/static/zscript/level_postprocessor.zs +++ b/wadsrc/static/zscript/level_postprocessor.zs @@ -13,7 +13,11 @@ class LevelPostProcessor native play protected native void AddLineID(int line, int tag); protected native void OffsetSectorPlane(int sector, int plane, double offset); + const SKILLS_ALL = 31; + const MODES_ALL = MTF_SINGLE | MTF_COOPERATIVE | MTF_DEATHMATCH; + protected native uint GetThingCount(); + protected native uint AddThing(int ednum, Vector3 pos, int angle = 0, uint skills = SKILLS_ALL, uint flags = MODES_ALL); protected native int GetThingEdNum(uint thing); protected native void SetThingEdNum(uint thing, int ednum);