mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- moved OwnedStates and NumOwnedStates out of PClassActor.
This commit is contained in:
parent
05240ccbe5
commit
4afe2d4218
11 changed files with 37 additions and 41 deletions
|
@ -2843,7 +2843,7 @@ static bool LoadDehSupp ()
|
|||
|
||||
sc.MustGetStringName(",");
|
||||
sc.MustGetNumber();
|
||||
if (s.State == NULL || s.State + sc.Number > actortype->OwnedStates + actortype->NumOwnedStates)
|
||||
if (s.State == NULL || !actortype->OwnsState(s.State + sc.Number))
|
||||
{
|
||||
sc.ScriptError("Invalid state range in '%s'", type->TypeName.GetChars());
|
||||
}
|
||||
|
|
|
@ -841,10 +841,11 @@ void gl_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
|||
PClassActor *cls = pair->Key;
|
||||
int gltrans = GLTranslationPalette::GetInternalTranslation(GetDefaultByType(cls)->Translation);
|
||||
|
||||
for (int i = 0; i < cls->NumOwnedStates; i++)
|
||||
for (int i = 0; i < cls->ActorInfo()->NumOwnedStates; i++)
|
||||
{
|
||||
spritelist[cls->OwnedStates[i].sprite].Insert(gltrans, true);
|
||||
FSpriteModelFrame * smf = gl_FindModelFrame(cls, cls->OwnedStates[i].sprite, cls->OwnedStates[i].Frame, false);
|
||||
auto &state = cls->ActorInfo()->OwnedStates[i];
|
||||
spritelist[state.sprite].Insert(gltrans, true);
|
||||
FSpriteModelFrame * smf = gl_FindModelFrame(cls, state.sprite, state.Frame, false);
|
||||
if (smf != NULL)
|
||||
{
|
||||
for (int i = 0; i < MAX_MODELS_PER_FRAME; i++)
|
||||
|
|
|
@ -162,15 +162,13 @@ bool FState::CallAction(AActor *self, AActor *stateowner, FStateParamInfo *info,
|
|||
catch (CVMAbortException &err)
|
||||
{
|
||||
err.MaybePrintMessage();
|
||||
auto owner = FState::StaticFindStateOwner(this);
|
||||
int offs = int(this - owner->OwnedStates);
|
||||
const char *callinfo = "";
|
||||
if (info != nullptr && info->mStateType == STATE_Psprite)
|
||||
{
|
||||
if (stateowner->IsKindOf(NAME_Weapon) && stateowner != self) callinfo = "weapon ";
|
||||
else callinfo = "overlay ";
|
||||
}
|
||||
err.stacktrace.AppendFormat("Called from %sstate %s.%d in %s\n", callinfo, owner->TypeName.GetChars(), offs, stateowner->GetClass()->TypeName.GetChars());
|
||||
err.stacktrace.AppendFormat("Called from %sstate %s in %s\n", callinfo, FState::StaticGetStateName(this), stateowner->GetClass()->TypeName.GetChars());
|
||||
throw;
|
||||
throw;
|
||||
}
|
||||
|
@ -299,8 +297,6 @@ PClassActor::PClassActor()
|
|||
GameFilter = GAME_Any;
|
||||
SpawnID = 0;
|
||||
DoomEdNum = -1;
|
||||
OwnedStates = NULL;
|
||||
NumOwnedStates = 0;
|
||||
StateList = NULL;
|
||||
DamageFactors = NULL;
|
||||
PainChances = NULL;
|
||||
|
|
|
@ -242,6 +242,8 @@ struct FActorInfo
|
|||
TArray<FInternalLightAssociation *> LightAssociations;
|
||||
PClassActor *Replacement = nullptr;
|
||||
PClassActor *Replacee = nullptr;
|
||||
FState *OwnedStates = nullptr;
|
||||
int NumOwnedStates = 0;
|
||||
|
||||
FActorInfo() {}
|
||||
FActorInfo(const FActorInfo & other)
|
||||
|
@ -284,14 +286,13 @@ public:
|
|||
|
||||
bool OwnsState(const FState *state)
|
||||
{
|
||||
return state >= OwnedStates && state < OwnedStates + NumOwnedStates;
|
||||
auto i = ActorInfo();
|
||||
return state >= i->OwnedStates && state < i->OwnedStates + i->NumOwnedStates;
|
||||
}
|
||||
|
||||
PClassActor *GetReplacement(bool lookskill=true);
|
||||
PClassActor *GetReplacee(bool lookskill=true);
|
||||
|
||||
FState *OwnedStates;
|
||||
int NumOwnedStates;
|
||||
uint8_t GameFilter;
|
||||
uint8_t DefaultStateUsage; // state flag defaults for blocks without a qualifier.
|
||||
uint16_t SpawnID;
|
||||
|
|
|
@ -3317,9 +3317,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnDebris)
|
|||
{
|
||||
mo->Translation = self->Translation;
|
||||
}
|
||||
if (i < mo->GetClass()->NumOwnedStates)
|
||||
if (i < mo->GetInfo()->NumOwnedStates)
|
||||
{
|
||||
mo->SetState (mo->GetClass()->OwnedStates + i);
|
||||
mo->SetState (mo->GetInfo()->OwnedStates + i);
|
||||
}
|
||||
mo->Vel.X = mult_h * pr_spawndebris.Random2() / 64.;
|
||||
mo->Vel.Y = mult_h * pr_spawndebris.Random2() / 64.;
|
||||
|
|
|
@ -133,7 +133,7 @@ PClassActor *FState::StaticFindStateOwner (const FState *state, PClassActor *inf
|
|||
FString FState::StaticGetStateName(const FState *state)
|
||||
{
|
||||
auto so = FState::StaticFindStateOwner(state);
|
||||
return FStringf("%s.%d", so->TypeName.GetChars(), int(state - so->OwnedStates));
|
||||
return FStringf("%s.%d", so->TypeName.GetChars(), int(state - so->ActorInfo()->OwnedStates));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -816,7 +816,7 @@ void FStateDefinitions::FixStatePointers (PClassActor *actor, TArray<FStateDefin
|
|||
if (list[i].DefineFlags == SDF_INDEX)
|
||||
{
|
||||
size_t v = (size_t)list[i].State;
|
||||
list[i].State = actor->OwnedStates + v - 1;
|
||||
list[i].State = actor->ActorInfo()->OwnedStates + v - 1;
|
||||
list[i].DefineFlags = SDF_STATE;
|
||||
}
|
||||
if (list[i].Children.Size() > 0)
|
||||
|
@ -1012,8 +1012,8 @@ int FStateDefinitions::FinishStates(PClassActor *actor, AActor *defaults)
|
|||
int i;
|
||||
|
||||
memcpy(realstates, &StateArray[0], count*sizeof(FState));
|
||||
actor->OwnedStates = realstates;
|
||||
actor->NumOwnedStates = count;
|
||||
actor->ActorInfo()->OwnedStates = realstates;
|
||||
actor->ActorInfo()->NumOwnedStates = count;
|
||||
SaveStateSourceLines(realstates, SourceLines);
|
||||
|
||||
// adjust the state pointers
|
||||
|
|
|
@ -10838,16 +10838,16 @@ FxExpression *FxStateByIndex::Resolve(FCompileContext &ctx)
|
|||
auto aclass = dyn_cast<PClassActor>(ctx.Class);
|
||||
|
||||
// This expression type can only be used from actors, for everything else it has already produced a compile error.
|
||||
assert(aclass != nullptr && aclass->NumOwnedStates > 0);
|
||||
assert(aclass != nullptr && aclass->ActorInfo()->NumOwnedStates > 0);
|
||||
|
||||
if (aclass->NumOwnedStates <= index)
|
||||
if (aclass->ActorInfo()->NumOwnedStates <= index)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "%s: Attempt to jump to non existing state index %d",
|
||||
ctx.Class->TypeName.GetChars(), index);
|
||||
delete this;
|
||||
return nullptr;
|
||||
}
|
||||
int symlabel = StateLabels.AddPointer(aclass->OwnedStates + index);
|
||||
int symlabel = StateLabels.AddPointer(aclass->ActorInfo()->OwnedStates + index);
|
||||
FxExpression *x = new FxConstant(symlabel, ScriptPosition);
|
||||
x->ValueType = TypeStateLabel;
|
||||
delete this;
|
||||
|
@ -10912,8 +10912,8 @@ FxExpression *FxRuntimeStateIndex::Resolve(FCompileContext &ctx)
|
|||
SAFE_RESOLVE(Index, ctx);
|
||||
}
|
||||
auto aclass = dyn_cast<PClassActor>(ctx.Class);
|
||||
assert(aclass != nullptr && aclass->NumOwnedStates > 0);
|
||||
symlabel = StateLabels.AddPointer(aclass->OwnedStates + ctx.StateIndex);
|
||||
assert(aclass != nullptr && aclass->ActorInfo()->NumOwnedStates > 0);
|
||||
symlabel = StateLabels.AddPointer(aclass->ActorInfo()->OwnedStates + ctx.StateIndex);
|
||||
ValueType = TypeStateLabel;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -130,8 +130,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
|
|||
memset (&extra, 0, sizeof(extra));
|
||||
ParseInsideDecoration (bag, (AActor *)(type->Defaults), extra, def, sc, StateArray, SourceLines);
|
||||
|
||||
bag.Info->NumOwnedStates = StateArray.Size();
|
||||
if (bag.Info->NumOwnedStates == 0)
|
||||
if (StateArray.Size() == 0)
|
||||
{
|
||||
sc.ScriptError ("%s does not define any animation frames", typeName.GetChars() );
|
||||
}
|
||||
|
@ -155,14 +154,13 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
|
|||
FScriptPosition icepos = SourceLines[extra.IceDeathEnd - 1];
|
||||
StateArray.Push (icecopy);
|
||||
SourceLines.Push(icepos);
|
||||
type->NumOwnedStates += 1;
|
||||
}
|
||||
|
||||
FState *states;
|
||||
states = type->OwnedStates = (FState*)ClassDataAllocator.Alloc(type->NumOwnedStates * sizeof(FState));
|
||||
states = type->ActorInfo()->OwnedStates = (FState*)ClassDataAllocator.Alloc(StateArray.Size() * sizeof(FState));
|
||||
SaveStateSourceLines(states, SourceLines);
|
||||
memcpy (states, &StateArray[0], type->NumOwnedStates * sizeof(states[0]));
|
||||
if (type->NumOwnedStates == 1)
|
||||
memcpy (states, &StateArray[0], StateArray.Size() * sizeof(states[0]));
|
||||
if (StateArray.Size() == 1)
|
||||
{
|
||||
states->Tics = -1;
|
||||
states->TicRange = 0;
|
||||
|
@ -171,7 +169,6 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
|
|||
else
|
||||
{
|
||||
size_t i;
|
||||
// auto
|
||||
|
||||
// Spawn states loop endlessly
|
||||
for (i = extra.SpawnStart; i < extra.SpawnEnd-1; ++i)
|
||||
|
@ -281,13 +278,13 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
|
|||
states[i].NextState = &states[i+1];
|
||||
}
|
||||
FState *state = &states[i];
|
||||
state->NextState = &states[type->NumOwnedStates-1];
|
||||
state->NextState = &states[StateArray.Size() - 1];
|
||||
state->Tics = 5;
|
||||
state->TicRange = 0;
|
||||
state->Misc1 = 0;
|
||||
state->SetAction("A_FreezeDeath");
|
||||
|
||||
i = type->NumOwnedStates - 1;
|
||||
i = StateArray.Size() - 1;
|
||||
state->NextState = &states[i];
|
||||
state->Tics = 1;
|
||||
state->TicRange = 0;
|
||||
|
@ -310,6 +307,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
|
|||
}
|
||||
bag.statedef.SetStateLabel("Spawn", &states[extra.SpawnStart]);
|
||||
bag.statedef.InstallStates (type, ((AActor *)(type->Defaults)));
|
||||
bag.Info->ActorInfo()->NumOwnedStates = StateArray.Size();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -353,13 +353,13 @@ static void CheckStates(PClassActor *obj)
|
|||
{
|
||||
CheckStateLabels(obj, pickupstates, SUF_ITEM, "CustomInventory state chain");
|
||||
}
|
||||
for (int i = 0; i < obj->NumOwnedStates; i++)
|
||||
for (int i = 0; i < obj->ActorInfo()->NumOwnedStates; i++)
|
||||
{
|
||||
auto state = obj->OwnedStates + i;
|
||||
auto state = obj->ActorInfo()->OwnedStates + i;
|
||||
if (state->NextState && (state->UseFlags & state->NextState->UseFlags) != state->UseFlags)
|
||||
{
|
||||
GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "State %s.%d links to a state with incompatible restrictions.\n",
|
||||
obj->TypeName.GetChars(), int(state - obj->OwnedStates));
|
||||
GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "State %s links to a state with incompatible restrictions.\n",
|
||||
FState::StaticGetStateName(state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1877,7 +1877,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FState *&state, FState
|
|||
{
|
||||
arc.w->StartArray();
|
||||
arc.w->String(info->TypeName.GetChars());
|
||||
arc.w->Uint((uint32_t)(state - info->OwnedStates));
|
||||
arc.w->Uint((uint32_t)(state - info->ActorInfo()->OwnedStates));
|
||||
arc.w->EndArray();
|
||||
}
|
||||
else
|
||||
|
@ -1908,9 +1908,9 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FState *&state, FState
|
|||
if (cls.IsString() && ndx.IsUint())
|
||||
{
|
||||
PClassActor *clas = PClass::FindActor(UnicodeToString(cls.GetString()));
|
||||
if (clas && ndx.GetUint() < (unsigned)clas->NumOwnedStates)
|
||||
if (clas && ndx.GetUint() < (unsigned)clas->ActorInfo()->NumOwnedStates)
|
||||
{
|
||||
state = clas->OwnedStates + ndx.GetUint();
|
||||
state = clas->ActorInfo()->OwnedStates + ndx.GetUint();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -132,9 +132,9 @@ void FSoftwareRenderer::Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &
|
|||
{
|
||||
PClassActor *cls = pair->Key;
|
||||
|
||||
for (int i = 0; i < cls->NumOwnedStates; i++)
|
||||
for (int i = 0; i < cls->ActorInfo()->NumOwnedStates; i++)
|
||||
{
|
||||
spritelist[cls->OwnedStates[i].sprite] = true;
|
||||
spritelist[cls->ActorInfo()->OwnedStates[i].sprite] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue