Fixed a crash when trying to parse an empty TEXTURES lump (probably covers some other empty text lumps as well).

Added strict revision checking to BuilderModes.dll (this plugin must always stay in sync with the core).
This commit is contained in:
MaxED 2016-01-20 17:54:56 +00:00
parent 8ac4189c7a
commit a1c290d49c
8 changed files with 46 additions and 17 deletions

View file

@ -381,7 +381,7 @@ namespace CodeImp.DoomBuilder.Data
while(lumpindex > -1)
{
MemoryStream filedata = new MemoryStream(file.Lumps[lumpindex].Stream.ReadAllBytes());
WADReader.LoadHighresTextures(filedata, "TEXTURES", ref images, null, null);
WADReader.LoadHighresTextures(filedata, Path.Combine(Path.GetFileName(file.Filename), "TEXTURES#" + lumpindex), ref images, null, null);
filedata.Dispose();
// Find next
@ -611,7 +611,7 @@ namespace CodeImp.DoomBuilder.Data
while(lumpindex > -1)
{
MemoryStream filedata = new MemoryStream(file.Lumps[lumpindex].Stream.ReadAllBytes());
WADReader.LoadHighresFlats(filedata, "TEXTURES", ref images, null, null);
WADReader.LoadHighresFlats(filedata, Path.Combine(Path.GetFileName(file.Filename), "TEXTURES#" + lumpindex), ref images, null, null);
filedata.Dispose();
// Find next
@ -676,7 +676,7 @@ namespace CodeImp.DoomBuilder.Data
while(lumpindex > -1)
{
MemoryStream filedata = new MemoryStream(file.Lumps[lumpindex].Stream.ReadAllBytes());
WADReader.LoadHighresSprites(filedata, "TEXTURES", ref images, null, null);
WADReader.LoadHighresSprites(filedata, Path.Combine(Path.GetFileName(file.Filename), "TEXTURES#" + lumpindex), ref images, null, null);
filedata.Dispose();
// Find next

View file

@ -1023,13 +1023,13 @@ namespace CodeImp.DoomBuilder
General.Actions.UnbindMethods(typeof(General));
// Save colors
colors.SaveColors(settings.Config);
if(colors != null) colors.SaveColors(settings.Config);
// Save action controls
actions.SaveSettings();
// Save game configuration settings
foreach(ConfigurationInfo ci in configs) ci.SaveSettings();
if(configs != null) foreach(ConfigurationInfo ci in configs) ci.SaveSettings();
// Save settings configuration
if(!General.NoSettings)

View file

@ -52,11 +52,16 @@ namespace CodeImp.DoomBuilder.Plugins
public virtual string Name { get { return plugin.Name; } }
/// <summary>
/// Override this to return the minimum revision of the Doom Builder 2 core that is
/// Override this to return the minimum revision of the GZDoom Builder core that is
/// required to use this plugin. You can find the revision number in the About dialog,
/// it is the right most part of the version number.
/// </summary>
public virtual int MinimumRevision { get { return 0; } }
/// <summary>
/// Set to true to indicate that plugin revision number must match the main module revision number.
/// </summary>
public virtual bool StrictRevisionMatching { get { return false; } } //mxd
#endregion

View file

@ -71,7 +71,6 @@ namespace CodeImp.DoomBuilder.Plugins
try
{
// Load assembly
//asm = Assembly.LoadFile(filename); //mxd
asm = Assembly.LoadFrom(filename);
}
catch(Exception)
@ -95,8 +94,30 @@ namespace CodeImp.DoomBuilder.Plugins
plug = CreateObject<Plug>(t);
plug.Plugin = this;
// Verify minimum revision number
// Verify revision numbers
int thisrevision = General.ThisAssembly.GetName().Version.Revision;
//mxd. Revision numbers should match?
if(plug.StrictRevisionMatching && plug.MinimumRevision != thisrevision)
{
string message = shortfilename + " plugin's assembly version (" + plug.MinimumRevision + ") doesn't match main module version (" + thisrevision + ").";
if(General.ShowWarningMessage(message + Environment.NewLine +
"It's strongly recomended to update the editor." + Environment.NewLine +
"Program stability is not guaranteed." + Environment.NewLine + Environment.NewLine +
"Continue anyway?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2, false) == DialogResult.No)
{
General.WriteLogLine("Quiting on " + shortfilename + " module version mismatch");
General.Exit(General.Map != null);
return;
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, message);
throw new InvalidProgramException();
}
}
// Verify minimum revision number
if((thisrevision != 0) && (plug.MinimumRevision > thisrevision))
{
// Can't load this plugin because it is meant for a newer version

View file

@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CodeImp, MaxED")]
[assembly: AssemblyProduct("GZDoom Builder")]
[assembly: AssemblyCopyright("Copyright © 2007, 2015")]
[assembly: AssemblyCopyright("Copyright © 2007, 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View file

@ -97,11 +97,15 @@ namespace CodeImp.DoomBuilder.ZDoom
if(stream.Length == 0)
{
if(!string.IsNullOrEmpty(sourcename))
if(!string.IsNullOrEmpty(sourcename) && sourcename != sourcefilename)
{
LogWarning("Include file \"" + sourcefilename + "\" is empty");
}
else
{
sourcename = sourcefilename; // LogWarning() needs "sourcename" property to properly log the warning...
LogWarning("File is empty");
return true;
}
}
datastream = stream;
@ -526,7 +530,7 @@ namespace CodeImp.DoomBuilder.ZDoom
protected internal void LogWarning(string message)
{
// Add a warning
int errline = GetCurrentLineNumber();
int errline = (datastream != null ? GetCurrentLineNumber() : CompilerError.NO_LINE_NUMBER);
General.ErrorLogger.Add(ErrorType.Warning, GetLanguageType() + " warning in '" + sourcename
+ (errline != CompilerError.NO_LINE_NUMBER ? "', line " + (errline + 1) : "'") + ". "
+ message + ".");

View file

@ -137,9 +137,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public override string Name { get { return "GZDoom Builder"; } } //mxd
public static BuilderPlug Me { get { return me; } }
// It is only safe to do this dynamically because we compile and distribute both
// the core and this plugin together with the same revision number! In third party
// plugins this should just contain a fixed number.
//mxd. BuilderModes.dll revision should always match the main module revision
public override bool StrictRevisionMatching { get { return true; } }
public override int MinimumRevision { get { return Assembly.GetExecutingAssembly().GetName().Version.Revision; } }
public MenusForm MenusForm { get { return menusform; } }

View file

@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CodeImp, MaxED")]
[assembly: AssemblyProduct("Doom Builder")]
[assembly: AssemblyCopyright("Copyright © 2007, 2014")]
[assembly: AssemblyCopyright("Copyright © 2007, 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -28,4 +28,4 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.3.0.1885")]
[assembly: AssemblyVersion("2.3.0.2411")]