Updated, Visual mode: some cases when the sky hack must be applied were not handled.

Updated, Script editor: script editor was unable to show error location after double-clicking on it in the Warnings and Errors window when said location was inside of a WAD located in a PK3 file.
Updated, text lumps tracking: already parsed DECORATE/GLDEFS lumps are now added to the text lumps list even when DECORATE/GLDEFS parsing fails, allowing you to fix errors without the need to use external tools.
Fixed: in some cases the editor could stuck in an infinite loop when searching for wad lumps.
This commit is contained in:
MaxED 2016-11-28 20:01:47 +00:00
parent 18dc8cebba
commit 1523d06ee3
9 changed files with 167 additions and 30 deletions

View file

@ -628,12 +628,35 @@ namespace CodeImp.DoomBuilder.Controls
{
// Resource exists?
DataReader dr = null;
foreach(DataReader reader in General.Map.Data.Containers)
// Resource is a temporary file?
if(item.ResourceLocation.StartsWith(General.Map.TempPath))
{
if(reader.Location.location == item.ResourceLocation)
// Search in PK3-embedded wads only
foreach(DataReader reader in General.Map.Data.Containers)
{
dr = reader;
break;
if(!(reader is PK3Reader)) continue;
PK3Reader pkr = (PK3Reader)reader;
foreach(WADReader wadreader in pkr.Wads)
{
if(wadreader.Location.location == item.ResourceLocation)
{
dr = wadreader;
break;
}
}
}
}
else
{
// Search among resources
foreach(DataReader reader in General.Map.Data.Containers)
{
if(reader.Location.location == item.ResourceLocation)
{
dr = reader;
break;
}
}
}
@ -643,9 +666,14 @@ namespace CodeImp.DoomBuilder.Controls
TextResourceData trd = new TextResourceData(dr, dr.LoadFile(item.LumpName, item.LumpIndex), item.LumpName, item.LumpIndex, false);
var targettab = OpenResource(new ScriptResource(trd, item.ScriptType));
// Go to error line
if(targettab != null && item.LineNumber != CompilerError.NO_LINE_NUMBER)
targettab.MoveToLine(item.LineNumber);
if(targettab != null)
{
// Go to error line
if(item.LineNumber != CompilerError.NO_LINE_NUMBER) targettab.MoveToLine(item.LineNumber);
// Show in resources tree
scriptresources.SelectItem(item.ResourceLocation, item.LumpName, item.LumpIndex, item.ScriptType);
}
}
//mxd

View file

@ -185,6 +185,41 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Methods
public void SelectItem(string resourcelocation, string lumpname, int lumpindex, ScriptType scripttype)
{
TreeNode target = FindItem(projecttree.Nodes, resourcelocation, lumpname, lumpindex, scripttype);
if(target != null)
{
projecttree.SelectedNode = target;
}
}
private static TreeNode FindItem(TreeNodeCollection nodes, string resourcelocation, string lumpname, int lumpindex, ScriptType scripttype)
{
foreach(TreeNode node in nodes)
{
// Is this the item we are looking for?
TextResourceNodeData data = (TextResourceNodeData)node.Tag;
if(data.NodeType == TextResourceNodeType.NODE && data.ResourceLocation == resourcelocation
&& data.ScriptType == scripttype && data.Resource.Filename == lumpname && data.Resource.LumpIndex == lumpindex)
{
// Found it!
return node;
}
// Try children...
if(node.Nodes.Count > 0)
{
TreeNode item = FindItem(node.Nodes, resourcelocation, lumpname, lumpindex, scripttype);
if(item != null) return item;
}
}
// No dice...
return null;
}
private void UpdateResourcesTree()
{
ScriptType targettype = (filterbytype.SelectedIndex > -1 ? ((ScriptTypeItem)filterbytype.SelectedItem).Type : ScriptType.UNKNOWN);
@ -352,6 +387,7 @@ namespace CodeImp.DoomBuilder.Controls
LocationInResource = path,
NodeType = TextResourceNodeType.NODE,
Resource = res,
ScriptType = res.ScriptType,
};
string includepath = (res.ScriptType == ScriptType.ACS ? "\nInclude path: \"" + res.Filename + "\"" : "");
TreeNode scriptnode = new TreeNode(res.ToString(), iconindex, iconindex) { Tag = data, ToolTipText = data + includepath };

View file

@ -1831,8 +1831,7 @@ namespace CodeImp.DoomBuilder.Data
if(decorate.HasError)
{
decorate.LogError();
currentreader = null;
return counter;
break;
}
}
}
@ -2022,6 +2021,11 @@ namespace CodeImp.DoomBuilder.Data
}
}
}
else
{
// Return after adding parsed resources
return counter;
}
}
// Output info
@ -2375,6 +2379,8 @@ namespace CodeImp.DoomBuilder.Data
// Load gldefs from resources
foreach(DataReader dr in containers)
{
if(parser.HasError) break;
currentreader = dr;
parser.ClearIncludesList();
IEnumerable<TextResourceData> streams = dr.GetGldefsData(General.Map.Config.BaseGame);
@ -2387,8 +2393,7 @@ namespace CodeImp.DoomBuilder.Data
if(parser.HasError)
{
parser.LogError();
currentreader = null;
return;
break;
}
}
}
@ -2397,6 +2402,9 @@ namespace CodeImp.DoomBuilder.Data
scriptresources[parser.ScriptType] = new HashSet<ScriptResource>(parser.ScriptResources.Values);
currentreader = null;
//mxd. Abort on errors, but after adding parsed text resources
if(parser.HasError) return;
// Create Gldefs Entries dictionary
foreach(KeyValuePair<string, string> e in parser.Objects) //<ClassName, Light name>
{

View file

@ -508,12 +508,12 @@ namespace CodeImp.DoomBuilder.IO
// This finds a lump by name, returns -1 when not found
public int FindLumpIndex(string name, int start, int end)
{
if(name.Length > 8 || lumps.Count == 0) return -1; //mxd. Can't be here. Go away!
if(name.Length > 8 || lumps.Count == 0 || start > lumps.Count - 1) return -1; //mxd. Can't be here. Go away!
long longname = Lump.MakeLongName(name);
// Fix start/end when they exceed safe bounds
start = General.Clamp(start, 0, lumps.Count - 1);
start = Math.Max(start, 0);
end = General.Clamp(end, 0, lumps.Count - 1);
// Loop through the lumps

View file

@ -213,15 +213,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
int brightness = level.brightnessbelow;
//mxd. Apply lightfloor value
// According to Graf, this is incorrect behaviour...
// TECH: In (G)ZDoom, this is ignored when ceiling texture is sky or a thing is below a 3D floor
// It's probably more involved than this, but for now let's do it only when there are no 3d floors in Thing.Sector...
if(General.Map.UDMF && sd.LightLevels.Count == 2 && Thing.Sector.CeilTexture != General.Map.Config.SkyFlatName)
/*if(General.Map.UDMF && sd.LightLevels.Count == 2 && Thing.Sector.CeilTexture != General.Map.Config.SkyFlatName)
{
if(sd.Sector.Fields.GetValue("lightfloorabsolute", false))
brightness = UniFields.GetInteger(sd.Sector.Fields, "lightfloor");
else
brightness += UniFields.GetInteger(sd.Sector.Fields, "lightfloor");
}
}*/
// Level is glowing
if(level.affectedbyglow && level.type == SectorLevelType.Floor)

View file

@ -218,20 +218,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach(Sidedef side in level.sector.Sidedefs)
{
VisualSidedefParts parts = Sector.GetSidedefParts(side);
if(parts.upper != null) parts.upper.UpdateSkyRenderFlag();
else if(parts.middlesingle != null) parts.middlesingle.UpdateSkyRenderFlag();
// On the other side as well...
if(side.Other != null && side.Other.Sector != null &&
side.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName)
if(parts.upper != null)
{
BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector);
if(other != null && other.Sides != null)
parts.upper.UpdateSkyRenderFlag();
// On the other side as well...
if(side.Other != null && side.Other.Sector != null &&
(side.Other.HighTexture == "-" || side.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName))
{
parts = other.GetSidedefParts(side.Other);
if(parts.upper != null) parts.upper.UpdateSkyRenderFlag();
BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector);
if(other != null && other.Sides != null)
{
parts = other.GetSidedefParts(side.Other);
if(parts.upper != null) parts.upper.UpdateSkyRenderFlag();
}
}
}
else if(parts.middlesingle != null)
{
parts.middlesingle.UpdateSkyRenderFlag();
}
}
}
}

View file

@ -198,11 +198,30 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderassky = (level.sector.FloorTexture == General.Map.Config.SkyFlatName || level.sector.LongFloorTexture == MapSet.EmptyLongName);
if(isrenderedassky != renderassky && Sector.Sides != null)
{
// Middle geometry may need updating...
// Middle/Lower geometry may need updating...
foreach(Sidedef side in level.sector.Sidedefs)
{
VisualSidedefParts parts = Sector.GetSidedefParts(side);
if(parts.middlesingle != null) parts.middlesingle.UpdateSkyRenderFlag();
if(parts.lower != null)
{
parts.lower.UpdateSkyRenderFlag();
// On the other side as well...
if(side.Other != null && side.Other.Sector != null &&
(side.Other.LowTexture == "-" || side.Other.Sector.FloorTexture == General.Map.Config.SkyFlatName))
{
BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector);
if(other != null && other.Sides != null)
{
parts = other.GetSidedefParts(side.Other);
if(parts.lower != null) parts.lower.UpdateSkyRenderFlag();
}
}
}
else if(parts.middlesingle != null)
{
parts.middlesingle.UpdateSkyRenderFlag();
}
}
}
}

View file

@ -62,6 +62,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
Vector2D vl, vr;
//mxd. Apply sky hack?
UpdateSkyRenderFlag();
//mxd. lightfog flag support
int lightvalue;
bool lightabsolute;
@ -206,6 +209,28 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.SetVertices(null); //mxd
return false;
}
//mxd
internal void UpdateSkyRenderFlag()
{
bool isdoublesided = (Sidedef.Other != null && Sidedef.Sector != null && Sidedef.Other.Sector != null);
//TECH: when a side part has no texture, sky hack will be applied when either front or back sectors' floor uses SkyFlatName texture
//TECH: this glitches in both ZDoom and GZDoom when only lower sector's floor has SkyFlatName
if(Sidedef.LowTexture == "-")
{
renderassky = (isdoublesided
&& (Sidedef.Sector.FloorTexture == General.Map.Config.SkyFlatName
|| Sidedef.Other.Sector.FloorTexture == General.Map.Config.SkyFlatName));
}
//TECH: otherwise, sky hack will be applied when both front and back sector floors use SkyFlatName texture
else
{
renderassky = (isdoublesided
&& Sidedef.Sector.FloorTexture == General.Map.Config.SkyFlatName
&& Sidedef.Other.Sector.FloorTexture == General.Map.Config.SkyFlatName);
}
}
#endregion

View file

@ -204,9 +204,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd
internal void UpdateSkyRenderFlag()
{
renderassky = (Sidedef.Other != null && Sidedef.Sector != null && Sidedef.Other.Sector != null &&
Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName &&
Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName);
bool isdoublesided = (Sidedef.Other != null && Sidedef.Sector != null && Sidedef.Other.Sector != null);
//TECH: when a side part has no texture, sky hack will be applied when either front or back sectors' ceiling uses SkyFlatName texture
//TECH: this glitches in both ZDoom and GZDoom when only higher sector's ceiling has SkyFlatName
if(Sidedef.HighTexture == "-")
{
renderassky = (isdoublesided
&& (Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName
|| Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName));
}
//TECH: otherwise, sky hack will be applied when both front and back sector ceilings use SkyFlatName texture
else
{
renderassky = (isdoublesided
&& Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName
&& Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName);
}
}
#endregion