Fixed a crash in playerinfo level data when its missing from the DB.

Fixes #53
This commit is contained in:
hondacrx
2023-02-15 08:20:43 -05:00
parent d408bd2841
commit 1a01c02261
2 changed files with 7 additions and 9 deletions
+4 -1
View File
@@ -298,7 +298,10 @@ namespace Game.Entities
public PlayerInfo()
{
for (var i = 0; i < castSpells.Length; ++i)
castSpells[i] = new List<uint>();
castSpells[i] = new();
for (var i = 0; i < levelInfo.Length; ++i)
levelInfo[i] = new();
}
public struct CreatePosition
+3 -8
View File
@@ -6492,13 +6492,8 @@ namespace Game
if (playerInfo == null)
continue;
if (playerInfo.levelInfo[currentlevel - 1] == null)
playerInfo.levelInfo[currentlevel - 1] = new PlayerLevelInfo();
var levelinfo = playerInfo.levelInfo[currentlevel - 1];
for (var i = 0; i < (int)Stats.Max; i++)
levelinfo.stats[i] = (ushort)(result.Read<ushort>(i + 2) + raceStatModifiers[race][i]);
playerInfo.levelInfo[currentlevel - 1].stats[i] = (ushort)(result.Read<ushort>(i + 2) + raceStatModifiers[race][i]);
}
++count;
@@ -6539,10 +6534,10 @@ namespace Game
continue;
// fatal error if no level 1 data
if (playerInfo.levelInfo == null || playerInfo.levelInfo[0].stats[0] == 0)
if (playerInfo.levelInfo[0].stats[0] == 0)
{
Log.outError(LogFilter.Sql, "Race {0} Class {1} Level 1 does not have stats data!", race, _class);
Global.WorldMgr.StopNow();
Environment.Exit(1);
return;
}