Add workaround for double slashes in SOC causing freezes

This commit is contained in:
spherallic 2024-02-09 22:47:00 +01:00
parent 85bc168377
commit 8b7bd3ce8c
2 changed files with 8 additions and 6 deletions

View file

@ -121,7 +121,7 @@ namespace CodeImp.DoomBuilder.ZDoom
while (SkipWhitespace(true, true)) while (SkipWhitespace(true, true))
{ {
// Read a token // Read a token
string token = ReadToken(); string token = ReadToken(true, true);
if (!string.IsNullOrEmpty(token)) if (!string.IsNullOrEmpty(token))
{ {
@ -131,7 +131,7 @@ namespace CodeImp.DoomBuilder.ZDoom
if (token.StartsWith("thing") || token.EndsWith("mobj") || token.EndsWith("object")) if (token.StartsWith("thing") || token.EndsWith("mobj") || token.EndsWith("object"))
{ {
SkipWhitespace(true, true); SkipWhitespace(true, true);
token = ReadToken(); token = ReadToken(true, true);
if (!token.ToUpper().StartsWith("MT_")) if (!token.ToUpper().StartsWith("MT_"))
continue; continue;
@ -148,7 +148,7 @@ namespace CodeImp.DoomBuilder.ZDoom
else if (token.Equals("level")) else if (token.Equals("level"))
{ {
SkipWhitespace(true, true); SkipWhitespace(true, true);
token = ReadToken(); token = ReadToken(true, true);
string mapname = GetMapName(token); string mapname = GetMapName(token);

View file

@ -328,8 +328,9 @@ namespace CodeImp.DoomBuilder.ZDoom
// This reads a token (all sequential non-whitespace characters or a single character) // This reads a token (all sequential non-whitespace characters or a single character)
// Returns null when the end of the stream has been reached // Returns null when the end of the stream has been reached
protected internal string ReadToken() { return ReadToken(true); } //mxd. Added "multiline" param protected internal string ReadToken() { return ReadToken(true, false); } //mxd. Added "multiline" param
protected internal string ReadToken(bool multiline) protected internal string ReadToken(bool multiline) { return ReadToken(multiline, false); } //sphere
protected internal string ReadToken(bool multiline, bool SOC)
{ {
//mxd. Return empty string when the end of the stream has been reached //mxd. Return empty string when the end of the stream has been reached
if(datastream.Position == datastream.Length) return string.Empty; if(datastream.Position == datastream.Length) return string.Empty;
@ -387,7 +388,8 @@ namespace CodeImp.DoomBuilder.ZDoom
if(!quotedstring) break; if(!quotedstring) break;
} }
// Potential comment? // Potential comment?
else if((c == '/') && !quotedstring) // TODO: figure out why double slashes in SOC scripts cause UZB to freeze forever
else if (!SOC && (c == '/') && !quotedstring)
{ {
// Check the next byte // Check the next byte
if(datastream.Position == datastream.Length) return token; if(datastream.Position == datastream.Length) return token;