2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Copyright ( c ) 2007 Pascal vd Heiden
/ *
* Copyright ( c ) 2007 Pascal vd Heiden , www . codeimp . com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* /
#endregion
#region = = = = = = = = = = = = = = = = = = Namespaces
using System ;
using System.Collections ;
using System.Collections.Generic ;
using System.IO ;
2016-04-29 13:42:52 +00:00
using System.Text.RegularExpressions ;
using CodeImp.DoomBuilder.Compilers ;
2016-05-12 13:56:25 +00:00
using CodeImp.DoomBuilder.Config ;
2016-11-24 11:55:11 +00:00
using CodeImp.DoomBuilder.Data.Scripting ;
2016-04-29 13:42:52 +00:00
using CodeImp.DoomBuilder.GZBuilder.Data ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.IO ;
using CodeImp.DoomBuilder.ZDoom ;
#endregion
namespace CodeImp.DoomBuilder.Data
{
internal sealed class WADReader : DataReader
{
#region = = = = = = = = = = = = = = = = = = Constants
2016-06-15 14:48:21 +00:00
//mxd. TEXTUREx flags
private const int TX_WORLDPANNING = 0x8000 ;
2016-06-26 22:42:24 +00:00
//mxd. Sprite recognition. Also http://regexr.com/ is a nice site ^.^
private static readonly Regex sprite6 = new Regex ( @"(\S{4}[A-Za-z\[\]\\]{1}[0-8]{1})" ) ;
private static readonly Regex sprite8 = new Regex ( @"(\S{4}[A-Za-z\[\]\\]{1}[0-8]{1}[A-Za-z\[\]\\]{1}[0-8]{1})" ) ;
2016-07-11 22:13:43 +00:00
//mxd. Voxel recognition.
private static readonly Regex voxel = new Regex ( @"^\S{4}(([A-Za-z][0-9]){0,2}|[A-Za-z]{0,1})$" ) ;
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Structures
private struct LumpRange
{
public int start ;
public int end ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Variables
// Source
private WAD file ;
private bool is_iwad ;
2016-04-29 13:42:52 +00:00
private bool strictpatches ;
2009-04-19 18:07:22 +00:00
// Lump ranges
2016-04-29 13:42:52 +00:00
private List < LumpRange > flatranges ;
private List < LumpRange > invertedflatranges ; //mxd
private List < LumpRange > patchranges ;
private List < LumpRange > spriteranges ;
private List < LumpRange > textureranges ;
private List < LumpRange > hiresranges ; //mxd
private List < LumpRange > colormapranges ;
private List < LumpRange > voxelranges ; //mxd
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Properties
public bool IsIWAD { get { return is_iwad ; } }
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 WAD WadFile { get { return file ; } } //mxd
2016-11-24 11:55:11 +00:00
internal PK3StructuredReader ParentResource ; //mxd
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Constructor / Disposer
// Constructor
2016-04-29 13:42:52 +00:00
public WADReader ( DataLocation dl , bool asreadonly ) : base ( dl , asreadonly )
2009-04-19 18:07:22 +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
General . WriteLogLine ( "Opening WAD resource \"" + location . location + "\"" ) ;
2009-04-19 18:07:22 +00:00
2010-10-03 16:54:38 +00:00
if ( ! File . Exists ( location . location ) )
throw new FileNotFoundException ( "Could not find the file \"" + location . location + "\"" , location . location ) ;
2016-04-29 13:42:52 +00:00
2009-04-19 18:07:22 +00:00
// Initialize
2016-11-24 11:55:11 +00:00
file = new WAD ( location . location , asreadonly ) ;
2009-04-19 18:07:22 +00:00
strictpatches = dl . option1 ;
2016-04-29 13:42:52 +00:00
Initialize ( ) ; //mxd
// We have no destructor
GC . SuppressFinalize ( this ) ;
}
2016-06-13 23:37:55 +00:00
//mxd. Constructor for temporary WAD files
2016-04-29 13:42:52 +00:00
internal WADReader ( DataLocation dl , bool asreadonly , bool create ) : base ( dl , asreadonly )
{
if ( ! create )
{
General . WriteLogLine ( "Opening WAD resource \"" + location . location + "\"" ) ;
if ( ! File . Exists ( location . location ) )
throw new FileNotFoundException ( "Could not find the file \"" + location . location + "\"" , location . location ) ;
}
// Initialize
file = new WAD ( location . location , asreadonly ) ;
strictpatches = dl . option1 ;
Initialize ( ) ;
// We have no destructor
GC . SuppressFinalize ( this ) ;
}
//mxd
private void Initialize ( )
{
is_iwad = file . IsIWAD ;
2016-11-24 11:55:11 +00:00
isreadonly | = is_iwad ; // Just in case...
2016-04-29 13:42:52 +00:00
// Initialize
2009-04-19 18:07:22 +00:00
patchranges = new List < LumpRange > ( ) ;
spriteranges = new List < LumpRange > ( ) ;
flatranges = new List < LumpRange > ( ) ;
textureranges = new List < LumpRange > ( ) ;
2016-03-04 08:10:56 +00:00
hiresranges = new List < LumpRange > ( ) ; //mxd
2009-05-12 09:50:08 +00:00
colormapranges = new List < LumpRange > ( ) ;
2014-01-08 09:46:57 +00:00
voxelranges = new List < LumpRange > ( ) ; //mxd
2009-04-19 18:07:22 +00:00
// Find ranges
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
FindRanges ( patchranges , General . Map . Config . PatchRanges , "patches" , "Patch" ) ;
FindRanges ( spriteranges , General . Map . Config . SpriteRanges , "sprites" , "Sprite" ) ;
FindRanges ( flatranges , General . Map . Config . FlatRanges , "flats" , "Flat" ) ;
FindRanges ( textureranges , General . Map . Config . TextureRanges , "textures" , "Texture" ) ;
2016-03-04 08:10:56 +00:00
FindRanges ( hiresranges , General . Map . Config . HiResRanges , "hires" , "HiRes texture" ) ;
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
FindRanges ( colormapranges , General . Map . Config . ColormapRanges , "colormaps" , "Colormap" ) ;
FindRanges ( voxelranges , General . Map . Config . VoxelRanges , "voxels" , "Voxel" ) ;
2009-04-19 18:07:22 +00:00
2013-12-02 15:02:01 +00:00
//mxd
invertedflatranges = new List < LumpRange > ( ) ;
2014-12-03 23:15:26 +00:00
if ( flatranges . Count > 0 )
{
2014-04-09 10:16:33 +00:00
//add range before the first flatrange
2015-12-28 15:01:53 +00:00
if ( flatranges [ 0 ] . start > 0 )
2014-12-03 23:15:26 +00:00
{
2014-04-03 12:57:02 +00:00
LumpRange range = new LumpRange { start = 0 , end = flatranges [ 0 ] . start - 1 } ;
invertedflatranges . Add ( range ) ;
}
2013-12-02 15:02:01 +00:00
2014-04-08 11:09:05 +00:00
//add ranges between flatranges
2014-12-03 23:15:26 +00:00
for ( int i = 1 ; i < flatranges . Count ; i + + )
{
2014-04-08 11:09:05 +00:00
LumpRange range = new LumpRange { start = flatranges [ i - 1 ] . end + 1 , end = flatranges [ i ] . start - 1 } ;
invertedflatranges . Add ( range ) ;
}
2014-04-09 10:16:33 +00:00
//add range after the last flatrange
2014-12-03 23:15:26 +00:00
if ( flatranges [ flatranges . Count - 1 ] . end < file . Lumps . Count - 1 )
{
2014-04-08 11:09:05 +00:00
LumpRange range = new LumpRange { start = flatranges [ flatranges . Count - 1 ] . end + 1 , end = file . Lumps . Count - 1 } ;
2013-12-02 15:02:01 +00:00
invertedflatranges . Add ( range ) ;
}
2014-12-03 23:15:26 +00:00
}
else // No flat ranges? Make one giant range then...
{
2014-04-08 11:09:05 +00:00
LumpRange range = new LumpRange { start = 0 , end = file . Lumps . Count - 1 } ;
invertedflatranges . Add ( range ) ;
2013-12-02 15:02:01 +00:00
}
2009-04-19 18:07:22 +00:00
}
// Disposer
public override void Dispose ( )
{
// Not already disposed?
if ( ! isdisposed )
{
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
General . WriteLogLine ( "Closing WAD resource \"" + location . location + "\"" ) ;
2009-04-19 18:07:22 +00:00
// Clean up
file . Dispose ( ) ;
// Done
base . Dispose ( ) ;
}
}
#endregion
#region = = = = = = = = = = = = = = = = = = Management
// Return a short name for this data location
public override string GetTitle ( )
{
return Path . GetFileName ( location . location ) ;
}
// This suspends use of this resource
public override void Suspend ( )
{
file . Dispose ( ) ;
base . Suspend ( ) ;
}
// This resumes use of this resource
public override void Resume ( )
{
file = new WAD ( location . location , true ) ;
2016-03-14 10:25:27 +00:00
is_iwad = file . IsIWAD ;
2009-04-19 18:07:22 +00:00
base . Resume ( ) ;
}
// This fills a ranges list
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
private void FindRanges ( List < LumpRange > ranges , IDictionary rangeinfos , string rangename , string elementname )
2009-04-19 18:07:22 +00:00
{
2014-10-31 13:53:43 +00:00
Dictionary < LumpRange , KeyValuePair < string , string > > failedranges = new Dictionary < LumpRange , KeyValuePair < string , string > > ( ) ; //mxd
Dictionary < int , bool > successfulrangestarts = new Dictionary < int , bool > ( ) ; //mxd
Dictionary < int , bool > failedrangestarts = new Dictionary < int , bool > ( ) ; //mxd
2009-04-19 18:07:22 +00:00
foreach ( DictionaryEntry r in rangeinfos )
{
// Read start and end
string rangestart = General . Map . Config . ReadSetting ( rangename + "." + r . Key + ".start" , "" ) ;
string rangeend = General . Map . Config . ReadSetting ( rangename + "." + r . Key + ".end" , "" ) ;
if ( ( rangestart . Length > 0 ) & & ( rangeend . Length > 0 ) )
{
// Find ranges
int startindex = file . FindLumpIndex ( rangestart ) ;
while ( startindex > - 1 )
{
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
LumpRange range = new LumpRange { start = startindex , end = file . FindLumpIndex ( rangeend , startindex ) } ;
2009-04-19 18:07:22 +00:00
if ( range . end > - 1 )
{
2014-10-31 13:53:43 +00:00
if ( ! successfulrangestarts . ContainsKey ( startindex ) ) successfulrangestarts . Add ( startindex , false ) ; //mxd
2009-04-19 18:07:22 +00:00
ranges . Add ( range ) ;
startindex = file . FindLumpIndex ( rangestart , range . end ) ;
}
else
{
2014-10-31 13:53:43 +00:00
//mxd
2015-12-28 15:01:53 +00:00
if ( ! failedrangestarts . ContainsKey ( startindex ) )
2014-10-31 13:53:43 +00:00
{
failedranges . Add ( range , new KeyValuePair < string , string > ( rangestart , rangeend ) ) ; //mxd
failedrangestarts . Add ( startindex , false ) ;
}
2009-04-19 18:07:22 +00:00
startindex = - 1 ;
}
}
}
}
2014-10-31 13:53:43 +00:00
2016-03-14 10:25:27 +00:00
// Don't check official IWADs
if ( ! file . IsOfficialIWAD )
2014-10-31 13:53:43 +00:00
{
2016-03-14 10:25:27 +00:00
//mxd. Display warnings for unclosed ranges
foreach ( KeyValuePair < LumpRange , KeyValuePair < string , string > > group in failedranges )
{
if ( successfulrangestarts . ContainsKey ( group . Key . start ) ) continue ;
2016-03-14 21:53:53 +00:00
General . ErrorLogger . Add ( ErrorType . Warning , "\"" + group . Value . Key + "\" range at index " + group . Key . start + " is not closed in resource \"" + location . GetDisplayName ( ) + "\" (\"" + group . Value . Value + "\" marker is missing)." ) ;
2016-03-14 10:25:27 +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
2016-03-14 10:25:27 +00:00
//mxd. Check duplicates
foreach ( LumpRange range in ranges )
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
{
2016-03-14 10:25:27 +00:00
HashSet < string > names = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
for ( int i = range . start + 1 ; i < range . end ; i + + )
{
if ( names . Contains ( file . Lumps [ i ] . Name ) )
2016-03-14 21:53:53 +00:00
General . ErrorLogger . Add ( ErrorType . Warning , elementname + " \"" + file . Lumps [ i ] . Name + "\", index " + i + " is double defined in resource \"" + location . GetDisplayName ( ) + "\"." ) ;
2016-03-14 10:25:27 +00:00
else
names . Add ( file . Lumps [ i ] . 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
}
2014-10-31 13:53:43 +00:00
}
2009-04-19 18:07:22 +00:00
}
#endregion
#region = = = = = = = = = = = = = = = = = = Palette
// This loads the PLAYPAL palette
public override Playpal LoadPalette ( )
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Look for a lump named PLAYPAL
2013-12-04 13:27:34 +00:00
Lump lump = file . FindLump ( "PLAYPAL" ) ;
if ( lump ! = null ) return new Playpal ( lump . Stream ) ; // Read the PLAYPAL from stream
return null ; // No palette
2009-04-19 18:07:22 +00:00
}
#endregion
2009-05-12 09:50:08 +00:00
#region = = = = = = = = = = = = = = = = = = Colormaps
// This loads the textures
public override ICollection < ImageData > LoadColormaps ( )
{
List < ImageData > images = new List < ImageData > ( ) ;
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Read ranges from configuration
foreach ( DictionaryEntry r in General . Map . Config . ColormapRanges )
{
// Read start and end
2015-12-28 15:01:53 +00:00
string rangestart = General . Map . Config . ReadSetting ( "colormaps." + r . Key + ".start" , "" ) ;
string rangeend = General . Map . Config . ReadSetting ( "colormaps." + r . Key + ".end" , "" ) ;
2009-05-12 09:50:08 +00:00
if ( ( rangestart . Length > 0 ) & & ( rangeend . Length > 0 ) )
{
// Load texture range
LoadColormapsRange ( rangestart , rangeend , ref images ) ;
}
}
// Add images to the container-specific texture set
2015-12-28 15:01:53 +00:00
foreach ( ImageData img in images ) textureset . AddFlat ( img ) ;
2009-05-12 09:50:08 +00:00
// Return result
return images ;
}
// This loads a range of colormaps
private void LoadColormapsRange ( string startlump , string endlump , ref List < ImageData > images )
{
// Continue until no more start can be found
2015-12-27 21:54:50 +00:00
int startindex = file . FindLumpIndex ( startlump ) ;
2009-05-12 09:50:08 +00:00
while ( startindex > - 1 )
{
// Find end index
2015-12-27 21:54:50 +00:00
int endindex = file . FindLumpIndex ( endlump , startindex + 1 ) ;
2009-05-12 09:50:08 +00:00
if ( endindex > - 1 )
{
// Go for all lumps between start and end exclusive
for ( int i = startindex + 1 ; i < endindex ; i + + )
{
// Lump not zero-length?
if ( file . Lumps [ i ] . Length > 0 )
{
// Make the image object
2015-12-27 21:54:50 +00:00
ColormapImage image = new ColormapImage ( file . Lumps [ i ] . Name ) ;
2009-05-12 09:50:08 +00:00
// Add image to collection
images . Add ( image ) ;
}
}
}
// Find the next start
startindex = file . FindLumpIndex ( startlump , startindex + 1 ) ;
}
}
// This finds and returns a colormap stream
public override Stream GetColormapData ( string pname )
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2009-05-13 20:54:45 +00:00
// Strictly read patches only between C_START and C_END?
if ( strictpatches )
2009-05-12 09:50:08 +00:00
{
2009-05-13 20:54:45 +00:00
// Find the lump in ranges
foreach ( LumpRange range in colormapranges )
{
2015-12-27 21:54:50 +00:00
Lump lump = file . FindLump ( pname , range . start , range . end ) ;
2009-05-13 20:54:45 +00:00
if ( lump ! = null ) return lump . Stream ;
}
}
else
{
// Find the lump anywhere
2015-12-27 21:54:50 +00:00
Lump lump = file . FindLump ( pname ) ;
2009-05-12 09:50:08 +00:00
if ( lump ! = null ) return lump . Stream ;
}
return null ;
}
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Textures
// This loads the textures
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
public override IEnumerable < ImageData > LoadTextures ( PatchNames pnames , Dictionary < string , TexturesParser > cachedparsers )
2009-04-19 18:07:22 +00:00
{
2014-01-08 09:46:57 +00:00
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2009-04-19 18:07:22 +00:00
List < ImageData > images = new List < ImageData > ( ) ;
2014-01-08 09:46:57 +00:00
float defaultscale = General . Map . Config . DefaultTextureScale ; //mxd
2009-04-19 18:07:22 +00:00
// Load two sets of textures, if available
2015-01-15 20:48:57 +00:00
Lump lump = file . FindLump ( "TEXTURE1" ) ;
if ( lump ! = null )
{
LoadTextureSet ( "TEXTURE1" , lump . Stream , ref images , pnames ) ;
if ( images . Count > 0 ) images . RemoveAt ( 0 ) ; //mxd. The first TEXTURE1 texture cannot be used. Let's remove it here
}
2009-04-19 18:07:22 +00:00
lump = file . FindLump ( "TEXTURE2" ) ;
if ( lump ! = null ) LoadTextureSet ( "TEXTURE2" , lump . Stream , ref images , pnames ) ;
// Read ranges from configuration
foreach ( LumpRange range in textureranges )
{
2014-01-08 09:46:57 +00:00
// Go for all lumps between start and end exclusive
2014-12-03 23:15:26 +00:00
for ( int i = range . start + 1 ; i < range . end ; i + + )
{
2014-01-08 09:46:57 +00:00
// Lump not zero length?
2014-12-03 23:15:26 +00:00
if ( file . Lumps [ i ] . Length > 0 )
{
2014-01-08 09:46:57 +00:00
// Make the image
SimpleTextureImage image = new SimpleTextureImage ( file . Lumps [ i ] . Name , file . Lumps [ i ] . Name , defaultscale , defaultscale ) ;
// Add image to collection
images . Add ( image ) ;
2014-12-03 23:15:26 +00:00
}
else
{
2014-01-08 09:46:57 +00:00
// Can't load image without size
2016-03-14 21:53:53 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Can't load texture \"" + file . Lumps [ i ] . Name + "\" from \"" + location . GetDisplayName ( ) + "\" because it doesn't contain any data." ) ;
2014-01-08 09:46:57 +00:00
}
}
2009-04-19 18:07:22 +00:00
}
2010-08-13 15:19:51 +00:00
2009-04-19 18:07:22 +00:00
// Load TEXTURES lump file
2015-01-15 20:48:57 +00:00
int lumpindex = file . FindLumpIndex ( "TEXTURES" ) ;
2010-08-13 15:19:51 +00:00
while ( lumpindex > - 1 )
2009-04-19 18:07:22 +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
//mxd. Added TexturesParser caching
string fullpath = Path . Combine ( this . location . location , "TEXTURES#" + lumpindex ) ;
if ( cachedparsers . ContainsKey ( fullpath ) )
{
// Make the textures
foreach ( TextureStructure t in cachedparsers [ fullpath ] . Textures )
images . Add ( t . MakeImage ( ) ) ;
}
else
{
MemoryStream filedata = new MemoryStream ( file . Lumps [ lumpindex ] . Stream . ReadAllBytes ( ) ) ;
2016-03-04 08:10:56 +00:00
cachedparsers . Add ( fullpath , LoadTEXTURESTextures ( new TextResourceData ( this , filedata , "TEXTURES" , lumpindex , true ) , ref images ) ) ; //mxd
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
filedata . Dispose ( ) ;
}
2010-08-13 15:19:51 +00:00
// Find next
lumpindex = file . FindLumpIndex ( "TEXTURES" , lumpindex + 1 ) ;
2009-04-19 18:07:22 +00:00
}
2010-08-13 15:19:51 +00:00
2009-04-19 18:07:22 +00:00
// Add images to the container-specific texture set
2015-01-15 20:48:57 +00:00
foreach ( ImageData img in images ) textureset . AddTexture ( img ) ;
2009-04-19 18:07:22 +00:00
// Return result
return images ;
}
2016-03-04 08:10:56 +00:00
//mxd. This loads the HiRes textures
public override IEnumerable < HiResImage > LoadHiResTextures ( )
{
List < HiResImage > images = new List < HiResImage > ( ) ;
// Read ranges from configuration
foreach ( LumpRange range in hiresranges )
{
// Go for all lumps between start and end exclusive
for ( int i = range . start + 1 ; i < range . end ; i + + )
{
// Lump not zero length?
if ( file . Lumps [ i ] . Length > 0 )
{
// Add image to collection
images . Add ( new HiResImage ( file . Lumps [ i ] . Name ) ) ;
}
else
{
// Can't load image without size
2016-03-14 21:53:53 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Can't load HiRes texture \"" + file . Lumps [ i ] . Name + "\" from \"" + location . GetDisplayName ( ) + "\" because it doesn't contain any data." ) ;
2016-03-04 08:10:56 +00:00
}
}
}
return images ;
}
2009-04-19 18:07:22 +00:00
// This loads the texture definitions from a TEXTURES lump
2016-03-04 08:10:56 +00:00
public static TexturesParser LoadTEXTURESTextures ( TextResourceData data , ref List < ImageData > images )
2009-04-19 18:07:22 +00:00
{
// Parse the data
TexturesParser parser = new TexturesParser ( ) ;
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
parser . Parse ( data , false ) ;
2015-12-17 10:07:28 +00:00
if ( parser . HasError ) parser . LogError ( ) ; //mxd
2009-04-19 18:07:22 +00:00
// Make the textures
foreach ( TextureStructure t in parser . Textures )
{
2015-12-17 10:07:28 +00:00
// Add the texture
2016-03-04 08:10:56 +00:00
images . Add ( t . MakeImage ( ) ) ;
2009-04-19 18:07:22 +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
//mxd. Add to text resources collection
2016-11-24 11:55:11 +00:00
if ( ! General . Map . Data . ScriptResources . ContainsKey ( parser . ScriptType ) )
General . Map . Data . ScriptResources [ parser . ScriptType ] = new HashSet < ScriptResource > ( ) ;
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
2016-11-24 11:55:11 +00:00
foreach ( KeyValuePair < string , ScriptResource > group in parser . ScriptResources )
General . Map . Data . ScriptResources [ parser . ScriptType ] . Add ( group . Value ) ;
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 parser ; //mxd
2009-04-19 18:07:22 +00:00
}
// This loads a set of textures
public static void LoadTextureSet ( string sourcename , Stream texturedata , ref List < ImageData > images , PatchNames pnames )
{
2013-12-03 10:50:33 +00:00
if ( texturedata . Length = = 0 ) return ;
2015-12-27 21:54:50 +00:00
BinaryReader reader = new BinaryReader ( texturedata ) ;
2010-08-14 15:44:47 +00:00
2009-04-19 18:07:22 +00:00
// Determine default scale
2015-12-27 21:54:50 +00:00
float defaultscale = General . Map . Config . DefaultTextureScale ;
2009-04-19 18:07:22 +00:00
// Get number of textures
texturedata . Seek ( 0 , SeekOrigin . Begin ) ;
2015-12-27 21:54:50 +00:00
uint numtextures = reader . ReadUInt32 ( ) ;
2009-04-19 18:07:22 +00:00
// Skip offset bytes (we will read all textures sequentially)
texturedata . Seek ( 4 * numtextures , SeekOrigin . Current ) ;
// Go for all textures defined in this lump
for ( uint i = 0 ; i < numtextures ; i + + )
{
// Read texture properties
2015-12-27 21:54:50 +00:00
byte [ ] namebytes = reader . ReadBytes ( 8 ) ;
int flags = reader . ReadUInt16 ( ) ;
2016-06-15 14:48:21 +00:00
bool worldpanning = ( flags & TX_WORLDPANNING ) ! = 0 ; //mxd
2015-12-27 21:54:50 +00:00
byte scalebytex = reader . ReadByte ( ) ;
byte scalebytey = reader . ReadByte ( ) ;
int width = reader . ReadInt16 ( ) ;
int height = reader . ReadInt16 ( ) ;
int patches = reader . ReadInt16 ( ) ;
2009-04-19 18:07:22 +00:00
// Check for doom or strife data format
2015-12-27 21:54:50 +00:00
bool strifedata ;
2009-04-19 18:07:22 +00:00
if ( patches = = 0 )
{
// Ignore 2 bytes and then read number of patches
texturedata . Seek ( 2 , SeekOrigin . Current ) ;
patches = reader . ReadInt16 ( ) ;
strifedata = false ;
}
else
{
// Texture data is in strife format
strifedata = true ;
}
// Determine actual scales
2015-12-27 21:54:50 +00:00
float scalex = ( scalebytex = = 0 ? defaultscale : 1f / ( scalebytex / 8f ) ) ;
float scaley = ( scalebytey = = 0 ? defaultscale : 1f / ( scalebytey / 8f ) ) ;
2009-04-19 18:07:22 +00:00
// Validate data
2015-12-27 21:54:50 +00:00
if ( ( width > 0 ) & & ( height > 0 ) & & ( patches > 0 ) & & ( scalex ! = 0 ) | | ( scaley ! = 0 ) )
2009-04-19 18:07:22 +00:00
{
string texname = Lump . MakeNormalName ( namebytes , WAD . ENCODING ) ;
2015-12-27 21:54:50 +00:00
TextureImage image = null ;
2009-04-19 18:07:22 +00:00
if ( texname . Length > 0 )
{
// Make the image object
2015-03-22 20:43:05 +00:00
image = new TextureImage ( sourcename , Lump . MakeNormalName ( namebytes , WAD . ENCODING ) ,
2016-06-15 14:48:21 +00:00
width , height , scalex , scaley , worldpanning ) ;
2009-04-19 18:07:22 +00:00
}
else
{
// Can't load image without name
2009-05-10 16:02:08 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Can't load an unnamed texture from \"" + sourcename + "\". Please consider giving names to your resources." ) ;
2009-04-19 18:07:22 +00:00
}
// Go for all patches in texture
for ( int p = 0 ; p < patches ; p + + )
{
// Read patch properties
2015-12-27 21:54:50 +00:00
int px = reader . ReadInt16 ( ) ;
int py = reader . ReadInt16 ( ) ;
int pi = reader . ReadUInt16 ( ) ;
2009-04-19 18:07:22 +00:00
if ( ! strifedata ) texturedata . Seek ( 4 , SeekOrigin . Current ) ;
// Validate data
if ( ( pi > = 0 ) & & ( pi < pnames . Length ) )
{
if ( pnames [ pi ] . Length > 0 )
{
// Create patch on image
if ( image ! = null ) image . AddPatch ( new TexturePatch ( pnames [ pi ] , px , py ) ) ;
}
else
{
// Can't load image without name
2009-05-10 16:02:08 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Can't use an unnamed patch referenced in \"" + sourcename + "\". Please consider giving names to your resources." ) ;
2009-04-19 18:07:22 +00:00
}
}
}
// Add image to collection
2015-12-29 18:22:08 +00:00
if ( image ! = null ) images . Add ( image ) ;
2009-04-19 18:07:22 +00:00
}
else
{
// Skip patches data
texturedata . Seek ( 6 * patches , SeekOrigin . Current ) ;
if ( ! strifedata ) texturedata . Seek ( 4 * patches , SeekOrigin . Current ) ;
}
}
}
// This returns the patch names from the PNAMES lump
public override PatchNames LoadPatchNames ( )
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Look for a lump named PNAMES
2013-12-04 13:27:34 +00:00
Lump lump = file . FindLump ( "PNAMES" ) ;
if ( lump ! = null ) return new PatchNames ( lump . Stream ) ; // Read the PNAMES from stream
return null ; // No patch names found
2009-04-19 18:07:22 +00:00
}
// This finds and returns a patch stream
2016-03-14 21:53:53 +00:00
public override Stream GetPatchData ( string pname , bool longname , ref string patchlocation )
2009-04-19 18:07:22 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2014-11-25 11:52:01 +00:00
if ( longname ) return null ; //mxd
Lump lump ;
2009-04-19 18:07:22 +00:00
2013-12-02 15:02:01 +00:00
// mxd. First strictly read patches between P_START and P_END
2014-11-25 11:52:01 +00:00
foreach ( LumpRange range in patchranges )
{
2013-12-02 15:02:01 +00:00
lump = file . FindLump ( pname , range . start , range . end ) ;
if ( lump ! = null ) return lump . Stream ;
}
2015-12-28 15:01:53 +00:00
if ( ! strictpatches )
2014-11-25 11:52:01 +00:00
{
2013-12-02 15:02:01 +00:00
//mxd. Find the lump anywhere EXCEPT flat ranges (the way it's done in ZDoom)
2015-12-28 15:01:53 +00:00
foreach ( LumpRange range in invertedflatranges )
2014-11-25 11:52:01 +00:00
{
2009-04-19 18:07:22 +00:00
lump = file . FindLump ( pname , range . start , range . end ) ;
2016-03-14 21:53:53 +00:00
if ( lump ! = null )
{
patchlocation = location . GetDisplayName ( ) ;
return lump . Stream ;
}
2009-04-19 18:07:22 +00:00
}
2013-12-02 15:02:01 +00:00
// Find the lump anywhere IN flat ranges
2015-12-28 15:01:53 +00:00
foreach ( LumpRange range in flatranges )
2014-11-25 11:52:01 +00:00
{
2013-12-02 15:02:01 +00:00
lump = file . FindLump ( pname , range . start , range . end ) ;
2016-03-14 21:53:53 +00:00
if ( lump ! = null )
{
patchlocation = location . GetDisplayName ( ) ;
return lump . Stream ;
}
2013-09-11 09:47:53 +00:00
}
2009-04-19 18:07:22 +00:00
}
return null ;
}
// This finds and returns a texture stream
2016-03-14 21:53:53 +00:00
public override Stream GetTextureData ( string pname , bool longname , ref string texturelocation )
2009-04-19 18:07:22 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2014-11-25 11:52:01 +00:00
if ( longname ) return null ; //mxd
2009-04-19 18:07:22 +00:00
// Find the lump in ranges
foreach ( LumpRange range in textureranges )
{
2015-12-28 15:01:53 +00:00
Lump lump = file . FindLump ( pname , range . start , range . end ) ;
2016-03-14 21:53:53 +00:00
if ( lump ! = null )
{
texturelocation = location . GetDisplayName ( ) ; //mxd
return lump . Stream ;
}
2009-04-19 18:07:22 +00:00
}
return null ;
}
2009-05-12 09:50:08 +00:00
2016-03-04 08:10:56 +00:00
//mxd. This finds and returns a HiRes texture stream
2016-03-14 21:53:53 +00:00
public override Stream GetHiResTextureData ( string name , ref string hireslocation )
2016-03-04 08:10:56 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Find the lump in ranges
foreach ( LumpRange range in hiresranges )
{
Lump lump = file . FindLump ( name , range . start , range . end ) ;
2016-03-14 21:53:53 +00:00
if ( lump ! = null )
{
hireslocation = location . GetDisplayName ( ) ;
return lump . Stream ;
}
2016-03-04 08:10:56 +00:00
}
return null ;
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Flats
2014-01-08 09:46:57 +00:00
//mxd. This loads the flats
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
public override IEnumerable < ImageData > LoadFlats ( Dictionary < string , TexturesParser > cachedparsers )
2014-11-25 11:52:01 +00:00
{
2009-04-19 18:07:22 +00:00
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2014-01-08 09:46:57 +00:00
List < ImageData > images = new List < ImageData > ( ) ;
2014-11-25 11:52:01 +00:00
foreach ( LumpRange range in flatranges )
{
2014-01-08 09:46:57 +00:00
if ( range . end < range . start + 2 ) continue ;
2014-11-25 11:52:01 +00:00
for ( int i = range . start + 1 ; i < range . end ; i + + )
{
2014-01-08 09:46:57 +00:00
// Lump not zero-length?
2015-12-28 15:01:53 +00:00
if ( file . Lumps [ i ] . Length > 0 )
2014-11-25 11:52:01 +00:00
{
2014-01-08 09:46:57 +00:00
// Make the image object
2015-12-28 15:01:53 +00:00
FlatImage image = new FlatImage ( file . Lumps [ i ] . Name ) ;
2014-01-08 09:46:57 +00:00
// Add image to collection
images . Add ( image ) ;
}
2009-04-19 18:07:22 +00:00
}
}
2010-08-18 05:49:15 +00:00
// Load TEXTURES lump file
2014-01-08 09:46:57 +00:00
int lumpindex = file . FindLumpIndex ( "TEXTURES" ) ;
2014-11-25 11:52:01 +00:00
while ( lumpindex > - 1 )
{
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
//mxd. Added TexturesParser caching
string fullpath = Path . Combine ( this . location . location , "TEXTURES#" + lumpindex ) ;
if ( cachedparsers . ContainsKey ( fullpath ) )
{
// Make the textures
foreach ( TextureStructure t in cachedparsers [ fullpath ] . Flats )
images . Add ( t . MakeImage ( ) ) ;
}
else
{
MemoryStream filedata = new MemoryStream ( file . Lumps [ lumpindex ] . Stream . ReadAllBytes ( ) ) ;
2016-03-04 08:10:56 +00:00
cachedparsers . Add ( fullpath , LoadTEXTURESFlats ( new TextResourceData ( this , filedata , "TEXTURES" , lumpindex , true ) , ref images ) ) ; //mxd
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
filedata . Dispose ( ) ;
}
2010-08-18 05:49:15 +00:00
// Find next
lumpindex = file . FindLumpIndex ( "TEXTURES" , lumpindex + 1 ) ;
}
2014-01-08 09:46:57 +00:00
2009-04-19 18:07:22 +00:00
// Add images to the container-specific texture set
2014-01-08 09:46:57 +00:00
foreach ( ImageData img in images ) textureset . AddFlat ( img ) ;
2009-04-19 18:07:22 +00:00
// Return result
return images ;
}
2010-08-18 05:49:15 +00:00
// This loads the flat definitions from a TEXTURES lump
2016-03-04 08:10:56 +00:00
public static TexturesParser LoadTEXTURESFlats ( TextResourceData data , ref List < ImageData > images )
2010-08-18 05:49:15 +00:00
{
// Parse the data
TexturesParser parser = new TexturesParser ( ) ;
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
parser . Parse ( data , false ) ;
2015-12-17 10:07:28 +00:00
if ( parser . HasError ) parser . LogError ( ) ; //mxd
2010-08-18 05:49:15 +00:00
2016-03-04 08:10:56 +00:00
// Make the flat
2010-08-18 05:49:15 +00:00
foreach ( TextureStructure t in parser . Flats )
{
2016-03-04 08:10:56 +00:00
// Add the flat
images . Add ( t . MakeImage ( ) ) ;
2010-08-18 05:49:15 +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
//mxd. Add to text resources collection
2016-11-24 11:55:11 +00:00
if ( ! General . Map . Data . ScriptResources . ContainsKey ( parser . ScriptType ) )
General . Map . Data . ScriptResources [ parser . ScriptType ] = new HashSet < ScriptResource > ( ) ;
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
2016-11-24 11:55:11 +00:00
foreach ( KeyValuePair < string , ScriptResource > group in parser . ScriptResources )
General . Map . Data . ScriptResources [ parser . ScriptType ] . Add ( group . Value ) ;
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 parser ; //mxd
2010-08-18 05:49:15 +00:00
}
2009-04-19 18:07:22 +00:00
// This finds and returns a patch stream
2016-03-14 21:53:53 +00:00
public override Stream GetFlatData ( string pname , bool longname , ref string flatlocation )
2009-04-19 18:07:22 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2014-11-25 11:52:01 +00:00
if ( longname ) return null ; //mxd
2014-01-08 09:46:57 +00:00
2009-04-19 18:07:22 +00:00
// Find the lump in ranges
foreach ( LumpRange range in flatranges )
{
2015-12-28 15:01:53 +00:00
Lump lump = file . FindLump ( pname , range . start , range . end ) ;
2016-03-14 21:53:53 +00:00
if ( lump ! = null )
{
flatlocation = location . GetDisplayName ( ) ; //mxd
return lump . Stream ;
}
2009-04-19 18:07:22 +00:00
}
return null ;
}
#endregion
2016-06-26 22:42:24 +00:00
#region = = = = = = = = = = = = = = = = = = Sprites
2009-04-19 18:07:22 +00:00
2010-08-18 09:07:54 +00:00
// This loads the textures
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
public override IEnumerable < ImageData > LoadSprites ( Dictionary < string , TexturesParser > cachedparsers )
2010-08-18 09:07:54 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2014-01-08 09:46:57 +00:00
List < ImageData > images = new List < ImageData > ( ) ;
2010-08-18 09:07:54 +00:00
// Load TEXTURES lump file
2014-01-08 09:46:57 +00:00
int lumpindex = file . FindLumpIndex ( "TEXTURES" ) ;
2010-08-18 09:07:54 +00:00
while ( lumpindex > - 1 )
{
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
//mxd. Added TexturesParser caching
string fullpath = Path . Combine ( this . location . location , "TEXTURES#" + lumpindex ) ;
if ( cachedparsers . ContainsKey ( fullpath ) )
{
// Make the textures
foreach ( TextureStructure t in cachedparsers [ fullpath ] . Sprites )
images . Add ( t . MakeImage ( ) ) ;
}
else
{
MemoryStream filedata = new MemoryStream ( file . Lumps [ lumpindex ] . Stream . ReadAllBytes ( ) ) ;
2016-03-04 08:10:56 +00:00
cachedparsers . Add ( fullpath , LoadTEXTURESSprites ( new TextResourceData ( this , filedata , "TEXTURES" , lumpindex , true ) , ref images ) ) ; //mxd
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
filedata . Dispose ( ) ;
}
2010-08-18 09:07:54 +00:00
// Find next
lumpindex = file . FindLumpIndex ( "TEXTURES" , lumpindex + 1 ) ;
}
// Return result
return images ;
}
// This loads the sprites definitions from a TEXTURES lump
2016-03-04 08:10:56 +00:00
public static TexturesParser LoadTEXTURESSprites ( TextResourceData data , ref List < ImageData > images )
2010-08-18 09:07:54 +00:00
{
// Parse the data
TexturesParser parser = new TexturesParser ( ) ;
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
parser . Parse ( data , false ) ;
2015-12-17 10:07:28 +00:00
if ( parser . HasError ) parser . LogError ( ) ; //mxd
2010-08-18 09:07:54 +00:00
2016-03-04 08:10:56 +00:00
// Make the sprites
2010-08-18 09:07:54 +00:00
foreach ( TextureStructure t in parser . Sprites )
{
2015-12-17 10:07:28 +00:00
// Add the sprite
2016-03-04 08:10:56 +00:00
images . Add ( t . MakeImage ( ) ) ;
2010-08-18 09:07:54 +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
//mxd. Add to text resources collection
2016-11-24 11:55:11 +00:00
if ( ! General . Map . Data . ScriptResources . ContainsKey ( parser . ScriptType ) )
General . Map . Data . ScriptResources [ parser . ScriptType ] = new HashSet < ScriptResource > ( ) ;
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
2016-11-24 11:55:11 +00:00
foreach ( KeyValuePair < string , ScriptResource > group in parser . ScriptResources )
General . Map . Data . ScriptResources [ parser . ScriptType ] . Add ( group . Value ) ;
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 parser ; //mxd
2010-08-18 09:07:54 +00:00
}
2009-04-19 18:07:22 +00:00
// This finds and returns a sprite stream
2016-03-14 21:53:53 +00:00
public override Stream GetSpriteData ( string pname , ref string spritelocation )
2009-04-19 18:07:22 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Find the lump in ranges
foreach ( LumpRange range in spriteranges )
{
2015-12-28 15:01:53 +00:00
Lump lump = file . FindLump ( pname , range . start , range . end ) ;
2016-03-14 21:53:53 +00:00
if ( lump ! = null )
{
spritelocation = location . GetDisplayName ( ) ; //mxd
return lump . Stream ;
}
2009-04-19 18:07:22 +00:00
}
return null ;
}
// This checks if the given sprite exists
public override bool GetSpriteExists ( string pname )
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Find the lump in ranges
foreach ( LumpRange range in spriteranges )
{
2015-12-28 15:01:53 +00:00
Lump lump = file . FindLump ( pname , range . start , range . end ) ;
2009-04-19 18:07:22 +00:00
if ( lump ! = null ) return true ;
}
return false ;
}
2016-04-08 14:02:08 +00:00
2016-07-11 22:13:43 +00:00
//mxd. This returns all sprite names in the WAD
public override HashSet < string > GetSpriteNames ( )
2016-04-08 14:02:08 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
HashSet < string > result = new HashSet < string > ( ) ;
foreach ( LumpRange range in spriteranges )
{
for ( int i = range . start ; i < range . end + 1 ; i + + )
2016-07-11 22:13:43 +00:00
if ( IsValidSpriteName ( file . Lumps [ i ] . Name ) ) result . Add ( file . Lumps [ i ] . Name ) ;
2016-04-08 14:02:08 +00:00
}
return result ;
}
2016-06-26 22:42:24 +00:00
//mxd
internal static bool IsValidSpriteName ( string name )
{
return ( name . Length = = 6 & & sprite6 . IsMatch ( name ) ) | | ( name . Length = = 8 & & sprite8 . IsMatch ( name ) ) ;
}
2009-04-19 18:07:22 +00:00
#endregion
2014-01-08 09:46:57 +00:00
#region = = = = = = = = = = = = = = = = = = Voxels ( mxd )
//mxd. This returns the list of voxels, which can be used without VOXELDEF definition
2016-07-11 22:13:43 +00:00
public override HashSet < string > GetVoxelNames ( )
2014-12-03 23:15:26 +00:00
{
2014-01-08 09:46:57 +00:00
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2016-07-11 22:13:43 +00:00
HashSet < string > result = new HashSet < string > ( ) ;
2014-12-03 23:15:26 +00:00
foreach ( LumpRange range in voxelranges )
{
2014-01-08 09:46:57 +00:00
if ( range . start = = range . end ) continue ;
2014-12-03 23:15:26 +00:00
for ( int i = range . start + 1 ; i < range . end ; i + + )
{
2016-07-11 22:13:43 +00:00
if ( IsValidVoxelName ( file . Lumps [ i ] . Name ) ) result . Add ( file . Lumps [ i ] . Name ) ;
2014-01-08 09:46:57 +00:00
}
}
2016-07-11 22:13:43 +00:00
return result ;
2014-01-08 09:46:57 +00:00
}
//mxd
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
public override IEnumerable < TextResourceData > GetVoxeldefData ( )
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
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2016-04-23 23:15:43 +00:00
return GetAllLumps ( "VOXELDEF" ) ;
2014-01-08 09:46:57 +00:00
}
//mxd. This finds and returns a voxel stream or null if no voxel was found
2016-07-11 22:13:43 +00:00
public override Stream GetVoxelData ( string name , ref string voxellocation )
2014-12-03 23:15:26 +00:00
{
2014-01-08 09:46:57 +00:00
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2014-12-03 23:15:26 +00:00
foreach ( LumpRange range in voxelranges )
{
2014-01-08 09:46:57 +00:00
if ( range . start = = range . end ) continue ;
2015-12-28 15:01:53 +00:00
Lump lump = file . FindLump ( name , range . start , range . end ) ;
2016-07-11 22:13:43 +00:00
if ( lump ! = null )
{
voxellocation = location . GetDisplayName ( ) ;
2016-07-17 21:38:29 +00:00
// Copy stream, because model/voxel streams are expected to be disposed
lump . Stream . Seek ( 0 , SeekOrigin . Begin ) ; // Rewind before use
return new MemoryStream ( lump . Stream . ReadAllBytes ( ) ) ;
2016-07-11 22:13:43 +00:00
}
2014-01-08 09:46:57 +00:00
}
return null ;
}
2016-07-11 22:13:43 +00:00
//mxd
internal static bool IsValidVoxelName ( string name )
{
return ( name . Length > 3 & & name . Length < 7 ) & & voxel . IsMatch ( name ) ;
}
2014-01-08 09:46:57 +00:00
#endregion
2012-07-23 21:28:23 +00:00
#region = = = = = = = = = = = = = = = = = = Decorate , Gldefs , Mapinfo , etc . . .
2009-04-19 18:07:22 +00:00
2016-02-26 23:35:32 +00:00
// This finds and returns DECORATE streams
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
public override IEnumerable < TextResourceData > GetDecorateData ( string pname )
2009-04-19 18:07:22 +00:00
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2016-02-26 23:35:32 +00:00
List < TextResourceData > result = GetAllLumps ( pname ) ; //mxd
//mxd. Return ALL DECORATE lumps
if ( result . Count = = 0 | | string . Compare ( pname , "DECORATE" , StringComparison . OrdinalIgnoreCase ) = = 0 )
return result ;
//mxd. Return THE LAST include lump, because that's the way ZDoom seems to operate
return new List < TextResourceData > { result [ result . Count - 1 ] } ;
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
}
2014-02-26 14:11:06 +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
//mxd. Should be only one entry per wad
public override IEnumerable < TextResourceData > GetMapinfoData ( )
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2010-08-12 10:03:29 +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
// First look for ZMAPINFO
List < TextResourceData > result = new List < TextResourceData > ( ) ;
2016-11-24 21:09:24 +00:00
result . AddRange ( GetLastLump ( "ZMAPINFO" ) ) ;
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
// Then for MAPINFO
2016-11-24 21:09:24 +00:00
if ( result . Count = = 0 ) result . AddRange ( GetLastLump ( "MAPINFO" ) ) ;
2014-10-23 12:48:31 +00:00
return result ;
2009-04-19 18:07:22 +00:00
}
2012-06-01 10:17:47 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2016-07-14 23:39:48 +00:00
public override IEnumerable < TextResourceData > GetGldefsData ( string basegame )
2014-12-03 23:15:26 +00:00
{
2015-12-28 15:01:53 +00:00
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2012-06-01 10:17:47 +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
List < TextResourceData > result = new List < TextResourceData > ( ) ;
2012-06-01 10:17:47 +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
// Try to load game specific GLDEFS first
2016-07-14 23:39:48 +00:00
if ( basegame ! = GameType . UNKNOWN )
2014-12-03 23:15:26 +00:00
{
2016-07-14 23:39:48 +00:00
string lumpname = GameType . GldefsLumpsPerGame [ basegame ] ;
2016-04-23 23:15:43 +00:00
result . AddRange ( GetAllLumps ( lumpname ) ) ;
2013-09-11 09:47:53 +00:00
}
2012-06-01 10:17:47 +00:00
2016-04-23 23:15:43 +00:00
// Can be many entries per wad
result . AddRange ( GetAllLumps ( "GLDEFS" ) ) ;
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 result ;
2013-09-11 09:47:53 +00:00
}
2012-06-01 10:17:47 +00:00
2013-09-11 09:47:53 +00:00
//mxd
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
public override IEnumerable < TextResourceData > GetModeldefData ( )
2014-12-03 23:15:26 +00:00
{
2015-12-28 15:01:53 +00:00
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2016-04-23 23:15:43 +00:00
return GetAllLumps ( "MODELDEF" ) ;
2013-09-11 09:47:53 +00:00
}
2012-06-01 10:17:47 +00:00
2013-09-11 09:47:53 +00:00
//mxd
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
public override IEnumerable < TextResourceData > GetReverbsData ( )
2014-12-03 23:15:26 +00:00
{
2015-04-14 11:33:57 +00:00
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2016-04-23 23:15:43 +00:00
return GetAllLumps ( "REVERBS" ) ;
2013-09-11 09:47:53 +00:00
}
2013-03-18 13:52:27 +00:00
2016-05-24 22:11:29 +00:00
//mxd
public override IEnumerable < TextResourceData > GetSndInfoData ( )
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
return GetAllLumps ( "SNDINFO" ) ;
}
2015-01-25 23:22:42 +00:00
//mxd
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
public override IEnumerable < TextResourceData > GetSndSeqData ( )
2015-01-25 23:22:42 +00:00
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2016-04-23 23:15:43 +00:00
return GetAllLumps ( "SNDSEQ" ) ;
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
}
2015-01-25 23:22:42 +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
//mxd
public override IEnumerable < TextResourceData > GetAnimdefsData ( )
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
return GetAllLumps ( "ANIMDEFS" ) ;
2015-01-25 23:22:42 +00:00
}
2015-05-28 13:45:01 +00:00
//mxd
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
public override IEnumerable < TextResourceData > GetTerrainData ( )
2015-05-28 13:45:01 +00:00
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
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 GetAllLumps ( "TERRAIN" ) ;
}
2016-03-16 23:26:53 +00:00
//mxd
public override IEnumerable < TextResourceData > GetX11R6RGBData ( )
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
return GetAllLumps ( "X11R6RGB" ) ;
}
2016-04-13 14:11:35 +00:00
//mxd
public override IEnumerable < TextResourceData > GetCvarInfoData ( )
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
return GetAllLumps ( "CVARINFO" ) ;
}
2016-07-14 23:39:48 +00:00
//mxd
public override IEnumerable < TextResourceData > GetLockDefsData ( )
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
return GetAllLumps ( "LOCKDEFS" ) ;
}
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
//mxd
2016-11-24 21:09:24 +00:00
public override IEnumerable < TextResourceData > GetMenuDefData ( )
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
return GetLastLump ( "MENUDEF" ) ;
}
//mxd
public override IEnumerable < TextResourceData > GetSBarInfoData ( )
{
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
return GetLastLump ( "SBARINFO" ) ;
}
//mxd
private IEnumerable < TextResourceData > GetLastLump ( string 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
{
List < TextResourceData > result = new List < TextResourceData > ( ) ;
int lumpindex = file . FindLumpIndex ( name ) ;
if ( lumpindex ! = - 1 )
result . Add ( new TextResourceData ( this , file . Lumps [ lumpindex ] . Stream , name , lumpindex , true ) ) ;
2015-05-28 13:45:01 +00:00
2015-12-18 10:16:53 +00:00
return result ;
}
//mxd
2016-02-26 23:35:32 +00:00
private List < TextResourceData > GetAllLumps ( string name )
2015-12-18 10:16:53 +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
List < TextResourceData > result = new List < TextResourceData > ( ) ;
// Find all lumps with given name
int lumpindex = file . FindLumpIndex ( name ) ;
while ( lumpindex > - 1 )
{
// Add to collection
result . Add ( new TextResourceData ( this , file . Lumps [ lumpindex ] . Stream , name , lumpindex , true ) ) ;
// Find next entry
lumpindex = file . FindLumpIndex ( name , lumpindex + 1 ) ;
}
2015-12-18 10:16:53 +00:00
2015-05-28 13:45:01 +00:00
return result ;
}
2016-04-29 13:42:52 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = IO ( mxd )
2014-12-03 23:15:26 +00:00
internal override MemoryStream LoadFile ( string name )
{
2013-09-11 09:47:53 +00:00
Lump l = file . FindLump ( name ) ;
2013-03-18 13:52:27 +00:00
2015-12-28 15:01:53 +00:00
if ( l ! = null )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
l . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
return new MemoryStream ( l . Stream . ReadAllBytes ( ) ) ;
}
2013-03-18 13:52:27 +00:00
2013-09-11 09:47:53 +00:00
return null ;
}
2012-07-23 21:28:23 +00:00
2016-04-29 13:42:52 +00:00
internal override MemoryStream LoadFile ( string name , int lumpindex )
{
2016-11-24 11:55:11 +00:00
if ( lumpindex < 0 | | file . Lumps . Count < = lumpindex | | file . Lumps [ lumpindex ] . Name ! = name . ToUpperInvariant ( ) )
2016-04-29 13:42:52 +00:00
return null ;
Lump l = file . Lumps [ lumpindex ] ;
l . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
return new MemoryStream ( l . Stream . ReadAllBytes ( ) ) ;
}
internal override bool SaveFile ( MemoryStream lumpdata , string lumpname )
{
if ( isreadonly ) return false ;
int insertindex = file . Lumps . Count ;
// Remove the lump if it already exists
int li = file . FindLumpIndex ( lumpname ) ;
if ( li > - 1 )
{
insertindex = li ;
file . RemoveAt ( li ) ;
}
// Insert new lump
Lump l = file . Insert ( lumpname , insertindex , ( int ) lumpdata . Length ) ;
l . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
lumpdata . WriteTo ( l . Stream ) ;
2016-11-24 11:55:11 +00:00
// Update WAD file
file . WriteHeaders ( ) ;
2016-04-29 13:42:52 +00:00
return true ;
}
internal override bool SaveFile ( MemoryStream lumpdata , string lumpname , int lumpindex )
{
2016-11-24 11:55:11 +00:00
if ( isreadonly | | lumpindex < 0 | | file . Lumps . Count < = lumpindex | | file . Lumps [ lumpindex ] . Name ! = lumpname . ToUpperInvariant ( ) )
2016-04-29 13:42:52 +00:00
return false ;
// Remove the lump
file . RemoveAt ( lumpindex ) ;
// Insert new lump
Lump l = file . Insert ( lumpname , lumpindex , ( int ) lumpdata . Length ) ;
l . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
lumpdata . WriteTo ( l . Stream ) ;
2016-11-24 11:55:11 +00:00
// Update WAD file
file . WriteHeaders ( ) ;
2016-04-29 13:42:52 +00:00
return true ;
}
internal override bool FileExists ( string lumpname )
{
return file . FindLumpIndex ( lumpname ) ! = - 1 ;
}
internal override bool FileExists ( string lumpname , int lumpindex )
{
return file . FindLumpIndex ( lumpname ) = = lumpindex ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Compiling ( mxd )
// This compiles a script lump and returns any errors that may have occurred
// Returns true when our code worked properly (even when the compiler returned errors)
2016-05-12 13:56:25 +00:00
internal override bool CompileLump ( string lumpname , ScriptConfiguration scriptconfig , List < CompilerError > errors )
2016-04-29 13:42:52 +00:00
{
int index = file . FindLumpIndex ( lumpname ) ;
if ( index = = - 1 )
{
2016-05-12 13:56:25 +00:00
errors . Add ( new CompilerError { description = "Lump \"" + lumpname + "\" does not exist" , filename = this . location . GetDisplayName ( ) } ) ;
2016-04-29 13:42:52 +00:00
return false ;
}
2016-05-12 13:56:25 +00:00
return CompileLump ( lumpname , index , scriptconfig , errors ) ;
2016-04-29 13:42:52 +00:00
}
// This compiles a script lump and returns any errors that may have occurred
// Returns true when our code worked properly (even when the compiler returned errors)
2016-05-12 13:56:25 +00:00
internal override bool CompileLump ( string lumpname , int lumpindex , ScriptConfiguration scriptconfig , List < CompilerError > errors )
2014-12-03 23:15:26 +00:00
{
2016-05-12 13:56:25 +00:00
// No compiling required
if ( scriptconfig . Compiler = = null ) return true ;
string inputfile ;
Compiler compiler ;
string reallumpname = lumpname ;
// Find the lump
if ( lumpname = = MapManager . CONFIG_MAP_HEADER ) reallumpname = MapManager . TEMP_MAP_HEADER ;
2016-11-24 11:55:11 +00:00
Lump lump = file . FindLump ( reallumpname , lumpindex , lumpindex ) ;
2016-05-12 13:56:25 +00:00
if ( lump = = null )
throw new Exception ( "Unable to find lump \"" + reallumpname + "\" to compile in \"" + location . GetDisplayName ( ) + "\"." ) ;
// Determine source file
string sourcefile = ( General . Map . FilePathName . Length > 0 ? General . Map . FilePathName : file . Filename ) ;
// Initialize compiler
try
{
compiler = scriptconfig . Compiler . Create ( ) ;
}
catch ( Exception e )
{
// Fail
errors . Add ( new CompilerError ( "Unable to initialize compiler. " + e . GetType ( ) . Name + ": " + e . Message ) ) ;
return false ;
}
2016-11-24 11:55:11 +00:00
//mxd. AccCompiler requires some additional settings...
if ( scriptconfig . ScriptType = = ScriptType . ACS )
{
AccCompiler acccompiler = compiler as AccCompiler ;
if ( acccompiler = = null )
{
// Fail
errors . Add ( new CompilerError ( "Unexpected ACS compiler: " + compiler ) ) ;
return false ;
}
if ( lumpname = = "SCRIPTS" & & this = = General . Map . TemporaryMapFile )
{
acccompiler . SourceIsMapScriptsLump = true ;
}
else
{
//TODO: implement library compiling...
errors . Add ( new CompilerError ( "Compilation of ACS libraries is not supported yet..." ) ) ;
return false ;
}
}
2016-05-12 13:56:25 +00:00
try
{
// Write lump data to temp script file in compiler's temp directory
inputfile = General . MakeTempFilename ( compiler . Location , "tmp" ) ;
lump . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
BinaryReader reader = new BinaryReader ( lump . Stream ) ;
File . WriteAllBytes ( inputfile , reader . ReadBytes ( ( int ) lump . Stream . Length ) ) ;
}
catch ( Exception e )
{
// Fail
compiler . Dispose ( ) ;
errors . Add ( new CompilerError ( "Unable to write script to working file. " + e . GetType ( ) . Name + ": " + e . Message ) ) ;
return false ;
}
// Make random output filename
string outputfile = General . MakeTempFilename ( compiler . Location , "tmp" ) ;
// Run compiler
compiler . Parameters = scriptconfig . Parameters ;
compiler . InputFile = Path . GetFileName ( inputfile ) ;
compiler . OutputFile = Path . GetFileName ( outputfile ) ;
compiler . SourceFile = sourcefile ;
compiler . WorkingDirectory = Path . GetDirectoryName ( inputfile ) ;
if ( compiler . Run ( ) )
{
// Process errors
foreach ( CompilerError e in compiler . Errors )
{
CompilerError newerror = e ;
// If the error's filename equals our temporary file, use the lump name instead and prefix it with ?
if ( string . Compare ( e . filename , inputfile , true ) = = 0 ) newerror . filename = "?" + reallumpname ;
errors . Add ( newerror ) ;
}
// No errors?
if ( compiler . Errors . Length = = 0 )
{
// Output file exists?
if ( File . Exists ( outputfile ) )
{
// Copy output file data into a lump?
if ( ! string . IsNullOrEmpty ( scriptconfig . ResultLump ) )
{
// Do that now then
byte [ ] filedata ;
try
{
filedata = File . ReadAllBytes ( outputfile ) ;
}
catch ( Exception e )
{
// Fail
compiler . Dispose ( ) ;
errors . Add ( new CompilerError ( "Unable to read compiler output file. " + e . GetType ( ) . Name + ": " + e . Message ) ) ;
return false ;
}
// Store data
SaveFile ( new MemoryStream ( filedata ) , scriptconfig . ResultLump ) ;
}
}
}
// Clean up
compiler . Dispose ( ) ;
// Done
return true ;
}
// Fail
compiler . Dispose ( ) ;
return false ;
2013-09-11 09:47:53 +00:00
}
2012-07-23 21:28:23 +00:00
2009-04-19 18:07:22 +00:00
#endregion
}
}