mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Channels: Revamp of channel system
* Core/Chat: general cleanup and revamping: (#17576) (fbbb03212e) * Core/Channel: restore accidentally deleted line, fixes channels not honoring ownership setting (7c71417993) * Channel Followup: avoid setting an invisible gm as Channel owner (#17597) (8a8362ef15) * Core/Channel: change the way channels are stored and sent to client, fixes multiple channels per zone when using different locales (#17980)
This commit is contained in:
@@ -82,7 +82,7 @@ bool ChatHandler::isAvailable(ChatCommand const& cmd) const
|
||||
|
||||
bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
|
||||
{
|
||||
WorldSession* target_session = NULL;
|
||||
WorldSession* target_session = nullptr;
|
||||
uint32 target_account = 0;
|
||||
|
||||
if (target)
|
||||
@@ -117,7 +117,7 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
|
||||
else if (target_account)
|
||||
target_sec = AccountMgr::GetSecurity(target_account, realm.Id.Realm);
|
||||
else
|
||||
return true; // caller must report error for (target == NULL && target_account == 0)
|
||||
return true; // caller must report error for (target == nullptr && target_account == 0)
|
||||
|
||||
AccountTypes target_ac_sec = AccountTypes(target_sec);
|
||||
if (m_session->GetSecurity() < target_ac_sec || (strong && m_session->GetSecurity() <= target_ac_sec))
|
||||
@@ -540,7 +540,7 @@ bool ChatHandler::ShowHelpForCommand(std::vector<ChatCommand> const& table, cons
|
||||
continue;
|
||||
|
||||
// have subcommand
|
||||
char const* subcmd = (*cmd) ? strtok(NULL, " ") : "";
|
||||
char const* subcmd = (*cmd) ? strtok(nullptr, " ") : "";
|
||||
|
||||
if (!table[i].ChildCommands.empty() && subcmd && *subcmd)
|
||||
{
|
||||
@@ -586,7 +586,7 @@ bool ChatHandler::ShowHelpForCommand(std::vector<ChatCommand> const& table, cons
|
||||
Player* ChatHandler::getSelectedPlayer()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
ObjectGuid selected = m_session->GetPlayer()->GetTarget();
|
||||
if (!selected)
|
||||
@@ -598,7 +598,7 @@ Player* ChatHandler::getSelectedPlayer()
|
||||
Unit* ChatHandler::getSelectedUnit()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (Unit* selected = m_session->GetPlayer()->GetSelectedUnit())
|
||||
return selected;
|
||||
@@ -609,7 +609,7 @@ Unit* ChatHandler::getSelectedUnit()
|
||||
WorldObject* ChatHandler::getSelectedObject()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
ObjectGuid guid = m_session->GetPlayer()->GetTarget();
|
||||
|
||||
@@ -622,7 +622,7 @@ WorldObject* ChatHandler::getSelectedObject()
|
||||
Creature* ChatHandler::getSelectedCreature()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return ObjectAccessor::GetCreatureOrPetOrVehicle(*m_session->GetPlayer(), m_session->GetPlayer()->GetTarget());
|
||||
}
|
||||
@@ -630,7 +630,7 @@ Creature* ChatHandler::getSelectedCreature()
|
||||
Player* ChatHandler::getSelectedPlayerOrSelf()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
ObjectGuid selected = m_session->GetPlayer()->GetTarget();
|
||||
if (!selected)
|
||||
@@ -649,14 +649,14 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** s
|
||||
{
|
||||
// skip empty
|
||||
if (!text)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// skip spaces
|
||||
while (*text == ' '||*text == '\t'||*text == '\b')
|
||||
++text;
|
||||
|
||||
if (!*text)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// return non link case
|
||||
if (text[0] != '|')
|
||||
@@ -668,28 +668,28 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** s
|
||||
|
||||
char* check = strtok(text, "|"); // skip color
|
||||
if (!check)
|
||||
return NULL; // end of data
|
||||
return nullptr; // end of data
|
||||
|
||||
char* cLinkType = strtok(NULL, ":"); // linktype
|
||||
char* cLinkType = strtok(nullptr, ":"); // linktype
|
||||
if (!cLinkType)
|
||||
return NULL; // end of data
|
||||
return nullptr; // end of data
|
||||
|
||||
if (strcmp(cLinkType, linkType) != 0)
|
||||
{
|
||||
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after retturn from function
|
||||
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after retturn from function
|
||||
SendSysMessage(LANG_WRONG_LINK_TYPE);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char* cKeys = strtok(NULL, "|"); // extract keys and values
|
||||
char* cKeysTail = strtok(NULL, "");
|
||||
char* cKeys = strtok(nullptr, "|"); // extract keys and values
|
||||
char* cKeysTail = strtok(nullptr, "");
|
||||
|
||||
char* cKey = strtok(cKeys, ":|"); // extract key
|
||||
if (something1)
|
||||
*something1 = strtok(NULL, ":|"); // extract something
|
||||
*something1 = strtok(nullptr, ":|"); // extract something
|
||||
|
||||
strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
|
||||
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after return from function
|
||||
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
|
||||
return cKey;
|
||||
}
|
||||
|
||||
@@ -697,14 +697,14 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes,
|
||||
{
|
||||
// skip empty
|
||||
if (!text)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// skip spaces
|
||||
while (*text == ' '||*text == '\t'||*text == '\b')
|
||||
++text;
|
||||
|
||||
if (!*text)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// return non link case
|
||||
if (text[0] != '|')
|
||||
@@ -722,48 +722,48 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes,
|
||||
{
|
||||
char* check = strtok(text, "|"); // skip color
|
||||
if (!check)
|
||||
return NULL; // end of data
|
||||
return nullptr; // end of data
|
||||
|
||||
tail = strtok(NULL, ""); // tail
|
||||
tail = strtok(nullptr, ""); // tail
|
||||
}
|
||||
else
|
||||
tail = text+1; // skip first |
|
||||
|
||||
char* cLinkType = strtok(tail, ":"); // linktype
|
||||
if (!cLinkType)
|
||||
return NULL; // end of data
|
||||
return nullptr; // end of data
|
||||
|
||||
for (int i = 0; linkTypes[i]; ++i)
|
||||
{
|
||||
if (strcmp(cLinkType, linkTypes[i]) == 0)
|
||||
{
|
||||
char* cKeys = strtok(NULL, "|"); // extract keys and values
|
||||
char* cKeysTail = strtok(NULL, "");
|
||||
char* cKeys = strtok(nullptr, "|"); // extract keys and values
|
||||
char* cKeysTail = strtok(nullptr, "");
|
||||
|
||||
char* cKey = strtok(cKeys, ":|"); // extract key
|
||||
if (something1)
|
||||
*something1 = strtok(NULL, ":|"); // extract something
|
||||
*something1 = strtok(nullptr, ":|"); // extract something
|
||||
|
||||
strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces
|
||||
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after return from function
|
||||
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
|
||||
if (found_idx)
|
||||
*found_idx = i;
|
||||
return cKey;
|
||||
}
|
||||
}
|
||||
|
||||
strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL, s) use after return from function
|
||||
strtok(nullptr, " "); // skip link tail (to allow continue strtok(nullptr, s) use after return from function
|
||||
SendSysMessage(LANG_WRONG_LINK_TYPE);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GameObject* ChatHandler::GetNearbyGameObject()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
Player* pl = m_session->GetPlayer();
|
||||
GameObject* obj = NULL;
|
||||
GameObject* obj = nullptr;
|
||||
Trinity::NearestGameObjectCheck check(*pl);
|
||||
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectCheck> searcher(pl, obj, check);
|
||||
pl->VisitNearbyGridObject(SIZE_OF_GRIDS, searcher);
|
||||
@@ -773,7 +773,7 @@ GameObject* ChatHandler::GetNearbyGameObject()
|
||||
GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::LowType lowguid, uint32 entry)
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
Player* pl = m_session->GetPlayer();
|
||||
|
||||
@@ -818,7 +818,7 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
|
||||
// number or [name] Shift-click form |color|Htalent:talent_id, rank|h[name]|h|r
|
||||
// number or [name] Shift-click form |color|Htrade:spell_id, skill_id, max_value, cur_value|h[name]|h|r
|
||||
int type = 0;
|
||||
char* param1_str = NULL;
|
||||
char* param1_str = nullptr;
|
||||
char* idS = extractKeyFromLink(text, spellKeys, &type, ¶m1_str);
|
||||
if (!idS)
|
||||
return 0;
|
||||
@@ -862,7 +862,7 @@ GameTele const* ChatHandler::extractGameTeleFromLink(char* text)
|
||||
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||
char* cId = extractKeyFromLink(text, "Htele");
|
||||
if (!cId)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// id case (explicit or from shift link)
|
||||
if (cId[0] >= '0' || cId[0] >= '9')
|
||||
@@ -949,7 +949,7 @@ std::string ChatHandler::extractPlayerNameFromLink(char* text)
|
||||
return name;
|
||||
}
|
||||
|
||||
bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*=NULL*/, std::string* player_name /*= NULL*/)
|
||||
bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* player_guid /*= nullptr*/, std::string* player_name /*= nullptr*/)
|
||||
{
|
||||
if (args && *args)
|
||||
{
|
||||
@@ -1005,12 +1005,12 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* p
|
||||
void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
|
||||
{
|
||||
char* p1 = strtok(args, " ");
|
||||
char* p2 = strtok(NULL, " ");
|
||||
char* p2 = strtok(nullptr, " ");
|
||||
|
||||
if (!p2)
|
||||
{
|
||||
p2 = p1;
|
||||
p1 = NULL;
|
||||
p1 = nullptr;
|
||||
}
|
||||
|
||||
if (arg1)
|
||||
@@ -1023,7 +1023,7 @@ void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
|
||||
char* ChatHandler::extractQuotedArg(char* args)
|
||||
{
|
||||
if (!args || !*args)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (*args == '"')
|
||||
return strtok(args+1, "\"");
|
||||
@@ -1036,9 +1036,9 @@ char* ChatHandler::extractQuotedArg(char* args)
|
||||
continue;
|
||||
}
|
||||
|
||||
// return NULL if we reached the end of the string
|
||||
// return nullptr if we reached the end of the string
|
||||
if (!*args)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// since we skipped all spaces, we expect another token now
|
||||
if (*args == '"')
|
||||
@@ -1056,7 +1056,7 @@ char* ChatHandler::extractQuotedArg(char* args)
|
||||
return strtok(args + 1, "\"");
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1110,7 +1110,7 @@ bool CliHandler::needReportToTarget(Player* /*chr*/) const
|
||||
|
||||
bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline)
|
||||
{
|
||||
player = NULL;
|
||||
player = nullptr;
|
||||
guid.Clear();
|
||||
|
||||
if (cname)
|
||||
|
||||
Reference in New Issue
Block a user