From 3023af8223bd7c40941f5881b25f82b9d167160b Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 17 Dec 2016 12:46:40 -0600 Subject: [PATCH 1/4] - Added A_SetSize(double newradius, double newheight = -1). - Changes the calling actor's radius and height. --- src/p_actionfunctions.cpp | 16 ++++++++++++++++ wadsrc/static/zscript/actor.txt | 1 + 2 files changed, 17 insertions(+) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 6ddfd52819..8c222a4f65 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -6846,3 +6846,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) } return 0; } + +DEFINE_ACTION_FUNCTION(AActor, A_SetSize) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(newradius); + PARAM_FLOAT_DEF(newheight); + + if (newradius < 0.) newradius = self->radius; + if (newheight < 0.) newheight = self->Height; + + self->UnlinkFromWorld(); + self->radius = newradius; + self->Height = newheight; + self->LinkToWorld(); + return 0; +} diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index d804a434c6..2a5d8c53d7 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -793,6 +793,7 @@ class Actor : Thinker native native bool A_CopySpriteFrame(int from, int to, int flags = 0); native bool A_SetVisibleRotation(double anglestart = 0, double angleend = 0, double pitchstart = 0, double pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetTranslation(name transname); + native void A_SetSize(double newradius, double newheight = -1); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); From 1bcebb091a059371496f025ebae5c2e3c416dba1 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 17 Dec 2016 18:31:25 -0600 Subject: [PATCH 2/4] Added option to check the location for resizing, changing the return into a bool. --- src/p_actionfunctions.cpp | 16 +++++++++++++++- wadsrc/static/zscript/actor.txt | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 8c222a4f65..13a347ef2c 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -6852,13 +6852,27 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetSize) PARAM_SELF_PROLOGUE(AActor); PARAM_FLOAT(newradius); PARAM_FLOAT_DEF(newheight); + PARAM_BOOL_DEF(testpos); if (newradius < 0.) newradius = self->radius; if (newheight < 0.) newheight = self->Height; + double oldradius = self->radius; + double oldheight = self->Height; + self->UnlinkFromWorld(); self->radius = newradius; self->Height = newheight; self->LinkToWorld(); - return 0; + + if (testpos && !P_TestMobjLocation(self)) + { + self->UnlinkFromWorld(); + self->radius = oldradius; + self->Height = oldheight; + self->LinkToWorld(); + ACTION_RETURN_BOOL(false); + } + + ACTION_RETURN_BOOL(true); } diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 2a5d8c53d7..0d264580a8 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -793,7 +793,7 @@ class Actor : Thinker native native bool A_CopySpriteFrame(int from, int to, int flags = 0); native bool A_SetVisibleRotation(double anglestart = 0, double angleend = 0, double pitchstart = 0, double pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetTranslation(name transname); - native void A_SetSize(double newradius, double newheight = -1); + native bool A_SetSize(double newradius, double newheight = -1, bool testpos = false); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); From 8dd91f7129796d4bc26258f17e303c405d739b48 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Dec 2016 12:18:03 +0100 Subject: [PATCH 3/4] - added a missing null pointer check to FxIfStatement::Emit. --- src/scripting/codegeneration/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 90fbcfe683..57b554e25f 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -8964,7 +8964,7 @@ ExpEmit FxIfStatement::Emit(VMFunctionBuilder *build) } if (WhenFalse != nullptr) { - if (!WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns. + if (WhenTrue != nullptr && !WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns. build->BackpatchListToHere(no); WhenFalse->EmitStatement(build); if (jumpspot != ~0u) build->BackpatchToHere(jumpspot); From 1fa37aaeb79d3ab1e5d4aa2b4376130e9f4826fb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Dec 2016 14:09:16 +0100 Subject: [PATCH 4/4] - fixed code generation for if statements with empty 'true' part. For those the jump statement backpatching was not done correctly. --- src/scripting/codegeneration/codegen.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 57b554e25f..8e57506606 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -8955,7 +8955,7 @@ ExpEmit FxIfStatement::Emit(VMFunctionBuilder *build) size_t jumpspot = ~0u; TArray yes, no; - Condition->EmitCompare(build, false, yes, no); + Condition->EmitCompare(build, WhenTrue == nullptr, yes, no); if (WhenTrue != nullptr) { @@ -8964,11 +8964,14 @@ ExpEmit FxIfStatement::Emit(VMFunctionBuilder *build) } if (WhenFalse != nullptr) { - if (WhenTrue != nullptr && !WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns. - build->BackpatchListToHere(no); + if (WhenTrue != nullptr) + { + if (!WhenTrue->CheckReturn()) jumpspot = build->Emit(OP_JMP, 0); // no need to emit a jump if the block returns. + build->BackpatchListToHere(no); + } WhenFalse->EmitStatement(build); if (jumpspot != ~0u) build->BackpatchToHere(jumpspot); - if (WhenTrue == nullptr) build->BackpatchListToHere(yes); + if (WhenTrue == nullptr) build->BackpatchListToHere(no); } else {