Merge branch 'master' into visual-slope2

This commit is contained in:
biwa 2020-04-04 13:12:20 +02:00
commit a3ce81dc2b
32 changed files with 151 additions and 61 deletions

View file

@ -664,7 +664,7 @@ floor
28
{
title = "Floor Crusher Start";
title = "Floor Raise And Crush";
id = "Floor_RaiseAndCrush";
arg0

View file

@ -38,7 +38,7 @@ namespace CodeImp.DoomBuilder.Data
public BitmapImage(Bitmap img, string name)
{
// Initialize
this.img = img;
this.img = new Bitmap(img);
this.AllowUnload = false;
SetName(name);
@ -62,7 +62,7 @@ namespace CodeImp.DoomBuilder.Data
// No failure checking here. I anything fails here, it is not the user's fault,
// because the resources this loads are in the assembly.
return new LocalLoadResult(img);
return new LocalLoadResult(new Bitmap(img));
}
#endregion

View file

@ -2531,7 +2531,7 @@ namespace CodeImp.DoomBuilder.Data
foreach(KeyValuePair<int, AmbientSoundInfo> group in parser.AmbientSounds)
{
configenums[group.Key] = new EnumItem(group.Key.ToString(), group.Value.SoundName);
configenums[group.Key] = new EnumItem(group.Key.ToString(), group.Value.SoundDescription);
}
// Store results in "ambient_sounds" enum

View file

@ -165,10 +165,10 @@ namespace CodeImp.DoomBuilder.Data
data.Position += 9; // Skip some stuff...
int width = data.ReadByte() + (data.ReadByte() << 8);
if(width < 0 || width > 8192) return false;
if(width <= 0 || width > 8192) return false;
int height = data.ReadByte() + (data.ReadByte() << 8);
if(height < 0 || height > 8192) return false;
if(height <= 0 || height > 8192) return false;
int bitsperpixel = data.ReadByte(); // Can be 8, 16, 24, 32
return (bitsperpixel == 8 || bitsperpixel == 16 || bitsperpixel == 24 || bitsperpixel == 32);

View file

@ -39,7 +39,7 @@ namespace CodeImp.DoomBuilder.Data
// Initialize
this.width = 0;
this.height = 0;
this.loadbitmap = Properties.Resources.UnknownImage;
this.loadbitmap = new Bitmap(Properties.Resources.UnknownImage);
SetName("");
LoadImageNow();

View file

@ -35,7 +35,7 @@ namespace CodeImp.DoomBuilder.IO
offsetx = int.MinValue;
offsety = int.MinValue;
using (BinaryReader reader = new BinaryReader(stream))
using (BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.UTF8, true))
{
int manufacturer = reader.ReadByte(); // 10=ZSoft
int version = reader.ReadByte();
@ -64,6 +64,9 @@ namespace CodeImp.DoomBuilder.IO
int width = rightMargin - leftMargin + 1;
int height = bottomMargin - topMargin + 1;
if (width == 0 || height == 0)
throw new InvalidDataException("Invalid pcx image file");
int vgaPaletteID = 0;
byte[] vgaPalette = null;
@ -218,7 +221,7 @@ namespace CodeImp.DoomBuilder.IO
offsetx = int.MinValue;
offsety = int.MinValue;
using (BinaryReader reader = new BinaryReader(stream))
using (BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.UTF8, true))
{
read_header(reader);
read_image_id(reader);
@ -250,6 +253,12 @@ namespace CodeImp.DoomBuilder.IO
if (colormap_type > 1)
throw new InvalidDataException("Invalid or unsupported targa image file");
if (image_type != 1 && image_type != 2 && image_type != 3 && image_type != 9 && image_type != 10 && image_type != 11)
throw new InvalidDataException("Invalid or unsupported targa image type");
if (image_width == 0 || image_height == 0)
throw new InvalidDataException("Invalid targa image file");
if (colormap_type == 0)
colormap_length = 0;
@ -581,7 +590,7 @@ namespace CodeImp.DoomBuilder.IO
if (isPng)
{
stream.Position = 8;
using (BinaryReader reader = new BinaryReader(stream))
using (BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.UTF8, true))
{
// Read chunks untill we encounter either "grAb" or "IDAT"
while (reader.BaseStream.Position < reader.BaseStream.Length)

View file

@ -151,7 +151,7 @@ namespace CodeImp.DoomBuilder.IO
// Read the UDMF data
lump.Stream.Seek(0, SeekOrigin.Begin);
udmfreader.SetKnownCustomTypes = true;
udmfreader.SetKnownCustomTypes = false;
udmfreader.Read(map, lump.Stream);
// Return result

View file

@ -1739,6 +1739,9 @@ namespace CodeImp.DoomBuilder.Rendering
// This collects a visual sector's geometry for rendering
public void AddThingGeometry(VisualThing t)
{
// The thing might have changed, especially when doing realtime editing from the edit thing dialog, so update it if necessary
t.Update();
//mxd. Gather lights
if (General.Settings.GZDrawLightsMode != LightRenderMode.NONE && !fullbrightness && t.LightType != null)
{

View file

@ -9,7 +9,7 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.AngleByte, "Byte Angle", true)]
[TypeHandler(UniversalType.AngleByte, "Byte Angle", false)]
internal class AngleByteHandler : AngleDegreesHandler
{
#region ================== Properties

View file

@ -26,7 +26,7 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.AngleDegreesFloat, "Degrees (Decimal)", true)]
[TypeHandler(UniversalType.AngleDegreesFloat, "Degrees (Decimal)", false)]
internal class AngleDegreesFloatHandler : AngleDegreesHandler
{
#region ================== Constants

View file

@ -26,7 +26,7 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.AngleDegrees, "Degrees (Integer)", true)]
[TypeHandler(UniversalType.AngleDegrees, "Degrees (Integer)", false)]
internal class AngleDegreesHandler : TypeHandler
{
#region ================== Constants

View file

@ -27,7 +27,7 @@ using CodeImp.DoomBuilder.Geometry;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.AngleRadians, "Radians", true)]
[TypeHandler(UniversalType.AngleRadians, "Radians", false)]
internal class AngleRadiansHandler : AngleDegreesHandler
{
#region ================== Constants

View file

@ -25,7 +25,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.Color, "Color", true)]
[TypeHandler(UniversalType.Color, "Color", false)]
internal class ColorHandler : TypeHandler
{
#region ================== Constants

View file

@ -24,7 +24,7 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.Flat, "Flat", true)]
[TypeHandler(UniversalType.Flat, "Flat", false)]
internal class FlatHandler : TypeHandler
{
#region ================== Constants

View file

@ -24,7 +24,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.LinedefTag, "Linedef Tag", true)]
[TypeHandler(UniversalType.LinedefTag, "Linedef Tag", false)]
internal class LinedefTagHandler : SectorTagHandler
{
#region ================== Setup (mxd)

View file

@ -26,7 +26,7 @@ using System.Windows.Forms;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.LinedefType, "Linedef Action", true)]
[TypeHandler(UniversalType.LinedefType, "Linedef Action", false)]
internal class LinedefTypeHandler : TypeHandler
{
#region ================== Constants

View file

@ -8,7 +8,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.RandomFloat, "Decimal (Random)", true)]
[TypeHandler(UniversalType.RandomFloat, "Decimal (Random)", false)]
internal class RandomFloatHandler : TypeHandler
{
#region ================== Constants

View file

@ -8,7 +8,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.RandomInteger, "Integer (Random)", true)]
[TypeHandler(UniversalType.RandomInteger, "Integer (Random)", false)]
internal class RandomIntegerHandler : TypeHandler
{
#region ================== Variables

View file

@ -26,7 +26,7 @@ using System.Windows.Forms;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.SectorEffect, "Sector Effect", true)]
[TypeHandler(UniversalType.SectorEffect, "Sector Effect", false)]
internal class SectorEffectHandler : TypeHandler
{
#region ================== Constants

View file

@ -26,7 +26,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.SectorTag, "Sector Tag", true)]
[TypeHandler(UniversalType.SectorTag, "Sector Tag", false)]
internal class SectorTagHandler : IntegerHandler
{
#region ================== Variables

View file

@ -24,7 +24,7 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.Texture, "Texture", true)]
[TypeHandler(UniversalType.Texture, "Texture", false)]
internal class TextureHandler : TypeHandler
{
#region ================== Constants

View file

@ -25,7 +25,7 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.ThingClass, "Thing Class", true)]
[TypeHandler(UniversalType.ThingClass, "Thing Class", false)]
internal class ThingClassHandler : TypeHandler
{
#region ================== Constants

View file

@ -24,7 +24,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.ThingTag, "Thing Tag", true)]
[TypeHandler(UniversalType.ThingTag, "Thing Tag", false)]
internal class ThingTagHandler : SectorTagHandler
{
#region ================== Setup (mxd)

View file

@ -26,7 +26,7 @@ using System.Windows.Forms;
namespace CodeImp.DoomBuilder.Types
{
[TypeHandler(UniversalType.ThingType, "Thing Type", true)]
[TypeHandler(UniversalType.ThingType, "Thing Type", false)]
internal class ThingTypeHandler : TypeHandler
{
#region ================== Constants

View file

@ -27,6 +27,7 @@ namespace CodeImp.DoomBuilder.ZDoom
#region ================== Variables
private string soundname;
private string sounddescription;
private int index = -1;
private AmbientType type = AmbientType.NONE;
@ -48,6 +49,7 @@ namespace CodeImp.DoomBuilder.ZDoom
#region ================== Properties
public string SoundName { get { return soundname; } }
public string SoundDescription { get { return sounddescription; } }
public int Index { get { return index; } } // Ambient sound index
// Sound settings
@ -107,7 +109,7 @@ namespace CodeImp.DoomBuilder.ZDoom
}
// Next token can be either [type] or <mode>...
if(!parser.SkipWhitespace(true)) return false;
if (!parser.SkipWhitespace(true)) return false;
string token = parser.ReadToken(false).ToLowerInvariant();
// Can be [type]
@ -191,6 +193,22 @@ namespace CodeImp.DoomBuilder.ZDoom
return false;
}
// There can be multiple different ambient sounds with the same sound name, so build a description containing the index
// and the name to differentiate them. See https://github.com/jewalky/UltimateDoomBuilder/issues/390
sounddescription = index.ToString() + ": " + soundname + " (" + type.ToString().ToLowerInvariant();
if (type == AmbientType.POINT)
sounddescription += ", attenuation: " + attenuation;
if (mode == AmbientMode.CONTINUOUS)
sounddescription += ", " + mode.ToString().ToLowerInvariant();
else if (mode == AmbientMode.RANDOM)
sounddescription += ", every " + minsecs + " to " + maxsecs + " seconds";
else if (mode == AmbientMode.PERIODIC)
sounddescription += ", every " + secs + " seconds";
sounddescription += ", " + volume * 100 + "% volume)";
return true;
}

View file

@ -452,39 +452,61 @@ namespace CodeImp.DoomBuilder.ZDoom
return true;
}
private string ParseVersion(bool required)
{
// read in the version.
tokenizer.SkipWhitespace();
ZScriptToken token = tokenizer.ExpectToken(ZScriptTokenType.OpenParen);
if (token == null || !token.IsValid)
{
if (required)
parser.ReportError("Expected (, got " + ((Object)token ?? "<null>").ToString());
return null;
}
private string ParseVersion(bool required)
{
// read in the version.
tokenizer.SkipWhitespace();
ZScriptToken token = tokenizer.ExpectToken(ZScriptTokenType.OpenParen);
if (token == null || !token.IsValid)
{
if (required)
parser.ReportError("Expected (, got " + ((Object)token ?? "<null>").ToString());
return null;
}
tokenizer.SkipWhitespace();
token = tokenizer.ExpectToken(ZScriptTokenType.String);
if (token == null || !token.IsValid)
{
parser.ReportError("Expected version, got " + ((Object)token ?? "<null>").ToString());
return null;
}
tokenizer.SkipWhitespace();
token = tokenizer.ExpectToken(ZScriptTokenType.String);
if (token == null || !token.IsValid)
{
parser.ReportError("Expected version, got " + ((Object)token ?? "<null>").ToString());
return null;
}
string version = token.Value.Trim();
tokenizer.SkipWhitespace();
token = tokenizer.ExpectToken(ZScriptTokenType.CloseParen);
if (token == null || !token.IsValid)
{
parser.ReportError("Expected ), got " + ((Object)token ?? "<null>").ToString());
return null;
}
string version = token.Value.Trim();
tokenizer.SkipWhitespace();
return version;
}
// As of https://github.com/coelckers/gzdoom/commit/7a141f3aa3b67b5b1d326f5d9b3904da1b65f847
// there can be helper messages as the 2nd parameter
token = tokenizer.ExpectToken(ZScriptTokenType.CloseParen, ZScriptTokenType.Comma);
if (token == null || !token.IsValid)
{
parser.ReportError("Expected ) or comma, got " + ((Object)token ?? "<null>").ToString());
return null;
}
internal ZScriptActorStructure(ZDTextParser zdparser, DecorateCategoryInfo catinfo, string _classname, string _replacesname, string _parentname)
if (token.Type == ZScriptTokenType.CloseParen)
return version;
tokenizer.SkipWhitespace();
token = tokenizer.ExpectToken(ZScriptTokenType.String);
if (token == null || !token.IsValid)
{
parser.ReportError("Expected helper message string, got " + ((Object)token ?? "<null>").ToString());
return null;
}
tokenizer.SkipWhitespace();
token = tokenizer.ExpectToken(ZScriptTokenType.CloseParen);
if (token == null || !token.IsValid)
{
parser.ReportError("Expected ), got " + ((Object)token ?? "<null>").ToString());
return null;
}
return version;
}
internal ZScriptActorStructure(ZDTextParser zdparser, DecorateCategoryInfo catinfo, string _classname, string _replacesname, string _parentname)
{
this.catinfo = catinfo; //mxd

View file

@ -4621,8 +4621,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
backwardoffset = j.offsetx;
if(!worldpanning)
forwardoffset = (float)Math.Round((j.offsetx + (float)Math.Round(j.sidedef.Line.Length) / scalex * first.scaleX) % vwidth, General.Map.FormatInterface.VertexDecimals);
if (!worldpanning)
{
// If the texture gets replaced with a "hires" texture it adds more fuckery
if (texture is HiResImage)
forwardoffset = j.offsetx + (float)Math.Round(((float)Math.Round(j.sidedef.Line.Length) / scalex) % vwidth, General.Map.FormatInterface.VertexDecimals);
else
forwardoffset = j.offsetx + (float)Math.Round(((float)Math.Round(j.sidedef.Line.Length) / scalex * Math.Abs(first.scaleX)) % vwidth, General.Map.FormatInterface.VertexDecimals);
}
else
forwardoffset = (float)Math.Round((j.offsetx + (float)Math.Round(j.sidedef.Line.Length)) % vwidth, General.Map.FormatInterface.VertexDecimals);
@ -4646,7 +4652,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
float offset;
if(!worldpanning)
offset = (float)Math.Round((j.offsetx - j.sidedef.OffsetX - (float)Math.Round(j.sidedef.Line.Length) / scalex * first.scaleX) % vwidth, General.Map.FormatInterface.VertexDecimals);
{
// If the texture gets replaced with a "hires" texture it adds more fuckery
if (texture is HiResImage)
offset = (float)Math.Round((j.offsetx - j.sidedef.OffsetX - (float)Math.Round(j.sidedef.Line.Length) / scalex) % vwidth, General.Map.FormatInterface.VertexDecimals);
else
offset = (float)Math.Round((j.offsetx - j.sidedef.OffsetX - (float)Math.Round(j.sidedef.Line.Length) / scalex * first.scaleX) % vwidth, General.Map.FormatInterface.VertexDecimals);
}
else
offset = (float)Math.Round((j.offsetx - j.sidedef.OffsetX - (float)Math.Round(j.sidedef.Line.Length)) % vwidth, General.Map.FormatInterface.VertexDecimals);
@ -4762,7 +4774,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
forwardoffset = j.offsetx;
if (!worldpanning)
backwardoffset = (float)Math.Round((j.offsetx - (float)Math.Round(j.sidedef.Line.Length) / scalex * first.scaleX) % vwidth, General.Map.FormatInterface.VertexDecimals);
{
// If the texture gets replaced with a "hires" texture it adds more fuckery
if (texture is HiResImage)
backwardoffset = (float)Math.Round((j.offsetx - (float)Math.Round(j.sidedef.Line.Length) / scalex) % vwidth, General.Map.FormatInterface.VertexDecimals);
else
backwardoffset = (float)Math.Round((j.offsetx - (float)Math.Round(j.sidedef.Line.Length) / scalex * Math.Abs(first.scaleX)) % vwidth, General.Map.FormatInterface.VertexDecimals);
}
else
backwardoffset = (float)Math.Round((j.offsetx - (float)Math.Round(j.sidedef.Line.Length)) % vwidth, General.Map.FormatInterface.VertexDecimals);

View file

@ -139,6 +139,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
tof = tof / tscaleAbs;
tof = tof * base.Texture.Scale;
// If the texture gets replaced with a "hires" texture it adds more fuckery
if (base.Texture is HiResImage)
tof *= tscaleAbs;
}
// Determine texture coordinates plane as they would be in normal circumstances.

View file

@ -157,6 +157,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
tof = tof / tscaleAbs;
tof = tof * base.Texture.Scale;
// If the texture gets replaced with a "hires" texture it adds more fuckery
if (base.Texture is HiResImage)
tof *= tscaleAbs;
}
// For Vavoom type 3D floors the ceiling is lower than floor and they are reversed.

View file

@ -139,6 +139,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
tof = tof / tscaleAbs;
tof = tof * base.Texture.Scale;
// If the texture gets replaced with a "hires" texture it adds more fuckery
if (base.Texture is HiResImage)
tof *= tscaleAbs;
}
// Determine texture coordinates plane as they would be in normal circumstances.

View file

@ -125,6 +125,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
tof = tof / tscaleAbs;
tof = tof * base.Texture.Scale;
// If the texture gets replaced with a "hires" texture it adds more fuckery
if (base.Texture is HiResImage)
tof *= tscaleAbs;
}
// Determine texture coordinates plane as they would be in normal circumstances.

View file

@ -140,6 +140,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
tof = tof / tscaleAbs;
tof = tof * base.Texture.Scale;
// If the texture gets replaced with a "hires" texture it adds more fuckery
if (base.Texture is HiResImage)
tof *= tscaleAbs;
}
// Determine texture coordinates plane as they would be in normal circumstances.