mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* Changing configuration file format to JavaScript instead of JSON for the ability to embed comments, Backwards compatible, ACE.Server project pre-build renames Config.json to Config.js when needed, but if that never happens it's still OK and falls back to the old filename. Changed startup batch files to determine what the current directory should be and change to it before starting ACE * fixed * move config old to new filename upon program start
77 lines
3.3 KiB
C#
77 lines
3.3 KiB
C#
using System.IO;
|
|
|
|
using log4net;
|
|
|
|
namespace ACE.DatLoader
|
|
{
|
|
public static class DatManager
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
private static string datFile;
|
|
|
|
private static int count;
|
|
|
|
public static CellDatDatabase CellDat { get; private set; }
|
|
|
|
public static PortalDatDatabase PortalDat { get; private set; }
|
|
public static DatDatabase HighResDat { get; private set; }
|
|
public static LanguageDatDatabase LanguageDat { get; private set; }
|
|
|
|
public static void Initialize(string datFileDirectory, bool keepOpen = false, bool loadCell = true)
|
|
{
|
|
var datDir = Path.GetFullPath(Path.Combine(datFileDirectory));
|
|
|
|
if (loadCell)
|
|
{
|
|
try
|
|
{
|
|
datFile = Path.Combine(datDir, "client_cell_1.dat");
|
|
CellDat = new CellDatDatabase(datFile, keepOpen);
|
|
count = CellDat.AllFiles.Count;
|
|
log.Info($"Successfully opened {datFile} file, containing {count} records");
|
|
}
|
|
catch (FileNotFoundException ex)
|
|
{
|
|
log.Info($"An exception occured while attempting to open {datFile} file! This needs to be corrected in order for Landblocks to load!");
|
|
log.Info($"Exception: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
try
|
|
{
|
|
datFile = Path.Combine(datDir, "client_portal.dat");
|
|
PortalDat = new PortalDatDatabase(datFile, keepOpen);
|
|
count = PortalDat.AllFiles.Count;
|
|
log.Info($"Successfully opened {datFile} file, containing {count} records");
|
|
}
|
|
catch (FileNotFoundException ex)
|
|
{
|
|
log.Info($"An exception occured while attempting to open {datFile} file!\n\n *** Please check your 'DatFilesDirectory' setting in the config.js file. ***\n *** ACE will not run properly without this properly configured! ***\n");
|
|
log.Info($"Exception: {ex.Message}");
|
|
}
|
|
|
|
// Load the client_highres.dat file. This is not required for ACE operation, so no exception needs to be generated.
|
|
datFile = Path.Combine(datDir, "client_highres.dat");
|
|
if (File.Exists(datFile))
|
|
{
|
|
HighResDat = new DatDatabase(datFile, keepOpen);
|
|
count = HighResDat.AllFiles.Count;
|
|
log.Info($"Successfully opened {datFile} file, containing {count} records");
|
|
}
|
|
|
|
try
|
|
{
|
|
datFile = Path.Combine(datDir, "client_local_English.dat");
|
|
LanguageDat = new LanguageDatDatabase(datFile, keepOpen);
|
|
count = LanguageDat.AllFiles.Count;
|
|
log.Info($"Successfully opened {datFile} file, containing {count} records");
|
|
}
|
|
catch (FileNotFoundException ex)
|
|
{
|
|
log.Info($"An exception occured while attempting to open {datFile} file!\n\n *** Please check your 'DatFilesDirectory' setting in the config.json file. ***\n *** ACE will not run properly without this properly configured! ***\n");
|
|
log.Info($"Exception: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|