mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-31 17:43:47 +00:00
refactor(Core): NULL -> nullptr (#3275)
* NULL to nullptr * NULL to nullptr * NULL to nullptr * NULL to nullptr * NULL to nullptr Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com> Co-authored-by: Stefano Borzì <stefanoborzi32@gmail.com>
This commit is contained in:
@@ -84,7 +84,7 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId,
|
||||
bool Channel::IsBanned(uint64 guid) const
|
||||
{
|
||||
BannedContainer::const_iterator itr = bannedStore.find(GUID_LOPART(guid));
|
||||
return itr != bannedStore.end() && itr->second > time(NULL);
|
||||
return itr != bannedStore.end() && itr->second > time(nullptr);
|
||||
}
|
||||
|
||||
void Channel::UpdateChannelInDB() const
|
||||
@@ -417,8 +417,8 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
|
||||
{
|
||||
if (!IsBanned(victim))
|
||||
{
|
||||
bannedStore[GUID_LOPART(victim)] = time(NULL) + CHANNEL_BAN_DURATION;
|
||||
AddChannelBanToDB(GUID_LOPART(victim), time(NULL) + CHANNEL_BAN_DURATION);
|
||||
bannedStore[GUID_LOPART(victim)] = time(nullptr) + CHANNEL_BAN_DURATION;
|
||||
AddChannelBanToDB(GUID_LOPART(victim), time(nullptr) + CHANNEL_BAN_DURATION);
|
||||
|
||||
if (notify)
|
||||
{
|
||||
|
||||
@@ -120,7 +120,7 @@ Channel* ChannelMgr::GetChannel(std::string const& name, Player* player, bool pk
|
||||
player->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return i->second;
|
||||
|
||||
@@ -83,7 +83,7 @@ bool ChatHandler::isAvailable(ChatCommand const& cmd) const
|
||||
|
||||
bool ChatHandler::HasLowerSecurity(Player* target, uint64 guid, bool strong)
|
||||
{
|
||||
WorldSession* target_session = NULL;
|
||||
WorldSession* target_session = nullptr;
|
||||
uint32 target_account = 0;
|
||||
|
||||
if (target)
|
||||
@@ -166,7 +166,7 @@ void ChatHandler::SendSysMessage(const char *str)
|
||||
|
||||
while (char* line = LineFromMessage(pos))
|
||||
{
|
||||
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
|
||||
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
|
||||
m_session->SendPacket(&data);
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ void ChatHandler::SendGlobalSysMessage(const char *str)
|
||||
|
||||
while (char* line = LineFromMessage(pos))
|
||||
{
|
||||
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
|
||||
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
|
||||
sWorld->SendGlobalMessage(&data);
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ void ChatHandler::SendGlobalGMSysMessage(const char *str)
|
||||
|
||||
while (char* line = LineFromMessage(pos))
|
||||
{
|
||||
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
|
||||
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
|
||||
sWorld->SendGlobalGMMessage(&data);
|
||||
}
|
||||
|
||||
@@ -553,7 +553,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)
|
||||
{
|
||||
@@ -708,7 +708,7 @@ size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Languag
|
||||
Player* ChatHandler::getSelectedPlayer()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
uint64 selected = m_session->GetPlayer()->GetTarget();
|
||||
if (!selected)
|
||||
@@ -720,7 +720,7 @@ Player* ChatHandler::getSelectedPlayer()
|
||||
Unit* ChatHandler::getSelectedUnit()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (Unit* selected = m_session->GetPlayer()->GetSelectedUnit())
|
||||
return selected;
|
||||
@@ -731,7 +731,7 @@ Unit* ChatHandler::getSelectedUnit()
|
||||
WorldObject* ChatHandler::getSelectedObject()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
uint64 guid = m_session->GetPlayer()->GetTarget();
|
||||
|
||||
@@ -744,7 +744,7 @@ WorldObject* ChatHandler::getSelectedObject()
|
||||
Creature* ChatHandler::getSelectedCreature()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return ObjectAccessor::GetCreatureOrPetOrVehicle(*m_session->GetPlayer(), m_session->GetPlayer()->GetTarget());
|
||||
}
|
||||
@@ -752,7 +752,7 @@ Creature* ChatHandler::getSelectedCreature()
|
||||
Player* ChatHandler::getSelectedPlayerOrSelf()
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
uint64 selected = m_session->GetPlayer()->GetTarget();
|
||||
if (!selected)
|
||||
@@ -771,14 +771,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] != '|')
|
||||
@@ -790,28 +790,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;
|
||||
}
|
||||
|
||||
@@ -819,14 +819,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] != '|')
|
||||
@@ -844,48 +844,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;
|
||||
acore::NearestGameObjectCheck check(*pl);
|
||||
acore::GameObjectLastSearcher<acore::NearestGameObjectCheck> searcher(pl, obj, check);
|
||||
pl->VisitNearbyGridObject(SIZE_OF_GRIDS, searcher);
|
||||
@@ -895,7 +895,7 @@ GameObject* ChatHandler::GetNearbyGameObject()
|
||||
GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry)
|
||||
{
|
||||
if (!m_session)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
Player* pl = m_session->GetPlayer();
|
||||
|
||||
@@ -944,7 +944,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;
|
||||
@@ -995,7 +995,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')
|
||||
@@ -1141,12 +1141,12 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe
|
||||
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)
|
||||
@@ -1159,7 +1159,7 @@ void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
|
||||
char* ChatHandler::extractQuotedArg(char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (*args == '"')
|
||||
return strtok(args+1, "\"");
|
||||
@@ -1174,7 +1174,7 @@ char* ChatHandler::extractQuotedArg(char* args)
|
||||
|
||||
// return NULL 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 == '"')
|
||||
@@ -1192,7 +1192,7 @@ char* ChatHandler::extractQuotedArg(char* args)
|
||||
return strtok(args + 1, "\"");
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1246,7 +1246,7 @@ bool CliHandler::needReportToTarget(Player* /*chr*/) const
|
||||
|
||||
bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &player, Group* &group, uint64 &guid, bool offline)
|
||||
{
|
||||
player = NULL;
|
||||
player = nullptr;
|
||||
guid = 0;
|
||||
|
||||
if (cname)
|
||||
|
||||
@@ -53,7 +53,7 @@ class ChatHandler
|
||||
// Builds chat packet and returns receiver guid position in the packet to substitute in whisper builders
|
||||
static size_t BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, WorldObject const* sender, WorldObject const* receiver, std::string const& message, uint32 achievementId = 0, std::string const& channelName = "", LocaleConstant locale = DEFAULT_LOCALE);
|
||||
|
||||
static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = NULL; return start; }
|
||||
static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = nullptr; return start; }
|
||||
|
||||
// function with different implementation for chat/console
|
||||
virtual char const* GetAcoreString(uint32 entry) const;
|
||||
@@ -91,8 +91,8 @@ class ChatHandler
|
||||
// Returns either the selected player or self if there is no selected player
|
||||
Player* getSelectedPlayerOrSelf();
|
||||
|
||||
char* extractKeyFromLink(char* text, char const* linkType, char** something1 = NULL);
|
||||
char* extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = NULL);
|
||||
char* extractKeyFromLink(char* text, char const* linkType, char** something1 = nullptr);
|
||||
char* extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = nullptr);
|
||||
|
||||
// if args have single value then it return in arg2 and arg1 == NULL
|
||||
void extractOptFirstArg(char* args, char** arg1, char** arg2);
|
||||
@@ -104,7 +104,7 @@ class ChatHandler
|
||||
bool GetPlayerGroupAndGUIDByName(const char* cname, Player* &player, Group* &group, uint64 &guid, bool offline = false);
|
||||
std::string extractPlayerNameFromLink(char* text);
|
||||
// select by arg (name/link) or in-game selection online/offline player
|
||||
bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
|
||||
bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = nullptr);
|
||||
|
||||
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
|
||||
std::string GetNameLink(Player* chr) const;
|
||||
@@ -118,7 +118,7 @@ class ChatHandler
|
||||
|
||||
bool ShowHelpForCommand(std::vector<ChatCommand> const& table, const char* cmd);
|
||||
protected:
|
||||
explicit ChatHandler() : m_session(NULL), sentErrorMessage(false) {} // for CLI subclass
|
||||
explicit ChatHandler() : m_session(nullptr), sentErrorMessage(false) {} // for CLI subclass
|
||||
static bool SetDataForCommandInTable(std::vector<ChatCommand>& table, const char* text, uint32 securityLevel, std::string const& help, std::string const& fullcommand);
|
||||
bool ExecuteCommandInTable(std::vector<ChatCommand> const& table, const char* text, std::string const& fullcmd);
|
||||
bool ShowHelpForSubCommands(std::vector<ChatCommand> const& table, char const* cmd, char const* subcmd);
|
||||
|
||||
@@ -186,7 +186,7 @@ bool ItemChatLink::ValidateName(char* buffer, const char* context)
|
||||
{
|
||||
ChatLink::ValidateName(buffer, context);
|
||||
|
||||
char* const* suffixStrings = _suffix ? _suffix->nameSuffix : (_property ? _property->nameSuffix : NULL);
|
||||
char* const* suffixStrings = _suffix ? _suffix->nameSuffix : (_property ? _property->nameSuffix : nullptr);
|
||||
|
||||
bool res = (FormatName(LOCALE_enUS, NULL, suffixStrings) == buffer);
|
||||
|
||||
@@ -638,12 +638,12 @@ bool LinkExtractor::IsValidMessage()
|
||||
std::istringstream::pos_type startPos = 0;
|
||||
uint32 color = 0;
|
||||
|
||||
ChatLink* link = NULL;
|
||||
ChatLink* link = nullptr;
|
||||
while (!_iss.eof())
|
||||
{
|
||||
if (validSequence == validSequenceIterator)
|
||||
{
|
||||
link = NULL;
|
||||
link = nullptr;
|
||||
_iss.ignore(255, PIPE_CHAR);
|
||||
startPos = _iss.tellg() - std::istringstream::pos_type(1);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ protected:
|
||||
class ItemChatLink : public ChatLink
|
||||
{
|
||||
public:
|
||||
ItemChatLink() : ChatLink(), _item(NULL), _suffix(NULL), _property(NULL)
|
||||
ItemChatLink() : ChatLink(), _item(nullptr), _suffix(nullptr), _property(nullptr)
|
||||
{
|
||||
memset(_data, 0, sizeof(_data));
|
||||
}
|
||||
@@ -65,7 +65,7 @@ protected:
|
||||
class QuestChatLink : public ChatLink
|
||||
{
|
||||
public:
|
||||
QuestChatLink() : ChatLink(), _quest(NULL), _questLevel(0) { }
|
||||
QuestChatLink() : ChatLink(), _quest(nullptr), _questLevel(0) { }
|
||||
virtual bool Initialize(std::istringstream& iss);
|
||||
virtual bool ValidateName(char* buffer, const char* context);
|
||||
|
||||
@@ -78,7 +78,7 @@ protected:
|
||||
class SpellChatLink : public ChatLink
|
||||
{
|
||||
public:
|
||||
SpellChatLink() : ChatLink(), _spell(NULL) { }
|
||||
SpellChatLink() : ChatLink(), _spell(nullptr) { }
|
||||
virtual bool Initialize(std::istringstream& iss);
|
||||
virtual bool ValidateName(char* buffer, const char* context);
|
||||
|
||||
@@ -90,7 +90,7 @@ protected:
|
||||
class AchievementChatLink : public ChatLink
|
||||
{
|
||||
public:
|
||||
AchievementChatLink() : ChatLink(), _guid(0), _achievement(NULL)
|
||||
AchievementChatLink() : ChatLink(), _guid(0), _achievement(nullptr)
|
||||
{
|
||||
memset(_data, 0, sizeof(_data));
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
class GlyphChatLink : public SpellChatLink
|
||||
{
|
||||
public:
|
||||
GlyphChatLink() : SpellChatLink(), _slotId(0), _glyph(NULL) { }
|
||||
GlyphChatLink() : SpellChatLink(), _slotId(0), _glyph(nullptr) { }
|
||||
virtual bool Initialize(std::istringstream& iss);
|
||||
private:
|
||||
uint32 _slotId;
|
||||
|
||||
Reference in New Issue
Block a user