mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
chore(PlayerSettings): Save data and lowGuid (#22921)
This commit is contained in:
@@ -49,14 +49,14 @@ namespace PlayerSettingsStore
|
|||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::ostringstream data;
|
std::ostringstream data;
|
||||||
data << settings[0].value;
|
data << settings[0].value << ' ';
|
||||||
for (size_t i = 1; i < settings.size(); ++i)
|
for (size_t i = 1; i < settings.size(); ++i)
|
||||||
data << ' ' << settings[i].value;
|
data << settings[i].value << ' ';
|
||||||
return data.str();
|
return data.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper: load a single source row for a player and parse to vector
|
// helper: load a single source row for a player and parse to vector
|
||||||
static PlayerSettingVector LoadPlayerSettings(uint32 playerLowGuid, std::string const& source)
|
static PlayerSettingVector LoadPlayerSettings(ObjectGuid::LowType playerLowGuid, std::string const& source)
|
||||||
{
|
{
|
||||||
PlayerSettingVector result;
|
PlayerSettingVector result;
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ namespace PlayerSettingsStore
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateSetting(uint32 playerLowGuid, std::string const& source, uint32 index, uint32 value)
|
void UpdateSetting(ObjectGuid::LowType playerLowGuid, std::string const& source, uint32 index, uint32 value)
|
||||||
{
|
{
|
||||||
if (!sWorld->getBoolConfig(CONFIG_PLAYER_SETTINGS_ENABLED))
|
if (!sWorld->getBoolConfig(CONFIG_PLAYER_SETTINGS_ENABLED))
|
||||||
return;
|
return;
|
||||||
@@ -98,7 +98,7 @@ namespace PlayerSettingsStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implementation of PrepareReplaceStatement
|
// Implementation of PrepareReplaceStatement
|
||||||
CharacterDatabasePreparedStatement* PlayerSettingsStore::PrepareReplaceStatement(uint32 playerLowGuid, std::string const& source, PlayerSettingVector const& settings)
|
CharacterDatabasePreparedStatement* PlayerSettingsStore::PrepareReplaceStatement(ObjectGuid::LowType playerLowGuid, std::string const& source, PlayerSettingVector const& settings)
|
||||||
{
|
{
|
||||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_SETTINGS);
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_SETTINGS);
|
||||||
stmt->SetData(0, playerLowGuid);
|
stmt->SetData(0, playerLowGuid);
|
||||||
|
|||||||
@@ -57,13 +57,13 @@ namespace PlayerSettingsStore
|
|||||||
{
|
{
|
||||||
// Update a single setting value for any player by GUID (works for online or offline players).
|
// Update a single setting value for any player by GUID (works for online or offline players).
|
||||||
// This reads the existing "source" row from character_settings, adjusts the index, and REPLACE's it back.
|
// This reads the existing "source" row from character_settings, adjusts the index, and REPLACE's it back.
|
||||||
void UpdateSetting(uint32 playerLowGuid, std::string const& source, uint32 index, uint32 value);
|
void UpdateSetting(ObjectGuid::LowType playerLowGuid, std::string const& source, uint32 index, uint32 value);
|
||||||
|
|
||||||
// Common helpers for parsing and serializing settings data
|
// Common helpers for parsing and serializing settings data
|
||||||
PlayerSettingVector ParseSettingsData(std::string const& data);
|
PlayerSettingVector ParseSettingsData(std::string const& data);
|
||||||
std::string SerializeSettingsData(PlayerSettingVector const& settings);
|
std::string SerializeSettingsData(PlayerSettingVector const& settings);
|
||||||
// Prepare a REPLACE statement populated with given settings data. Caller may execute or append to a transaction.
|
// Prepare a REPLACE statement populated with given settings data. Caller may execute or append to a transaction.
|
||||||
CharacterDatabasePreparedStatement* PrepareReplaceStatement(uint32 playerLowGuid, std::string const& source, PlayerSettingVector const& settings);
|
CharacterDatabasePreparedStatement* PrepareReplaceStatement(ObjectGuid::LowType playerLowGuid, std::string const& source, PlayerSettingVector const& settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user