mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
importing changes from callmephil repo
a special thanks to him
This commit is contained in:
@@ -680,7 +680,19 @@ void World::LoadConfigSettings(bool reload)
|
||||
m_int_configs[CONFIG_STRICT_CHARTER_NAMES] = sConfigMgr->GetIntDefault ("StrictCharterNames", 0);
|
||||
m_int_configs[CONFIG_STRICT_CHANNEL_NAMES] = sConfigMgr->GetIntDefault ("StrictChannelNames", 0);
|
||||
m_int_configs[CONFIG_STRICT_PET_NAMES] = sConfigMgr->GetIntDefault ("StrictPetNames", 0);
|
||||
|
||||
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS] = sConfigMgr->GetBoolDefault("AllowTwoSide.Accounts", true);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR]= sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Calendar", false);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Chat", false);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Channel", false);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Group", false);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Guild", false);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Auction", false);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Mail", false);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST] = sConfigMgr->GetBoolDefault("AllowTwoSide.WhoList", false);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND] = sConfigMgr->GetBoolDefault("AllowTwoSide.AddFriend", false);
|
||||
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_TRADE] = sConfigMgr->GetBoolDefault("AllowTwoSide.trade", false);
|
||||
|
||||
m_int_configs[CONFIG_MIN_PLAYER_NAME] = sConfigMgr->GetIntDefault ("MinPlayerName", 2);
|
||||
if (m_int_configs[CONFIG_MIN_PLAYER_NAME] < 1 || m_int_configs[CONFIG_MIN_PLAYER_NAME] > MAX_PLAYER_NAME)
|
||||
{
|
||||
@@ -1664,6 +1676,10 @@ void World::SetInitialWorldSettings()
|
||||
///- Handle outdated emails (delete/return)
|
||||
sLog->outString("Returning old mails...");
|
||||
sObjectMgr->ReturnOrDeleteOldMails(false);
|
||||
|
||||
///- Load AutoBroadCast
|
||||
sLog->outString("Loading Autobroadcasts...");
|
||||
LoadAutobroadcasts();
|
||||
|
||||
///- Load and initialize scripts
|
||||
sObjectMgr->LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data)
|
||||
@@ -1842,6 +1858,40 @@ void World::DetectDBCLang()
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
void World::LoadAutobroadcasts()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
m_Autobroadcasts.clear();
|
||||
m_AutobroadcastsWeights.clear();
|
||||
|
||||
uint32 realmId = sConfigMgr->GetIntDefault("RealmID", 0);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_AUTOBROADCAST);
|
||||
stmt->setInt32(0, realmId);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 autobroadcasts definitions. DB table `autobroadcast` is empty for this realm!");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint8 id = fields[0].GetUInt8();
|
||||
|
||||
m_Autobroadcasts[id] = fields[2].GetString();
|
||||
m_AutobroadcastsWeights[id] = fields[1].GetUInt8();
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u autobroadcast definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
/// Update the World !
|
||||
void World::Update(uint32 diff)
|
||||
{
|
||||
@@ -2579,10 +2629,37 @@ void World::SendAutoBroadcast()
|
||||
{
|
||||
if (m_Autobroadcasts.empty())
|
||||
return;
|
||||
|
||||
uint32 weight = 0;
|
||||
AutobroadcastsWeightMap selectionWeights;
|
||||
|
||||
std::string msg;
|
||||
|
||||
msg = Trinity::Containers::SelectRandomContainerElement(m_Autobroadcasts);
|
||||
for (AutobroadcastsWeightMap::const_iterator it = m_AutobroadcastsWeights.begin(); it != m_AutobroadcastsWeights.end(); ++it)
|
||||
{
|
||||
if (it->second)
|
||||
{
|
||||
weight += it->second;
|
||||
selectionWeights[it->first] = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
if (weight)
|
||||
{
|
||||
uint32 selectedWeight = urand(0, weight - 1);
|
||||
weight = 0;
|
||||
for (AutobroadcastsWeightMap::const_iterator it = selectionWeights.begin(); it != selectionWeights.end(); ++it)
|
||||
{
|
||||
weight += it->second;
|
||||
if (selectedWeight < weight)
|
||||
{
|
||||
msg = m_Autobroadcasts[it->first];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
msg = m_Autobroadcasts[urand(0, m_Autobroadcasts.size())];
|
||||
|
||||
uint32 abcenter = sWorld->getIntConfig(CONFIG_AUTOBROADCAST_CENTER);
|
||||
|
||||
|
||||
@@ -90,6 +90,17 @@ enum WorldBoolConfigs
|
||||
CONFIG_ALLOW_PLAYER_COMMANDS,
|
||||
CONFIG_CLEAN_CHARACTER_DB,
|
||||
CONFIG_STATS_SAVE_ONLY_ON_LOGOUT,
|
||||
CONFIG_ALLOW_TWO_SIDE_ACCOUNTS,
|
||||
CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR,
|
||||
CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT,
|
||||
CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL,
|
||||
CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP,
|
||||
CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD,
|
||||
CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION,
|
||||
CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL,
|
||||
CONFIG_ALLOW_TWO_SIDE_WHO_LIST,
|
||||
CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND,
|
||||
CONFIG_ALLOW_TWO_SIDE_TRADE,
|
||||
CONFIG_ALL_TAXI_PATHS,
|
||||
CONFIG_INSTANT_TAXI,
|
||||
CONFIG_INSTANCE_IGNORE_LEVEL,
|
||||
@@ -741,6 +752,8 @@ class World
|
||||
void LoadDBVersion();
|
||||
char const* GetDBVersion() const { return m_DBVersion.c_str(); }
|
||||
|
||||
void LoadAutobroadcasts();
|
||||
|
||||
void UpdateAreaDependentAuras();
|
||||
|
||||
uint32 GetCleaningFlags() const { return m_CleaningFlags; }
|
||||
@@ -841,7 +854,11 @@ class World
|
||||
// used versions
|
||||
std::string m_DBVersion;
|
||||
|
||||
std::list<std::string> m_Autobroadcasts;
|
||||
typedef std::map<uint8, std::string> AutobroadcastsMap;
|
||||
AutobroadcastsMap m_Autobroadcasts;
|
||||
|
||||
typedef std::map<uint8, uint8> AutobroadcastsWeightMap;
|
||||
AutobroadcastsWeightMap m_AutobroadcastsWeights;
|
||||
|
||||
void ProcessQueryCallbacks();
|
||||
ACE_Future_Set<PreparedQueryResult> m_realmCharCallbacks;
|
||||
|
||||
Reference in New Issue
Block a user