"Fixed", DECORATE parser: looks like treating missing parent class as an error was way too overwhelming to some users, so parsing is no longer aborted and a warning is added instead of an error.

This commit is contained in:
MaxED 2015-09-28 19:49:15 +00:00
parent 07b4a7a9cd
commit 439d9adc69
2 changed files with 15 additions and 11 deletions

View file

@ -120,16 +120,12 @@ namespace CodeImp.DoomBuilder.ZDoom
parser.ReportError("Expected class name to inherit from");
return;
}
// Find the actor to inherit from
baseclass = parser.GetArchivedActorByName(inheritclass);
//mxd. Does it exist?
if(baseclass == null)
{
parser.ReportError("Parent class '" + inheritclass + "' does not exist");
return;
}
//mxd. Does it exist? (We can carry on regardless, so add a warning)
if(baseclass == null) parser.ReportWarning("Parent class '" + inheritclass + "' does not exist");
break;
case "replaces":

View file

@ -468,26 +468,34 @@ namespace CodeImp.DoomBuilder.ZDoom
errorsource = sourcename;
}
//mxd. This reports a warning
protected internal void ReportWarning(string message)
{
// Add a warning
General.ErrorLogger.Add(ErrorType.Warning, "DECORATE warning in '" + sourcename + "', line " + GetCurrentLineNumber() + ". " + message + ".");
}
//mxd
protected internal int GetCurrentLineNumber()
{
long position = Math.Min(prevstreamposition, datastream.Position);
long pos = datastream.Position;
long finishpos = Math.Min(prevstreamposition, pos);
long readpos = 0;
int linenumber = 0;
// Find the line on which we found this error
datastream.Seek(0, SeekOrigin.Begin);
StreamReader textreader = new StreamReader(datastream, Encoding.ASCII);
while (readpos < position)
while(readpos < finishpos)
{
string line = textreader.ReadLine();
if (line == null) break;
if(line == null) break;
readpos += line.Length + 2;
linenumber++;
}
// Return to original position
datastream.Seek(position, SeekOrigin.Begin);
datastream.Seek(pos, SeekOrigin.Begin);
return linenumber;
}