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.MustGetStringName(",");
|
||||||
sc.MustGetNumber();
|
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());
|
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;
|
PClassActor *cls = pair->Key;
|
||||||
int gltrans = GLTranslationPalette::GetInternalTranslation(GetDefaultByType(cls)->Translation);
|
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);
|
auto &state = cls->ActorInfo()->OwnedStates[i];
|
||||||
FSpriteModelFrame * smf = gl_FindModelFrame(cls, cls->OwnedStates[i].sprite, cls->OwnedStates[i].Frame, false);
|
spritelist[state.sprite].Insert(gltrans, true);
|
||||||
|
FSpriteModelFrame * smf = gl_FindModelFrame(cls, state.sprite, state.Frame, false);
|
||||||
if (smf != NULL)
|
if (smf != NULL)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_MODELS_PER_FRAME; i++)
|
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)
|
catch (CVMAbortException &err)
|
||||||
{
|
{
|
||||||
err.MaybePrintMessage();
|
err.MaybePrintMessage();
|
||||||
auto owner = FState::StaticFindStateOwner(this);
|
|
||||||
int offs = int(this - owner->OwnedStates);
|
|
||||||
const char *callinfo = "";
|
const char *callinfo = "";
|
||||||
if (info != nullptr && info->mStateType == STATE_Psprite)
|
if (info != nullptr && info->mStateType == STATE_Psprite)
|
||||||
{
|
{
|
||||||
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.%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;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -299,8 +297,6 @@ PClassActor::PClassActor()
|
||||||
GameFilter = GAME_Any;
|
GameFilter = GAME_Any;
|
||||||
SpawnID = 0;
|
SpawnID = 0;
|
||||||
DoomEdNum = -1;
|
DoomEdNum = -1;
|
||||||
OwnedStates = NULL;
|
|
||||||
NumOwnedStates = 0;
|
|
||||||
StateList = NULL;
|
StateList = NULL;
|
||||||
DamageFactors = NULL;
|
DamageFactors = NULL;
|
||||||
PainChances = NULL;
|
PainChances = NULL;
|
||||||
|
|
|
@ -242,6 +242,8 @@ struct FActorInfo
|
||||||
TArray<FInternalLightAssociation *> LightAssociations;
|
TArray<FInternalLightAssociation *> LightAssociations;
|
||||||
PClassActor *Replacement = nullptr;
|
PClassActor *Replacement = nullptr;
|
||||||
PClassActor *Replacee = nullptr;
|
PClassActor *Replacee = nullptr;
|
||||||
|
FState *OwnedStates = nullptr;
|
||||||
|
int NumOwnedStates = 0;
|
||||||
|
|
||||||
FActorInfo() {}
|
FActorInfo() {}
|
||||||
FActorInfo(const FActorInfo & other)
|
FActorInfo(const FActorInfo & other)
|
||||||
|
@ -284,14 +286,13 @@ public:
|
||||||
|
|
||||||
bool OwnsState(const FState *state)
|
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 *GetReplacement(bool lookskill=true);
|
||||||
PClassActor *GetReplacee(bool lookskill=true);
|
PClassActor *GetReplacee(bool lookskill=true);
|
||||||
|
|
||||||
FState *OwnedStates;
|
|
||||||
int NumOwnedStates;
|
|
||||||
uint8_t GameFilter;
|
uint8_t GameFilter;
|
||||||
uint8_t DefaultStateUsage; // state flag defaults for blocks without a qualifier.
|
uint8_t DefaultStateUsage; // state flag defaults for blocks without a qualifier.
|
||||||
uint16_t SpawnID;
|
uint16_t SpawnID;
|
||||||
|
|
|
@ -3317,9 +3317,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnDebris)
|
||||||
{
|
{
|
||||||
mo->Translation = self->Translation;
|
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.X = mult_h * pr_spawndebris.Random2() / 64.;
|
||||||
mo->Vel.Y = 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)
|
FString FState::StaticGetStateName(const FState *state)
|
||||||
{
|
{
|
||||||
auto so = FState::StaticFindStateOwner(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)
|
if (list[i].DefineFlags == SDF_INDEX)
|
||||||
{
|
{
|
||||||
size_t v = (size_t)list[i].State;
|
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;
|
list[i].DefineFlags = SDF_STATE;
|
||||||
}
|
}
|
||||||
if (list[i].Children.Size() > 0)
|
if (list[i].Children.Size() > 0)
|
||||||
|
@ -1012,8 +1012,8 @@ int FStateDefinitions::FinishStates(PClassActor *actor, AActor *defaults)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memcpy(realstates, &StateArray[0], count*sizeof(FState));
|
memcpy(realstates, &StateArray[0], count*sizeof(FState));
|
||||||
actor->OwnedStates = realstates;
|
actor->ActorInfo()->OwnedStates = realstates;
|
||||||
actor->NumOwnedStates = count;
|
actor->ActorInfo()->NumOwnedStates = count;
|
||||||
SaveStateSourceLines(realstates, SourceLines);
|
SaveStateSourceLines(realstates, SourceLines);
|
||||||
|
|
||||||
// adjust the state pointers
|
// adjust the state pointers
|
||||||
|
|
|
@ -10838,16 +10838,16 @@ FxExpression *FxStateByIndex::Resolve(FCompileContext &ctx)
|
||||||
auto aclass = dyn_cast<PClassActor>(ctx.Class);
|
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.
|
// 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",
|
ScriptPosition.Message(MSG_ERROR, "%s: Attempt to jump to non existing state index %d",
|
||||||
ctx.Class->TypeName.GetChars(), index);
|
ctx.Class->TypeName.GetChars(), index);
|
||||||
delete this;
|
delete this;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
int symlabel = StateLabels.AddPointer(aclass->OwnedStates + index);
|
int symlabel = StateLabels.AddPointer(aclass->ActorInfo()->OwnedStates + index);
|
||||||
FxExpression *x = new FxConstant(symlabel, ScriptPosition);
|
FxExpression *x = new FxConstant(symlabel, ScriptPosition);
|
||||||
x->ValueType = TypeStateLabel;
|
x->ValueType = TypeStateLabel;
|
||||||
delete this;
|
delete this;
|
||||||
|
@ -10912,8 +10912,8 @@ FxExpression *FxRuntimeStateIndex::Resolve(FCompileContext &ctx)
|
||||||
SAFE_RESOLVE(Index, ctx);
|
SAFE_RESOLVE(Index, ctx);
|
||||||
}
|
}
|
||||||
auto aclass = dyn_cast<PClassActor>(ctx.Class);
|
auto aclass = dyn_cast<PClassActor>(ctx.Class);
|
||||||
assert(aclass != nullptr && aclass->NumOwnedStates > 0);
|
assert(aclass != nullptr && aclass->ActorInfo()->NumOwnedStates > 0);
|
||||||
symlabel = StateLabels.AddPointer(aclass->OwnedStates + ctx.StateIndex);
|
symlabel = StateLabels.AddPointer(aclass->ActorInfo()->OwnedStates + ctx.StateIndex);
|
||||||
ValueType = TypeStateLabel;
|
ValueType = TypeStateLabel;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,8 +130,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
|
||||||
memset (&extra, 0, sizeof(extra));
|
memset (&extra, 0, sizeof(extra));
|
||||||
ParseInsideDecoration (bag, (AActor *)(type->Defaults), extra, def, sc, StateArray, SourceLines);
|
ParseInsideDecoration (bag, (AActor *)(type->Defaults), extra, def, sc, StateArray, SourceLines);
|
||||||
|
|
||||||
bag.Info->NumOwnedStates = StateArray.Size();
|
if (StateArray.Size() == 0)
|
||||||
if (bag.Info->NumOwnedStates == 0)
|
|
||||||
{
|
{
|
||||||
sc.ScriptError ("%s does not define any animation frames", typeName.GetChars() );
|
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];
|
FScriptPosition icepos = SourceLines[extra.IceDeathEnd - 1];
|
||||||
StateArray.Push (icecopy);
|
StateArray.Push (icecopy);
|
||||||
SourceLines.Push(icepos);
|
SourceLines.Push(icepos);
|
||||||
type->NumOwnedStates += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FState *states;
|
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);
|
SaveStateSourceLines(states, SourceLines);
|
||||||
memcpy (states, &StateArray[0], type->NumOwnedStates * sizeof(states[0]));
|
memcpy (states, &StateArray[0], StateArray.Size() * sizeof(states[0]));
|
||||||
if (type->NumOwnedStates == 1)
|
if (StateArray.Size() == 1)
|
||||||
{
|
{
|
||||||
states->Tics = -1;
|
states->Tics = -1;
|
||||||
states->TicRange = 0;
|
states->TicRange = 0;
|
||||||
|
@ -171,7 +169,6 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
// auto
|
|
||||||
|
|
||||||
// Spawn states loop endlessly
|
// Spawn states loop endlessly
|
||||||
for (i = extra.SpawnStart; i < extra.SpawnEnd-1; ++i)
|
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];
|
states[i].NextState = &states[i+1];
|
||||||
}
|
}
|
||||||
FState *state = &states[i];
|
FState *state = &states[i];
|
||||||
state->NextState = &states[type->NumOwnedStates-1];
|
state->NextState = &states[StateArray.Size() - 1];
|
||||||
state->Tics = 5;
|
state->Tics = 5;
|
||||||
state->TicRange = 0;
|
state->TicRange = 0;
|
||||||
state->Misc1 = 0;
|
state->Misc1 = 0;
|
||||||
state->SetAction("A_FreezeDeath");
|
state->SetAction("A_FreezeDeath");
|
||||||
|
|
||||||
i = type->NumOwnedStates - 1;
|
i = StateArray.Size() - 1;
|
||||||
state->NextState = &states[i];
|
state->NextState = &states[i];
|
||||||
state->Tics = 1;
|
state->Tics = 1;
|
||||||
state->TicRange = 0;
|
state->TicRange = 0;
|
||||||
|
@ -310,6 +307,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
|
||||||
}
|
}
|
||||||
bag.statedef.SetStateLabel("Spawn", &states[extra.SpawnStart]);
|
bag.statedef.SetStateLabel("Spawn", &states[extra.SpawnStart]);
|
||||||
bag.statedef.InstallStates (type, ((AActor *)(type->Defaults)));
|
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");
|
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)
|
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",
|
GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "State %s links to a state with incompatible restrictions.\n",
|
||||||
obj->TypeName.GetChars(), int(state - obj->OwnedStates));
|
FState::StaticGetStateName(state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1877,7 +1877,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FState *&state, FState
|
||||||
{
|
{
|
||||||
arc.w->StartArray();
|
arc.w->StartArray();
|
||||||
arc.w->String(info->TypeName.GetChars());
|
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();
|
arc.w->EndArray();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1908,9 +1908,9 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FState *&state, FState
|
||||||
if (cls.IsString() && ndx.IsUint())
|
if (cls.IsString() && ndx.IsUint())
|
||||||
{
|
{
|
||||||
PClassActor *clas = PClass::FindActor(UnicodeToString(cls.GetString()));
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,9 +132,9 @@ void FSoftwareRenderer::Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &
|
||||||
{
|
{
|
||||||
PClassActor *cls = pair->Key;
|
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