mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 12:22:35 +00:00
MODELDEF parser: a model should be skipped when it's FrameIndex is -1.
This commit is contained in:
parent
45dca2be46
commit
6565dd9384
2 changed files with 37 additions and 10 deletions
|
@ -19,6 +19,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
string[] textureNames = new string[4];
|
||||
string[] modelNames = new string[4];
|
||||
bool[] modelsUsed = new bool[MAX_MODELS];
|
||||
string path = "";
|
||||
Vector3 scale = new Vector3(1, 1, 1);
|
||||
Vector3 offset = new Vector3();
|
||||
|
@ -279,7 +280,6 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
string spriteLump = null;
|
||||
string spriteFrame = null;
|
||||
bool[] modelsUsed = new bool[MAX_MODELS];
|
||||
|
||||
//step back
|
||||
parser.DataStream.Seek(-token.Length - 1, SeekOrigin.Current);
|
||||
|
@ -368,21 +368,23 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
parser.SkipWhitespace(true);
|
||||
|
||||
//should be frame name or index. Currently I have no use for it
|
||||
// Should be frame name or index. Currently I have no use for it
|
||||
token = parser.StripTokenQuotes(parser.ReadToken());
|
||||
|
||||
if(frameIndex)
|
||||
{
|
||||
int frame;
|
||||
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out frame))
|
||||
int frame = 0;
|
||||
if(!parser.ReadSignedInt(token, ref frame))
|
||||
{
|
||||
// Not numeric!
|
||||
General.ErrorLogger.Add(ErrorType.Error, "Error in " + parser.Source + " at line " + parser.GetCurrentLineNumber() + ": expected model frame, but got '" + token + "'");
|
||||
gotErrors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Skip the model if frame index is -1
|
||||
if(frame == -1) modelsUsed[modelIndex] = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -398,16 +400,17 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
}
|
||||
}
|
||||
|
||||
//find closing brace, then quit;
|
||||
// Find closing brace, then quit
|
||||
while (parser.SkipWhitespace(true))
|
||||
{
|
||||
token = parser.ReadToken();
|
||||
if (token == "}") break;
|
||||
}
|
||||
|
||||
if (gotErrors) return null;
|
||||
|
||||
//classname is set in ModeldefParser
|
||||
// Bail out when got errors or no models are used
|
||||
if (gotErrors || Array.IndexOf(modelsUsed, true) == -1) return null;
|
||||
|
||||
// Classname is set in ModeldefParser
|
||||
ModelData mde = new ModelData();
|
||||
mde.InheritActorPitch = inheritactorpitch;
|
||||
mde.InheritActorRoll = inheritactorroll;
|
||||
|
|
|
@ -386,6 +386,30 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
return token.Trim();
|
||||
}
|
||||
|
||||
//mxd
|
||||
protected bool NextTokenIs(string expectedtoken)
|
||||
{
|
||||
return NextTokenIs(expectedtoken, true);
|
||||
}
|
||||
|
||||
//mxd
|
||||
protected bool NextTokenIs(string expectedtoken, bool reporterror)
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
string token = ReadToken();
|
||||
|
||||
if(token != expectedtoken)
|
||||
{
|
||||
if(reporterror) General.ErrorLogger.Add(ErrorType.Error, "Error in '" + sourcename + "' at line " + GetCurrentLineNumber() + ": expected '" + expectedtoken + "', but got '" + token + "'");
|
||||
|
||||
// Rewind so this structure can be read again
|
||||
DataStream.Seek(-token.Length - 1, SeekOrigin.Current);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//mxd
|
||||
protected internal bool ReadSignedFloat(string token, ref float value)
|
||||
{
|
||||
|
@ -403,7 +427,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
}
|
||||
|
||||
//mxd
|
||||
protected bool ReadSignedInt(string token, ref int value)
|
||||
protected internal bool ReadSignedInt(string token, ref int value)
|
||||
{
|
||||
int sign = 1;
|
||||
if (token == "-")
|
||||
|
|
Loading…
Reference in a new issue