mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-19 03:45:43 +00:00
refactor(Core/player_levelstats): Split player_levelstats into class and race specific tables. (#14383)
Co-authored-by: ahchxj2416 <64737877+ahchxj2416@users.noreply.github.com> Co-authored-by: Shauren <shauren.trinity@gmail.com> Co-authored-by: funjoker <torti-esser@web.de>
This commit is contained in:
@@ -4016,15 +4016,47 @@ void ObjectMgr::LoadPlayerInfo()
|
||||
// Loading levels data (class/race dependent)
|
||||
LOG_INFO("server.loading", "Loading Player Create Level Stats Data...");
|
||||
{
|
||||
struct RaceStats
|
||||
{
|
||||
int16 StatModifier[MAX_STATS];
|
||||
};
|
||||
|
||||
std::array<RaceStats, MAX_RACES> raceStatModifiers;
|
||||
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// 0 1 2 3 4 5 6 7
|
||||
QueryResult result = WorldDatabase.Query("SELECT race, class, level, str, agi, sta, inte, spi FROM player_levelstats");
|
||||
// 0 1 2 3 4 5
|
||||
QueryResult raceStatsResult = WorldDatabase.Query("SELECT Race, Strength, Agility, Stamina, Intellect, Spirit FROM player_race_stats");
|
||||
|
||||
if (!raceStatsResult)
|
||||
{
|
||||
LOG_WARN("server.loading", ">> Loaded 0 race stats definitions. DB table `player_race_stats` is empty.");
|
||||
LOG_INFO("server.loading", " ");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = raceStatsResult->Fetch();
|
||||
|
||||
uint32 current_race = fields[0].Get<uint8>();
|
||||
if (current_race >= MAX_RACES)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Wrong race {} in `player_race_stats` table, ignoring.", current_race);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < MAX_STATS; ++i)
|
||||
raceStatModifiers[current_race].StatModifier[i] = fields[i + 1].Get<int16>();
|
||||
|
||||
} while (raceStatsResult->NextRow());
|
||||
|
||||
// 0 1 2 3 4 5 6
|
||||
QueryResult result = WorldDatabase.Query("SELECT Class, Level, Strength, Agility, Stamina, Intellect, Spirit FROM player_class_stats");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
LOG_WARN("server.loading", ">> Loaded 0 level stats definitions. DB table `player_levelstats` is empty.");
|
||||
LOG_INFO("server.loading", " ");
|
||||
LOG_ERROR("server.loading", ">> Loaded 0 level stats definitions. DB table `player_class_stats` is empty.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -4034,41 +4066,35 @@ void ObjectMgr::LoadPlayerInfo()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 current_race = fields[0].Get<uint8>();
|
||||
if (current_race >= MAX_RACES)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Wrong race {} in `player_levelstats` table, ignoring.", current_race);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 current_class = fields[1].Get<uint8>();
|
||||
uint32 current_class = fields[0].Get<uint8>();
|
||||
if (current_class >= MAX_CLASSES)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Wrong class {} in `player_levelstats` table, ignoring.", current_class);
|
||||
LOG_ERROR("sql.sql", "Wrong class {} in `player_class_stats` table, ignoring.", current_class);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 current_level = fields[2].Get<uint8>();
|
||||
uint32 current_level = fields[1].Get<uint8>();
|
||||
if (current_level > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
{
|
||||
if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
|
||||
LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
|
||||
LOG_ERROR("sql.sql", "Wrong (> {}) level {} in `player_class_stats` table, ignoring.", STRONG_MAX_LEVEL, current_level);
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_levelstats` table, ignoring.", current_level);
|
||||
++count; // make result loading percent "expected" correct in case disabled detail mode for example.
|
||||
}
|
||||
LOG_DEBUG("sql.sql", "Unused (> MaxPlayerLevel in worldserver.conf) level {} in `player_class_stats` table, ignoring.", current_level);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (PlayerInfo* info = _playerInfo[current_race][current_class])
|
||||
for (std::size_t race = 0; race < raceStatModifiers.size(); ++race)
|
||||
{
|
||||
if (!info->levelInfo)
|
||||
info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
|
||||
if (PlayerInfo* info = _playerInfo[race][current_class])
|
||||
{
|
||||
if (!info->levelInfo)
|
||||
info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)];
|
||||
|
||||
PlayerLevelInfo& levelInfo = info->levelInfo[current_level - 1];
|
||||
for (uint8 i = 0; i < MAX_STATS; i++)
|
||||
levelInfo.stats[i] = fields[i + 3].Get<uint32>();
|
||||
PlayerLevelInfo& levelInfo = info->levelInfo[current_level - 1];
|
||||
for (int i = 0; i < MAX_STATS; ++i)
|
||||
levelInfo.stats[i] = fields[i + 2].Get<uint16>() + raceStatModifiers[race].StatModifier[i];
|
||||
}
|
||||
}
|
||||
|
||||
++count;
|
||||
|
||||
Reference in New Issue
Block a user