From 1c8d6981217ac12980d1c9a583db23b52bd37d7f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 Apr 2017 02:42:31 +0200 Subject: [PATCH 1/7] - added WeaponState enum for ZScript. --- wadsrc/static/zscript/constants.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index 95863452c..5477d24ee 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -1154,3 +1154,19 @@ const TEXTCOLOR_BOLD = "\034+"; const TEXTCOLOR_CHAT = "\034*"; const TEXTCOLOR_TEAMCHAT = "\034!"; + +enum EWeaponState +{ + WF_WEAPONREADY = 1 << 0, // [RH] Weapon is in the ready state and can fire its primary attack + WF_WEAPONBOBBING = 1 << 1, // [HW] Bob weapon while the player is moving + WF_WEAPONREADYALT = 1 << 2, // Weapon can fire its secondary attack + WF_WEAPONSWITCHOK = 1 << 3, // It is okay to switch away from this weapon + WF_DISABLESWITCH = 1 << 4, // Disable weapon switching completely + WF_WEAPONRELOADOK = 1 << 5, // [XA] Okay to reload this weapon. + WF_WEAPONZOOMOK = 1 << 6, // [XA] Okay to use weapon zoom function. + WF_REFIRESWITCHOK = 1 << 7, // Mirror WF_WEAPONSWITCHOK for A_ReFire + WF_USER1OK = 1 << 8, // [MC] Allow pushing of custom state buttons 1-4 + WF_USER2OK = 1 << 9, + WF_USER3OK = 1 << 10, + WF_USER4OK = 1 << 11, +}; \ No newline at end of file From 1889efa814722755956bf5e49fc9e992b778093e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 13 Apr 2017 10:17:11 +0300 Subject: [PATCH 2/7] Fixed build with Clang Fixed bunch of compilation errors: cannot pass non-trivial object of type 'FString' to variadic method; expected type from format string was 'char *' [-Wnon-pod-varargs] Fixed linker erorr: g_doomedmap.cpp.o: In function `InitActorNumsFromMapinfo()': src/g_doomedmap.cpp: undefined reference to `PClass::FindActor(FName)' --- src/g_doomedmap.cpp | 1 + src/info.cpp | 2 +- src/p_actionfunctions.cpp | 6 +++--- src/p_mobj.cpp | 2 +- src/p_pspr.cpp | 6 +++--- src/p_states.cpp | 2 +- src/scripting/thingdef.cpp | 6 +++--- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/g_doomedmap.cpp b/src/g_doomedmap.cpp index 2f3409ef2..b79543650 100644 --- a/src/g_doomedmap.cpp +++ b/src/g_doomedmap.cpp @@ -34,6 +34,7 @@ */ #include "info.h" +#include "actor.h" #include "p_lnspec.h" #include "m_fixed.h" #include "c_dispatch.h" diff --git a/src/info.cpp b/src/info.cpp index 7dd40c1ea..c6072afca 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -170,7 +170,7 @@ bool FState::CallAction(AActor *self, AActor *stateowner, FStateParamInfo *info, if (stateowner->IsKindOf(NAME_Weapon) && stateowner != self) callinfo = "weapon "; else callinfo = "overlay "; } - err.stacktrace.AppendFormat("Called from %sstate %s in %s\n", callinfo, FState::StaticGetStateName(this), stateowner->GetClass()->TypeName.GetChars()); + err.stacktrace.AppendFormat("Called from %sstate %s in %s\n", callinfo, FState::StaticGetStateName(this).GetChars(), stateowner->GetClass()->TypeName.GetChars()); throw; throw; } diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 8fe698a2f..030bdae51 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -132,7 +132,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) { if (!(state->UseFlags & SUF_ITEM)) { - Printf(TEXTCOLOR_RED "State %s not flagged for use in CustomInventory state chains.\n", FState::StaticGetStateName(state)); + Printf(TEXTCOLOR_RED "State %s not flagged for use in CustomInventory state chains.\n", FState::StaticGetStateName(state).GetChars()); return false; } @@ -146,7 +146,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) // If an unsafe function (i.e. one that accesses user variables) is being detected, print a warning once and remove the bogus function. We may not call it because that would inevitably crash. auto owner = FState::StaticFindStateOwner(state); Printf(TEXTCOLOR_RED "Unsafe state call in state %s to %s which accesses user variables. The action function has been removed from this state\n", - FState::StaticGetStateName(state), state->ActionFunc->PrintableName.GetChars()); + FState::StaticGetStateName(state).GetChars(), state->ActionFunc->PrintableName.GetChars()); state->ActionFunc = nullptr; } @@ -189,7 +189,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) catch (CVMAbortException &err) { err.MaybePrintMessage(); - err.stacktrace.AppendFormat("Called from state %s in inventory state chain in %s\n", FState::StaticGetStateName(state), GetClass()->TypeName.GetChars()); + err.stacktrace.AppendFormat("Called from state %s in inventory state chain in %s\n", FState::StaticGetStateName(state).GetChars(), GetClass()->TypeName.GetChars()); throw; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index afaad56e9..066396cd0 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -629,7 +629,7 @@ bool AActor::SetState (FState *newstate, bool nofunction) } if (!(newstate->UseFlags & SUF_ACTOR)) { - Printf(TEXTCOLOR_RED "State %s in %s not flagged for use as an actor sprite\n", FState::StaticGetStateName(newstate), GetClass()->TypeName.GetChars()); + Printf(TEXTCOLOR_RED "State %s in %s not flagged for use as an actor sprite\n", FState::StaticGetStateName(newstate).GetChars(), GetClass()->TypeName.GetChars()); state = nullptr; Destroy(); return false; diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 12c158c94..7f59376e1 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -351,7 +351,7 @@ void DPSprite::SetState(FState *newstate, bool pending) if (!(newstate->UseFlags & (SUF_OVERLAY|SUF_WEAPON))) // Weapon and overlay are mostly the same, the main difference is that weapon states restrict the self pointer to class Actor. { - Printf(TEXTCOLOR_RED "State %s not flagged for use in overlays or weapons\n", FState::StaticGetStateName(newstate)); + Printf(TEXTCOLOR_RED "State %s not flagged for use in overlays or weapons\n", FState::StaticGetStateName(newstate).GetChars()); State = nullptr; Destroy(); return; @@ -360,7 +360,7 @@ void DPSprite::SetState(FState *newstate, bool pending) { if (Caller->IsKindOf(NAME_Weapon)) { - Printf(TEXTCOLOR_RED "State %s.%d not flagged for use in weapons\n", FState::StaticGetStateName(newstate)); + Printf(TEXTCOLOR_RED "State %s.%d not flagged for use in weapons\n", FState::StaticGetStateName(newstate).GetChars()); State = nullptr; Destroy(); return; @@ -414,7 +414,7 @@ void DPSprite::SetState(FState *newstate, bool pending) { // If an unsafe function (i.e. one that accesses user variables) is being detected, print a warning once and remove the bogus function. We may not call it because that would inevitably crash. Printf(TEXTCOLOR_RED "Unsafe state call in state %sd to %s which accesses user variables. The action function has been removed from this state\n", - FState::StaticGetStateName(newstate), newstate->ActionFunc->PrintableName.GetChars()); + FState::StaticGetStateName(newstate).GetChars(), newstate->ActionFunc->PrintableName.GetChars()); newstate->ActionFunc = nullptr; } if (newstate->CallAction(Owner->mo, Caller, &stp, &nextstate)) diff --git a/src/p_states.cpp b/src/p_states.cpp index c358ceed5..c1e3e79c2 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -1081,7 +1081,7 @@ void DumpStateHelper(FStateLabels *StateList, const FString &prefix) } else { - Printf(PRINT_LOG, "%s%s: %s\n", prefix.GetChars(), StateList->Labels[i].Label.GetChars(), FState::StaticGetStateName(StateList->Labels[i].State)); + Printf(PRINT_LOG, "%s%s: %s\n", prefix.GetChars(), StateList->Labels[i].Label.GetChars(), FState::StaticGetStateName(StateList->Labels[i].State).GetChars()); } } if (StateList->Labels[i].Children != NULL) diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index bf585077f..19a7316bc 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -283,7 +283,7 @@ static void CheckForUnsafeStates(PClassActor *obj) { // If an unsafe function (i.e. one that accesses user variables) is being detected, print a warning once and remove the bogus function. We may not call it because that would inevitably crash. GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "Unsafe state call in state %s which accesses user variables, reached by %s.%s.\n", - FState::StaticGetStateName(state), obj->TypeName.GetChars(), FName(*test).GetChars()); + FState::StaticGetStateName(state).GetChars(), obj->TypeName.GetChars(), FName(*test).GetChars()); } state = state->NextState; } @@ -308,7 +308,7 @@ static void CheckLabel(PClassActor *obj, FStateLabel *slb, int useflag, FName st if (!(state->UseFlags & useflag)) { GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "%s references state %s as %s state, but this state is not flagged for use as %s.\n", - obj->TypeName.GetChars(), FState::StaticGetStateName(state), statename.GetChars(), descript); + obj->TypeName.GetChars(), FState::StaticGetStateName(state).GetChars(), statename.GetChars(), descript); } } if (slb->Children != nullptr) @@ -359,7 +359,7 @@ static void CheckStates(PClassActor *obj) if (state->NextState && (state->UseFlags & state->NextState->UseFlags) != state->UseFlags) { GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "State %s links to a state with incompatible restrictions.\n", - FState::StaticGetStateName(state)); + FState::StaticGetStateName(state).GetChars()); } } } From c99cecea8e51b49f79397852497b1678b20ea89e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 13 Apr 2017 10:25:52 +0300 Subject: [PATCH 3/7] Fixed warnings reported by GCC/Clang src/p_pspr.cpp:363:37: warning: more '%' conversions than data arguments [-Wformat] src/gl/textures/gl_texture.cpp:845:21: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare] --- src/gl/textures/gl_texture.cpp | 2 +- src/p_pspr.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index e0b065a13..76477c738 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -842,7 +842,7 @@ void gl_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl PClassActor *cls = pair->Key; int gltrans = GLTranslationPalette::GetInternalTranslation(GetDefaultByType(cls)->Translation); - for (int i = 0; i < cls->GetStateCount(); i++) + for (unsigned i = 0; i < cls->GetStateCount(); i++) { auto &state = cls->GetStates()[i]; spritelist[state.sprite].Insert(gltrans, true); diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 7f59376e1..45c4d36d7 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -360,7 +360,7 @@ void DPSprite::SetState(FState *newstate, bool pending) { if (Caller->IsKindOf(NAME_Weapon)) { - Printf(TEXTCOLOR_RED "State %s.%d not flagged for use in weapons\n", FState::StaticGetStateName(newstate).GetChars()); + Printf(TEXTCOLOR_RED "State %s not flagged for use in weapons\n", FState::StaticGetStateName(newstate).GetChars()); State = nullptr; Destroy(); return; From cbf2a21c83e1b0be2bb24a992abc692977445d03 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 13 Apr 2017 12:03:45 +0300 Subject: [PATCH 4/7] Fixed registration of tentative classes --- src/dobjtype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index d7703de1c..117180d75 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -754,7 +754,7 @@ PClass *PClass::FindClassTentative(FName name) Derive(type, name); type->Size = TentativeClass; - InsertIntoHash(); + type->InsertIntoHash(); return type; } From fbc1028d2b6156a297540d9d4a0030ff0036717d Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 13 Apr 2017 12:06:59 +0300 Subject: [PATCH 5/7] Fixed crash when parsing DECORATE constant expressions --- src/scripting/decorate/thingdef_exp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scripting/decorate/thingdef_exp.cpp b/src/scripting/decorate/thingdef_exp.cpp index d3acae632..37d613d8a 100644 --- a/src/scripting/decorate/thingdef_exp.cpp +++ b/src/scripting/decorate/thingdef_exp.cpp @@ -88,7 +88,8 @@ FxExpression *ParseExpression (FScanner &sc, PClassActor *cls, PNamespace *spc) if (spc) { - FCompileContext ctx(spc, cls->VMType, true); + PClassType *vmtype = nullptr == cls ? nullptr : cls->VMType; + FCompileContext ctx(spc, vmtype, true); data = data->Resolve(ctx); } From cced9e014be44308a1001edbed4a5bf521bca94e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 13 Apr 2017 13:14:33 +0300 Subject: [PATCH 6/7] Fixed issue with actors occasionally unaffected by dynamic lights https://mantis.zdoom.org/view.php?id=536 --- src/g_shared/a_dynlightdata.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_shared/a_dynlightdata.cpp b/src/g_shared/a_dynlightdata.cpp index 757d26bf3..afe5157e1 100644 --- a/src/g_shared/a_dynlightdata.cpp +++ b/src/g_shared/a_dynlightdata.cpp @@ -170,6 +170,7 @@ FLightDefaults::FLightDefaults(FName name, ELightType type) m_additive = false; m_halo = false; m_dontlightself = false; + m_dontlightactors = false; m_attenuate = -1; } From 522ce59be206d355b62980f2c6d4fb75315a01f2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 13 Apr 2017 12:50:43 +0200 Subject: [PATCH 7/7] - use in-class initialization for FLightDefaults to avoid uninitialized variables in the future. --- src/g_shared/a_dynlightdata.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/g_shared/a_dynlightdata.cpp b/src/g_shared/a_dynlightdata.cpp index afe5157e1..3c1f7c134 100644 --- a/src/g_shared/a_dynlightdata.cpp +++ b/src/g_shared/a_dynlightdata.cpp @@ -140,12 +140,16 @@ public: protected: FName m_Name; - int m_Args[5]; - double m_Param; - DVector3 m_Pos; + int m_Args[5] = { 0,0,0,0,0 }; + double m_Param = 0; + DVector3 m_Pos = { 0,0,0 }; ELightType m_type; - int8_t m_attenuate; - bool m_subtractive, m_additive, m_halo, m_dontlightself, m_dontlightactors; + int8_t m_attenuate = -1; + bool m_subtractive = false; + bool m_additive = false; + bool m_halo = false; + bool m_dontlightself = false; + bool m_dontlightactors = false; bool m_swapped = false; }; @@ -161,17 +165,6 @@ FLightDefaults::FLightDefaults(FName name, ELightType type) { m_Name = name; m_type = type; - - m_Pos.Zero(); - memset(m_Args, 0, sizeof(m_Args)); - m_Param = 0; - - m_subtractive = false; - m_additive = false; - m_halo = false; - m_dontlightself = false; - m_dontlightactors = false; - m_attenuate = -1; } void FLightDefaults::ApplyProperties(ADynamicLight * light) const