public static void WriteViewIds(ServerDbs dbSource, AbstractDb <int> db) { if (ProjectConfiguration.SynchronizeWithClientDatabases && dbSource == ServerDbs.Items && ProjectConfiguration.HandleViewIds) { //return; int debugInfo = 0; _debugStatus = "OK"; var dataAccId = db.ProjectDatabase.MetaGrf.GetData(ProjectConfiguration.SyncAccId); var dataAccName = db.ProjectDatabase.MetaGrf.GetData(ProjectConfiguration.SyncAccName); if (dataAccId != null && dataAccName != null) { var itemDb1 = db.Get <int>(ServerDbs.Items); var itemDb2 = db.Get <int>(ServerDbs.Items2); var citemDb = db.Get <int>(ServerDbs.CItems); debugInfo++; try { itemDb1.Commands.Begin(); itemDb2.Commands.Begin(); citemDb.Commands.Begin(); debugInfo++; AccessoryTable table = new AccessoryTable(db, dataAccId, dataAccName); table.SetLuaTables(); table.SetTables(); table.SetDbs(); _debugStatus = "BackupManager"; BackupEngine.Instance.BackupClient(ProjectConfiguration.SyncAccId, db.ProjectDatabase.MetaGrf.GetData(ProjectConfiguration.SyncAccId)); BackupEngine.Instance.BackupClient(ProjectConfiguration.SyncAccName, db.ProjectDatabase.MetaGrf.GetData(ProjectConfiguration.SyncAccName)); debugInfo++; _debugStatus = "WriteLuaFiles"; _writeLuaFiles(table.LuaAccIdParser, table.LuaAccNameParser, db); debugInfo++; } catch (Exception err) { ErrorHandler.HandleException("Couldn't save the accessory item files. Error code = " + debugInfo + ", state = " + _debugStatus, err, ErrorLevel.Low); DbIOErrorHandler.Handle(err, "Generic exception while trying to save the client accessory items, debug code = " + debugInfo, ErrorLevel.NotSpecified); DbIOErrorHandler.Focus(); } finally { itemDb1.Commands.End(); itemDb2.Commands.End(); citemDb.Commands.End(); } } } }
public AccessoryTable(AbstractDb <int> db, byte[] dataAccId, byte[] dataAccName) { // Load current tables as fallback values ItemIdToSprite = LuaHelper.GetRedirectionTable(); _itemDb = db.GetMeta <int>(ServerDbs.Items); _cItemDb = db.Get <int>(ServerDbs.CItems); LuaAccIdParser = new LuaParser(dataAccId, true, p => new Lub(p).Decompile(), EncodingService.DetectEncoding(dataAccId), EncodingService.DisplayEncoding); LuaAccNameParser = new LuaParser(dataAccName, true, p => new Lub(p).Decompile(), EncodingService.DetectEncoding(dataAccName), EncodingService.DisplayEncoding); LuaAccId = LuaHelper.GetLuaTable(LuaAccIdParser, "ACCESSORY_IDs"); LuaAccName = LuaHelper.GetLuaTable(LuaAccNameParser, "AccNameTable"); _viewIdToSpriteFallback = GetViewIdTableFallback(LuaAccId, LuaAccName); _headgears = _itemDb.FastItems.Where(p => ItemParser.IsArmorType(p) && (p.GetIntNoThrow(ServerItemAttributes.Location) & 7937) != 0).OrderBy(p => p.GetIntNoThrow(ServerItemAttributes.ClassNumber)).ToList(); LuaAccId.Clear(); LuaAccName.Clear(); }