ace/Source/ACE.DatLoader/DatManager.cs
Mag-nus 4d650bc8f9
Cleanup log.Info level messages (#2217)
* Cleanup log.Info level messages

Log.info is the default console output and is intended for:
server startup
connection/disconnections
admin initiated command output
server shutdown

Log.Debug is the appropriate level for debug-type messages that are to be logged and audited at a later date, but not output to the console.

* Missed a couple

* Move HandleSalvaging from Warn to Debug

* Add some tags

* Couple more

* remove space between tags

* Update the log4net examples

* fix message

* Add requested tags

* more tags
2019-08-30 19:25:35 -05:00

78 lines
3.4 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.Error($"An exception occured while attempting to open {datFile} file! This needs to be corrected in order for Landblocks to load!");
log.Error($"Exception: {ex.Message}");
}
}
try
{
datFile = Path.Combine(datDir, "client_portal.dat");
PortalDat = new PortalDatDatabase(datFile, keepOpen);
PortalDat.SkillTable.AddRetiredSkills();
count = PortalDat.AllFiles.Count;
log.Info($"Successfully opened {datFile} file, containing {count} records");
}
catch (FileNotFoundException ex)
{
log.Error($"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.Error($"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.Error($"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.Error($"Exception: {ex.Message}");
}
}
}
}