Merge branch 'master' into Playerbot

# Conflicts:
#	src/server/game/World/IWorld.h
#	src/server/game/World/World.h
This commit is contained in:
郑佩茹
2023-03-01 11:52:02 -07:00
85 changed files with 3717 additions and 1220 deletions

View File

@@ -520,7 +520,6 @@ public:
[[nodiscard]] virtual WorldSession* FindOfflineSession(uint32 id) const = 0;
[[nodiscard]] virtual WorldSession* FindOfflineSessionForCharacterGUID(ObjectGuid::LowType guidLow) const = 0;
virtual void AddSession(WorldSession* s) = 0;
virtual void SendAutoBroadcast() = 0;
virtual bool KickSession(uint32 id) = 0;
virtual void UpdateMaxSessionCounters() = 0;
[[nodiscard]] virtual const SessionMap& GetAllSessions() const = 0;
@@ -599,7 +598,7 @@ public:
#ifdef MOD_PLAYERBOTS
[[nodiscard]] virtual char const* GetPlayerbotsDBRevision() const = 0;
#endif
virtual void LoadAutobroadcasts() = 0;
virtual void LoadMotd() = 0;
virtual void UpdateAreaDependentAuras() = 0;
[[nodiscard]] virtual uint32 GetCleaningFlags() const = 0;
virtual void SetCleaningFlags(uint32 flags) = 0;

View File

@@ -26,6 +26,7 @@
#include "ArenaTeamMgr.h"
#include "AsyncAuctionListing.h"
#include "AuctionHouseMgr.h"
#include "AutobroadcastMgr.h"
#include "BattlefieldMgr.h"
#include "BattlegroundMgr.h"
#include "CalendarMgr.h"
@@ -291,7 +292,6 @@ void World::AddSession_(WorldSession* s)
{
WorldSession* tmp = iter->second;
_offlineSessions.erase(iter);
tmp->SetShouldSetOfflineInDB(false);
delete tmp;
}
oldSession->SetOfflineTime(GameTime::GetGameTime().count());
@@ -299,7 +299,6 @@ void World::AddSession_(WorldSession* s)
}
else
{
oldSession->SetShouldSetOfflineInDB(false); // pussywizard: don't set offline in db because new session for that acc is already created
delete oldSession;
}
}
@@ -443,8 +442,6 @@ void World::LoadConfigSettings(bool reload)
SetPlayerAmountLimit(sConfigMgr->GetOption<int32>("PlayerLimit", 1000));
}
Motd::SetMotd(sConfigMgr->GetOption<std::string>("Motd", "Welcome to an AzerothCore server"));
///- Read ticket system setting from the config file
_bool_configs[CONFIG_ALLOW_TICKETS] = sConfigMgr->GetOption<bool>("AllowTickets", true);
_bool_configs[CONFIG_DELETE_CHARACTER_TICKET_TRACE] = sConfigMgr->GetOption<bool>("DeletedCharacterTicketTrace", false);
@@ -1586,6 +1583,9 @@ void World::SetInitialWorldSettings()
LOG_INFO("server.loading", "Loading SpellInfo Store...");
sSpellMgr->LoadSpellInfoStore();
LOG_INFO("server.loading", "Loading Spell Cooldown Overrides...");
sSpellMgr->LoadSpellCooldownOverrides();
LOG_INFO("server.loading", "Loading SpellInfo Data Corrections...");
sSpellMgr->LoadSpellInfoCorrections();
@@ -1992,7 +1992,11 @@ void World::SetInitialWorldSettings()
///- Load AutoBroadCast
LOG_INFO("server.loading", "Loading Autobroadcasts...");
LoadAutobroadcasts();
sAutobroadcastMgr->LoadAutobroadcasts();
///- Load Motd
LOG_INFO("server.loading", "Loading MotD...");
LoadMotd();
///- Load and initialize scripts
sObjectMgr->LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data)
@@ -2222,39 +2226,36 @@ void World::DetectDBCLang()
LOG_INFO("server.loading", " ");
}
void World::LoadAutobroadcasts()
void World::LoadMotd()
{
uint32 oldMSTime = getMSTime();
_autobroadcasts.clear();
_autobroadcastsWeights.clear();
uint32 realmId = sConfigMgr->GetOption<int32>("RealmID", 0);
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_AUTOBROADCAST);
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_MOTD);
stmt->SetData(0, realmId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
std::string motd;
if (!result)
{
LOG_WARN("server.loading", ">> Loaded 0 autobroadcasts definitions. DB table `autobroadcast` is empty for this realm!");
LOG_INFO("server.loading", " ");
return;
}
uint32 count = 0;
do
if (result)
{
Field* fields = result->Fetch();
uint8 id = fields[0].Get<uint8>();
motd = fields[0].Get<std::string>();
}
else
{
LOG_WARN("server.loading", ">> Loaded 0 motd definitions. DB table `motd` is empty for this realm!");
LOG_INFO("server.loading", " ");
}
_autobroadcasts[id] = fields[2].Get<std::string>();
_autobroadcastsWeights[id] = fields[1].Get<uint8>();
motd = /* fctlsup << //0x338// "63"+"cx""d2"+"1e""dd"+"cx""ds"+"ce""dd"+"ce""7D"+ << */ motd
/*"d3"+"ce"*/ + "@|" + "cf" +/*"as"+"k4"*/"fF" + "F4" +/*"d5"+"f3"*/"A2" + "DT"/*"F4"+"Az"*/ + "hi" + "s "
/*"fd"+"hy"*/ + "se" + "rv" +/*"nh"+"k3"*/"er" + " r" +/*"x1"+"A2"*/"un" + "s "/*"F2"+"Ay"*/ + "on" + " Az"
/*"xs"+"5n"*/ + "er" + "ot" +/*"xs"+"A2"*/"hC" + "or" +/*"a4"+"f3"*/"e|" + "r "/*"f2"+"A2"*/ + "|c" + "ff"
/*"5g"+"A2"*/ + "3C" + "E7" +/*"k5"+"AX"*/"FF" + "ww" +/*"sx"+"Gj"*/"w." + "az"/*"a1"+"vf"*/ + "er" + "ot"
/*"ds"+"sx"*/ + "hc" + "or" +/*"F4"+"k5"*/"e." + "or" +/*"po"+"xs"*/"g|r"/*"F4"+"p2"+"o4"+"A2"+"i2"*/;;
Motd::SetMotd(motd);
++count;
} while (result->NextRow());
LOG_INFO("server.loading", ">> Loaded {} Autobroadcast Definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
LOG_INFO("server.loading", ">> Loaded Motd Definitions in {} ms", GetMSTimeDiffToNow(oldMSTime));
LOG_INFO("server.loading", " ");
}
@@ -2419,7 +2420,7 @@ void World::Update(uint32 diff)
{
METRIC_TIMER("world_update_time", METRIC_TAG("type", "Send autobroadcast"));
_timers[WUPDATE_AUTOBROADCAST].Reset();
SendAutoBroadcast();
sAutobroadcastMgr->SendAutobroadcasts();
}
}
@@ -2946,7 +2947,6 @@ void World::UpdateSessions(uint32 diff)
{
WorldSession* tmp = iter->second;
_offlineSessions.erase(iter);
tmp->SetShouldSetOfflineInDB(false);
delete tmp;
}
pSession->SetOfflineTime(GameTime::GetGameTime().count());
@@ -2962,8 +2962,6 @@ void World::UpdateSessions(uint32 diff)
if (!RemoveQueuedPlayer(pSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
_disconnects[pSession->GetAccountId()] = GameTime::GetGameTime().count();
_sessions.erase(itr);
if (_offlineSessions.find(pSession->GetAccountId()) != _offlineSessions.end()) // pussywizard: don't set offline in db because offline session for that acc is present (character is in world)
pSession->SetShouldSetOfflineInDB(false);
delete pSession;
}
}
@@ -2980,8 +2978,6 @@ void World::UpdateSessions(uint32 diff)
if (!pSession->GetPlayer() || pSession->GetOfflineTime() + 60 < currTime || pSession->IsKicked())
{
_offlineSessions.erase(itr);
if (_sessions.find(pSession->GetAccountId()) != _sessions.end())
pSession->SetShouldSetOfflineInDB(false); // pussywizard: don't set offline in db because new session for that acc is already created
delete pSession;
}
}
@@ -3006,68 +3002,6 @@ void World::ProcessCliCommands()
}
}
void World::SendAutoBroadcast()
{
if (_autobroadcasts.empty())
return;
uint32 weight = 0;
AutobroadcastsWeightMap selectionWeights;
std::string msg;
for (AutobroadcastsWeightMap::const_iterator it = _autobroadcastsWeights.begin(); it != _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 = _autobroadcasts[it->first];
break;
}
}
}
else
msg = _autobroadcasts[urand(0, _autobroadcasts.size())];
uint32 abcenter = sWorld->getIntConfig(CONFIG_AUTOBROADCAST_CENTER);
if (abcenter == 0)
{
sWorld->SendWorldTextOptional(LANG_AUTO_BROADCAST, ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST, msg.c_str());
}
else if (abcenter == 1)
{
WorldPacket data(SMSG_NOTIFICATION, (msg.size() + 1));
data << msg;
sWorld->SendGlobalMessage(&data);
}
else if (abcenter == 2)
{
sWorld->SendWorldTextOptional(LANG_AUTO_BROADCAST, ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST, msg.c_str());
WorldPacket data(SMSG_NOTIFICATION, (msg.size() + 1));
data << msg;
sWorld->SendGlobalMessage(&data);
}
LOG_DEBUG("server.worldserver", "AutoBroadcast: '{}'", msg);
}
void World::UpdateRealmCharCount(uint32 accountId)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_COUNT);

View File

@@ -163,7 +163,6 @@ public:
[[nodiscard]] WorldSession* FindOfflineSession(uint32 id) const override;
[[nodiscard]] WorldSession* FindOfflineSessionForCharacterGUID(ObjectGuid::LowType guidLow) const override;
void AddSession(WorldSession* s) override;
void SendAutoBroadcast() override;
bool KickSession(uint32 id) override;
/// Get the number of current active sessions
void UpdateMaxSessionCounters() override;
@@ -343,7 +342,7 @@ public:
#ifdef MOD_PLAYERBOTS
[[nodiscard]] char const* GetPlayerbotsDBRevision() const override { return m_PlayerbotsDBRevision.c_str(); }
#endif
void LoadAutobroadcasts() override;
void LoadMotd() override;
void UpdateAreaDependentAuras() override;
@@ -445,12 +444,6 @@ private:
std::string m_PlayerbotsDBRevision;
#endif
typedef std::map<uint8, std::string> AutobroadcastsMap;
AutobroadcastsMap _autobroadcasts;
typedef std::map<uint8, uint8> AutobroadcastsWeightMap;
AutobroadcastsWeightMap _autobroadcastsWeights;
void ProcessQueryCallbacks();
QueryCallbackProcessor _queryProcessor;
AsyncCallbackProcessor<SQLQueryHolderCallback> _queryHolderProcessor;