Skip to content

Commit

Permalink
Use nullptr instead of NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
marksamman committed Sep 22, 2013
1 parent 42df6e4 commit 70d48df
Show file tree
Hide file tree
Showing 93 changed files with 791 additions and 791 deletions.
18 changes: 9 additions & 9 deletions src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Event* Actions::getEvent(const std::string& nodeName)
if (asLowerCaseString(nodeName) == "action") {
return new Action(&m_scriptInterface);
} else {
return NULL;
return nullptr;
}
}

Expand Down Expand Up @@ -288,7 +288,7 @@ Action* Actions::getAction(const Item* item)
if (runeSpell) {
return runeSpell;
}
return NULL;
return nullptr;
}

ReturnValue Actions::internalUseItem(Player* player, const Position& pos,
Expand Down Expand Up @@ -330,7 +330,7 @@ ReturnValue Actions::internalUseItem(Player* player, const Position& pos,
}

if (Container* container = item->getContainer()) {
Container* openContainer = NULL;
Container* openContainer = nullptr;

//depot container
if (DepotLocker* depot = container->getDepotLocker()) {
Expand Down Expand Up @@ -364,7 +364,7 @@ ReturnValue Actions::internalUseItem(Player* player, const Position& pos,
player->setWriteItem(item, item->getMaxWriteLength());
player->sendTextWindow(item, item->getMaxWriteLength(), true);
} else {
player->setWriteItem(NULL);
player->setWriteItem(nullptr);
player->sendTextWindow(item, 0, false);
}

Expand All @@ -380,7 +380,7 @@ bool Actions::useItem(Player* player, const Position& pos, uint8_t index, Item*
return false;
}

player->setNextActionTask(NULL);
player->setNextActionTask(nullptr);
player->setNextAction(OTSYS_TIME() + g_config.getNumber(ConfigManager::ACTIONS_DELAY_INTERVAL));
player->stopWalk();

Expand All @@ -405,7 +405,7 @@ bool Actions::useItemEx(Player* player, const Position& fromPos, const Position&
return false;
}

player->setNextActionTask(NULL);
player->setNextActionTask(nullptr);
player->setNextAction(OTSYS_TIME() + g_config.getNumber(ConfigManager::EX_ACTIONS_DELAY_INTERVAL));
player->stopWalk();

Expand Down Expand Up @@ -458,15 +458,15 @@ void Actions::showUseHotkeyMessage(Player* player, int32_t id, uint32_t count)

bool Actions::hasAction(const Item* item)
{
return getAction(item) != NULL;
return getAction(item) != nullptr;
}

Action::Action(LuaScriptInterface* _interface) :
Event(_interface)
{
allowFarUse = false;
checkLineOfSight = true;
function = NULL;
function = nullptr;
}

Action::Action(const Action* copy) :
Expand Down Expand Up @@ -579,7 +579,7 @@ bool Action::executeUse(Player* player, Item* item, const PositionEx& fromPos, c
LuaScriptInterface::pushThing(L, thing, env->addThing(thing));
LuaScriptInterface::pushPosition(L, toPos, toPos.stackpos);
} else {
LuaScriptInterface::pushThing(L, NULL, 0);
LuaScriptInterface::pushThing(L, nullptr, 0);
Position posEx;
LuaScriptInterface::pushPosition(L, posEx, 0);
}
Expand Down
22 changes: 11 additions & 11 deletions src/admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extern Game g_game;
extern ConfigManager g_config;
extern Ban g_bans;

AdminProtocolConfig* g_adminConfig = NULL;
AdminProtocolConfig* g_adminConfig = nullptr;

#ifdef __ENABLE_SERVER_DIAGNOSTIC__
uint32_t ProtocolAdmin::protocolAdminCount = 0;
Expand All @@ -54,7 +54,7 @@ ProtocolAdmin::ProtocolAdmin(Connection_ptr connection) :
m_state = NO_CONNECTED;
m_loginTries = 0;
m_lastCommand = 0;
m_startTime = time(NULL);
m_startTime = time(nullptr);
#ifdef __ENABLE_SERVER_DIAGNOSTIC__
protocolAdminCount++;
#endif
Expand Down Expand Up @@ -104,13 +104,13 @@ void ProtocolAdmin::onRecvFirstMessage(NetworkMessage& msg)
OutputMessagePool::getInstance()->send(output);
}

m_lastCommand = time(NULL);
m_lastCommand = time(nullptr);
m_state = ENCRYPTION_NO_SET;
}

void ProtocolAdmin::deleteProtocolTask()
{
addLogLine(NULL, LOGTYPE_EVENT, 1, "end connection");
addLogLine(nullptr, LOGTYPE_EVENT, 1, "end connection");
g_adminConfig->removeConnection();
Protocol::deleteProtocolTask();
}
Expand All @@ -134,7 +134,7 @@ void ProtocolAdmin::parsePacket(NetworkMessage& msg)
switch (m_state) {
case ENCRYPTION_NO_SET: {
if (g_adminConfig->requireEncryption()) {
if ((time(NULL) - m_startTime) > 30000) {
if ((time(nullptr) - m_startTime) > 30000) {
getConnection()->closeConnection();
addLogLine(this, LOGTYPE_WARNING, 1, "encryption timeout");
return;
Expand All @@ -157,7 +157,7 @@ void ProtocolAdmin::parsePacket(NetworkMessage& msg)

case NO_LOGGED_IN: {
if (g_adminConfig->requireLogin()) {
if ((time(NULL) - m_startTime) > 30000) {
if ((time(nullptr) - m_startTime) > 30000) {
//login timeout
getConnection()->closeConnection();
addLogLine(this, LOGTYPE_WARNING, 1, "login timeout");
Expand Down Expand Up @@ -199,7 +199,7 @@ void ProtocolAdmin::parsePacket(NetworkMessage& msg)
}
}

m_lastCommand = time(NULL);
m_lastCommand = time(nullptr);

switch (recvbyte) {
case AP_MSG_LOGIN: {
Expand Down Expand Up @@ -503,7 +503,7 @@ AdminProtocolConfig::AdminProtocolConfig()
m_maxConnections = 1;
m_currrentConnections = 0;
m_password = "";
m_key_RSA1024XTEA = NULL;
m_key_RSA1024XTEA = nullptr;
m_requireLogin = true;
m_requireEncryption = false;
}
Expand Down Expand Up @@ -559,7 +559,7 @@ bool AdminProtocolConfig::loadXMLConfig()
m_key_RSA1024XTEA = new RSA();
if (!m_key_RSA1024XTEA->setKey("data/XML/" + std::string(encryptionFile.as_string()))) {
delete m_key_RSA1024XTEA;
m_key_RSA1024XTEA = NULL;
m_key_RSA1024XTEA = nullptr;
std::cout << "[AdminProtocolConfig::loadXMLConfig - Warning] Can not load key from data/XML/" << encryptionFile.as_string() << std::endl;
}
}
Expand Down Expand Up @@ -602,7 +602,7 @@ bool AdminProtocolConfig::passwordMatch(const std::string& password)
bool AdminProtocolConfig::allowIP(uint32_t ip)
{
if (m_onlyLocalHost && ip != 0x0100007F) { //127.0.0.1
addLogLine(NULL, LOGTYPE_WARNING, 1, std::string("forbidden connection try from ") + convertIPToString(ip));
addLogLine(nullptr, LOGTYPE_WARNING, 1, std::string("forbidden connection try from ") + convertIPToString(ip));
return false;
}
return true;
Expand Down Expand Up @@ -653,7 +653,7 @@ RSA* AdminProtocolConfig::getRSAKey(uint8_t type)
return m_key_RSA1024XTEA;

default:
return NULL;
return nullptr;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/ban.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ bool IOBan::isAccountBanned(uint32_t accountId, BanInfo& banInfo)
}

int64_t expiresAt = result->getNumber<int64_t>("expires_at");
if (expiresAt != 0 && time(NULL) > expiresAt) {
if (expiresAt != 0 && time(nullptr) > expiresAt) {
// Move the ban to history if it has expired
query << "INSERT INTO `account_ban_history` (`account_id`, `reason`, `banned_at`, `expired_at`, `banned_by`) VALUES (" << accountId << ',' << db->escapeString(result->getDataString("reason")) << ',' << result->getDataInt("banned_at") << ',' << expiresAt << ',' << result->getDataInt("banned_by") << ')';
db->executeQuery(query.str());
Expand Down Expand Up @@ -116,7 +116,7 @@ bool IOBan::isIpBanned(uint32_t clientip, BanInfo& banInfo)
}

int64_t expiresAt = result->getNumber<int64_t>("expires_at");
if (expiresAt != 0 && time(NULL) > expiresAt) {
if (expiresAt != 0 && time(nullptr) > expiresAt) {
query << "DELETE FROM `ip_bans` WHERE `ip` = " << clientip;
db->executeQuery(query.str());

Expand Down
6 changes: 3 additions & 3 deletions src/baseevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool Event::checkScript(const std::string& basePath, const std::string& scriptsN
bool Event::loadScript(const std::string& scriptFile)
{
if (!m_scriptInterface || m_scriptId != 0) {
std::cout << "Failure: [Event::loadScript] m_scriptInterface == NULL. scriptid = " << m_scriptId << std::endl;
std::cout << "Failure: [Event::loadScript] m_scriptInterface == nullptr. scriptid = " << m_scriptId << std::endl;
return false;
}

Expand Down Expand Up @@ -179,7 +179,7 @@ bool Event::loadFunction(const std::string& functionName)
CallBack::CallBack()
{
m_scriptId = 0;
m_scriptInterface = NULL;
m_scriptInterface = nullptr;
m_loaded = false;
}

Expand All @@ -191,7 +191,7 @@ CallBack::~CallBack()
bool CallBack::loadCallBack(LuaScriptInterface* _interface, const std::string& name)
{
if (!_interface) {
std::cout << "Failure: [CallBack::loadCallBack] m_scriptInterface == NULL" << std::endl;
std::cout << "Failure: [CallBack::loadCallBack] m_scriptInterface == nullptr" << std::endl;
return false;
}

Expand Down
22 changes: 11 additions & 11 deletions src/beds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern Game g_game;

BedItem::BedItem(uint16_t _id) : Item(_id)
{
house = NULL;
house = nullptr;
internalRemoveSleeper();
}

Expand Down Expand Up @@ -93,7 +93,7 @@ BedItem* BedItem::getNextBedItem()

Tile* tile = g_game.getMap()->getTile(targetPos);
if (!tile) {
return NULL;
return nullptr;
}
return tile->getBedItem();
}
Expand All @@ -112,7 +112,7 @@ bool BedItem::canUse(Player* player)
return true;
}

Player sleeper(NULL);
Player sleeper(nullptr);
if (!IOLoginData::getInstance()->loadPlayerById(&sleeper, sleeperGUID)) {
return false;
}
Expand All @@ -131,7 +131,7 @@ bool BedItem::trySleep(Player* player)

if (sleeperGUID != 0) {
if (Item::items[getID()].transformToFree != 0 && house->getHouseOwner() == player->getGUID()) {
wakeUp(NULL);
wakeUp(nullptr);
}

g_game.addMagicEffect(player->getPosition(), NM_ME_POFF);
Expand Down Expand Up @@ -190,7 +190,7 @@ void BedItem::wakeUp(Player* player)

if (sleeperGUID != 0) {
if (!player) {
Player _player(NULL);
Player _player(nullptr);
if (IOLoginData::getInstance()->loadPlayerById(&_player, sleeperGUID)) {
regeneratePlayer(&_player);
IOLoginData::getInstance()->savePlayer(&_player);
Expand All @@ -202,7 +202,7 @@ void BedItem::wakeUp(Player* player)
}

// update the BedSleepersMap
Beds::getInstance().setBedSleeper(NULL, sleeperGUID);
Beds::getInstance().setBedSleeper(nullptr, sleeperGUID);

BedItem* nextBedItem = getNextBedItem();

Expand All @@ -214,16 +214,16 @@ void BedItem::wakeUp(Player* player)
}

// change self and partner's appearance
updateAppearance(NULL);
updateAppearance(nullptr);

if (nextBedItem) {
nextBedItem->updateAppearance(NULL);
nextBedItem->updateAppearance(nullptr);
}
}

void BedItem::regeneratePlayer(Player* player) const
{
int32_t sleptTime = int32_t(time(NULL) - sleepStart);
int32_t sleptTime = int32_t(time(nullptr) - sleepStart);

Condition* condition = player->getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT);
if (condition) {
Expand Down Expand Up @@ -271,7 +271,7 @@ void BedItem::internalSetSleeper(const Player* player)
std::string desc_str = player->getName() + " is sleeping there.";

setSleeper(player->getGUID());
setSleepStart(time(NULL));
setSleepStart(time(nullptr));
setSpecialDescription(desc_str);
}

Expand All @@ -286,7 +286,7 @@ BedItem* Beds::getBedBySleeper(uint32_t guid)
{
auto it = BedSleepersMap.find(guid);
if (it == BedSleepersMap.end()) {
return NULL;
return nullptr;
}
return it->second;
}
Expand Down
2 changes: 1 addition & 1 deletion src/beds.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BedItem : public Item
virtual bool serializeAttr(PropWriteStream& propWriteStream) const;

virtual bool canRemove() const {
return (house == NULL);
return (house == nullptr);
}

uint32_t getSleeper() const {
Expand Down
Loading

0 comments on commit 70d48df

Please sign in to comment.