This commit is contained in:
Rachael Alexanderson 2017-04-13 10:09:47 -04:00
commit 2c4552da42
12 changed files with 42 additions and 30 deletions

View file

@ -754,7 +754,7 @@ PClass *PClass::FindClassTentative(FName name)
Derive(type, name); Derive(type, name);
type->Size = TentativeClass; type->Size = TentativeClass;
InsertIntoHash(); type->InsertIntoHash();
return type; return type;
} }

View file

@ -34,6 +34,7 @@
*/ */
#include "info.h" #include "info.h"
#include "actor.h"
#include "p_lnspec.h" #include "p_lnspec.h"
#include "m_fixed.h" #include "m_fixed.h"
#include "c_dispatch.h" #include "c_dispatch.h"

View file

@ -140,12 +140,16 @@ public:
protected: protected:
FName m_Name; FName m_Name;
int m_Args[5]; int m_Args[5] = { 0,0,0,0,0 };
double m_Param; double m_Param = 0;
DVector3 m_Pos; DVector3 m_Pos = { 0,0,0 };
ELightType m_type; ELightType m_type;
int8_t m_attenuate; int8_t m_attenuate = -1;
bool m_subtractive, m_additive, m_halo, m_dontlightself, m_dontlightactors; bool m_subtractive = false;
bool m_additive = false;
bool m_halo = false;
bool m_dontlightself = false;
bool m_dontlightactors = false;
bool m_swapped = false; bool m_swapped = false;
}; };
@ -161,16 +165,6 @@ FLightDefaults::FLightDefaults(FName name, ELightType type)
{ {
m_Name = name; m_Name = name;
m_type = type; 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_attenuate = -1;
} }
void FLightDefaults::ApplyProperties(ADynamicLight * light) const void FLightDefaults::ApplyProperties(ADynamicLight * light) const

View file

@ -842,7 +842,7 @@ void gl_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
PClassActor *cls = pair->Key; PClassActor *cls = pair->Key;
int gltrans = GLTranslationPalette::GetInternalTranslation(GetDefaultByType(cls)->Translation); 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]; auto &state = cls->GetStates()[i];
spritelist[state.sprite].Insert(gltrans, true); spritelist[state.sprite].Insert(gltrans, true);

View file

@ -170,7 +170,7 @@ bool FState::CallAction(AActor *self, AActor *stateowner, FStateParamInfo *info,
if (stateowner->IsKindOf(NAME_Weapon) && stateowner != self) callinfo = "weapon "; if (stateowner->IsKindOf(NAME_Weapon) && stateowner != self) callinfo = "weapon ";
else callinfo = "overlay "; 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;
throw; throw;
} }

View file

@ -132,7 +132,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state)
{ {
if (!(state->UseFlags & SUF_ITEM)) 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; 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. // 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); 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", 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; state->ActionFunc = nullptr;
} }
@ -189,7 +189,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state)
catch (CVMAbortException &err) catch (CVMAbortException &err)
{ {
err.MaybePrintMessage(); 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; throw;
} }

View file

@ -629,7 +629,7 @@ bool AActor::SetState (FState *newstate, bool nofunction)
} }
if (!(newstate->UseFlags & SUF_ACTOR)) 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; state = nullptr;
Destroy(); Destroy();
return false; return false;

View file

@ -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. 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; State = nullptr;
Destroy(); Destroy();
return; return;
@ -360,7 +360,7 @@ void DPSprite::SetState(FState *newstate, bool pending)
{ {
if (Caller->IsKindOf(NAME_Weapon)) 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 not flagged for use in weapons\n", FState::StaticGetStateName(newstate).GetChars());
State = nullptr; State = nullptr;
Destroy(); Destroy();
return; 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. // 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", 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; newstate->ActionFunc = nullptr;
} }
if (newstate->CallAction(Owner->mo, Caller, &stp, &nextstate)) if (newstate->CallAction(Owner->mo, Caller, &stp, &nextstate))

View file

@ -1081,7 +1081,7 @@ void DumpStateHelper(FStateLabels *StateList, const FString &prefix)
} }
else 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) if (StateList->Labels[i].Children != NULL)

View file

@ -88,7 +88,8 @@ FxExpression *ParseExpression (FScanner &sc, PClassActor *cls, PNamespace *spc)
if (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); data = data->Resolve(ctx);
} }

View file

@ -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. // 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", 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; state = state->NextState;
} }
@ -308,7 +308,7 @@ static void CheckLabel(PClassActor *obj, FStateLabel *slb, int useflag, FName st
if (!(state->UseFlags & useflag)) 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", 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) if (slb->Children != nullptr)
@ -359,7 +359,7 @@ static void CheckStates(PClassActor *obj)
if (state->NextState && (state->UseFlags & state->NextState->UseFlags) != state->UseFlags) 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", GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "State %s links to a state with incompatible restrictions.\n",
FState::StaticGetStateName(state)); FState::StaticGetStateName(state).GetChars());
} }
} }
} }

View file

@ -1154,3 +1154,19 @@ const TEXTCOLOR_BOLD = "\034+";
const TEXTCOLOR_CHAT = "\034*"; const TEXTCOLOR_CHAT = "\034*";
const TEXTCOLOR_TEAMCHAT = "\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,
};