mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-06 12:27:48 +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:
@@ -100,7 +100,7 @@ World::World()
|
||||
m_allowMovement = true;
|
||||
m_ShutdownMask = 0;
|
||||
m_ShutdownTimer = 0;
|
||||
m_gameTime = time(NULL);
|
||||
m_gameTime = time(nullptr);
|
||||
m_gameMSTime = getMSTime();
|
||||
m_startTime = m_gameTime;
|
||||
m_maxActiveSessionCount = 0;
|
||||
@@ -147,7 +147,7 @@ World::~World()
|
||||
m_offlineSessions.erase(m_offlineSessions.begin());
|
||||
}
|
||||
|
||||
CliCommandHolder* command = NULL;
|
||||
CliCommandHolder* command = nullptr;
|
||||
while (cliCmdQueue.next(command))
|
||||
delete command;
|
||||
|
||||
@@ -180,7 +180,7 @@ Player* World::FindPlayerInZone(uint32 zone)
|
||||
if (player->IsInWorld() && player->GetZoneId() == zone)
|
||||
return player;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool World::IsClosed() const
|
||||
@@ -204,7 +204,7 @@ WorldSession* World::FindSession(uint32 id) const
|
||||
if (itr != m_sessions.end())
|
||||
return itr->second; // also can return NULL for kicked session
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WorldSession* World::FindOfflineSession(uint32 id) const
|
||||
@@ -213,17 +213,17 @@ WorldSession* World::FindOfflineSession(uint32 id) const
|
||||
if (itr != m_offlineSessions.end())
|
||||
return itr->second;
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WorldSession* World::FindOfflineSessionForCharacterGUID(uint32 guidLow) const
|
||||
{
|
||||
if (m_offlineSessions.empty())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
for (SessionMap::const_iterator itr = m_offlineSessions.begin(); itr != m_offlineSessions.end(); ++itr)
|
||||
if (itr->second->GetGuidLow() == guidLow)
|
||||
return itr->second;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// Remove a given session
|
||||
@@ -267,7 +267,7 @@ void World::AddSession_(WorldSession* s)
|
||||
WorldSession* oldSession = old->second;
|
||||
|
||||
if (!RemoveQueuedPlayer(oldSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
|
||||
m_disconnects[s->GetAccountId()] = time(NULL);
|
||||
m_disconnects[s->GetAccountId()] = time(nullptr);
|
||||
|
||||
// pussywizard:
|
||||
if (oldSession->HandleSocketClosed())
|
||||
@@ -281,7 +281,7 @@ void World::AddSession_(WorldSession* s)
|
||||
tmp->SetShouldSetOfflineInDB(false);
|
||||
delete tmp;
|
||||
}
|
||||
oldSession->SetOfflineTime(time(NULL));
|
||||
oldSession->SetOfflineTime(time(nullptr));
|
||||
m_offlineSessions[oldSession->GetAccountId()] = oldSession;
|
||||
}
|
||||
else
|
||||
@@ -323,7 +323,7 @@ bool World::HasRecentlyDisconnected(WorldSession* session)
|
||||
{
|
||||
for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end();)
|
||||
{
|
||||
if ((time(NULL) - i->second) < tolerance)
|
||||
if ((time(nullptr) - i->second) < tolerance)
|
||||
{
|
||||
if (i->first == session->GetAccountId())
|
||||
return true;
|
||||
@@ -1392,7 +1392,7 @@ void World::SetInitialWorldSettings()
|
||||
uint32 startupBegin = getMSTime();
|
||||
|
||||
///- Initialize the random number generator
|
||||
srand((unsigned int)time(NULL));
|
||||
srand((unsigned int)time(nullptr));
|
||||
|
||||
///- Initialize detour memory management
|
||||
dtAllocSetCustom(dtCustomAlloc, dtCustomFree);
|
||||
@@ -1897,7 +1897,7 @@ void World::SetInitialWorldSettings()
|
||||
|
||||
///- Initialize game time and timers
|
||||
sLog->outString("Initialize game time and timers");
|
||||
m_gameTime = time(NULL);
|
||||
m_gameTime = time(nullptr);
|
||||
m_startTime = m_gameTime;
|
||||
|
||||
LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES(%u, %u, 0, '%s')",
|
||||
@@ -1922,7 +1922,7 @@ void World::SetInitialWorldSettings()
|
||||
// our speed up
|
||||
m_timers[WUPDATE_5_SECS].SetInterval(5*IN_MILLISECONDS);
|
||||
|
||||
mail_expire_check_timer = time(NULL) + 6*3600;
|
||||
mail_expire_check_timer = time(nullptr) + 6*3600;
|
||||
|
||||
///- Initilize static helper structures
|
||||
AIRegistry::Initialize();
|
||||
@@ -2376,7 +2376,7 @@ namespace acore
|
||||
{
|
||||
public:
|
||||
typedef std::vector<WorldPacket*> WorldPacketList;
|
||||
explicit WorldWorldTextBuilder(uint32 textId, va_list* args = NULL) : i_textId(textId), i_args(args) {}
|
||||
explicit WorldWorldTextBuilder(uint32 textId, va_list* args = nullptr) : i_textId(textId), i_args(args) {}
|
||||
void operator()(WorldPacketList& data_list, LocaleConstant loc_idx)
|
||||
{
|
||||
char const* text = sObjectMgr->GetAcoreString(i_textId, loc_idx);
|
||||
@@ -2397,14 +2397,14 @@ namespace acore
|
||||
do_helper(data_list, (char*)text);
|
||||
}
|
||||
private:
|
||||
char* lineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = NULL; return start; }
|
||||
char* lineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = nullptr; return start; }
|
||||
void do_helper(WorldPacketList& data_list, char* text)
|
||||
{
|
||||
char* pos = text;
|
||||
while (char* line = lineFromMessage(pos))
|
||||
{
|
||||
WorldPacket* data = new WorldPacket();
|
||||
ChatHandler::BuildChatPacket(*data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
|
||||
ChatHandler::BuildChatPacket(*data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
|
||||
data_list.push_back(data);
|
||||
}
|
||||
}
|
||||
@@ -2467,7 +2467,7 @@ void World::SendGlobalText(const char* text, WorldSession* self)
|
||||
|
||||
while (char* line = ChatHandler::LineFromMessage(pos))
|
||||
{
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, line);
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
|
||||
SendGlobalMessage(&data, self);
|
||||
}
|
||||
|
||||
@@ -2501,7 +2501,7 @@ bool World::SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self
|
||||
void World::SendZoneText(uint32 zone, const char* text, WorldSession* self, TeamId teamId)
|
||||
{
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, NULL, text);
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, text);
|
||||
SendZoneMessage(zone, &data, self, teamId);
|
||||
}
|
||||
|
||||
@@ -2532,7 +2532,7 @@ void World::KickAllLess(AccountTypes sec)
|
||||
void World::_UpdateGameTime()
|
||||
{
|
||||
///- update the time
|
||||
time_t thisTime = time(NULL);
|
||||
time_t thisTime = time(nullptr);
|
||||
uint32 elapsed = uint32(thisTime - m_gameTime);
|
||||
m_gameTime = thisTime;
|
||||
m_gameMSTime = getMSTime();
|
||||
@@ -2650,7 +2650,7 @@ void World::SendServerMessage(ServerMessageType type, const char *text, Player*
|
||||
void World::UpdateSessions(uint32 diff)
|
||||
{
|
||||
///- Add new sessions
|
||||
WorldSession* sess = NULL;
|
||||
WorldSession* sess = nullptr;
|
||||
while (addSessQueue.next(sess))
|
||||
AddSession_ (sess);
|
||||
|
||||
@@ -2668,7 +2668,7 @@ void World::UpdateSessions(uint32 diff)
|
||||
if (pSession->HandleSocketClosed())
|
||||
{
|
||||
if (!RemoveQueuedPlayer(pSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
|
||||
m_disconnects[pSession->GetAccountId()] = time(NULL);
|
||||
m_disconnects[pSession->GetAccountId()] = time(nullptr);
|
||||
m_sessions.erase(itr);
|
||||
// there should be no offline session if current one is logged onto a character
|
||||
SessionMap::iterator iter;
|
||||
@@ -2679,7 +2679,7 @@ void World::UpdateSessions(uint32 diff)
|
||||
tmp->SetShouldSetOfflineInDB(false);
|
||||
delete tmp;
|
||||
}
|
||||
pSession->SetOfflineTime(time(NULL));
|
||||
pSession->SetOfflineTime(time(nullptr));
|
||||
m_offlineSessions[pSession->GetAccountId()] = pSession;
|
||||
continue;
|
||||
}
|
||||
@@ -2687,7 +2687,7 @@ void World::UpdateSessions(uint32 diff)
|
||||
if (!pSession->Update(diff, updater))
|
||||
{
|
||||
if (!RemoveQueuedPlayer(pSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
|
||||
m_disconnects[pSession->GetAccountId()] = time(NULL);
|
||||
m_disconnects[pSession->GetAccountId()] = time(nullptr);
|
||||
m_sessions.erase(itr);
|
||||
if (m_offlineSessions.find(pSession->GetAccountId()) != m_offlineSessions.end()) // pussywizard: don't set offline in db because offline session for that acc is present (character is in world)
|
||||
pSession->SetShouldSetOfflineInDB(false);
|
||||
@@ -2698,7 +2698,7 @@ void World::UpdateSessions(uint32 diff)
|
||||
// pussywizard:
|
||||
if (m_offlineSessions.empty())
|
||||
return;
|
||||
uint32 currTime = time(NULL);
|
||||
uint32 currTime = time(nullptr);
|
||||
for (SessionMap::iterator itr = m_offlineSessions.begin(), next; itr != m_offlineSessions.end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
@@ -2717,9 +2717,9 @@ void World::UpdateSessions(uint32 diff)
|
||||
// This handles the issued and queued CLI commands
|
||||
void World::ProcessCliCommands()
|
||||
{
|
||||
CliCommandHolder::Print* zprint = NULL;
|
||||
void* callbackArg = NULL;
|
||||
CliCommandHolder* command = NULL;
|
||||
CliCommandHolder::Print* zprint = nullptr;
|
||||
void* callbackArg = nullptr;
|
||||
CliCommandHolder* command = nullptr;
|
||||
while (cliCmdQueue.next(command))
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
@@ -2836,7 +2836,7 @@ time_t World::GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour)
|
||||
{
|
||||
if (hour < 0 || hour > 23)
|
||||
hour = 0;
|
||||
time_t curr = time(NULL);
|
||||
time_t curr = time(nullptr);
|
||||
tm localTm;
|
||||
ACE_OS::localtime_r(&curr, &localTm);
|
||||
localTm.tm_hour = hour;
|
||||
@@ -2857,7 +2857,7 @@ time_t World::GetNextTimeWithMonthAndHour(int8 month, int8 hour)
|
||||
{
|
||||
if (hour < 0 || hour > 23)
|
||||
hour = 0;
|
||||
time_t curr = time(NULL);
|
||||
time_t curr = time(nullptr);
|
||||
tm localTm;
|
||||
ACE_OS::localtime_r(&curr, &localTm);
|
||||
localTm.tm_mday = 1;
|
||||
@@ -3362,7 +3362,7 @@ GlobalPlayerData const* World::GetGlobalPlayerData(uint32 guid) const
|
||||
}
|
||||
|
||||
// Player not found
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32 World::GetGlobalPlayerGUID(std::string const& name) const
|
||||
|
||||
@@ -713,14 +713,14 @@ class World
|
||||
void SendGlobalGMMessage(WorldPacket* packet, WorldSession* self = 0, TeamId teamId = TEAM_NEUTRAL);
|
||||
bool SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self = 0, TeamId teamId = TEAM_NEUTRAL);
|
||||
void SendZoneText(uint32 zone, const char *text, WorldSession* self = 0, TeamId teamId = TEAM_NEUTRAL);
|
||||
void SendServerMessage(ServerMessageType type, const char *text = "", Player* player = NULL);
|
||||
void SendServerMessage(ServerMessageType type, const char *text = "", Player* player = nullptr);
|
||||
|
||||
/// Are we in the middle of a shutdown?
|
||||
bool IsShuttingDown() const { return m_ShutdownTimer > 0; }
|
||||
uint32 GetShutDownTimeLeft() const { return m_ShutdownTimer; }
|
||||
void ShutdownServ(uint32 time, uint32 options, uint8 exitcode);
|
||||
void ShutdownCancel();
|
||||
void ShutdownMsg(bool show = false, Player* player = NULL);
|
||||
void ShutdownMsg(bool show = false, Player* player = nullptr);
|
||||
static uint8 GetExitCode() { return m_ExitCode; }
|
||||
static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; }
|
||||
static bool IsStopped() { return m_stopEvent.value(); }
|
||||
|
||||
Reference in New Issue
Block a user