mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-31 17:43:47 +00:00
feat(Core/Player): Implement player specific settings (#9483)
This commit is contained in:
@@ -171,6 +171,7 @@ enum WorldBoolConfigs
|
||||
CONFIG_SET_BOP_ITEM_TRADEABLE,
|
||||
CONFIG_ALLOW_LOGGING_IP_ADDRESSES_IN_DATABASE,
|
||||
CONFIG_REALM_LOGIN_ENABLED,
|
||||
CONFIG_PLAYER_SETTINGS_ENABLED,
|
||||
BOOL_CONFIG_VALUE_COUNT
|
||||
};
|
||||
|
||||
@@ -334,6 +335,7 @@ enum WorldIntConfigs
|
||||
CONFIG_CHARDELETE_MIN_LEVEL,
|
||||
CONFIG_AUTOBROADCAST_CENTER,
|
||||
CONFIG_AUTOBROADCAST_INTERVAL,
|
||||
CONFIG_AUTOBROADCAST_MIN_LEVEL_DISABLE,
|
||||
CONFIG_MAX_RESULTS_LOOKUP_COMMANDS,
|
||||
CONFIG_DB_PING_INTERVAL,
|
||||
CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION,
|
||||
@@ -537,6 +539,7 @@ public:
|
||||
virtual void SetInitialWorldSettings() = 0;
|
||||
virtual void LoadConfigSettings(bool reload = false) = 0;
|
||||
virtual void SendWorldText(uint32 string_id, ...) = 0;
|
||||
virtual void SendWorldTextOptional(uint32 string_id, uint32 flag, ...) = 0;
|
||||
virtual void SendGlobalText(const char* text, WorldSession* self) = 0;
|
||||
virtual void SendGMText(uint32 string_id, ...) = 0;
|
||||
virtual void SendGlobalMessage(WorldPacket* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
|
||||
|
||||
@@ -1243,6 +1243,8 @@ void World::LoadConfigSettings(bool reload)
|
||||
|
||||
m_int_configs[CONFIG_LOOT_NEED_BEFORE_GREED_ILVL_RESTRICTION] = sConfigMgr->GetOption<int32>("LootNeedBeforeGreedILvlRestriction", 70);
|
||||
|
||||
m_bool_configs[CONFIG_PLAYER_SETTINGS_ENABLED] = sConfigMgr->GetOption<bool>("EnablePlayerSettings", 0);
|
||||
|
||||
///- Read the "Data" directory from the config file
|
||||
std::string dataPath = sConfigMgr->GetOption<std::string>("DataDir", "./");
|
||||
if (dataPath.empty() || (dataPath.at(dataPath.length() - 1) != '/' && dataPath.at(dataPath.length() - 1) != '\\'))
|
||||
@@ -1324,6 +1326,7 @@ void World::LoadConfigSettings(bool reload)
|
||||
m_bool_configs[CONFIG_AUTOBROADCAST] = sConfigMgr->GetOption<bool>("AutoBroadcast.On", false);
|
||||
m_int_configs[CONFIG_AUTOBROADCAST_CENTER] = sConfigMgr->GetOption<int32>("AutoBroadcast.Center", 0);
|
||||
m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL] = sConfigMgr->GetOption<int32>("AutoBroadcast.Timer", 60000);
|
||||
m_int_configs[CONFIG_AUTOBROADCAST_MIN_LEVEL_DISABLE] = sConfigMgr->GetOption<int32>("AutoBroadcast.MinDisableLevel", 0);
|
||||
if (reload)
|
||||
{
|
||||
m_timers[WUPDATE_AUTOBROADCAST].SetInterval(m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL]);
|
||||
@@ -2576,6 +2579,34 @@ void World::SendWorldText(uint32 string_id, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void World::SendWorldTextOptional(uint32 string_id, uint32 flag, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, flag);
|
||||
|
||||
Acore::WorldWorldTextBuilder wt_builder(string_id, &ap);
|
||||
Acore::LocalizedPacketListDo<Acore::WorldWorldTextBuilder> wt_do(wt_builder);
|
||||
for (auto const& itr : m_sessions)
|
||||
{
|
||||
if (!itr.second || !itr.second->GetPlayer() || !itr.second->GetPlayer()->IsInWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_PLAYER_SETTINGS_ENABLED))
|
||||
{
|
||||
if (itr.second->GetPlayer()->GetPlayerSetting(AzerothcorePSSource, SETTING_ANNOUNCER_FLAGS).HasFlag(flag))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
wt_do(itr.second->GetPlayer());
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/// Send a System Message to all GMs (except self if mentioned)
|
||||
void World::SendGMText(uint32 string_id, ...)
|
||||
{
|
||||
@@ -2953,7 +2984,9 @@ void World::SendAutoBroadcast()
|
||||
uint32 abcenter = sWorld->getIntConfig(CONFIG_AUTOBROADCAST_CENTER);
|
||||
|
||||
if (abcenter == 0)
|
||||
sWorld->SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
|
||||
{
|
||||
sWorld->SendWorldTextOptional(LANG_AUTO_BROADCAST, ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST, msg.c_str());
|
||||
}
|
||||
|
||||
else if (abcenter == 1)
|
||||
{
|
||||
@@ -2964,7 +2997,7 @@ void World::SendAutoBroadcast()
|
||||
|
||||
else if (abcenter == 2)
|
||||
{
|
||||
sWorld->SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
|
||||
sWorld->SendWorldTextOptional(LANG_AUTO_BROADCAST, ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST, msg.c_str());
|
||||
|
||||
WorldPacket data(SMSG_NOTIFICATION, (msg.size() + 1));
|
||||
data << msg;
|
||||
|
||||
@@ -262,6 +262,8 @@ public:
|
||||
void SendZoneText(uint32 zone, const char* text, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL);
|
||||
void SendServerMessage(ServerMessageType type, const char* text = "", Player* player = nullptr);
|
||||
|
||||
void SendWorldTextOptional(uint32 string_id, uint32 flag, ...);
|
||||
|
||||
/// Are we in the middle of a shutdown?
|
||||
bool IsShuttingDown() const { return m_ShutdownTimer > 0; }
|
||||
uint32 GetShutDownTimeLeft() const { return m_ShutdownTimer; }
|
||||
|
||||
Reference in New Issue
Block a user