2016-03-25 14:06:00 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
2015-12-21 14:17:47 +00:00
|
|
|
|
using System.IO;
|
2012-07-10 10:20:45 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Config;
|
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
2012-07-10 10:20:45 +00:00
|
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2012-07-12 22:34:12 +00:00
|
|
|
|
//mxd. ACS parser used to create ScriptItems for use in script editor's navigator
|
2016-04-27 09:13:07 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.ZDoom.Scripting
|
2012-07-10 10:20:45 +00:00
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
internal sealed class AcsParserSE : ZDTextParser
|
|
|
|
|
{
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#region ================== Event Delegates
|
|
|
|
|
|
2015-12-27 21:54:50 +00:00
|
|
|
|
internal delegate void IncludeDelegate(AcsParserSE parser, string includefile, IncludeType includetype);
|
2013-09-11 09:47:53 +00:00
|
|
|
|
internal IncludeDelegate OnInclude;
|
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
|
|
private readonly Dictionary<string, HashSet<string>> includes; // <either "SCRIPTS" or Source library name, <List of files it #includes>>
|
2015-12-21 14:17:47 +00:00
|
|
|
|
private HashSet<string> includestoskip;
|
2015-11-30 14:18:42 +00:00
|
|
|
|
private string libraryname;
|
2014-07-16 09:47:23 +00:00
|
|
|
|
|
2015-04-28 08:31:06 +00:00
|
|
|
|
private readonly List<ScriptItem> namedscripts;
|
|
|
|
|
private readonly List<ScriptItem> numberedscripts;
|
2014-07-16 09:47:23 +00:00
|
|
|
|
private readonly List<ScriptItem> functions;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
|
|
internal override ScriptType ScriptType { get { return ScriptType.ACS; } }
|
|
|
|
|
|
2015-04-28 08:31:06 +00:00
|
|
|
|
internal List<ScriptItem> NamedScripts { get { return namedscripts; } }
|
|
|
|
|
internal List<ScriptItem> NumberedScripts { get { return numberedscripts; } }
|
2014-07-16 09:47:23 +00:00
|
|
|
|
internal List<ScriptItem> Functions { get { return functions; } }
|
2015-11-30 14:18:42 +00:00
|
|
|
|
internal bool IsLibrary { get { return !string.IsNullOrEmpty(libraryname); } }
|
|
|
|
|
internal string LibraryName { get { return libraryname; } }
|
|
|
|
|
|
|
|
|
|
internal bool AddArgumentsToScriptNames;
|
|
|
|
|
internal bool IsMapScriptsLump;
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
internal bool IgnoreErrors;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Enums
|
|
|
|
|
|
2015-12-27 21:54:50 +00:00
|
|
|
|
internal enum IncludeType
|
|
|
|
|
{
|
|
|
|
|
NONE,
|
|
|
|
|
INCLUDE,
|
|
|
|
|
LIBRARY
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
internal AcsParserSE()
|
|
|
|
|
{
|
2015-04-28 08:31:06 +00:00
|
|
|
|
namedscripts = new List<ScriptItem>();
|
|
|
|
|
numberedscripts = new List<ScriptItem>();
|
2014-07-16 09:47:23 +00:00
|
|
|
|
functions = new List<ScriptItem>();
|
2016-03-25 14:06:00 +00:00
|
|
|
|
includes = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
|
2015-12-21 14:17:47 +00:00
|
|
|
|
includestoskip = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
2015-07-27 09:02:28 +00:00
|
|
|
|
specialtokens += "(,)";
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#endregion
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#region ================== Parsing
|
2015-11-13 21:42:41 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
public override bool Parse(TextResourceData data, bool clearerrors) { return Parse(data, new HashSet<string>(), false, IncludeType.NONE, clearerrors); }
|
|
|
|
|
public bool Parse(TextResourceData data, bool processincludes, IncludeType includetype, bool clearerrors) { return Parse(data, includestoskip, processincludes, includetype, clearerrors); }
|
|
|
|
|
public bool Parse(TextResourceData data, HashSet<string> configincludes, bool processincludes, IncludeType includetype, bool clearerrors)
|
2015-11-13 21:42:41 +00:00
|
|
|
|
{
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
string source = data.Filename.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
2015-12-18 10:16:53 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
//INFO: files included or imported inside a library are not visible to the code outside it
|
|
|
|
|
//and must be included/imported separately
|
|
|
|
|
|
|
|
|
|
// Includes tracking. "Regular" includes go to "SCRIPTS" group, library includes are tracked per-library
|
|
|
|
|
string includecategory = (processincludes && includetype == IncludeType.LIBRARY ? source : "SCRIPTS");
|
|
|
|
|
if(!includes.ContainsKey(includecategory)) includes.Add(includecategory, new HashSet<string>(StringComparer.OrdinalIgnoreCase));
|
|
|
|
|
|
2015-12-21 14:17:47 +00:00
|
|
|
|
includestoskip = configincludes;
|
|
|
|
|
int bracelevel = 0;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
// Already parsed?
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
if(!base.AddTextResource(data))
|
|
|
|
|
{
|
|
|
|
|
if(clearerrors) ClearError();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cannot process?
|
|
|
|
|
if(!base.Parse(data, clearerrors)) return false;
|
2012-07-23 21:28:23 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Keep local data
|
|
|
|
|
Stream localstream = datastream;
|
|
|
|
|
string localsourcename = sourcename;
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
int localsourcelumpindex = sourcelumpindex;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
BinaryReader localreader = datareader;
|
2016-03-25 14:06:00 +00:00
|
|
|
|
DataLocation locallocation = datalocation;
|
|
|
|
|
string localincludecategory = includecategory;
|
2012-07-23 21:28:23 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Continue until at the end of the stream
|
2015-11-13 21:42:41 +00:00
|
|
|
|
while(SkipWhitespace(true))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-04-06 22:54:04 +00:00
|
|
|
|
string token = ReadToken().ToLowerInvariant();
|
2015-04-28 08:31:06 +00:00
|
|
|
|
if(string.IsNullOrEmpty(token)) continue;
|
2012-07-10 10:20:45 +00:00
|
|
|
|
|
2015-04-28 08:31:06 +00:00
|
|
|
|
// Ignore inner scope stuff
|
|
|
|
|
if(token == "{") { bracelevel++; continue; }
|
|
|
|
|
if(token == "}") { bracelevel--; continue; }
|
|
|
|
|
if(bracelevel > 0) continue;
|
2012-07-10 10:20:45 +00:00
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
switch(token)
|
2015-04-28 08:31:06 +00:00
|
|
|
|
{
|
|
|
|
|
case "script":
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
SkipWhitespace(true);
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
int startpos = (int)datastream.Position;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
token = ReadToken();
|
2012-07-10 10:20:45 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
// Is this a named script?
|
2015-11-13 21:42:41 +00:00
|
|
|
|
if(token.IndexOf('"') != -1)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-04-28 08:31:06 +00:00
|
|
|
|
startpos += 1;
|
2016-04-06 22:54:04 +00:00
|
|
|
|
string scriptname = StripQuotes(token);
|
2013-08-07 09:25:37 +00:00
|
|
|
|
|
2015-07-27 09:02:28 +00:00
|
|
|
|
// Try to parse argument names
|
|
|
|
|
List<KeyValuePair<string, string>> args = ParseArgs();
|
|
|
|
|
List<string> argnames = new List<string>();
|
|
|
|
|
foreach(KeyValuePair<string, string> group in args) argnames.Add(group.Value);
|
|
|
|
|
|
2015-11-30 14:18:42 +00:00
|
|
|
|
// Make full name
|
|
|
|
|
if(AddArgumentsToScriptNames) scriptname += " " + GetArgumentNames(args);
|
|
|
|
|
|
2015-07-27 09:02:28 +00:00
|
|
|
|
// Add to collection
|
2015-12-27 21:54:50 +00:00
|
|
|
|
namedscripts.Add(new ScriptItem(scriptname, argnames, startpos, includetype != IncludeType.NONE));
|
2016-03-25 14:06:00 +00:00
|
|
|
|
}
|
|
|
|
|
// Should be numbered script
|
|
|
|
|
else
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2014-02-21 14:42:12 +00:00
|
|
|
|
int n;
|
2015-11-13 21:42:41 +00:00
|
|
|
|
if(int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out n))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-07-27 09:02:28 +00:00
|
|
|
|
// Try to parse argument names
|
|
|
|
|
List<KeyValuePair<string, string>> args = ParseArgs();
|
|
|
|
|
|
|
|
|
|
// Now find the opening brace
|
2014-12-03 23:15:26 +00:00
|
|
|
|
do
|
|
|
|
|
{
|
2015-03-21 19:41:54 +00:00
|
|
|
|
if(!SkipWhitespace(true)) break;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
token = ReadToken();
|
2015-12-28 15:01:53 +00:00
|
|
|
|
} while(!string.IsNullOrEmpty(token) && token != "{");
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
|
|
|
|
token = ReadLine();
|
|
|
|
|
string name = "";
|
2015-04-28 08:31:06 +00:00
|
|
|
|
bracelevel = 1;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2015-11-13 21:42:41 +00:00
|
|
|
|
if(!string.IsNullOrEmpty(token))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
int commentstart = token.IndexOf("//", StringComparison.Ordinal);
|
2016-03-25 14:06:00 +00:00
|
|
|
|
if(commentstart != -1) // Found comment
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-04-28 08:31:06 +00:00
|
|
|
|
commentstart += 2;
|
|
|
|
|
name = token.Substring(commentstart, token.Length - commentstart).Trim();
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-28 15:04:21 +00:00
|
|
|
|
bool customname = (name.Length > 0);
|
2015-11-30 14:18:42 +00:00
|
|
|
|
name = (customname ? name + " [Script " + n + "]" : "Script " + n);
|
2015-07-27 09:02:28 +00:00
|
|
|
|
|
|
|
|
|
List<string> argnames = new List<string>();
|
|
|
|
|
foreach(KeyValuePair<string, string> group in args) argnames.Add(group.Value);
|
|
|
|
|
|
2015-11-30 14:18:42 +00:00
|
|
|
|
// Make full name
|
|
|
|
|
if(AddArgumentsToScriptNames) name += " " + GetArgumentNames(args);
|
|
|
|
|
|
2015-07-27 09:02:28 +00:00
|
|
|
|
// Add to collection
|
2015-12-27 21:54:50 +00:00
|
|
|
|
numberedscripts.Add(new ScriptItem(n, name, argnames, startpos, includetype != IncludeType.NONE, customname));
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-28 08:31:06 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "function":
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2014-07-16 09:47:23 +00:00
|
|
|
|
SkipWhitespace(true);
|
2016-03-25 14:06:00 +00:00
|
|
|
|
string funcname = ReadToken(); // Read return type
|
2014-07-16 09:47:23 +00:00
|
|
|
|
SkipWhitespace(true);
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
int startpos = (int)datastream.Position;
|
2016-03-25 14:06:00 +00:00
|
|
|
|
funcname += " " + ReadToken(); // Read function name
|
2014-07-16 09:47:23 +00:00
|
|
|
|
|
2015-07-27 09:02:28 +00:00
|
|
|
|
// Try to parse argument names
|
|
|
|
|
List<KeyValuePair<string, string>> args = ParseArgs();
|
|
|
|
|
List<string> argnames = new List<string>();
|
|
|
|
|
foreach(KeyValuePair<string, string> group in args) argnames.Add(group.Value);
|
2014-07-16 09:47:23 +00:00
|
|
|
|
|
2015-11-30 14:18:42 +00:00
|
|
|
|
// Make full name
|
|
|
|
|
if(AddArgumentsToScriptNames) funcname += GetArgumentNames(args);
|
|
|
|
|
|
2015-07-27 09:02:28 +00:00
|
|
|
|
// Add to collection
|
2015-12-27 21:54:50 +00:00
|
|
|
|
functions.Add(new ScriptItem(funcname, argnames, startpos, includetype != IncludeType.NONE));
|
2015-04-28 08:31:06 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2015-11-30 14:18:42 +00:00
|
|
|
|
case "#library":
|
|
|
|
|
if(IsMapScriptsLump)
|
|
|
|
|
{
|
2015-12-17 10:07:28 +00:00
|
|
|
|
ReportError("SCRIPTS lump can not be compiled as a library");
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
if(!IgnoreErrors) return false;
|
2015-11-30 14:18:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SkipWhitespace(true);
|
2015-12-27 21:54:50 +00:00
|
|
|
|
string libname = ReadToken(false); // Don't skip newline
|
2015-11-30 14:18:42 +00:00
|
|
|
|
|
2015-12-27 21:54:50 +00:00
|
|
|
|
if(!libname.StartsWith("\"") || !libname.EndsWith("\""))
|
2015-11-30 14:18:42 +00:00
|
|
|
|
{
|
2015-12-17 10:07:28 +00:00
|
|
|
|
ReportError("#library name should be quoted");
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
return IgnoreErrors;
|
2015-11-30 14:18:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
libname = StripQuotes(libname);
|
2015-12-17 10:07:28 +00:00
|
|
|
|
|
2015-12-27 21:54:50 +00:00
|
|
|
|
if(string.IsNullOrEmpty(libname))
|
2015-12-17 10:07:28 +00:00
|
|
|
|
{
|
|
|
|
|
ReportError("Expected library name");
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
return IgnoreErrors;
|
2015-12-17 10:07:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-27 21:54:50 +00:00
|
|
|
|
// Store only when the script compiling was executed for is library
|
|
|
|
|
if(includetype == IncludeType.NONE)
|
|
|
|
|
{
|
|
|
|
|
libraryname = libname;
|
|
|
|
|
includetype = IncludeType.LIBRARY;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-30 14:18:42 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2015-04-28 08:31:06 +00:00
|
|
|
|
default:
|
2015-11-13 21:42:41 +00:00
|
|
|
|
if(processincludes && (token == "#include" || token == "#import"))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
//INFO: ZDoom ACC include paths can be absolute ("d:\stuff\coollib.acs"), relative ("../coollib.acs")
|
|
|
|
|
//and can use forward and backward slashes ("acs\map01/script.acs")
|
|
|
|
|
//also include paths must be quoted
|
|
|
|
|
//long filenames are supported
|
2016-03-25 14:06:00 +00:00
|
|
|
|
|
2015-04-28 08:31:06 +00:00
|
|
|
|
SkipWhitespace(true);
|
2015-12-17 10:07:28 +00:00
|
|
|
|
string includelump = ReadToken(false); // Don't skip newline
|
|
|
|
|
|
|
|
|
|
if(!includelump.StartsWith("\"") || !includelump.EndsWith("\""))
|
|
|
|
|
{
|
|
|
|
|
ReportError(token + " filename should be quoted");
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
return IgnoreErrors;
|
2015-12-17 10:07:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
includelump = StripQuotes(includelump);
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2015-12-17 10:07:28 +00:00
|
|
|
|
if(string.IsNullOrEmpty(includelump))
|
2015-04-28 08:31:06 +00:00
|
|
|
|
{
|
2015-12-17 10:07:28 +00:00
|
|
|
|
ReportError("Expected file name to " + token);
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
return IgnoreErrors;
|
2015-12-17 10:07:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-21 14:17:47 +00:00
|
|
|
|
includelump = includelump.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
2015-12-17 10:07:28 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
// Compiler files? Track them, but don't parse them
|
2016-03-07 20:01:13 +00:00
|
|
|
|
if(includestoskip.Contains(includelump))
|
|
|
|
|
{
|
|
|
|
|
// These can also be included several times...
|
2016-03-25 14:06:00 +00:00
|
|
|
|
if(includes[includecategory].Contains(includelump))
|
2016-03-08 21:14:24 +00:00
|
|
|
|
{
|
2016-03-25 14:06:00 +00:00
|
|
|
|
ReportError("Already parsed \"" + includelump + "\". Check your " + token + " directives");
|
|
|
|
|
return IgnoreErrors;
|
2016-03-08 21:14:24 +00:00
|
|
|
|
}
|
2016-03-25 14:06:00 +00:00
|
|
|
|
|
|
|
|
|
// Add to collection
|
|
|
|
|
includes[includecategory].Add(includelump);
|
2016-03-07 20:01:13 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2015-12-17 10:07:28 +00:00
|
|
|
|
|
2015-12-27 21:54:50 +00:00
|
|
|
|
// Convert to a path we can use
|
2015-12-21 14:17:47 +00:00
|
|
|
|
string includelumppath = GetRootedPath(source, includelump);
|
|
|
|
|
|
|
|
|
|
// Rooting succeeded?
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
|
if((HasError && !IgnoreErrors) || string.IsNullOrEmpty(includelumppath))
|
|
|
|
|
return IgnoreErrors;
|
2015-12-21 14:17:47 +00:00
|
|
|
|
|
|
|
|
|
// Already parsed?
|
2016-03-25 14:06:00 +00:00
|
|
|
|
if(includes[includecategory].Contains(includelumppath))
|
2015-04-28 08:31:06 +00:00
|
|
|
|
{
|
2016-03-25 14:06:00 +00:00
|
|
|
|
ReportError("Already parsed \"" + includelump + "\". Check your " + token + " directives");
|
|
|
|
|
return IgnoreErrors;
|
2015-04-28 08:31:06 +00:00
|
|
|
|
}
|
2015-12-21 14:17:47 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
// Add to collection
|
|
|
|
|
includes[includecategory].Add(includelumppath);
|
2015-12-17 10:07:28 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
// Callback to parse this file
|
|
|
|
|
if(OnInclude != null)
|
|
|
|
|
{
|
|
|
|
|
IsMapScriptsLump = false;
|
|
|
|
|
OnInclude(this, includelumppath, (token == "#import" ? IncludeType.LIBRARY : IncludeType.INCLUDE));
|
2015-12-27 21:54:50 +00:00
|
|
|
|
}
|
2016-03-25 14:06:00 +00:00
|
|
|
|
|
|
|
|
|
// Bail out on error
|
|
|
|
|
if(this.HasError && !IgnoreErrors) return false;
|
|
|
|
|
|
|
|
|
|
// Set our buffers back to continue parsing
|
|
|
|
|
datastream = localstream;
|
|
|
|
|
datareader = localreader;
|
|
|
|
|
sourcename = localsourcename;
|
|
|
|
|
sourcelumpindex = localsourcelumpindex;
|
|
|
|
|
datalocation = locallocation;
|
|
|
|
|
includecategory = localincludecategory;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2015-04-28 08:31:06 +00:00
|
|
|
|
break;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-07-27 09:02:28 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
|
|
internal HashSet<string> GetIncludes()
|
|
|
|
|
{
|
|
|
|
|
HashSet<string> result = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
foreach(KeyValuePair<string, HashSet<string>> group in includes)
|
|
|
|
|
{
|
|
|
|
|
foreach(string include in group.Value) result.Add(include);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.ExceptWith(includestoskip); // Remove compiler includes
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-27 09:02:28 +00:00
|
|
|
|
private List<KeyValuePair<string, string>> ParseArgs() //type, name
|
|
|
|
|
{
|
|
|
|
|
List<KeyValuePair<string, string>> argnames = new List<KeyValuePair<string, string>>();
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
string token = ReadToken();
|
|
|
|
|
|
|
|
|
|
// Should be ENTER/OPEN etc. script type
|
|
|
|
|
if(token != "(")
|
|
|
|
|
{
|
|
|
|
|
argnames.Add(new KeyValuePair<string, string>(token.ToUpperInvariant(), string.Empty));
|
|
|
|
|
return argnames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while(SkipWhitespace(true))
|
|
|
|
|
{
|
|
|
|
|
string argtype = ReadToken(); // should be type
|
|
|
|
|
if(IsSpecialToken(argtype)) break;
|
|
|
|
|
if(argtype.ToUpperInvariant() == "VOID")
|
|
|
|
|
{
|
2015-11-30 14:18:42 +00:00
|
|
|
|
argnames.Add(new KeyValuePair<string, string>("void", string.Empty));
|
2015-07-27 09:02:28 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = ReadToken(); // should be arg name
|
|
|
|
|
argnames.Add(new KeyValuePair<string, string>(argtype, token));
|
|
|
|
|
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = ReadToken(); // should be comma or ")"
|
|
|
|
|
if(token != ",") break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return argnames;
|
|
|
|
|
}
|
2015-11-30 14:18:42 +00:00
|
|
|
|
|
|
|
|
|
private static string GetArgumentNames(List<KeyValuePair<string, string>> args)
|
|
|
|
|
{
|
|
|
|
|
// Make full name
|
|
|
|
|
if(args.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
List<string> argdescs = new List<string>(args.Count);
|
|
|
|
|
foreach(KeyValuePair<string, string> group in args)
|
|
|
|
|
argdescs.Add((group.Key + " " + group.Value).TrimEnd());
|
|
|
|
|
|
|
|
|
|
return "(" + string.Join(", ", argdescs.ToArray()) + ")";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "(void)";
|
|
|
|
|
}
|
2015-12-17 10:07:28 +00:00
|
|
|
|
|
2016-03-25 14:06:00 +00:00
|
|
|
|
#endregion
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2012-07-10 14:14:53 +00:00
|
|
|
|
}
|