Create new table character_stats for external tools(website,etc). This table use only when player logout. Original code by hunuza.
--HG-- branch : trunk
This commit is contained in:
@@ -17448,6 +17448,11 @@ void Player::SaveToDB()
|
||||
|
||||
CharacterDatabase.CommitTransaction();
|
||||
|
||||
// check if stats should only be saved on logout
|
||||
// save stats can be out of transaction
|
||||
if (m_session->isLogingOut() || !sWorld.getConfig(CONFIG_STATS_SAVE_ONLY_ON_LOGOUT))
|
||||
_SaveStats();
|
||||
|
||||
// save pet (hunter pet level and experience and all type pets health/mana).
|
||||
if (Pet* pet = GetPet())
|
||||
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
|
||||
@@ -17789,6 +17794,40 @@ void Player::_SaveSpells()
|
||||
}
|
||||
}
|
||||
|
||||
// save player stats -- only for external usage
|
||||
// real stats will be recalculated on player login
|
||||
void Player::_SaveStats()
|
||||
{
|
||||
// check if stat saving is enabled and if char level is high enough
|
||||
if (!sWorld.getConfig(CONFIG_MIN_LEVEL_STAT_SAVE) || getLevel() < sWorld.getConfig(CONFIG_MIN_LEVEL_STAT_SAVE))
|
||||
return;
|
||||
|
||||
CharacterDatabase.PExecute("DELETE FROM character_stats WHERE guid = '%u'", GetGUIDLow());
|
||||
std::ostringstream ss;
|
||||
ss << "INSERT INTO character_stats (guid, maxhealth, maxpower1, maxpower2, maxpower3, maxpower4, maxpower5, maxpower6, maxpower7, "
|
||||
"strength, agility, stamina, intellect, spirit, armor, resHoly, resFire, resNature, resFrost, resShadow, resArcane, "
|
||||
"blockPct, dodgePct, parryPct, critPct, rangedCritPct, spellCritPct, attackPower, rangedAttackPower, spellPower) VALUES ("
|
||||
<< GetGUIDLow() << ", "
|
||||
<< GetMaxHealth() << ", ";
|
||||
for (int i = 0; i < MAX_POWERS; ++i)
|
||||
ss << GetMaxPower(Powers(i)) << ", ";
|
||||
for (int i = 0; i < MAX_STATS; ++i)
|
||||
ss << GetStat(Stats(i)) << ", ";
|
||||
// armor + school resistances
|
||||
for (int i = 0; i < MAX_SPELL_SCHOOL; ++i)
|
||||
ss << GetResistance(SpellSchools(i)) << ",";
|
||||
ss << GetFloatValue(PLAYER_BLOCK_PERCENTAGE) << ", "
|
||||
<< GetFloatValue(PLAYER_DODGE_PERCENTAGE) << ", "
|
||||
<< GetFloatValue(PLAYER_PARRY_PERCENTAGE) << ", "
|
||||
<< GetFloatValue(PLAYER_CRIT_PERCENTAGE) << ", "
|
||||
<< GetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE) << ", "
|
||||
<< GetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1) << ", "
|
||||
<< GetUInt32Value(UNIT_FIELD_ATTACK_POWER) << ", "
|
||||
<< GetUInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER) << ", "
|
||||
<< GetBaseSpellPowerBonus() << ")";
|
||||
CharacterDatabase.Execute(ss.str().c_str());
|
||||
}
|
||||
|
||||
void Player::outDebugValues() const
|
||||
{
|
||||
if (!sLog.IsOutDebug()) // optimize disabled debug output
|
||||
|
||||
@@ -2411,6 +2411,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void _SaveBGData();
|
||||
void _SaveGlyphs();
|
||||
void _SaveTalents();
|
||||
void _SaveStats();
|
||||
|
||||
void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
|
||||
void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
|
||||
|
||||
@@ -613,6 +613,14 @@ void World::LoadConfigSettings(bool reload)
|
||||
m_configs[CONFIG_GRID_UNLOAD] = sConfig.GetBoolDefault("GridUnload", true);
|
||||
m_configs[CONFIG_INTERVAL_SAVE] = sConfig.GetIntDefault("PlayerSaveInterval", 15 * MINUTE * IN_MILISECONDS);
|
||||
m_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE] = sConfig.GetIntDefault("DisconnectToleranceInterval", 0);
|
||||
m_configs[CONFIG_STATS_SAVE_ONLY_ON_LOGOUT] = sConfig.GetBoolDefault("PlayerSave.Stats.SaveOnlyOnLogout", true);
|
||||
|
||||
m_configs[CONFIG_MIN_LEVEL_STAT_SAVE] = sConfig.GetIntDefault("PlayerSave.Stats.MinLevel", 0);
|
||||
if (m_configs[CONFIG_MIN_LEVEL_STAT_SAVE] > MAX_LEVEL)
|
||||
{
|
||||
sLog.outError("PlayerSave.Stats.MinLevel (%i) must be in range 0..80. Using default, do not save character stats (0).",m_configs[CONFIG_MIN_LEVEL_STAT_SAVE]);
|
||||
m_configs[CONFIG_MIN_LEVEL_STAT_SAVE] = 0;
|
||||
}
|
||||
|
||||
m_configs[CONFIG_INTERVAL_GRIDCLEAN] = sConfig.GetIntDefault("GridCleanUpDelay", 5 * MINUTE * IN_MILISECONDS);
|
||||
if (m_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY)
|
||||
|
||||
@@ -274,6 +274,8 @@ enum WorldConfigs
|
||||
CONFIG_CLIENTCACHE_VERSION,
|
||||
CONFIG_GUILD_EVENT_LOG_COUNT,
|
||||
CONFIG_GUILD_BANK_EVENT_LOG_COUNT,
|
||||
CONFIG_MIN_LEVEL_STAT_SAVE,
|
||||
CONFIG_STATS_SAVE_ONLY_ON_LOGOUT,
|
||||
CONFIG_VALUE_COUNT
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user