Skip to content

Commit

Permalink
WIP Locale support
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlamin committed Jan 25, 2020
1 parent 7fa8c64 commit 347b390
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
31 changes: 29 additions & 2 deletions DBCDumpHost/Controllers/DataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public string Get()

// GET/POST: data/name
[HttpGet("{name}"), HttpPost("{name}")]
public async Task<DataTablesResult> Get(string name, string build, int draw, int start, int length, bool useHotfixes = false)
public async Task<DataTablesResult> Get(string name, string build, int draw, int start, int length, bool useHotfixes = false, LocaleFlags locale = LocaleFlags.All_WoW)
{
var searching = false;

Expand Down Expand Up @@ -97,7 +97,7 @@ public async Task<DataTablesResult> Get(string name, string build, int draw, int

try
{
var storage = await dbcManager.GetOrLoad(name, build, useHotfixes);
var storage = await dbcManager.GetOrLoad(name, build, useHotfixes, locale);

if (storage == null)
{
Expand Down Expand Up @@ -306,4 +306,31 @@ public async Task<DataTablesResult> Get(string name, string build, int draw, int
return result;
}
}

[Flags]
public enum LocaleFlags : uint
{
All = 0xFFFFFFFF,
None = 0,
//Unk_1 = 0x1,
enUS = 0x2,
koKR = 0x4,
//Unk_8 = 0x8,
frFR = 0x10,
deDE = 0x20,
zhCN = 0x40,
esES = 0x80,
zhTW = 0x100,
enGB = 0x200,
enCN = 0x400,
enTW = 0x800,
esMX = 0x1000,
ruRU = 0x2000,
ptBR = 0x4000,
itIT = 0x8000,
ptPT = 0x10000,
enSG = 0x20000000, // custom
plPL = 0x40000000, // custom
All_WoW = enUS | koKR | frFR | deDE | zhCN | esES | zhTW | enGB | esMX | ruRU | ptBR | itIT | ptPT
}
}
10 changes: 8 additions & 2 deletions DBCDumpHost/Services/DBCManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DBCD;
using DBCD.Providers;
using DBCDumpHost.Controllers;
using DBCDumpHost.Utils;
using Microsoft.Extensions.Caching.Memory;
using System;
Expand Down Expand Up @@ -31,7 +32,7 @@ public async Task<IDBCDStorage> GetOrLoad(string name, string build)
return await GetOrLoad(name, build, false);
}

public async Task<IDBCDStorage> GetOrLoad(string name, string build, bool useHotfixes = false)
public async Task<IDBCDStorage> GetOrLoad(string name, string build, bool useHotfixes = false, LocaleFlags locale = LocaleFlags.All_WoW)
{
if (!Cache.TryGetValue((name, build, useHotfixes), out IDBCDStorage cachedDBC))
{
Expand All @@ -46,7 +47,12 @@ public async Task<IDBCDStorage> GetOrLoad(string name, string build, bool useHot
// Key not in cache, load DBC
Logger.WriteLine("DBC " + name + " for build " + build + " (hotfixes: " + useHotfixes + ") is not cached, loading!");
cachedDBC = LoadDBC(name, build, useHotfixes);
Cache.Set((name, build, useHotfixes), cachedDBC, new MemoryCacheEntryOptions().SetSize(1));

// Only cache non-specific locale DB2s for now
if(locale == LocaleFlags.All_WoW)
{
Cache.Set((name, build, useHotfixes), cachedDBC, new MemoryCacheEntryOptions().SetSize(1));
}
}
}
finally
Expand Down

0 comments on commit 347b390

Please sign in to comment.