From c160121f4535d9d5aab394e01c585e942a3463c0 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 1 Mar 2016 11:36:15 -0600 Subject: [PATCH] Add float casts to DECORATE for the sake of completeness --- src/namedef.h | 3 ++- src/thingdef/thingdef_codeptr.cpp | 35 ++++++++++++++-------------- src/thingdef/thingdef_expression.cpp | 3 ++- src/thingdef/thingdef_states.cpp | 2 ++ wadsrc/static/actors/actor.txt | 1 + 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/namedef.h b/src/namedef.h index 567d43f5ca..cca8727061 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -690,4 +690,5 @@ xx(Max_10_Exp) xx(__decorate_internal_int__) xx(__decorate_internal_bool__) -xx(__decorate_internal_state__) \ No newline at end of file +xx(__decorate_internal_state__) +xx(__decorate_internal_float__) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index c1724c2c56..fda1a44778 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -360,8 +360,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetGibHealth) //=========================================================================== // // __decorate_internal_state__ +// __decorate_internal_int__ +// __decorate_internal_bool__ +// __decorate_internal_float__ // -// Returns the state passed in. +// Placeholders for forcing DECORATE to cast numbers. If actually called, +// returns whatever was passed. // //=========================================================================== @@ -373,14 +377,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_state__) ACTION_RETURN_STATE(returnme); } -//=========================================================================== -// -// __decorate_internal_int__ -// -// Returns the int passed in. -// -//=========================================================================== - DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_int__) { PARAM_PROLOGUE; @@ -389,14 +385,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_int__) ACTION_RETURN_INT(returnme); } -//=========================================================================== -// -// __decorate_internal_bool__ -// -// Returns the bool passed in. -// -//=========================================================================== - DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_bool__) { PARAM_PROLOGUE; @@ -405,6 +393,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_bool__) ACTION_RETURN_BOOL(returnme); } +DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_float__) +{ + PARAM_PROLOGUE; + PARAM_OBJECT(self, AActor); + PARAM_FLOAT(returnme); + if (numret > 0) + { + ret->SetFloat(returnme); + return 1; + } + return 0; +} + //========================================================================== // // A_RearrangePointers diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 9ad8e207f9..8239f0e475 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -3420,7 +3420,8 @@ bool FxVMFunctionCall::CheckEmitCast(VMFunctionBuilder *build, bool returnit, Ex FName funcname = Function->SymbolName; if (funcname == NAME___decorate_internal_int__ || funcname == NAME___decorate_internal_bool__ || - funcname == NAME___decorate_internal_state__) + funcname == NAME___decorate_internal_state__ || + funcname == NAME___decorate_internal_float__) { FxExpression *arg = (*ArgList)[0]; if (returnit) diff --git a/src/thingdef/thingdef_states.cpp b/src/thingdef/thingdef_states.cpp index c87c9f316a..ae18051190 100644 --- a/src/thingdef/thingdef_states.cpp +++ b/src/thingdef/thingdef_states.cpp @@ -711,6 +711,8 @@ FName CheckCastKludges(FName in) return NAME___decorate_internal_bool__; case NAME_State: return NAME___decorate_internal_state__; + case NAME_Float: + return NAME___decorate_internal_float__; default: return in; } diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 3bc3772bd1..ad7e9e9302 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -356,4 +356,5 @@ ACTOR Actor native //: Thinker native state __decorate_internal_state__(state); native int __decorate_internal_int__(int); native bool __decorate_internal_bool__(bool); + native float __decorate_internal_float__(float); }