Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,7 @@ paket-files/

# Visual Studio Code
.vscode

CASCHost/*.db3
CASCHost/listfile.csv
HttpProxy/logs/
7 changes: 6 additions & 1 deletion CASCEdit/CASCEdit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net471|AnyCPU'">
<PropertyGroup>
<Optimize>true</Optimize>
</PropertyGroup>

<PropertyGroup>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<None Remove="ZLib\License.txt" />
</ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions CASCEdit/CASContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ public static void Open(CASSettings settings)
if (BuildInfo["Version"] != Settings.Cache?.Version)
{
Settings.Cache?.Clean();
LoadBuildInfo(Settings.SystemFilesPath);
LoadBuildInfo(Settings.BuildInfoPath);
}
else
{
Settings.SystemFilesPath = Settings.OutputPath; //Update system path to latest output build
}
}
else if (File.Exists(Path.Combine(settings.SystemFilesPath, ".build.info")))
else if (File.Exists(Path.Combine(Settings.BuildInfoPath, ".build.info")))
{
LoadBuildInfo(Settings.SystemFilesPath);
LoadBuildInfo(Settings.BuildInfoPath);
}
else
{
Expand Down Expand Up @@ -99,7 +99,8 @@ private static void LoadBuildInfo(string path)
return;
}

BuildInfo = new SingleConfig(buildInfoPath, "Active", "1");
Logger.LogInformation($"Loading build info for {Settings.Product}");
BuildInfo = new SingleConfig(buildInfoPath, "Active", "1", Settings.Product);
}

private static void LoadBuildConfig()
Expand Down
5 changes: 5 additions & 0 deletions CASCEdit/CASSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class CASSettings
public bool Basic { get; set; } = false;
public string BasePath { get; set; }
public string SystemFilesPath { get; set; }
public string BuildInfoPath { get; set; }
public string OutputPath { get; set; }
public string PatchUrl { get; set; }
public string Host { get; set; }
Expand All @@ -23,6 +24,7 @@ public class CASSettings
public LocaleFlags Locale { get; set; } = LocaleFlags.enUS;
public bool StaticMode { get; set; } = false;

public string Product { get; set; }

public HashSet<string> DownloadLocations { get; set; }
public HashSet<string> CDNs { get; set; }
Expand All @@ -38,6 +40,9 @@ public void Format()
SystemFilesPath = BasePath;
else if (!Directory.Exists(SystemFilesPath))
SystemFilesPath = Path.Combine(BasePath, SystemFilesPath);

if (!Directory.Exists(BuildInfoPath))
BuildInfoPath = Path.Combine(BasePath, BuildInfoPath);
}
}
}
22 changes: 18 additions & 4 deletions CASCEdit/Configs/SingleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CASCEdit.Handlers;
using CASCEdit.IO;

namespace CASCEdit.Configs
Expand All @@ -15,6 +13,7 @@ public class SingleConfig
private List<string> Lines;
private string BaseFile;
private string NewLineChar;
private string productCode;

public string this[string key]
{
Expand All @@ -26,11 +25,14 @@ public string this[string key]
}
}

public SingleConfig(string file, string key, string value)
public SingleConfig(string file, string key, string value, string product = null)
{
BaseFile = file;
productCode = product;


Stream stream;

Stream stream;

if (Uri.IsWellFormedUriString(file, UriKind.Absolute)) // URLs require streaming
{
Expand Down Expand Up @@ -123,6 +125,18 @@ private void Parse(BinaryReader reader, string key, string value)
}
else
{

if (Path.GetFileNameWithoutExtension(BaseFile) == ".build")
{
// ignore non-relevant product entry in .build.info
int productidx = fields.IndexOf("Product");
if (productidx >= 0 && tokens[productidx] != productCode)
{
Lines.RemoveAt(i--);
continue;
}
}

// ignore lines not matching the indentifier key value
int keyidx = fields.IndexOf(key);
if (keyidx >= 0 && tokens[keyidx] != value)
Expand Down
28 changes: 22 additions & 6 deletions CASCEdit/Handlers/RootHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class RootHandler : IDisposable

public RootHandler()
{
GlobalRoot = new RootChunk() { ContentFlags = ContentFlags.None, LocaleFlags = LocaleFlags.All_WoW };
GlobalRoot = new RootChunk() { ContentFlags = ContentFlags.None, LocaleFlags = LocaleFlags.All_WoW, Count = 0 };
encodingMap = new EncodingMap(EncodingType.ZLib, 9);
}

Expand All @@ -47,7 +47,7 @@ public RootHandler(Stream data, LocaleFlags locale, uint minimumid = 0, bool onl
this.locale = locale;
string cdnPath = Helper.GetCDNPath("listfile.csv");

if (!(File.Exists(Path.Combine(CASContainer.Settings.OutputPath, cdnPath))) && onlineListfile)
if (!(File.Exists(cdnPath)) && onlineListfile)
{
CASContainer.Logger.LogInformation("Downloading listfile from WoW.Tools");
ListFileClient.DownloadFile("https://wow.tools/casc/listfile/download/csv/unverified", cdnPath);
Expand All @@ -65,7 +65,7 @@ public RootHandler(Stream data, LocaleFlags locale, uint minimumid = 0, bool onl
}
else
{
stream.BaseStream.Position = 0;
stream.BaseStream.Position -= 4;
}

long length = stream.BaseStream.Length;
Expand All @@ -80,9 +80,25 @@ public RootHandler(Stream data, LocaleFlags locale, uint minimumid = 0, bool onl

parsedFiles += (int)chunk.Count;

// set the global root
if (chunk.LocaleFlags == LocaleFlags.All_WoW && chunk.ContentFlags == ContentFlags.None)
GlobalRoot = chunk;
//Console.WriteLine("Chunk: {0} {1} (size {2})", chunk.ContentFlags, chunk.LocaleFlags, chunk.Count);

// set the global root if not already set
if (GlobalRoot == null)
{
if (chunk.LocaleFlags == LocaleFlags.All_WoW && chunk.ContentFlags == ContentFlags.F00080000)
{
GlobalRoot = chunk;
}
else if (chunk.LocaleFlags == LocaleFlags.All_WoW_Classic && chunk.ContentFlags == ContentFlags.None)
{
GlobalRoot = chunk;
}

if (GlobalRoot != null)
{
CASContainer.Logger.LogInformation($"Global root found. Flags: {chunk.ContentFlags}, {chunk.LocaleFlags}. Count: {chunk.Count}");
}
}

uint fileDataIndex = 0;
for (int i = 0; i < chunk.Count; i++)
Expand Down
31 changes: 22 additions & 9 deletions CASCEdit/Structs/RootStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,36 @@ public enum LocaleFlags : uint
ptBR = 0x4000,
itIT = 0x8000,
ptPT = 0x10000,
All_WoW = enUS | koKR | frFR | deDE | zhCN | esES | zhTW | enGB | esMX | ruRU | ptBR | itIT | ptPT
All_WoW = enUS | koKR | frFR | deDE | zhCN | esES | zhTW | enGB | esMX | ruRU | ptBR | itIT | ptPT,
All_WoW_Classic = enUS | koKR | frFR | deDE | zhCN | esES | zhTW | enGB | esMX | ruRU | ptBR | ptPT
}

[Flags]
public enum ContentFlags : uint
{
None = 0,
F00000001 = 0x1,
F00000001 = 0x1, // seen on *.wlm files
F00000002 = 0x2,
F00000004 = 0x4,
F00000008 = 0x8, // added in 7.2.0.23436
F00000010 = 0x10, // added in 7.2.0.23436
LowViolence = 0x80, // many models have this flag
NoNames = 0x10000000,
F20000000 = 0x20000000, // added in 21737
Bundle = 0x40000000,
NoCompression = 0x80000000 // sounds have this flag
Windows = 0x8, // added in 7.2.0.23436
MacOS = 0x10, // added in 7.2.0.23436
Alternate = 0x80, // many chinese models have this flag
F00000100 = 0x100, // apparently client doesn't load files with this flag
F00000800 = 0x800, // only seen on UpdatePlugin files
F00020000 = 0x20000, // new 9.0
F00040000 = 0x40000, // new 9.0
F00080000 = 0x80000, // new 9.0
F00100000 = 0x100000, // new 9.0
F00200000 = 0x200000, // new 9.0
F00400000 = 0x400000, // new 9.0
F00800000 = 0x800000, // new 9.0
F02000000 = 0x2000000, // new 9.0
F04000000 = 0x4000000, // new 9.0
Encrypted = 0x8000000, // encrypted may be?
NoNameHash = 0x10000000, // doesn't have name hash?
F20000000 = 0x20000000, // added in 21737, used for many cinematics
Bundle = 0x40000000, // not related to wow, used as some old overwatch hack
NotCompressed = 0x80000000 // sounds have this flag
}

public class RootChunk
Expand Down
18 changes: 12 additions & 6 deletions CASCHost/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@ namespace CASCHost
public class AppSettings
{
public uint MinimumFileDataId { get; set; } // the minimum file id for new files
public bool OnlineListFile { get; set; } = false; // fetchs from WoW.Tools the lastest listfile
public bool OnlineListFile { get; set; } = true; // fetchs from WoW.Tools the lastest listfile
public bool BNetAppSupport { get; set; } = false; // create install and download files?
public bool StaticMode { get; set; } = false; // Build CDN file struct
public string RebuildPassword { get; set; } = "";

public string HostDomain { get; set; } // accessible address of this server
public string GameDirectory { get; set; } = "";

public string Product { get; set; } = "wow";
public string SqliteDatabase { get; set; } = "caschost.db3";

public string HostDomain { get; set; } // accessible address of this server
public string[] CDNs { get; set; } // custom CDNs i.e. local client CASC archive clone
public string SqlConnection { get; set; } // database connection string
public string PatchUrl { get; set; } // offical blizzard patch url i.e. http://us.patch.battle.net:1119
public string Locale { get; set; } // preferred locale for content

public string[] DirectoryHash { get; set; } // hashes of directories for offline change detection

public void Save(IHostingEnvironment env)

public string GameVersion { get; set; } = ""; // Game version the cdn was built for

public void Save(IHostingEnvironment env)
{
if (CDNs == null)
CDNs = new string[0];
Expand All @@ -35,7 +41,7 @@ public void Save(IHostingEnvironment env)
var obj = new ExpandoObject() as IDictionary<string, Object>;
obj.Add(GetType().Name, this);

using (FileStream fs = new FileStream(Path.Combine(env.ContentRootPath, "appsettings.json"), FileMode.Create, FileAccess.Write, FileShare.Read))
using (FileStream fs = new FileStream(Path.Combine(env.ContentRootPath, $"appsettings.{Product}.json"), FileMode.Create, FileAccess.Write, FileShare.Read))
using (StreamWriter sw = new StreamWriter(fs))
{
sw.Write(JsonConvert.SerializeObject(obj, Formatting.Indented));
Expand Down
30 changes: 26 additions & 4 deletions CASCHost/CASCHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,43 @@
<StartupObject />
</PropertyGroup>

<PropertyGroup>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<Compile Remove="wwwroot\**" />
<Content Remove="wwwroot\**" />
<EmbeddedResource Remove="wwwroot\**" />
<None Remove="wwwroot\**" />
</ItemGroup>

<ItemGroup>
<Content Remove="wwwroot/Data" />
<Content Remove="wwwroot/Output" />
<Content Remove="wwwroot\SystemFiles\.build.info" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
<PackageReference Include="MySqlConnector" Version="0.42.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="System.Data.SQLite" Version="1.0.113.5" />
</ItemGroup>

<ItemGroup>
<Content Update="appsettings.json">
<Content Update="appsettings.wow.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="hosting.json">
<Content Update="hosting.wow.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.wow_classic.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="hosting.wow_classic.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand All @@ -35,7 +54,10 @@
</ItemGroup>

<ItemGroup>
<None Update="Start.bat">
<None Update="Start Retail.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Start Classic.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
Loading