Skip to content

Commit

Permalink
Improve WDT locating
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlamin committed Dec 1, 2024
1 parent 5e984f8 commit 7614518
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions MapUpconverter/WDT/RootWDT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ public static class RootWDT
{
public static Warcraft.NET.Files.WDT.Root.WotLK.WorldDataTable GenerateLegion()
{
var wotlkWDTPath = Path.Combine(Settings.InputDir, Settings.MapName + ".wdt");
var wotlkFlags = new MPHDFlags();
var wdtResults = Directory.GetFiles(Settings.InputDir, Settings.MapName + ".wdt", SearchOption.AllDirectories);
if(wdtResults.Length == 0)
Console.WriteLine("No input WDT found for map " + Settings.MapName + ", using default flags.");

var wotlkWDTPath = wdtResults.FirstOrDefault();
var wotlkWDTExists = File.Exists(wotlkWDTPath);
Warcraft.NET.Files.WDT.Root.WotLK.WorldDataTable wotlkWDT = new();
var wotlkFlags = new MPHDFlags();

if (wotlkWDTExists)
{
Expand All @@ -30,7 +34,6 @@ public static Warcraft.NET.Files.WDT.Root.WotLK.WorldDataTable GenerateLegion()
WorldModelObjectPlacementInfo = new Warcraft.NET.Files.ADT.Chunks.MODF(),
};


rootWDT.Header.Flags = wotlkFlags | MPHDFlags.hasHeightTexturing;

for (byte x = 0; x < 64; x++)
Expand All @@ -56,17 +59,20 @@ public static Warcraft.NET.Files.WDT.Root.WotLK.WorldDataTable GenerateLegion()
rootWDT.Tiles.Entries[x, y].AsyncId = wotlkWDT.Tiles.Entries[x, y].AsyncId;
}
}
// }
}
return rootWDT;
}

public static Warcraft.NET.Files.WDT.Root.BfA.WorldDataTable Generate()
{
var wotlkWDTPath = Path.Combine(Settings.InputDir, Settings.MapName + ".wdt");
var wotlkFlags = new MPHDFlags();
var wdtResults = Directory.GetFiles(Settings.InputDir, Settings.MapName + ".wdt", SearchOption.AllDirectories);
if (wdtResults.Length == 0)
Console.WriteLine("No input WDT found for map " + Settings.MapName + ", using default flags.");

var wotlkWDTPath = wdtResults.FirstOrDefault();
var wotlkWDTExists = File.Exists(wotlkWDTPath);
Warcraft.NET.Files.WDT.Root.BfA.WorldDataTable wotlkWDT = new();
var wotlkFlags = new MPHDFlags();

if (wotlkWDTExists)
{
Expand All @@ -76,21 +82,6 @@ public static Warcraft.NET.Files.WDT.Root.BfA.WorldDataTable Generate()

var currentWDTPath = Path.Combine(ExportHelper.GetExportDirectory(), "world", "maps", Settings.MapName, Settings.MapName + ".wdt");

//if (File.Exists(currentWDTPath))
//{
// rootWDT = new Warcraft.NET.Files.WDT.Root.BfA.WorldDataTable(File.ReadAllBytes(currentWDTPath));
//}
//else
//{
// We need to generate an entirely new WDT, oh dear.
//Console.ForegroundColor = ConsoleColor.Red;
//if (wotlkWDTExists)
// Console.WriteLine("Generating WDT based on WotLK input WDT. This is not fully implemented yet, and will not work as expected.");
//else
// Console.WriteLine("Generating an entirely new WDT. This is not fully implemented yet, and will not work as expected.");

//Console.ResetColor();

var rootWDT = new Warcraft.NET.Files.WDT.Root.BfA.WorldDataTable()
{
Version = new Warcraft.NET.Files.WDT.Chunks.MVER(18),
Expand Down Expand Up @@ -175,7 +166,6 @@ public static Warcraft.NET.Files.WDT.Root.BfA.WorldDataTable Generate()
MinimapTextureFileId = hasMinimapTexture ? GetOrAssignFileDataID("world/minimaps/" + Settings.MapName + "/map" + x.ToString().PadLeft(2, '0') + "_" + y.ToString().PadLeft(2, '0') + ".blp") : 0
};
}
// }
}

return rootWDT;
Expand Down

0 comments on commit 7614518

Please sign in to comment.