Fixes a crash in server startup.

This commit is contained in:
hondacrx
2021-01-02 12:09:30 -05:00
parent dec28bdeb7
commit 25be69e859
2 changed files with 14 additions and 15 deletions
+8 -9
View File
@@ -691,7 +691,7 @@ namespace Game.DataStorage
return; return;
} }
Dictionary<Tuple<uint, int>, bool> deletedRecords = new Dictionary<Tuple<uint, int>, bool>(); Dictionary<(uint tableHash, int recordId), bool> deletedRecords = new Dictionary<(uint tableHash, int recordId), bool>();
uint count = 0; uint count = 0;
do do
@@ -702,8 +702,7 @@ namespace Game.DataStorage
bool deleted = result.Read<bool>(3); bool deleted = result.Read<bool>(3);
if (!deleted && !_storage.ContainsKey(tableHash)) if (!deleted && !_storage.ContainsKey(tableHash))
{ {
var key = Tuple.Create(tableHash, recordId); if (!_hotfixBlob.Any(p => p.ContainsKey((tableHash, recordId))))
if (!_hotfixBlob.Any(p => p.ContainsKey(key)))
{ {
Log.outError(LogFilter.Sql, $"Table `hotfix_data` references unknown DB2 store by hash 0x{tableHash:X} and has no reference to `hotfix_blob` in hotfix id {id} with RecordID: {recordId}"); Log.outError(LogFilter.Sql, $"Table `hotfix_data` references unknown DB2 store by hash 0x{tableHash:X} and has no reference to `hotfix_blob` in hotfix id {id} with RecordID: {recordId}");
continue; continue;
@@ -715,7 +714,7 @@ namespace Game.DataStorage
hotfixRecord.RecordID = recordId; hotfixRecord.RecordID = recordId;
hotfixRecord.HotfixID = id; hotfixRecord.HotfixID = id;
_hotfixData.Add(hotfixRecord); _hotfixData.Add(hotfixRecord);
deletedRecords[Tuple.Create(tableHash, recordId)] = deleted; deletedRecords[(tableHash, recordId)] = deleted;
++count; ++count;
} while (result.NextRow()); } while (result.NextRow());
@@ -724,9 +723,9 @@ namespace Game.DataStorage
{ {
if (itr.Value) if (itr.Value)
{ {
var store = _storage.LookupByKey(itr.Key.Item1); var store = _storage.LookupByKey(itr.Key.tableHash);
if (store != null) if (store != null)
store.EraseRecord((uint)itr.Key.Item2); store.EraseRecord((uint)itr.Key.recordId);
} }
} }
@@ -859,7 +858,7 @@ namespace Game.DataStorage
{ {
Cypher.Assert(SharedConst.IsValidLocale(locale), "Locale {locale} is invalid locale"); Cypher.Assert(SharedConst.IsValidLocale(locale), "Locale {locale} is invalid locale");
return _hotfixBlob[(int)locale].LookupByKey(Tuple.Create(tableHash, recordId)); return _hotfixBlob[(int)locale].LookupByKey((tableHash, recordId));
} }
public List<HotfixOptionalData> GetHotfixOptionalData(uint tableHash, uint recordId, Locale locale) public List<HotfixOptionalData> GetHotfixOptionalData(uint tableHash, uint recordId, Locale locale)
@@ -2244,9 +2243,9 @@ namespace Game.DataStorage
Dictionary<uint, IDB2Storage> _storage = new Dictionary<uint, IDB2Storage>(); Dictionary<uint, IDB2Storage> _storage = new Dictionary<uint, IDB2Storage>();
List<HotfixRecord> _hotfixData = new List<HotfixRecord>(); List<HotfixRecord> _hotfixData = new List<HotfixRecord>();
Dictionary<(uint tableHas, int recordId), byte[]>[] _hotfixBlob = new Dictionary<(uint tableHas, int recordId), byte[]>[(int)Locale.Total]; Dictionary<(uint tableHash, int recordId), byte[]>[] _hotfixBlob = new Dictionary<(uint tableHash, int recordId), byte[]>[(int)Locale.Total];
MultiMap<uint, Tuple<uint, AllowedHotfixOptionalData>> _allowedHotfixOptionalData = new MultiMap<uint, Tuple<uint, AllowedHotfixOptionalData>>(); MultiMap<uint, Tuple<uint, AllowedHotfixOptionalData>> _allowedHotfixOptionalData = new MultiMap<uint, Tuple<uint, AllowedHotfixOptionalData>>();
MultiMap<(uint tableHas, int recordId), HotfixOptionalData>[]_hotfixOptionalData = new MultiMap<(uint tableHas, int recordId), HotfixOptionalData>[(int)Locale.Total]; MultiMap<(uint tableHash, int recordId), HotfixOptionalData>[]_hotfixOptionalData = new MultiMap<(uint tableHash, int recordId), HotfixOptionalData>[(int)Locale.Total];
MultiMap<uint, uint> _areaGroupMembers = new MultiMap<uint, uint>(); MultiMap<uint, uint> _areaGroupMembers = new MultiMap<uint, uint>();
MultiMap<uint, ArtifactPowerRecord> _artifactPowers = new MultiMap<uint, ArtifactPowerRecord>(); MultiMap<uint, ArtifactPowerRecord> _artifactPowers = new MultiMap<uint, ArtifactPowerRecord>();
+6 -6
View File
@@ -431,7 +431,7 @@ namespace Game
} }
else if ((int)Values[WorldCfg.StartDemonHunterPlayerLevel] > (int)Values[WorldCfg.MaxPlayerLevel]) else if ((int)Values[WorldCfg.StartDemonHunterPlayerLevel] > (int)Values[WorldCfg.MaxPlayerLevel])
{ {
Log.outError(LogFilter.ServerLoading, "StartDemonHunterPlayerLevel ({0}) must be in range 98..MaxPlayerLevel({1}). Set to {2}.", Log.outError(LogFilter.ServerLoading, "StartDemonHunterPlayerLevel ({0}) must be in range 1..MaxPlayerLevel({1}). Set to {2}.",
Values[WorldCfg.StartDemonHunterPlayerLevel], Values[WorldCfg.MaxPlayerLevel], Values[WorldCfg.MaxPlayerLevel]); Values[WorldCfg.StartDemonHunterPlayerLevel], Values[WorldCfg.MaxPlayerLevel], Values[WorldCfg.MaxPlayerLevel]);
Values[WorldCfg.StartDemonHunterPlayerLevel] = Values[WorldCfg.MaxPlayerLevel]; Values[WorldCfg.StartDemonHunterPlayerLevel] = Values[WorldCfg.MaxPlayerLevel];
} }
@@ -439,12 +439,12 @@ namespace Game
Values[WorldCfg.StartAlliedRaceLevel] = GetDefaultValue("StartAlliedRacePlayerLevel", 10); Values[WorldCfg.StartAlliedRaceLevel] = GetDefaultValue("StartAlliedRacePlayerLevel", 10);
if ((int)Values[WorldCfg.StartAlliedRaceLevel] < 1) if ((int)Values[WorldCfg.StartAlliedRaceLevel] < 1)
{ {
Log.outError(LogFilter.ServerLoading, $"StartDemonHunterPlayerLevel ({Values[WorldCfg.StartAlliedRaceLevel]}) must be in range 1..MaxPlayerLevel({Values[WorldCfg.MaxPlayerLevel]}). Set to 1."); Log.outError(LogFilter.ServerLoading, $"StartAlliedRaceLevel ({Values[WorldCfg.StartAlliedRaceLevel]}) must be in range 1..MaxPlayerLevel({Values[WorldCfg.MaxPlayerLevel]}). Set to 1.");
Values[WorldCfg.StartAlliedRaceLevel] = 1; Values[WorldCfg.StartAlliedRaceLevel] = 1;
} }
else if ((int)Values[WorldCfg.StartAlliedRaceLevel] > (int)Values[WorldCfg.MaxPlayerLevel]) else if ((int)Values[WorldCfg.StartAlliedRaceLevel] > (int)Values[WorldCfg.MaxPlayerLevel])
{ {
Log.outError(LogFilter.ServerLoading, $"StartDemonHunterPlayerLevel ({Values[WorldCfg.StartAlliedRaceLevel]}) must be in range 1..MaxPlayerLevel({Values[WorldCfg.MaxPlayerLevel]}). Set to {Values[WorldCfg.MaxPlayerLevel]}."); Log.outError(LogFilter.ServerLoading, $"StartAlliedRaceLevel ({Values[WorldCfg.StartAlliedRaceLevel]}) must be in range 1..MaxPlayerLevel({Values[WorldCfg.MaxPlayerLevel]}). Set to {Values[WorldCfg.MaxPlayerLevel]}.");
Values[WorldCfg.StartAlliedRaceLevel] = Values[WorldCfg.MaxPlayerLevel]; Values[WorldCfg.StartAlliedRaceLevel] = Values[WorldCfg.MaxPlayerLevel];
} }
@@ -507,12 +507,12 @@ namespace Game
} }
Values[WorldCfg.CurrencyMaxJusticePoints] = (int)Values[WorldCfg.CurrencyMaxJusticePoints] * 100; //precision mod Values[WorldCfg.CurrencyMaxJusticePoints] = (int)Values[WorldCfg.CurrencyMaxJusticePoints] * 100; //precision mod
Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevel] = GetDefaultValue("RecruitAFriend.MaxLevel", 85); Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevel] = GetDefaultValue("RecruitAFriend.MaxLevel", 60);
if ((int)Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevel] > (int)Values[WorldCfg.MaxPlayerLevel]) if ((int)Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevel] > (int)Values[WorldCfg.MaxPlayerLevel])
{ {
Log.outError(LogFilter.ServerLoading, "RecruitAFriend.MaxLevel ({0}) must be in the range 0..MaxLevel({1}). Set to {2}.", Log.outError(LogFilter.ServerLoading, "RecruitAFriend.MaxLevel ({0}) must be in the range 0..MaxLevel({1}). Set to {2}.",
Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevel], Values[WorldCfg.MaxPlayerLevel], 85); Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevel], Values[WorldCfg.MaxPlayerLevel], 60);
Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevel] = 85; Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevel] = 60;
} }
Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevelDifference] = GetDefaultValue("RecruitAFriend.MaxDifference", 4); Values[WorldCfg.MaxRecruitAFriendBonusPlayerLevelDifference] = GetDefaultValue("RecruitAFriend.MaxDifference", 4);