mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- Fixed: FStateDefinitions::FinishStates() must ResolveGotoLabels before resolving labelled gotos. Otherwise, something like this fails:
Goto State1 State1: Goto State2 State2: because when "Goto State1" is processed, State1 is still pointing at the string "State2" rather than State2's state, so the goto will end up pointing at a string (which will soon be freed from memory) instead of at an actual state. SVN r3784 (trunk)
This commit is contained in:
parent
6bb6df483a
commit
22cc0544af
1 changed files with 12 additions and 8 deletions
|
@ -884,7 +884,6 @@ int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults)
|
|||
{
|
||||
FState *realstates = new FState[count];
|
||||
int i;
|
||||
int currange;
|
||||
|
||||
memcpy(realstates, &StateArray[0], count*sizeof(FState));
|
||||
actor->OwnedStates = realstates;
|
||||
|
@ -892,12 +891,15 @@ int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults)
|
|||
|
||||
// adjust the state pointers
|
||||
// In the case new states are added these must be adjusted, too!
|
||||
FixStatePointers (actor, StateLabels);
|
||||
FixStatePointers(actor, StateLabels);
|
||||
|
||||
for(i = currange = 0; i < count; i++)
|
||||
// Fix state pointers that are gotos
|
||||
ResolveGotoLabels(actor, defaults, StateLabels);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
// resolve labels and jumps
|
||||
switch(realstates[i].DefineFlags)
|
||||
switch (realstates[i].DefineFlags)
|
||||
{
|
||||
case SDF_STOP: // stop
|
||||
realstates[i].NextState = NULL;
|
||||
|
@ -916,14 +918,16 @@ int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults)
|
|||
break;
|
||||
|
||||
case SDF_LABEL:
|
||||
realstates[i].NextState = ResolveGotoLabel (defaults, actor->Class, (char *)realstates[i].NextState);
|
||||
realstates[i].NextState = ResolveGotoLabel(defaults, actor->Class, (char *)realstates[i].NextState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fix state pointers that are gotos
|
||||
ResolveGotoLabels (actor, defaults, StateLabels);
|
||||
else
|
||||
{
|
||||
// Fix state pointers that are gotos
|
||||
ResolveGotoLabels(actor, defaults, StateLabels);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue