2015-04-14 11:33:57 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
using System;
|
2015-04-14 11:33:57 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
2012-06-01 10:17:47 +00:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using SlimDX;
|
|
|
|
|
using CodeImp.DoomBuilder.ZDoom;
|
|
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
|
|
|
|
|
2015-04-14 11:33:57 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|
|
|
|
{
|
|
|
|
|
internal sealed class MapinfoParser : ZDTextParser
|
|
|
|
|
{
|
|
|
|
|
#region ================== Delegates
|
|
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
|
public delegate void IncludeDelegate(MapinfoParser parser, string includefile, bool clearerror);
|
2015-04-14 11:33:57 +00:00
|
|
|
|
public IncludeDelegate OnInclude;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
|
|
private MapInfo mapinfo;
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
private string mapname;
|
2015-04-14 11:33:57 +00:00
|
|
|
|
private readonly Dictionary<int, string> spawnnums;
|
|
|
|
|
private readonly Dictionary<int, string> doomednums; // <DoomEdNum, <lowercase classname, List of default arguments>>
|
2015-12-17 10:07:28 +00:00
|
|
|
|
private readonly HashSet<string> parsedlumps;
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
|
|
public MapInfo MapInfo { get { return mapinfo; } }
|
|
|
|
|
public Dictionary<int, string> SpawnNums { get { return spawnnums; } }
|
|
|
|
|
public Dictionary<int, string> DoomEdNums { get { return doomednums; } }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor
|
|
|
|
|
|
|
|
|
|
public MapinfoParser()
|
|
|
|
|
{
|
2015-04-29 08:36:10 +00:00
|
|
|
|
// Syntax
|
|
|
|
|
whitespace = "\n \t\r\u00A0";
|
2015-05-18 18:49:15 +00:00
|
|
|
|
specialtokens = ",{}=\n";
|
2015-04-29 08:36:10 +00:00
|
|
|
|
|
2015-04-14 11:33:57 +00:00
|
|
|
|
mapinfo = new MapInfo();
|
|
|
|
|
spawnnums = new Dictionary<int, string>();
|
|
|
|
|
doomednums = new Dictionary<int, string>();
|
2015-12-21 14:17:47 +00:00
|
|
|
|
parsedlumps = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
2015-04-14 11:33:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2012-06-01 10:17:47 +00:00
|
|
|
|
|
2015-04-14 11:33:57 +00:00
|
|
|
|
#region ================== Parsing
|
2012-06-01 10:17:47 +00:00
|
|
|
|
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
|
override public bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
if(string.IsNullOrEmpty(mapname)) throw new NotSupportedException("Map name required!");
|
2015-12-18 10:16:53 +00:00
|
|
|
|
return Parse(stream, sourcefilename, mapname, clearerrors);
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
|
public bool Parse(Stream stream, string sourcefilename, string mapname, bool clearerrors)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
this.mapname = mapname.ToLowerInvariant();
|
2015-12-18 10:16:53 +00:00
|
|
|
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
2012-06-01 10:17:47 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Keep local data
|
|
|
|
|
Stream localstream = datastream;
|
|
|
|
|
string localsourcename = sourcename;
|
|
|
|
|
BinaryReader localreader = datareader;
|
|
|
|
|
|
|
|
|
|
// Classic format skip stoppers...
|
|
|
|
|
HashSet<string> breakat = new HashSet<string> { "map", "defaultmap", "adddefaultmap" };
|
|
|
|
|
|
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
|
|
|
|
while(SkipWhitespace(true))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
string token = ReadToken().ToLowerInvariant();
|
Fixed, Visual mode: in some cases ceiling glow effect was interfering with Transfer Brightness effect resulting in incorrectly lit sidedef geometry.
Fixed, Visual mode: UDMF sidedef brightness should be ignored when a wall section is affected by Transfer Brightness effect.
Fixed, Visual mode: any custom fog should be rendered regardless of sector brightness.
Fixed, Visual mode: "fogdensity" and "outsidefogdensity" MAPINFO values were processed incorrectly.
Fixed, Visual mode: in some cases Things were rendered twice during a render pass.
Fixed, Visual mode: floor glow effect should affect thing brightness only when applied to floor of the sector thing is in.
Fixed, TEXTURES parser: TEXTURES group was named incorrectly in the Textures Browser window when parsed from a WAD file.
Fixed, MAPINFO, GLDEFS, DECORATE parsers: "//$GZDB_SKIP" special comment was processed incorrectly.
Fixed, MAPINFO parser: "fogdensity" and "outsidefogdensity" properties are now initialized using GZDoom default value (255) instead of 0.
2016-01-25 13:42:53 +00:00
|
|
|
|
if(string.IsNullOrEmpty(token) || token == "$gzdb_skip") break;
|
2016-01-11 13:00:52 +00:00
|
|
|
|
|
|
|
|
|
switch(token)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
case "adddefaultmap":
|
|
|
|
|
// Parse properties
|
|
|
|
|
if(!ParseMapBlock()) return false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "defaultmap":
|
|
|
|
|
// Reset MapInfo
|
|
|
|
|
mapinfo = new MapInfo();
|
|
|
|
|
|
|
|
|
|
// Parse properties
|
|
|
|
|
if(!ParseMapBlock()) return false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "map":
|
|
|
|
|
// Get map lump name
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = ReadToken().ToLowerInvariant();
|
|
|
|
|
if(token != this.mapname)
|
|
|
|
|
{
|
|
|
|
|
// Map number? Try to build map name from it...
|
|
|
|
|
int n;
|
|
|
|
|
if(int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out n))
|
|
|
|
|
{
|
|
|
|
|
token = ((n > 0 && n < 10) ? "map0" + n : "map" + n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Still no dice?
|
|
|
|
|
if(token != this.mapname)
|
|
|
|
|
{
|
|
|
|
|
SkipStructure(breakat);
|
|
|
|
|
continue; // Not finished, search for next "map", "defaultmap" or "adddefaultmap" block
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Try to get map name
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = ReadToken();
|
|
|
|
|
if(token.ToLowerInvariant() == "lookup")
|
|
|
|
|
{
|
|
|
|
|
// No dice...
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
ReadToken();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mapinfo.Title = StripTokenQuotes(token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Parse properties
|
|
|
|
|
if(!ParseMapBlock()) return false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "include":
|
|
|
|
|
if(!ParseInclude(clearerrors)) return false;
|
|
|
|
|
|
|
|
|
|
// Set our buffers back to continue parsing
|
|
|
|
|
datastream = localstream;
|
|
|
|
|
datareader = localreader;
|
|
|
|
|
sourcename = localsourcename;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "gameinfo":
|
|
|
|
|
if(!ParseGameInfo()) return false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "doomednums":
|
|
|
|
|
if(!ParseDoomEdNums()) return false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "spawnnums":
|
|
|
|
|
if(!ParseSpawnNums()) return false;
|
|
|
|
|
break;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-01 10:17:47 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Check values
|
Fixed, Visual mode: in some cases ceiling glow effect was interfering with Transfer Brightness effect resulting in incorrectly lit sidedef geometry.
Fixed, Visual mode: UDMF sidedef brightness should be ignored when a wall section is affected by Transfer Brightness effect.
Fixed, Visual mode: any custom fog should be rendered regardless of sector brightness.
Fixed, Visual mode: "fogdensity" and "outsidefogdensity" MAPINFO values were processed incorrectly.
Fixed, Visual mode: in some cases Things were rendered twice during a render pass.
Fixed, Visual mode: floor glow effect should affect thing brightness only when applied to floor of the sector thing is in.
Fixed, TEXTURES parser: TEXTURES group was named incorrectly in the Textures Browser window when parsed from a WAD file.
Fixed, MAPINFO, GLDEFS, DECORATE parsers: "//$GZDB_SKIP" special comment was processed incorrectly.
Fixed, MAPINFO parser: "fogdensity" and "outsidefogdensity" properties are now initialized using GZDoom default value (255) instead of 0.
2016-01-25 13:42:53 +00:00
|
|
|
|
if(mapinfo.FogDensity > 0 && (mapinfo.FadeColor.Red > 0 || mapinfo.FadeColor.Green > 0 || mapinfo.FadeColor.Blue > 0))
|
2015-04-14 11:33:57 +00:00
|
|
|
|
mapinfo.HasFadeColor = true;
|
2012-06-01 10:17:47 +00:00
|
|
|
|
|
Fixed, Visual mode: in some cases ceiling glow effect was interfering with Transfer Brightness effect resulting in incorrectly lit sidedef geometry.
Fixed, Visual mode: UDMF sidedef brightness should be ignored when a wall section is affected by Transfer Brightness effect.
Fixed, Visual mode: any custom fog should be rendered regardless of sector brightness.
Fixed, Visual mode: "fogdensity" and "outsidefogdensity" MAPINFO values were processed incorrectly.
Fixed, Visual mode: in some cases Things were rendered twice during a render pass.
Fixed, Visual mode: floor glow effect should affect thing brightness only when applied to floor of the sector thing is in.
Fixed, TEXTURES parser: TEXTURES group was named incorrectly in the Textures Browser window when parsed from a WAD file.
Fixed, MAPINFO, GLDEFS, DECORATE parsers: "//$GZDB_SKIP" special comment was processed incorrectly.
Fixed, MAPINFO parser: "fogdensity" and "outsidefogdensity" properties are now initialized using GZDoom default value (255) instead of 0.
2016-01-25 13:42:53 +00:00
|
|
|
|
if(mapinfo.OutsideFogDensity > 0 && (mapinfo.OutsideFogColor.Red > 0 || mapinfo.OutsideFogColor.Green > 0 || mapinfo.OutsideFogColor.Blue > 0))
|
2015-04-14 11:33:57 +00:00
|
|
|
|
mapinfo.HasOutsideFogColor = true;
|
2012-06-01 10:17:47 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// All done
|
|
|
|
|
return !this.HasError;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2012-06-01 10:17:47 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
private bool ParseInclude(bool clearerrors)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
string includelump = StripTokenQuotes(ReadToken(false)); // Don't skip newline
|
|
|
|
|
|
|
|
|
|
//INFO: ZDoom MAPINFO include paths can't be relative ("../mapstuff.txt")
|
|
|
|
|
//or absolute ("d:/project/mapstuff.txt")
|
|
|
|
|
//or have backward slashes ("info\mapstuff.txt")
|
|
|
|
|
//include paths are relative to the first parsed entry, not the current one
|
|
|
|
|
//also include paths may or may not be quoted
|
|
|
|
|
if(!string.IsNullOrEmpty(includelump))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Absolute paths are not supported...
|
|
|
|
|
if(Path.IsPathRooted(includelump))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
ReportError("Absolute include paths are not supported by ZDoom");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-03-21 19:41:54 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Relative paths are not supported
|
|
|
|
|
if(includelump.StartsWith(RELATIVE_PATH_MARKER) || includelump.StartsWith(CURRENT_FOLDER_PATH_MARKER) ||
|
|
|
|
|
includelump.StartsWith(ALT_RELATIVE_PATH_MARKER) || includelump.StartsWith(ALT_CURRENT_FOLDER_PATH_MARKER))
|
|
|
|
|
{
|
|
|
|
|
ReportError("Relative include paths are not supported by ZDoom");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Backward slashes are not supported
|
|
|
|
|
if(includelump.Contains(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)))
|
|
|
|
|
{
|
|
|
|
|
ReportError("Only forward slashes are supported by ZDoom");
|
|
|
|
|
return false;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2012-06-01 10:17:47 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Check invalid path chars
|
|
|
|
|
if(!CheckInvalidPathChars(includelump)) return false;
|
2015-08-23 23:32:12 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Already parsed?
|
|
|
|
|
if(parsedlumps.Contains(includelump))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
ReportError("Already parsed '" + includelump + "'. Check your include directives");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Add to collection
|
|
|
|
|
parsedlumps.Add(includelump);
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Callback to parse this file
|
|
|
|
|
if(OnInclude != null)
|
|
|
|
|
{
|
|
|
|
|
OnInclude(this, includelump, clearerrors);
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Bail out on error
|
|
|
|
|
if(this.HasError) return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReportError("Expected filename to include");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// All done here
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
private bool ParseGameInfo()
|
|
|
|
|
{
|
|
|
|
|
if(!NextTokenIs("{")) return false; // Finished with this file
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
while(SkipWhitespace(true))
|
|
|
|
|
{
|
|
|
|
|
string token = ReadToken();
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
ReportError("Failed to find the end of GameInfo block");
|
|
|
|
|
return false; // Finished with this file
|
|
|
|
|
}
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
if(token == "}") break;
|
|
|
|
|
|
|
|
|
|
if(token.ToLowerInvariant() == "skyflatname")
|
|
|
|
|
{
|
|
|
|
|
if(!NextTokenIs("=")) return false; // Finished with this file
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
string skyflatname = StripTokenQuotes(ReadToken());
|
|
|
|
|
if(string.IsNullOrEmpty(skyflatname))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
ReportError("Unable to get SkyFlatName value");
|
|
|
|
|
return false; // Finished with this file
|
|
|
|
|
}
|
2013-09-11 08:49:45 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
General.Map.Config.SkyFlatName = skyflatname.ToUpperInvariant();
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-11 08:49:45 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// All done here
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-09-11 08:49:45 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
private bool ParseDoomEdNums()
|
|
|
|
|
{
|
|
|
|
|
if(!NextTokenIs("{")) return false; // Finished with this file
|
|
|
|
|
|
|
|
|
|
while(SkipWhitespace(true))
|
|
|
|
|
{
|
|
|
|
|
string token = ReadToken();
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
ReportError("Failed to find the end of DoomEdNums block");
|
|
|
|
|
return false; // Finished with this file
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(token == "}") break;
|
|
|
|
|
|
|
|
|
|
// First must be a number
|
|
|
|
|
int id;
|
|
|
|
|
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out id))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
ReportError("Expected DoomEdNums entry number, but got '" + token + "'");
|
|
|
|
|
return false; // Finished with this file
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Then "="
|
|
|
|
|
if(!NextTokenIs("=")) return false; // Finished with this file
|
|
|
|
|
|
|
|
|
|
// Then actor class
|
|
|
|
|
SkipWhitespace(false);
|
|
|
|
|
string classname = StripTokenQuotes(ReadToken());
|
|
|
|
|
if(string.IsNullOrEmpty(classname))
|
|
|
|
|
{
|
|
|
|
|
ReportError("Unable to get DoomEdNums entry class definition");
|
|
|
|
|
return false; // Finished with this file
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Possible special and args. We'll skip them
|
|
|
|
|
for(int i = 0; i < 6; i++)
|
|
|
|
|
{
|
|
|
|
|
if(!NextTokenIs(",", false)) break;
|
|
|
|
|
|
|
|
|
|
// Read special name or arg value
|
|
|
|
|
if(!SkipWhitespace(true) || string.IsNullOrEmpty(ReadToken())) return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add to collection?
|
|
|
|
|
if(id != 0) doomednums[id] = classname.ToLowerInvariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// All done here
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool ParseSpawnNums()
|
|
|
|
|
{
|
|
|
|
|
if(!NextTokenIs("{")) return false; // Finished with this file
|
|
|
|
|
|
|
|
|
|
while(SkipWhitespace(true))
|
|
|
|
|
{
|
|
|
|
|
string token = ReadToken();
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
ReportError("Failed to find the end of SpawnNums block");
|
|
|
|
|
return false; // Finished with this file
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(token == "}") break;
|
|
|
|
|
|
|
|
|
|
// First must be a number
|
|
|
|
|
int id;
|
|
|
|
|
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out id))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
ReportError("Expected SpawnNums number, but got '" + token + "'");
|
|
|
|
|
return false; // Finished with this file
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Then "="
|
|
|
|
|
if(!NextTokenIs("=")) return false; // Finished with this file
|
|
|
|
|
|
|
|
|
|
// Then actor class
|
|
|
|
|
SkipWhitespace(false);
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
ReportError("Unable to get SpawnNums entry class definition");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add to collection
|
|
|
|
|
spawnnums[id] = token.ToLowerInvariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// All done here
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Map block parsing
|
|
|
|
|
|
|
|
|
|
private bool ParseMapBlock()
|
|
|
|
|
{
|
|
|
|
|
bool classicformat = !NextTokenIs("{", false);
|
|
|
|
|
|
|
|
|
|
// Track brace level
|
|
|
|
|
int bracelevel = 0;
|
2013-09-11 08:49:45 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Parse required values
|
|
|
|
|
while(SkipWhitespace(true))
|
|
|
|
|
{
|
|
|
|
|
string token = ReadToken().ToLowerInvariant();
|
|
|
|
|
switch(token)
|
|
|
|
|
{
|
|
|
|
|
//TODO: are there any other blocks available in the classic format?..
|
|
|
|
|
case "map": case "defaultmap": case "adddefaultmap":
|
|
|
|
|
if(classicformat)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// We parsed too greadily, step back
|
|
|
|
|
DataStream.Seek(-token.Length - 1, SeekOrigin.Current);
|
2013-09-11 08:49:45 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Finished with this block
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
ReportError("Unexpected token \"" + token + "\"");
|
2015-12-17 10:07:28 +00:00
|
|
|
|
return false;
|
2013-09-11 08:49:45 +00:00
|
|
|
|
}
|
2016-01-11 13:00:52 +00:00
|
|
|
|
|
|
|
|
|
case "sky2": case "sky1":
|
|
|
|
|
if(!ParseSky(token)) return false;
|
|
|
|
|
break;
|
2013-09-11 08:49:45 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
case "outsidefog": case "fade":
|
|
|
|
|
if(!ParseFade(token)) return false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "horizwallshade": case "vertwallshade":
|
|
|
|
|
if(!ParseWallShade(token)) return false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "outsidefogdensity": case "fogdensity":
|
|
|
|
|
if(!ParseFogDensity(token)) return false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "doublesky":
|
2015-04-14 11:33:57 +00:00
|
|
|
|
mapinfo.DoubleSky = true;
|
2016-01-11 13:00:52 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "evenlighting":
|
2015-04-14 11:33:57 +00:00
|
|
|
|
mapinfo.EvenLighting = true;
|
2016-01-11 13:00:52 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "smoothlighting":
|
2015-04-14 11:33:57 +00:00
|
|
|
|
mapinfo.SmoothLighting = true;
|
2016-01-11 13:00:52 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "}": return true; // Block end
|
|
|
|
|
|
|
|
|
|
case "{": // Skip inner blocks
|
2015-08-23 23:32:12 +00:00
|
|
|
|
bracelevel++;
|
|
|
|
|
if(bracelevel > 1)
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = ReadToken();
|
|
|
|
|
if(token == "{") bracelevel++;
|
|
|
|
|
else if(token == "}") bracelevel--;
|
|
|
|
|
} while(!string.IsNullOrEmpty(token) && bracelevel > 1);
|
|
|
|
|
}
|
2016-01-11 13:00:52 +00:00
|
|
|
|
break;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2015-12-21 14:17:47 +00:00
|
|
|
|
}
|
2016-01-11 13:00:52 +00:00
|
|
|
|
|
|
|
|
|
// All done here
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool ParseSky(string skytype)
|
|
|
|
|
{
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
string token = StripTokenQuotes(ReadToken());
|
|
|
|
|
|
|
|
|
|
// New format
|
|
|
|
|
if(token == "=")
|
2015-04-14 11:33:57 +00:00
|
|
|
|
{
|
|
|
|
|
SkipWhitespace(true);
|
2016-01-11 13:00:52 +00:00
|
|
|
|
|
|
|
|
|
// Should be sky texture name
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
|
|
|
|
bool gotcomma = (token.IndexOf(",", StringComparison.Ordinal) != -1);
|
|
|
|
|
if(gotcomma) token = token.Replace(",", "");
|
|
|
|
|
string skytexture = token.ToUpperInvariant();
|
|
|
|
|
|
|
|
|
|
if(string.IsNullOrEmpty(skytexture))
|
2015-04-14 11:33:57 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
ReportError("Expected " + skytype + " texture name");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-12-21 14:17:47 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
if(skytype == "sky1")
|
|
|
|
|
mapinfo.Sky1 = skytexture;
|
|
|
|
|
else
|
|
|
|
|
mapinfo.Sky2 = skytexture;
|
2015-12-21 14:17:47 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Check if we have scrollspeed
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
|
|
|
|
|
|
|
|
|
if(!gotcomma && token == ",")
|
|
|
|
|
{
|
|
|
|
|
gotcomma = true;
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
|
|
|
|
}
|
2015-12-21 14:17:47 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
if(gotcomma)
|
|
|
|
|
{
|
|
|
|
|
float scrollspeed = 0;
|
|
|
|
|
if(!ReadSignedFloat(token, ref scrollspeed))
|
2015-12-21 14:17:47 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Not numeric!
|
|
|
|
|
ReportError("Expected " + skytype + " scroll speed value, but got '" + token + "'");
|
2015-12-21 14:17:47 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
if(skytype == "sky1")
|
|
|
|
|
mapinfo.Sky1ScrollSpeed = scrollspeed;
|
|
|
|
|
else
|
|
|
|
|
mapinfo.Sky2ScrollSpeed = scrollspeed;
|
|
|
|
|
}
|
|
|
|
|
else
|
2015-04-14 11:33:57 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
datastream.Seek(-token.Length - 1, SeekOrigin.Current); // Step back and try parsing this token again
|
2015-04-14 11:33:57 +00:00
|
|
|
|
}
|
2015-05-23 21:40:21 +00:00
|
|
|
|
}
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Old format
|
|
|
|
|
else
|
2015-05-23 21:40:21 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Token should be sky1/2 name
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
2015-05-23 21:40:21 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
ReportError("Expected " + skytype + " texture name");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-05-23 21:40:21 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
if(skytype == "sky1")
|
|
|
|
|
mapinfo.Sky1 = token.ToUpperInvariant();
|
|
|
|
|
else
|
|
|
|
|
mapinfo.Sky2 = token.ToUpperInvariant();
|
2015-05-23 21:40:21 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Try to read scroll speed
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
|
|
|
|
|
|
|
|
|
float scrollspeed = 0;
|
|
|
|
|
if(!ReadSignedFloat(token, ref scrollspeed))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
datastream.Seek(-token.Length - 1, SeekOrigin.Current); // Step back and try parsing this token again
|
|
|
|
|
return true;
|
2015-05-23 21:40:21 +00:00
|
|
|
|
}
|
2016-01-11 13:00:52 +00:00
|
|
|
|
|
|
|
|
|
if(skytype == "sky1")
|
|
|
|
|
mapinfo.Sky1ScrollSpeed = scrollspeed;
|
|
|
|
|
else
|
|
|
|
|
mapinfo.Sky2ScrollSpeed = scrollspeed;
|
2015-05-23 21:40:21 +00:00
|
|
|
|
}
|
2016-01-11 13:00:52 +00:00
|
|
|
|
|
|
|
|
|
// All done here
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool ParseFade(string fadetype)
|
|
|
|
|
{
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
string token = StripTokenQuotes(ReadToken());
|
|
|
|
|
|
|
|
|
|
// New format?
|
|
|
|
|
if(token == "=")
|
2015-04-14 11:33:57 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Get the color value
|
|
|
|
|
string colorval = StripTokenQuotes(token).ToLowerInvariant().Replace(" ", "");
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
if(string.IsNullOrEmpty(colorval))
|
|
|
|
|
{
|
|
|
|
|
ReportError("Expected " + fadetype + " color value");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
Color4 color = new Color4();
|
|
|
|
|
|
|
|
|
|
// Try to get the color...
|
|
|
|
|
if(GetColor(colorval, ref color))
|
|
|
|
|
{
|
|
|
|
|
if(fadetype == "fade")
|
|
|
|
|
mapinfo.FadeColor = color;
|
|
|
|
|
else
|
|
|
|
|
mapinfo.OutsideFogColor = color;
|
|
|
|
|
}
|
|
|
|
|
else //...or not
|
|
|
|
|
{
|
|
|
|
|
ReportError("Failed to parse " + fadetype + " value from string '" + colorval + "'");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// All done here
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
private bool ParseWallShade(string shadetype)
|
|
|
|
|
{
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
string token = StripTokenQuotes(ReadToken());
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// New format
|
|
|
|
|
if(token == "=")
|
|
|
|
|
{
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
int val = 0;
|
|
|
|
|
if(!ReadSignedInt(token, ref val))
|
2015-04-14 11:33:57 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Not numeric!
|
|
|
|
|
ReportError("Expected " + shadetype + " value, but got '" + token + "'");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
if(shadetype == "vertwallshade")
|
|
|
|
|
mapinfo.VertWallShade = General.Clamp(val, -255, 255);
|
|
|
|
|
else
|
|
|
|
|
mapinfo.HorizWallShade = General.Clamp(val, -255, 255);
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// All done here
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
private bool ParseFogDensity(string densitytype)
|
|
|
|
|
{
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
string token = StripTokenQuotes(ReadToken());
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// New format
|
|
|
|
|
if(token == "=")
|
|
|
|
|
{
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
|
int val;
|
|
|
|
|
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
|
2015-04-14 11:33:57 +00:00
|
|
|
|
{
|
2016-01-11 13:00:52 +00:00
|
|
|
|
// Not numeric!
|
|
|
|
|
ReportError("Expected " + densitytype + " value, but got '" + token + "'");
|
|
|
|
|
return false;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
Fixed, Visual mode: in some cases ceiling glow effect was interfering with Transfer Brightness effect resulting in incorrectly lit sidedef geometry.
Fixed, Visual mode: UDMF sidedef brightness should be ignored when a wall section is affected by Transfer Brightness effect.
Fixed, Visual mode: any custom fog should be rendered regardless of sector brightness.
Fixed, Visual mode: "fogdensity" and "outsidefogdensity" MAPINFO values were processed incorrectly.
Fixed, Visual mode: in some cases Things were rendered twice during a render pass.
Fixed, Visual mode: floor glow effect should affect thing brightness only when applied to floor of the sector thing is in.
Fixed, TEXTURES parser: TEXTURES group was named incorrectly in the Textures Browser window when parsed from a WAD file.
Fixed, MAPINFO, GLDEFS, DECORATE parsers: "//$GZDB_SKIP" special comment was processed incorrectly.
Fixed, MAPINFO parser: "fogdensity" and "outsidefogdensity" properties are now initialized using GZDoom default value (255) instead of 0.
2016-01-25 13:42:53 +00:00
|
|
|
|
val = Math.Max(0, val);
|
|
|
|
|
if(densitytype == "fogdensity") mapinfo.FogDensity = val;
|
|
|
|
|
else mapinfo.OutsideFogDensity = val;
|
2016-01-11 13:00:52 +00:00
|
|
|
|
|
|
|
|
|
// All done here
|
|
|
|
|
return true;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-14 11:33:57 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private static bool GetColor(string name, ref Color4 color)
|
|
|
|
|
{
|
2015-12-17 10:07:28 +00:00
|
|
|
|
if(name == "black") return true;
|
2013-09-11 08:49:45 +00:00
|
|
|
|
|
|
|
|
|
//probably it's a hex color (like FFCC11)?
|
|
|
|
|
int ci;
|
2015-12-17 10:07:28 +00:00
|
|
|
|
if(int.TryParse(name, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ci))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2013-09-11 08:49:45 +00:00
|
|
|
|
color = new Color4(ci) {Alpha = 1.0f};
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2012-06-01 10:17:47 +00:00
|
|
|
|
|
2013-09-11 08:49:45 +00:00
|
|
|
|
//probably it's a color name?
|
2013-09-11 09:47:53 +00:00
|
|
|
|
Color c = Color.FromName(name); //should be similar to C++ color name detection, I suppose
|
2015-12-17 10:07:28 +00:00
|
|
|
|
if(c.IsKnownColor)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
color = new Color4(c);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-04-14 11:33:57 +00:00
|
|
|
|
|
2015-12-17 10:07:28 +00:00
|
|
|
|
protected override string GetLanguageType()
|
|
|
|
|
{
|
|
|
|
|
return "MAPINFO";
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-14 11:33:57 +00:00
|
|
|
|
#endregion
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2012-06-01 10:17:47 +00:00
|
|
|
|
}
|