summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-04-27 21:42:58 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-04-27 21:42:58 +0200
commitd4f3105d9a879f27baad6e43b8b3cb6fe2f0ef50 (patch)
tree474ec7369f0d367d7780f73901d38d1daec4d2eb
parent2c14cd30ecbacbd5a808cb2641d40f6d568ec294 (diff)
downloadmanaserv-d4f3105d9a879f27baad6e43b8b3cb6fe2f0ef50.tar.gz
manaserv-d4f3105d9a879f27baad6e43b8b3cb6fe2f0ef50.tar.xz
manaserv-d4f3105d9a879f27baad6e43b8b3cb6fe2f0ef50.zip
Use nullptr instead of NULL everywhere
-rw-r--r--src/account-server/accountclient.cpp4
-rw-r--r--src/account-server/accounthandler.cpp2
-rw-r--r--src/account-server/character.cpp2
-rw-r--r--src/account-server/main-account.cpp6
-rw-r--r--src/account-server/serverhandler.cpp6
-rw-r--r--src/account-server/storage.cpp6
-rw-r--r--src/chat-server/chatchannelmanager.h4
-rw-r--r--src/chat-server/chathandler.cpp2
-rw-r--r--src/chat-server/chathandler.h6
-rw-r--r--src/chat-server/guildmanager.h4
-rw-r--r--src/chat-server/partyhandler.cpp2
-rw-r--r--src/chat-server/post.cpp4
-rw-r--r--src/common/configuration.cpp2
-rw-r--r--src/common/permissionmanager.cpp2
-rw-r--r--src/common/resourcemanager.cpp6
-rw-r--r--src/common/resourcemanager.h2
-rw-r--r--src/dal/mysqldataprovider.cpp4
-rw-r--r--src/dal/sqlitedataprovider.cpp2
-rw-r--r--src/game-server/character.cpp8
-rw-r--r--src/game-server/commandhandler.cpp6
-rw-r--r--src/game-server/gamehandler.cpp2
-rw-r--r--src/game-server/main-game.cpp4
-rw-r--r--src/game-server/mapcomposite.cpp6
-rw-r--r--src/game-server/mapmanager.cpp4
-rw-r--r--src/game-server/mapmanager.h2
-rw-r--r--src/game-server/mapreader.cpp2
-rw-r--r--src/game-server/monster.cpp2
-rw-r--r--src/game-server/state.cpp2
-rw-r--r--src/game-server/state.h2
-rw-r--r--src/net/connection.cpp4
-rw-r--r--src/net/connectionhandler.cpp2
-rw-r--r--src/scripting/lua.cpp20
-rw-r--r--src/scripting/luascript.cpp2
-rw-r--r--src/scripting/luautil.h2
-rw-r--r--src/scripting/script.cpp4
-rw-r--r--src/utils/base64.cpp6
-rw-r--r--src/utils/tokencollector.cpp6
-rw-r--r--src/utils/xml.cpp2
-rw-r--r--src/utils/xml.h2
39 files changed, 78 insertions, 78 deletions
diff --git a/src/account-server/accountclient.cpp b/src/account-server/accountclient.cpp
index f8134ba..814f2ab 100644
--- a/src/account-server/accountclient.cpp
+++ b/src/account-server/accountclient.cpp
@@ -23,7 +23,7 @@
AccountClient::AccountClient(ENetPeer *peer):
NetComputer(peer),
status(CLIENT_LOGIN),
- mAccount(NULL)
+ mAccount(nullptr)
{
}
@@ -41,5 +41,5 @@ void AccountClient::setAccount(Account *acc)
void AccountClient::unsetAccount()
{
delete mAccount;
- mAccount = NULL;
+ mAccount = nullptr;
}
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp
index 76a427e..b9397fe 100644
--- a/src/account-server/accounthandler.cpp
+++ b/src/account-server/accounthandler.cpp
@@ -346,7 +346,7 @@ void AccountHandler::handleLoginMessage(AccountClient &client, MessageIn &msg)
// Check whether the last login attempt for this IP is still too fresh
const int address = client.getIP();
- const time_t now = time(NULL);
+ const time_t now = time(nullptr);
IPsToTime::const_iterator it = mLastLoginAttemptForIP.find(address);
if (it != mLastLoginAttemptForIP.end())
{
diff --git a/src/account-server/character.cpp b/src/account-server/character.cpp
index eafae1c..61e59b4 100644
--- a/src/account-server/character.cpp
+++ b/src/account-server/character.cpp
@@ -27,7 +27,7 @@ CharacterData::CharacterData(const std::string &name, int id):
mDatabaseID(id),
mCharacterSlot(0),
mAccountID(-1),
- mAccount(NULL),
+ mAccount(nullptr),
mMapId(0),
mGender(0),
mHairStyle(0),
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp
index db69fe6..ee5fcaf 100644
--- a/src/account-server/main-account.cpp
+++ b/src/account-server/main-account.cpp
@@ -148,7 +148,7 @@ static void initialize()
utils::processor::init();
// Seed the random number generator
- std::srand( time(NULL) );
+ std::srand( time(nullptr) );
}
@@ -258,7 +258,7 @@ static void parseOptions(int argc, char *argv[], CommandLineOptions &options)
while (optind < argc)
{
- int result = getopt_long(argc, argv, optString, longOptions, NULL);
+ int result = getopt_long(argc, argv, optString, longOptions, nullptr);
if (result == -1)
break;
@@ -371,7 +371,7 @@ int main(int argc, char *argv[])
// Write startup time to database as system world state variable
std::stringstream timestamp;
- timestamp << time(NULL);
+ timestamp << time(nullptr);
storage->setWorldStateVar("accountserver_startup", timestamp.str(),
Storage::SystemMap);
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp
index 9ed317e..dbf74d0 100644
--- a/src/account-server/serverhandler.cpp
+++ b/src/account-server/serverhandler.cpp
@@ -139,7 +139,7 @@ static GameServer *getGameServerFromMap(int mapId)
if (it == server->maps.end()) continue;
return server;
}
- return NULL;
+ return nullptr;
}
bool GameServerHandler::getGameServerFromMap(int mapId,
@@ -432,7 +432,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
int level = msg.readInt16();
// get the character so we can get the account id
- CharacterData *c = storage->getCharacter(id, NULL);
+ CharacterData *c = storage->getCharacter(id, nullptr);
if (c)
{
storage->setAccountLevel(c->getAccountID(), level);
@@ -528,7 +528,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
result.writeInt32(senderId);
// get their characters
- CharacterData *sender = storage->getCharacter(senderId, NULL);
+ CharacterData *sender = storage->getCharacter(senderId, nullptr);
CharacterData *receiver = storage->getCharacter(receiverName);
if (!sender || !receiver)
{
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index dd8cf9a..1560547 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -56,7 +56,7 @@ static const char *DB_VERSION_PARAMETER = "database_version";
* SQLite3 specificities:
* - any column (but only one for each table) with the exact type of
* 'INTEGER PRIMARY KEY' is taken as auto-increment.
- * - the supported data types are: NULL, INTEGER, REAL, TEXT and BLOB
+ * - the supported data types are: nullptr, INTEGER, REAL, TEXT and BLOB
* (http://www.sqlite.org/datatype3.html)
* - the size of TEXT cannot be set, it is just ignored by the engine.
* - IMPORTANT: foreign key constraints are not yet supported
@@ -1912,7 +1912,7 @@ void Storage::storeLetter(Letter *letter)
{
// The letter was never saved before
sql << "INSERT INTO " << POST_TBL_NAME << " VALUES ( "
- << "NULL, "
+ << "nullptr, "
<< letter->getSender()->getDatabaseID() << ", "
<< letter->getReceiver()->getDatabaseID() << ", "
<< letter->getExpiry() << ", "
@@ -2207,7 +2207,7 @@ void Storage::addTransaction(const Transaction &trans)
{
std::stringstream sql;
sql << "INSERT INTO " << TRANSACTION_TBL_NAME
- << " VALUES (NULL, " << trans.mCharacterId << ", "
+ << " VALUES (nullptr, " << trans.mCharacterId << ", "
<< trans.mAction << ", "
<< "?, "
<< time(0) << ")";
diff --git a/src/chat-server/chatchannelmanager.h b/src/chat-server/chatchannelmanager.h
index b7f19ee..9a18954 100644
--- a/src/chat-server/chatchannelmanager.h
+++ b/src/chat-server/chatchannelmanager.h
@@ -76,14 +76,14 @@ class ChatChannelManager
/**
* Returns the chat channel with the given channel ID.
*
- * @return The chat channel, or NULL when it doesn't exist.
+ * @return The chat channel, or nullptr when it doesn't exist.
*/
ChatChannel *getChannel(int channelId);
/**
* Returns the chat channel with the given channel name.
*
- * @return The chat channel, or NULL when it doesn't exist.
+ * @return The chat channel, or nullptr when it doesn't exist.
*/
ChatChannel *getChannel(const std::string &name);
diff --git a/src/chat-server/chathandler.cpp b/src/chat-server/chathandler.cpp
index 209c31c..e1bb10d 100644
--- a/src/chat-server/chathandler.cpp
+++ b/src/chat-server/chathandler.cpp
@@ -344,7 +344,7 @@ void ChatHandler::handleEnterChannelMessage(ChatClient &client, MessageIn &msg)
std::string channelName = msg.readString();
std::string givenPassword = msg.readString();
- ChatChannel *channel = NULL;
+ ChatChannel *channel = nullptr;
if (chatChannelManager->channelExists(channelName) ||
chatChannelManager->tryNewPublicChannel(channelName))
{
diff --git a/src/chat-server/chathandler.h b/src/chat-server/chathandler.h
index 1a96cfb..62970ff 100644
--- a/src/chat-server/chathandler.h
+++ b/src/chat-server/chathandler.h
@@ -61,7 +61,7 @@ class ChatHandler : public ConnectionHandler
, mInvitee(inviteeName)
{
const int validTimeframe = 60;
- mExpireTime = time(NULL) + validTimeframe;
+ mExpireTime = time(nullptr) + validTimeframe;
}
std::string mInviter;
@@ -84,7 +84,7 @@ class ChatHandler : public ConnectionHandler
/**
* Tell a list of users about an event in a chatchannel.
*
- * @param channel the channel to send the message in, must not be NULL
+ * @param channel the channel to send the message in, must not be nullptr
* @param info information pertaining to the event
*/
void warnUsersAboutPlayerEventInChat(ChatChannel *channel,
@@ -219,7 +219,7 @@ class ChatHandler : public ConnectionHandler
/**
* Sends a message to every client in a registered channel.
*
- * @param channel the channel to send the message in, must not be NULL
+ * @param channel the channel to send the message in, must not be nullptr
* @param msg the message to be sent
*/
void sendInChannel(ChatChannel *channel, MessageOut &msg);
diff --git a/src/chat-server/guildmanager.h b/src/chat-server/guildmanager.h
index 06a0e5a..93e5cf2 100644
--- a/src/chat-server/guildmanager.h
+++ b/src/chat-server/guildmanager.h
@@ -63,14 +63,14 @@ class GuildManager
/**
* Returns the guild with the given id. O(n)
*
- * @return the guild with the given id, or NULL if it doesn't exist
+ * @return the guild with the given id, or nullptr if it doesn't exist
*/
Guild *findById(short id) const;
/**
* Returns the guild with the given name. O(n)
*
- * @return the guild with the given name, or NULL if it doesn't exist
+ * @return the guild with the given name, or nullptr if it doesn't exist
*/
Guild *findByName(const std::string &name) const;
diff --git a/src/chat-server/partyhandler.cpp b/src/chat-server/partyhandler.cpp
index 1e5ad6b..b78bc22 100644
--- a/src/chat-server/partyhandler.cpp
+++ b/src/chat-server/partyhandler.cpp
@@ -40,7 +40,7 @@ void updateInfo(ChatClient *client, int partyId)
void ChatHandler::removeExpiredPartyInvites()
{
- time_t now = time(NULL);
+ time_t now = time(nullptr);
while (!mInvitations.empty() && mInvitations.front().mExpireTime < now)
{
std::map<std::string, int>::iterator itr;
diff --git a/src/chat-server/post.cpp b/src/chat-server/post.cpp
index 6db5f76..9da0753 100644
--- a/src/chat-server/post.cpp
+++ b/src/chat-server/post.cpp
@@ -115,7 +115,7 @@ Letter* Post::getLetter(int letter) const
{
if (letter < 0 || (size_t) letter > mLetters.size())
{
- return NULL;
+ return nullptr;
}
return mLetters[letter];
}
@@ -146,7 +146,7 @@ void PostManager::addLetter(Letter *letter)
Post *PostManager::getPost(CharacterData *player) const
{
std::map<CharacterData*, Post*>::const_iterator itr = mPostBox.find(player);
- return (itr == mPostBox.end()) ? NULL : itr->second;
+ return (itr == mPostBox.end()) ? nullptr : itr->second;
}
void PostManager::clearPost(CharacterData *player)
diff --git a/src/common/configuration.cpp b/src/common/configuration.cpp
index 460db37..906d262 100644
--- a/src/common/configuration.cpp
+++ b/src/common/configuration.cpp
@@ -57,7 +57,7 @@ static bool readFile(const std::string &fileName)
return false;
}
- for (node = node->xmlChildrenNode; node != NULL; node = node->next)
+ for (node = node->xmlChildrenNode; node != nullptr; node = node->next)
{
if (xmlStrEqual(node->name, BAD_CAST "include"))
{
diff --git a/src/common/permissionmanager.cpp b/src/common/permissionmanager.cpp
index c5c87f6..b1c93c1 100644
--- a/src/common/permissionmanager.cpp
+++ b/src/common/permissionmanager.cpp
@@ -83,7 +83,7 @@ void PermissionManager::reload()
xmlNodePtr perNode;
- for (perNode = node->xmlChildrenNode; perNode != NULL; perNode = perNode->next)
+ for (perNode = node->xmlChildrenNode; perNode != nullptr; perNode = perNode->next)
{
if (xmlStrEqual(perNode->name, BAD_CAST "allow"))
{
diff --git a/src/common/resourcemanager.cpp b/src/common/resourcemanager.cpp
index 45735b4..92a8591 100644
--- a/src/common/resourcemanager.cpp
+++ b/src/common/resourcemanager.cpp
@@ -91,11 +91,11 @@ char *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
PHYSFS_file *file = PHYSFS_openRead(fileName.c_str());
// If the handler is an invalid pointer indicate failure
- if (file == NULL)
+ if (file == nullptr)
{
LOG_WARN("Failed to load '" << fileName << "': "
<< PHYSFS_getLastError());
- return NULL;
+ return nullptr;
}
// Get the size of the file
@@ -108,7 +108,7 @@ char *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
free(buffer);
LOG_WARN("Failed to load '" << fileName << "': "
<< PHYSFS_getLastError());
- return NULL;
+ return nullptr;
}
// Close the file and let the user deallocate the memory
diff --git a/src/common/resourcemanager.h b/src/common/resourcemanager.h
index 3d722a4..569428d 100644
--- a/src/common/resourcemanager.h
+++ b/src/common/resourcemanager.h
@@ -56,7 +56,7 @@ namespace ResourceManager
* @param fileSize The size of the file that was loaded.
*
* @return An allocated byte array containing the data that was loaded,
- * or <code>NULL</code> on failure.
+ * or <code>nullptr</code> on failure.
* @note The array contains an extra \0 character at position fileSize.
*/
char *loadFile(const std::string &fileName, int &fileSize);
diff --git a/src/dal/mysqldataprovider.cpp b/src/dal/mysqldataprovider.cpp
index 9f9c4a9..626d5cc 100644
--- a/src/dal/mysqldataprovider.cpp
+++ b/src/dal/mysqldataprovider.cpp
@@ -89,7 +89,7 @@ void MySqlDataProvider::connect()
// allocate and initialize a new MySQL object suitable
// for mysql_real_connect().
- mDb = mysql_init(NULL);
+ mDb = mysql_init(nullptr);
if (!mDb)
{
@@ -108,7 +108,7 @@ void MySqlDataProvider::connect()
password.c_str(), // password
dbName.c_str(), // database name
tcpPort, // tcp port
- NULL, // socket, currently not used
+ nullptr, // socket, currently not used
CLIENT_FOUND_ROWS)) // client flags
{
std::string msg(mysql_error(mDb));
diff --git a/src/dal/sqlitedataprovider.cpp b/src/dal/sqlitedataprovider.cpp
index 8054f1f..e267e38 100644
--- a/src/dal/sqlitedataprovider.cpp
+++ b/src/dal/sqlitedataprovider.cpp
@@ -361,7 +361,7 @@ bool SqLiteDataProvider::prepareSql(const std::string &sql)
mRecordSet.clear();
if (sqlite3_prepare_v2(mDb, sql.c_str(), sql.size(),
- &mStmt, NULL) != SQLITE_OK)
+ &mStmt, nullptr) != SQLITE_OK)
return false;
return true;
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index d0bcf46..52cc73f 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -72,9 +72,9 @@ static bool executeCallback(Script::Ref function, Entity &entity)
CharacterComponent::CharacterComponent(Entity &entity, MessageIn &msg):
- mClient(NULL),
+ mClient(nullptr),
mConnected(true),
- mTransactionHandler(NULL),
+ mTransactionHandler(nullptr),
mSpecialUpdateNeeded(false),
mDatabaseID(-1),
mHairStyle(0),
@@ -374,13 +374,13 @@ void CharacterComponent::cancelTransaction()
Trade *CharacterComponent::getTrading() const
{
return mTransaction == TRANS_TRADE
- ? static_cast< Trade * >(mTransactionHandler) : NULL;
+ ? static_cast< Trade * >(mTransactionHandler) : nullptr;
}
BuySell *CharacterComponent::getBuySell() const
{
return mTransaction == TRANS_BUYSELL
- ? static_cast< BuySell * >(mTransactionHandler) : NULL;
+ ? static_cast< BuySell * >(mTransactionHandler) : nullptr;
}
void CharacterComponent::setTrading(Trade *t)
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index 9c413ed..dcdd8c6 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -167,7 +167,7 @@ static CmdRef const cmdRef[] =
"<setname>_<specialname>", &handleRechargeSpecial},
{"listspecials", "<character>",
"Lists the specials of the character.", &handleListSpecials},
- {NULL, NULL, NULL, NULL}
+ {nullptr, nullptr, nullptr, nullptr}
};
@@ -284,7 +284,7 @@ static void handleHelp(Entity *player, std::string &args)
return;
}
// detailed description of single command
- for (size_t j = 0; cmdRef[j].cmd != NULL; j++)
+ for (size_t j = 0; cmdRef[j].cmd != nullptr; j++)
{
if (cmdRef[j].cmd == args)
{
@@ -1803,7 +1803,7 @@ void CommandHandler::handleCommand(Entity *player,
break;
case PermissionManager::PMR_ALLOWED:
// handle the command
- for (size_t i = 0; cmdRef[i].cmd != NULL; i++)
+ for (size_t i = 0; cmdRef[i].cmd != nullptr; i++)
{
if (cmdRef[i].cmd == type)
{
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index fa579c3..79a14c6 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -116,7 +116,7 @@ void GameHandler::completeServerChange(int id, const std::string &token,
c->character->getComponent<CharacterComponent>()->disconnected(
*c->character);
delete c->character;
- c->character = NULL;
+ c->character = nullptr;
c->status = CLIENT_LOGIN;
return;
}
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp
index 3a12cdb..8866a39 100644
--- a/src/game-server/main-game.cpp
+++ b/src/game-server/main-game.cpp
@@ -165,7 +165,7 @@ static void initializeServer()
utils::processor::init();
// Seed the random number generator
- std::srand( time(NULL) );
+ std::srand( time(nullptr) );
}
@@ -257,7 +257,7 @@ static void parseOptions(int argc, char *argv[], CommandLineOptions &options)
while (optind < argc)
{
- int result = getopt_long(argc, argv, optString, longOptions, NULL);
+ int result = getopt_long(argc, argv, optString, longOptions, nullptr);
if (result == -1)
break;
diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp
index ec881cf..4a5d800 100644
--- a/src/game-server/mapcomposite.cpp
+++ b/src/game-server/mapcomposite.cpp
@@ -159,7 +159,7 @@ ZoneIterator::ZoneIterator(const MapRegion &r, const MapContent *m)
void ZoneIterator::operator++()
{
- current = NULL;
+ current = nullptr;
if (!region.empty())
{
if (++pos != region.size())
@@ -348,13 +348,13 @@ void ObjectBucket::deallocate(int i)
*****************************************************************************/
MapContent::MapContent(Map *map)
- : last_bucket(0), zones(NULL)
+ : last_bucket(0), zones(nullptr)
{
buckets[0] = new ObjectBucket;
buckets[0]->allocate(); // Skip ID 0
for (int i = 1; i < 256; ++i)
{
- buckets[i] = NULL;
+ buckets[i] = nullptr;
}
mapWidth = (map->getWidth() * map->getTileWidth() + zoneDiam - 1)
/ zoneDiam;
diff --git a/src/game-server/mapmanager.cpp b/src/game-server/mapmanager.cpp
index b3b2931..50f79cd 100644
--- a/src/game-server/mapmanager.cpp
+++ b/src/game-server/mapmanager.cpp
@@ -118,7 +118,7 @@ void MapManager::deinitialize()
MapComposite *MapManager::getMap(int mapId)
{
Maps::const_iterator i = maps.find(mapId);
- return (i != maps.end()) ? i->second : NULL;
+ return (i != maps.end()) ? i->second : nullptr;
}
MapComposite *MapManager::getMap(const std::string &mapName)
@@ -127,7 +127,7 @@ MapComposite *MapManager::getMap(const std::string &mapName)
if (i->second->getName() == mapName)
return i->second;
- return NULL;
+ return nullptr;
}
bool MapManager::activateMap(int mapId)
diff --git a/src/game-server/mapmanager.h b/src/game-server/mapmanager.h
index 6b51881..12cbc34 100644
--- a/src/game-server/mapmanager.h
+++ b/src/game-server/mapmanager.h
@@ -45,7 +45,7 @@ namespace MapManager
/**
* Returns the requested map.
*
- * @return the requested map, or NULL if no map with the given ID exists.
+ * @return the requested map, or nullptr if no map with the given ID exists.
*/
MapComposite *getMap(int mapId);
diff --git a/src/game-server/mapreader.cpp b/src/game-server/mapreader.cpp
index af40e56..acac685 100644
--- a/src/game-server/mapreader.cpp
+++ b/src/game-server/mapreader.cpp
@@ -56,7 +56,7 @@ Map *MapReader::readMap(xmlNodePtr node)
int tileH = XML::getProperty(node, "tileheight", DEFAULT_TILE_LENGTH);
Map *map = new Map(w, h, tileW, tileH);
- for (node = node->xmlChildrenNode; node != NULL; node = node->next)
+ for (node = node->xmlChildrenNode; node != nullptr; node = node->next)
{
if (xmlStrEqual(node->name, BAD_CAST "tileset"))
{
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index be0e161..5d77db4 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -125,7 +125,7 @@ MonsterComponent::~MonsterComponent()
void MonsterComponent::update(Entity &entity)
{
if (mKillStealProtectedTimeout.justFinished())
- mOwner = NULL;
+ mOwner = nullptr;
auto *beingComponent = entity.getComponent<BeingComponent>();
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index 58d848d..db224b8 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -845,7 +845,7 @@ void GameState::sayTo(Entity *destination, Entity *source, const std::string &te
return; //only characters will read it anyway
MessageOut msg(GPMSG_SAY);
- if (source == NULL)
+ if (source == nullptr)
{
msg.writeInt16(0);
}
diff --git a/src/game-server/state.h b/src/game-server/state.h
index 147a57c..256512c 100644
--- a/src/game-server/state.h
+++ b/src/game-server/state.h
@@ -92,7 +92,7 @@ namespace GameState
/**
* Says something to an actor.
- * @note passing NULL as source generates a message from "Server:"
+ * @note passing nullptr as source generates a message from "Server:"
*/
void sayTo(Entity *destination, Entity *source, const std::string &text);
diff --git a/src/net/connection.cpp b/src/net/connection.cpp
index 88c59f0..c54c0db 100644
--- a/src/net/connection.cpp
+++ b/src/net/connection.cpp
@@ -43,13 +43,13 @@ bool Connection::start(const std::string &address, int port)
enetAddress.port = port;
#if defined(ENET_VERSION) && ENET_VERSION >= ENET_CUTOFF
- mLocal = enet_host_create(NULL /* create a client host */,
+ mLocal = enet_host_create(nullptr /* create a client host */,
1 /* allow one outgoing connection */,
0 /* unlimited channel count */,
0 /* assume any amount of incoming bandwidth */,
0 /* assume any amount of outgoing bandwidth */);
#else
- mLocal = enet_host_create(NULL /* create a client host */,
+ mLocal = enet_host_create(nullptr /* create a client host */,
1 /* allow one outgoing connection */,
0 /* assume any amount of incoming bandwidth */,
0 /* assume any amount of outgoing bandwidth */);
diff --git a/src/net/connectionhandler.cpp b/src/net/connectionhandler.cpp
index d116aa9..f1bcf5f 100644
--- a/src/net/connectionhandler.cpp
+++ b/src/net/connectionhandler.cpp
@@ -145,7 +145,7 @@ void ConnectionHandler::process(enet_uint32 timeout)
// Reset the peer's client information.
computerDisconnected(comp);
clients.erase(std::find(clients.begin(), clients.end(), comp));
- event.peer->data = NULL;
+ event.peer->data = nullptr;
} break;
default: break;
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index ac88178..422649f 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -3691,11 +3691,11 @@ LuaScript::LuaScript():
{ "map_get_objects", map_get_objects },
{ "announce", announce },
{ "get_special_info", get_special_info },
- { NULL, NULL }
+ { nullptr, nullptr }
};
#if LUA_VERSION_NUM < 502
lua_pushvalue(mRootState, LUA_GLOBALSINDEX);
- luaL_register(mRootState, NULL, callbacks);
+ luaL_register(mRootState, nullptr, callbacks);
#else
lua_pushglobaltable(mRootState);
luaL_setfuncs(mRootState, callbacks, 0);
@@ -3709,7 +3709,7 @@ LuaScript::LuaScript():
{ "reusetime", attack_get_reusetime },
{ "damage", attack_get_damage },
{ "on_attack", attack_on_attack },
- { NULL, NULL }
+ { nullptr, nullptr }
};
static luaL_Reg const members_Damage[] = {
@@ -3722,7 +3722,7 @@ LuaScript::LuaScript():
{ "type", damage_get_type },
{ "is_truestrike", damage_is_truestrike },
{ "range", damage_get_range },
- { NULL, NULL }
+ { nullptr, nullptr }
};
static luaL_Reg const members_Entity[] = {
@@ -3789,14 +3789,14 @@ LuaScript::LuaScript():
{ "has_status", entity_has_status },
{ "status_time", entity_get_status_time },
{ "set_status_time", entity_set_status_time },
- { NULL, NULL }
+ { nullptr, nullptr }
};
static luaL_Reg const members_ItemClass[] = {
{ "on", item_class_on },
{ "name", item_class_get_name },
{ "attacks", item_class_attacks },
- { NULL, NULL }
+ { nullptr, nullptr }
};
static luaL_Reg const members_MapObject[] = {
@@ -3804,7 +3804,7 @@ LuaScript::LuaScript():
{ "bounds", map_object_get_bounds },
{ "name", map_object_get_name },
{ "type", map_object_get_type },
- { NULL, NULL }
+ { nullptr, nullptr }
};
static luaL_Reg const members_MonsterClass[] = {
@@ -3812,12 +3812,12 @@ LuaScript::LuaScript():
{ "on_damage", monster_class_on_damage },
{ "name", monster_class_get_name },
{ "attacks", monster_class_attacks },
- { NULL, NULL }
+ { nullptr, nullptr }
};
static luaL_Reg const members_StatusEffect[] = {
{ "on_tick", status_effect_on_tick },
- { NULL, NULL }
+ { nullptr, nullptr }
};
static luaL_Reg const members_SpecialInfo[] = {
@@ -3827,7 +3827,7 @@ LuaScript::LuaScript():
{ "on_use", specialinfo_on_use },
{ "on_recharged", specialinfo_on_recharged },
{ "category", specialinfo_get_category },
- { NULL, NULL}
+ { nullptr, nullptr}
};
LuaAttackInfo::registerType(mRootState, "Attack", members_AttackInfo);
diff --git a/src/scripting/luascript.cpp b/src/scripting/luascript.cpp
index f5fb6a4..2b9644d 100644
--- a/src/scripting/luascript.cpp
+++ b/src/scripting/luascript.cpp
@@ -155,7 +155,7 @@ bool LuaScript::resume()
#if LUA_VERSION_NUM < 502
int result = lua_resume(mCurrentState, tmpNbArgs);
#else
- int result = lua_resume(mCurrentState, NULL, tmpNbArgs);
+ int result = lua_resume(mCurrentState, nullptr, tmpNbArgs);
#endif
if (result == 0) // Thread is done
diff --git a/src/scripting/luautil.h b/src/scripting/luautil.h
index 6d078e3..8bcc2a3 100644
--- a/src/scripting/luautil.h
+++ b/src/scripting/luautil.h
@@ -102,7 +102,7 @@ public:
lua_pushliteral(s, "__index"); // metatable, "__index"
lua_createtable(s, 0, 0); // metatable, "__index", {}
#if LUA_VERSION_NUM < 502
- luaL_register(s, NULL, members);
+ luaL_register(s, nullptr, members);
#else
luaL_setfuncs(s, members, 0);
#endif
diff --git a/src/scripting/script.cpp b/src/scripting/script.cpp
index 72943d4..715a799 100644
--- a/src/scripting/script.cpp
+++ b/src/scripting/script.cpp
@@ -33,7 +33,7 @@
typedef std::map< std::string, Script::Factory > Engines;
-static Engines *engines = NULL;
+static Engines *engines = nullptr;
Script::Ref Script::mCreateNpcDelayedCallback;
Script::Ref Script::mUpdateCallback;
@@ -73,7 +73,7 @@ Script *Script::create(const std::string &engine)
}
}
LOG_ERROR("No scripting engine named " << engine);
- return NULL;
+ return nullptr;
}
void Script::update()
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index c0a8753..342c39b 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -89,8 +89,8 @@ unsigned char *php_base64_decode(const unsigned char *str, int length, int *ret_
}
result = (unsigned char *)malloc(length + 1);
- if (result == NULL) {
- return NULL;
+ if (result == nullptr) {
+ return nullptr;
}
/* run through the whole string, converting as we go */
@@ -135,7 +135,7 @@ unsigned char *php_base64_decode(const unsigned char *str, int length, int *ret_
case 0:
case 1:
free(result);
- return NULL;
+ return nullptr;
case 2:
k++;
case 3:
diff --git a/src/utils/tokencollector.cpp b/src/utils/tokencollector.cpp
index e41d228..691eca2 100644
--- a/src/utils/tokencollector.cpp
+++ b/src/utils/tokencollector.cpp
@@ -40,7 +40,7 @@ void TokenCollectorBase::insertClient(const std::string &token, intptr_t data)
}
}
- time_t current = time(NULL);
+ time_t current = time(nullptr);
Item item;
item.token = token;
@@ -64,7 +64,7 @@ void TokenCollectorBase::insertConnect(const std::string &token, intptr_t data)
}
}
- time_t current = time(NULL);
+ time_t current = time(nullptr);
Item item;
item.token = token;
@@ -114,7 +114,7 @@ void TokenCollectorBase::removeOutdated(time_t current)
}
TokenCollectorBase::TokenCollectorBase():
- mLastCheck(time(NULL))
+ mLastCheck(time(nullptr))
{
}
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 91ebb44..3c286db 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -138,7 +138,7 @@ namespace XML
if (xmlStrEqual(child->name, BAD_CAST name))
return child;
- return NULL;
+ return nullptr;
}
} // namespace XML
diff --git a/src/utils/xml.h b/src/utils/xml.h
index 2278ce4..801fd70 100644
--- a/src/utils/xml.h
+++ b/src/utils/xml.h
@@ -55,7 +55,7 @@ namespace XML
~Document();
/**
- * Returns the root node of the document (or NULL if there was a
+ * Returns the root node of the document (or nullptr if there was a
* load error).
*/
xmlNodePtr rootNode();