mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
IPK3 and IPK7 with an IWADINFO lump with a single IWAD definition are now recognized as the main resource file (used for the -iwad parameter when testing). Fixes #653
This commit is contained in:
parent
beacc21d96
commit
d68f41a2a3
10 changed files with 284 additions and 2 deletions
|
@ -623,6 +623,8 @@
|
|||
<Compile Include="ZDoom\DecorateActorStructure.cs" />
|
||||
<Compile Include="ZDoom\DecorateStateGoto.cs" />
|
||||
<Compile Include="ZDoom\DecorateStateStructure.cs" />
|
||||
<Compile Include="ZDoom\IWadInfo.cs" />
|
||||
<Compile Include="ZDoom\IWadInfoParser.cs" />
|
||||
<Compile Include="ZDoom\Scripting\ZScriptParserSE.cs" />
|
||||
<Compile Include="ZDoom\ZScriptActorStructure.cs" />
|
||||
<Compile Include="ZDoom\ZScriptParser.cs" />
|
||||
|
|
|
@ -615,6 +615,8 @@
|
|||
<Compile Include="ZDoom\DecorateActorStructure.cs" />
|
||||
<Compile Include="ZDoom\DecorateStateGoto.cs" />
|
||||
<Compile Include="ZDoom\DecorateStateStructure.cs" />
|
||||
<Compile Include="ZDoom\IWadInfo.cs" />
|
||||
<Compile Include="ZDoom\IWadInfoParser.cs" />
|
||||
<Compile Include="ZDoom\Scripting\ZScriptParserSE.cs" />
|
||||
<Compile Include="ZDoom\ZScriptActorStructure.cs" />
|
||||
<Compile Include="ZDoom\ZScriptParser.cs" />
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
ZSCRIPT,
|
||||
DECALDEF,
|
||||
DEHACKED,
|
||||
IWADINFO,
|
||||
}
|
||||
|
||||
public class ScriptConfiguration : IComparable<ScriptConfiguration>
|
||||
|
|
|
@ -3071,7 +3071,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
#region ================== Tools
|
||||
|
||||
// This finds the first IWAD resource
|
||||
// This finds the first IWAD or IPK3 resource
|
||||
// Returns false when not found
|
||||
public bool FindFirstIWAD(out DataLocation result)
|
||||
{
|
||||
|
@ -3090,6 +3090,15 @@ namespace CodeImp.DoomBuilder.Data
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else if(dr is PK3Reader)
|
||||
{
|
||||
PK3Reader pk3r = dr as PK3Reader;
|
||||
if(pk3r.GetIWadInfos().Count == 1)
|
||||
{
|
||||
result = pk3r.Location;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No IWAD found
|
||||
|
|
|
@ -254,6 +254,9 @@ namespace CodeImp.DoomBuilder.Data
|
|||
//mxd. When implemented, this returns the voxel lump
|
||||
public abstract Stream GetVoxelData(string name, ref string voxellocation);
|
||||
|
||||
// When implemented, this returns the list of IWAD infos
|
||||
public abstract List<IWadInfo> GetIWadInfos();
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Load/Save (mxd)
|
||||
|
|
|
@ -512,6 +512,29 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== IWADINFO
|
||||
|
||||
public override List<IWadInfo> GetIWadInfos()
|
||||
{
|
||||
IWadInfoParser parser = new IWadInfoParser();
|
||||
|
||||
// At least one of IWADINFO should be in the root folder
|
||||
List<string> files = new List<string>();
|
||||
|
||||
// Can be several entries
|
||||
files.AddRange(GetAllFilesWhichTitleStartsWith("", "IWADINFO", false));
|
||||
|
||||
foreach(string s in files)
|
||||
{
|
||||
parser.Parse(new TextResourceData(this, LoadFile(s), s, true), false);
|
||||
if (parser.HasError) parser.LogError();
|
||||
}
|
||||
|
||||
return parser.IWads;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== DECORATE
|
||||
|
||||
// This finds and returns DECORATE streams
|
||||
|
|
|
@ -1018,6 +1018,23 @@ namespace CodeImp.DoomBuilder.Data
|
|||
return GetAllLumpsData("DEHACKED");
|
||||
}
|
||||
|
||||
#region ================== IWADINFO
|
||||
|
||||
public override List<IWadInfo> GetIWadInfos()
|
||||
{
|
||||
IWadInfoParser parser = new IWadInfoParser();
|
||||
|
||||
foreach (TextResourceData trd in GetAllLumpsData("IWADINFO"))
|
||||
{
|
||||
parser.Parse(trd, false);
|
||||
if (parser.HasError) parser.LogError();
|
||||
}
|
||||
|
||||
return parser.IWads;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// This finds and returns DECORATE streams
|
||||
public override IEnumerable<TextResourceData> GetDecorateData(string pname)
|
||||
{
|
||||
|
|
|
@ -158,7 +158,7 @@ namespace CodeImp.DoomBuilder
|
|||
foreach(DataLocation dl in locations)
|
||||
{
|
||||
// Location not the IWAD file?
|
||||
if((dl.type != DataLocation.RESOURCE_WAD) || (dl.location != iwadloc.location))
|
||||
if((dl.location != iwadloc.location))
|
||||
{
|
||||
// Location not included?
|
||||
if(!dl.notfortesting)
|
||||
|
|
44
Source/Core/ZDoom/IWadInfo.cs
Normal file
44
Source/Core/ZDoom/IWadInfo.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
#region ================== Copyright (c) 2021 Boris Iwanski
|
||||
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
*
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
*
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.If not, see<http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.ZDoom
|
||||
{
|
||||
class IWadInfo
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private string autoname;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public string AutoName { get { return autoname; } internal set { autoname = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructors
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
181
Source/Core/ZDoom/IWadInfoParser.cs
Normal file
181
Source/Core/ZDoom/IWadInfoParser.cs
Normal file
|
@ -0,0 +1,181 @@
|
|||
#region ================== Copyright (c) 2021 Boris Iwanski
|
||||
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
*
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
*
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.If not, see<http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System.Collections.Generic;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.ZDoom
|
||||
{
|
||||
class IWadInfoParser : ZDTextParser
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private List<IWadInfo> iwads;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
internal override ScriptType ScriptType { get { return ScriptType.IWADINFO; } }
|
||||
public List<IWadInfo> IWads { get { return iwads; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructors
|
||||
|
||||
public IWadInfoParser()
|
||||
{
|
||||
iwads = new List<IWadInfo>();
|
||||
|
||||
whitespace = "\n \t\r\u00A0";
|
||||
specialtokens = ",{}=\n";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
/// <summary>
|
||||
/// Parses DECALDEF data
|
||||
/// </summary>
|
||||
/// <param name="data">The data to parse</param>
|
||||
/// <param name="clearerrors">If errors should be cleared</param>
|
||||
/// <returns>true if paring worked, otherwise false</returns>
|
||||
public override bool Parse(TextResourceData data, bool clearerrors)
|
||||
{
|
||||
if (!AddTextResource(data))
|
||||
{
|
||||
if (clearerrors) ClearError();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cannot process?
|
||||
if (!base.Parse(data, clearerrors)) return false;
|
||||
|
||||
while (SkipWhitespace(true))
|
||||
{
|
||||
string token = ReadToken().ToLowerInvariant();
|
||||
if (string.IsNullOrEmpty(token)) continue;
|
||||
|
||||
switch (token)
|
||||
{
|
||||
case "iwad":
|
||||
ParseIWad();
|
||||
break;
|
||||
default:
|
||||
SkipStructure();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a pair of a key and multiple values.
|
||||
/// The key value pair looks like this:
|
||||
/// key = value1 [, value2 [, value3 [...] ] ]
|
||||
/// </summary>
|
||||
/// <param name="key">The key</param>
|
||||
/// <param name="values">The list of values</param>
|
||||
/// <returns>True if a pair could be parsed, false otherwise</returns>
|
||||
private bool GetKeyValuesPair(out string key, out List<string> values)
|
||||
{
|
||||
|
||||
string token;
|
||||
|
||||
values = new List<string>();
|
||||
|
||||
SkipWhitespace(true);
|
||||
|
||||
key = ReadToken().ToLowerInvariant();
|
||||
|
||||
SkipWhitespace(true);
|
||||
|
||||
token = ReadToken().ToLowerInvariant();
|
||||
|
||||
if(token != "=")
|
||||
{
|
||||
ReportError("Expected \"=\", but got \"" + token + "\"");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get all values
|
||||
do
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
token = ReadToken();
|
||||
values.Add(token);
|
||||
} while (NextTokenIs(",", false));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a Iwad block.
|
||||
/// </summary>
|
||||
/// <returns>True if parsing succeeded, false if it didn't</returns>
|
||||
private bool ParseIWad()
|
||||
{
|
||||
if(!NextTokenIs("{", false))
|
||||
{
|
||||
ReportError("Expected opening brace");
|
||||
return false;
|
||||
}
|
||||
|
||||
IWadInfo iwad = new IWadInfo();
|
||||
|
||||
while(SkipWhitespace(true))
|
||||
{
|
||||
string key;
|
||||
List<string> values;
|
||||
|
||||
// If we encounter a closing swirly bracke the end of the block is reached
|
||||
if(NextTokenIs("}", false))
|
||||
{
|
||||
iwads.Add(iwad);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!GetKeyValuesPair(out key, out values))
|
||||
return false;
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case "autoname":
|
||||
iwad.AutoName = values[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue