- 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
parent 8127af1082
commit 677b24b108
3 changed files with 10 additions and 0 deletions

View file

@ -1148,6 +1148,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 != '}')

View file

@ -1173,6 +1173,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

@ -169,12 +169,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()
{ {