- fixed crash on message output during decorate parsing

Script position is now initialized at the very beginning of decorate parsing process
Script position no longer contains uninitialized file name

https://forum.zdoom.org/viewtopic.php?t=64836
This commit is contained in:
alexey.lysiuk 2019-05-28 18:13:34 +03:00 committed by drfrag
parent 6dcabe52ca
commit f44a9c8453
3 changed files with 10 additions and 0 deletions

View file

@ -1174,6 +1174,13 @@ FScriptPosition &FScriptPosition::operator=(const FScriptPosition &other)
return *this; return *this;
} }
FScriptPosition &FScriptPosition::operator=(FScanner &sc)
{
FileName = sc.ScriptName;
ScriptLine = sc.GetMessageLine();
return *this;
}
//========================================================================== //==========================================================================
// //
// FScriptPosition::Message // FScriptPosition::Message

View file

@ -167,12 +167,14 @@ struct FScriptPosition
FScriptPosition() FScriptPosition()
{ {
FileName = NAME_None;
ScriptLine=0; ScriptLine=0;
} }
FScriptPosition(const FScriptPosition &other); FScriptPosition(const FScriptPosition &other);
FScriptPosition(FString fname, int line); FScriptPosition(FString fname, int line);
FScriptPosition(FScanner &sc); FScriptPosition(FScanner &sc);
FScriptPosition &operator=(const FScriptPosition &other); FScriptPosition &operator=(const FScriptPosition &other);
FScriptPosition &operator=(FScanner &sc);
void Message(int severity, const char *message,...) const GCCPRINTF(3,4); void Message(int severity, const char *message,...) const GCCPRINTF(3,4);
static void ResetErrorCounter() static void ResetErrorCounter()
{ {

View file

@ -1151,6 +1151,7 @@ static void ParseActor(FScanner &sc, PNamespace *ns)
bag.Namespace = ns; bag.Namespace = ns;
bag.Version = { 2, 0, 0 }; bag.Version = { 2, 0, 0 };
bag.fromDecorate = true; bag.fromDecorate = true;
bag.ScriptPosition = sc;
info = ParseActorHeader(sc, &bag); info = ParseActorHeader(sc, &bag);
sc.MustGetToken('{'); sc.MustGetToken('{');
while (sc.MustGetAnyToken(), sc.TokenType != '}') while (sc.MustGetAnyToken(), sc.TokenType != '}')