From a1a0da1f13ea142228c1b375c52885ce7a678757 Mon Sep 17 00:00:00 2001 From: Xaser Acheron Date: Fri, 29 Jul 2016 18:48:54 -0500 Subject: [PATCH 1/3] added SWF_SELECTPRIORITY flag to A_SelectWeapon --- src/thingdef/thingdef_codeptr.cpp | 17 ++++++++++++++++- wadsrc/static/actors/actor.txt | 2 +- wadsrc/static/actors/constants.txt | 3 +++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 16f9e2482..6904a05d4 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3103,12 +3103,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Recoil) // A_SelectWeapon // //=========================================================================== +enum SW_Flags +{ + SWF_SELECTPRIORITY = 1, +}; DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SelectWeapon) { PARAM_SELF_PROLOGUE(AActor); PARAM_CLASS(cls, AWeapon); + PARAM_INT_OPT(flags) { flags = 0; } - if (cls == NULL || self->player == NULL) + bool selectPriority = !!(flags & SWF_SELECTPRIORITY); + + if ((!selectPriority && cls == NULL) || self->player == NULL) { ACTION_RETURN_BOOL(false); } @@ -3123,6 +3130,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SelectWeapon) } ACTION_RETURN_BOOL(true); } + else if (selectPriority) + { + // [XA] if the named weapon cannot be found (or is a dummy like 'None'), + // select the next highest priority weapon. This is basically + // the same as A_CheckReload minus the ammo check. Handy. + self->player->mo->PickNewWeapon(NULL); + ACTION_RETURN_BOOL(true); + } else { ACTION_RETURN_BOOL(false); diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 868925c3d..23ac3d19c 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -265,7 +265,7 @@ ACTOR Actor native //: Thinker native state A_CheckLOF(state jump, int flags = 0, float range = 0, float minrange = 0, float angle = 0, float pitch = 0, float offsetheight = 0, float offsetwidth = 0, int ptr_target = AAPTR_DEFAULT, float offsetforward = 0); native state A_JumpIfTargetInLOS (state label, float/*angle*/ fov = 0, int flags = 0, float dist_max = 0, float dist_close = 0); native state A_JumpIfInTargetLOS (state label, float/*angle*/ fov = 0, int flags = 0, float dist_max = 0, float dist_close = 0); - native bool A_SelectWeapon(class whichweapon); + native bool A_SelectWeapon(class whichweapon, int flags = 0); action native A_Punch(); action native A_Feathers(); action native A_ClassBossHealth(); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 76bdcf9eb..30afd1064 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -150,6 +150,9 @@ const int WRF_ALLOWUSER2 = 256; const int WRF_ALLOWUSER3 = 512; const int WRF_ALLOWUSER4 = 1024; +// Flags for A_SelectWeapon +const int SWF_SELECTPRIORITY = 1; + // Morph constants const int MRF_ADDSTAMINA = 1; const int MRF_FULLHEALTH = 2; From 0648ef693f8e02d1aed69e08d2590c72dbff59be Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 30 Jul 2016 10:09:00 +0300 Subject: [PATCH 2/3] Fixed compilation with Clang and GCC No more "error: cannot pass object of non-trivial type 'FString' through variadic method; call will abort at runtime" --- src/thingdef/thingdef_expression.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 5017ae421..acb26d05b 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -4212,7 +4212,7 @@ ExpEmit FxJumpStatement::Emit(VMFunctionBuilder *build) { if (AddressResolver == nullptr) { - ScriptPosition.Message(MSG_ERROR, "Jump statement %s has nowhere to go!", FScanner::TokenName(Token)); + ScriptPosition.Message(MSG_ERROR, "Jump statement %s has nowhere to go!", FScanner::TokenName(Token).GetChars()); } Address = build->Emit(OP_JMP, 0); From 5ddee98e70c2ad37e43cd93165084e1ccc31f6f2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Jul 2016 13:19:02 +0200 Subject: [PATCH 3/3] - fixed: Voxels with scaled to 0 caused a division by zero crash. --- src/r_things.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/r_things.cpp b/src/r_things.cpp index 78d72fbc8..248e50c18 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2751,6 +2751,11 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, // Also do some magic voodoo scaling to make them the right size. daxscale = daxscale / (0xC000 >> 6); dayscale = dayscale / (0xC000 >> 6); + if (daxscale <= 0 || dayscale <= 0) + { + // won't be visible. + return; + } angle_t viewang = viewangle.BAMs(); cosang = FLOAT2FIXED(viewangle.Cos()) >> 2;