Compare commits

...

4 Commits

6 changed files with 32 additions and 6 deletions

View File

@ -28,3 +28,4 @@ git clone --depth=1 --branch=master https://github.com/azerothcore/mod-server-au
git clone --depth=1 --branch=master https://github.com/azerothcore/mod-transmog.git modules/mod-transmog
git clone --depth=1 --branch=main https://github.com/azerothcore/mod-progression-system.git modules/mod-progression-system
git clone --depth=1 --branch=master https://github.com/azerothcore/mod-arena-3v3-solo-queue.git modules/mod-arena-3v3-solo-queue
git clone --depth=1 --branch=master https://github.com/azerothcore/mod-costumes.git modules/mod-costumes

View File

@ -1745,16 +1745,27 @@ PlayerSave.Stats.SaveOnlyOnLogout = 1
CleanCharacterDB = 0
#
# CleanCharacterDB.OrderItems
# Description: Requires CleanCharacterDB = 1
# Reoder item guids in item_instance and character_inventory
#
# Default: 0 - (Disabled)
# 1 - (Enable)
CleanCharacterDB.OrderItems = 0
#
# PersistentCharacterCleanFlags
# Description: Determines the character clean flags that remain set after cleanups.
# Description: Requires CleanCharacterDB = 1
# Determines the character clean flags that remain set after cleanups.
# This is a bitmask value, you can use one of the following values:
#
# CLEANING_FLAG_ACHIEVEMENT_PROGRESS = 0x1
# CLEANING_FLAG_SKILLS = 0x2
# CLEANING_FLAG_SPELLS = 0x4
# CLEANING_FLAG_TALENTS = 0x8
# CLEANING_FLAG_QUESTSTATUS = 0x10
# CLEANING_FLAG_ACHIEVEMENT_PROGRESS = 1
# CLEANING_FLAG_SKILLS = 2
# CLEANING_FLAG_SPELLS = 4
# CLEANING_FLAG_TALENTS = 8
# CLEANING_FLAG_QUESTSTATUS = 16
#
# Before use this feature, make a backup of your database.
#

View File

@ -56,6 +56,9 @@ void CharacterDatabaseCleaner::CleanDatabase()
if (flags & CLEANING_FLAG_QUESTSTATUS)
CleanCharacterQuestStatus();
if (sWorld->getBoolConfig(CONFIG_CLEAN_CHARACTER_DB_ORDER_ITEMS))
CleanCharacterItem();
// NOTE: In order to have persistentFlags be set in worldstates for the next cleanup,
// you need to define them at least once in worldstates.
flags &= sWorld->getIntConfig(CONFIG_PERSISTENT_CHARACTER_CLEAN_FLAGS);
@ -154,3 +157,11 @@ void CharacterDatabaseCleaner::CleanCharacterQuestStatus()
{
CharacterDatabase.DirectExecute("DELETE FROM character_queststatus WHERE status = 0");
}
void CharacterDatabaseCleaner::CleanCharacterItem()
{
CharacterDatabase.DirectExecute("CREATE TEMPORARY TABLE temp_guid_mapping AS SELECT guid AS old_guid, ROW_NUMBER() OVER (ORDER BY guid) AS new_guid FROM item_instance;");
CharacterDatabase.DirectExecute("UPDATE item_instance i JOIN temp_guid_mapping m ON i.guid = m.old_guid SET i.guid = m.new_guid;");
CharacterDatabase.DirectExecute("UPDATE character_inventory ci JOIN temp_guid_mapping m ON ci.item = m.old_guid SET ci.item = m.new_guid;");
CharacterDatabase.DirectExecute("DROP TEMPORARY TABLE temp_guid_mapping;");
}

View File

@ -45,6 +45,7 @@ namespace CharacterDatabaseCleaner
void CleanCharacterSpell();
void CleanCharacterTalent();
void CleanCharacterQuestStatus();
void CleanCharacterItem();
}
#endif

View File

@ -65,6 +65,7 @@ enum WorldBoolConfigs
CONFIG_ADDON_CHANNEL,
CONFIG_ALLOW_PLAYER_COMMANDS,
CONFIG_CLEAN_CHARACTER_DB,
CONFIG_CLEAN_CHARACTER_DB_ORDER_ITEMS,
CONFIG_STATS_SAVE_ONLY_ON_LOGOUT,
CONFIG_ALLOW_TWO_SIDE_ACCOUNTS,
CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR,

View File

@ -399,6 +399,7 @@ void World::LoadConfigSettings(bool reload)
}
_bool_configs[CONFIG_ADDON_CHANNEL] = sConfigMgr->GetOption<bool>("AddonChannel", true);
_bool_configs[CONFIG_CLEAN_CHARACTER_DB] = sConfigMgr->GetOption<bool>("CleanCharacterDB", false);
_bool_configs[CONFIG_CLEAN_CHARACTER_DB_ORDER_ITEMS] = sConfigMgr->GetOption<bool>("CleanCharacterDB.OrderItems", false);
_int_configs[CONFIG_PERSISTENT_CHARACTER_CLEAN_FLAGS] = sConfigMgr->GetOption<int32>("PersistentCharacterCleanFlags", 0);
_int_configs[CONFIG_CHAT_CHANNEL_LEVEL_REQ] = sConfigMgr->GetOption<int32>("ChatLevelReq.Channel", 1);
_int_configs[CONFIG_CHAT_WHISPER_LEVEL_REQ] = sConfigMgr->GetOption<int32>("ChatLevelReq.Whisper", 1);