Fixed, Script Editor, Script names parser, DECORATE actor names parser: in some cases (for example, when entering utter garbage instead of proper acs), parsers could get stuck in an infinite loop...

Updated ZDoom_ACS.cfg.
This commit is contained in:
MaxED 2015-03-21 19:41:54 +00:00
parent 8cf084fc41
commit d72e642dce
7 changed files with 32 additions and 35 deletions

View file

@ -318,7 +318,7 @@ keywords
PolyWait = "void PolyWait(int polyid)";
Print = "void Print(type:expression)\nPrint will print something to the screen.\nPrint will only display for the activator of the script\nFor printing to all players, use PrintBold.";
PrintBold = "void PrintBold(type:expression)\nThis is exactly the same as Print, except all players will see the printed text\non the screen instead of just the activator of the script.";
QuakeEx = "void QuakeEx(int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, str sound[, int flags = 0[, float mulwavex = 1.0[, float mulwavey = 1.0[, float mulwavez = 1.0]]]])";
QuakeEx = "bool QuakeEx(int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, str sound[, int flags = 0[, float mulwavex = 1.0[, float mulwavey = 1.0[, float mulwavez = 1.0]]]])";
Radius_Quake = "Radius_Quake(intensity, duration, damrad, tremrad, tid)";
Radius_Quake2 = "void Radius_Quake2(int tid, int intensity, int duration, int damrad, int tremrad, str sound)";
Random = "int Random(int min, int max)";

View file

@ -94,14 +94,14 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
//now find opening brace
do
{
SkipWhitespace(true);
if(!SkipWhitespace(true)) break;
token = ReadToken();
} while (token != "{");
} while (!string.IsNullOrEmpty(token) && token != "{");
token = ReadLine();
string name = "";
if (token.Length > 0)
if (!string.IsNullOrEmpty(token))
{
int commentStart = token.IndexOf("//");
if (commentStart != -1) //found comment
@ -141,10 +141,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
{
do
{
SkipWhitespace(true);
if(!SkipWhitespace(true)) break;
token = ReadToken();
funcname += " " + token;
} while(!token.Contains(")"));
} while(!string.IsNullOrEmpty(token) && !token.Contains(")"));
}
ScriptItem i = new ScriptItem(0, funcname, startPos, isinclude);

View file

@ -8,7 +8,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
{
internal sealed class DecorateParserSE : ZDTextParser
{
private List<ScriptItem> actors;
private readonly List<ScriptItem> actors;
public List<ScriptItem> Actors { get { return actors; } }
public DecorateParserSE()
@ -36,11 +36,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
List<string> definition = new List<string>();
while ((token = ReadToken()) != "{")
do
{
token = ReadToken();
if(string.IsNullOrEmpty(token) || token == "{") break;
definition.Add(token);
SkipWhitespace(true);
}
} while(SkipWhitespace(true));
string name = "";
foreach (string s in definition) name += s + " ";

View file

@ -14,13 +14,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
public delegate void IncludeDelegate(GldefsParser parser, string includefile);
public IncludeDelegate OnInclude;
private Dictionary<string, DynamicLightData> lightsByName; //LightName, light definition
private Dictionary<string, string> objects; //ClassName, LightName
private readonly Dictionary<string, DynamicLightData> lightsByName; //LightName, light definition
private readonly Dictionary<string, string> objects; //ClassName, LightName
public Dictionary<string, DynamicLightData> LightsByName { get { return lightsByName; } }
public Dictionary<string, string> Objects { get { return objects; } }
private List<string> parsedLumps;
private readonly List<string> parsedLumps;
private struct GldefsLightType
{
@ -30,7 +30,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
public const string FLICKER2 = "flickerlight2";
public const string SECTOR = "sectorlight";
public static Dictionary<string, DynamicLightType> GLDEFS_TO_GZDOOM_LIGHT_TYPE = new Dictionary<string, DynamicLightType>(StringComparer.Ordinal) { { POINT, DynamicLightType.NORMAL }, { PULSE, DynamicLightType.PULSE }, { FLICKER, DynamicLightType.FLICKER }, { FLICKER2, DynamicLightType.RANDOM }, { SECTOR, DynamicLightType.SECTOR } };
public static readonly Dictionary<string, DynamicLightType> GLDEFS_TO_GZDOOM_LIGHT_TYPE = new Dictionary<string, DynamicLightType>(StringComparer.Ordinal) { { POINT, DynamicLightType.NORMAL }, { PULSE, DynamicLightType.PULSE }, { FLICKER, DynamicLightType.FLICKER }, { FLICKER2, DynamicLightType.RANDOM }, { SECTOR, DynamicLightType.SECTOR } };
}
public GldefsParser()

View file

@ -41,22 +41,22 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom {
//returns true if parsing is finished
private bool ParseBlock(string token, string mapName)
{
string curBlockName;
if (token == "map" || token == "defaultmap" || token == "adddefaultmap")
{
curBlockName = token;
if (token == "map") //check map name
{
//get map name
SkipWhitespace(true);
token = ReadToken().ToLowerInvariant();
if (token != mapName) return false; //not finished, search for next "map", "defaultmap" or "adddefaultmap" block
}
else if (token == "defaultmap")
string curBlockName = token;
switch(token)
{
//reset MapInfo
mapInfo = new MapInfo();
case "map":
//get map name
SkipWhitespace(true);
token = ReadToken().ToLowerInvariant();
if (token != mapName) return false; //not finished, search for next "map", "defaultmap" or "adddefaultmap" block
break;
case "defaultmap":
//reset MapInfo
mapInfo = new MapInfo();
break;
}
//search for required keys

View file

@ -114,6 +114,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
"It's CRASHENING!",
"W-W-W-WIPEOUT!",
"EVERYTHING IS LOST!",
"Your empty is full!",
"Let's see how far this infinite loop goes...",
};
this.Text = titles[new Random().Next(0, titles.Length - 1)];
}

View file

@ -36,19 +36,13 @@ namespace CodeImp.DoomBuilder.ZDoom
if(token == ",") //previous token was a sprite name
{
if(!string.IsNullOrEmpty(prevToken))
{
if(!spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
}
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
prevToken = token.ToUpperInvariant();
}
else if(token == "=") //next token should be a voxel model name
{
if(!string.IsNullOrEmpty(prevToken))
{
if(!spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
}
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
SkipWhitespace(true);
token = ReadToken();