- NULL/nullptr replacing done development
authorAkiko <akiko@linux-addicted.net>
Wed, 3 Jun 2015 08:05:34 +0000 (10:05 +0200)
committerAkiko <akiko@linux-addicted.net>
Wed, 3 Jun 2015 08:05:34 +0000 (10:05 +0200)
- old time functions replaced by new one

77 files changed:
TinNS/Source/GameServer/Accounts.cxx
TinNS/Source/GameServer/Accounts.hxx
TinNS/Source/GameServer/BuddyList.cxx
TinNS/Source/GameServer/CMakeLists.txt
TinNS/Source/GameServer/Chars.cxx
TinNS/Source/GameServer/Chars.hxx
TinNS/Source/GameServer/Client.cxx
TinNS/Source/GameServer/Client.hxx
TinNS/Source/GameServer/ClientManager.cxx
TinNS/Source/GameServer/Commands.cxx
TinNS/Source/GameServer/Container.cxx
TinNS/Source/GameServer/Decoder/Udp0x13.cxx
TinNS/Source/GameServer/Decoder/Udp0x1f.cxx
TinNS/Source/GameServer/Decoder/Udp0x22.cxx
TinNS/Source/GameServer/Decoder/UdpHack.cxx
TinNS/Source/GameServer/Decoder/UdpHeldItemAction.cxx
TinNS/Source/GameServer/Decoder/UdpItemMove.cxx
TinNS/Source/GameServer/Decoder/UdpPopupResponse.cxx
TinNS/Source/GameServer/Decoder/UdpQuickAccessBelt.cxx
TinNS/Source/GameServer/Decoder/UdpRequestInfo.cxx
TinNS/Source/GameServer/Decoder/UdpTerminal.cxx
TinNS/Source/GameServer/Decoder/UdpUseObject.cxx
TinNS/Source/GameServer/Decoder/UdpWorldIdInfo.cxx
TinNS/Source/GameServer/Decoder/UdpZoning.cxx
TinNS/Source/GameServer/Definitions/Items.cxx
TinNS/Source/GameServer/Definitions/WorldDatParser.cxx
TinNS/Source/GameServer/DoorTemplate.cxx
TinNS/Source/GameServer/FurnitureTemplate.cxx
TinNS/Source/GameServer/GameCommands/GiveMoney.cxx
TinNS/Source/GameServer/GameCommands/Info.cxx
TinNS/Source/GameServer/GameCommands/Jail.cxx
TinNS/Source/GameServer/GameCommands/Kick.cxx
TinNS/Source/GameServer/GameCommands/Npc.cxx
TinNS/Source/GameServer/GameCommands/NpcShop.cxx
TinNS/Source/GameServer/GameCommands/Recall.cxx
TinNS/Source/GameServer/GameCommands/SetLevel.cxx
TinNS/Source/GameServer/GameCommands/SetMainSkill.cxx
TinNS/Source/GameServer/GameCommands/SetSubSkill.cxx
TinNS/Source/GameServer/GameCommands/Shun.cxx
TinNS/Source/GameServer/GameCommands/SpawnActor.cxx
TinNS/Source/GameServer/GameCommands/T.cxx
TinNS/Source/GameServer/GameCommands/TakeMoney.cxx
TinNS/Source/GameServer/GameCommands/Teleport.cxx
TinNS/Source/GameServer/GameCommands/Test.cxx
TinNS/Source/GameServer/GameCommands/UnJail.cxx
TinNS/Source/GameServer/GameCommands/UnShun.cxx
TinNS/Source/GameServer/GameCommands/Uptime.cxx
TinNS/Source/GameServer/GameCommands/WarpTo.cxx
TinNS/Source/GameServer/GameScript.cxx [deleted file]
TinNS/Source/GameServer/GameScript.hxx [deleted file]
TinNS/Source/GameServer/GameServer.cxx
TinNS/Source/GameServer/GenrepList.cxx
TinNS/Source/GameServer/Includes.hxx
TinNS/Source/GameServer/Inventory.cxx
TinNS/Source/GameServer/Isc.cxx
TinNS/Source/GameServer/LuaEngine.cxx
TinNS/Source/GameServer/MultiPart.cxx
TinNS/Source/GameServer/Npc.cxx
TinNS/Source/GameServer/Npc.hxx
TinNS/Source/GameServer/NpcAi.cxx
TinNS/Source/GameServer/NpcConversation.cxx
TinNS/Source/GameServer/Outpost.cxx
TinNS/Source/GameServer/Sql.cxx
TinNS/Source/GameServer/Sql.hxx
TinNS/Source/GameServer/Subway.hxx
TinNS/Source/GameServer/Terminal.cxx
TinNS/Source/GameServer/TerminalReceiveDatabase.cxx
TinNS/Source/GameServer/TerminalTryAccess.cxx
TinNS/Source/GameServer/Vehicle.cxx
TinNS/Source/GameServer/VehicleAccessRequest.cxx
TinNS/Source/GameServer/WorldActors.cxx
TinNS/Source/GameServer/WorldDataTemplate.cxx
TinNS/Source/GameServer/Worlds.cxx
TinNS/Source/InfoServer/Accounts.cxx
TinNS/Source/InfoServer/Accounts.hxx
TinNS/Source/InfoServer/InfoServer.cxx
TinNS/Source/InfoServer/Sql.cxx

index c3d66ef..5cf4cb4 100644 (file)
@@ -17,15 +17,15 @@ a_status:
 */
 
 /** Static members **/
 */
 
 /** Static members **/
-RegEx* PAccount::mUsernameRegexFilter = NULL;
-RegEx* PAccount::mPasswordRegexFilter = NULL;
+RegEx* PAccount::mUsernameRegexFilter = nullptr;
+RegEx* PAccount::mPasswordRegexFilter = nullptr;
 
 bool PAccount::SetUsernameRegexFilter(const char* RegexStr)
 {
   if(mUsernameRegexFilter)
   {
     delete mUsernameRegexFilter;
 
 bool PAccount::SetUsernameRegexFilter(const char* RegexStr)
 {
   if(mUsernameRegexFilter)
   {
     delete mUsernameRegexFilter;
-    mUsernameRegexFilter = NULL;
+    mUsernameRegexFilter = nullptr;
   }
 
   if(RegexStr)
   }
 
   if(RegexStr)
@@ -45,7 +45,7 @@ bool PAccount::SetPasswordRegexFilter(const char* RegexStr)
   if(mPasswordRegexFilter)
   {
     delete mPasswordRegexFilter;
   if(mPasswordRegexFilter)
   {
     delete mPasswordRegexFilter;
-    mPasswordRegexFilter = NULL;
+    mPasswordRegexFilter = nullptr;
   }
 
   if(RegexStr)
   }
 
   if(RegexStr)
@@ -117,7 +117,7 @@ bool PAccount::LoadFromQuery(char* query)
   bool FinalResult = false;
 
   result = MySQL->InfoResQuery(query);
   bool FinalResult = false;
 
   result = MySQL->InfoResQuery(query);
-  if(result == NULL)
+  if(result == nullptr)
   {
       Console->Print(RED, BLACK, "Failed to load AccountData from SQL");
       MySQL->ShowInfoSQLError();
   {
       Console->Print(RED, BLACK, "Failed to load AccountData from SQL");
       MySQL->ShowInfoSQLError();
@@ -131,7 +131,7 @@ bool PAccount::LoadFromQuery(char* query)
     mPassword = row[a_password];
 
     mBannedUntil = atoi(row[a_bandate]);
     mPassword = row[a_password];
 
     mBannedUntil = atoi(row[a_bandate]);
-    if(mBannedUntil > time(NULL))
+    if(mBannedUntil > Time::nowTimeT())
     {
       mStatus = PAS_BANNED;
       mLevel = PAL_BANNED;
     {
       mStatus = PAS_BANNED;
       mLevel = PAL_BANNED;
@@ -228,9 +228,9 @@ bool PAccount::SetStatus(PAccountStatus Status)
   return true;
 }
 
   return true;
 }
 
-bool PAccount::SetBannedUntilTime(std::time_t BannedUntil)
+bool PAccount::SetBannedUntilTime(time_t BannedUntil)
 {
 {
-  if ((BannedUntil == 0) || (BannedUntil > std::time(NULL)))
+  if ((BannedUntil == 0) || (BannedUntil > Time::nowTimeT()))
   {
     mBannedUntil = BannedUntil;
     return true;
   {
     mBannedUntil = BannedUntil;
     return true;
@@ -241,6 +241,11 @@ bool PAccount::SetBannedUntilTime(std::time_t BannedUntil)
   }
 }
 
   }
 }
 
+bool PAccount::IsBanned() const
+{
+    return (mBannedUntil > Time::nowTimeT());
+}
+
 bool PAccount::DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword)
 {
   ClearPassword[0] = 0;
 bool PAccount::DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword)
 {
   ClearPassword[0] = 0;
@@ -341,7 +346,7 @@ uint32_t PAccount::GetCharIdBySlot(const uint32_t SlotId)
   snprintf(query, 256, "SELECT c_id FROM characters WHERE a_id = %d AND c_slot = %d LIMIT 1;", mID, SlotId);
 
   result = MySQL->GameResQuery(query);
   snprintf(query, 256, "SELECT c_id FROM characters WHERE a_id = %d AND c_slot = %d LIMIT 1;", mID, SlotId);
 
   result = MySQL->GameResQuery(query);
-  if(result == NULL)
+  if (result == nullptr)
   {
       Console->Print(RED, BLACK, "Failed to load CharacterData from SQL");
       MySQL->ShowGameSQLError();
   {
       Console->Print(RED, BLACK, "Failed to load CharacterData from SQL");
       MySQL->ShowGameSQLError();
@@ -361,7 +366,7 @@ uint32_t PAccount::GetCharIdBySlot(const uint32_t SlotId)
     snprintf(query, 256, "SELECT c_id FROM characters WHERE a_id = %d ORDER BY c_slot ASC, c_id ASC LIMIT %d, 1;", mID, SlotId);
 
     result = MySQL->GameResQuery(query);
     snprintf(query, 256, "SELECT c_id FROM characters WHERE a_id = %d ORDER BY c_slot ASC, c_id ASC LIMIT %d, 1;", mID, SlotId);
 
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "Failed to load CharacterData from SQL");
         MySQL->ShowGameSQLError();
     {
         Console->Print(RED, BLACK, "Failed to load CharacterData from SQL");
         MySQL->ShowGameSQLError();
@@ -385,7 +390,7 @@ std::string PAccount::GetBannedTime() const
 {
   const char* unit[5] = {"seconds", "minutes", "hours", "days", "weeks"};
 
 {
   const char* unit[5] = {"seconds", "minutes", "hours", "days", "weeks"};
 
-  std::time_t timediff = mBannedUntil - std::time(NULL);
+  time_t timediff = mBannedUntil - Time::nowTimeT();
   if(timediff <=0)
   {
     return "0 more seconds. Please relog";
   if(timediff <=0)
   {
     return "0 more seconds. Please relog";
index 1c0c0e3..70c3559 100644 (file)
@@ -88,7 +88,7 @@ class PAccount {
     bool SetStatus(PAccountStatus Status);
         inline PAccountStatus GetStatus() const { return mStatus; }
         bool SetBannedUntilTime(time_t BannedUntil);
     bool SetStatus(PAccountStatus Status);
         inline PAccountStatus GetStatus() const { return mStatus; }
         bool SetBannedUntilTime(time_t BannedUntil);
-    inline bool IsBanned() const { return (mBannedUntil > std::time(NULL)); }
+    bool IsBanned() const;
     std::string GetBannedTime() const;
 
         bool Authenticate(const uint8_t* PasswordData, int PassLen, const uint8_t *Key);
     std::string GetBannedTime() const;
 
         bool Authenticate(const uint8_t* PasswordData, int PassLen, const uint8_t *Key);
index 79ac545..ecb2db3 100644 (file)
@@ -6,7 +6,7 @@ PBuddyList::PBuddyList(uint32_t nOwnerCharID)
 {
     mOwnerCharID = nOwnerCharID;
     mListMaxSize = mListSize = 0;
 {
     mOwnerCharID = nOwnerCharID;
     mListMaxSize = mListSize = 0;
-    mCharIDList = NULL;
+    mCharIDList = nullptr;
 }
 
 PBuddyList::~PBuddyList()
 }
 
 PBuddyList::~PBuddyList()
@@ -82,7 +82,7 @@ bool PBuddyList::SQLLoad()
 
     snprintf(query, 256, "SELECT * FROM buddy_list WHERE (bud_charid='%u')", mOwnerCharID);
     result = MySQL->GameResQuery(query);
 
     snprintf(query, 256, "SELECT * FROM buddy_list WHERE (bud_charid='%u')", mOwnerCharID);
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PBuddyList::SQLLoad could not load buddylist entry from the database");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PBuddyList::SQLLoad could not load buddylist entry from the database");
         Console->Print("Query was:");
index 479ed02..426c79b 100644 (file)
@@ -6,7 +6,7 @@ ADD_SUBDIRECTORY        (GameCommands)
 
 ADD_EXECUTABLE          (GameServer
                          Accounts.cxx Appartements.cxx BuddyList.cxx Chars.cxx Chat.cxx Client.cxx ClientManager.cxx
 
 ADD_EXECUTABLE          (GameServer
                          Accounts.cxx Appartements.cxx BuddyList.cxx Chars.cxx Chat.cxx Client.cxx ClientManager.cxx
-                         Commands.cxx Container.cxx DoorTemplate.cxx FurnitureTemplate.cxx GameScript.cxx
+                         Commands.cxx Container.cxx DoorTemplate.cxx FurnitureTemplate.cxx
                          GameServer.cxx GenrepList.cxx Includes.cxx Isc.cxx Inventory.cxx Item.cxx LuaEngine.cxx
                          Main.cxx MessageBuilder.cxx MultiPart.cxx Npc.cxx NpcAi.cxx NpcConversation.cxx NpcTemplate.cxx
                          Outpost.cxx RemoteConsole.cxx Server.cxx Skill.cxx Sql.cxx Subway.cxx Terminal.cxx
                          GameServer.cxx GenrepList.cxx Includes.cxx Isc.cxx Inventory.cxx Item.cxx LuaEngine.cxx
                          Main.cxx MessageBuilder.cxx MultiPart.cxx Npc.cxx NpcAi.cxx NpcConversation.cxx NpcTemplate.cxx
                          Outpost.cxx RemoteConsole.cxx Server.cxx Skill.cxx Sql.cxx Subway.cxx Terminal.cxx
index f247f8a..8b2f62a 100644 (file)
@@ -126,7 +126,7 @@ enum
     c_soullight
 };
 
     c_soullight
 };
 
-RegEx* PChar::mCharnameRegexFilter = NULL;
+RegEx* PChar::mCharnameRegexFilter = nullptr;
 
 PChar::PChar()
 {
 
 PChar::PChar()
 {
@@ -167,9 +167,9 @@ PChar::PChar()
   mSeatInUseType = seat_none;
   mSeatInUseObjectId = 0;
   mSeatInUseSeatId = 0;
   mSeatInUseType = seat_none;
   mSeatInUseObjectId = 0;
   mSeatInUseSeatId = 0;
-  mVhcAccessRequestList = NULL;
+  mVhcAccessRequestList = nullptr;
 
 
-  mContainerInExclusiveUse = NULL;
+  mContainerInExclusiveUse = nullptr;
 
   mIsOnline = false;
   mDirtyFlag = false;
 
   mIsOnline = false;
   mDirtyFlag = false;
@@ -181,8 +181,8 @@ PChar::PChar()
   mCurrentDialogNode = 0;
 
   Skill = new PSkillHandler();
   mCurrentDialogNode = 0;
 
   Skill = new PSkillHandler();
-  mBuddyList = NULL;
-  mGenrepList = NULL;
+  mBuddyList = nullptr;
+  mGenrepList = nullptr;
 
   // Required for initial OOC Broadcast welcome message.
   //Gets overwritten as soon as the first PingPacket arrives
 
   // Required for initial OOC Broadcast welcome message.
   //Gets overwritten as soon as the first PingPacket arrives
@@ -220,7 +220,7 @@ bool PChar::SetCharnameRegexFilter( const char* RegexStr )
   if ( mCharnameRegexFilter )
   {
     delete mCharnameRegexFilter;
   if ( mCharnameRegexFilter )
   {
     delete mCharnameRegexFilter;
-    mCharnameRegexFilter = NULL;
+    mCharnameRegexFilter = nullptr;
   }
 
   if ( RegexStr )
   }
 
   if ( RegexStr )
@@ -250,7 +250,7 @@ bool PChar::IsCharnameWellFormed( const char *Charname )
 void PChar::SetProfession( uint32_t Profession )
 {
   const PDefCharKind *def = GameDefs->CharKinds()->GetDef( Profession );
 void PChar::SetProfession( uint32_t Profession )
 {
   const PDefCharKind *def = GameDefs->CharKinds()->GetDef( Profession );
-  if ( def == NULL )
+  if (def == nullptr)
   {
     Console->Print( RED, BLACK, "Char %d: Invalid profession %d", mID, Profession );
     mProfession = 10;
   {
     Console->Print( RED, BLACK, "Char %d: Invalid profession %d", mID, Profession );
     mProfession = 10;
@@ -379,7 +379,7 @@ void PChar::SetBaseSkills()
 {
   const PDefCharKind *def = GameDefs->CharKinds()->GetDef( mProfession );
   //Console->Print(YELLOW, BLACK, "PChar::SetBaseSkills() Profession: %d",def->GetIndex());
 {
   const PDefCharKind *def = GameDefs->CharKinds()->GetDef( mProfession );
   //Console->Print(YELLOW, BLACK, "PChar::SetBaseSkills() Profession: %d",def->GetIndex());
-  if ( def == NULL )
+  if (def == nullptr)
   {
     Console->Print( RED, BLACK, "PChar::SetBaseSkills: GetCharKindDef=NULL" );
     return;
   {
     Console->Print( RED, BLACK, "PChar::SetBaseSkills: GetCharKindDef=NULL" );
     return;
@@ -454,7 +454,7 @@ void PChar::LoadClanLevel()
 
     snprintf(query, 200, "SELECT cll_level FROM clanlevels WHERE cll_charid = %d AND cll_clanid = %d", mID, mClanID);
     result = MySQL->GameResQuery( query );
 
     snprintf(query, 200, "SELECT cll_level FROM clanlevels WHERE cll_charid = %d AND cll_clanid = %d", mID, mClanID);
     result = MySQL->GameResQuery( query );
-    if ( result == NULL )
+    if (result == nullptr)
     {
         mClanID = 0;
         Console->Print( RED, BLACK, "PChar::GetClanLevel could not load ClanLevel from the database" );
     {
         mClanID = 0;
         Console->Print( RED, BLACK, "PChar::GetClanLevel could not load ClanLevel from the database" );
@@ -481,7 +481,7 @@ bool PChar::SQLLoad( int CharID )
 
   snprintf( query, 1024, "SELECT * FROM characters WHERE c_id = %d LIMIT 1", CharID );
   result = MySQL->GameResQuery( query );
 
   snprintf( query, 1024, "SELECT * FROM characters WHERE c_id = %d LIMIT 1", CharID );
   result = MySQL->GameResQuery( query );
-  if ( result == NULL )
+  if (result == nullptr)
   {
     Console->Print( RED, BLACK, "PChar::SQLLoad could not load Chardata from the database" );
     Console->Print( "Query was:" );
   {
     Console->Print( RED, BLACK, "PChar::SQLLoad could not load Chardata from the database" );
     Console->Print( "Query was:" );
@@ -1075,12 +1075,12 @@ PVhcAccessRequestList* PChar::GetVhcAccessRequestList()
 void PChar::SetLookingAt( uint16_t nLocalCharID )
 {
   mLookingAt = nLocalCharID;
 void PChar::SetLookingAt( uint16_t nLocalCharID )
 {
   mLookingAt = nLocalCharID;
-  mLookAtTimestamp = std::time( NULL );
+  mLookAtTimestamp = Time::nowTimeT();
 }
 
 uint16_t PChar::GetLookingAt( uint16_t nMaxDelaySec )
 {
 }
 
 uint16_t PChar::GetLookingAt( uint16_t nMaxDelaySec )
 {
-  return ((( mLookAtTimestamp + nMaxDelaySec ) >= std::time( NULL ) ) ? mLookingAt : 0 );
+  return ((( mLookAtTimestamp + nMaxDelaySec ) >= Time::nowTimeT() ) ? mLookingAt : 0 );
 }
 
 // ===================================
 }
 
 // ===================================
@@ -1088,7 +1088,7 @@ uint16_t PChar::GetLookingAt( uint16_t nMaxDelaySec )
 PChars::PChars()
 {
   mLastID = 0;
 PChars::PChars()
 {
   mLastID = 0;
-  mLastSave = std::time( NULL );
+  mLastSave = Time::nowTimeT();
 
   mAutoSavePeriod = Config->GetOptionInt( "auto_save_period" );
   if ( mAutoSavePeriod < 0 )
 
   mAutoSavePeriod = Config->GetOptionInt( "auto_save_period" );
   if ( mAutoSavePeriod < 0 )
@@ -1158,7 +1158,7 @@ bool PChars::AddChar( PChar* nChar )
 
 PChar* PChars::RemoveChar( uint32_t CharID )
 {
 
 PChar* PChars::RemoveChar( uint32_t CharID )
 {
-  PChar* Result = NULL;
+  PChar* Result = nullptr;
 
   CharMap::iterator i = mChars.find( CharID );
   if ( i != mChars.end() )
 
   CharMap::iterator i = mChars.find( CharID );
   if ( i != mChars.end() )
@@ -1233,7 +1233,7 @@ bool PChars::CharExist( const std::string &Name ) const
   snprintf( query, 256, "SELECT 1 FROM characters WHERE c_name = '%s' LIMIT 1;", escUsername );
 
   result = MySQL->GameResQuery( query );
   snprintf( query, 256, "SELECT 1 FROM characters WHERE c_name = '%s' LIMIT 1;", escUsername );
 
   result = MySQL->GameResQuery( query );
-  if ( result == NULL )
+  if (result == nullptr)
   {
     Console->Print( RED, BLACK, "[ERROR] Failed to get CharacterData from SQL" );
     MySQL->ShowGameSQLError();
   {
     Console->Print( RED, BLACK, "[ERROR] Failed to get CharacterData from SQL" );
     MySQL->ShowGameSQLError();
@@ -1247,7 +1247,7 @@ bool PChars::CharExist( const std::string &Name ) const
 
 void PChars::Update()
 {
 
 void PChars::Update()
 {
-  std::time_t t = std::time( NULL ); // changed to time() to have real time instead of cpu used time
+  time_t t = Time::nowTimeT(); // changed to time() to have real time instead of cpu used time
 
   if ( mAutoSavePeriod && (( t - mLastSave ) >= mAutoSavePeriod ) )
   {
 
   if ( mAutoSavePeriod && (( t - mLastSave ) >= mAutoSavePeriod ) )
   {
@@ -1283,7 +1283,7 @@ int PChars::GetCharProfiles( const uint32_t AccountID, PCharProfile* CharSlotsAr
   snprintf( query, 256, "SELECT * FROM characters WHERE a_id = %d ORDER BY c_slot ASC", AccountID );
 
   result = MySQL->GameResQuery( query );
   snprintf( query, 256, "SELECT * FROM characters WHERE a_id = %d ORDER BY c_slot ASC", AccountID );
 
   result = MySQL->GameResQuery( query );
-  if ( result == NULL )
+  if (result == nullptr)
   {
     Console->Print( RED, BLACK, "[ERROR] Failed to load CharacterData from SQL" );
     MySQL->ShowGameSQLError();
   {
     Console->Print( RED, BLACK, "[ERROR] Failed to load CharacterData from SQL" );
     MySQL->ShowGameSQLError();
index bb964b6..c182e35 100644 (file)
@@ -120,7 +120,7 @@ class PChar
     uint8_t mQuickBeltActiveSlot; // QB SlotID of item "in hand", or INV_WORN_QB_HAND or INV_WORN_QB_NONE
 
     uint16_t mLookingAt;  // Zone charID of currently targeted player
     uint8_t mQuickBeltActiveSlot; // QB SlotID of item "in hand", or INV_WORN_QB_HAND or INV_WORN_QB_NONE
 
     uint16_t mLookingAt;  // Zone charID of currently targeted player
-    std::time_t mLookAtTimestamp; // Lifetimer of lookat var
+    time_t mLookAtTimestamp; // Lifetimer of lookat var
     uint32_t mLastUsedWorldObjectId; // Last world object clicked on
 
     uint8_t mClanLevel; // 1-15
     uint32_t mLastUsedWorldObjectId; // Last world object clicked on
 
     uint8_t mClanLevel; // 1-15
@@ -272,8 +272,8 @@ class PChar
     inline void SetLocationLeased( bool nState = true ) { mLocationLeased = nState; }
     inline bool GetLocationLeased() { return mLocationLeased; }
 
     inline void SetLocationLeased( bool nState = true ) { mLocationLeased = nState; }
     inline bool GetLocationLeased() { return mLocationLeased; }
 
-    PSeatType GetSeatInUse( uint32_t* nObjectId = NULL, uint8_t* nSeatId = NULL );
-    void SetSeatInUse( PSeatType nSeatType, uint32_t nObjectId = 0, uint8_t nSeatId = 0 );
+    PSeatType GetSeatInUse(uint32_t* nObjectId = nullptr, uint8_t* nSeatId = nullptr);
+    void SetSeatInUse(PSeatType nSeatType, uint32_t nObjectId = 0, uint8_t nSeatId = 0);
 
     PVhcAccessRequestList* GetVhcAccessRequestList();
 
 
     PVhcAccessRequestList* GetVhcAccessRequestList();
 
@@ -313,8 +313,8 @@ class PChars
     CharMap mChars;
     uint32_t mLastID;
 
     CharMap mChars;
     uint32_t mLastID;
 
-    std::time_t mAutoSavePeriod;
-    std::time_t mLastSave;
+    time_t mAutoSavePeriod;
+    time_t mLastSave;
 
   public :
     PChars();
 
   public :
     PChars();
index c3e0508..f2d8b37 100644 (file)
@@ -10,8 +10,8 @@ PClient::PClient( int Index )
   mCharID = 0;
   mConnection = PCC_NONE;
   mRemotePort = 0;
   mCharID = 0;
   mConnection = PCC_NONE;
   mRemotePort = 0;
-  m_TCPConnection = NULL;
-  m_UDPConnection = NULL;
+  m_TCPConnection = nullptr;
+  m_UDPConnection = nullptr;
 
   for ( int i = 0; i < DEBUG_MODES ; i++ )
     mDebugMode[i] = false;
 
   for ( int i = 0; i < DEBUG_MODES ; i++ )
     mDebugMode[i] = false;
@@ -33,12 +33,12 @@ PClient::~PClient()
   if ( m_TCPConnection )
   {
     delete m_TCPConnection;
   if ( m_TCPConnection )
   {
     delete m_TCPConnection;
-    m_TCPConnection = NULL;
+    m_TCPConnection = nullptr;
   }
   if ( m_UDPConnection )
   {
     delete m_UDPConnection;
   }
   if ( m_UDPConnection )
   {
     delete m_UDPConnection;
-    m_UDPConnection = NULL;
+    m_UDPConnection = nullptr;
   }
 }
 /// ******************************************************
   }
 }
 /// ******************************************************
@@ -309,7 +309,7 @@ void PClient::FragmentAndSendUDPMessage( PMessage* nMessage, uint8_t nType )
     for ( uint16_t ChunkID = 0; ChunkID < ChunksNum; ChunkID++ )
     {
       ChunkBuffer = nMessage->GetChunk( IncludedHeaderSize, ChunkSize, ChunkID );
     for ( uint16_t ChunkID = 0; ChunkID < ChunksNum; ChunkID++ )
     {
       ChunkBuffer = nMessage->GetChunk( IncludedHeaderSize, ChunkSize, ChunkID );
-      if ( ChunkBuffer == NULL )
+      if (ChunkBuffer == nullptr)
       {
         Console->Print( RED, BLACK, "[Error] PClient::FragmentAndSendUDPMessage: Bad chunk number: %d for size %d", ChunksNum, nMessage->GetSize() );
         break;
       {
         Console->Print( RED, BLACK, "[Error] PClient::FragmentAndSendUDPMessage: Bad chunk number: %d for size %d", ChunksNum, nMessage->GetSize() );
         break;
@@ -471,13 +471,13 @@ void PClient::GameDisconnect()
   if ( m_TCPConnection )
   {
     delete m_TCPConnection;
   if ( m_TCPConnection )
   {
     delete m_TCPConnection;
-    m_TCPConnection = NULL;
+    m_TCPConnection = nullptr;
   }
 
   if ( m_UDPConnection )
   {
     delete m_UDPConnection;
   }
 
   if ( m_UDPConnection )
   {
     delete m_UDPConnection;
-    m_UDPConnection = NULL;
+    m_UDPConnection = nullptr;
   }
 
   /**** Will be better to put that char-saving-at-disconnect in Char destructor, when only used Chars will be loaded ****/
   }
 
   /**** Will be better to put that char-saving-at-disconnect in Char destructor, when only used Chars will be loaded ****/
@@ -491,7 +491,7 @@ void PClient::GameDisconnect()
       {
         //if(gDevDebug)
           Console->Print( "%s Trying to get leaving char out of her seat", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) );
       {
         //if(gDevDebug)
           Console->Print( "%s Trying to get leaving char out of her seat", Console->ColorText( CYAN, BLACK, "[DEBUG]" ) );
-        PUdpCharExitChair::DoLeaveChair( tChar, this, NULL, true );
+        PUdpCharExitChair::DoLeaveChair(tChar, this, nullptr, true);
       }
       /* // replaced by the lines above
       PSeatType cSeatType;
       }
       /* // replaced by the lines above
       PSeatType cSeatType;
@@ -560,9 +560,7 @@ void PClient::GameDisconnect()
   {
     //Console->Print(YELLOW, BLACK, "GameDisconnect: Client %i had no char online.", mIndex);
   }
   {
     //Console->Print(YELLOW, BLACK, "GameDisconnect: Client %i had no char online.", mIndex);
   }
-  /**********************************/
 
 
-  //mConnection &= ~PCC_GAME;
   mConnection = PCC_NONE;
 }
 
   mConnection = PCC_NONE;
 }
 
@@ -620,7 +618,7 @@ PChar* PClient::GetChar() const
   }
   else
   {
   }
   else
   {
-    return NULL;
+    return nullptr;
   }
 }
 
   }
 }
 
@@ -647,24 +645,6 @@ bool PClient::GetCharAwaitingWarpto( uint16_t* PosX, uint16_t* PosY, uint16_t* P
     *PosZ = mTargetZ;
 
   return mAwaitingWarpto;
     *PosZ = mTargetZ;
 
   return mAwaitingWarpto;
-  /*
-    if(mAwaitingWarpto == true)
-    {
-
-        // Position update doesnt work. Uncomment&Change function if ever required again
-        mAwaitingWarpto = false;
-            (GetChar()->Coords).mX = mTargetX;
-            (GetChar()->Coords).mY = mTargetY;
-            (GetChar()->Coords).mZ = mTargetZ;
-        return true;
-  //        PMessage* tmpMsg_posupdate;
-  //
-  //        tmpMsg_posupdate = MsgBuilder->BuildCharPosMoveMsg(this, mTargetX, mTargetY, mTargetZ);
-  //        ClientManager->UDPBroadcast(tmpMsg_posupdate, this);
-  //        tmpMsg_posupdate = NULL;
-    }
-    return false;
-  */
 }
 
 void PClient::InitWarpCircle()
 }
 
 void PClient::InitWarpCircle()
index e56d96e..c114d1d 100644 (file)
@@ -159,7 +159,7 @@ class PClient
     //inline int* getIP() const { return (int*) m_IP; }
 
     void SetAwaitingWarpto(bool yesno, uint16_t NewX, uint16_t NewY, uint16_t NewZ);
     //inline int* getIP() const { return (int*) m_IP; }
 
     void SetAwaitingWarpto(bool yesno, uint16_t NewX, uint16_t NewY, uint16_t NewZ);
-    bool GetCharAwaitingWarpto(uint16_t* PosX = NULL, uint16_t* PosY = NULL, uint16_t* PosZ = NULL);
+    bool GetCharAwaitingWarpto(uint16_t* PosX = nullptr, uint16_t* PosY = nullptr, uint16_t* PosZ = nullptr);
 
     // Char broadcasted effects
     void InitWarpCircle();
 
     // Char broadcasted effects
     void InitWarpCircle();
index 433e8fe..60df027 100644 (file)
@@ -82,27 +82,10 @@ void PClientManager::deleteClientFromList( uint32_t id )
   }
 }
 
   }
 }
 
-/* bool PClientManager::deleteClientFromList(PClient* delClient)
-{
-    for(PClientMap::iterator it=mClientList.begin(); it!=mClientList.end(); it++)
-    {
-        if(delClient == it->second)
-        {
-      //     if(it->second)
-      //    {
-      //         delete delClient;
-                mClientList.erase( it );
-                return true;
-      //    }
-        }
-    }
-    return false;
-} */
-
 PClient* PClientManager::getClientByID( uint32_t id ) const
 {
   PClientMap::const_iterator it = mClientList.find( id );
 PClient* PClientManager::getClientByID( uint32_t id ) const
 {
   PClientMap::const_iterator it = mClientList.find( id );
-  return (( it != mClientList.end() ) ? ( PClient* )( it->second ) : NULL );
+  return (( it != mClientList.end() ) ? ( PClient* )( it->second ) : nullptr);
 }
 
 PClient* PClientManager::getClientByChar( uint32_t CharID ) const
 }
 
 PClient* PClientManager::getClientByChar( uint32_t CharID ) const
@@ -115,7 +98,7 @@ PClient* PClientManager::getClientByChar( uint32_t CharID ) const
         return it->second;
     }
   }
         return it->second;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 PClient* PClientManager::getClientByChar( const std::string &Name ) const
 }
 
 PClient* PClientManager::getClientByChar( const std::string &Name ) const
@@ -128,22 +111,9 @@ PClient* PClientManager::getClientByChar( const std::string &Name ) const
         return it->second;
     }
   }
         return it->second;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 }
 
-/* uint32_t PClientManager::getClientID(PClient* _client)
-{
-    for(PClientMap::iterator it=mClientList.begin(); it!=mClientList<p align="center"></p>.end(); it++)
-    {
-        if(_client == it->second)
-        {
-            return it->first;
-        }
-    }
-
-    return -1;
-} */
-
 // Distance checking doesn't care for Z axis ATM
 int PClientManager::UDPBroadcast( PMessage* nMessage, uint32_t nZoneID, uint16_t nX, uint16_t nY, uint16_t nZ, uint16_t nMaxDist, uint32_t nSkipCharId, bool nNPCPing )
 {
 // Distance checking doesn't care for Z axis ATM
 int PClientManager::UDPBroadcast( PMessage* nMessage, uint32_t nZoneID, uint16_t nX, uint16_t nY, uint16_t nZ, uint16_t nMaxDist, uint32_t nSkipCharId, bool nNPCPing )
 {
index 0d6c973..b2c0f3e 100644 (file)
@@ -129,20 +129,6 @@ void PCommands::HandleGameCommand(char *packet, PClient *Client)
     {
         doCmdrawf();
     }
     {
         doCmdrawf();
     }
-    /* Not required anymore, TinNS gets is worlditemdata from .dat files now
-        else if(strcmp(Command, "delworlditem") == 0)
-        {
-            doCmddelworlditem();
-        }
-        else if(strcmp(Command, "addworlditem") == 0)
-        {
-            doCmdaddworlditem();
-        }
-        else if(strcmp(Command, "adddoor") == 0)
-        {
-            doCmdadddor();
-        }
-    */
     else if ( (strcmp(Command, "online") == 0) || (strcmp(Command, "who") == 0) ) // Was: connectedList
     {
         doCmdconlist();
     else if ( (strcmp(Command, "online") == 0) || (strcmp(Command, "who") == 0) ) // Was: connectedList
     {
         doCmdconlist();
@@ -321,7 +307,7 @@ bool PCommands::GetTarget(int ArgNum)
         target = GetClientByNick(tmp);
     }
 
         target = GetClientByNick(tmp);
     }
 
-    if (target == NULL)
+    if (target == nullptr)
         return false;
     else
         return true;
         return false;
     else
         return true;
@@ -354,8 +340,8 @@ void PCommands::FlushArgs()
 
     ArgC = 0;
     DumbMade = false;
 
     ArgC = 0;
     DumbMade = false;
-    source = NULL;
-    target = NULL;
+    source = nullptr;
+    target = nullptr;
 
 }
 
 
 }
 
@@ -395,41 +381,11 @@ PClient* PCommands::GetClientByID(int charid)
 {
     return ClientManager->getClientByChar( charid );
 }
 {
     return ClientManager->getClientByChar( charid );
 }
-/*
-PClient* PCommands::GetClientByID(int charid)
-{
-    for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++)
-    {
-        if(it->second)
-        {
-            PClient* target = it->second;
-            if((int)target->GetCharID() == charid)
-                return it->second;
-        }
-    }
-    return NULL;
-}
-*/
 
 PClient* PCommands::GetClientByNick(const char *nick)
 {
     return ClientManager->getClientByChar( (std::string) nick );
 }
 
 PClient* PCommands::GetClientByNick(const char *nick)
 {
     return ClientManager->getClientByChar( (std::string) nick );
 }
-/*
-PClient* PCommands::GetClientByNick(const char *nick)
-{
-    for(PClientMap::iterator it=ClientManager->getClientListBegin(); it!=ClientManager->getClientListEnd(); it++)
-    {
-        if(it->second)
-        {
-            PClient* target = it->second;
-            if(!strcasecmp(Chars->GetChar(target->GetCharID())->GetName().c_str(), nick))
-                return it->second;
-        }
-    }
-    return NULL;
-}
-*/
 
 bool PCommands::RequirePacketDumb()
 {
 
 bool PCommands::RequirePacketDumb()
 {
index 43fbe1d..23e5012 100644 (file)
@@ -15,7 +15,7 @@ PContainerEntry::PContainerEntry( PItem* nItem, uint8_t X, uint8_t Y, uint32_t n
 
 PContainerEntry::PContainerEntry( MYSQL_ROW row )
 {
 
 PContainerEntry::PContainerEntry( MYSQL_ROW row )
 {
-  mItem = NULL;
+  mItem = nullptr;
   mInvID = atoi( row[i_invid] );
   mPosX = atoi( row[i_x] );
   mPosY = atoi( row[i_y] );
   mInvID = atoi( row[i_invid] );
   mPosX = atoi( row[i_x] );
   mPosY = atoi( row[i_y] );
@@ -108,7 +108,7 @@ bool PContainerEntry::SQLDelete()
         Console->Print( GREEN, BLACK, "Item %d deleted from container DB", mInvID );
       mInvID = 0;
       delete mItem;
         Console->Print( GREEN, BLACK, "Item %d deleted from container DB", mInvID );
       mInvID = 0;
       delete mItem;
-      mItem = NULL;
+      mItem = nullptr;
 
       mDirtyFlag = false;
       return true;
 
       mDirtyFlag = false;
       return true;
@@ -127,9 +127,9 @@ PContainer::PContainer( uint8_t nMaxSlots )
 {
   mMaxSlots = ( nMaxSlots > CONTAINER_MAX_SIZE ? CONTAINER_MAX_SIZE : nMaxSlots ) ;
   if ( mMaxSlots )
 {
   mMaxSlots = ( nMaxSlots > CONTAINER_MAX_SIZE ? CONTAINER_MAX_SIZE : nMaxSlots ) ;
   if ( mMaxSlots )
-    mContContent = new std::vector< PContainerEntry* >( mMaxSlots, NULL );
+    mContContent = new std::vector<PContainerEntry *>(mMaxSlots, nullptr);
   else
   else
-    mContContent = new std::vector< PContainerEntry* >;
+    mContContent = new std::vector<PContainerEntry *>;
   mCharID = 0;
   mInvLoc = 0;
   mExclusiveUseCharID = 0;
   mCharID = 0;
   mInvLoc = 0;
   mExclusiveUseCharID = 0;
@@ -150,7 +150,7 @@ bool PContainer::AddEntry( PContainerEntry* NewEntry, uint8_t nSlotId )
   if ( IsSlotAllowed( nSlotId ) )
   {
     for ( uint8_t i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed
   if ( IsSlotAllowed( nSlotId ) )
   {
     for ( uint8_t i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed
-      mContContent->push_back( static_cast<PContainerEntry*>(NULL) );
+      mContContent->push_back( static_cast<PContainerEntry *>(nullptr));
     if ( mContContent->at( nSlotId ) )
     {
       Console->Print( RED, BLACK, "[Warning] PContainer::AddEntry: Target entry already %d in use !!!", nSlotId );
     if ( mContContent->at( nSlotId ) )
     {
       Console->Print( RED, BLACK, "[Warning] PContainer::AddEntry: Target entry already %d in use !!!", nSlotId );
@@ -182,12 +182,12 @@ void PContainer::SetEntryPosXY( PContainerEntry* nEntry, uint8_t nSlotId, uint8_
 
 PContainerEntry* PContainer::RemoveEntry( uint8_t nSlotId )
 {
 
 PContainerEntry* PContainer::RemoveEntry( uint8_t nSlotId )
 {
-  PContainerEntry* tEntry = NULL;
+  PContainerEntry *tEntry = nullptr;
 
   if ( nSlotId < mContContent->size() )
   {
     tEntry = mContContent->at( nSlotId );
 
   if ( nSlotId < mContContent->size() )
   {
     tEntry = mContContent->at( nSlotId );
-    mContContent->at( nSlotId ) = NULL;
+    mContContent->at(nSlotId) = nullptr;
   }
   return tEntry;
 }
   }
   return tEntry;
 }
@@ -210,7 +210,7 @@ void PContainer::Compact( uint8_t startSlotId )
       {
         mContContent->at( j ) = tEntry = mContContent->at( i );
         this->SetEntryPosXY( tEntry, j, tEntry->mPosX, tEntry->mPosX );
       {
         mContContent->at( j ) = tEntry = mContContent->at( i );
         this->SetEntryPosXY( tEntry, j, tEntry->mPosX, tEntry->mPosX );
-        mContContent->at( i ) = NULL;
+        mContContent->at(i) = nullptr;
         mDirtyFlag = true;
       }
       ++j;
         mDirtyFlag = true;
       }
       ++j;
@@ -272,7 +272,7 @@ bool PContainer::SQLLoad()
 
   snprintf( query, 1024, "SELECT * FROM inventory WHERE inv_charid='%d' AND inv_loc='%d' ORDER BY inv_x ASC", mCharID, mInvLoc );
   result = MySQL->GameResQuery( query );
 
   snprintf( query, 1024, "SELECT * FROM inventory WHERE inv_charid='%d' AND inv_loc='%d' ORDER BY inv_x ASC", mCharID, mInvLoc );
   result = MySQL->GameResQuery( query );
-  if ( result == NULL )
+  if (result == nullptr)
   {
     Console->Print( RED, BLACK, "[Warning] PContainer::SQLLoad could not load inventory from the database" );
     Console->Print( "Query was:" );
   {
     Console->Print( RED, BLACK, "[Warning] PContainer::SQLLoad could not load inventory from the database" );
     Console->Print( "Query was:" );
@@ -438,7 +438,7 @@ bool PContainer::MoveItem( uint8_t srcSlotId, uint8_t nCount, uint8_t dstSlotId
     tEntry->mPosX = dstSlotId;
     tEntry->mPosY = 0;
     tEntry->mDirtyFlag = true;
     tEntry->mPosX = dstSlotId;
     tEntry->mPosY = 0;
     tEntry->mDirtyFlag = true;
-    mContContent->at( srcSlotId ) = NULL;
+    mContContent->at(srcSlotId) = nullptr;
     mDirtyFlag = true;
     return true;
   }
     mDirtyFlag = true;
     return true;
   }
@@ -462,7 +462,7 @@ std::vector< PContainerEntry* >* PContainer::GetEntries()
 PContainerEntry* PContainer::GetEntry( uint8_t nSlotId )
 {
   if ( nSlotId >= mContContent->size() )
 PContainerEntry* PContainer::GetEntry( uint8_t nSlotId )
 {
   if ( nSlotId >= mContContent->size() )
-    return NULL;
+    return nullptr;
 
   return mContContent->at( nSlotId );
 }
 
   return mContContent->at( nSlotId );
 }
@@ -470,12 +470,12 @@ PContainerEntry* PContainer::GetEntry( uint8_t nSlotId )
 PItem* PContainer::GetItem( uint8_t nSlotId )
 {
   PContainerEntry* tEntry = this->GetEntry( nSlotId );
 PItem* PContainer::GetItem( uint8_t nSlotId )
 {
   PContainerEntry* tEntry = this->GetEntry( nSlotId );
-  return ( tEntry ? tEntry->mItem : NULL );
+  return (tEntry ? tEntry->mItem : nullptr);
 }
 
 uint8_t PContainer::RandomFill( uint8_t nItemCount, int nItemContainerDefIndex )
 {
 }
 
 uint8_t PContainer::RandomFill( uint8_t nItemCount, int nItemContainerDefIndex )
 {
-  PItem* nItem = NULL;
+  PItem* nItem = nullptr;
   const PDefItems* nItemDef;
   uint32_t nItemSeqId;
   uint8_t CreatedCount = 0;
   const PDefItems* nItemDef;
   uint32_t nItemSeqId;
   uint8_t CreatedCount = 0;
@@ -581,12 +581,12 @@ void PContainer::Dump()
 /* --- PContainerAutoCompact --- */
 PContainerEntry* PContainerAutoCompact::RemoveEntry( uint8_t nSlotId )
 {
 /* --- PContainerAutoCompact --- */
 PContainerEntry* PContainerAutoCompact::RemoveEntry( uint8_t nSlotId )
 {
-  PContainerEntry* tEntry = NULL;
+  PContainerEntry* tEntry = nullptr;
 
   if ( nSlotId < mContContent->size() )
   {
     tEntry = mContContent->at( nSlotId );
 
   if ( nSlotId < mContContent->size() )
   {
     tEntry = mContContent->at( nSlotId );
-    mContContent->at( nSlotId ) = NULL;
+    mContContent->at( nSlotId ) = nullptr;
     if ( nSlotId == ( mContContent->size() - 1 ) )
       mContContent->pop_back();
     else
     if ( nSlotId == ( mContContent->size() - 1 ) )
       mContContent->pop_back();
     else
@@ -651,7 +651,7 @@ bool PContainer2DWorkaround::AddEntry( PContainerEntry* tEntry, uint8_t nSlotId
     if ( FindValid2DPos( tEntry ) )
     {
       for ( uint8_t i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed
     if ( FindValid2DPos( tEntry ) )
     {
       for ( uint8_t i = mContContent->size(); i <= nSlotId; ++i ) // Extend as needed
-        mContContent->push_back( static_cast<PContainerEntry *>(NULL) );
+        mContContent->push_back( static_cast<PContainerEntry *>(nullptr));
       if ( mContContent->at( nSlotId ) )
       {
         Console->Print( RED, BLACK, "[Warning] PContainer2DWorkaround::AddEntry: Target entry already %d in use !!!", nSlotId );
       if ( mContContent->at( nSlotId ) )
       {
         Console->Print( RED, BLACK, "[Warning] PContainer2DWorkaround::AddEntry: Target entry already %d in use !!!", nSlotId );
@@ -680,12 +680,12 @@ bool PContainer2DWorkaround::AddEntry( PContainerEntry* tEntry, uint8_t nSlotId
 
 PContainerEntry* PContainer2DWorkaround::RemoveEntry( uint8_t nSlotId )
 {
 
 PContainerEntry* PContainer2DWorkaround::RemoveEntry( uint8_t nSlotId )
 {
-  PContainerEntry* tEntry = NULL;
+  PContainerEntry* tEntry = nullptr;
 
   if ( nSlotId < mContContent->size() )
   {
     tEntry = mContContent->at( nSlotId );
 
   if ( nSlotId < mContContent->size() )
   {
     tEntry = mContContent->at( nSlotId );
-    mContContent->at( nSlotId ) = NULL;
+    mContContent->at( nSlotId ) = nullptr;
     //Console->Print(YELLOW, BLACK, "Cleaning (%d,%d) (%d x %d)", tEntry->mPosX, tEntry->mPosY, tEntry->mItem->GetSizeX(), tEntry->mItem->GetSizeY());
     SetUsed( tEntry, false );
   }
     //Console->Print(YELLOW, BLACK, "Cleaning (%d,%d) (%d x %d)", tEntry->mPosX, tEntry->mPosY, tEntry->mItem->GetSizeX(), tEntry->mItem->GetSizeY());
     SetUsed( tEntry, false );
   }
index edd7e4e..2f4a1d7 100644 (file)
@@ -12,7 +12,7 @@ PUdp0x13::PUdp0x13( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyser( nDecodeData
 PUdpMsgAnalyser* PUdp0x13::Analyse()
 {
     PMessage* TmpMsg = mDecodeData->mMessage;
 PUdpMsgAnalyser* PUdp0x13::Analyse()
 {
     PMessage* TmpMsg = mDecodeData->mMessage;
-    PUdpMsgAnalyser* nextAnalyser = NULL;
+    PUdpMsgAnalyser* nextAnalyser = nullptr;
 
     if ( ! mDecodeData->mHandling0x13Sub ) // First decoding pass
     {
 
     if ( ! mDecodeData->mHandling0x13Sub ) // First decoding pass
     {
index d9e6fda..c4a90f0 100644 (file)
@@ -10,7 +10,7 @@ PUdp0x1f::PUdp0x1f( PMsgDecodeData* nDecodeData ) : PUdpMsgAnalyser( nDecodeData
 
 PUdpMsgAnalyser* PUdp0x1f::Analyse()
 {
 
 PUdpMsgAnalyser* PUdp0x1f::Analyse()
 {
-  PUdpMsgAnalyser* nextAnalyser = NULL;
+  PUdpMsgAnalyser* nextAnalyser = nullptr;
   mDecodeData->mState = DECODE_MORE;
   uint8_t MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 7 );
   uint8_t MsgSubType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 8 );
   mDecodeData->mState = DECODE_MORE;
   uint8_t MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 7 );
   uint8_t MsgSubType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 8 );
index a2f54ee..0c88902 100644 (file)
@@ -10,7 +10,7 @@ PUdp0x22::PUdp0x22(PMsgDecodeData* nDecodeData) : PUdpMsgAnalyser(nDecodeData)
 
 PUdpMsgAnalyser* PUdp0x22::Analyse()
 {
 
 PUdpMsgAnalyser* PUdp0x22::Analyse()
 {
-  PUdpMsgAnalyser* nextAnalyser = NULL;
+  PUdpMsgAnalyser* nextAnalyser = nullptr;
   mDecodeData->mState = DECODE_MORE;
   uint8_t MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5);
   switch(MsgType) // MsgType is probably uint16_t rather than uint8_t
   mDecodeData->mState = DECODE_MORE;
   uint8_t MsgType = mDecodeData->mMessage->U8Data(mDecodeData->Sub0x13Start + 5);
   switch(MsgType) // MsgType is probably uint16_t rather than uint8_t
index 35473c0..f6153c5 100644 (file)
@@ -23,8 +23,8 @@ bool PUdpHackSuccess::DoAction()
     PClient* nClient = mDecodeData->mClient;
     PChar* tChar = nClient->GetChar();
     PWorld* CurrentWorld = Worlds->GetWorld(tChar->GetLocation());
     PClient* nClient = mDecodeData->mClient;
     PChar* tChar = nClient->GetChar();
     PWorld* CurrentWorld = Worlds->GetWorld(tChar->GetLocation());
-    const PFurnitureItemTemplate* tFurnitureTemplate = NULL;
-    const PDefWorldModel* tFurnitureModel = NULL;
+    const PFurnitureItemTemplate* tFurnitureTemplate = nullptr;
+    const PDefWorldModel* tFurnitureModel = nullptr;
 
     uint32_t mRawItemID = mDecodeData->mMessage->U32Data(mDecodeData->Sub0x13Start+8);
     if(gDevDebug) Console->Print("DEBUG: Client %d successfully hacked object %d", mDecodeData->mClient->GetID(), mRawItemID);
 
     uint32_t mRawItemID = mDecodeData->mMessage->U32Data(mDecodeData->Sub0x13Start+8);
     if(gDevDebug) Console->Print("DEBUG: Client %d successfully hacked object %d", mDecodeData->mClient->GetID(), mRawItemID);
@@ -53,7 +53,7 @@ bool PUdpHackSuccess::DoAction()
     }
 
 
     }
 
 
-    if(tHandleDynamicActor == false && tFurnitureTemplate != NULL)
+    if(tHandleDynamicActor == false && tFurnitureTemplate != nullptr)
     {
         if (tFurnitureTemplate->GetLinkedObjectID())
         {
     {
         if (tFurnitureTemplate->GetLinkedObjectID())
         {
index e0c0a35..f2fccbd 100644 (file)
@@ -132,8 +132,8 @@ bool PUdpHeldItemLaunchingAction::DoAction()
   PClient* nClient = mDecodeData->mClient;
   PChar* tChar = nClient->GetChar();
   PWorld* CurrentWorld = Worlds->GetWorld( tChar->GetLocation() );
   PClient* nClient = mDecodeData->mClient;
   PChar* tChar = nClient->GetChar();
   PWorld* CurrentWorld = Worlds->GetWorld( tChar->GetLocation() );
-  const PFurnitureItemTemplate* tFurnitureTemplate = NULL;
-  const PDefWorldModel* tFurnitureModel = NULL;
+  const PFurnitureItemTemplate* tFurnitureTemplate = nullptr;
+  const PDefWorldModel* tFurnitureModel = nullptr;
 
   uint32_t mRawItemID = mDecodeData->mMessage->U32Data( mDecodeData->Sub0x13Start + 24 );
   //if(gDevDebug) Console->Print("Client %d wants to hack itemID %d ***not managed yet***", mDecodeData->mClient->GetID(), mRawItemID);
 
   uint32_t mRawItemID = mDecodeData->mMessage->U32Data( mDecodeData->Sub0x13Start + 24 );
   //if(gDevDebug) Console->Print("Client %d wants to hack itemID %d ***not managed yet***", mDecodeData->mClient->GetID(), mRawItemID);
@@ -172,7 +172,7 @@ bool PUdpHeldItemLaunchingAction::DoAction()
 
       PMessage* tmpMsg = MsgBuilder->BuildStartHackGameMsg( nClient, mRawItemID, tHackDifficult );
       nClient->SendUDPMessage( tmpMsg );
 
       PMessage* tmpMsg = MsgBuilder->BuildStartHackGameMsg( nClient, mRawItemID, tHackDifficult );
       nClient->SendUDPMessage( tmpMsg );
-      tmpMsg = NULL;
+      tmpMsg = nullptr;
     }
   }
 
     }
   }
 
index 4ef1208..dcdf9ef 100644 (file)
@@ -41,7 +41,7 @@ bool PUdpItemMove::DoAction()
   uint8_t origDstY = mDstY;
   PContainerEntry* tEntry;
 
   uint8_t origDstY = mDstY;
   PContainerEntry* tEntry;
 
-  PItem* tItem = NULL;
+  PItem* tItem = nullptr;
 
   PContainer* SrcContainer = GetContainerByLoc( tChar, mSrcLoc );
   if ( SrcContainer )
 
   PContainer* SrcContainer = GetContainerByLoc( tChar, mSrcLoc );
   if ( SrcContainer )
@@ -131,7 +131,7 @@ bool PUdpItemMove::DoAction()
 
 PContainer* PUdpItemMove::GetContainerByLoc( PChar* nChar, uint8_t nLoc )
 {
 
 PContainer* PUdpItemMove::GetContainerByLoc( PChar* nChar, uint8_t nLoc )
 {
-  PContainer* tContainer = NULL;
+  PContainer* tContainer = nullptr;
 
   switch ( nLoc )
   {
 
   switch ( nLoc )
   {
@@ -216,7 +216,7 @@ bool PUdpItemMoveBP::DoAction()
 //SrcContainer->Dump();
 
 // No answer to confirm ?
 //SrcContainer->Dump();
 
 // No answer to confirm ?
-//tmpMsg = NULL;
+//tmpMsg = nullptr;
 
   mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED;
   return true;
 
   mDecodeData->mState = DECODE_ACTION_DONE | DECODE_FINISHED;
   return true;
index 54587cc..533f420 100644 (file)
@@ -12,7 +12,7 @@ PUdpPopupResponse::PUdpPopupResponse( PMsgDecodeData* nDecodeData ) : PUdpMsgAna
 
 PUdpMsgAnalyser* PUdpPopupResponse::Analyse()
 {
 
 PUdpMsgAnalyser* PUdpPopupResponse::Analyse()
 {
-  PUdpMsgAnalyser* nextAnalyser = NULL;
+  PUdpMsgAnalyser* nextAnalyser = nullptr;
   mDecodeData->mState = DECODE_MORE;
   uint8_t MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 12 ); //uint32_t but only uint8_t used
 
   mDecodeData->mState = DECODE_MORE;
   uint8_t MsgType = mDecodeData->mMessage->U8Data( mDecodeData->Sub0x13Start + 12 ); //uint32_t but only uint8_t used
 
@@ -130,7 +130,7 @@ bool PUdpVhcAccessResponse::DoAction()
     uint32_t vehicleId = 0;
     nAccessRequests->GetInfo( mVhcAccessRequestId, &requesterCharId, &vehicleId );
     PClient* requesterClient = ClientManager->getClientByChar( requesterCharId );
     uint32_t vehicleId = 0;
     nAccessRequests->GetInfo( mVhcAccessRequestId, &requesterCharId, &vehicleId );
     PClient* requesterClient = ClientManager->getClientByChar( requesterCharId );
-    PChar* requesterChar = ( requesterClient ? requesterClient->GetChar() : NULL );
+    PChar* requesterChar = (requesterClient ? requesterClient->GetChar() : nullptr);
 
     if ( requesterChar && nAccessRequests->Check( mVhcAccessRequestId ) )
     {
 
     if ( requesterChar && nAccessRequests->Check( mVhcAccessRequestId ) )
     {
index 7526e3a..3f40d18 100644 (file)
@@ -28,7 +28,7 @@ bool PUdpItemSlotUse::DoAction()
 {
   PClient* nClient = mDecodeData->mClient;
   PChar* tChar = nClient->GetChar();
 {
   PClient* nClient = mDecodeData->mClient;
   PChar* tChar = nClient->GetChar();
-  PItem* targetItem = NULL;
+  PItem* targetItem = nullptr;
   bool tUsable = false;
   bool tUsableInHand = false;
   uint16_t nWeaponId = 0;
   bool tUsable = false;
   bool tUsableInHand = false;
   uint16_t nWeaponId = 0;
index 7d5628f..e8e073b 100644 (file)
@@ -66,11 +66,11 @@ PUdpMsgAnalyser* PUdpReqInfo::Analyse()
 
 bool PUdpReqInfo::DoAction()
 {
 
 bool PUdpReqInfo::DoAction()
 {
-    MYSQL_RES* result = NULL;
+    MYSQL_RES* result = nullptr;
     MYSQL_ROW row;
     char query[255];
     char txtmsg[32];
     MYSQL_ROW row;
     char query[255];
     char txtmsg[32];
-    void* Answer = NULL;
+    void* Answer = nullptr;
     int len;
 
     query[0]='\0';
     int len;
 
     query[0]='\0';
@@ -166,7 +166,7 @@ bool PUdpReqInfo::DoAction()
     if(mRequestType == 3)
     {
         uint32_t tFileLen = 0;
     if(mRequestType == 3)
     {
         uint32_t tFileLen = 0;
-        PFile* fLua = NULL;
+        PFile* fLua = nullptr;
         fLua = Filesystem->Open( "", (char*)Answer, Config->GetOption( "nc_data_path" ) );
         std::string tLUAScript = "";
         if(fLua)
         fLua = Filesystem->Open( "", (char*)Answer, Config->GetOption( "nc_data_path" ) );
         std::string tLUAScript = "";
         if(fLua)
@@ -176,7 +176,7 @@ bool PUdpReqInfo::DoAction()
             memset(t_content, '\0', tFileLen+1);
 
             fLua->Read( t_content, tFileLen );
             memset(t_content, '\0', tFileLen+1);
 
             fLua->Read( t_content, tFileLen );
-            fLua = NULL;
+            fLua = nullptr;
 
             Filesystem->Close( fLua );
             tLUAScript =  t_content;  // APPEND the script to our existing lua headerfile
 
             Filesystem->Close( fLua );
             tLUAScript =  t_content;  // APPEND the script to our existing lua headerfile
index 004f7ba..25208e9 100644 (file)
@@ -529,7 +529,7 @@ bool PUdpQueryDB::ActionDismissVehicle()
         {
           if (( tChar = Chars->GetChar( tCharId ) ) )
           {
         {
           if (( tChar = Chars->GetChar( tCharId ) ) )
           {
-            PUdpCharExitChair::DoLeaveChair( tChar, NULL, tVhc );
+            PUdpCharExitChair::DoLeaveChair(tChar, nullptr, tVhc);
           }
         }
       }
           }
         }
       }
index b73f0fd..45b0996 100644 (file)
@@ -253,8 +253,8 @@ bool PUdpUseObject::DoAction()
     }
     else // furniture objects
     {
     }
     else // furniture objects
     {
-      const PFurnitureItemTemplate* tFurnitureTemplate = NULL;
-      const PDefWorldModel* tFurnitureModel = NULL;
+      const PFurnitureItemTemplate* tFurnitureTemplate = nullptr;
+      const PDefWorldModel* tFurnitureModel = nullptr;
       if ( tHandleDynamicActor == false )
       {
         // We have an STATIC ACTOR, which means we DONT KNOW the FUNCTION VALUE from pak_worldmodel.def yet
       if ( tHandleDynamicActor == false )
       {
         // We have an STATIC ACTOR, which means we DONT KNOW the FUNCTION VALUE from pak_worldmodel.def yet
@@ -309,7 +309,7 @@ bool PUdpUseObject::DoAction()
                 CurrentWorld->CharLeaveChair( nClient->GetLocalID(), cSeatObjectId );
               }
               nChar->SetSeatInUse( seat_chair, ItemID );
                 CurrentWorld->CharLeaveChair( nClient->GetLocalID(), cSeatObjectId );
               }
               nChar->SetSeatInUse( seat_chair, ItemID );
-              if ( tHandleDynamicActor == false && tFurnitureTemplate != NULL )
+              if (tHandleDynamicActor == false && tFurnitureTemplate != nullptr)
               {
                 tFurnitureTemplate->GetFrontPos( &( nChar->Coords.mX ), &( nChar->Coords.mY ), &( nChar->Coords.mZ ) );
                 //(nChar->Coords).mLR = tFurnitureTemplate->GetFrontLR();
               {
                 tFurnitureTemplate->GetFrontPos( &( nChar->Coords.mX ), &( nChar->Coords.mY ), &( nChar->Coords.mZ ) );
                 //(nChar->Coords).mLR = tFurnitureTemplate->GetFrontLR();
@@ -354,7 +354,7 @@ bool PUdpUseObject::DoAction()
                 //nEntity = MySQL->GetWorldItemOption(mRawItemID/256, nLocation, 1);
                 // This is a kind of nearly-not-hardcoded-hack ...
                 int nEntityInt = 0;
                 //nEntity = MySQL->GetWorldItemOption(mRawItemID/256, nLocation, 1);
                 // This is a kind of nearly-not-hardcoded-hack ...
                 int nEntityInt = 0;
-                if ( tHandleDynamicActor == false && tFurnitureTemplate != NULL )
+                if (tHandleDynamicActor == false && tFurnitureTemplate != nullptr)
                 {
                   nEntityInt = GameDefs->Respawns()->GetRespawnEntity( nChar->GetLocation(), tFurnitureTemplate->GetLinkedObjectID() );
                 }
                 {
                   nEntityInt = GameDefs->Respawns()->GetRespawnEntity( nChar->GetLocation(), tFurnitureTemplate->GetLinkedObjectID() );
                 }
@@ -506,7 +506,7 @@ bool PUdpUseObject::DoAction()
             {
               if ( Appartements->CanFreelyEnter( nChar, nChar->GetLocation() ) )
               {
             {
               if ( Appartements->CanFreelyEnter( nChar, nChar->GetLocation() ) )
               {
-                if ( tHandleDynamicActor == false && tFurnitureTemplate != NULL )
+                if (tHandleDynamicActor == false && tFurnitureTemplate != nullptr)
                 {
                   if ( tFurnitureTemplate->GetLinkedObjectID() )
                   {
                 {
                   if ( tFurnitureTemplate->GetLinkedObjectID() )
                   {
@@ -544,7 +544,7 @@ bool PUdpUseObject::DoAction()
 
             case 12: //Standard Button
             {
 
             case 12: //Standard Button
             {
-              if ( tHandleDynamicActor == false && tFurnitureTemplate != NULL )
+              if (tHandleDynamicActor == false && tFurnitureTemplate != nullptr)
               {
                 if ( tFurnitureTemplate->GetLinkedObjectID() )
                 {
               {
                 if ( tFurnitureTemplate->GetLinkedObjectID() )
                 {
@@ -575,7 +575,7 @@ bool PUdpUseObject::DoAction()
             }
             case 13: //Hack Button
             {
             }
             case 13: //Hack Button
             {
-              if ( tHandleDynamicActor == false && tFurnitureTemplate != NULL )
+              if (tHandleDynamicActor == false && tFurnitureTemplate != nullptr)
               {
                 if ( tFurnitureTemplate->GetLinkedObjectID() )
                 {
               {
                 if ( tFurnitureTemplate->GetLinkedObjectID() )
                 {
@@ -626,7 +626,7 @@ bool PUdpUseObject::DoAction()
 
             case 23: //EINTRITTSGELD BUTTON
             {
 
             case 23: //EINTRITTSGELD BUTTON
             {
-              if ( tHandleDynamicActor == false && tFurnitureTemplate != NULL )
+              if (tHandleDynamicActor == false && tFurnitureTemplate != nullptr)
               {
                 if ( tFurnitureTemplate->GetLinkedObjectID() )
                 {
               {
                 if ( tFurnitureTemplate->GetLinkedObjectID() )
                 {
@@ -637,7 +637,7 @@ bool PUdpUseObject::DoAction()
                     uint32_t NewCash = nChar->SetCash( OldCash - DoorFee );
                     PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg( nClient, NewCash );
                     nClient->SendUDPMessage( tmpMsg_cash );
                     uint32_t NewCash = nChar->SetCash( OldCash - DoorFee );
                     PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg( nClient, NewCash );
                     nClient->SendUDPMessage( tmpMsg_cash );
-                    tmpMsg_cash = NULL;
+                    tmpMsg_cash = nullptr;
                     tmpMsg = MsgBuilder->BuildDoorOpenMsg( 0x80 + tFurnitureTemplate->GetLinkedObjectID(), CurrentWorld->GetDoor( tFurnitureTemplate->GetLinkedObjectID() )->IsDoubleDoor() );
                     ClientManager->UDPBroadcast( tmpMsg, nClient );
                   }
                     tmpMsg = MsgBuilder->BuildDoorOpenMsg( 0x80 + tFurnitureTemplate->GetLinkedObjectID(), CurrentWorld->GetDoor( tFurnitureTemplate->GetLinkedObjectID() )->IsDoubleDoor() );
                     ClientManager->UDPBroadcast( tmpMsg, nClient );
                   }
@@ -665,7 +665,7 @@ bool PUdpUseObject::DoAction()
                     uint32_t NewCash = nChar->SetCash( OldCash - DoorFee );
                     PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg( nClient, NewCash );
                     nClient->SendUDPMessage( tmpMsg_cash );
                     uint32_t NewCash = nChar->SetCash( OldCash - DoorFee );
                     PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg( nClient, NewCash );
                     nClient->SendUDPMessage( tmpMsg_cash );
-                    tmpMsg_cash = NULL;
+                    tmpMsg_cash = nullptr;
                     tmpMsg = MsgBuilder->BuildDoorOpenMsg( 0x80 + linkobjID, CurrentWorld->GetDoor( linkobjID )->IsDoubleDoor() );
                     ClientManager->UDPBroadcast( tmpMsg, nClient );
                   }
                     tmpMsg = MsgBuilder->BuildDoorOpenMsg( 0x80 + linkobjID, CurrentWorld->GetDoor( linkobjID )->IsDoubleDoor() );
                     ClientManager->UDPBroadcast( tmpMsg, nClient );
                   }
@@ -853,7 +853,7 @@ bool PUdpCloseItemContainer::DoAction()
   PContainer* tContainer = nChar->GetContainerInExclusiveUse();
   if ( tContainer )
   {
   PContainer* tContainer = nChar->GetContainerInExclusiveUse();
   if ( tContainer )
   {
-    nChar->SetContainerInExclusiveUse( NULL );
+    nChar->SetContainerInExclusiveUse(nullptr);
     tContainer->EndUse( nChar->GetID() );
     if ( ! tContainer->GetOwnerId() )
     {
     tContainer->EndUse( nChar->GetID() );
     if ( ! tContainer->GetOwnerId() )
     {
index 9d7b747..a7aeb08 100644 (file)
@@ -23,7 +23,7 @@ PUdpMsgAnalyser* PWorldIDInfoReq::Analyse()
 
 bool PWorldIDInfoReq::DoAction()
 {
 
 bool PWorldIDInfoReq::DoAction()
 {
-    PNPC* targetNPC = NULL;
+    PNPC* targetNPC = nullptr;
 
     PNPCWorld* currentNPCWorld = NPCManager->GetWorld( mDecodeData->mClient->GetChar()->GetLocation() );
     if ( currentNPCWorld )
 
     PNPCWorld* currentNPCWorld = NPCManager->GetWorld( mDecodeData->mClient->GetChar()->GetLocation() );
     if ( currentNPCWorld )
index f94e403..e26c54b 100644 (file)
@@ -287,7 +287,7 @@ bool PUdpAppartmentAccess::DoAction()
       tmpMsg = MsgBuilder->BuildAptLiftFailedMsg( nClient );
     }
     else
       tmpMsg = MsgBuilder->BuildAptLiftFailedMsg( nClient );
     }
     else
-      tmpMsg = NULL;
+      tmpMsg = nullptr;
 
     mDecodeData->mTraceDump = true;
   }
 
     mDecodeData->mTraceDump = true;
   }
index 2b8e54e..b487962 100644 (file)
@@ -97,7 +97,7 @@ bool PDefItems::LoadFromDef( PTokenList *Tokens )
 
 PDefItemsMap::PDefItemsMap()
 {
 
 PDefItemsMap::PDefItemsMap()
 {
-  mMapItCache = NULL;
+  mMapItCache = nullptr;
   mMapItCacheCount = 0;
   mMaxItemGroupId = -1;
 }
   mMapItCacheCount = 0;
   mMaxItemGroupId = -1;
 }
@@ -155,7 +155,7 @@ void PDefItemsMap::BuildItemGroups()
       mMaxItemGroupId = i->first;
     //Console->Print("Item group %d : %d items", i->first, i->second);
   }
       mMaxItemGroupId = i->first;
     //Console->Print("Item group %d : %d items", i->first, i->second);
   }
-  
+
   // Effective groups building
   for ( std::map<int, PDefItems*>::const_iterator i = mDefs.begin(); i != mDefs.end(); i++ )
     mItemGroups[ i->second->GetItemGroupID() ].push_back(i->first); // i->first is ItemIndex
   // Effective groups building
   for ( std::map<int, PDefItems*>::const_iterator i = mDefs.begin(); i != mDefs.end(); i++ )
     mItemGroups[ i->second->GetItemGroupID() ].push_back(i->first); // i->first is ItemIndex
@@ -177,7 +177,7 @@ const PDefItems* PDefItemsMap::GetDefBySeqIndex( int nSeqIndex ) const
 {
   int CacheEntryIdx = nSeqIndex / GAMEDEFS_DEFITEMSMAXSEQ;
   if ( CacheEntryIdx >= mMapItCacheCount )
 {
   int CacheEntryIdx = nSeqIndex / GAMEDEFS_DEFITEMSMAXSEQ;
   if ( CacheEntryIdx >= mMapItCacheCount )
-    return NULL;
+    return nullptr;
 
   std::map<int, PDefItems*>::const_iterator It = mMapItCache[CacheEntryIdx];
   int EntrySeqIdx = CacheEntryIdx * GAMEDEFS_DEFITEMSMAXSEQ;
 
   std::map<int, PDefItems*>::const_iterator It = mMapItCache[CacheEntryIdx];
   int EntrySeqIdx = CacheEntryIdx * GAMEDEFS_DEFITEMSMAXSEQ;
@@ -193,7 +193,7 @@ const PDefItems* PDefItemsMap::GetDefBySeqIndex( int nSeqIndex ) const
     return It->second;
   }
   else
     return It->second;
   }
   else
-    return NULL;
+    return nullptr;
 }
 
 int PDefItemsMap::GetRandomItemIdFromGroup( int nGroupId ) const
 }
 
 int PDefItemsMap::GetRandomItemIdFromGroup( int nGroupId ) const
index 346a320..2b10043 100644 (file)
@@ -7,7 +7,7 @@ const uint16_t nonDiscardUseFlags = ufTouchable | ufUsable | ufChair | ufToolTar
 
 PWorldDatParser::PWorldDatParser()
 {
 
 PWorldDatParser::PWorldDatParser()
 {
-    f = NULL;
+    f = nullptr;
 }
 
 PWorldDatParser::~PWorldDatParser()
 }
 
 PWorldDatParser::~PWorldDatParser()
@@ -210,7 +210,7 @@ bool PWorldDatParser::ProcessSec2ElemType3( uint32_t nSize ) // furniture
     else
     {
         nName = "PASSIVE";
     else
     {
         nName = "PASSIVE";
-        nWorldModel = NULL;
+        nWorldModel = nullptr;
     }
 
     /* if (gDevDebug) {
     }
 
     /* if (gDevDebug) {
@@ -334,7 +334,7 @@ bool PWorldDatParser::ProcessSec2ElemType5( uint32_t nSize ) // doors
     else
     {
         nName = "PASSIVE";
     else
     {
         nName = "PASSIVE";
-        nWorldModel = NULL;
+        nWorldModel = nullptr;
     }
 
     StringData[Data.mActorStringSize - 1] = 0;
     }
 
     StringData[Data.mActorStringSize - 1] = 0;
index 43685e7..50540ed 100644 (file)
@@ -11,7 +11,7 @@ PDoorTemplate::PDoorTemplate()
 {
   mDoorID = 0;
   mWorldmodelID = 0;
 {
   mDoorID = 0;
   mWorldmodelID = 0;
-  mDefWorldModel = NULL;
+  mDefWorldModel = nullptr;
   mIsDoubleDoor = false;
   mIsTriggeredDoor = false;
 }
   mIsDoubleDoor = false;
   mIsTriggeredDoor = false;
 }
index 3d1e974..6ba560e 100644 (file)
@@ -8,7 +8,7 @@ PFurnitureItemTemplate::PFurnitureItemTemplate()
   mObjectID = 0;
   mModelID = 0;
   mWorldmodelID = 0;
   mObjectID = 0;
   mModelID = 0;
   mWorldmodelID = 0;
-  mDefWorldModel = NULL;
+  mDefWorldModel = nullptr;
   mLinkedObjectID = 0;
 }
 
   mLinkedObjectID = 0;
 }
 
index c7b50f3..e75de41 100644 (file)
@@ -38,7 +38,7 @@ void PCommands::doCmdgivemoney()
             GetArgText(2, tmp_destNick, 50);
             target = GetClientByNick(tmp_destNick);
         }
             GetArgText(2, tmp_destNick, 50);
             target = GetClientByNick(tmp_destNick);
         }
-        if(target == NULL)
+        if (target == nullptr)
         {
             Chat->send(source, CHAT_DIRECT, "System", "No such player");
             return;
         {
             Chat->send(source, CHAT_DIRECT, "System", "No such player");
             return;
@@ -58,7 +58,7 @@ void PCommands::doCmdgivemoney()
 
         PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(target, newcashvalue);
         target->SendUDPMessage(tmpMsg_cash);
 
         PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(target, newcashvalue);
         target->SendUDPMessage(tmpMsg_cash);
-        tmpMsg_cash = NULL;
+        tmpMsg_cash = nullptr;
 
         char tmpMsg_success[200];
         snprintf(tmpMsg_success, 199, "Added %d NC to %s's wallet (Has now %d NC)", diffcash, target->GetChar()->GetName().c_str(), newcashvalue);
 
         char tmpMsg_success[200];
         snprintf(tmpMsg_success, 199, "Added %d NC to %s's wallet (Has now %d NC)", diffcash, target->GetChar()->GetName().c_str(), newcashvalue);
@@ -72,7 +72,7 @@ void PCommands::doCmdgivemoney()
 
         PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(source, newcashvalue);
         source->SendUDPMessage(tmpMsg_cash);
 
         PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(source, newcashvalue);
         source->SendUDPMessage(tmpMsg_cash);
-        tmpMsg_cash = NULL;
+        tmpMsg_cash = nullptr;
         //Console->Print("oldcashval: %d  newcashvalue: %d", oldcashval, newcashvalue);
     }
 }
         //Console->Print("oldcashval: %d  newcashvalue: %d", oldcashval, newcashvalue);
     }
 }
index 92d023c..77b9402 100644 (file)
@@ -25,7 +25,7 @@ void PCommands::doCmdinfo()
         target = GetClientByNick(tmp_destNick);
     }
 
         target = GetClientByNick(tmp_destNick);
     }
 
-    if(target == NULL) // If victim isnt found, return error
+    if (target == nullptr) // If victim isnt found, return error
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
index 3a715d8..367af41 100644 (file)
@@ -26,7 +26,7 @@ void PCommands::doCmdjail()
     target = GetClientByNick( tmp_destNick );
   }
 
     target = GetClientByNick( tmp_destNick );
   }
 
-  if ( target == NULL ) // If victim isnt found, return error
+  if (target == nullptr) // If victim isnt found, return error
   {
     Chat->send( source, CHAT_DIRECT, "System", "No such player" );
     return;
   {
     Chat->send( source, CHAT_DIRECT, "System", "No such player" );
     return;
@@ -56,7 +56,7 @@ void PCommands::doCmdjail()
   {
     PMessage* tmpMsg_zone = MsgBuilder->BuildAptLiftUseMsg( target, destZone, 0 );
     target->SendUDPMessage( tmpMsg_zone );
   {
     PMessage* tmpMsg_zone = MsgBuilder->BuildAptLiftUseMsg( target, destZone, 0 );
     target->SendUDPMessage( tmpMsg_zone );
-    tmpMsg_zone = NULL;
+    tmpMsg_zone = nullptr;
 
     char tmpMsg_success[81];
     snprintf( tmpMsg_success, 80, "Successfully jailed %s", target->GetChar()->GetName().c_str() );
 
     char tmpMsg_success[81];
     snprintf( tmpMsg_success, 80, "Successfully jailed %s", target->GetChar()->GetName().c_str() );
index c4a6b00..57f5218 100644 (file)
@@ -26,7 +26,7 @@ void PCommands::doCmdkick()
         target = GetClientByNick(tmp_destNick);
     }
 
         target = GetClientByNick(tmp_destNick);
     }
 
-    if(target == NULL) // If victim isnt found, return error
+    if (target == nullptr) // If victim isnt found, return error
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
@@ -43,7 +43,7 @@ void PCommands::doCmdkick()
     }
 
 // *************** Checks done, proceed with command
     }
 
 // *************** Checks done, proceed with command
-    int final_bantime = std::time(NULL) + 60;               // Ban 60 seconds (Anti-Rejoin)
+    int final_bantime = Time::nowTimeT() + 60;               // Ban 60 seconds (Anti-Rejoin)
     PAccount Acc(target->GetAccountID());
     Acc.SetBannedUntilTime(final_bantime);
     Acc.Save();
     PAccount Acc(target->GetAccountID());
     Acc.SetBannedUntilTime(final_bantime);
     Acc.Save();
index 8737347..88b15ed 100644 (file)
@@ -29,8 +29,8 @@ void PCommands::doNPC()
     GetArgText(1, tmp_npccommand, 50);
 
     // Dont search for NPC ID when commands HELP and SPAWN are used
     GetArgText(1, tmp_npccommand, 50);
 
     // Dont search for NPC ID when commands HELP and SPAWN are used
-    PNPC* targetNPC = NULL;
-    PNPCWorld* currentNPCWorld = NULL;
+    PNPC* targetNPC = nullptr;
+    PNPCWorld* currentNPCWorld = nullptr;
     if(strncmp(tmp_npccommand, "spawn", 5) != 0 && strncmp(tmp_npccommand, "help", 4) != 0)
     {
         currentNPCWorld = NPCManager->GetWorld( source->GetChar()->GetLocation() );
     if(strncmp(tmp_npccommand, "spawn", 5) != 0 && strncmp(tmp_npccommand, "help", 4) != 0)
     {
         currentNPCWorld = NPCManager->GetWorld( source->GetChar()->GetLocation() );
@@ -125,7 +125,7 @@ void PCommands::doNPC()
         /*-------------------------------------------------------*/
         // Get the highest NPC Id for current zone
         /*-------------------------------------------------------*/
         /*-------------------------------------------------------*/
         // Get the highest NPC Id for current zone
         /*-------------------------------------------------------*/
-        MYSQL_RES *result = NULL;
+        MYSQL_RES *result = nullptr;
         char tSql[100];
         snprintf(tSql, 100, "SELECT IFNULL(MAX(npc_worldid)+1,0) FROM npc_spawns WHERE npc_location = %d", tLocation);
         result = MySQL->GameResQuery(tSql);
         char tSql[100];
         snprintf(tSql, 100, "SELECT IFNULL(MAX(npc_worldid)+1,0) FROM npc_spawns WHERE npc_location = %d", tLocation);
         result = MySQL->GameResQuery(tSql);
index 3224da5..a3d919a 100644 (file)
@@ -35,7 +35,7 @@ void PCommands::doNPC_Shop()
         return;
     }
 
         return;
     }
 
-    PNPC* targetNPC = NULL;
+    PNPC* targetNPC = nullptr;
     PNPCWorld* currentNPCWorld = NPCManager->GetWorld( source->GetChar()->GetLocation() );
     if ( currentNPCWorld )
     {
     PNPCWorld* currentNPCWorld = NPCManager->GetWorld( source->GetChar()->GetLocation() );
     if ( currentNPCWorld )
     {
index f9a4751..3847619 100644 (file)
@@ -26,7 +26,7 @@ void PCommands::doCmdrecall()
     target = GetClientByNick( tmp_destNick );
   }
 
     target = GetClientByNick( tmp_destNick );
   }
 
-  if ( target == NULL ) // If victim isnt found, return error
+  if (target == nullptr) // If victim isnt found, return error
   {
     Chat->send( source, CHAT_DIRECT, "System", "No such player" );
     return;
   {
     Chat->send( source, CHAT_DIRECT, "System", "No such player" );
     return;
@@ -54,7 +54,7 @@ void PCommands::doCmdrecall()
   {
     PMessage* tmpMsg_zone = MsgBuilder->BuildAptLiftUseMsg( target, destZone, 0 );
     target->SendUDPMessage( tmpMsg_zone );
   {
     PMessage* tmpMsg_zone = MsgBuilder->BuildAptLiftUseMsg( target, destZone, 0 );
     target->SendUDPMessage( tmpMsg_zone );
-    tmpMsg_zone = NULL;
+    tmpMsg_zone = nullptr;
 
     uint16_t nNewX, nNewY, nNewZ;
     nNewX = source->GetChar()->Coords.mX;
 
     uint16_t nNewX, nNewY, nNewZ;
     nNewX = source->GetChar()->Coords.mX;
index e0a2a74..f30edbb 100644 (file)
@@ -35,7 +35,7 @@ void PCommands::doCmdsetlevel()
         target = GetClientByNick(tmp_destNick);
     }
 
         target = GetClientByNick(tmp_destNick);
     }
 
-    if (target == NULL) // If victim isnt found, return error
+    if (target == nullptr) // If victim isnt found, return error
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
index a778821..3c36783 100644 (file)
@@ -34,7 +34,7 @@ void PCommands::doCmdSetMainSkill()
         return;
     }
 
         return;
     }
 
-    PClient *temp_target = NULL;
+    PClient *temp_target = nullptr;
     if ( ArgC == 3 )
     {
         if (IsArgNumeric(3) == true)
     if ( ArgC == 3 )
     {
         if (IsArgNumeric(3) == true)
@@ -47,7 +47,7 @@ void PCommands::doCmdSetMainSkill()
             GetArgText(3, tmp_destNick, 50);
             temp_target = GetClientByNick(tmp_destNick);
         }
             GetArgText(3, tmp_destNick, 50);
             temp_target = GetClientByNick(tmp_destNick);
         }
-        if (temp_target == NULL)
+        if (temp_target == nullptr)
         {
             Chat->send(source, CHAT_DIRECT, "System", "No such player");
             return;
         {
             Chat->send(source, CHAT_DIRECT, "System", "No such player");
             return;
@@ -91,6 +91,6 @@ void PCommands::doCmdSetMainSkill()
     //PMessage* PMsgBuilder::BuildLevelUpMessage( PClient* nClient, uint8_t nMainSkill, uint8_t nNewLevel, uint16_t nFreeSkillPoints)
     PMessage* tmpMsg_setLv = MsgBuilder->BuildLevelUpMessage(temp_target, tMainSkill, tNewLevel, tNewSkillPoints);
     temp_target->SendUDPMessage(tmpMsg_setLv);
     //PMessage* PMsgBuilder::BuildLevelUpMessage( PClient* nClient, uint8_t nMainSkill, uint8_t nNewLevel, uint16_t nFreeSkillPoints)
     PMessage* tmpMsg_setLv = MsgBuilder->BuildLevelUpMessage(temp_target, tMainSkill, tNewLevel, tNewSkillPoints);
     temp_target->SendUDPMessage(tmpMsg_setLv);
-    tmpMsg_setLv = NULL;
-    temp_target = NULL;
+    tmpMsg_setLv = nullptr;
+    temp_target = nullptr;
 }
 }
index f42118c..2c32f77 100644 (file)
@@ -34,7 +34,7 @@ void PCommands::doCmdSetSubSkill()
         return;
     }
 
         return;
     }
 
-    PClient *temp_target = NULL;
+    PClient *temp_target = nullptr;
     if ( ArgC == 3 )
     {
         if (IsArgNumeric(3) == true)
     if ( ArgC == 3 )
     {
         if (IsArgNumeric(3) == true)
@@ -47,7 +47,7 @@ void PCommands::doCmdSetSubSkill()
             GetArgText(3, tmp_destNick, 50);
             temp_target = GetClientByNick(tmp_destNick);
         }
             GetArgText(3, tmp_destNick, 50);
             temp_target = GetClientByNick(tmp_destNick);
         }
-        if (temp_target == NULL)
+        if (temp_target == nullptr)
         {
             Chat->send(source, CHAT_DIRECT, "System", "No such player");
             return;
         {
             Chat->send(source, CHAT_DIRECT, "System", "No such player");
             return;
@@ -78,6 +78,6 @@ void PCommands::doCmdSetSubSkill()
     MAIN_SKILLS tMainSkill = temp_target->GetChar()->Skill->GetMSfromSS(tSubSkill);
     PMessage* tmpMsg_setSLv = MsgBuilder->BuildSubskillIncMsg(temp_target, tSubSkill, temp_target->GetChar()->Skill->GetSP(tMainSkill));
     temp_target->SendUDPMessage(tmpMsg_setSLv);
     MAIN_SKILLS tMainSkill = temp_target->GetChar()->Skill->GetMSfromSS(tSubSkill);
     PMessage* tmpMsg_setSLv = MsgBuilder->BuildSubskillIncMsg(temp_target, tSubSkill, temp_target->GetChar()->Skill->GetSP(tMainSkill));
     temp_target->SendUDPMessage(tmpMsg_setSLv);
-    tmpMsg_setSLv = NULL;
-    temp_target = NULL;
+    tmpMsg_setSLv = nullptr;
+    temp_target = nullptr;
 }
 }
index d1447d4..d1a7226 100644 (file)
@@ -25,7 +25,7 @@ void PCommands::doCmdshun()
         target = GetClientByNick(tmp_destNick);
     }
 
         target = GetClientByNick(tmp_destNick);
     }
 
-    if(target == NULL) // If victim isnt found, return error
+    if (target == nullptr) // If victim isnt found, return error
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
index 9d8407a..c74f765 100644 (file)
@@ -88,5 +88,5 @@ void PCommands::doCmdspawnactor()
     }
     //PMessage* tmpMsg = MsgBuilder->BuiltSpawnObjectMsg(source, tmpActorID, tmpFunctionID, mWOID++);
     //ClientManager->UDPBroadcast(tmpMsg, source);
     }
     //PMessage* tmpMsg = MsgBuilder->BuiltSpawnObjectMsg(source, tmpActorID, tmpFunctionID, mWOID++);
     //ClientManager->UDPBroadcast(tmpMsg, source);
-    //tmpMsg = NULL;
+    //tmpMsg = nullptr;
 }
 }
index 051b2fb..7d8d939 100644 (file)
@@ -8,7 +8,7 @@ void PCommands::doCmd_dev_t()
   const char* usage = "Usage: @t r <rawid> (to remove object) | @t d <rawid> [<v1=74> [<v2=29>]] (to send death packet to object with args v1 v2)";
   char tmpStr[128];
   const char* textMsg = usage;
   const char* usage = "Usage: @t r <rawid> (to remove object) | @t d <rawid> [<v1=74> [<v2=29>]] (to send death packet to object with args v1 v2)";
   char tmpStr[128];
   const char* textMsg = usage;
-  PMessage* tmpMsg = NULL;
+  PMessage* tmpMsg = nullptr;
   char Arg1[30];
 
   if ( IsAdmin() == false )
   char Arg1[30];
 
   if ( IsAdmin() == false )
@@ -70,7 +70,7 @@ void PCommands::doCmd_dev_t()
         //sleep(1);
         std::this_thread::sleep_for(std::chrono::seconds(1));
       }
         //sleep(1);
         std::this_thread::sleep_for(std::chrono::seconds(1));
       }
-      tmpMsg = NULL;
+      tmpMsg = nullptr;
     }
     else if ( Arg1[0] == 'd' )
     {
     }
     else if ( Arg1[0] == 'd' )
     {
@@ -123,7 +123,7 @@ void PCommands::doCmd_dev_t()
       textMsg = tmpStr;
 
       source->SendUDPMessage( tmpMsg );
       textMsg = tmpStr;
 
       source->SendUDPMessage( tmpMsg );
-      tmpMsg = NULL;
+      tmpMsg = nullptr;
     }
     else if ( Arg1[0] == 'e' )
     {
     }
     else if ( Arg1[0] == 'e' )
     {
@@ -162,7 +162,7 @@ void PCommands::doCmd_dev_t()
         textMsg = tmpStr;
 
         source->SendUDPMessage( tmpMsg );
         textMsg = tmpStr;
 
         source->SendUDPMessage( tmpMsg );
-        tmpMsg = NULL;
+        tmpMsg = nullptr;
     }
     else if ( Arg1[0] == 'w' )
     {
     }
     else if ( Arg1[0] == 'w' )
     {
@@ -192,7 +192,7 @@ void PCommands::doCmd_dev_t()
       textMsg = tmpStr;
 
       source->SendUDPMessage( tmpMsg );
       textMsg = tmpStr;
 
       source->SendUDPMessage( tmpMsg );
-      tmpMsg = NULL;
+      tmpMsg = nullptr;
     }
     else if ( Arg1[0] == 'x' )
     {
     }
     else if ( Arg1[0] == 'x' )
     {
@@ -204,7 +204,7 @@ void PCommands::doCmd_dev_t()
       textMsg = tmpStr;
 
       source->SendUDPMessage( tmpMsg );
       textMsg = tmpStr;
 
       source->SendUDPMessage( tmpMsg );
-      tmpMsg = NULL;
+      tmpMsg = nullptr;
     }
   }
 
     }
   }
 
@@ -238,7 +238,7 @@ void PCommands::doCmd_dev_t()
     uint32_t val1;
     uint8_t val2;
     char tmpStr[128];
     uint32_t val1;
     uint8_t val2;
     char tmpStr[128];
-    static PMessage* tmpMsg = NULL;
+    static PMessage* tmpMsg = nullptr;
     bool SetUDP_IDNeeded = true;
     PChar* nChar = source->GetChar();
     (nChar->Coords).mY += 20;
     bool SetUDP_IDNeeded = true;
     PChar* nChar = source->GetChar();
     (nChar->Coords).mY += 20;
index 0cd7968..01fdd8f 100644 (file)
@@ -38,7 +38,7 @@ void PCommands::doCmdtakemoney()
             GetArgText(2, tmp_destNick, 50);
             target = GetClientByNick(tmp_destNick);
         }
             GetArgText(2, tmp_destNick, 50);
             target = GetClientByNick(tmp_destNick);
         }
-        if(target == NULL)
+        if (target == nullptr)
         {
             Chat->send(source, CHAT_DIRECT, "System", "No such player");
             return;
         {
             Chat->send(source, CHAT_DIRECT, "System", "No such player");
             return;
@@ -62,7 +62,7 @@ void PCommands::doCmdtakemoney()
 
         PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(target, newcashvalue);
         target->SendUDPMessage(tmpMsg_cash);
 
         PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(target, newcashvalue);
         target->SendUDPMessage(tmpMsg_cash);
-        tmpMsg_cash = NULL;
+        tmpMsg_cash = nullptr;
 
         char tmpMsg_success[200];
         snprintf(tmpMsg_success, 199, "Stole %d NC from %s's wallet (Has now %d NC)", diffcash, target->GetChar()->GetName().c_str(), newcashvalue);
 
         char tmpMsg_success[200];
         snprintf(tmpMsg_success, 199, "Stole %d NC from %s's wallet (Has now %d NC)", diffcash, target->GetChar()->GetName().c_str(), newcashvalue);
@@ -79,6 +79,6 @@ void PCommands::doCmdtakemoney()
 
         PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(source, newcashvalue);
         source->SendUDPMessage(tmpMsg_cash);
 
         PMessage* tmpMsg_cash = MsgBuilder->BuildCharMoneyUpdateMsg(source, newcashvalue);
         source->SendUDPMessage(tmpMsg_cash);
-        tmpMsg_cash = NULL;
+        tmpMsg_cash = nullptr;
     }
 }
     }
 }
index 7e3eb64..ee53090 100644 (file)
@@ -31,7 +31,7 @@ void PCommands::doCmdteleport()
         target = GetClientByNick(tmp_destNick);
     }
 
         target = GetClientByNick(tmp_destNick);
     }
 
-    if(target == NULL) // If victim isnt found, return error
+    if (target == nullptr) // If victim isnt found, return error
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
@@ -63,7 +63,7 @@ void PCommands::doCmdteleport()
 
         PMessage* tmpMsg_zone = MsgBuilder->BuildAptLiftUseMsg (target, destZone, 0);
         target->SendUDPMessage(tmpMsg_zone);
 
         PMessage* tmpMsg_zone = MsgBuilder->BuildAptLiftUseMsg (target, destZone, 0);
         target->SendUDPMessage(tmpMsg_zone);
-        tmpMsg_zone = NULL;
+        tmpMsg_zone = nullptr;
 
         char tmpMsg_success[81];
         snprintf(tmpMsg_success, 80, "Successfully teleported %s to World %d", target->GetChar()->GetName().c_str(), destZone);
 
         char tmpMsg_success[81];
         snprintf(tmpMsg_success, 80, "Successfully teleported %s to World %d", target->GetChar()->GetName().c_str(), destZone);
index 8755110..f4bce41 100644 (file)
@@ -8,8 +8,8 @@ void PCommands::doCmdtest()
         if(ArgC < 5)
             return;
 
         if(ArgC < 5)
             return;
 
-        PNPC* targetNPC = NULL;
-        PNPCWorld* currentNPCWorld = NULL;
+        PNPC* targetNPC = nullptr;
+        PNPCWorld* currentNPCWorld = nullptr;
         currentNPCWorld = NPCManager->GetWorld( source->GetChar()->GetLocation() );
         if ( currentNPCWorld )
         {
         currentNPCWorld = NPCManager->GetWorld( source->GetChar()->GetLocation() );
         if ( currentNPCWorld )
         {
@@ -27,8 +27,8 @@ void PCommands::doCmdtest()
 
         int tF1 = GetArgInt(2);
         int tF2 = GetArgInt(3);
 
         int tF1 = GetArgInt(2);
         int tF2 = GetArgInt(3);
-        const PDefFaction* tFactionA = NULL;
-        const PDefFaction* tFactionB = NULL;
+        const PDefFaction* tFactionA = nullptr;
+        const PDefFaction* tFactionB = nullptr;
 
         if(tF1 > tF2)
         {
 
         if(tF1 > tF2)
         {
@@ -56,213 +56,4 @@ void PCommands::doCmdtest()
         else
             Chat->send(source, CHAT_DIRECT, "Relations", "Invalid faction");
     }
         else
             Chat->send(source, CHAT_DIRECT, "Relations", "Invalid faction");
     }
-
-
-
-
-
-
-    /*
-        uint8_t val1 = 0;
-        uint8_t val2 = 0;
-        uint8_t val3 = 0;
-        uint16_t val4 = 0;
-        uint16_t val5 = 0;
-    //    uint16_t val6 = 0;
-    //    uint8_t val7 = 0;
-
-        bool SyntaxError = false;
-        if(ArgC < 5)
-        {
-            SyntaxError = true;
-        }
-
-        if(IsArgNumeric(1) == false)
-            SyntaxError = true;
-        if(IsArgNumeric(2) == false)
-            SyntaxError = true;
-        if(IsArgNumeric(3) == false)
-            SyntaxError = true;
-        if(IsArgNumeric(4) == false)
-            SyntaxError = true;
-        if(IsArgNumeric(5) == false)
-            SyntaxError = true;
-    //    if(IsArgNumeric(6) == false)
-    //        SyntaxError = true;
-    //    if(IsArgNumeric(7) == false)
-    //        SyntaxError = true;
-
-        if(SyntaxError == true)
-        {
-            PMessage* tmpMsg1 = new PMessage(14);
-
-            *tmpMsg1 << (uint8_t)0x13;
-            *tmpMsg1 << (uint16_t)0x0000; // UDP ID placeholder
-            *tmpMsg1 << (uint16_t)0x0000; // SessionID placeholder
-            *tmpMsg1 << (uint8_t)0x08;    // Len (static, always 0x08
-            *tmpMsg1 << (uint8_t)0x03;
-            *tmpMsg1 << (uint16_t)0x0000; // Sub UDP ID placeholder
-            *tmpMsg1 << (uint8_t)0x26;    // Command FADE AWAY CHAR (kinda ^^)
-            *tmpMsg1 << (uint8_t)0x00;
-            *tmpMsg1 << (uint8_t)0x10;
-            *tmpMsg1 << (uint8_t)0x00;
-            *tmpMsg1 << (uint8_t)0x80;
-            ClientManager->UDPBroadcast(tmpMsg1, source);
-        }
-
-        val1 = (uint8_t)GetArgInt(1);
-        val2 = (uint8_t)GetArgInt(2);
-        val3 = (uint8_t)GetArgInt(3);
-        val4 = (uint16_t)GetArgInt(4);
-        val5 = (uint16_t)GetArgInt(5);
-    //    val7 = (uint16_t)GetArgInt(7);
-
-        //tmpMsg = MsgBuilder->BuildCharUseQBSlotMsg1(source, 59);
-        //source->SendUDPMessage(tmpMsg);
-        //tmpMsg = NULL;
-
-        PMessage* tmpMsg = new PMessage(29);
-        *tmpMsg << (uint8_t)0x13;
-       *tmpMsg << (uint16_t)0x0000;
-       *tmpMsg << (uint16_t)0x0000;
-       *tmpMsg << (uint8_t)0x16; // Message length
-       *tmpMsg << (uint8_t)0x03;
-       *tmpMsg << (uint16_t)0x0000;
-       *tmpMsg << (uint8_t)0x1b;
-       *tmpMsg << (uint8_t)0x00;
-       *tmpMsg << (uint8_t)0x10;
-       *tmpMsg << (uint8_t)0x00;
-       *tmpMsg << (uint8_t)0x80;
-       *tmpMsg << (uint8_t)0x19;
-       *tmpMsg << (uint8_t)0x55;
-       *tmpMsg << (uint8_t)0x74;
-       *tmpMsg << (uint8_t)0x80;
-       *tmpMsg << (uint8_t)0x82;
-       *tmpMsg << (uint8_t)0xc2;
-       *tmpMsg << (uint8_t)0x84;
-       *tmpMsg << (uint8_t)val1;
-       *tmpMsg << (uint8_t)val2;
-       *tmpMsg << (uint8_t)val3;
-       *tmpMsg << (uint16_t)val4;
-       *tmpMsg << (uint16_t)val5;
-    // *tmpMsg << (uint8_t)0x69;
-    // *tmpMsg << (uint8_t)0x00;
-
-        ClientManager->UDPBroadcast(tmpMsg, source);
-
-    // ***************************
-        bool SyntaxError = false;
-        if(ArgC < 1)
-        {
-            SyntaxError = true;
-        }
-
-        if(IsArgNumeric(1) == false)
-            SyntaxError = true;
-
-        if(SyntaxError == true)
-        {
-            Chat->send(source, CHAT_DIRECT, "Usage", "@test <id>");
-            return;
-        }
-
-        uint16_t itemID;
-        char effStr[128];
-        PMessage* tmpMsg;
-
-        itemID = (uint16_t)GetArgInt(1);
-
-        source->GetChar()->SetItemInHand(itemID);
-
-        tmpMsg = MsgBuilder->BuildCharHelloMsg(source);
-        ClientManager->UDPBroadcast(tmpMsg, source);
-        snprintf(effStr, 127, "Item in hand changes to value %d", itemID);
-        effStr[127] = '\0';
-        Chat->send(source, CHAT_DIRECT, "System", effStr);
-    ===========================================================================
-        uint16_t ItemToSpawn = 0;
-        uint8_t Quality = 0;
-        uint8_t Stack = 0;
-
-        bool SyntaxError = false;
-        if(ArgC < 3)
-        {
-            SyntaxError = true;
-        }
-        else
-        {
-            if(IsArgNumeric(1) == true)
-            {
-                ItemToSpawn = (uint16_t)GetArgInt(1);
-                if(ItemToSpawn == 0)
-                {
-                    SyntaxError = true;
-                }
-            }
-            else
-            {
-                SyntaxError = true;
-            }
-
-            if(IsArgNumeric(2) == true)
-            {
-                Quality = (uint8_t)GetArgInt(2);
-                if(Quality == 0)
-                {
-                    SyntaxError = true;
-                }
-            }
-            else
-            {
-                SyntaxError = true;
-            }
-
-            if(IsArgNumeric(3) == true)
-            {
-                Stack = (uint8_t)GetArgInt(3);
-                if(Stack == 0)
-                {
-                    SyntaxError = true;
-                }
-            }
-            else
-            {
-                SyntaxError = true;
-            }
-        }
-        if(SyntaxError == true)
-        {
-            Chat->send(source, CHAT_DIRECT, "Usage", "@test <itemID> <quality> <itemID>");
-            return;
-        }
-        PMessage* tmpMsg = new PMessage(29);
-        source->IncreaseUDP_ID();
-        source->IncreaseTransactionID();
-
-        *tmpMsg << (uint8_t)0x13;
-       *tmpMsg << (uint16_t)source->GetUDP_ID();
-       *tmpMsg << (uint16_t)source->GetSessionID();
-       *tmpMsg << (uint8_t)0x16; // Message length
-       *tmpMsg << (uint8_t)0x03;
-       *tmpMsg << (uint16_t)source->GetUDP_ID();
-       *tmpMsg << (uint8_t)0x1f;
-       *tmpMsg << (uint16_t)source->GetLocalID();
-       *tmpMsg << (uint8_t)0x25; // ??
-       *tmpMsg << (uint8_t)0x13; // ??
-        *tmpMsg << (uint16_t)source->GetTransactionID();
-       *tmpMsg << (uint8_t)0x18; // ??
-       *tmpMsg << (uint8_t)0x03; // ??
-       *tmpMsg << (uint8_t)0x01; // ??
-       *tmpMsg << (uint8_t)0x00; // ??
-       *tmpMsg << (uint8_t)0x05; // ??
-       *tmpMsg << (uint8_t)0x00; // ??
-       *tmpMsg << ItemToSpawn;
-       *tmpMsg << (uint8_t)0x02; // ??
-       *tmpMsg << (uint8_t)0x01; // ??
-       *tmpMsg << Quality;
-       *tmpMsg << Stack;
-
-
-        source->SendUDPMessage(tmpMsg);
-        */
 }
 }
index 18e4c95..535ec1f 100644 (file)
@@ -26,7 +26,7 @@ void PCommands::doCmdunjail()
     target = GetClientByNick( tmp_destNick );
   }
 
     target = GetClientByNick( tmp_destNick );
   }
 
-  if ( target == NULL ) // If victim isnt found, return error
+  if (target == nullptr) // If victim isnt found, return error
   {
     Chat->send( source, CHAT_DIRECT, "System", "No such player" );
     return;
   {
     Chat->send( source, CHAT_DIRECT, "System", "No such player" );
     return;
@@ -56,7 +56,7 @@ void PCommands::doCmdunjail()
   {
     PMessage* tmpMsg_zone = MsgBuilder->BuildAptLiftUseMsg( target, destZone, 0 );
     target->SendUDPMessage( tmpMsg_zone );
   {
     PMessage* tmpMsg_zone = MsgBuilder->BuildAptLiftUseMsg( target, destZone, 0 );
     target->SendUDPMessage( tmpMsg_zone );
-    tmpMsg_zone = NULL;
+    tmpMsg_zone = nullptr;
 
     char tmpMsg_success[81];
     snprintf( tmpMsg_success, 80, "Successfully unjailed %s", target->GetChar()->GetName().c_str() );
 
     char tmpMsg_success[81];
     snprintf( tmpMsg_success, 80, "Successfully unjailed %s", target->GetChar()->GetName().c_str() );
index aa6ec77..ab146ad 100644 (file)
@@ -25,7 +25,7 @@ void PCommands::doCmdunshun()
         target = GetClientByNick(tmp_destNick);
     }
 
         target = GetClientByNick(tmp_destNick);
     }
 
-    if(target == NULL) // If victim isnt found, return error
+    if (target == nullptr) // If victim isnt found, return error
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
     {
         Chat->send(source, CHAT_DIRECT, "System", "No such player");
         return;
index 479d036..557dc81 100644 (file)
@@ -1,10 +1,11 @@
 #include "GameServer/Includes.hxx"
 #include "GameServer/Includes.hxx"
+#include "Common/Includes.hxx"
 
 void PCommands::doCmduptime()
 {
     // get difference between var uptime and current time
     time_t Uptime = GameServer->GetStartTime();
 
 void PCommands::doCmduptime()
 {
     // get difference between var uptime and current time
     time_t Uptime = GameServer->GetStartTime();
-    uint32_t TimeDiff = std::time(NULL) - Uptime;
+    uint32_t TimeDiff = Time::nowTimeT() - Uptime;
     uint32_t UpYears = 0, UpMonths = 0, UpWeeks = 0, UpDays = 0, UpHours = 0, UpMinutes = 0, UpSeconds = 0;
     char tmpY[21], tmpM[21], tmpW[21], tmpD[21], tmpH[21], tmpMi[21], tmpS[21];
 
     uint32_t UpYears = 0, UpMonths = 0, UpWeeks = 0, UpDays = 0, UpHours = 0, UpMinutes = 0, UpSeconds = 0;
     char tmpY[21], tmpM[21], tmpW[21], tmpD[21], tmpH[21], tmpMi[21], tmpS[21];
 
index cc3e864..5da8a98 100644 (file)
@@ -26,7 +26,7 @@ void PCommands::doCmdwarpto()
     target = GetClientByNick( tmp_destNick );
   }
 
     target = GetClientByNick( tmp_destNick );
   }
 
-  if ( target == NULL ) // If victim isnt found, return error
+  if (target == nullptr) // If victim isnt found, return error
   {
     Chat->send( source, CHAT_DIRECT, "System", "No such player" );
     return;
   {
     Chat->send( source, CHAT_DIRECT, "System", "No such player" );
     return;
diff --git a/TinNS/Source/GameServer/GameScript.cxx b/TinNS/Source/GameServer/GameScript.cxx
deleted file mode 100644 (file)
index 6cd26e7..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "GameServer/Includes.hxx"
-#include "Common/Includes.hxx"
-
-#if 0
-PGameScript::PGameScript()
-{
-}
-
-PGameScript::~PGameScript()
-{
-    for(HookMap::iterator it = mHooks.begin(); it != mHooks.end(); it++)
-        delete it->second;
-}
-
-bool PGameScript::LoadScripts()
-{
-}
-
-bool PGameScript::Rehash()
-{
-    Console->LPrint("Rehashing GameMonkey Scripts...");
-    for(HookMap::iterator it = mHooks.end(); it != mHooks.begin(); it--)
-        mHooks.erase(it);
-
-    if(LoadScripts() == true)
-    {
-        Console->LPrint(GREEN, BLACK, "Done");
-        Console->LClose();
-        return true;
-    }
-    else
-    {
-        Console->LPrint(RED, BLACK, "Failed");
-        Console->LClose();
-        return false;
-    }
-}
-
-void PGameScript::TriggerHook(PHookTypes hook)
-{
-}
-
-
-bool PGameScript::ExecuteFile(const char* a_fileName)
-{
-  FILE* scriptFile = NULL;
-  char* fileString = NULL;
-  int fileSize = 0;
-
-  GM_ASSERT(m_machine);
-
-  if( !(scriptFile = fopen(a_fileName, "rb")) )
-  {
-    return false;
-  }
-
-  fseek(scriptFile, 0, SEEK_END);
-  fileSize = ftell(scriptFile);
-  fseek(scriptFile, 0, SEEK_SET);
-  fileString = new char [fileSize+1];
-  fread(fileString, fileSize, 1, scriptFile);
-  fileString[fileSize] = 0; // Terminating null
-  fclose(scriptFile);
-
-  int threadId = GM_INVALID_THREAD;
-  int errors = m_machine->ExecuteString(fileString, &threadId, true, a_fileName);
-  if(errors)
-  {
-    LogAnyMachineErrorMessages();
-  }
-
-  delete [] fileString;
-
-  return true;
-}
-
-
-int GM_CDECL PGameScript::AddHook(gmThread *a_thread)
-{
-    GM_CHECK_NUM_PARAMS(2);
-    GM_CHECK_STRING_PARAM(tmphooktype, 0);
-    GM_CHECK_STRING_PARAM(tmpfunction, 1);
-
-    mHooks.insert(std::make_pair(tmphooktype, tmpfunction));
-
-    return GM_OK;
-}
-
-int PGameScript::AddTwoIntegers(int valueA, int valueB)
-{
-  int resultInt = 0;
-
-  gmCall call;
-
-  if(call.BeginGlobalFunction(&machine, "Add"))
-  {
-    call.AddParamInt(valueA);
-    call.AddParamInt(valueB);
-    call.End();
-    call.GetReturnedInt(resultInt);
-  }
-
-  return resultInt;
-}
-#endif
diff --git a/TinNS/Source/GameServer/GameScript.hxx b/TinNS/Source/GameServer/GameScript.hxx
deleted file mode 100644 (file)
index 89831b9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#if 0
-#include <map>
-#include <string>
-
-enum PHookTypes {
-    HOOK_CHAT,
-    HOOK_TRADE,
-    HOOK_ZONE
-};
-
-class PGameScript {
-private:
-    typedef std::map<PHookTypes, std::string> HookMap;
-    HookMap mHooks;
-
-public:
-    PGameScript();
-    ~PGameScript();
-
-    bool LoadScripts();
-    bool Rehash();
-    void TriggerHook(PHookTypes hook);
-    bool ExecuteFile(const char* a_fileName);
-};
-#endif
index 73ce9a4..68fe455 100644 (file)
@@ -14,7 +14,7 @@
 
 PGameServer::PGameServer()
 {
 
 PGameServer::PGameServer()
 {
-  mServerStartupTime = std::time( NULL );
+  mServerStartupTime = Time::nowTimeT();
   mNumClients = 0;
   MsgDecoder = new PUdpMsgDecoder();
 }
   mNumClients = 0;
   MsgDecoder = new PUdpMsgDecoder();
 }
@@ -566,7 +566,7 @@ bool PGameServer::HandleCharList( PClient *Client, PGameState *State, const uint
           uint32_t CharID = Acc.GetCharIdBySlot( Num );
 
           // Also check that char is out of game
           uint32_t CharID = Acc.GetCharIdBySlot( Num );
 
           // Also check that char is out of game
-          if (( CharID != 0 ) && ( Chars->GetChar( CharID ) == NULL ) )
+          if ((CharID != 0) && (Chars->GetChar(CharID) == nullptr))
           {
             char query[100];
             snprintf( query, 100, "DELETE FROM characters WHERE c_id = %d LIMIT 1", CharID );
           {
             char query[100];
             snprintf( query, 100, "DELETE FROM characters WHERE c_id = %d LIMIT 1", CharID );
@@ -965,7 +965,7 @@ PGameState* PGameServer::GetClientState( PClient* nClient )
   GameStateMap::iterator node = ClientStates.find( nClient );
 
   if ( node == ClientStates.end() )
   GameStateMap::iterator node = ClientStates.find( nClient );
 
   if ( node == ClientStates.end() )
-    return NULL;
+    return nullptr;
   else
     return node->second;
 }
   else
     return node->second;
 }
index 85cb220..ffe6732 100644 (file)
@@ -6,7 +6,7 @@ PGenrepList::PGenrepList(uint32_t nOwnerCharID)
 {
     mOwnerCharID = nOwnerCharID;
     mListMaxSize = mListSize = 0;
 {
     mOwnerCharID = nOwnerCharID;
     mListMaxSize = mListSize = 0;
-    mGenrepList = NULL;
+    mGenrepList = nullptr;
 }
 
 PGenrepList::~PGenrepList()
 }
 
 PGenrepList::~PGenrepList()
@@ -82,7 +82,7 @@ bool PGenrepList::SQLLoad()
 
     snprintf(query, 256, "SELECT * FROM genrep WHERE (g_charid='%u')", mOwnerCharID);
     result = MySQL->GameResQuery(query);
 
     snprintf(query, 256, "SELECT * FROM genrep WHERE (g_charid='%u')", mOwnerCharID);
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PGenrepList::SQLLoad could not load genreplist from the database");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PGenrepList::SQLLoad could not load genreplist from the database");
         Console->Print("Query was:");
index 18cc26d..5fdb081 100644 (file)
@@ -12,7 +12,6 @@
 #include "GameServer/Container.hxx"
 #include "GameServer/DoorTemplate.hxx"
 #include "GameServer/FurnitureTemplate.hxx"
 #include "GameServer/Container.hxx"
 #include "GameServer/DoorTemplate.hxx"
 #include "GameServer/FurnitureTemplate.hxx"
-#include "GameServer/GameScript.hxx"
 #include "GameServer/GameServer.hxx"
 #include "GameServer/GenrepList.hxx"
 #include "GameServer/Inventory.hxx"
 #include "GameServer/GameServer.hxx"
 #include "GameServer/GenrepList.hxx"
 #include "GameServer/Inventory.hxx"
index 5d82f13..2c43217 100644 (file)
@@ -65,7 +65,7 @@ PContainer* PInventory::GetContainer(uint8_t nInvLoc)
       tContainer = mGogo;
       break;
     default:
       tContainer = mGogo;
       break;
     default:
-      tContainer = NULL;
+      tContainer = nullptr;
   }
   return tContainer;
 }
   }
   return tContainer;
 }
index 5115e79..27ca239 100644 (file)
@@ -118,7 +118,7 @@ void PISC::Start_mysql()
 void PISC::Update_mysql()
 {
   bool do_update = false;
 void PISC::Update_mysql()
 {
   bool do_update = false;
-  std::time_t t = std::time(NULL);
+  time_t t = Time::nowTimeT();
   int client_count = Server->GetNumClients();
 
   if (((t - mysql_last_update_time) >= mysql_update_intervall) || (client_count > mysql_last_client_count))
   int client_count = Server->GetNumClients();
 
   if (((t - mysql_last_update_time) >= mysql_update_intervall) || (client_count > mysql_last_client_count))
@@ -150,7 +150,7 @@ void PISC::Update_mysql()
     do_mysql_db_update(client_count);
     mysql_last_client_count = client_count;
     mysql_last_count_decrease_time = 0;
     do_mysql_db_update(client_count);
     mysql_last_client_count = client_count;
     mysql_last_count_decrease_time = 0;
-    mysql_last_update_time = std::time(NULL);
+    mysql_last_update_time = Time::nowTimeT();
   }
 }
 
   }
 }
 
index bbce3c3..6b14881 100644 (file)
@@ -19,7 +19,7 @@
 int npcscript_callback(lua_State *nLua)
 {
     PClient* tClient = LuaEngine->GetBoundClient();
 int npcscript_callback(lua_State *nLua)
 {
     PClient* tClient = LuaEngine->GetBoundClient();
-    if(tClient == NULL)
+    if (tClient == nullptr)
     {
         Console->Print("%s [npcscript_callback] No client is set, unable to process actions!", Console->ColorText(RED, BLACK, "[Error]"));
         return 0;
     {
         Console->Print("%s [npcscript_callback] No client is set, unable to process actions!", Console->ColorText(RED, BLACK, "[Error]"));
         return 0;
@@ -209,7 +209,7 @@ void PLuaEngine::ProcessDialogScript(PClient* nClient, std::string nLUAFile, int
     }
 
     // Cleanup everything
     }
 
     // Cleanup everything
-    mTargetClient = NULL;
+    mTargetClient = nullptr;
     CleanUp();
 }
 
     CleanUp();
 }
 
@@ -256,7 +256,7 @@ PLuaEngine::~PLuaEngine()
 bool PLuaEngine::ExecuteScript(std::string nLUAScript, int nNode, int nDialogClass)
 {
     // Make sure we have an bound client to work with
 bool PLuaEngine::ExecuteScript(std::string nLUAScript, int nNode, int nDialogClass)
 {
     // Make sure we have an bound client to work with
-    if(mTargetClient == NULL)
+    if (mTargetClient == nullptr)
     {
         Console->Print("%s [PLuaEngine::ExecuteScript] No Client has been bound. Cannot run lua script", Console->ColorText(RED, BLACK, "[Error]"));
         return false;
     {
         Console->Print("%s [PLuaEngine::ExecuteScript] No Client has been bound. Cannot run lua script", Console->ColorText(RED, BLACK, "[Error]"));
         return false;
index a3b23f7..c9f1ff3 100644 (file)
@@ -125,7 +125,7 @@ void PMultiPart::Update()
         }
 
         // Check if sequence is timed out
         }
 
         // Check if sequence is timed out
-        if(i->second.smTimeStamp + MAX_SEQUENCE_LIFE < time(NULL))
+        if(i->second.smTimeStamp + MAX_SEQUENCE_LIFE < Time::nowTimeT())
         {
             if (gDevDebug) Console->Print("[PMultiPart::Update] Sequence number %d timed out. Deleting...", i->first);
             MsgMap.erase(i);
         {
             if (gDevDebug) Console->Print("[PMultiPart::Update] Sequence number %d timed out. Deleting...", i->first);
             MsgMap.erase(i);
@@ -150,7 +150,7 @@ void PMultiPart::AddMultiPartChunk(PClient *nClient, PMessage *nChunk, uint16_t
         // And push it into the vector
         it->second.smvChunk.push_back(tChunk);
         // Update lifetimer
         // And push it into the vector
         it->second.smvChunk.push_back(tChunk);
         // Update lifetimer
-        it->second.smTimeStamp = time(NULL);
+        it->second.smTimeStamp = Time::nowTimeT();
     }
     else
     {
     }
     else
     {
@@ -164,7 +164,7 @@ void PMultiPart::AddMultiPartChunk(PClient *nClient, PMessage *nChunk, uint16_t
         // Push our temp chunk into the vector
         tSeq.smvChunk.push_back(tChunk);
         // Add current timestamp
         // Push our temp chunk into the vector
         tSeq.smvChunk.push_back(tChunk);
         // Add current timestamp
-        tSeq.smTimeStamp = time(NULL);
+        tSeq.smTimeStamp = Time::nowTimeT();
         // Set chunktotal
         tSeq.smChunkTotal = nChunkTotal;
         // Store client
         // Set chunktotal
         tSeq.smChunkTotal = nChunkTotal;
         // Store client
index b08c947..b16b8b4 100644 (file)
@@ -6,7 +6,7 @@
 
 void PNPC::PushUpdateTimer()
 {
 
 void PNPC::PushUpdateTimer()
 {
-    mNextUpdate = std::time(nullptr) + GetRandom(NPC_HEARTBEAT_MAX, NPC_HEARTBEAT_MIN);
+    mNextUpdate = Time::nowTimeT() + GetRandom(NPC_HEARTBEAT_MAX, NPC_HEARTBEAT_MIN);
 };
 
 // Reload LUA script while running, in case we modified it and dont want to restart the entire server
 };
 
 // Reload LUA script while running, in case we modified it and dont want to restart the entire server
@@ -69,14 +69,14 @@ bool PNPC::DEF_Load(uint32_t nWorldID)
 bool PNPC::SQL_Load()
 {
     if ( gDevDebug ) Console->Print( "[DEBUG] Now loading NPC data for NPC id %d from SQL", mID );
 bool PNPC::SQL_Load()
 {
     if ( gDevDebug ) Console->Print( "[DEBUG] Now loading NPC data for NPC id %d from SQL", mID );
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_spawns` WHERE `npc_id` = %d", mID );
     if ( gDevDebug ) Console->Print( "[DEBUG] Executing query %s", query );
     result = MySQL->GameResQuery( query );
     MYSQL_ROW row;
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_spawns` WHERE `npc_id` = %d", mID );
     if ( gDevDebug ) Console->Print( "[DEBUG] Executing query %s", query );
     result = MySQL->GameResQuery( query );
-    if ( result == NULL )
+    if (result == nullptr)
     {
         Console->Print( RED, BLACK, "PNPC::SQL_Load could not load NPC definition" );
         Console->Print( "Query was:" );
     {
         Console->Print( RED, BLACK, "PNPC::SQL_Load could not load NPC definition" );
         Console->Print( "Query was:" );
@@ -117,13 +117,13 @@ bool PNPC::SQL_Load()
     else
         mScripting = false;
 
     else
         mScripting = false;
 
-    if ( row[npc_name] != NULL )
+    if (row[npc_name] != nullptr)
         mName = row[npc_name];
 
         mName = row[npc_name];
 
-    if ( row[npc_customname] != NULL )
+    if (row[npc_customname] != nullptr)
         mCustomName = row[npc_customname];
 
         mCustomName = row[npc_customname];
 
-    if ( row[npc_customscript] != NULL )
+    if (row[npc_customscript] != nullptr)
         mCustomLua = row[npc_customscript];
 
     // Now make sure we have an valid NPC here. Besides we need some more information
         mCustomLua = row[npc_customscript];
 
     // Now make sure we have an valid NPC here. Besides we need some more information
@@ -172,7 +172,7 @@ bool PNPC::SQL_Load()
 bool PNPC::LoadLUAScript()
 {
     uint32_t tFileLen = 0;
 bool PNPC::LoadLUAScript()
 {
     uint32_t tFileLen = 0;
-    PFile* fLua = NULL;
+    PFile* fLua = nullptr;
     std::string tLuaFile = "";
     std::string tHDRFile = "";
 
     std::string tLuaFile = "";
     std::string tHDRFile = "";
 
@@ -185,7 +185,7 @@ bool PNPC::LoadLUAScript()
     if(mDialogScript.length() > 1)
     {
         // Get LUA filename from defs
     if(mDialogScript.length() > 1)
     {
         // Get LUA filename from defs
-        const PDefScripts* tDefScripts = NULL;
+        const PDefScripts* tDefScripts = nullptr;
         std::map<int, PDefScripts*>::const_iterator itScrStart = GameDefs->Scripts()->ConstIteratorBegin();
         std::map<int, PDefScripts*>::const_iterator itScrEnd = GameDefs->Scripts()->ConstIteratorEnd();
         for ( std::map<int, PDefScripts*>::const_iterator i = itScrStart; i != itScrEnd; i++ )
         std::map<int, PDefScripts*>::const_iterator itScrStart = GameDefs->Scripts()->ConstIteratorBegin();
         std::map<int, PDefScripts*>::const_iterator itScrEnd = GameDefs->Scripts()->ConstIteratorEnd();
         for ( std::map<int, PDefScripts*>::const_iterator i = itScrStart; i != itScrEnd; i++ )
@@ -259,7 +259,7 @@ bool PNPC::LoadLUAScript()
 
     // Reset vars
     tFileLen = 0;
 
     // Reset vars
     tFileLen = 0;
-    fLua = NULL;
+    fLua = nullptr;
 
     fLua = Filesystem->Open( "", tLuaFile.c_str(), Config->GetOption( "nc_data_path" ) );
     if(fLua)
 
     fLua = Filesystem->Open( "", tLuaFile.c_str(), Config->GetOption( "nc_data_path" ) );
     if(fLua)
@@ -305,14 +305,14 @@ bool PNPC::LoadLUAScript()
     if ( gDevDebug ) Console->Print( "[DEBUG] NPC dying now" );
     mHealth = 0;
     mAction = NPC_ACTIONSTATE_DEATH;
     if ( gDevDebug ) Console->Print( "[DEBUG] NPC dying now" );
     mHealth = 0;
     mAction = NPC_ACTIONSTATE_DEATH;
-    mRespawn = std::time( NULL ) + NPC_RESPAWN_AFTER;
+    mRespawn = Time::nowTimeT() + NPC_RESPAWN_AFTER;
     mDirty = true;
  }
 
  void PNPC::Update()
 {
     // Has to be changed for mobs later
     mDirty = true;
  }
 
  void PNPC::Update()
 {
     // Has to be changed for mobs later
-    if ( std::time( NULL ) >= mRespawn && (mAction&NPC_ACTIONSTATE_DEATH) )
+    if (Time::nowTimeT() >= mRespawn && (mAction&NPC_ACTIONSTATE_DEATH))
     {
         if ( gDevDebug ) Console->Print( "[DEBUG] NPC Update: Respawn timer triggered! Setting NPC back to life" );
         mHealth = mMaxHealth;
     {
         if ( gDevDebug ) Console->Print( "[DEBUG] NPC Update: Respawn timer triggered! Setting NPC back to life" );
         mHealth = mMaxHealth;
@@ -355,7 +355,7 @@ void PNPC::InitVars()
     // Set next update timer for this NPC to 10 - 30 seconds
     // Note: this is for regular heartbeats only. If npc is dirty,
     // an update is sent anyway
     // Set next update timer for this NPC to 10 - 30 seconds
     // Note: this is for regular heartbeats only. If npc is dirty,
     // an update is sent anyway
-    mNextUpdate = std::time(NULL) + GetRandom(30, 10);
+    mNextUpdate = Time::nowTimeT() + GetRandom(30, 10);
  }
 
 void PNPC::Attack( uint32_t nWorldID, uint8_t nType, uint8_t nUnknown )
  }
 
 void PNPC::Attack( uint32_t nWorldID, uint8_t nType, uint8_t nUnknown )
@@ -429,7 +429,7 @@ bool PNPCWorld::AddNPC(uint32_t nSQL_ID, uint32_t nRaw_ID)
         // Now broadcast the new NPC to all clients
         BroadcastNewNPC(tmpNpc);
         mNPCs.insert( std::make_pair( nRaw_ID, tmpNpc ) );
         // Now broadcast the new NPC to all clients
         BroadcastNewNPC(tmpNpc);
         mNPCs.insert( std::make_pair( nRaw_ID, tmpNpc ) );
-        tmpNpc = NULL;
+        tmpNpc = nullptr;
         if ( gDevDebug ) Console->Print( "[PNPCWorld::AddNPC] Custom NPC added" );
     }
     else
         if ( gDevDebug ) Console->Print( "[PNPCWorld::AddNPC] Custom NPC added" );
     }
     else
@@ -471,7 +471,7 @@ void PNPCWorld::SendSingleNPCInfo( PClient* nClient, PNPC* nNpc )
 
  void PNPCWorld::MSG_SendNPCs( PClient* nClient )
 {
 
  void PNPCWorld::MSG_SendNPCs( PClient* nClient )
 {
-    PNPC* nNpc = NULL;
+    PNPC* nNpc = nullptr;
     for ( PNPCMap::iterator it = mNPCs.begin(); it != mNPCs.end(); it++ )
     {
         nNpc = it->second;
     for ( PNPCMap::iterator it = mNPCs.begin(); it != mNPCs.end(); it++ )
     {
         nNpc = it->second;
@@ -490,14 +490,14 @@ void PNPCWorld::SendSingleNPCInfo( PClient* nClient, PNPC* nNpc )
 bool PNPCWorld::LoadNPCfromSQL()
  {
 // Load NPC defs from MySQL
 bool PNPCWorld::LoadNPCfromSQL()
  {
 // Load NPC defs from MySQL
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_spawns` WHERE `npc_location` = %d", mWorldID );
 //if(gDevDebug) Console->Print("[DEBUG] Query is: %s", query);
     result = MySQL->GameResQuery( query );
     MYSQL_ROW row;
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_spawns` WHERE `npc_location` = %d", mWorldID );
 //if(gDevDebug) Console->Print("[DEBUG] Query is: %s", query);
     result = MySQL->GameResQuery( query );
-    if ( result == NULL )
+    if (result == nullptr)
      {
         Console->Print( RED, BLACK, "PNPCWorld::PNPCWorld could not load NPC definition" );
         Console->Print( "Query was:" );
      {
         Console->Print( RED, BLACK, "PNPCWorld::PNPCWorld could not load NPC definition" );
         Console->Print( "Query was:" );
@@ -512,7 +512,7 @@ bool PNPCWorld::LoadNPCfromSQL()
         return true;
      }
 //if(gDevDebug) Console->Print("[DEBUG] Found NPCs, now adding!");
         return true;
      }
 //if(gDevDebug) Console->Print("[DEBUG] Found NPCs, now adding!");
-    PNPC* tmpNpc = NULL;
+    PNPC* tmpNpc = nullptr;
     uint32_t tRawID = 0;
     int tSQLID = 0;
     while (( row = mysql_fetch_row( result ) ) )
     uint32_t tRawID = 0;
     int tSQLID = 0;
     while (( row = mysql_fetch_row( result ) ) )
@@ -524,7 +524,7 @@ bool PNPCWorld::LoadNPCfromSQL()
         {
             //if(gDevDebug) Console->Print("[DEBUG] NPC init successfull, adding to list");
             mNPCs.insert( std::make_pair( tRawID, tmpNpc ) );
         {
             //if(gDevDebug) Console->Print("[DEBUG] NPC init successfull, adding to list");
             mNPCs.insert( std::make_pair( tRawID, tmpNpc ) );
-            tmpNpc = NULL;
+            tmpNpc = nullptr;
         }
         else
         {
         }
         else
         {
@@ -541,7 +541,7 @@ bool PNPCWorld::LoadNPCfromDEF()
  {
     const PNPCsMap* tNPCmap = Worlds->GetWorld(mWorldID)->GetNPCMap(); // Get the NPC Map for this world
 
  {
     const PNPCsMap* tNPCmap = Worlds->GetWorld(mWorldID)->GetNPCMap(); // Get the NPC Map for this world
 
-    PNPC* tmpNpc = NULL;
+    PNPC* tmpNpc = nullptr;
     uint32_t tDEFID = 0;
 
     for ( PNPCsMap::const_iterator i = tNPCmap->begin(); i != tNPCmap->end(); i++ )
     uint32_t tDEFID = 0;
 
     for ( PNPCsMap::const_iterator i = tNPCmap->begin(); i != tNPCmap->end(); i++ )
@@ -552,7 +552,7 @@ bool PNPCWorld::LoadNPCfromDEF()
         if ( tmpNpc->mSuccess == true )
          {
             mNPCs.insert( std::make_pair( tDEFID, tmpNpc ) );
         if ( tmpNpc->mSuccess == true )
          {
             mNPCs.insert( std::make_pair( tDEFID, tmpNpc ) );
-            tmpNpc = NULL;
+            tmpNpc = nullptr;
          }
          else
          {
          }
          else
          {
@@ -568,7 +568,7 @@ bool PNPCWorld::LoadNPCfromDEF()
 //if(gDevDebug) Console->Print("[DEBUG] New world got initialized! Now starting to add NPCs. (WorldID %d)", nWorldID);
 
 // Assign WorldValues now
 //if(gDevDebug) Console->Print("[DEBUG] New world got initialized! Now starting to add NPCs. (WorldID %d)", nWorldID);
 
 // Assign WorldValues now
-    mCreation = std::time( NULL );
+    mCreation = Time::nowTimeT();
     mWorldID = nWorldID;
     mLastAliveMsg = 0;
     LoadNPCfromSQL();
     mWorldID = nWorldID;
     mLastAliveMsg = 0;
     LoadNPCfromSQL();
@@ -591,8 +591,8 @@ void PNPCWorld::Update() // v2; New send function
     // Updates NPC in a World.
     // If NPC is dirty, send "large" update. Else
     // send small "i'm alive" message
     // Updates NPC in a World.
     // If NPC is dirty, send "large" update. Else
     // send small "i'm alive" message
-    std::time_t tNow = std::time(NULL);
-    PNPC* tNPC = NULL;
+    time_t tNow = Time::nowTimeT();
+    PNPC* tNPC = nullptr;
     for ( PNPCMap::iterator it = mNPCs.begin(); it != mNPCs.end(); it++ )
     {
         if ( it->second )
     for ( PNPCMap::iterator it = mNPCs.begin(); it != mNPCs.end(); it++ )
     {
         if ( it->second )
@@ -625,54 +625,12 @@ void PNPCWorld::Update() // v2; New send function
     return;
  }
 
     return;
  }
 
-/*
-void PNPCWorld::Update()
-{
-    // Updates NPC in a World.
-    // If NPC is dirty, send "large" update. Else
-    // send small "i'm alive" message
-    std::time_t tNow = std::time(NULL);
-    PNPC* tNPC = NULL;
-    for ( PNPCMap::iterator it = mNPCs.begin(); it != mNPCs.end(); it++ )
-    {
-        if ( it->second )
-        {
-            tNPC = it->second;
-            // Check for enemies nearby
-            CheckForEnemies(tNPC);
-            // Let NPC make themselfs "dirty"
-            tNPC->Update();
-            // Only update dirty npcs
-            if ( tNPC->mDirty == true )
-            {
-                PMessage* tmpMsg = MsgBuilder->BuildNPCMassUpdateMsg( tNPC->GetRealWorldID(), tNPC->mPosX, tNPC->mPosY,
-                                                                     tNPC->mPosZ, tNPC->GetActionStatus(), tNPC->mHealth, tNPC->mTarget, tNPC->mAction);
-
-                ClientManager->UDPBroadcast( tmpMsg, mWorldID );
-                tNPC->mDirty = false;
-                // Large update also counts as small one, inc update counter
-                tNPC->PushUpdateTimer();
-            }
-            else if(tNPC->mNextUpdate <= tNow)
-            {
-                PMessage* tmpMsg = MsgBuilder->BuildNPCMassAliveMsg( tNPC->GetRealWorldID(), tNPC->mPosX, tNPC->mPosY,
-                                                                     tNPC->mPosZ, tNPC->GetActionStatus(), tNPC->mHealth, tNPC->mAction);
-
-                ClientManager->UDPBroadcast( tmpMsg, mWorldID );
-                tNPC->PushUpdateTimer();
-            }
-        }
-    }
-
-    return;
-}
-*/
  PNPC* PNPCWorld::GetNPC( uint32_t nNPCID )
  {
     if ( gDevDebug ) Console->Print( "[DEBUG] Searching for NPC %d in list", nNPCID );
     PNPCMap::const_iterator it = mNPCs.find( nNPCID );
     if ( it == mNPCs.end() ) // only if client not found in list
  PNPC* PNPCWorld::GetNPC( uint32_t nNPCID )
  {
     if ( gDevDebug ) Console->Print( "[DEBUG] Searching for NPC %d in list", nNPCID );
     PNPCMap::const_iterator it = mNPCs.find( nNPCID );
     if ( it == mNPCs.end() ) // only if client not found in list
-        return NULL;
+        return nullptr;
     else
         return it->second;
  }
     else
         return it->second;
  }
@@ -704,7 +662,7 @@ void PNPCWorld::Update()
 // Search worldmanager for this zone
     PNPCWorld* tmpWorld = GetWorld( nZone );
 
 // Search worldmanager for this zone
     PNPCWorld* tmpWorld = GetWorld( nZone );
 
-    if ( tmpWorld != NULL )
+    if (tmpWorld != nullptr)
      {
         if ( gDevDebug ) Console->Print( "[DEBUG] World found, poking MSG_SendNPCs" );
 // World found? Fine. Then poke the class to send its content to the client
      {
         if ( gDevDebug ) Console->Print( "[DEBUG] World found, poking MSG_SendNPCs" );
 // World found? Fine. Then poke the class to send its content to the client
@@ -715,7 +673,7 @@ void PNPCWorld::Update()
         if ( gDevDebug ) Console->Print( "[DEBUG] World not found, creating...." );
 // World not found! OMG! Create it!
         tmpWorld = InitWorld( nZone );
         if ( gDevDebug ) Console->Print( "[DEBUG] World not found, creating...." );
 // World not found! OMG! Create it!
         tmpWorld = InitWorld( nZone );
-        if ( tmpWorld == NULL )
+        if (tmpWorld == nullptr)
         {
             Console->Print( "%s Unable to init NPCs for world %d", Console->ColorText( RED, BLACK, "[ERROR]" ), nZone );
             return;
         {
             Console->Print( "%s Unable to init NPCs for world %d", Console->ColorText( RED, BLACK, "[ERROR]" ), nZone );
             return;
@@ -730,9 +688,9 @@ void PNPCWorld::Update()
  PNPCWorld* PNPCManager::InitWorld( uint32_t nWorldID )
  {
     if ( gDevDebug ) Console->Print( "[DEBUG] InitWorld triggered: ID %d", nWorldID );
  PNPCWorld* PNPCManager::InitWorld( uint32_t nWorldID )
  {
     if ( gDevDebug ) Console->Print( "[DEBUG] InitWorld triggered: ID %d", nWorldID );
-    PNPCWorld* tmpWorld = NULL;
+    PNPCWorld* tmpWorld = nullptr;
     tmpWorld = new PNPCWorld( nWorldID );
     tmpWorld = new PNPCWorld( nWorldID );
-    if ( tmpWorld != NULL )
+    if (tmpWorld != nullptr)
     {
         if ( gDevDebug ) Console->Print( "[DEBUG] World created. Adding to list..." );
         mWorlds.insert( std::make_pair( nWorldID, tmpWorld ) );
     {
         if ( gDevDebug ) Console->Print( "[DEBUG] World created. Adding to list..." );
         mWorlds.insert( std::make_pair( nWorldID, tmpWorld ) );
@@ -742,15 +700,15 @@ void PNPCWorld::Update()
     else
     {
         if ( gDevDebug ) Console->Print( "[DEBUG] Failed to init world. Returning NULL" );
     else
     {
         if ( gDevDebug ) Console->Print( "[DEBUG] Failed to init world. Returning NULL" );
-        return NULL;
+        return nullptr;
     }
  }
 
  void PNPCManager::Update()
  {
     }
  }
 
  void PNPCManager::Update()
  {
-    static std::time_t lastdebug = std::time( NULL );
+    static time_t lastdebug = Time::nowTimeT();
 // Loop all worlds
 // Loop all worlds
- //    if(lastdebug < std::time(NULL))
+ //    if(lastdebug < Time::nowTimeT())
  //        if(gDevDebug) Console->Print("[DEBUG] WorldLoop still running...");
 
     for ( PNPCWorldMap::iterator it = mWorlds.begin(); it != mWorlds.end(); it++ )
  //        if(gDevDebug) Console->Print("[DEBUG] WorldLoop still running...");
 
     for ( PNPCWorldMap::iterator it = mWorlds.begin(); it != mWorlds.end(); it++ )
@@ -762,18 +720,18 @@ void PNPCWorld::Update()
             PNPCWorld* tWorld = it->second;
             if ( ClientManager->IsWorldInUse( tWorld->mWorldID ) == true )
             {
             PNPCWorld* tWorld = it->second;
             if ( ClientManager->IsWorldInUse( tWorld->mWorldID ) == true )
             {
-                //if(lastdebug < std::time(NULL))
+                //if(lastdebug < Time::nowTimeT())
                 //    if(gDevDebug) Console->Print("[DEBUG] World is in use, poking management class to update itself");
                 // World is in use. Now send "dirty" npcs or alive messages
                 tWorld->Update();
             }
             else
             {
                 //    if(gDevDebug) Console->Print("[DEBUG] World is in use, poking management class to update itself");
                 // World is in use. Now send "dirty" npcs or alive messages
                 tWorld->Update();
             }
             else
             {
-                //if(lastdebug < std::time(NULL))
+                //if(lastdebug < Time::nowTimeT())
                 //    if(gDevDebug) Console->Print("[DEBUG] World not in use. Checking lifetimer...");
 
                 //    if(gDevDebug) Console->Print("[DEBUG] World not in use. Checking lifetimer...");
 
-                if (( tWorld->mCreation + ZONE_RESET_AFTER ) <= std::time( NULL ) )
-                    //if(tWorld->mCreation <= std::time(NULL))
+                if ((tWorld->mCreation + ZONE_RESET_AFTER ) <= Time::nowTimeT())
+                    //if(tWorld->mCreation <= Time::nowTimeT())
                 {
                     if ( gDevDebug ) Console->Print( "[DEBUG] World reached ZONE_RESET timeout. Erasing..." );
                     // World is unused sine ZONE_RESET_AFTER minutes, deleting now
                 {
                     if ( gDevDebug ) Console->Print( "[DEBUG] World reached ZONE_RESET timeout. Erasing..." );
                     // World is unused sine ZONE_RESET_AFTER minutes, deleting now
@@ -783,16 +741,16 @@ void PNPCWorld::Update()
                 else
                 {
                     // Keep LastAliveMessage up to date until someone enters zone
                 else
                 {
                     // Keep LastAliveMessage up to date until someone enters zone
-                    tWorld->mLastAliveMsg = std::time( NULL );
-                    //  if(lastdebug < std::time(NULL))
+                    tWorld->mLastAliveMsg = Time::nowTimeT();
+                    //  if(lastdebug < Time::nowTimeT())
                     //      if(gDevDebug) Console->Print("[DEBUG] World still within ZONE_RESET timeout");
                 }
             }
          }
      }
                     //      if(gDevDebug) Console->Print("[DEBUG] World still within ZONE_RESET timeout");
                 }
             }
          }
      }
-    if ( lastdebug < std::time( NULL ) )
+    if (lastdebug < Time::nowTimeT())
     {
     {
-        lastdebug = std::time( NULL ) + 3;
+        lastdebug = Time::nowTimeT() + 3;
 //if(gDevDebug) Console->Print("[DEBUG] next updateloopmsg in 3 seconds");
     }
  }
 //if(gDevDebug) Console->Print("[DEBUG] next updateloopmsg in 3 seconds");
     }
  }
@@ -804,7 +762,7 @@ void PNPCWorld::Update()
     if ( it == mWorlds.end() )
     {
         if ( gDevDebug ) Console->Print( "[DEBUG] Not found, returning NULL" );
     if ( it == mWorlds.end() )
     {
         if ( gDevDebug ) Console->Print( "[DEBUG] Not found, returning NULL" );
-        return NULL;
+        return nullptr;
     }
     else
     {
     }
     else
     {
index 678f804..31a681f 100644 (file)
@@ -8,14 +8,14 @@
 
 // Healthfactor for NPCs (see old npc.def)
 #define NPC_HEALTHFACTOR 15
 
 // Healthfactor for NPCs (see old npc.def)
 #define NPC_HEALTHFACTOR 15
+
 // Minimum time in seconds that has to pass before an NPC
 // gets his heartbeat send
 #define NPC_HEARTBEAT_MIN 5
 // Maximum time in seconds that is allowed to pass without
 // an NPC heartbeat
 #define NPC_HEARTBEAT_MAX 20
 // Minimum time in seconds that has to pass before an NPC
 // gets his heartbeat send
 #define NPC_HEARTBEAT_MIN 5
 // Maximum time in seconds that is allowed to pass without
 // an NPC heartbeat
 #define NPC_HEARTBEAT_MAX 20
+
 // If no custom NPC is set in this Zone, what ID to start with?
 #define NEW_NPC_ZONEID_START 1000
 
 // If no custom NPC is set in this Zone, what ID to start with?
 #define NEW_NPC_ZONEID_START 1000
 
 
 // How many seconds have to pass until we need an NPC "keepalive" packet?
 #define NPC_ALIVE_MSG 15
 
 // How many seconds have to pass until we need an NPC "keepalive" packet?
 #define NPC_ALIVE_MSG 15
+
 // How often a NPC should check if an enemy is nearby?
 #define NPC_ENEMYCHECK 5
 // How often a NPC should check if an enemy is nearby?
 #define NPC_ENEMYCHECK 5
+
 #define NPC_ACTIONSTATE_SITGND  0x00
 #define NPC_ACTIONSTATE_ATTACK  0x01
 //#define NPC_ACTIONSTATE_?       0x02
 #define NPC_ACTIONSTATE_SITGND  0x00
 #define NPC_ACTIONSTATE_ATTACK  0x01
 //#define NPC_ACTIONSTATE_?       0x02
 #define NPC_ACTIONSTATE_PASSIVE 0x20
 #define NPC_ACTIONSTATE_IDLE    0x40
 #define NPC_ACTIONSTATE_DEATH   0x80
 #define NPC_ACTIONSTATE_PASSIVE 0x20
 #define NPC_ACTIONSTATE_IDLE    0x40
 #define NPC_ACTIONSTATE_DEATH   0x80
+
 #define NPC_SHOOT_IDLE      15
 #define NPC_SHOOT_SINGLE    16
 #define NPC_SHOOT_AUTO1     17
 #define NPC_SHOOT_AUTO2     18
 #define NPC_SHOOT_IDLE      15
 #define NPC_SHOOT_SINGLE    16
 #define NPC_SHOOT_AUTO1     17
 #define NPC_SHOOT_AUTO2     18
+
 class PNPC;
 class PNPCWorld;
 
 typedef std::map<uint32_t, PNPC*> PNPCMap;
 typedef std::map<uint32_t, PNPCWorld*> PNPCWorldMap;
 class PNPC;
 class PNPCWorld;
 
 typedef std::map<uint32_t, PNPC*> PNPCMap;
 typedef std::map<uint32_t, PNPCWorld*> PNPCWorldMap;
+
 typedef struct
 {
     uint16_t ItemID;
     uint32_t Price;
 } stShopListEntry;
 typedef struct
 {
     uint16_t ItemID;
     uint32_t Price;
 } stShopListEntry;
+
 class PNPC
 {
 private:
 class PNPC
 {
 private:
@@ -85,7 +85,7 @@ private:
         npc_shop_quality,
         npc_scripting
     };
         npc_shop_quality,
         npc_scripting
     };
+
     time_t mNextUpdate;    // Timestamp for next heartbeat
     time_t mNextEnemyCheck; // Timestamp for next enemycheck
     void PushUpdateTimer();
     time_t mNextUpdate;    // Timestamp for next heartbeat
     time_t mNextEnemyCheck; // Timestamp for next enemycheck
     void PushUpdateTimer();
@@ -104,14 +104,14 @@ private:
     uint16_t mTrader;
     uint8_t mItemQuality; // Used for Shopping stuff
     uint8_t mUnknown;
     uint16_t mTrader;
     uint8_t mItemQuality; // Used for Shopping stuff
     uint8_t mUnknown;
+
     std::string mDialogScript;
     std::string mLUAFile; // Load File; Preloaded uppon NPC creation
     std::string mDialogScript;
     std::string mLUAFile; // Load File; Preloaded uppon NPC creation
+
     std::vector<stShopListEntry> mVectItemsInShop;    // We need to keep track of the itemorder for shopping
     void AddToVectorList(uint16_t nItemID, uint32_t nPrice);
     std::vector<stShopListEntry> mVectItemsInShop;    // We need to keep track of the itemorder for shopping
     void AddToVectorList(uint16_t nItemID, uint32_t nPrice);
-    inline const stShopListEntry* GetItemNum(uint32_t nIdx) const { if(nIdx > mVectItemsInShop.size()) { return NULL; } else { return &mVectItemsInShop[nIdx]; }};
+    inline const stShopListEntry* GetItemNum(uint32_t nIdx) const { if(nIdx > mVectItemsInShop.size()) { return nullptr; } else { return &mVectItemsInShop[nIdx]; }};
+
     bool mScripting;    // Manual override to disable scripting for an NPC TRUE: Scripts will be executed FALSE: Scripts will be ignored
 
     std::string mName;
     bool mScripting;    // Manual override to disable scripting for an NPC TRUE: Scripts will be executed FALSE: Scripts will be ignored
 
     std::string mName;
@@ -132,7 +132,7 @@ private:
     // WorldID Fix 10.10.2009
     bool mFromDEF;      // to differ DEF NPCs from SQL NPCs
     bool mSuccess;      // NPC load successfull?
     // WorldID Fix 10.10.2009
     bool mFromDEF;      // to differ DEF NPCs from SQL NPCs
     bool mSuccess;      // NPC load successfull?
+
 
      uint8_t mAction;         // Current action
     inline uint8_t GetActionStatus() const { return mAction; };
 
      uint8_t mAction;         // Current action
     inline uint8_t GetActionStatus() const { return mAction; };
@@ -144,40 +144,40 @@ private:
     // 00100000 ( 32) 0x20: Passive-Mode  (Depends on WeaponStatus. Difference between 0x01: NPC does NOT open fire)
     // 01000000 ( 64) 0x40: Idle
     // 10000000 (128) 0x80: Die
     // 00100000 ( 32) 0x20: Passive-Mode  (Depends on WeaponStatus. Difference between 0x01: NPC does NOT open fire)
     // 01000000 ( 64) 0x40: Idle
     // 10000000 (128) 0x80: Die
+
     uint8_t mWeaponStatus;
     inline uint8_t GetWeaponStatus() const { return mWeaponStatus; };
     // 00001111 (15) 0x0F: Follow given target with eyes / Put weapon away if pulled
     // 00010000 (16) 0x10: Pull weapon if not pulled / If pulled, attack
     // 00010001 (17) 0x11: Pull weapon and attack
 
     uint8_t mWeaponStatus;
     inline uint8_t GetWeaponStatus() const { return mWeaponStatus; };
     // 00001111 (15) 0x0F: Follow given target with eyes / Put weapon away if pulled
     // 00010000 (16) 0x10: Pull weapon if not pulled / If pulled, attack
     // 00010001 (17) 0x11: Pull weapon and attack
 
+
     bool SQL_Load();
     bool DEF_Load(uint32_t nWorldID);
     bool SQL_Load();
     bool DEF_Load(uint32_t nWorldID);
+
      PNPC( int nSQLID );
     PNPC( int nDEFID, uint32_t nWorldID );
      ~PNPC();
      PNPC( int nSQLID );
     PNPC( int nDEFID, uint32_t nWorldID );
      ~PNPC();
+
     void InitVars();
     void ContentListAddItem(PMessage* nContentList, uint16_t nItemID, uint32_t nBasePrice = 0, bool nAddToList = true);
     void ContentListAddItemGroup(PMessage* nContentList, uint32_t nItemGroupID);
     void StartDialog( PClient* nClient/*, string &nDialogscript */);
     void InitVars();
     void ContentListAddItem(PMessage* nContentList, uint16_t nItemID, uint32_t nBasePrice = 0, bool nAddToList = true);
     void ContentListAddItemGroup(PMessage* nContentList, uint32_t nItemGroupID);
     void StartDialog( PClient* nClient/*, string &nDialogscript */);
+
     bool DoSQLShoppingList( PClient* nClient, PMessage* nContentList );
     bool HasSQLShoppingList( PClient* nClient );
     bool IsAllbuyer( PClient* nClient );
     bool LoadLUAScript();
     bool DoSQLShoppingList( PClient* nClient, PMessage* nContentList );
     bool HasSQLShoppingList( PClient* nClient );
     bool IsAllbuyer( PClient* nClient );
     bool LoadLUAScript();
+
     inline uint32_t GetRealWorldID() { if(mFromDEF == true) return mWorldID+255; else return mWorldID; };
 
 public:
     friend class PNPCWorld;
     inline uint32_t GetRealWorldID() { if(mFromDEF == true) return mWorldID+255; else return mWorldID; };
 
 public:
     friend class PNPCWorld;
+
     inline void StopAttack() { mDirty = true; mAction = NPC_ACTIONSTATE_IDLE; mWeaponStatus = NPC_SHOOT_IDLE; };
     inline void Attack( PClient* nClient, uint8_t nType = NPC_SHOOT_SINGLE, uint8_t nUnknown = 90 ) { Attack(nClient->GetChar()->GetID(), nType, nUnknown); };
     void Attack( uint32_t nWorldID, uint8_t nType = NPC_SHOOT_SINGLE, uint8_t nUnknown = 90 );
     inline void StopAttack() { mDirty = true; mAction = NPC_ACTIONSTATE_IDLE; mWeaponStatus = NPC_SHOOT_IDLE; };
     inline void Attack( PClient* nClient, uint8_t nType = NPC_SHOOT_SINGLE, uint8_t nUnknown = 90 ) { Attack(nClient->GetChar()->GetID(), nType, nUnknown); };
     void Attack( uint32_t nWorldID, uint8_t nType = NPC_SHOOT_SINGLE, uint8_t nUnknown = 90 );
+
     inline void Move( uint16_t nNewX, uint16_t nNewY, uint16_t nNewZ )
     {
         mPosX = nNewX;
     inline void Move( uint16_t nNewX, uint16_t nNewY, uint16_t nNewZ )
     {
         mPosX = nNewX;
@@ -190,7 +190,7 @@ public:
     void Update(); // Check respawn timer
     void StartConversation( PClient* nClient );
     void DoConversation( PClient* nClient, uint8_t nAnswer ) ;
     void Update(); // Check respawn timer
     void StartConversation( PClient* nClient );
     void DoConversation( PClient* nClient, uint8_t nAnswer ) ;
+
     // GameCommands
     bool ReloadLUAScript();
     bool ReloadShopList();
     // GameCommands
     bool ReloadLUAScript();
     bool ReloadShopList();
@@ -237,14 +237,14 @@ private:
 
     bool LoadNPCfromSQL();
     bool LoadNPCfromDEF();
 
     bool LoadNPCfromSQL();
     bool LoadNPCfromDEF();
+
     void BroadcastNewNPC(PNPC* nNpc);
     void CheckForEnemies(PNPC* nNPC);
 
 public:
     friend class PNPCManager;
      PNPC* GetNPC( uint32_t nNPCID );
     void BroadcastNewNPC(PNPC* nNpc);
     void CheckForEnemies(PNPC* nNPC);
 
 public:
     friend class PNPCManager;
      PNPC* GetNPC( uint32_t nNPCID );
+
     // Functions to add/remove an NPC while server is running
     void SendSingleNPCInfo( PClient* nClient, PNPC* nNpc ); // Send
     bool AddNPC(uint32_t nSQL_ID, uint32_t nRaw_ID); // Load single SQL NPC from given SQL ID
     // Functions to add/remove an NPC while server is running
     void SendSingleNPCInfo( PClient* nClient, PNPC* nNpc ); // Send
     bool AddNPC(uint32_t nSQL_ID, uint32_t nRaw_ID); // Load single SQL NPC from given SQL ID
index aa4606e..9afa1eb 100644 (file)
@@ -6,7 +6,7 @@
 void PNPCWorld::CheckForEnemies(PNPC* nNPC)
 {
     //return;
 void PNPCWorld::CheckForEnemies(PNPC* nNPC)
 {
     //return;
-    time_t tNow = time(NULL);
+    time_t tNow = Time::nowTimeT();
     // Is it time for next enemy check?
 
     // Temp: Skip that for IDs below 1000
     // Is it time for next enemy check?
 
     // Temp: Skip that for IDs below 1000
@@ -17,7 +17,7 @@ void PNPCWorld::CheckForEnemies(PNPC* nNPC)
     if(tNow > nNPC->mNextEnemyCheck)
     {
         //Console->Print("[NPC AI] Checking enemy status for NPC %d", nNPC->GetRealWorldID());
     if(tNow > nNPC->mNextEnemyCheck)
     {
         //Console->Print("[NPC AI] Checking enemy status for NPC %d", nNPC->GetRealWorldID());
-        nNPC->mNextEnemyCheck = time(NULL) + NPC_ENEMYCHECK;
+        nNPC->mNextEnemyCheck = Time::nowTimeT() + NPC_ENEMYCHECK;
         // Loop all NPCs in my world
 
         // tNearestEnemy[0] = WorldID | tNearestEnemy[1] = Distance to us
         // Loop all NPCs in my world
 
         // tNearestEnemy[0] = WorldID | tNearestEnemy[1] = Distance to us
@@ -64,7 +64,7 @@ void PNPCWorld::CheckForEnemies(PNPC* nNPC)
                 if(tFactionMe == tFactionHim)
                     continue;
 
                 if(tFactionMe == tFactionHim)
                     continue;
 
-                const PDefFaction* tFaction = NULL;
+                const PDefFaction* tFaction = nullptr;
                 int tStanding = 0;
                 // Always check higher faction against lower faction
                 if(tFactionMe > tFactionHim)
                 int tStanding = 0;
                 // Always check higher faction against lower faction
                 if(tFactionMe > tFactionHim)
index 0528819..4ced717 100644 (file)
@@ -52,7 +52,7 @@ void PNPC::ContentListAddItem(PMessage* nContentList, uint16_t nItemID, uint32_t
 
 void PNPC::ContentListAddItemGroup(PMessage* nContentList, uint32_t nItemGroupID)
 {
 
 void PNPC::ContentListAddItemGroup(PMessage* nContentList, uint32_t nItemGroupID)
 {
-    const PDefItems* tDefItems = NULL;
+    const PDefItems* tDefItems = nullptr;
     std::map<int, PDefItems*>::const_iterator itStart = GameDefs->Items()->ConstIteratorBegin();
     std::map<int, PDefItems*>::const_iterator itEnd = GameDefs->Items()->ConstIteratorEnd();
     for ( std::map<int, PDefItems*>::const_iterator i = itStart; i != itEnd; i++ )
     std::map<int, PDefItems*>::const_iterator itStart = GameDefs->Items()->ConstIteratorBegin();
     std::map<int, PDefItems*>::const_iterator itEnd = GameDefs->Items()->ConstIteratorEnd();
     for ( std::map<int, PDefItems*>::const_iterator i = itStart; i != itEnd; i++ )
@@ -75,14 +75,14 @@ void PNPC::ContentListAddItemGroup(PMessage* nContentList, uint32_t nItemGroupID
 
 bool PNPC::DoSQLShoppingList( PClient* nClient, PMessage* nContentList )
 {
 
 bool PNPC::DoSQLShoppingList( PClient* nClient, PMessage* nContentList )
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_shop` WHERE `c_npc_id` = %d AND `c_zoneid` = %d", mWorldID, nClient->GetChar()->GetLocation());
     if (gDevDebug) Console->Print( "[PNPC::DoSQLShoppingList] Executing query %s", query );
     result = MySQL->GameResQuery( query );
     MYSQL_ROW row;
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_shop` WHERE `c_npc_id` = %d AND `c_zoneid` = %d", mWorldID, nClient->GetChar()->GetLocation());
     if (gDevDebug) Console->Print( "[PNPC::DoSQLShoppingList] Executing query %s", query );
     result = MySQL->GameResQuery( query );
-    if ( result == NULL )
+    if (result == nullptr)
     {
         Console->Print( YELLOW, BLACK, "[PNPC::DoSQLShoppingList] could not load shoplist from SQL" );
         Console->Print( "Query was:" );
     {
         Console->Print( YELLOW, BLACK, "[PNPC::DoSQLShoppingList] could not load shoplist from SQL" );
         Console->Print( "Query was:" );
@@ -136,13 +136,13 @@ bool PNPC::DoSQLShoppingList( PClient* nClient, PMessage* nContentList )
 
 bool PNPC::IsAllbuyer( PClient* nClient )
 {
 
 bool PNPC::IsAllbuyer( PClient* nClient )
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_shop` WHERE `c_npc_id` = %d AND `c_zoneid` = %d and `c_itemid` = -1", mWorldID, nClient->GetChar()->GetLocation());
     Console->Print( "[PNPC::IsAllbuyer] Executing query %s", query );
     result = MySQL->GameResQuery( query );
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_shop` WHERE `c_npc_id` = %d AND `c_zoneid` = %d and `c_itemid` = -1", mWorldID, nClient->GetChar()->GetLocation());
     Console->Print( "[PNPC::IsAllbuyer] Executing query %s", query );
     result = MySQL->GameResQuery( query );
-    if ( result == NULL )
+    if (result == nullptr)
     {
         Console->Print( YELLOW, BLACK, "[PNPC::IsAllbuyer] could not check if npc is allbuyer" );
         Console->Print( "Query was:" );
     {
         Console->Print( YELLOW, BLACK, "[PNPC::IsAllbuyer] could not check if npc is allbuyer" );
         Console->Print( "Query was:" );
@@ -160,13 +160,13 @@ bool PNPC::IsAllbuyer( PClient* nClient )
 
 bool PNPC::HasSQLShoppingList( PClient* nClient )
 {
 
 bool PNPC::HasSQLShoppingList( PClient* nClient )
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_shop` WHERE `c_npc_id` = %d AND `c_zoneid` = %d", mWorldID, nClient->GetChar()->GetLocation());
     Console->Print( "[PNPC::HasSQLShoppingList] Executing query %s", query );
     result = MySQL->GameResQuery( query );
     char query[100];
 
     snprintf( query, 100, "SELECT * FROM `npc_shop` WHERE `c_npc_id` = %d AND `c_zoneid` = %d", mWorldID, nClient->GetChar()->GetLocation());
     Console->Print( "[PNPC::HasSQLShoppingList] Executing query %s", query );
     result = MySQL->GameResQuery( query );
-    if ( result == NULL )
+    if (result == nullptr)
     {
         Console->Print( YELLOW, BLACK, "[PNPC::HasSQLShoppingList] could not load shoplist from SQL" );
         Console->Print( "Query was:" );
     {
         Console->Print( YELLOW, BLACK, "[PNPC::HasSQLShoppingList] could not load shoplist from SQL" );
         Console->Print( "Query was:" );
index 2ed10e8..167c7bd 100644 (file)
@@ -12,7 +12,7 @@ POutpost::~POutpost()
 
 uint32_t POutpost::GetCurrentClan(uint32_t nOutpostID)
 {
 
 uint32_t POutpost::GetCurrentClan(uint32_t nOutpostID)
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     char tQuery[200];
 
     snprintf(tQuery, 200, "SELECT o_clan FROM outposts WHERE o_outnum = %d", nOutpostID);
     char tQuery[200];
 
     snprintf(tQuery, 200, "SELECT o_clan FROM outposts WHERE o_outnum = %d", nOutpostID);
@@ -59,8 +59,8 @@ void POutpost::SendOPAreaData(PClient* nClient)
     if(!nClient)
         return;
 
     if(!nClient)
         return;
 
-    MYSQL_RES *result = NULL;
-    MYSQL_ROW row = NULL;
+    MYSQL_RES *result = nullptr;
+    MYSQL_ROW row = nullptr;
     char tQuery[200];
     int nZoneID = nClient->GetChar()->GetLocation();
 
     char tQuery[200];
     int nZoneID = nClient->GetChar()->GetLocation();
 
index 9b11437..de92399 100644 (file)
@@ -18,7 +18,7 @@ PMySQL::PMySQL()
     strncpy(game_password, Config->GetOption("game_sql_password").c_str(), 100);
     strncpy(game_database, Config->GetOption("game_sql_database").c_str(), 100);
 
     strncpy(game_password, Config->GetOption("game_sql_password").c_str(), 100);
     strncpy(game_database, Config->GetOption("game_sql_database").c_str(), 100);
 
-    mKeepaliveDelay = (std::time_t) (Config->GetOptionInt("mysql_wait_timeout") * 0.9) ; // we take 90% of the wait_timeout to trigger keepalive
+    mKeepaliveDelay = (time_t) (Config->GetOptionInt("mysql_wait_timeout") * 0.9) ; // we take 90% of the wait_timeout to trigger keepalive
     if (mKeepaliveDelay == 0)
     {
       Console->Print("%s MySQL keepalive disabled by config", Console->ColorText(GREEN, BLACK, "[Info]"));
     if (mKeepaliveDelay == 0)
     {
       Console->Print("%s MySQL keepalive disabled by config", Console->ColorText(GREEN, BLACK, "[Info]"));
@@ -43,7 +43,7 @@ void PMySQL::Update()
     CheckResCount(); // Check for MYSQL_RES mem leak
 
     // MySQL keepalive
     CheckResCount(); // Check for MYSQL_RES mem leak
 
     // MySQL keepalive
-    std::time_t t = std::time(NULL);
+    time_t t = Time::nowTimeT();
     if ((mKeepaliveDelay > 0) && ((t - mLastKeepaliveSent) > mKeepaliveDelay))
     {
       MYSQL_RES *result;
     if ((mKeepaliveDelay > 0) && ((t - mLastKeepaliveSent) > mKeepaliveDelay))
     {
       MYSQL_RES *result;
@@ -70,7 +70,7 @@ void PMySQL::Update()
       else
         FreeInfoSQLResult(result);
 
       else
         FreeInfoSQLResult(result);
 
-      mLastKeepaliveSent = std::time(NULL);
+      mLastKeepaliveSent = Time::nowTimeT();
       if (gDevDebug) Console->Print("%s MySQL keepalive sent", Console->ColorText(GREEN, BLACK, "[Debug]"));
     }
 }
       if (gDevDebug) Console->Print("%s MySQL keepalive sent", Console->ColorText(GREEN, BLACK, "[Debug]"));
     }
 }
@@ -97,7 +97,7 @@ bool PMySQL::Connect()
 {
     Console->LPrint("Establishing link to Infoserver Database...");
 
 {
     Console->LPrint("Establishing link to Infoserver Database...");
 
-    info_dbHandle = mysql_init(NULL);
+    info_dbHandle = mysql_init(nullptr);
 
     if(!info_dbHandle)
     {
 
     if(!info_dbHandle)
     {
@@ -107,7 +107,7 @@ bool PMySQL::Connect()
         exit(0);
     }
 
         exit(0);
     }
 
-    if(!mysql_real_connect(info_dbHandle, info_host, info_userName, info_password, info_database, info_port, NULL, 0))
+    if(!mysql_real_connect(info_dbHandle, info_host, info_userName, info_password, info_database, info_port, nullptr, 0))
     {
         Console->LPrint(RED, BLACK, "[ERROR]");
         Console->LClose();
     {
         Console->LPrint(RED, BLACK, "[ERROR]");
         Console->LClose();
@@ -121,7 +121,7 @@ bool PMySQL::Connect()
 // <><><><><><><><> Gameserver DB <><><><><><><><>
     Console->LPrint("Establishing link to Gameserver Database...");
 
 // <><><><><><><><> Gameserver DB <><><><><><><><>
     Console->LPrint("Establishing link to Gameserver Database...");
 
-    game_dbHandle = mysql_init(NULL);
+    game_dbHandle = mysql_init(nullptr);
 
     if(!game_dbHandle)
     {
 
     if(!game_dbHandle)
     {
@@ -131,7 +131,7 @@ bool PMySQL::Connect()
         exit(0);
     }
 
         exit(0);
     }
 
-    if(!mysql_real_connect(game_dbHandle, game_host, game_userName, game_password, game_database, game_port, NULL, 0))
+    if(!mysql_real_connect(game_dbHandle, game_host, game_userName, game_password, game_database, game_port, nullptr, 0))
     {
         Console->LPrint(RED, BLACK, "[ERROR]");
         Console->LClose();
     {
         Console->LPrint(RED, BLACK, "[ERROR]");
         Console->LClose();
@@ -153,15 +153,12 @@ MYSQL_RES *PMySQL::InfoResQuery(const char *query)
     MYSQL_RES *result;
 
     sql_result = mysql_real_query(info_dbHandle, query, strlen(query));
     MYSQL_RES *result;
 
     sql_result = mysql_real_query(info_dbHandle, query, strlen(query));
-    if(sql_result)
-    {
-        return NULL;
-    }
+    if (sql_result)
+        return nullptr;
+
     result = mysql_store_result(info_dbHandle);
     result = mysql_store_result(info_dbHandle);
-    if(!result)
-    {
-        return NULL;
-    }
+    if (!result)
+        return nullptr;
     //if(InfoDBInuse == true)
     /*if(InfoDBInuse > 0)
     {
     //if(InfoDBInuse == true)
     /*if(InfoDBInuse > 0)
     {
@@ -202,15 +199,13 @@ MYSQL_RES *PMySQL::GameResQuery(const char *query)
     MYSQL_RES *result;
 
     sql_result = mysql_real_query(game_dbHandle, query, strlen(query));
     MYSQL_RES *result;
 
     sql_result = mysql_real_query(game_dbHandle, query, strlen(query));
-    if(sql_result)
-    {
-        return NULL;
-    }
+    if (sql_result)
+        return nullptr;
+
     result = mysql_store_result(game_dbHandle);
     result = mysql_store_result(game_dbHandle);
-    if(!result)
-    {
-        return NULL;
-    }
+    if (!result)
+        return nullptr;
+
     /*if(GameDBInuse > 0)
     {
         Console->Print("%s another (%d) game_dbHandle result is still in use", Console->ColorText(YELLOW, BLACK, "[Warning]"), GameDBInuse);
     /*if(GameDBInuse > 0)
     {
         Console->Print("%s another (%d) game_dbHandle result is still in use", Console->ColorText(YELLOW, BLACK, "[Warning]"), GameDBInuse);
@@ -256,174 +251,3 @@ uint32_t PMySQL::EscapeString(const char* nText, char* dText, uint32_t dMaxLengt
 
   return mysql_real_escape_string(game_dbHandle, dText, nText, nLength);
 }
 
   return mysql_real_escape_string(game_dbHandle, dText, nText, nLength);
 }
-
-// ----------------------------------------------------
-/*
-int PMySQL::GetWorldItemType(unsigned short ID, int Location)
-{
-    char query[2048];
-    MYSQL_RES *result;
-    MYSQL_ROW row;
-
-    if (Location > 100000)
-    {
-      //int nAppLoc = GetAptLocation(Location);
-      int nAppLoc = Location - 100000; // temp as DB doesn't link with App world ID, but with app ID
-      if (nAppLoc)
-        snprintf(query, 2048, "SELECT ai_type FROM apt_items WHERE ai_apt_id = %d AND ai_apt_map = %d", ID, nAppLoc);
-      else
-        return 0;
-    }
-    else
-      snprintf(query, 2048, "SELECT wi_type FROM world_items WHERE wi_worlditem_id = %d AND wi_worlditem_map = %d", ID, Location);
-
-    result = GameResQuery(query);
-    if(!result)
-    {
-        Console->Print("%s Cannot get WorldItemType; MySQL returned", Console->ColorText(RED, BLACK, "[Error]"));
-        ShowGameSQLError();
-        return 0;
-    }
-    else
-    {
-        if(mysql_num_rows(result) > 1)
-        {
-            FreeGameSQLResult(result);
-            return -2;
-        }
-        else
-        {
-            row = mysql_fetch_row(result);
-            if(row == NULL)
-            {
-                FreeGameSQLResult(result);
-                return -1;
-            }
-            int ret_val = std::atoi(row[0]);
-            FreeGameSQLResult(result);
-            return ret_val;
-        }
-    }
-//    else
-//  {
-//      FreeGameSQLResult(result);
-//      return -1;
-//  }
-//
-    return -1;
-}
-
-int PMySQL::GetWorldItemOption(unsigned short ID, int Location, int option)
-{
-    char query[2048];
-    MYSQL_RES *result;
-    MYSQL_ROW row;
-    if(option != 1 && option != 2 && option != 3)
-    {
-        return -1;
-    }
-
-    if (Location > 100000)
-    {
-      //int nAppLoc = GetAptLocation(Location);
-      int nAppLoc = Location - 100000; // temp as DB doesn't link with App world ID, but with app ID
-      if (nAppLoc)
-        snprintf(query, 2048, "SELECT ai_option%d FROM apt_items WHERE ai_apt_id = %d AND ai_apt_map = %d", option, ID, nAppLoc);
-      else
-        return 0;
-    }
-    else
-      snprintf(query, 2048, "SELECT wi_option%d FROM world_items WHERE wi_worlditem_id = %d AND wi_worlditem_map = %d", option, ID, Location);
-
-    result = GameResQuery(query);
-    if(!result)
-    {
-        Console->Print("%s Cannot get WorldItemOption; MySQL returned", Console->ColorText(RED, BLACK, "[Error]"));
-        ShowGameSQLError();
-        return 0;
-    }
-    else
-    {
-        if(mysql_num_rows(result) > 1)
-        {
-            FreeGameSQLResult(result);
-            return -2;
-        }
-        else
-        {
-            row = mysql_fetch_row(result);
-            if(row == NULL)
-            {
-                FreeGameSQLResult(result);
-                return -1;
-            }
-            int ret_val = std::atoi(row[0]);
-            FreeGameSQLResult(result);
-            return ret_val;
-        }
-    }
-//
-//  else
-//  {
-//      FreeGameSQLResult(result);
-//      return -1;
-//  }
-
-    return -1;
-}
-
-int PMySQL::GetWorldDoorType(unsigned int ID, int Location) // To be removed
-{
-    char query[2048];
-    MYSQL_RES *result;
-    MYSQL_ROW row;
-
-Console->Print(RED, BLACK, "PMySQL::GetWorldDoorType: DATABASE MUST NOT BE USED ANYMORE FOR DOORS INFO !!!");
-    if (Location > 100000)
-    {
-      //int nAppLoc = GetAptLocation(Location);
-      int nAppLoc = Location - 100000; // temp as DB doesn't link with App world ID, but with app ID
-      if (nAppLoc)
-        snprintf(query, 2048, "SELECT ad_type FROM apt_doors, apartments WHERE apt_doors.ad_apt_map = apartments.apt_type AND apt_doors.ad_apt_id = %i AND apartments.apt_id = %i", ID, nAppLoc);
-      else
-        return 0;
-    }
-    else
-    {
-        snprintf(query, 2048, "SELECT wd_type FROM world_doors WHERE wd_world_id = %d AND wd_world_map = %d", ID, Location);
-    }
-    result = GameResQuery(query);
-
-    if(!result)
-    {
-        Console->Print("%s Cannot get WorldDoorType; MySQL returned", Console->ColorText(RED, BLACK, "[Error]"));
-        ShowGameSQLError();
-        return 0;
-    } else {
-        if(mysql_num_rows(result) > 1)
-        {
-            FreeGameSQLResult(result);
-            return -2;
-        }
-        else
-        {
-            row = mysql_fetch_row(result);
-            if(row == NULL)
-            {
-                FreeGameSQLResult(result);
-                return -1;
-            }
-            int ret_val = std::atoi(row[0]);
-            FreeGameSQLResult(result);
-            return ret_val;
-        }
-    }
-//
-//    else
-//    {
-//        FreeGameSQLResult(result);
-//        return -1;
-//    }
-//
-    return -1;
-}*/
index 603d9fc..1d8953d 100644 (file)
@@ -18,8 +18,8 @@ private:
     char info_password[100];
     char info_database[100];
     MYSQL *info_dbHandle;
     char info_password[100];
     char info_database[100];
     MYSQL *info_dbHandle;
-    std::time_t mKeepaliveDelay;
-    std::time_t mLastKeepaliveSent;
+    time_t mKeepaliveDelay;
+    time_t mLastKeepaliveSent;
 
     int game_port;
     char game_host[100];
 
     int game_port;
     char game_host[100];
index 472caf5..0857228 100644 (file)
@@ -34,7 +34,7 @@ class PSubway {
     PSubwayInfo mSubways[mCabsNumber];
 
 public:
     PSubwayInfo mSubways[mCabsNumber];
 
 public:
-    bool GetInfoIndex(uint32_t nVhcId, uint8_t *Index = NULL);
+    bool GetInfoIndex(uint32_t nVhcId, uint8_t *Index = nullptr);
 
   public:
     PSubway();
 
   public:
     PSubway();
@@ -45,7 +45,7 @@ public:
     uint16_t GetPosition(uint32_t nVhcId);
 
     uint32_t GetTimeOffset(uint32_t nVhcId, uint32_t nTime);
     uint16_t GetPosition(uint32_t nVhcId);
 
     uint32_t GetTimeOffset(uint32_t nVhcId, uint32_t nTime);
-    uint8_t GetStation(uint32_t nVhcId, uint32_t nTime, uint32_t* TimeOffset = NULL);
+    uint8_t GetStation(uint32_t nVhcId, uint32_t nTime, uint32_t* TimeOffset = nullptr);
     bool IsDoorOpen(uint32_t nVhcId, uint32_t nTime);
     std::string* GetStationName(uint8_t nStationId);
     bool GetStationExitPosition(PCharCoordinates* nPosition, uint8_t nStationId, float nCoef = 0.5);
     bool IsDoorOpen(uint32_t nVhcId, uint32_t nTime);
     std::string* GetStationName(uint8_t nStationId);
     bool GetStationExitPosition(PCharCoordinates* nPosition, uint8_t nStationId, float nCoef = 0.5);
index 48525ff..76154fb 100644 (file)
@@ -16,14 +16,14 @@ void PTerminal::EraseVars()
 
 uint8_t PTerminal::GetNewEmailCount(PClient* nClient, bool nNoticeClient)
 {
 
 uint8_t PTerminal::GetNewEmailCount(PClient* nClient, bool nNoticeClient)
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT count(*) FROM emails WHERE e_toid = %d AND e_new = 1", nClient->GetCharID());
     if(gDevDebug) Console->Print("[DEBUG] Query is: %s", query);
     result = MySQL->GameResQuery(query);
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT count(*) FROM emails WHERE e_toid = %d AND e_new = 1", nClient->GetCharID());
     if(gDevDebug) Console->Print("[DEBUG] Query is: %s", query);
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if(result == nullptr)
     {
         Console->Print(RED, BLACK, "PTerminal::GetNewEmailCount could not get emailcount");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PTerminal::GetNewEmailCount could not get emailcount");
         Console->Print("Query was:");
index e8d8c7b..ccd20bf 100644 (file)
@@ -970,7 +970,7 @@ bool PTerminal::HandleReceiveDB(PClient* nClient, uint16_t mTerminalSessionId, s
     if(strlen(mSQLQuery) == 0)
         return false;
 // ---------------
     if(strlen(mSQLQuery) == 0)
         return false;
 // ---------------
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     int tNumRows = 0;
 
     MYSQL_ROW row;
     int tNumRows = 0;
 
index af52fcb..08d4d82 100644 (file)
@@ -4,7 +4,7 @@
 
 bool PTerminal::DoStockXCheck(PClient* nClient, int nAmountEntered, int nNewAmount)
  {
 
 bool PTerminal::DoStockXCheck(PClient* nClient, int nAmountEntered, int nNewAmount)
  {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     char qry[100];
     int tDepotAmount = 0;
 
     char qry[100];
     int tDepotAmount = 0;
 
@@ -286,7 +286,7 @@ bool PTerminal::HandleTryAccess(PClient* nClient, uint16_t mTerminalSessionId, s
     // ----------------
     if(tGetResultFromSQL == true)
      {
     // ----------------
     if(tGetResultFromSQL == true)
      {
-        MYSQL_RES *result = NULL;
+        MYSQL_RES *result = nullptr;
         //MYSQL_ROW row;
         int tNumRows = 0;
 
         //MYSQL_ROW row;
         int tNumRows = 0;
 
index 48d30b4..73283e3 100644 (file)
@@ -274,7 +274,7 @@ PSpawnedVehicle* PVehicles::GetSpawnedVehicle( uint32_t nVehicleId ) const
   }
   else
   {
   }
   else
   {
-    return NULL;
+    return nullptr;
   }
 }
 
   }
 }
 
@@ -321,7 +321,7 @@ PVhcInfoList* PVehicles::GetCharVehicles( uint32_t nCharId, uint16_t nMaxCount,
 
 PSpawnedVehicle* PVehicles::SpawnVehicle( uint32_t nVehicleId, uint32_t nLocation, PVhcCoordinates const* nVhcPos )
 {
 
 PSpawnedVehicle* PVehicles::SpawnVehicle( uint32_t nVehicleId, uint32_t nLocation, PVhcCoordinates const* nVhcPos )
 {
-  PSpawnedVehicle* newVhc = NULL;
+  PSpawnedVehicle* newVhc = nullptr;
   PWorld* cWorld;
   PVehicleInformation nVhcInfo;
 
   PWorld* cWorld;
   PVehicleInformation nVhcInfo;
 
@@ -398,7 +398,7 @@ PSpawnedVehicles::~PSpawnedVehicles()
 
 PSpawnedVehicle* PSpawnedVehicles::SpawnVehicle( PVehicleInformation const* nVhcInfo, PVhcCoordinates const* nVhcPos )
 {
 
 PSpawnedVehicle* PSpawnedVehicles::SpawnVehicle( PVehicleInformation const* nVhcInfo, PVhcCoordinates const* nVhcPos )
 {
-  PSpawnedVehicle* newVhc = NULL;
+  PSpawnedVehicle* newVhc = nullptr;
   uint32_t nSize;
 
   if ( nVhcInfo->GetStatus() == 0 ) // only if in garage
   uint32_t nSize;
 
   if ( nVhcInfo->GetStatus() == 0 ) // only if in garage
@@ -414,7 +414,7 @@ PSpawnedVehicle* PSpawnedVehicles::SpawnVehicle( PVehicleInformation const* nVhc
     }
     if ( mNextFreeHint == nSize )
     {
     }
     if ( mNextFreeHint == nSize )
     {
-      mSpawnedVehicles.push_back( static_cast<PSpawnedVehicle *>(NULL) );
+      mSpawnedVehicles.push_back( static_cast<PSpawnedVehicle *>(nullptr));
     }
 
     if ( mNextFreeHint < mMaxLocalVhc )
     }
 
     if ( mNextFreeHint < mMaxLocalVhc )
@@ -436,7 +436,7 @@ PSpawnedVehicle* PSpawnedVehicles::GetVehicle( uint32_t nLocalId )
   }
   else
   {
   }
   else
   {
-    return NULL;
+    return nullptr;
   }
 }
 
   }
 }
 
@@ -450,7 +450,7 @@ PSpawnedVehicle* PSpawnedVehicles::GetVehicleByGlobalId( uint32_t nVehicleId ) c
     }
   }
 
     }
   }
 
-  return NULL;
+  return nullptr;
 }
 
 bool PSpawnedVehicles::UnspawnVehicle( uint32_t nLocalId )
 }
 
 bool PSpawnedVehicles::UnspawnVehicle( uint32_t nLocalId )
@@ -469,7 +469,7 @@ bool PSpawnedVehicles::UnspawnVehicle( uint32_t nLocalId )
         tVhc->SetStatus( 0 );
       }
       delete tVhc;
         tVhc->SetStatus( 0 );
       }
       delete tVhc;
-      mSpawnedVehicles[Index] = NULL;
+      mSpawnedVehicles[Index] = nullptr;
       if ( mNextFreeHint > Index )
       {
         mNextFreeHint = Index;
       if ( mNextFreeHint > Index )
       {
         mNextFreeHint = Index;
index cdec035..475a79e 100644 (file)
@@ -13,7 +13,7 @@ PVhcAccessRequest::PVhcAccessRequest( uint32_t nRequesterCharId, uint32_t nVhcGl
   mCharId = nRequesterCharId;
   mVhcGlobalId = nVhcGlobalId;
   mStatus = 0;
   mCharId = nRequesterCharId;
   mVhcGlobalId = nVhcGlobalId;
   mStatus = 0;
-  mTimestamp = std::time( NULL );
+  mTimestamp = Time::nowTimeT();
 }
 
 /*
 }
 
 /*
@@ -22,9 +22,9 @@ typedef std::map<uint32_t, PVhcAccessRequest> PVhcAccessRequestMap;
 PVhcAccessRequestMap mActiveRequests;
 uint32_t mNextRequestId;
 
 PVhcAccessRequestMap mActiveRequests;
 uint32_t mNextRequestId;
 
-std::time_t mResponseWaitTime; // How long do we wait for owner answer
-std::time_t mCheckWaitTime; // How long do we wait for user access check (0: remaining time from mResponseWaitTime)
-std::time_t mReuseWaitTime; // How long do we allow user to re-use the autorization after first check
+time_t mResponseWaitTime; // How long do we wait for owner answer
+time_t mCheckWaitTime; // How long do we wait for user access check (0: remaining time from mResponseWaitTime)
+time_t mReuseWaitTime; // How long do we allow user to re-use the autorization after first check
 */
 void PVhcAccessRequestList::DropTimedOut()
 {
 */
 void PVhcAccessRequestList::DropTimedOut()
 {
@@ -62,7 +62,7 @@ PVhcAccessRequestList::~PVhcAccessRequestList()
 {
 }
 
 {
 }
 
-void PVhcAccessRequestList::SetParameters( std::time_t nResponseWaitTime, std::time_t nCheckWaitTime, std::time_t nReuseWaitTime )
+void PVhcAccessRequestList::SetParameters(time_t nResponseWaitTime, time_t nCheckWaitTime, time_t nReuseWaitTime)
 {
   mResponseWaitTime = nResponseWaitTime;
   mCheckWaitTime = nCheckWaitTime;
 {
   mResponseWaitTime = nResponseWaitTime;
   mCheckWaitTime = nCheckWaitTime;
@@ -107,7 +107,7 @@ bool PVhcAccessRequestList::RegisterResponse( uint32_t nRequestId, bool nStatus
       it->second.mStatus = 1;
       if ( mCheckWaitTime )
       {
       it->second.mStatus = 1;
       if ( mCheckWaitTime )
       {
-        it->second.mTimestamp = std::time( NULL );
+        it->second.mTimestamp = Time::nowTimeT();
       }
       return true;
     }
       }
       return true;
     }
@@ -131,7 +131,7 @@ bool PVhcAccessRequestList::Check( uint32_t nRequestId, uint32_t nRequesterCharI
       if ( mReuseWaitTime && ( it->second.mStatus == 1 ) )
       {
         it->second.mStatus = 2;
       if ( mReuseWaitTime && ( it->second.mStatus == 1 ) )
       {
         it->second.mStatus = 2;
-        it->second.mTimestamp = std::time( NULL );
+        it->second.mTimestamp = Time::nowTimeT();
       }
       else
       {
       }
       else
       {
index 36f75d3..bbc6b65 100644 (file)
@@ -26,7 +26,7 @@ void PWorldActors::VanishWA(uint32_t nWorld, uint32_t nWAid)
 uint32_t PWorldActors::GetNextFreeWAID()
 {
     if (gDevDebug) Console->Print("DEBUG: Getting next free worldactor ID...");
 uint32_t PWorldActors::GetNextFreeWAID()
 {
     if (gDevDebug) Console->Print("DEBUG: Getting next free worldactor ID...");
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     MYSQL_ROW row;
     char query[100];
 
@@ -34,7 +34,7 @@ uint32_t PWorldActors::GetNextFreeWAID()
     if (gDevDebug) Console->Print("DEBUG: Executing query %s", query);
 
     result = MySQL->GameResQuery(query);
     if (gDevDebug) Console->Print("DEBUG: Executing query %s", query);
 
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PWorldActors::GetNextFreeWAID could not get next free WorldActorID");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PWorldActors::GetNextFreeWAID could not get next free WorldActorID");
         Console->Print("Query was:");
@@ -69,14 +69,14 @@ void PWorldActors::InitWorld(PClient* nClient)
     DoActorCheck();
     if (gDevDebug) Console->Print("DEBUG: Initializing WorldActors for client...");
     uint32_t tZone = nClient->GetChar()->GetLocation();
     DoActorCheck();
     if (gDevDebug) Console->Print("DEBUG: Initializing WorldActors for client...");
     uint32_t tZone = nClient->GetChar()->GetLocation();
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_map` = %d", tZone);
     //if (gDevDebug) Console->Print("DEBUG: Executing query: %s", query);
     result = MySQL->GameResQuery(query);
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_map` = %d", tZone);
     //if (gDevDebug) Console->Print("DEBUG: Executing query: %s", query);
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PWorldActors::InitWorld could not load WorldActor definition");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PWorldActors::InitWorld could not load WorldActor definition");
         Console->Print("Query was:");
@@ -148,7 +148,7 @@ void PWorldActors::InitWorld(PClient* nClient)
                 tmpActorSpawn->U16Data(0x01) = nClient->GetUDP_ID();  // Set final UDP ID
                 tmpActorSpawn->U16Data(0x03) = nClient->GetSessionID();  // Set final SessionID
                 nClient->SendUDPMessage(tmpActorSpawn);
                 tmpActorSpawn->U16Data(0x01) = nClient->GetUDP_ID();  // Set final UDP ID
                 tmpActorSpawn->U16Data(0x03) = nClient->GetSessionID();  // Set final SessionID
                 nClient->SendUDPMessage(tmpActorSpawn);
-                tmpActorSpawn = NULL;
+                tmpActorSpawn = nullptr;
 
                 // ReInit message
                 tmpActorSpawn = new PMessage(256);
 
                 // ReInit message
                 tmpActorSpawn = new PMessage(256);
@@ -233,7 +233,7 @@ void PWorldActors::DelWorldActor(PClient* nClient, uint32_t nWAid)
 
 void PWorldActors::GetWAoption(uint32_t nWAid, uint16_t nWorld, uint16_t &nValue1, uint16_t &nValue2, uint16_t &nValue3)
 {
 
 void PWorldActors::GetWAoption(uint32_t nWAid, uint16_t nWorld, uint16_t &nValue1, uint16_t &nValue2, uint16_t &nValue3)
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     MYSQL_ROW row;
     char query[100];
 
@@ -243,7 +243,7 @@ void PWorldActors::GetWAoption(uint32_t nWAid, uint16_t nWorld, uint16_t &nValue
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_map` = %d AND `wa_actor_id` = %d", nWorld, nWAid);
 
     result = MySQL->GameResQuery(query);
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_map` = %d AND `wa_actor_id` = %d", nWorld, nWAid);
 
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PWorldActors::GetWAoption could not get WorldActor options");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PWorldActors::GetWAoption could not get WorldActor options");
         Console->Print("Query was:");
@@ -267,14 +267,14 @@ void PWorldActors::GetWAoption(uint32_t nWAid, uint16_t nWorld, uint16_t &nValue
 
 int PWorldActors::GetWASQLID(uint32_t nWAid, uint32_t nWorld)
 {
 
 int PWorldActors::GetWASQLID(uint32_t nWAid, uint32_t nWorld)
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_map` = %d AND `wa_actor_id` = %d", nWorld, nWAid);
 
     result = MySQL->GameResQuery(query);
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_map` = %d AND `wa_actor_id` = %d", nWorld, nWAid);
 
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PWorldActors::GetWASQLID could not get WorldActor SQL ID");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PWorldActors::GetWASQLID could not get WorldActor SQL ID");
         Console->Print("Query was:");
@@ -297,13 +297,13 @@ int PWorldActors::GetWASQLID(uint32_t nWAid, uint32_t nWorld)
 
 bool PWorldActors::IsDynamicActor(uint32_t nWAid)
 {
 
 bool PWorldActors::IsDynamicActor(uint32_t nWAid)
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_id` = %d", nWAid);
 
     result = MySQL->GameResQuery(query);
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_id` = %d", nWAid);
 
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PWorldActors::IsDynamicActor could not check if worldactor is dynamic");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PWorldActors::IsDynamicActor could not check if worldactor is dynamic");
         Console->Print("Query was:");
@@ -330,55 +330,17 @@ bool PWorldActors::IsDynamicActor(uint32_t nWAid)
     MySQL->FreeGameSQLResult(result);
     return false;
 }
     MySQL->FreeGameSQLResult(result);
     return false;
 }
-/* Not needed. Better re-spawn the actor
-bool PWorldActors::EditWorldActor(uint32_t nWorldID, int nOption1, int nOption2, int nOption3)
-{
-    if(IsDynamicActor(nWorldID) == false) // Make sure we really have this actor in DB
-        return false;
-
-    std::string query;
-    query = "UPDATE `world_actors` SET wa_option1 = ";
-    if(nOption1 > -1)
-        query += Ssprintf("%d,", nOption1);
-    else
-        query += "wa_option1,";
-
-    query += " wa_option2 = ";
-    if(nOption2 > -1)
-        query += Ssprintf("%d,", nOption2);
-    else
-        query += "wa_option1,";
-
-    query += " wa_option3 = ";
-    if(nOption3 > -1)
-        query += Ssprintf("%d", nOption3);
-    else
-        query += "wa_option1";
 
 
-    query += "WHERE wa_actor_id = ";
-    query += Ssprintf("%d", nWorldID);
-
-    if(MySQL->GameQuery(query.c_str()))
-    {
-        Console->Print(RED, BLACK, "PWorldActors::EditWorldActor could not update recordset for worldactor id %d", nWorldID);
-        Console->Print("Query was:");
-        Console->Print("%s", query.c_str());
-        MySQL->ShowGameSQLError();
-        return false;
-    }
-    return true;
-}
-*/
 int PWorldActors::GetWorldActorFunctionID(uint32_t nWAid)
 {
 int PWorldActors::GetWorldActorFunctionID(uint32_t nWAid)
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_id` = %d", nWAid);
 
     result = MySQL->GameResQuery(query);
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_id` = %d", nWAid);
 
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PWorldActors::GetWorldActorFunctionID could not get WorldActor Function ID");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PWorldActors::GetWorldActorFunctionID could not get WorldActor Function ID");
         Console->Print("Query was:");
@@ -401,7 +363,7 @@ int PWorldActors::GetWorldActorFunctionID(uint32_t nWAid)
 
 void PWorldActors::GetFrontPos(uint32_t nWAID, uint16_t* mX, uint16_t* mY, uint16_t* mZ)
 {
 
 void PWorldActors::GetFrontPos(uint32_t nWAID, uint16_t* mX, uint16_t* mY, uint16_t* mZ)
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     MYSQL_ROW row;
     char query[100];
 
@@ -412,7 +374,7 @@ void PWorldActors::GetFrontPos(uint32_t nWAID, uint16_t* mX, uint16_t* mY, uint1
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_id` = %d", nWAID);
 
     result = MySQL->GameResQuery(query);
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_id` = %d", nWAID);
 
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PWorldActors::GetFrontPos could not get X/Y/Z values for worldactor");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PWorldActors::GetFrontPos could not get X/Y/Z values for worldactor");
         Console->Print("Query was:");
@@ -442,14 +404,14 @@ void PWorldActors::GetFrontPos(uint32_t nWAID, uint16_t* mX, uint16_t* mY, uint1
 
 int PWorldActors::GetLinkedObjectID(uint32_t nWAID)
 {
 
 int PWorldActors::GetLinkedObjectID(uint32_t nWAID)
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_id` = %d", nWAID);
 
     result = MySQL->GameResQuery(query);
     MYSQL_ROW row;
     char query[100];
 
     snprintf(query, 100, "SELECT * FROM `world_actors` WHERE `wa_actor_id` = %d", nWAID);
 
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PWorldActors::GetLinkedObjectID could not get Linked object ID");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PWorldActors::GetLinkedObjectID could not get Linked object ID");
         Console->Print("Query was:");
@@ -477,7 +439,7 @@ bool PWorldActors::IsValidWAFunction(int nFunctionID)
 
     // Check if given WO function is a valid one
     const PDefWorldModel* tFurnitureModel = GameDefs->WorldModels()->GetDef(nFunctionID);
 
     // Check if given WO function is a valid one
     const PDefWorldModel* tFurnitureModel = GameDefs->WorldModels()->GetDef(nFunctionID);
-    if(tFurnitureModel == NULL)
+    if (tFurnitureModel == nullptr)
         return false;
     else
         return true;
         return false;
     else
         return true;
@@ -544,7 +506,7 @@ bool PWorldActors::IsValidLinkedObject(PClient *nClient, uint16_t nOption1, int
 
 void PWorldActors::DoActorCheck()
 {
 
 void PWorldActors::DoActorCheck()
 {
-    MYSQL_RES *result = NULL;
+    MYSQL_RES *result = nullptr;
     MYSQL_ROW row;
     char query[200];
     char query2[100];
     MYSQL_ROW row;
     char query[200];
     char query2[100];
@@ -552,7 +514,7 @@ void PWorldActors::DoActorCheck()
     snprintf(query, 200, "SELECT COUNT(`wa_actor_id`),`wa_actor_id` FROM `world_actors` GROUP BY `wa_actor_id` HAVING COUNT(`wa_actor_id`)>1");
 
     result = MySQL->GameResQuery(query);
     snprintf(query, 200, "SELECT COUNT(`wa_actor_id`),`wa_actor_id` FROM `world_actors` GROUP BY `wa_actor_id` HAVING COUNT(`wa_actor_id`)>1");
 
     result = MySQL->GameResQuery(query);
-    if(result == NULL)
+    if (result == nullptr)
     {
         Console->Print(RED, BLACK, "PWorldActors::DoActorCheck unable to check for double actorIDs");
         Console->Print("Query was:");
     {
         Console->Print(RED, BLACK, "PWorldActors::DoActorCheck unable to check for double actorIDs");
         Console->Print("Query was:");
index 4778ed3..0e725f0 100644 (file)
@@ -7,7 +7,7 @@ PWorldDataTemplate::PWorldDataTemplate()
     mUseCount = 0;
     for ( int i = 0; i < WORLDDATATEMPLATE_MAXPOSITEMS; ++i )
     {
     mUseCount = 0;
     for ( int i = 0; i < WORLDDATATEMPLATE_MAXPOSITEMS; ++i )
     {
-        mPositionItems[i] = NULL;
+        mPositionItems[i] = nullptr;
     }
 }
 
     }
 }
 
@@ -129,7 +129,7 @@ const PFurnitureItemTemplate* PWorldDataTemplate::GetFurnitureItem( uint32_t Ite
 {
     PFurnitureItemsMap::const_iterator it = mFurnitureItems.find( ItemID );
     if ( it == mFurnitureItems.end() )
 {
     PFurnitureItemsMap::const_iterator it = mFurnitureItems.find( ItemID );
     if ( it == mFurnitureItems.end() )
-        return NULL;
+        return nullptr;
     else
         return it->second;
 }
     else
         return it->second;
 }
@@ -165,7 +165,7 @@ const PDoorTemplate* PWorldDataTemplate::GetDoor( uint32_t DoorID )
 {
     PDoorsMap::const_iterator it = mDoors.find( DoorID );
     if ( it == mDoors.end() )
 {
     PDoorsMap::const_iterator it = mDoors.find( DoorID );
     if ( it == mDoors.end() )
-        return NULL;
+        return nullptr;
     else
         return it->second;
 }
     else
         return it->second;
 }
@@ -192,7 +192,7 @@ const PNPCTemplate* PWorldDataTemplate::GetNPC( uint32_t NPCID )
 {
     PNPCsMap::const_iterator it = mNPCs.find( NPCID );
     if ( it == mNPCs.end() )
 {
     PNPCsMap::const_iterator it = mNPCs.find( NPCID );
     if ( it == mNPCs.end() )
-        return NULL;
+        return nullptr;
     else
         return it->second;
 }
     else
         return it->second;
 }
index 57bf7a0..a5113fd 100644 (file)
@@ -15,7 +15,7 @@ PWorld::PWorld()
 {
   mID = 0;
   mUseCount = 0;
 {
   mID = 0;
   mUseCount = 0;
-  mWorldDataTemplate = NULL;
+  mWorldDataTemplate = nullptr;
 }
 
 PWorld::~PWorld()
 }
 
 PWorld::~PWorld()
@@ -64,7 +64,7 @@ bool PWorld::Load( uint32_t nWorldID )
 
     if (( nWorldID > 90000 ) && ( nWorldID < 90017 ) ) // hardcoded holomatch hack
     {
 
     if (( nWorldID > 90000 ) && ( nWorldID < 90017 ) ) // hardcoded holomatch hack
     {
-      nWorldFileDef = NULL;
+      nWorldFileDef = nullptr;
       char worldName[19];
       int MatchID = nWorldID - 90000;
       if ( MatchID > 8 ) // to care for Neofrag 1 & 2
       char worldName[19];
       int MatchID = nWorldID - 90000;
       if ( MatchID > 8 ) // to care for Neofrag 1 & 2
@@ -134,7 +134,7 @@ bool PWorld::IsAppartment()
 
 const PFurnitureItemTemplate *PWorld::GetFurnitureItemTemplate( uint32_t nItemID )
 {
 
 const PFurnitureItemTemplate *PWorld::GetFurnitureItemTemplate( uint32_t nItemID )
 {
-    return ( mWorldDataTemplate ? mWorldDataTemplate->GetFurnitureItem( nItemID ) : NULL ) ;
+    return ( mWorldDataTemplate ? mWorldDataTemplate->GetFurnitureItem( nItemID ) : nullptr);
 }
 
 const PDefWorldModel *PWorld::GetFurnitureItemModel(uint32_t nItemID)
 }
 
 const PDefWorldModel *PWorld::GetFurnitureItemModel(uint32_t nItemID)
@@ -353,7 +353,7 @@ bool PWorlds::LeaseWorldDataTemplate( const std::string& nBspName, const std::st
         }
         else
         {
         }
         else
         {
-          mWorldDataTemplatesMap.insert( std::make_pair( nFileName, ( PWorldDataTemplate* )NULL ) ); // NULL means file access OK but not preloaded yet
+          mWorldDataTemplatesMap.insert(std::make_pair(nFileName, (PWorldDataTemplate *)nullptr)); // NULL means file access OK but not preloaded yet
           delete tWorldDataTemplate;
         }
         //return true;
           delete tWorldDataTemplate;
         }
         //return true;
@@ -419,7 +419,7 @@ void PWorlds::UnloadWorldDataTemplate( const std::string& nFileName )
       Console->Print( "%s PWorlds::UnloadWorldDataTemplate : attempt to unload template %s when use count not null ou preload set", Console->ColorText( RED, BLACK, "[Warning]" ), nFileName.c_str() );
     else
     {
       Console->Print( "%s PWorlds::UnloadWorldDataTemplate : attempt to unload template %s when use count not null ou preload set", Console->ColorText( RED, BLACK, "[Warning]" ), nFileName.c_str() );
     else
     {
-      it->second = ( PWorldDataTemplate* )NULL;
+      it->second = (PWorldDataTemplate *)nullptr;
       delete tWorldDataTemplate;
     }
   }
       delete tWorldDataTemplate;
     }
   }
@@ -433,7 +433,7 @@ PWorldDataTemplate* PWorlds::GetWorldDataTemplate( const std::string& nFileName
   if ( it != mWorldDataTemplatesMap.end() )
     return it->second;
   else
   if ( it != mWorldDataTemplatesMap.end() )
     return it->second;
   else
-    return NULL;
+    return nullptr;
 }
 
 bool PWorlds::LoadWorlds() // once Load is done, only WorldDataTemplate registred in mWorldDataTemplatesMap
 }
 
 bool PWorlds::LoadWorlds() // once Load is done, only WorldDataTemplate registred in mWorldDataTemplatesMap
@@ -539,7 +539,7 @@ bool PWorlds::LoadWorlds() // once Load is done, only WorldDataTemplate registre
         }
         else
         {
         }
         else
         {
-          mStaticWorldsMap.insert( std::make_pair( tDefWorldFile->GetIndex(), ( PWorld* )NULL ) );
+          mStaticWorldsMap.insert(std::make_pair( tDefWorldFile->GetIndex(), (PWorld *)nullptr));
         }
         if ( gDevDebug )
           Console->Print( GREEN, BLACK, "Template file %s for world %d (%s) loaded", tFileName.c_str(), i->second->GetIndex(), i->second->GetName().c_str() );
         }
         if ( gDevDebug )
           Console->Print( GREEN, BLACK, "Template file %s for world %d (%s) loaded", tFileName.c_str(), i->second->GetIndex(), i->second->GetName().c_str() );
@@ -597,7 +597,7 @@ bool PWorlds::LoadWorlds() // once Load is done, only WorldDataTemplate registre
         }
         else
         {
         }
         else
         {
-          mStaticWorldsMap.insert( std::make_pair( 90000 + i, ( PWorld* )NULL ) );
+          mStaticWorldsMap.insert(std::make_pair(90000 + i, (PWorld *)nullptr));
         }
         if ( gDevDebug )
           Console->Print( GREEN, BLACK, "Template file %s for world %d (%s) loaded", tFileName.c_str(), 90000 + i, worldName );
         }
         if ( gDevDebug )
           Console->Print( GREEN, BLACK, "Template file %s for world %d (%s) loaded", tFileName.c_str(), 90000 + i, worldName );
@@ -674,7 +674,7 @@ PWorld* PWorlds::LeaseWorld( uint32_t nWorldID, const bool nPreloadPhase )
       {
         delete nWorld;
         Console->Print( "% Could not load world %d - World now set as invalid", Console->ColorText( RED, BLACK, "[Warning]" ), nWorldID );
       {
         delete nWorld;
         Console->Print( "% Could not load world %d - World now set as invalid", Console->ColorText( RED, BLACK, "[Warning]" ), nWorldID );
-        return NULL;
+        return nullptr;
       }
       else
       {
       }
       else
       {
@@ -691,7 +691,7 @@ PWorld* PWorlds::LeaseWorld( uint32_t nWorldID, const bool nPreloadPhase )
     it = mStaticWorldsMap.find( nWorldID ); // Check if already loaded
     if (( it == mStaticWorldsMap.end() ) && nPreloadPhase )
     {
     it = mStaticWorldsMap.find( nWorldID ); // Check if already loaded
     if (( it == mStaticWorldsMap.end() ) && nPreloadPhase )
     {
-      mStaticWorldsMap.insert( std::make_pair( nWorldID, ( PWorld* )NULL ) );
+      mStaticWorldsMap.insert(std::make_pair(nWorldID, (PWorld *)nullptr));
       it = mStaticWorldsMap.find( nWorldID );
     }
     if ( it != mStaticWorldsMap.end() )
       it = mStaticWorldsMap.find( nWorldID );
     }
     if ( it != mStaticWorldsMap.end() )
@@ -705,7 +705,7 @@ PWorld* PWorlds::LeaseWorld( uint32_t nWorldID, const bool nPreloadPhase )
           delete it->second;
           Console->Print( "%s Could not load world %d - World now set as invalid", Console->ColorText( RED, BLACK, "[Warning]" ), nWorldID );
           mStaticWorldsMap.erase( it ); // remove from valid worlds map
           delete it->second;
           Console->Print( "%s Could not load world %d - World now set as invalid", Console->ColorText( RED, BLACK, "[Warning]" ), nWorldID );
           mStaticWorldsMap.erase( it ); // remove from valid worlds map
-          return NULL;
+          return nullptr;
         }
       }
       it->second->IncreaseUseCount();
         }
       }
       it->second->IncreaseUseCount();
@@ -715,7 +715,7 @@ PWorld* PWorlds::LeaseWorld( uint32_t nWorldID, const bool nPreloadPhase )
     }
     else // invalid worldID
     {
     }
     else // invalid worldID
     {
-      return NULL;
+      return nullptr;
     }
   }
 }
     }
   }
 }
@@ -735,7 +735,7 @@ PWorld* PWorlds::GetWorld( uint32_t nWorldID )
   else
   {
     Console->Print( "%s PWorlds::GetWorld : Trying to get world %d without lease !", Console->ColorText( RED, BLACK, "[Warning]" ), nWorldID );
   else
   {
     Console->Print( "%s PWorlds::GetWorld : Trying to get world %d without lease !", Console->ColorText( RED, BLACK, "[Warning]" ), nWorldID );
-    return NULL;
+    return nullptr;
   }
 }
 
   }
 }
 
index ee05c3d..a13d4cd 100644 (file)
@@ -25,7 +25,7 @@ bool PAccount::SetUsernameRegexFilter(const char* RegexStr)
   if(mUsernameRegexFilter)
   {
     delete mUsernameRegexFilter;
   if(mUsernameRegexFilter)
   {
     delete mUsernameRegexFilter;
-    mUsernameRegexFilter = NULL;
+    mUsernameRegexFilter = nullptr;
   }
 
   if(RegexStr)
   }
 
   if(RegexStr)
@@ -45,7 +45,7 @@ bool PAccount::SetPasswordRegexFilter(const char* RegexStr)
   if(mPasswordRegexFilter)
   {
     delete mPasswordRegexFilter;
   if(mPasswordRegexFilter)
   {
     delete mPasswordRegexFilter;
-    mPasswordRegexFilter = NULL;
+    mPasswordRegexFilter = nullptr;
   }
 
   if(RegexStr)
   }
 
   if(RegexStr)
@@ -118,7 +118,7 @@ bool PAccount::LoadFromQuery(char* query)
 
   //result = MySQL->InfoResQuery(query);
   result = MySQL->ResQuery(query);
 
   //result = MySQL->InfoResQuery(query);
   result = MySQL->ResQuery(query);
-  if(result == NULL)
+  if(result == nullptr)
   {
       Console->Print(RED, BLACK, "Failed to load AccountData from SQL");
       //MySQL->ShowInfoSQLError();
   {
       Console->Print(RED, BLACK, "Failed to load AccountData from SQL");
       //MySQL->ShowInfoSQLError();
@@ -133,7 +133,7 @@ bool PAccount::LoadFromQuery(char* query)
     mPassword = row[a_password];
 
     mBannedUntil = atoi(row[a_bandate]);
     mPassword = row[a_password];
 
     mBannedUntil = atoi(row[a_bandate]);
-    if(mBannedUntil > std::time(NULL))
+    if(mBannedUntil > Time::nowTimeT())
     {
       mStatus = PAS_BANNED;
       mLevel = PAL_BANNED;
     {
       mStatus = PAS_BANNED;
       mLevel = PAL_BANNED;
@@ -256,9 +256,9 @@ PAccountStatus PAccount::GetStatus() const
     return mStatus;
 }
 
     return mStatus;
 }
 
-bool PAccount::SetBannedUntilTime(std::time_t BannedUntil)
+bool PAccount::SetBannedUntilTime(time_t BannedUntil)
 {
 {
-  if ((BannedUntil == 0) || (BannedUntil > std::time(NULL)))
+  if ((BannedUntil == 0) || (BannedUntil > Time::nowTimeT()))
   {
     mBannedUntil = BannedUntil;
     return true;
   {
     mBannedUntil = BannedUntil;
     return true;
@@ -271,7 +271,7 @@ bool PAccount::SetBannedUntilTime(std::time_t BannedUntil)
 
 bool PAccount::IsBanned() const
 {
 
 bool PAccount::IsBanned() const
 {
-    return (mBannedUntil > std::time(nullptr));
+    return (mBannedUntil > Time::nowTimeT());
 }
 
 bool PAccount::DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword)
 }
 
 bool PAccount::DecodePassword(const uint8_t* PasswordData, int PassLen, const uint8_t *Key, char* ClearPassword)
@@ -373,11 +373,9 @@ std::string PAccount::GetBannedTime() const
 {
   const char* unit[5] = {"seconds", "minutes", "hours", "days", "weeks"};
 
 {
   const char* unit[5] = {"seconds", "minutes", "hours", "days", "weeks"};
 
-  std::time_t timediff = mBannedUntil - std::time(NULL);
-  if(timediff <=0)
-  {
+  time_t timediff = mBannedUntil - Time::nowTimeT();
+  if (timediff <=0)
     return "0 more seconds. Please relog";
     return "0 more seconds. Please relog";
-  }
 
   long counter;
   int type;
 
   long counter;
   int type;
index 6ad130c..533eeeb 100644 (file)
@@ -1,7 +1,6 @@
 #pragma once
 
 #include <cstdint>
 #pragma once
 
 #include <cstdint>
-#include <ctime>
 #include <string>
 
 class RegEx;
 #include <string>
 
 class RegEx;
@@ -65,7 +64,7 @@ class PAccount
     std::string mPassword;
     int32_t mLevel;
     PAccountStatus mStatus;
     std::string mPassword;
     int32_t mLevel;
     PAccountStatus mStatus;
-    std::time_t mBannedUntil;
+    time_t mBannedUntil;
 
     bool LoadFromQuery(char *query);
     bool DecodePassword(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key, char *ClearPassword);
 
     bool LoadFromQuery(char *query);
     bool DecodePassword(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key, char *ClearPassword);
@@ -91,7 +90,7 @@ public:
     std::string GetLevelString() const;
     bool SetStatus(PAccountStatus Status);
     PAccountStatus GetStatus() const;
     std::string GetLevelString() const;
     bool SetStatus(PAccountStatus Status);
     PAccountStatus GetStatus() const;
-    bool SetBannedUntilTime(std::time_t BannedUntil);
+    bool SetBannedUntilTime(time_t BannedUntil);
     bool IsBanned() const;
     std::string GetBannedTime() const;
     bool Authenticate(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key);
     bool IsBanned() const;
     std::string GetBannedTime() const;
     bool Authenticate(const uint8_t *PasswordData, int32_t PassLen, const uint8_t *Key);
index 9b2f990..d013d00 100644 (file)
@@ -234,7 +234,7 @@ bool PInfoServer::HandleAuthenticate(PClient *Client, PInfoState *State, const u
     // -12: Account is not yet activated (accesslevel = 0)
     // -99: General fault. Contact admin
     ConnectionTCP *Socket = Client->getTCPConn();
     // -12: Account is not yet activated (accesslevel = 0)
     // -99: General fault. Contact admin
     ConnectionTCP *Socket = Client->getTCPConn();
-    PAccount* currentAccount = NULL;
+    PAccount* currentAccount = nullptr;
 
     if (PacketSize > 20 && *(uint16_t *)&Packet[3] == 0x8084)
     {
 
     if (PacketSize > 20 && *(uint16_t *)&Packet[3] == 0x8084)
     {
index d43c4e4..3131379 100644 (file)
@@ -32,7 +32,7 @@ PMySQL::~PMySQL()
 void PMySQL::Update()
 {
     // MySQL keepalive
 void PMySQL::Update()
 {
     // MySQL keepalive
-    time_t t = std::time(NULL);
+    time_t t = Time::nowTimeT();
     if ((mKeepaliveDelay > 0) && ((t - mLastKeepaliveSent) > mKeepaliveDelay))
     {
       MYSQL_RES *result;
     if ((mKeepaliveDelay > 0) && ((t - mLastKeepaliveSent) > mKeepaliveDelay))
     {
       MYSQL_RES *result;
@@ -49,7 +49,7 @@ void PMySQL::Update()
       else
         FreeSQLResult(result);
 
       else
         FreeSQLResult(result);
 
-      mLastKeepaliveSent = std::time(NULL);
+      mLastKeepaliveSent = Time::nowTimeT();
 //Console->Print("%s MySQL keepalive sent", Console->ColorText(GREEN, BLACK, "[Debug]"));
     }
 }
 //Console->Print("%s MySQL keepalive sent", Console->ColorText(GREEN, BLACK, "[Debug]"));
     }
 }
@@ -63,7 +63,7 @@ bool PMySQL::Connect()
 {
     Console->LPrint("Establishing link to MySQL Database...");
 
 {
     Console->LPrint("Establishing link to MySQL Database...");
 
-    dbHandle = mysql_init(NULL);
+    dbHandle = mysql_init(nullptr);
 
     if(dbHandle)
     {
 
     if(dbHandle)
     {
@@ -77,7 +77,7 @@ bool PMySQL::Connect()
         exit(0);
     }
 
         exit(0);
     }
 
-    if(!mysql_real_connect(dbHandle, host, userName, password, database, port, NULL, 0))
+    if (!mysql_real_connect(dbHandle, host, userName, password, database, port, nullptr, 0))
     {
         Console->LPrint(RED, BLACK, "[ERROR]");
         Console->LClose();
     {
         Console->LPrint(RED, BLACK, "[ERROR]");
         Console->LClose();
@@ -98,15 +98,12 @@ MYSQL_RES *PMySQL::ResQuery(const char *query)
     MYSQL_RES *result;
 
     sql_result = mysql_real_query(dbHandle, query, strlen(query));
     MYSQL_RES *result;
 
     sql_result = mysql_real_query(dbHandle, query, strlen(query));
-    if(sql_result)
-    {
-        return NULL;
-    }
+    if (sql_result)
+        return nullptr;
+
     result = mysql_store_result(dbHandle);
     result = mysql_store_result(dbHandle);
-    if(!result)
-    {
-        return NULL;
-    }
+    if (!result)
+        return nullptr;
 
     return result;
 }
 
     return result;
 }