Skip to content

Commit

Permalink
[9681] Add config to decide whether character stats should only be sa…
Browse files Browse the repository at this point in the history
…ved on logout.

Signed-off-by: hunuza <hunuza@gmail.com>
  • Loading branch information
hunuza committed Apr 6, 2010
1 parent 7bc819c commit 30c53a5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15951,7 +15951,7 @@ void Player::_LoadTalents(QueryResult *result)
do
{
Field *fields = result->Fetch();

uint32 talent_id = fields[0].GetUInt32();
TalentEntry const *talentInfo = sTalentStore.LookupEntry( talent_id );

Expand Down Expand Up @@ -16511,11 +16511,14 @@ void Player::SaveToDB()
GetSession()->SaveTutorialsData(); // changed only while character in game
_SaveGlyphs();
_SaveTalents();
if(m_session->isLogingOut()) // only save stats on logout
_SaveStats();

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_BOOL_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);
Expand Down Expand Up @@ -21295,7 +21298,7 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket *data)
for(PlayerTalentMap::iterator iter = m_talents[specIdx].begin(); iter != m_talents[specIdx].end(); ++iter)
{
PlayerTalent talent = (*iter).second;

if (talent.state == PLAYERSPELL_REMOVED)
continue;

Expand Down Expand Up @@ -21617,7 +21620,7 @@ void Player::ActivateSpec(uint8 specNum)
}
else
++specIter;
}
}

// now new spec data have only talents (maybe different rank) as in temp spec data, sync ranks then.
for (PlayerTalentMap::const_iterator tempIter = tempSpec.begin(); tempIter != tempSpec.end(); ++tempIter)
Expand Down
1 change: 1 addition & 0 deletions src/game/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ void World::LoadConfigSettings(bool reload)
setConfig(CONFIG_BOOL_GRID_UNLOAD, "GridUnload", true);
setConfigPos(CONFIG_UINT32_INTERVAL_SAVE, "PlayerSave.Interval", 15 * MINUTE * IN_MILLISECONDS);
setConfigMinMax(CONFIG_UINT32_MIN_LEVEL_STAT_SAVE, "PlayerSave.Stats.MinLevel", 0, 0, MAX_LEVEL);
setConfig(CONFIG_BOOL_STATS_SAVE_ONLY_ON_LOGOUT, "PlayerSave.Stats.SaveOnlyOnLogout", true);

setConfigMin(CONFIG_UINT32_INTERVAL_GRIDCLEAN, "GridCleanUpDelay", 5 * MINUTE * IN_MILLISECONDS, MIN_GRID_DELAY);
if (reload)
Expand Down
1 change: 1 addition & 0 deletions src/game/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ enum eConfigBoolValues
CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_JOIN,
CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_EXIT,
CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET,
CONFIG_BOOL_STATS_SAVE_ONLY_ON_LOGOUT,
CONFIG_BOOL_VALUE_COUNT
};

Expand Down
6 changes: 6 additions & 0 deletions src/mangosd/mangosd.conf.dist.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ BindIP = "0.0.0.0"
# Default: 0 (do not save character stats)
# 1+ (save stats for characters with level 1+)
#
# PlayerSave.Stats.SaveOnlyOnLogout
# Enable/Disable saving of character stats only on logout
# Default: 1 (only save on logout)
# 0 (save on every player save)
#
# vmap.enableLOS
# vmap.enableHeight
# Enable/Disable VMmap support for line of sight and height calculation
Expand Down Expand Up @@ -180,6 +185,7 @@ MapUpdateInterval = 100
ChangeWeatherInterval = 600000
PlayerSave.Interval = 900000
PlayerSave.Stats.MinLevel = 0
PlayerSave.Stats.SaveOnlyOnLogout = 1
vmap.enableLOS = 0
vmap.enableHeight = 0
vmap.ignoreMapIds = "369"
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9680"
#define REVISION_NR "9681"
#endif // __REVISION_NR_H__

0 comments on commit 30c53a5

Please sign in to comment.