mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-31 05:40:44 +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];
|
FState *realstates = new FState[count];
|
||||||
int i;
|
int i;
|
||||||
int currange;
|
|
||||||
|
|
||||||
memcpy(realstates, &StateArray[0], count*sizeof(FState));
|
memcpy(realstates, &StateArray[0], count*sizeof(FState));
|
||||||
actor->OwnedStates = realstates;
|
actor->OwnedStates = realstates;
|
||||||
|
@ -892,12 +891,15 @@ int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults)
|
||||||
|
|
||||||
// adjust the state pointers
|
// adjust the state pointers
|
||||||
// In the case new states are added these must be adjusted, too!
|
// 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
|
// resolve labels and jumps
|
||||||
switch(realstates[i].DefineFlags)
|
switch (realstates[i].DefineFlags)
|
||||||
{
|
{
|
||||||
case SDF_STOP: // stop
|
case SDF_STOP: // stop
|
||||||
realstates[i].NextState = NULL;
|
realstates[i].NextState = NULL;
|
||||||
|
@ -916,14 +918,16 @@ int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDF_LABEL:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Fix state pointers that are gotos
|
// Fix state pointers that are gotos
|
||||||
ResolveGotoLabels (actor, defaults, StateLabels);
|
ResolveGotoLabels(actor, defaults, StateLabels);
|
||||||
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue