mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 13:51:40 +00:00
Added, Search and Replace mode: "Find Sector Brightness" search mode now supports "<=", "<", ">=" and ">" prefixes.
Fixed, Sound Environment mode: fixed several cases when single-sided lines with only back side could cause either logic errors or crashes. Fixed, Automap mode: fixed several cases when single-sided lines with only back side could cause logic errors. Debug: added some debug code to WAD.Insert() to investigate the issue when lumpoffset could become negative.
This commit is contained in:
parent
3c62e89ded
commit
ea81ad80a8
6 changed files with 53 additions and 10 deletions
|
@ -363,10 +363,19 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Create the lump
|
||||
Lump lump = new Lump(file, this, Lump.MakeFixedName(name, ENCODING), lumpsoffset, datalength);
|
||||
lumps.Insert(position, lump);
|
||||
|
||||
//dbg
|
||||
int oldlumpoffset = lumpsoffset;
|
||||
|
||||
// Advance lumps table offset
|
||||
lumpsoffset += datalength;
|
||||
|
||||
//dbg
|
||||
if(lumpsoffset < 0)
|
||||
{
|
||||
throw new InvalidOperationException("Invalid lumpsoffset (" + lumpsoffset + ") after inserting lump \"" + name + "\" at position " + position + ", datalength=" + datalength + ". Previous lumpoffset was " + oldlumpoffset);
|
||||
}
|
||||
|
||||
// Write the new headers
|
||||
if(writeheaders) WriteHeaders();
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ namespace CodeImp.DoomBuilder.AutomapMode
|
|||
return ColorSecret;
|
||||
|
||||
if(ld.IsFlagSet(BuilderPlug.Me.HiddenFlag)) return ColorHiddenFlag;
|
||||
if(ld.Back == null || ld.IsFlagSet(BuilderPlug.Me.SecretFlag)) return ColorSingleSided;
|
||||
if(ld.Back == null || ld.Front == null || ld.IsFlagSet(BuilderPlug.Me.SecretFlag)) return ColorSingleSided;
|
||||
if(ld.Front.Sector.FloorHeight != ld.Back.Sector.FloorHeight) return ColorFloorDiff;
|
||||
if(ld.Front.Sector.CeilHeight != ld.Back.Sector.CeilHeight) return ColorCeilDiff;
|
||||
|
||||
|
@ -196,8 +196,8 @@ namespace CodeImp.DoomBuilder.AutomapMode
|
|||
{
|
||||
if(menusform.ShowHiddenLines ^ General.Interface.CtrlState) return true;
|
||||
if(ld.IsFlagSet(BuilderPlug.Me.HiddenFlag)) return false;
|
||||
if(ld.Back == null || ld.IsFlagSet(BuilderPlug.Me.SecretFlag)) return true;
|
||||
if(ld.Back != null && (ld.Front.Sector.FloorHeight != ld.Back.Sector.FloorHeight || ld.Front.Sector.CeilHeight != ld.Back.Sector.CeilHeight)) return true;
|
||||
if(ld.Back == null || ld.Front == null || ld.IsFlagSet(BuilderPlug.Me.SecretFlag)) return true;
|
||||
if(ld.Back != null && ld.Front != null && (ld.Front.Sector.FloorHeight != ld.Back.Sector.FloorHeight || ld.Front.Sector.CeilHeight != ld.Back.Sector.CeilHeight)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using System.Windows.Forms;
|
||||
|
@ -11,6 +12,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[FindReplace("Sector Brightness", BrowseButton = false)]
|
||||
internal class FindSectorBrightness : BaseFindSector
|
||||
{
|
||||
#region ================== Properties
|
||||
|
||||
//mxd. Prefixes usage
|
||||
public override string UsageHint { get { return "Supported prefixes:" + Environment.NewLine
|
||||
+ "\"<=\" - finds values less or equal to given value;" + Environment.NewLine
|
||||
+ "\">=\" - finds values greater or equal to given value;" + Environment.NewLine
|
||||
+ "\"<\" - finds values less than given value;" + Environment.NewLine
|
||||
+ "\">\" - finds values greater than given value."; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This is called to perform a search (and replace)
|
||||
|
@ -37,6 +49,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Interpret the number given
|
||||
int brightness;
|
||||
string prefix = string.Empty; //mxd
|
||||
|
||||
//mxd. Check prefixes
|
||||
value = value.Trim().Replace(" ", "");
|
||||
if(value.StartsWith(">=") || value.StartsWith("<=")) prefix = value.Substring(0, 2);
|
||||
else if(value.StartsWith(">") || value.StartsWith("<")) prefix = value.Substring(0, 1);
|
||||
value = value.Remove(0, prefix.Length);
|
||||
|
||||
if(int.TryParse(value, out brightness))
|
||||
{
|
||||
// Where to search?
|
||||
|
@ -46,12 +66,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach(Sector s in list)
|
||||
{
|
||||
// Brightness matches?
|
||||
if(s.Brightness == brightness)
|
||||
if(BrightnessMatches(s.Brightness, brightness, prefix))
|
||||
{
|
||||
// Replace
|
||||
if(replace) s.Brightness = replacebrightness;
|
||||
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index));
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index + (!replace ? " (Brightness " + s.Brightness + ")" : "")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +86,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
return objs.ToArray();
|
||||
}
|
||||
|
||||
//mxd
|
||||
private static bool BrightnessMatches(int sectorbrightness, int brightness, string prefix)
|
||||
{
|
||||
switch(prefix)
|
||||
{
|
||||
case "": return sectorbrightness == brightness;
|
||||
case "<=": return sectorbrightness <= brightness;
|
||||
case ">=": return sectorbrightness >= brightness;
|
||||
case "<": return sectorbrightness < brightness;
|
||||
case ">": return sectorbrightness > brightness;
|
||||
default: throw new NotImplementedException("Unknown prefix");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
continue;
|
||||
}
|
||||
|
||||
if(sd.Line.Back == null) continue;
|
||||
if(sd.Other == null) continue;
|
||||
|
||||
Sector oppositesector = (sd.Line.Front.Sector == sector ? sd.Line.Back.Sector : sd.Line.Front.Sector);
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
linedefnode.ImageIndex = iconindex; //mxd
|
||||
linedefnode.SelectedImageIndex = iconindex; //mxd
|
||||
|
||||
if(ld.Back == null)
|
||||
if(ld.Back == null || ld.Front == null)
|
||||
{
|
||||
showwarning = true;
|
||||
linedefnode.ToolTipText = "This line is single-sided, but has\nthe sound boundary flag set.";
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
if(blocksound) blockinglines.Add(sd.Line);
|
||||
|
||||
// If the line is one sided, the sound can travel nowhere, so try the next one
|
||||
if(sd.Line.Back == null || blocksound) continue;
|
||||
if(sd.Other == null || blocksound) continue;
|
||||
|
||||
// Get the sector on the other side of the line we're checking right now
|
||||
Sector oppositesector = sd.Other.Sector;
|
||||
|
@ -87,7 +87,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
{
|
||||
// Lines that don't have a back side, or where the sound is blocked due to
|
||||
// the sector heights on each side can be skipped
|
||||
if(ld.Back == null || IsSoundBlockedByHeight(ld)) continue;
|
||||
if(IsSoundBlockedByHeight(ld)) continue;
|
||||
if(!sectors.Contains(ld.Front.Sector)) adjacentsectors.Add(ld.Front.Sector);
|
||||
if(!sectors.Contains(ld.Back.Sector)) adjacentsectors.Add(ld.Back.Sector);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
|
||||
private static bool IsSoundBlockedByHeight(Linedef ld)
|
||||
{
|
||||
if(ld.Back == null) return false;
|
||||
if(ld.Back == null || ld.Front == null) return false;
|
||||
|
||||
Sector s1 = ld.Front.Sector;
|
||||
Sector s2 = ld.Back.Sector;
|
||||
|
|
Loading…
Reference in a new issue