From 656b8cb16e0baec82589f124b689397f5271e2f2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 25 Oct 2016 10:15:24 +0200 Subject: [PATCH] - added explicit setter functions for the count and link flags so that A_ChangeFlag and A_SetFlag can be deprecated. --- src/p_actionfunctions.cpp | 68 +++++++++++++++++++++++++++++ wadsrc/static/zscript.txt | 2 + wadsrc/static/zscript/actor.txt | 6 ++- wadsrc/static/zscript/constants.txt | 5 +++ 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index f389cd1eeb..3d9ccb3262 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -4852,6 +4852,74 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFlag) } +//=========================================================================== +// +// A_ChangeCountFlags (needed, because these flags affect global counters) +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeLinkFlags) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT_OPT(blockmap) { blockmap = -1; } + PARAM_INT_OPT(sector) { sector = -1; } + + self->UnlinkFromWorld(); + + if (blockmap != -1) + { + if (blockmap == 0) self->flags &= MF_NOBLOCKMAP; + else self->flags |= MF_NOBLOCKMAP; + } + + if (sector != -1) + { + if (sector == 0) self->flags &= MF_NOSECTOR; + else self->flags |= MF_NOSECTOR; + } + + self->LinkToWorld(); + return 0; +} + +//=========================================================================== +// +// A_ChangeCountFlags (needed, because these flags affect global counters) +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeCountFlags) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT_OPT(kill) { kill = -1; } + PARAM_INT_OPT(item) { item = -1; } + PARAM_INT_OPT(secret) { secret = -1; } + + if (self->CountsAsKill() && self->health > 0) --level.total_monsters; + if (self->flags & MF_COUNTITEM) --level.total_items; + if (self->flags5 & MF5_COUNTSECRET) --level.total_secrets; + + if (kill != -1) + { + if (kill == 0) self->flags &= MF_COUNTKILL; + else self->flags |= MF_COUNTKILL; + } + + if (item != -1) + { + if (item == 0) self->flags &= MF_COUNTITEM; + else self->flags |= MF_COUNTITEM; + } + + if (secret != -1) + { + if (secret == 0) self->flags5 &= MF5_COUNTSECRET; + else self->flags5 |= MF5_COUNTSECRET; + } + if (self->CountsAsKill() && self->health > 0) ++level.total_monsters; + if (self->flags & MF_COUNTITEM) ++level.total_items; + if (self->flags5 & MF5_COUNTSECRET) ++level.total_secrets; + return 0; +} + //=========================================================================== // // A_RaiseMaster diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 6de64d07e5..3ab33bfd96 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -177,3 +177,5 @@ zscript/chex/chexweapons.txt zscript/chex/chexitems.txt zscript/chex/chexdecorations.txt zscript/chex/chexplayer.txt + +zscript/test2.txt diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index b6d65a29e9..fa45eb0e67 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -238,8 +238,10 @@ class Actor : Thinker native native void A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false); native void A_DropInventory(class itemtype); native void A_SetBlend(color color1, float alpha, int tics, color color2 = ""); - native void A_ChangeFlag(string flagname, bool value); - native state A_CheckFlag(string flagname, state label, int check_pointer = AAPTR_DEFAULT); + deprecated native void A_ChangeFlag(string flagname, bool value); + deprecated native state A_CheckFlag(string flagname, state label, int check_pointer = AAPTR_DEFAULT); + native void A_ChangeCountFlags(int kill = FLAG_NO_CHANGE, int item = FLAG_NO_CHANGE, int secret = FLAG_NO_CHANGE); + native void A_ChangeLinkFlags(int blockmap = FLAG_NO_CHANGE, int sector = FLAG_NO_CHANGE); native state A_JumpIf(bool expression, state label); native void A_RaiseMaster(bool copy = 0); native void A_RaiseChildren(bool copy = 0); diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index b98846d8bd..9792ec2301 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -1,3 +1,6 @@ +// for flag changer functions. +const int FLAG_NO_CHANGE = -1; + // Flags for A_PainAttack enum EPainAttackFlags { @@ -820,3 +823,5 @@ struct FStateParamInfo EStateType mStateType; int mPSPIndex; } + +