Core/DataStorage: Fix loading all locale strings when not needed. More work to come on DataStorage system
This commit is contained in:
@@ -23,6 +23,7 @@ using Framework.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
|
||||
namespace Game.DataStorage
|
||||
{
|
||||
@@ -38,7 +39,7 @@ namespace Game.DataStorage
|
||||
[Serializable]
|
||||
public class DB6Storage<T> : Dictionary<uint, T>, IDB2Storage where T : new()
|
||||
{
|
||||
public void LoadData(int indexField, HotfixStatements preparedStatement, HotfixStatements preparedStatementLocale)
|
||||
public void LoadData(int indexField, BitSet availableDb2Locales, HotfixStatements preparedStatement, HotfixStatements preparedStatementLocale)
|
||||
{
|
||||
SQLResult result = DB.Hotfix.Query(DB.Hotfix.GetPreparedStatement(preparedStatement));
|
||||
if (!result.IsEmpty())
|
||||
@@ -193,7 +194,7 @@ namespace Game.DataStorage
|
||||
|
||||
for (Locale locale = 0; locale < Locale.Total; ++locale)
|
||||
{
|
||||
if (Global.WorldMgr.GetDefaultDbcLocale() == locale || locale == Locale.None)
|
||||
if (Global.WorldMgr.GetDefaultDbcLocale() == locale || !availableDb2Locales[(int)locale])
|
||||
continue;
|
||||
|
||||
PreparedStatement stmt = DB.Hotfix.GetPreparedStatement(preparedStatementLocale);
|
||||
|
||||
@@ -27,26 +27,26 @@ using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
|
||||
namespace Game.DataStorage
|
||||
{
|
||||
class DBReader
|
||||
{
|
||||
private const int HeaderSize = 72;
|
||||
private const uint WDC3FmtSig = 0x33434457; // WDC3
|
||||
|
||||
public static DB6Storage<T> Read<T>(string fileName, HotfixStatements preparedStatement, HotfixStatements preparedStatementLocale = 0) where T : new()
|
||||
public static DB6Storage<T> Read<T>(BitSet availableDb2Locales, string db2Path, string fileName, HotfixStatements preparedStatement, HotfixStatements preparedStatementLocale, ref uint loadedFileCount) where T : new()
|
||||
{
|
||||
DB6Storage<T> storage = new DB6Storage<T>();
|
||||
|
||||
if (!File.Exists(CliDB.DataPath + fileName))
|
||||
if (!File.Exists(db2Path + fileName))
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, $"File {fileName} not found.");
|
||||
return storage;
|
||||
}
|
||||
|
||||
DBReader reader = new DBReader();
|
||||
using (var stream = new FileStream(CliDB.DataPath + fileName, FileMode.Open))
|
||||
using (var stream = new FileStream(db2Path + fileName, FileMode.Open))
|
||||
{
|
||||
if (!reader.Load(stream))
|
||||
{
|
||||
@@ -58,10 +58,10 @@ namespace Game.DataStorage
|
||||
foreach (var b in reader._records)
|
||||
storage.Add((uint)b.Key, b.Value.As<T>());
|
||||
|
||||
storage.LoadData(reader.Header.IdIndex, preparedStatement, preparedStatementLocale);
|
||||
storage.LoadData(reader.Header.IdIndex, availableDb2Locales, preparedStatement, preparedStatementLocale);
|
||||
|
||||
Global.DB2Mgr.AddDB2(reader.Header.TableHash, storage);
|
||||
CliDB.LoadedFileCount++;
|
||||
loadedFileCount++;
|
||||
return storage;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@ namespace Game.DataStorage
|
||||
{
|
||||
public class GameTableReader
|
||||
{
|
||||
internal static GameTable<T> Read<T>(string fileName) where T : new()
|
||||
internal static GameTable<T> Read<T>(string path, string fileName, ref uint loadedFileCount) where T : new()
|
||||
{
|
||||
GameTable<T> storage = new GameTable<T>();
|
||||
|
||||
if (!File.Exists(CliDB.DataPath + fileName))
|
||||
if (!File.Exists(path + fileName))
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, "File {0} not found.", fileName);
|
||||
return storage;
|
||||
}
|
||||
using (var reader = new StreamReader(CliDB.DataPath + fileName))
|
||||
using (var reader = new StreamReader(path + fileName))
|
||||
{
|
||||
string headers = reader.ReadLine();
|
||||
if (headers.IsEmpty())
|
||||
@@ -73,7 +73,7 @@ namespace Game.DataStorage
|
||||
storage.SetData(data);
|
||||
}
|
||||
|
||||
CliDB.LoadedFileCount++;
|
||||
loadedFileCount++;
|
||||
return storage;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user