aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorn0n4m3 <none@none>2009-12-24 10:20:15 +0100
committern0n4m3 <none@none>2009-12-24 10:20:15 +0100
commit250a00cc1c91d2df2b6c4f72a2ad322b46fed783 (patch)
treeeab0216df4c91777747e866ed4525c9fbc7a037f /src
parentacdc4ca15b69c84197f867192328829904646a66 (diff)
Temporary revert 6743 commit. I fix this patch across 1-2 days.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/framework/GameSystem/NGrid.h2
-rw-r--r--src/game/AchievementMgr.cpp12
-rw-r--r--src/game/AuctionHouseBot.cpp13
-rw-r--r--src/game/AuctionHouseHandler.cpp3
-rw-r--r--src/game/AuctionHouseMgr.cpp7
-rw-r--r--src/game/BattleGround.cpp5
-rw-r--r--src/game/BattleGroundMgr.cpp7
-rw-r--r--src/game/CMakeLists.txt2
-rw-r--r--src/game/CalendarHandler.cpp3
-rw-r--r--src/game/CharacterHandler.cpp3
-rw-r--r--src/game/ChatHandler.cpp5
-rw-r--r--src/game/Corpse.cpp3
-rw-r--r--src/game/Corpse.h3
-rw-r--r--src/game/Creature.cpp96
-rw-r--r--src/game/Creature.h26
-rw-r--r--src/game/DestinationHolder.h2
-rw-r--r--src/game/DuelHandler.cpp3
-rw-r--r--src/game/GameEventMgr.cpp15
-rw-r--r--src/game/GameObject.cpp38
-rw-r--r--src/game/GameObject.h17
-rw-r--r--src/game/GuardAI.h2
-rw-r--r--src/game/Guild.cpp21
-rw-r--r--src/game/InstanceSaveMgr.cpp12
-rw-r--r--src/game/Level0.cpp15
-rw-r--r--src/game/Level2.cpp10
-rw-r--r--src/game/Level3.cpp11
-rw-r--r--src/game/Mail.cpp19
-rw-r--r--src/game/Map.cpp6
-rw-r--r--src/game/Map.h2
-rw-r--r--src/game/MiscHandler.cpp11
-rw-r--r--src/game/MovementHandler.cpp3
-rw-r--r--src/game/ObjectMgr.cpp10
-rw-r--r--src/game/Pet.cpp15
-rw-r--r--src/game/PetAI.h2
-rw-r--r--src/game/PetHandler.cpp3
-rw-r--r--src/game/Player.cpp101
-rw-r--r--src/game/Player.h23
-rw-r--r--src/game/QueryHandler.cpp3
-rw-r--r--src/game/RandomMovementGenerator.cpp2
-rw-r--r--src/game/SpellAuras.cpp5
-rw-r--r--src/game/SpellEffects.cpp3
-rw-r--r--src/game/TicketHandler.cpp9
-rw-r--r--src/game/TotemAI.h2
-rw-r--r--src/game/Unit.cpp27
-rw-r--r--src/game/Weather.cpp2
-rw-r--r--src/game/Weather.h2
-rw-r--r--src/game/World.cpp27
-rw-r--r--src/game/World.h8
-rw-r--r--src/game/WorldSession.cpp9
-rw-r--r--src/shared/Timer.h79
-rw-r--r--src/trinitycore/Master.cpp2
-rw-r--r--src/trinitycore/WorldRunnable.cpp2
52 files changed, 366 insertions, 347 deletions
diff --git a/src/framework/GameSystem/NGrid.h b/src/framework/GameSystem/NGrid.h
index c5e6cb5133d..ecb00e6d6f4 100644
--- a/src/framework/GameSystem/NGrid.h
+++ b/src/framework/GameSystem/NGrid.h
@@ -26,7 +26,7 @@
#include "GameSystem/Grid.h"
#include "GameSystem/GridReference.h"
-#include "TimeMgr.h"
+#include "Timer.h"
class GridInfo
{
diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp
index aaacee695fd..b7175a09af3 100644
--- a/src/game/AchievementMgr.cpp
+++ b/src/game/AchievementMgr.cpp
@@ -34,7 +34,7 @@
#include "Player.h"
#include "ProgressBar.h"
#include "SpellMgr.h"
-#include "TimeMgr.h"
+
#include "MapManager.h"
#include "BattleGround.h"
#include "BattleGroundAB.h"
@@ -552,7 +552,7 @@ void AchievementMgr::LoadFromDB(QueryResult *achievementResult, QueryResult *cri
continue;
}
- if (criteria->timeLimit && time_t(date + criteria->timeLimit) < sGameTime.GetGameTime())
+ if (criteria->timeLimit && time_t(date + criteria->timeLimit) < time(NULL))
continue;
CriteriaProgress& progress = m_criteriaProgress[id];
@@ -612,7 +612,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8);
data.append(GetPlayer()->GetPackGUID());
data << uint32(achievement->ID);
- data << uint32(secsToTimeBitFields(sGameTime.GetGameTime()));
+ data << uint32(secsToTimeBitFields(time(NULL)));
data << uint32(0);
GetPlayer()->SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY), true);
}
@@ -1623,7 +1623,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry,
progress = &m_criteriaProgress[entry->ID];
progress->counter = changeValue;
- progress->date = sGameTime.GetGameTime();
+ progress->date = time(NULL);
}
else
{
@@ -1658,7 +1658,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry,
if(entry->timeLimit)
{
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
if(time_t(progress->date + entry->timeLimit) < now)
progress->counter = 1;
@@ -1680,7 +1680,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
SendAchievementEarned(achievement);
CompletedAchievementData& ca = m_completedAchievements[achievement->ID];
- ca.date = sGameTime.GetGameTime();
+ ca.date = time(NULL);
ca.changed = true;
// don't insert for ACHIEVEMENT_FLAG_REALM_FIRST_KILL since otherwise only the first group member would reach that achievement
diff --git a/src/game/AuctionHouseBot.cpp b/src/game/AuctionHouseBot.cpp
index 556fb88a88f..6b86f9de306 100644
--- a/src/game/AuctionHouseBot.cpp
+++ b/src/game/AuctionHouseBot.cpp
@@ -1,7 +1,6 @@
#include "ObjectMgr.h"
#include "AuctionHouseMgr.h"
#include "AuctionHouseBot.h"
-#include "TimeMgr.h"
#include <vector>
#include "Policies/SingletonImp.h"
@@ -90,9 +89,9 @@ AuctionHouseBot::AuctionHouseBot()
//End Filters
- _lastrun_a = sGameTime.GetGameTime();
- _lastrun_h = sGameTime.GetGameTime();
- _lastrun_n = sGameTime.GetGameTime();
+ _lastrun_a = time(NULL);
+ _lastrun_h = time(NULL);
+ _lastrun_n = time(NULL);
AllianceConfig = AHBConfig(2);
HordeConfig = AHBConfig(6);
@@ -420,7 +419,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
auctionEntry->bidder = 0;
auctionEntry->bid = 0;
auctionEntry->deposit = dep;
- auctionEntry->expire_time = (time_t) etime + sGameTime.GetGameTime();
+ auctionEntry->expire_time = (time_t) etime + time(NULL);
auctionEntry->auctionHouseEntry = ahEntry;
item->SaveToDB();
item->RemoveFromUpdateQueueOf(AHBplayer);
@@ -696,7 +695,7 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
void AuctionHouseBot::Update()
{
- time_t _newrun = sGameTime.GetGameTime();
+ time_t _newrun = time(NULL);
if ((!AHBSeller) && (!AHBBuyer))
return;
@@ -1507,7 +1506,7 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
{
if (itr->second->owner == AHBplayerGUID)
{
- itr->second->expire_time = sGameTime.GetGameTime();
+ itr->second->expire_time = sWorld.GetGameTime();
uint32 id = itr->second->Id;
uint32 expire_time = itr->second->expire_time;
CharacterDatabase.PExecute("UPDATE auctionhouse SET time = '%u' WHERE id = '%u'", expire_time, id);
diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp
index 6ff9d7d5f8d..fdfea922c4f 100644
--- a/src/game/AuctionHouseHandler.cpp
+++ b/src/game/AuctionHouseHandler.cpp
@@ -30,7 +30,6 @@
#include "Opcodes.h"
#include "UpdateMask.h"
#include "Util.h"
-#include "TimeMgr.h"
//please DO NOT use iterator++, because it is slower than ++iterator!!!
//post-incrementation is always slower than pre-incrementation !
@@ -272,7 +271,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
AH->bidder = 0;
AH->bid = 0;
AH->buyout = buyout;
- AH->expire_time = sGameTime.GetGameTime() + auction_time;
+ AH->expire_time = time(NULL) + auction_time;
AH->deposit = deposit;
AH->auctionHouseEntry = auctionHouseEntry;
diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp
index 129089fd892..b2b5d250b28 100644
--- a/src/game/AuctionHouseMgr.cpp
+++ b/src/game/AuctionHouseMgr.cpp
@@ -32,7 +32,6 @@
#include "Item.h"
#include "Language.h"
#include "Log.h"
-#include "TimeMgr.h"
#include "ProgressBar.h"
#include <vector>
@@ -184,7 +183,7 @@ void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry * auction)
std::ostringstream msgAuctionSalePendingBody;
uint32 auctionCut = auction->GetAuctionCut();
- time_t distrTime = sGameTime.GetGameTime() + sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY);
+ time_t distrTime = time(NULL) + sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY);
msgAuctionSalePendingBody.width(16);
msgAuctionSalePendingBody << std::right << std::hex << auction->bidder;
@@ -500,7 +499,7 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTem
void AuctionHouseObject::Update()
{
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = sWorld.GetGameTime();
///- Handle expired auctions
// If storage is empty, no need to update. next == NULL in this case.
@@ -684,7 +683,7 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const
data << uint32(bid ? GetAuctionOutBid() : 0);
//minimal outbid
data << uint32(buyout); //auction->buyout
- data << uint32((expire_time-sGameTime.GetGameTime())*IN_MILISECONDS);//time left
+ data << uint32((expire_time-time(NULL))*IN_MILISECONDS);//time left
data << uint64(bidder) ; //auction->bidder current
data << uint32(bid); //current bid
return true;
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index ec8bccd535f..554f8555627 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -35,7 +35,6 @@
#include "Object.h"
#include "SpellAuras.h"
#include "Util.h"
-#include "TimeMgr.h"
namespace Trinity
{
@@ -260,7 +259,7 @@ void BattleGround::Update(uint32 diff)
BattleGroundPlayerMap::iterator itr = m_Players.find(*(m_OfflineQueue.begin()));
if (itr != m_Players.end())
{
- if (itr->second.OfflineRemoveTime <= sGameTime.GetGameTime())
+ if (itr->second.OfflineRemoveTime <= sWorld.GetGameTime())
{
RemovePlayerAtLeave(itr->first, true, true);// remove player from BG
m_OfflineQueue.pop_front(); // remove from offline queue
@@ -1267,7 +1266,7 @@ void BattleGround::EventPlayerLoggedOut(Player* player)
{
// player is correct pointer, it is checked in WorldSession::LogoutPlayer()
m_OfflineQueue.push_back(player->GetGUID());
- m_Players[player->GetGUID()].OfflineRemoveTime = sGameTime.GetGameTime() + MAX_OFFLINE_TIME;
+ m_Players[player->GetGUID()].OfflineRemoveTime = sWorld.GetGameTime() + MAX_OFFLINE_TIME;
if (GetStatus() == STATUS_IN_PROGRESS)
{
if (isBattleGround())
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
index e296d5634f3..1259f26b0da 100644
--- a/src/game/BattleGroundMgr.cpp
+++ b/src/game/BattleGroundMgr.cpp
@@ -47,7 +47,6 @@
#include "GameEventMgr.h"
#include "ProgressBar.h"
#include "SharedDefines.h"
-#include "TimeMgr.h"
INSTANTIATE_SINGLETON_1( BattleGroundMgr );
@@ -1225,10 +1224,10 @@ void BattleGroundMgr::Update(uint32 diff)
{
if (m_AutoDistributionTimeChecker < diff)
{
- if(sGameTime.GetGameTime() > m_NextAutoDistributionTime)
+ if(time(NULL) > m_NextAutoDistributionTime)
{
DistributeArenaPoints();
- m_NextAutoDistributionTime = sGameTime.GetGameTime() + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
+ m_NextAutoDistributionTime = time(NULL) + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
CharacterDatabase.PExecute("UPDATE saved_variables SET NextArenaPointDistributionTime = '"UI64FMTD"'", m_NextAutoDistributionTime);
}
m_AutoDistributionTimeChecker = 600000; // check 10 minutes
@@ -1761,7 +1760,7 @@ void BattleGroundMgr::InitAutomaticArenaPointDistribution()
if (!result)
{
sLog.outDebug("Battleground: Next arena point distribution time not found in SavedVariables, reseting it now.");
- m_NextAutoDistributionTime = sGameTime.GetGameTime() + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
+ m_NextAutoDistributionTime = time(NULL) + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
CharacterDatabase.PExecute("INSERT INTO saved_variables (NextArenaPointDistributionTime) VALUES ('"UI64FMTD"')", m_NextAutoDistributionTime);
}
else
diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt
index a4e1e75a330..a4d656cf7f6 100644
--- a/src/game/CMakeLists.txt
+++ b/src/game/CMakeLists.txt
@@ -250,8 +250,6 @@ SET(game_STAT_SRCS
TaxiHandler.cpp
TemporarySummon.cpp
TemporarySummon.h
- TimeMgr.cpp
- TimeMgr.h
TicketHandler.cpp
Tools.cpp
Tools.h
diff --git a/src/game/CalendarHandler.cpp b/src/game/CalendarHandler.cpp
index 1dbf86d69a9..5860f4acaec 100644
--- a/src/game/CalendarHandler.cpp
+++ b/src/game/CalendarHandler.cpp
@@ -24,13 +24,12 @@
#include "Log.h"
#include "Opcodes.h"
#include "Player.h"
-#include "TimeMgr.h"
void WorldSession::HandleCalendarGetCalendar(WorldPacket &recv_data)
{
sLog.outDebug("WORLD: CMSG_CALENDAR_GET_CALENDAR"); // empty
- time_t cur_time = sGameTime.GetGameTime();
+ time_t cur_time = time(NULL);
WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR,4+4*0+4+4*0+4+4);
diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 4dde49c4ee0..3ef302c2f79 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -43,7 +43,6 @@
#include "UpdateMask.h"
#include "Util.h"
#include "ScriptCalls.h"
-#include "TimeMgr.h"
class LoginQueryHolder : public SqlQueryHolder
{
@@ -76,7 +75,7 @@ bool LoginQueryHolder::Initialize()
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADREPUTATION, "SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADINVENTORY, "SELECT data,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACTIONS, "SELECT a.button,a.action,a.type FROM character_action as a, characters as c WHERE a.guid = c.guid AND a.spec = c.activespec AND a.guid = '%u' ORDER BY button", GUID_LOPART(m_guid));
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILCOUNT, "SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" UI64FMTD "'", GUID_LOPART(m_guid),(uint64)sGameTime.GetGameTime());
+ res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILCOUNT, "SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" UI64FMTD "'", GUID_LOPART(m_guid),(uint64)time(NULL));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILDATE, "SELECT MIN(deliver_time) FROM mail WHERE receiver = '%u' AND (checked & 1)=0", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSOCIALLIST, "SELECT friend,flags,note FROM character_social WHERE guid = '%u' LIMIT 255", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADHOMEBIND, "SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", GUID_LOPART(m_guid));
diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp
index 7616394134a..dd39dd72190 100644
--- a/src/game/ChatHandler.cpp
+++ b/src/game/ChatHandler.cpp
@@ -39,7 +39,6 @@
#include "ScriptCalls.h"
#include "SpellAuras.h"
#include "Util.h"
-#include "TimeMgr.h"
bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg, uint32 lang)
{
@@ -167,7 +166,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!_player->CanSpeak())
{
- std::string timeStr = secsToTimeString(m_muteTime - sGameTime.GetGameTime());
+ std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str());
return;
}
@@ -628,7 +627,7 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
if (!GetPlayer()->CanSpeak())
{
- std::string timeStr = secsToTimeString(m_muteTime - sGameTime.GetGameTime());
+ std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING),timeStr.c_str());
return;
}
diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp
index 2a8eb0f6795..1edb478872f 100644
--- a/src/game/Corpse.cpp
+++ b/src/game/Corpse.cpp
@@ -27,7 +27,6 @@
#include "Opcodes.h"
#include "GossipDef.h"
#include "World.h"
-#include "TimeMgr.h"
Corpse::Corpse(CorpseType type) : WorldObject()
, m_type(type)
@@ -39,7 +38,7 @@ Corpse::Corpse(CorpseType type) : WorldObject()
m_valuesCount = CORPSE_END;
- m_time = sGameTime.GetGameTime();
+ m_time = time(NULL);
lootForBody = false;
diff --git a/src/game/Corpse.h b/src/game/Corpse.h
index eb0d788ae35..e0374a03470 100644
--- a/src/game/Corpse.h
+++ b/src/game/Corpse.h
@@ -25,7 +25,6 @@
#include "Database/DatabaseEnv.h"
#include "GridDefines.h"
#include "LootMgr.h"
-#include "TimeMgr.h"
enum CorpseType
{
@@ -71,7 +70,7 @@ class Corpse : public WorldObject
uint64 const& GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); }
time_t const& GetGhostTime() const { return m_time; }
- void ResetGhostTime() { m_time = sGameTime.GetGameTime(); }
+ void ResetGhostTime() { m_time = time(NULL); }
CorpseType GetType() const { return m_type; }
GridPair const& GetGrid() const { return m_grid; }
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 98639a97018..05f2c7e1ec6 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -47,7 +47,6 @@
#include "GameEventMgr.h"
#include "CreatureGroups.h"
#include "Vehicle.h"
-#include "TimeMgr.h"
// apply implementation of the singletons
#include "Policies/SingletonImp.h"
@@ -60,40 +59,32 @@ TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
return NULL;
}
-bool VendorItemData::RemoveItem(uint32 item_id)
+bool VendorItemData::RemoveItem( uint32 item_id )
{
- ItemToSlotMap::iterator i = m_itemtoslot.find(item_id);
- if (i != m_itemtoslot.end())
+ for (VendorItemList::iterator i = m_items.begin(); i != m_items.end(); ++i )
{
- m_items.erase(m_items.begin() + i->second);
-
- //need to recount vendorslot
- ItemToSlotMap::iterator itr;
- for (itr = i; itr != m_itemtoslot.end();++itr)
- itr->second -= 1;
- //and delete
- m_itemtoslot.erase(i);
-
- return true;
+ if((*i)->item==item_id)
+ {
+ m_items.erase(i);
+ return true;
+ }
}
-
return false;
}
-uint8 VendorItemData::FindItemSlot(uint32 item_id) const
+size_t VendorItemData::FindItemSlot(uint32 item_id) const
{
- ItemToSlotMap::const_iterator i = m_itemtoslot.find(item_id);
- if (i != m_itemtoslot.end())
- return i->second;
-
- return uint8(m_items.size());
+ for (size_t i = 0; i < m_items.size(); ++i)
+ if (m_items[i]->item==item_id)
+ return i;
+ return m_items.size();
}
VendorItem const* VendorItemData::FindItem(uint32 item_id) const
{
- ItemToSlotMap::const_iterator i = m_itemtoslot.find(item_id);
- if (i != m_itemtoslot.end())
- return m_items[i->second];
+ for (VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i )
+ if((*i)->item==item_id)
+ return *i;
return NULL;
}
@@ -171,8 +162,6 @@ m_creatureInfo(NULL), m_reactState(REACT_AGGRESSIVE), m_formation(NULL)
Creature::~Creature()
{
- for (VendorItemCounts::iterator itr = m_vendorItemCounts.begin(); itr != m_vendorItemCounts.end(); ++itr)
- delete itr->second;
m_vendorItemCounts.clear();
if(i_AI)
@@ -251,7 +240,7 @@ void Creature::RemoveCorpse()
if (IsAIEnabled)
AI()->CorpseRemoved(respawnDelay);
- m_respawnTime = sGameTime.GetGameTime() + m_respawnDelay;
+ m_respawnTime = time(NULL) + m_respawnDelay;
float x,y,z,o;
GetRespawnCoord(x, y, z, &o);
@@ -451,7 +440,7 @@ void Creature::Update(uint32 diff)
break;
case DEAD:
{
- if( m_respawnTime <= sGameTime.GetGameTime() )
+ if( m_respawnTime <= time(NULL) )
{
if(!GetLinkedCreatureRespawnTime()) // Can respawn
Respawn();
@@ -462,7 +451,7 @@ void Creature::Update(uint32 diff)
if(targetGuid == m_DBTableGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
- m_respawnTime = (sGameTime.GetGameTime()>GetLinkedCreatureRespawnTime()? sGameTime.GetGameTime():GetLinkedCreatureRespawnTime())+urand(5,MINUTE); // else copy time from master and add a little
+ m_respawnTime = (time(NULL)>GetLinkedCreatureRespawnTime()? time(NULL):GetLinkedCreatureRespawnTime())+urand(5,MINUTE); // else copy time from master and add a little
SaveRespawnTime(); // also save to DB immediately
}
else
@@ -595,11 +584,6 @@ void Creature::Update(uint32 diff)
}
}
-void Creature::SetRespawnTime(uint32 respawn)
-{
- m_respawnTime = respawn ? sGameTime.GetGameTime() + respawn : 0;
-}
-
void Creature::RegenerateMana()
{
uint32 curValue = GetPower(POWER_MANA);
@@ -1886,10 +1870,10 @@ void Creature::SaveRespawnTime()
if(isSummon() || !m_DBTableGuid || m_creatureData && !m_creatureData->dbData)
return;
- if(m_respawnTime > sGameTime.GetGameTime()) // dead (no corpse)
+ if(m_respawnTime > time(NULL)) // dead (no corpse)
objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),m_respawnTime);
else if(m_deathTimer > 0) // dead (corpse)
- objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),sGameTime.GetGameTime()+m_respawnDelay+m_deathTimer/IN_MILISECONDS);
+ objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),time(NULL)+m_respawnDelay+m_deathTimer/IN_MILISECONDS);
}
// this should not be called by petAI or
@@ -2078,10 +2062,10 @@ void Creature::AddCreatureSpellCooldown(uint32 spellid)
modOwner->ApplySpellMod(spellid, SPELLMOD_COOLDOWN, cooldown);
if(cooldown)
- _AddCreatureSpellCooldown(spellid, sGameTime.GetGameTime() + cooldown/IN_MILISECONDS);
+ _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/IN_MILISECONDS);
if(spellInfo->Category)
- _AddCreatureCategoryCooldown(spellInfo->Category, sGameTime.GetGameTime());
+ _AddCreatureCategoryCooldown(spellInfo->Category, time(NULL));
m_GlobalCooldown = spellInfo->StartRecoveryTime;
}
@@ -2097,13 +2081,13 @@ bool Creature::HasCategoryCooldown(uint32 spell_id) const
return true;
CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->Category);
- return(itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / IN_MILISECONDS)) > sGameTime.GetGameTime());
+ return(itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / IN_MILISECONDS)) > time(NULL));
}
bool Creature::HasSpellCooldown(uint32 spell_id) const
{
CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id);
- return (itr != m_CreatureSpellCooldowns.end() && itr->second > sGameTime.GetGameTime()) || HasCategoryCooldown(spell_id);
+ return (itr != m_CreatureSpellCooldowns.end() && itr->second > time(NULL)) || HasCategoryCooldown(spell_id);
}
bool Creature::HasSpell(uint32 spellID) const
@@ -2117,7 +2101,7 @@ bool Creature::HasSpell(uint32 spellID) const
time_t Creature::GetRespawnTimeEx() const
{
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
if(m_respawnTime > now) // dead (no corpse)
return m_respawnTime;
else if(m_deathTimer > 0) // dead (corpse)
@@ -2212,13 +2196,17 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
if(!vItem->maxcount)
return vItem->maxcount;
- VendorItemCounts::iterator itr = m_vendorItemCounts.find(vItem->item);
+ VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
+ for (; itr != m_vendorItemCounts.end(); ++itr)
+ if(itr->itemId==vItem->item)
+ break;
+
if(itr == m_vendorItemCounts.end())
return vItem->maxcount;
- VendorItemCount* vCount = itr->second;
+ VendorItemCount* vCount = &*itr;
- time_t ptime = sGameTime.GetGameTime();
+ time_t ptime = time(NULL);
if( vCount->lastIncrementTime + vItem->incrtime <= ptime )
{
@@ -2227,7 +2215,6 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
if((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount )
{
- delete itr->second;
m_vendorItemCounts.erase(itr);
return vItem->maxcount;
}
@@ -2244,17 +2231,21 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
if(!vItem->maxcount)
return 0;
- VendorItemCounts::iterator itr = m_vendorItemCounts.find(vItem->item);
+ VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
+ for (; itr != m_vendorItemCounts.end(); ++itr)
+ if(itr->itemId==vItem->item)
+ break;
+
if(itr == m_vendorItemCounts.end())
{
- uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0;
- m_vendorItemCounts[vItem->item] = new VendorItemCount(new_count);
+ int32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0;
+ m_vendorItemCounts.push_back(VendorItemCount(vItem->item,new_count));
return new_count;
}
- VendorItemCount* vCount = itr->second;
+ VendorItemCount* vCount = &*itr;
- time_t ptime = sGameTime.GetGameTime();
+ time_t ptime = time(NULL);
if( vCount->lastIncrementTime + vItem->incrtime <= ptime )
{
@@ -2267,7 +2258,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
vCount->count = vItem->maxcount;
}
- vCount->count = vCount->count > used_count ? vCount->count - used_count : 0;
+ vCount->count = vCount->count > used_count ? vCount->count-used_count : 0;
vCount->lastIncrementTime = ptime;
return vCount->count;
}
@@ -2331,6 +2322,3 @@ BaseHealthManaPair Creature::GenerateHealthMana()
{
return objmgr.GenerateCreatureStats(getLevel(), GetCreatureInfo());
}
-
-VendorItemCount::VendorItemCount() : count(0), lastIncrementTime(sGameTime.GetGameTime()) {}
-VendorItemCount::VendorItemCount(uint32 _count) : count(_count), lastIncrementTime(sGameTime.GetGameTime()) {}
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 7209388c032..6470af4bb71 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -28,7 +28,6 @@
#include "LootMgr.h"
#include "Database/DatabaseEnv.h"
#include "Cell.h"
-#include "TimeMgr.h"
#include <list>
@@ -319,50 +318,45 @@ struct VendorItem
uint32 ExtendedCost;
};
typedef std::vector<VendorItem*> VendorItemList;
-typedef std::map<uint32, uint8> ItemToSlotMap;
struct VendorItemData
{
VendorItemList m_items;
- ItemToSlotMap m_itemtoslot;
- VendorItem* GetItem(uint8 slot) const
+ VendorItem* GetItem(uint32 slot) const
{
- if(slot >= uint8(m_items.size()))
- return NULL;
+ if(slot>=m_items.size()) return NULL;
return m_items[slot];
}
-
bool Empty() const { return m_items.empty(); }
- uint8 GetItemCount() const { return uint8(m_items.size()); }
- void AddItem(uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, uint8 vendorslot)
+ uint8 GetItemCount() const { return m_items.size(); }
+ void AddItem( uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost)
{
m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
- m_itemtoslot[item] = vendorslot;
}
bool RemoveItem( uint32 item_id );
VendorItem const* FindItem(uint32 item_id) const;
- uint8 FindItemSlot(uint32 item_id) const;
+ size_t FindItemSlot(uint32 item_id) const;
void Clear()
{
for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
delete (*itr);
m_items.clear();
- m_itemtoslot.clear();
}
};
struct VendorItemCount
{
- VendorItemCount();
- VendorItemCount(uint32 _count);
+ explicit VendorItemCount(uint32 _item, uint32 _count)
+ : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
+ uint32 itemId;
uint32 count;
time_t lastIncrementTime;
};
-typedef std::map<uint32, VendorItemCount*> VendorItemCounts;
+typedef std::list<VendorItemCount> VendorItemCounts;
struct TrainerSpell
{
@@ -589,7 +583,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const;
- void SetRespawnTime(uint32 respawn);
+ void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
void Respawn(bool force = false);
void SaveRespawnTime();
diff --git a/src/game/DestinationHolder.h b/src/game/DestinationHolder.h
index 4e93d1a2754..e41ced5980a 100644
--- a/src/game/DestinationHolder.h
+++ b/src/game/DestinationHolder.h
@@ -22,7 +22,7 @@
#define TRINITY_DESTINATION_HOLDER_H
#include "Platform/Define.h"
-#include "TimeMgr.h"
+#include "Timer.h"
class WorldObject;
class Map;
diff --git a/src/game/DuelHandler.cpp b/src/game/DuelHandler.cpp
index 8da8787ab8b..d9854d900c8 100644
--- a/src/game/DuelHandler.cpp
+++ b/src/game/DuelHandler.cpp
@@ -25,7 +25,6 @@
#include "Opcodes.h"
#include "UpdateData.h"
#include "Player.h"
-#include "TimeMgr.h"
void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket)
{
@@ -48,7 +47,7 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket)
DEBUG_LOG("Player 1 is: %u (%s)", pl->GetGUIDLow(),pl->GetName());
DEBUG_LOG("Player 2 is: %u (%s)", plTarget->GetGUIDLow(),plTarget->GetName());
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
pl->duel->startTimer = now;
plTarget->duel->startTimer = now;
diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp
index 735ee67ae01..c48a0f3f892 100644
--- a/src/game/GameEventMgr.cpp
+++ b/src/game/GameEventMgr.cpp
@@ -30,7 +30,6 @@
#include "GossipDef.h"
#include "Player.h"
#include "BattleGroundMgr.h"
-#include "TimeMgr.h"
INSTANTIATE_SINGLETON_1(GameEventMgr);
@@ -41,7 +40,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const
default:
case GAMEEVENT_NORMAL:
{
- time_t currenttime = sGameTime.GetGameTime();
+ time_t currenttime = time(NULL);
// Get the event information
return mGameEvent[entry].start < currenttime
&& currenttime < mGameEvent[entry].end
@@ -58,7 +57,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const
// if inactive world event, check the prerequisite events
case GAMEEVENT_WORLD_INACTIVE:
{
- time_t currenttime = sGameTime.GetGameTime();
+ time_t currenttime = time(NULL);
for (std::set<uint16>::const_iterator itr = mGameEvent[entry].prerequisite_events.begin(); itr != mGameEvent[entry].prerequisite_events.end(); ++itr)
{
if( (mGameEvent[*itr].state != GAMEEVENT_WORLD_NEXTPHASE && mGameEvent[*itr].state != GAMEEVENT_WORLD_FINISHED) || // if prereq not in nextphase or finished state, then can't start this one
@@ -74,7 +73,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const
uint32 GameEventMgr::NextCheck(uint16 entry) const
{
- time_t currenttime = sGameTime.GetGameTime();
+ time_t currenttime = time(NULL);
// for NEXTPHASE state world events, return the delay to start the next event, so the followup event will be checked correctly
if ((mGameEvent[entry].state == GAMEEVENT_WORLD_NEXTPHASE || mGameEvent[entry].state == GAMEEVENT_WORLD_FINISHED) && mGameEvent[entry].nextstart >= currenttime)
@@ -129,7 +128,7 @@ bool GameEventMgr::StartEvent( uint16 event_id, bool overwrite )
ApplyNewEvent(event_id);
if(overwrite)
{
- mGameEvent[event_id].start = sGameTime.GetGameTime();
+ mGameEvent[event_id].start = time(NULL);
if(mGameEvent[event_id].end <= mGameEvent[event_id].start)
mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length;
}
@@ -169,7 +168,7 @@ void GameEventMgr::StopEvent( uint16 event_id, bool overwrite )
if(overwrite && !serverwide_evt)
{
- mGameEvent[event_id].start = sGameTime.GetGameTime() - mGameEvent[event_id].length * MINUTE;
+ mGameEvent[event_id].start = time(NULL) - mGameEvent[event_id].length * MINUTE;
if(mGameEvent[event_id].end <= mGameEvent[event_id].start)
mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length;
}
@@ -1046,7 +1045,7 @@ uint32 GameEventMgr::Initialize() // return the next e
uint32 GameEventMgr::Update() // return the next event delay in ms
{
- time_t currenttime = sGameTime.GetGameTime();
+ time_t currenttime = time(NULL);
uint32 nextEventDelay = max_ge_check_delay; // 1 day
uint32 calcDelay;
std::set<uint16> activate, deactivate;
@@ -1599,7 +1598,7 @@ bool GameEventMgr::CheckOneGameEventConditions(uint16 event_id)
// set the followup events' start time
if(!mGameEvent[event_id].nextstart)
{
- time_t currenttime = sGameTime.GetGameTime();
+ time_t currenttime = time(NULL);
mGameEvent[event_id].nextstart = currenttime + mGameEvent[event_id].length * 60;
}
return true;
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 1c9e80ee84d..e3794de8a8e 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -39,7 +39,6 @@
#include "Util.h"
#include "OutdoorPvPMgr.h"
#include "BattleGroundAV.h"
-#include "TimeMgr.h"
GameObject::GameObject() : WorldObject(), m_goValue(new GameObjectValue)
{
@@ -226,14 +225,14 @@ void GameObject::Update(uint32 /*p_time*/)
// Arming Time for GAMEOBJECT_TYPE_TRAP (6)
Unit* owner = GetOwner();
if (owner && owner->isInCombat())
- m_cooldownTime = sGameTime.GetGameTime() + GetGOInfo()->trap.startDelay;
+ m_cooldownTime = time(NULL) + GetGOInfo()->trap.startDelay;
m_lootState = GO_READY;
break;
}
case GAMEOBJECT_TYPE_FISHINGNODE:
{
// fishing code (bobber ready)
- if( sGameTime.GetGameTime() > m_respawnTime - FISHING_BOBBER_READY_TIME )
+ if( time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME )
{
// splash bobber (bobber ready now)
Unit* caster = GetOwner();
@@ -265,7 +264,7 @@ void GameObject::Update(uint32 /*p_time*/)
{
if (m_respawnTime > 0) // timer on
{
- if (m_respawnTime <= sGameTime.GetGameTime()) // timer expired
+ if (m_respawnTime <= time(NULL)) // timer expired
{
m_respawnTime = 0;
m_SkillupList.clear();
@@ -317,7 +316,7 @@ void GameObject::Update(uint32 /*p_time*/)
GameObjectInfo const* goInfo = GetGOInfo();
if(goInfo->type == GAMEOBJECT_TYPE_TRAP)
{
- if(m_cooldownTime >= sGameTime.GetGameTime())
+ if(m_cooldownTime >= time(NULL))
return;
// traps
@@ -371,7 +370,7 @@ void GameObject::Update(uint32 /*p_time*/)
if(goInfo->trap.spellId)
CastSpell(ok, goInfo->trap.spellId);
- m_cooldownTime = sGameTime.GetGameTime() + 4; // 4 seconds
+ m_cooldownTime = time(NULL) + 4; // 4 seconds
// count charges
//if(goInfo->trap.charges > 0)
@@ -407,7 +406,7 @@ void GameObject::Update(uint32 /*p_time*/)
{
case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON:
- if (GetGOInfo()->GetAutoCloseTime() && (m_cooldownTime < sGameTime.GetGameTime()))
+ if (GetGOInfo()->GetAutoCloseTime() && (m_cooldownTime < time(NULL)))
ResetDoorOrButton();
break;
default: break;
@@ -471,7 +470,7 @@ void GameObject::Update(uint32 /*p_time*/)
return;
}
- m_respawnTime = sGameTime.GetGameTime() + m_respawnDelayTime;
+ m_respawnTime = time(NULL) + m_respawnDelayTime;
// if option not set then object will be saved at grid unload
if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
@@ -652,7 +651,7 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
m_respawnTime = objmgr.GetGORespawnTime(m_DBTableGuid, map->GetInstanceId());
// ready to respawn
- if(m_respawnTime && m_respawnTime <= sGameTime.GetGameTime())
+ if(m_respawnTime && m_respawnTime <= time(NULL))
{
m_respawnTime = 0;
objmgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),0);
@@ -736,7 +735,7 @@ Unit* GameObject::GetOwner(bool inWorld) const
void GameObject::SaveRespawnTime()
{
- if(m_goData && m_goData->dbData && m_respawnTime > sGameTime.GetGameTime() && m_spawnedByDefault)
+ if(m_goData && m_goData->dbData && m_respawnTime > time(NULL) && m_spawnedByDefault)
objmgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),m_respawnTime);
}
@@ -792,26 +791,11 @@ bool GameObject::canDetectTrap(Player const* u, float distance) const
return distance < visibleDistance;
}
-time_t GameObject::GetRespawnTimeEx() const
-{
- time_t now = sGameTime.GetGameTime();
- if(m_respawnTime > now)
- return m_respawnTime;
- else
- return now;
-}
-
-void GameObject::SetRespawnTime(int32 respawn)
-{
- m_respawnTime = respawn > 0 ? sGameTime.GetGameTime() + respawn : 0;
- m_respawnDelayTime = respawn > 0 ? respawn : 0;
-}
-
void GameObject::Respawn()
{
if(m_spawnedByDefault && m_respawnTime > 0)
{
- m_respawnTime = sGameTime.GetGameTime();
+ m_respawnTime = time(NULL);
objmgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),0);
}
}
@@ -936,7 +920,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
SwitchDoorOrButton(true,alternative);
SetLootState(GO_ACTIVATED);
- m_cooldownTime = sGameTime.GetGameTime() + time_to_restore;
+ m_cooldownTime = time(NULL) + time_to_restore;
}
void GameObject::SetGoArtKit(uint8 kit)
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index b6efbecd690..358af95a9be 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -25,7 +25,6 @@
#include "SharedDefines.h"
#include "Object.h"
#include "LootMgr.h"
-#include "TimeMgr.h"
#include "Database/DatabaseEnv.h"
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
@@ -641,10 +640,20 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
uint32 GetSpellId() const { return m_spellId;}
time_t GetRespawnTime() const { return m_respawnTime; }
- time_t GetRespawnTimeEx() const;
-
- void SetRespawnTime(int32 respawn);
+ time_t GetRespawnTimeEx() const
+ {
+ time_t now = time(NULL);
+ if(m_respawnTime > now)
+ return m_respawnTime;
+ else
+ return now;
+ }
+ void SetRespawnTime(int32 respawn)
+ {
+ m_respawnTime = respawn > 0 ? time(NULL) + respawn : 0;
+ m_respawnDelayTime = respawn > 0 ? respawn : 0;
+ }
void Respawn();
bool isSpawned() const
{
diff --git a/src/game/GuardAI.h b/src/game/GuardAI.h
index 70b5c5bf3de..db1bfe0229d 100644
--- a/src/game/GuardAI.h
+++ b/src/game/GuardAI.h
@@ -22,7 +22,7 @@
#define TRINITY_GUARDAI_H
#include "CreatureAI.h"
-#include "TimeMgr.h"
+#include "Timer.h"
class Creature;
diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp
index b0d09627c17..9359fbf5487 100644
--- a/src/game/Guild.cpp
+++ b/src/game/Guild.cpp
@@ -30,7 +30,6 @@
#include "Util.h"
#include "Language.h"
#include "World.h"
-#include "TimeMgr.h"
#include "Config/ConfigEnv.h"
Guild::Guild()
@@ -169,7 +168,7 @@ bool Guild::AddMember(uint64 plGuid, uint32 plRank)
newmember.RankId = plRank;
newmember.OFFnote = (std::string)"";
newmember.Pnote = (std::string)"";
- newmember.LogoutTime = sGameTime.GetGameTime();
+ newmember.LogoutTime = time(NULL);
newmember.BankResetTimeMoney = 0; // this will force update at first query
for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
newmember.BankResetTimeTab[i] = 0;
@@ -773,7 +772,7 @@ void Guild::Roster(WorldSession *session /*= NULL*/)
data << uint8(itr->second.Class);
data << uint8(0); // new 2.4.0
data << uint32(itr->second.ZoneId);
- data << float(float(sGameTime.GetGameTime()-itr->second.LogoutTime) / DAY);
+ data << float(float(time(NULL)-itr->second.LogoutTime) / DAY);
data << itr->second.Pnote;
data << itr->second.OFFnote;
}
@@ -828,7 +827,7 @@ void Guild::UpdateLogoutTime(uint64 guid)
if (itr == members.end())
return;
- itr->second.LogoutTime = sGameTime.GetGameTime();
+ itr->second.LogoutTime = time(NULL);
if (m_OnlineMembers > 0)
--m_OnlineMembers;
@@ -866,7 +865,7 @@ void Guild::DisplayGuildEventLog(WorldSession *session)
if (itr->EventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || itr->EventType == GUILD_EVENT_LOG_DEMOTE_PLAYER)
data << uint8(itr->NewRank);
// Event timestamp
- data << uint32(sGameTime.GetGameTime()-itr->TimeStamp);
+ data << uint32(time(NULL)-itr->TimeStamp);
}
session->SendPacket(&data);
sLog.outDebug("WORLD: Sent (MSG_GUILD_EVENT_LOG_QUERY)");
@@ -934,7 +933,7 @@ void Guild::LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid
NewEvent.PlayerGuid1 = PlayerGuid1;
NewEvent.PlayerGuid2 = PlayerGuid2;
NewEvent.NewRank = NewRank;
- NewEvent.TimeStamp = uint32(sGameTime.GetGameTime());
+ NewEvent.TimeStamp = uint32(time(NULL));
// Count new LogGuid
m_GuildEventLogNextGuid = (m_GuildEventLogNextGuid + 1) % sWorld.getConfig(CONFIG_GUILD_EVENT_LOG_COUNT);
// Check max records limit
@@ -1347,7 +1346,7 @@ uint32 Guild::GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId)
if ((GetBankRights(itr->second.RankId,TabId) & GUILD_BANK_RIGHT_VIEW_TAB) != GUILD_BANK_RIGHT_VIEW_TAB)
return 0;
- uint32 curTime = uint32(sGameTime.GetGameTime()/MINUTE);
+ uint32 curTime = uint32(time(NULL)/MINUTE);
if (curTime - itr->second.BankResetTimeTab[TabId] >= 24*HOUR/MINUTE)
{
itr->second.BankResetTimeTab[TabId] = curTime;
@@ -1367,7 +1366,7 @@ uint32 Guild::GetMemberMoneyWithdrawRem(uint32 LowGuid)
if (itr->second.RankId == GR_GUILDMASTER)
return WITHDRAW_MONEY_UNLIMITED;
- uint32 curTime = uint32(sGameTime.GetGameTime()/MINUTE); // minutes
+ uint32 curTime = uint32(time(NULL)/MINUTE); // minutes
// 24 hours
if (curTime > itr->second.BankResetTimeMoney + 24*HOUR/MINUTE)
{
@@ -1601,7 +1600,7 @@ void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId)
if (itr->EventType == GUILD_BANK_LOG_MOVE_ITEM || itr->EventType == GUILD_BANK_LOG_MOVE_ITEM2)
data << uint8(itr->DestTabId); // moved tab
}
- data << uint32(sGameTime.GetGameTime() - itr->TimeStamp);
+ data << uint32(time(NULL) - itr->TimeStamp);
}
session->SendPacket(&data);
}
@@ -1631,7 +1630,7 @@ void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId)
if (itr->EventType == GUILD_BANK_LOG_MOVE_ITEM || itr->EventType == GUILD_BANK_LOG_MOVE_ITEM2)
data << uint8(itr->DestTabId); // moved tab
}
- data << uint32(sGameTime.GetGameTime() - itr->TimeStamp);
+ data << uint32(time(NULL) - itr->TimeStamp);
}
session->SendPacket(&data);
}
@@ -1647,7 +1646,7 @@ void Guild::LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uin
NewEvent.ItemOrMoney = ItemOrMoney;
NewEvent.ItemStackCount = ItemStackCount;
NewEvent.DestTabId = DestTabId;
- NewEvent.TimeStamp = uint32(sGameTime.GetGameTime());
+ NewEvent.TimeStamp = uint32(time(NULL));
//add new event to the end of event list
uint32 currentTabId = TabId;
diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp
index 3c432d6cba6..a60df7c4f91 100644
--- a/src/game/InstanceSaveMgr.cpp
+++ b/src/game/InstanceSaveMgr.cpp
@@ -31,6 +31,7 @@
#include "MapManager.h"
#include "MapInstanced.h"
#include "InstanceSaveMgr.h"
+#include "Timer.h"
#include "GridNotifiersImpl.h"
#include "Config/ConfigEnv.h"
#include "Transports.h"
@@ -38,7 +39,6 @@
#include "World.h"
#include "Group.h"
#include "InstanceData.h"
-#include "TimeMgr.h"
#include "ProgressBar.h"
#include "Policies/Singleton.h"
#include "Policies/SingletonImp.h"
@@ -109,7 +109,7 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance
resetTime = GetResetTimeFor(mapId,difficulty);
else
{
- resetTime = sGameTime.GetGameTime() + 2 * HOUR;
+ resetTime = time(NULL) + 2 * HOUR;
// normally this will be removed soon after in InstanceMap::Add, prevent error
ScheduleReset(true, resetTime, InstResetEvent(0, mapId, difficulty, instanceId));
}
@@ -259,7 +259,7 @@ void InstanceSaveManager::_DelHelper(DatabaseType &db, const char *fields, const
void InstanceSaveManager::CleanupInstances()
{
- uint64 now = (uint64)sGameTime.GetGameTime();
+ uint64 now = (uint64)time(NULL);
barGoLink bar(2);
bar.step();
@@ -406,7 +406,7 @@ void InstanceSaveManager::PackInstances()
void InstanceSaveManager::LoadResetTimes()
{
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
time_t today = (now / DAY) * DAY;
// NOTE: Use DirectPExecute for tables that will be queried later
@@ -571,7 +571,7 @@ void InstanceSaveManager::ScheduleReset(bool add, time_t time, InstResetEvent ev
void InstanceSaveManager::Update()
{
- time_t now = sGameTime.GetGameTime(), t;
+ time_t now = time(NULL), t;
while(!m_resetTimeQueue.empty() && (t = m_resetTimeQueue.begin()->first) < now)
{
InstResetEvent &event = m_resetTimeQueue.begin()->second;
@@ -643,7 +643,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
if (!mapEntry->Instanceable())
return;
- uint64 now = (uint64)sGameTime.GetGameTime();
+ uint64 now = (uint64)time(NULL);
if(!warn)
{
diff --git a/src/game/Level0.cpp b/src/game/Level0.cpp
index 820478bee8e..cdfa3517bfa 100644
--- a/src/game/Level0.cpp
+++ b/src/game/Level0.cpp
@@ -30,7 +30,6 @@
#include "SystemConfig.h"
#include "revision.h"
#include "Util.h"
-#include "TimeMgr.h"
bool ChatHandler::HandleHelpCommand(const char* args)
{
@@ -100,14 +99,22 @@ bool ChatHandler::HandleServerInfoCommand(const char* /*args*/)
uint32 queuedClientsNum = sWorld.GetQueuedSessionCount();
uint32 maxActiveClientsNum = sWorld.GetMaxActiveSessionCount();
uint32 maxQueuedClientsNum = sWorld.GetMaxQueuedSessionCount();
- std::string str = secsToTimeString(sGameTime.GetUptime());
+ std::string uptime = secsToTimeString(sWorld.GetUptime());
uint32 updateTime = sWorld.GetUpdateTime();
PSendSysMessage(_FULLVERSION);
-
+ //if(m_session)
+ // full = _FULLVERSION(REVISION_DATE,REVISION_TIME,"|cffffffff|Hurl:" REVISION_ID "|h" REVISION_ID "|h|r");
+ //else
+ // full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_ID);
+
+ //SendSysMessage(full);
+ //PSendSysMessage(LANG_USING_SCRIPT_LIB,sWorld.GetScriptsVersion());
+ //PSendSysMessage(LANG_USING_WORLD_DB,sWorld.GetDBVersion());
+ //PSendSysMessage(LANG_USING_EVENT_AI,sWorld.GetCreatureEventAIVersion());
PSendSysMessage(LANG_CONNECTED_PLAYERS, PlayersNum, MaxPlayersNum);
PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
- PSendSysMessage(LANG_UPTIME, str.c_str());
+ PSendSysMessage(LANG_UPTIME, uptime.c_str());
PSendSysMessage("Update time diff: %u.", updateTime);
return true;
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index 106c573dc35..dc9d84bf4c8 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -42,7 +42,7 @@
#include "GlobalEvents.h"
#include "OutdoorPvPWG.h"
#include "OutdoorPvPMgr.h"
-#include "TimeMgr.h"
+
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
#include "CreatureGroups.h"
@@ -79,7 +79,7 @@ bool ChatHandler::HandleMuteCommand(const char* args)
if(HasLowerSecurity (target,target_guid,true))
return false;
- time_t mutetime = sGameTime.GetGameTime() + notspeaktime*60;
+ time_t mutetime = time(NULL) + notspeaktime*60;
if (target)
target->GetSession()->m_muteTime = mutetime;
@@ -536,7 +536,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(const char* args)
if(target)
{
- int32 curRespawnDelay = target->GetRespawnTimeEx()-sGameTime.GetGameTime();
+ int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL);
if(curRespawnDelay < 0)
curRespawnDelay = 0;
@@ -3502,8 +3502,8 @@ bool ChatHandler::HandleEventInfoCommand(const char* args)
std::string endTimeStr = TimeToTimestampStr(eventData.end);
uint32 delay = gameeventmgr.NextCheck(event_id);
- time_t nextTime = sGameTime.GetGameTime()+delay;
- std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(sGameTime.GetGameTime()+delay) : "-";
+ time_t nextTime = time(NULL)+delay;
+ std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-";
std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE);
std::string lengthStr = secsToTimeString(eventData.length * MINUTE);
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index 854ccc7e67a..540bd0d8586 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -55,7 +55,6 @@
#include "AuctionHouseBot.h"
#include "CreatureEventAIMgr.h"
#include "DBCEnums.h"
-#include "TimeMgr.h"
bool ChatHandler::HandleAHBotOptionsCommand(const char *args)
{
@@ -4615,7 +4614,7 @@ bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/)
uint32 Entry = target->GetEntry();
CreatureInfo const* cInfo = target->GetCreatureInfo();
- int32 curRespawnDelay = target->GetRespawnTimeEx()-sGameTime.GetGameTime();
+ int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL);
if(curRespawnDelay < 0)
curRespawnDelay = 0;
std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true);
@@ -5975,7 +5974,7 @@ bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname)
time_t unbandate = time_t(fields[3].GetUInt64());
bool active = false;
- if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= sGameTime.GetGameTime()) )
+ if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) )
active = true;
bool permanent = (fields[1].GetUInt64() == (uint64)0);
std::string bantime = permanent?GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true);
@@ -6825,7 +6824,7 @@ bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/)
for (Player::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr)
{
InstanceSave *save = itr->second.save;
- std::string timeleft = GetTimeString(save->GetResetTime() - sGameTime.GetGameTime());
+ std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL));
PSendSysMessage("map: %d inst: %d perm: %s diff: %d canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
counter++;
}
@@ -6841,7 +6840,7 @@ bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/)
for (Group::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr)
{
InstanceSave *save = itr->second.save;
- std::string timeleft = GetTimeString(save->GetResetTime() - sGameTime.GetGameTime());
+ std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL));
PSendSysMessage("map: %d inst: %d perm: %s diff: %d canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); counter++;
}
}
@@ -6870,7 +6869,7 @@ bool ChatHandler::HandleInstanceUnbindCommand(const char *args)
if(itr->first != player->GetMapId())
{
InstanceSave *save = itr->second.save;
- std::string timeleft = GetTimeString(save->GetResetTime() - sGameTime.GetGameTime());
+ std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL));
PSendSysMessage("unbinding map: %d inst: %d perm: %s diff: %d canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
player->UnbindInstance(itr, Difficulty(i));
counter++;
diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp
index d4c4d574591..961a12332e9 100644
--- a/src/game/Mail.cpp
+++ b/src/game/Mail.cpp
@@ -34,7 +34,6 @@
#include "BattleGroundMgr.h"
#include "Item.h"
#include "AuctionHouseMgr.h"
-#include "TimeMgr.h"
enum MailShowFlags
{
@@ -284,7 +283,7 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data )
if (pl->unReadMails)
--pl->unReadMails;
m->checked = m->checked | MAIL_CHECK_MASK_READ;
- // m->expire_time = sGameTime.GetGameTime() + (30 * DAY); // Expire time do not change at reading mail
+ // m->expire_time = time(NULL) + (30 * DAY); // Expire time do not change at reading mail
pl->m_mailsUpdated = true;
m->state = MAIL_STATE_CHANGED;
}
@@ -332,7 +331,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data )
Player *pl = _player;
Mail *m = pl->GetMail(mailId);
- if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > sGameTime.GetGameTime())
+ if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return;
@@ -394,7 +393,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
Player* pl = _player;
Mail* m = pl->GetMail(mailId);
- if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > sGameTime.GetGameTime())
+ if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
@@ -487,7 +486,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data )
Player *pl = _player;
Mail* m = pl->GetMail(mailId);
- if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > sGameTime.GetGameTime())
+ if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
pl->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
@@ -531,7 +530,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
WorldPacket data(SMSG_MAIL_LIST_RESULT, (200)); // guess size
data << uint32(0); // real mail's count
data << uint8(0); // mail's count
- time_t cur_time = sGameTime.GetGameTime();
+ time_t cur_time = time(NULL);
for (PlayerMails::iterator itr = pl->GetMailBegin(); itr != pl->GetMailEnd(); ++itr)
{
@@ -589,7 +588,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
data << uint32((*itr)->stationery); // stationery (Stationery.dbc)
data << uint32((*itr)->money); // Gold
data << uint32(show_flags); // unknown, 0x4 - auction, 0x10 - normal
- data << float(((*itr)->expire_time-sGameTime.GetGameTime())/DAY); // Time
+ data << float(((*itr)->expire_time-time(NULL))/DAY); // Time
data << uint32((*itr)->mailTemplateId); // mail template (MailTemplate.dbc)
data << (*itr)->subject; // Subject string - once 00, when mail type = 3
data << uint8(item_count); // client limit is 0x10
@@ -675,7 +674,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
Player *pl = _player;
Mail* m = pl->GetMail(mailId);
- if (!m || !m->itemTextId && !m->mailTemplateId || m->state == MAIL_STATE_DELETED || m->deliver_time > sGameTime.GetGameTime())
+ if (!m || !m->itemTextId && !m->mailTemplateId || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
return;
@@ -741,7 +740,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/ )
data << uint32(0); // count
uint32 count = 0;
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
for (PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr)
{
Mail *m = (*itr);
@@ -930,7 +929,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende
return;
}
- time_t deliver_time = sGameTime.GetGameTime() + deliver_delay;
+ time_t deliver_time = time(NULL) + deliver_delay;
//expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour
uint32 expire_delay;
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index f419e21364a..8e72be7ad5e 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -3135,7 +3135,7 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
sa.ownerGUID = ownerGUID;
sa.script = &iter->second;
- m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sGameTime.GetGameTime() + iter->first), sa));
+ m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld.GetGameTime() + iter->first), sa));
if (iter->first == 0)
immedScript = true;
@@ -3165,7 +3165,7 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou
sa.ownerGUID = ownerGUID;
sa.script = &script;
- m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sGameTime.GetGameTime() + delay), sa));
+ m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld.GetGameTime() + delay), sa));
sWorld.IncreaseScheduledScriptsCount();
@@ -3187,7 +3187,7 @@ void Map::ScriptsProcess()
///- Process overdue queued scripts
std::multimap<time_t, ScriptAction>::iterator iter = m_scriptSchedule.begin();
// ok as multimap is a *sorted* associative container
- while (!m_scriptSchedule.empty() && (iter->first <= sGameTime.GetGameTime()))
+ while (!m_scriptSchedule.empty() && (iter->first <= sWorld.GetGameTime()))
{
ScriptAction const& step = iter->second;
diff --git a/src/game/Map.h b/src/game/Map.h
index 4e2309768cb..494618baa8e 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -29,7 +29,7 @@
#include "DBCStructure.h"
#include "GridDefines.h"
#include "Cell.h"
-#include "TimeMgr.h"
+#include "Timer.h"
#include "SharedDefines.h"
#include "GameSystem/GridRefManager.h"
#include "MapRefManager.h"
diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index 2608f60dcb8..c9692b2ebef 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -48,7 +48,6 @@
#include "Vehicle.h"
#include "CreatureAI.h"
#include "DBCEnums.h"
-#include "TimeMgr.h"
void WorldSession::HandleRepopRequestOpcode( WorldPacket & recv_data )
{
@@ -383,7 +382,7 @@ void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ )
data << uint32(0);
data << uint8(0);
SendPacket( &data );
- LogoutRequest(sGameTime.GetGameTime());
+ LogoutRequest(time(NULL));
}
void WorldSession::HandlePlayerLogoutOpcode( WorldPacket & /*recv_data*/ )
@@ -443,7 +442,7 @@ void WorldSession::HandleTogglePvP( WorldPacket & recv_data )
else
{
if(!GetPlayer()->pvpInfo.inHostileArea && GetPlayer()->IsPvP())
- GetPlayer()->pvpInfo.endTimer = sGameTime.GetGameTime(); // start toggle-off
+ GetPlayer()->pvpInfo.endTimer = time(NULL); // start toggle-off
}
//if(OutdoorPvP * pvp = _player->GetOutdoorPvP())
@@ -734,7 +733,7 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data)
return;
// prevent resurrect before 30-sec delay after body release not finished
- if(corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP) > sGameTime.GetGameTime())
+ if(corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP) > time(NULL))
return;
if (!corpse->IsWithinDistInMap(GetPlayer(), CORPSE_RECLAIM_RADIUS, true))
@@ -868,7 +867,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
{
// set resting flag we are in the inn
GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
- GetPlayer()->InnEnter(sGameTime.GetGameTime(), atEntry->mapid, atEntry->x, atEntry->y, atEntry->z);
+ GetPlayer()->InnEnter(time(NULL), atEntry->mapid, atEntry->x, atEntry->y, atEntry->z);
GetPlayer()->SetRestType(REST_TYPE_IN_TAVERN);
if(sWorld.IsFFAPvPRealm())
@@ -1622,6 +1621,6 @@ void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket& recv_data)
sLog.outDebug("WORLD: CMSG_WORLD_STATE_UI_TIMER_UPDATE");
WorldPacket data(SMSG_WORLD_STATE_UI_TIMER_UPDATE, 4);
- data << uint32(sGameTime.GetGameTime());
+ data << uint32(time(NULL));
SendPacket(&data);
}
diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index 7942d0800ca..2fc1e5a9125 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -33,7 +33,6 @@
#include "WaypointMovementGenerator.h"
#include "InstanceSaveMgr.h"
#include "ObjectMgr.h"
-#include "TimeMgr.h"
void WorldSession::HandleMoveWorldportAckOpcode( WorldPacket & /*recv_data*/ )
{
@@ -155,7 +154,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
Difficulty diff = GetPlayer()->GetDifficulty(mEntry->IsRaid());
if (uint32 timeReset = sInstanceSaveManager.GetResetTimeFor(GetPlayer()->GetMapId(),diff))
{
- uint32 timeleft = timeReset - sGameTime.GetGameTime();
+ uint32 timeleft = timeReset - time(NULL);
GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), diff, timeleft);
}
}
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index ba52e8ff85c..01867c7cffc 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -46,7 +46,6 @@
#include "WaypointManager.h"
#include "InstanceData.h" //for condition_instance_data
#include "GossipDef.h"
-#include "TimeMgr.h"
INSTANTIATE_SINGLETON_1(ObjectMgr);
@@ -5025,7 +5024,7 @@ void ObjectMgr::LoadNpcTextLocales()
//not very fast function but it is called only once a day, or on starting-up
void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
{
- time_t basetime = sGameTime.GetGameTime();
+ time_t basetime = time(NULL);
sLog.outDebug("Returning mails current time: hour: %d, minute: %d, second: %d ", localtime(&basetime)->tm_hour, localtime(&basetime)->tm_min, localtime(&basetime)->tm_sec);
//delete all old mails without item and without body immediately, if starting server
if (!serverUp)
@@ -8250,9 +8249,7 @@ void ObjectMgr::LoadVendors()
VendorItemData& vList = m_mCacheVendorItemMap[entry];
- uint8 vendorslot = vList.GetItemCount();
-
- vList.AddItem(item_id,maxcount,incrtime,ExtendedCost,vendorslot);
+ vList.AddItem(item_id,maxcount,incrtime,ExtendedCost);
++count;
} while (result->NextRow());
@@ -8523,8 +8520,7 @@ void ObjectMgr::LoadGossipMenuItems()
void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, int32 maxcount, uint32 incrtime, uint32 extendedcost, bool savetodb)
{
VendorItemData& vList = m_mCacheVendorItemMap[entry];
- uint8 vendorslot = vList.GetItemCount();
- vList.AddItem(item,maxcount,incrtime,extendedcost,vendorslot);
+ vList.AddItem(item,maxcount,incrtime,extendedcost);
if(savetodb) WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",entry, item, maxcount,incrtime,extendedcost);
}
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index 3c8a3b3510f..58a561c3a6f 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -30,7 +30,6 @@
#include "CreatureAI.h"
#include "Unit.h"
#include "Util.h"
-#include "TimeMgr.h"
char const* petTypeSuffix[MAX_PET_TYPE] =
{
@@ -244,7 +243,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
break;
}
- SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, sGameTime.GetGameTime());
+ SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32());
SetCreatorGUID(owner->GetGUID());
@@ -302,7 +301,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
m_resetTalentsTime = fields[16].GetUInt64();
InitTalentForLevel(); // set original talents points before spell loading
- uint32 timediff = (sGameTime.GetGameTime() - fields[14].GetUInt32());
+ uint32 timediff = (time(NULL) - fields[14].GetUInt32());
_LoadAuras(timediff);
// load action bar, if data broken will fill later by default spells.
@@ -443,7 +442,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
};
ss << "', "
- << sGameTime.GetGameTime() << ", "
+ << time(NULL) << ", "
<< uint32(m_resetTalentsCost) << ", "
<< uint64(m_resetTalentsTime) << ", "
<< GetUInt32Value(UNIT_CREATED_BY_SPELL) << ", "
@@ -1035,7 +1034,7 @@ void Pet::_LoadSpellCooldowns()
if(result)
{
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = time(NULL);
WorldPacket data(SMSG_SPELL_COOLDOWN, (8+1+result->GetRowCount()*8));
data << GetGUID();
@@ -1078,7 +1077,7 @@ void Pet::_SaveSpellCooldowns()
{
CharacterDatabase.PExecute("DELETE FROM pet_spell_cooldown WHERE guid = '%u'", m_charmInfo->GetPetNumber());
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = time(NULL);
// remove oudated and save active
for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();)
@@ -1593,7 +1592,7 @@ bool Pet::resetTalents(bool no_cost)
player->ModifyMoney(-(int32)cost);
m_resetTalentsCost = cost;
- m_resetTalentsTime = sGameTime.GetGameTime();
+ m_resetTalentsTime = time(NULL);
}
if (!m_loading)
player->PetSpellInitialize();
@@ -1704,7 +1703,7 @@ void Pet::InitTalentForLevel()
uint32 Pet::resetTalentsCost() const
{
- uint32 days = (sGameTime.GetGameTime() - m_resetTalentsTime)/DAY;
+ uint32 days = (sWorld.GetGameTime() - m_resetTalentsTime)/DAY;
// The first time reset costs 10 silver; after 1 day cost is reset to 10 silver
if (m_resetTalentsCost < 10*SILVER || days > 0)
diff --git a/src/game/PetAI.h b/src/game/PetAI.h
index 4e47cd9dffe..226aa493202 100644
--- a/src/game/PetAI.h
+++ b/src/game/PetAI.h
@@ -22,7 +22,7 @@
#define TRINITY_PETAI_H
#include "CreatureAI.h"
-#include "TimeMgr.h"
+#include "Timer.h"
class Creature;
class Spell;
diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp
index 05c5c35bda5..ee8c02dfb43 100644
--- a/src/game/PetHandler.cpp
+++ b/src/game/PetHandler.cpp
@@ -31,7 +31,6 @@
#include "Util.h"
#include "Pet.h"
#include "World.h"
-#include "TimeMgr.h"
void WorldSession::HandlePetAction( WorldPacket & recv_data )
{
@@ -558,7 +557,7 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data )
CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
CharacterDatabase.CommitTransaction();
- pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, sGameTime.GetGameTime());
+ pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
}
void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 32ea3eb8374..d578a243a01 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -65,7 +65,6 @@
#include "GameEventMgr.h"
#include "AchievementMgr.h"
#include "SpellAuras.h"
-#include "TimeMgr.h"
#include <cmath>
@@ -386,7 +385,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
m_bgBattleGroundQueueID[j].invitedToInstance = 0;
}
- m_logintime = sGameTime.GetGameTime();
+ m_logintime = time(NULL);
m_Last_tick = m_logintime;
m_WeaponProficiency = 0;
m_ArmorProficiency = 0;
@@ -462,7 +461,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
m_baseHealthRegen = 0;
// Honor System
- m_lastHonorUpdateTime = sGameTime.GetGameTime();
+ m_lastHonorUpdateTime = time(NULL);
// Player summoning
m_summon_expire = 0;
@@ -697,7 +696,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
}
// Played time
- m_Last_tick = sGameTime.GetGameTime();
+ m_Last_tick = time(NULL);
m_Played_time[PLAYED_TIME_TOTAL] = 0;
m_Played_time[PLAYED_TIME_LEVEL] = 0;
@@ -1136,7 +1135,7 @@ void Player::Update( uint32 p_time )
return;
// undelivered mail
- if (m_nextMailDelivereTime && m_nextMailDelivereTime <= sGameTime.GetGameTime())
+ if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL))
{
SendNewMail();
++unReadMails;
@@ -1162,7 +1161,7 @@ void Player::Update( uint32 p_time )
Unit::Update(p_time);
SetCanDelayTeleport(false);
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
UpdatePvPFlag(now);
@@ -1280,13 +1279,13 @@ void Player::Update( uint32 p_time )
{
if (roll_chance_i(3) && GetTimeInnEnter() > 0) // freeze update
{
- int time_inn = sGameTime.GetGameTime()-GetTimeInnEnter();
+ int time_inn = time(NULL)-GetTimeInnEnter();
if (time_inn >= 10) // freeze update
{
float bubble = 0.125*sWorld.getRate(RATE_REST_INGAME);
// speed collect rest bonus (section/in hour)
SetRestBonus(GetRestBonus()+ time_inn*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble);
- UpdateInnerTime(sGameTime.GetGameTime());
+ UpdateInnerTime(time(NULL));
}
}
}
@@ -2781,7 +2780,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
void Player::SendInitialSpells()
{
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = time(NULL);
time_t infTime = curTime + infinityCooldownDelayCheck;
uint16 spellCount = 0;
@@ -2889,7 +2888,7 @@ void Player::UpdateNextMailTimeAndUnreads()
{
// calculate next delivery time (min. from non-delivered mails
// and recalculate unReadMail
- time_t cTime = sGameTime.GetGameTime();
+ time_t cTime = time(NULL);
m_nextMailDelivereTime = 0;
unReadMails = 0;
for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
@@ -2906,7 +2905,7 @@ void Player::UpdateNextMailTimeAndUnreads()
void Player::AddNewMailDeliverTime(time_t deliver_time)
{
- if(deliver_time <= sGameTime.GetGameTime()) // ready now
+ if(deliver_time <= time(NULL)) // ready now
{
++unReadMails;
SendNewMail();
@@ -3674,7 +3673,7 @@ void Player::_LoadSpellCooldowns(QueryResult *result)
if (result)
{
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = time(NULL);
do
{
@@ -3708,7 +3707,7 @@ void Player::_SaveSpellCooldowns()
{
CharacterDatabase.PExecute("DELETE FROM character_spell_cooldown WHERE guid = '%u'", GetGUIDLow());
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = time(NULL);
time_t infTime = curTime + infinityCooldownDelayCheck;
bool first_round = true;
@@ -3754,7 +3753,7 @@ uint32 Player::resetTalentsCost() const
return 10*GOLD;
else
{
- uint32 months = (sGameTime.GetGameTime() - m_resetTalentsTime)/MONTH;
+ uint32 months = (sWorld.GetGameTime() - m_resetTalentsTime)/MONTH;
if(months > 0)
{
// This cost will be reduced by a rate of 5 gold per month
@@ -3847,7 +3846,7 @@ bool Player::resetTalents(bool no_cost)
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, 1);
m_resetTalentsCost = cost;
- m_resetTalentsTime = sGameTime.GetGameTime();
+ m_resetTalentsTime = time(NULL);
}
//FIXME: remove pet before or after unlearn spells? for now after unlearn to allow removing of talent related, pet affecting auras
@@ -4381,7 +4380,7 @@ void Player::SendDelayResponse(const uint32 ml_seconds)
{
//FIXME: is this delay time arg really need? 50msec by default in code
WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 );
- data << (uint32)sGameTime.GetGameTime();
+ data << (uint32)time(NULL);
data << (uint32)0;
GetSession()->SendPacket( &data );
}
@@ -6287,8 +6286,8 @@ void Player::RewardReputation(Quest const *pQuest)
void Player::UpdateHonorFields()
{
/// called when rewarding honor and at each save
- uint64 now = sGameTime.GetGameTime();
- uint64 today = uint64(sGameTime.GetGameTime() / DAY) * DAY;
+ uint64 now = time(NULL);
+ uint64 today = uint64(time(NULL) / DAY) * DAY;
if(m_lastHonorUpdateTime < today)
{
@@ -6340,7 +6339,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt
uint64 victim_guid = 0;
uint32 victim_rank = 0;
uint32 rank_diff = 0;
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
// need call before fields update to have chance move yesterday data to appropriate fields before today data change.
UpdateHonorFields();
@@ -12053,7 +12052,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem )
sLog.outDebug( "STORAGE: AddItemToBuyBackSlot item = %u, slot = %u", pItem->GetEntry(), slot);
m_items[slot] = pItem;
- time_t base = sGameTime.GetGameTime();
+ time_t base = time(NULL);
uint32 etime = uint32(base - m_logintime + (30 * 3600));
uint32 eslot = slot - BUYBACK_SLOT_START;
@@ -13576,7 +13575,7 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver )
AddTimedQuest( quest_id );
questStatusData.m_timer = limittime * IN_MILISECONDS;
- qtime = static_cast<uint32>(sGameTime.GetGameTime()) + limittime;
+ qtime = static_cast<uint32>(time(NULL)) + limittime;
}
else
questStatusData.m_timer = 0;
@@ -15547,7 +15546,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
SaveRecallPosition();
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
time_t logoutTime = time_t(fields[23].GetUInt64());
// since last logout (in seconds)
@@ -16288,10 +16287,10 @@ void Player::_LoadQuestStatus(QueryResult *result)
{
AddTimedQuest(quest_id);
- if (quest_time <= sGameTime.GetGameTime())
+ if (quest_time <= sWorld.GetGameTime())
questStatusData.m_timer = 1;
else
- questStatusData.m_timer = (quest_time - sGameTime.GetGameTime()) * IN_MILISECONDS;
+ questStatusData.m_timer = (quest_time - sWorld.GetGameTime()) * IN_MILISECONDS;
}
else
quest_time = 0;
@@ -16589,7 +16588,7 @@ void Player::SendRaidInfo()
size_t p_counter = data.wpos();
data << uint32(counter); // placeholder
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
@@ -16912,7 +16911,7 @@ void Player::SaveToDB()
ss << m_Played_time[PLAYED_TIME_LEVEL] << ", ";
ss << finiteAlways(m_rest_bonus) << ", ";
- ss << (uint64)sGameTime.GetGameTime() << ", ";
+ ss << (uint64)time(NULL) << ", ";
ss << (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0) << ", ";
//save, far from tavern/city
//save, but in tavern/city
@@ -17181,11 +17180,11 @@ void Player::_SaveQuestStatus()
case QUEST_NEW :
CharacterDatabase.PExecute("INSERT INTO character_queststatus (guid,quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4) "
"VALUES ('%u', '%u', '%u', '%u', '%u', '" UI64FMTD "', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')",
- GetGUIDLow(), i->first, i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / IN_MILISECONDS+ sGameTime.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3]);
+ GetGUIDLow(), i->first, i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / IN_MILISECONDS+ sWorld.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3]);
break;
case QUEST_CHANGED :
CharacterDatabase.PExecute("UPDATE character_queststatus SET status = '%u',rewarded = '%u',explored = '%u',timer = '" UI64FMTD "',mobcount1 = '%u',mobcount2 = '%u',mobcount3 = '%u',mobcount4 = '%u',itemcount1 = '%u',itemcount2 = '%u',itemcount3 = '%u',itemcount4 = '%u' WHERE guid = '%u' AND quest = '%u' ",
- i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / IN_MILISECONDS + sGameTime.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3], GetGUIDLow(), i->first );
+ i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / IN_MILISECONDS + sWorld.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3], GetGUIDLow(), i->first );
break;
case QUEST_UNCHANGED:
break;
@@ -17880,7 +17879,7 @@ void Player::PetSpellInitialize()
uint8 cooldownsCount = pet->m_CreatureSpellCooldowns.size() + pet->m_CreatureCategoryCooldowns.size();
data << uint8(cooldownsCount);
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = time(NULL);
for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr)
{
@@ -18646,7 +18645,7 @@ void Player::ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs )
WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+m_spells.size()*8);
data << GetGUID();
data << uint8(0x0); // flags (0x1, 0x2)
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = time(NULL);
for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
{
if (itr->second->state == PLAYERSPELL_REMOVED)
@@ -18925,7 +18924,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
{
it->SetPaidArenaPoints(arenaPoints);
it->SetPaidHonorPoints(honorPoints);
- it->SetRefundExpiryTime( sGameTime.GetGameTime()+(HOUR*2) );
+ it->SetRefundExpiryTime( time(NULL)+(HOUR*2) );
for (uint8 i = 0; i < 5; ++i)
it->SetPaidExtendedCost(i, extendedCost[i], extendedCostCount[i]);
}
@@ -19091,25 +19090,12 @@ void Player::UpdatePvP(bool state, bool override)
else
{
if(pvpInfo.endTimer != 0)
- pvpInfo.endTimer = sGameTime.GetGameTime();
+ pvpInfo.endTimer = time(NULL);
else
SetPvP(state);
}
}
-bool Player::HasSpellCooldown(uint32 spell_id) const
-{
- SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
- return itr != m_spellCooldowns.end() && itr->second.end > sGameTime.GetGameTime();
-}
-
-uint32 Player::GetSpellCooldownDelay(uint32 spell_id) const
-{
- SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
- time_t t = sGameTime.GetGameTime();
- return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0;
-}
-
void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 itemId, Spell* spell, bool infinityCooldown)
{
// init cooldown values
@@ -19146,7 +19132,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it
catrec = spellInfo->CategoryRecoveryTime;
}
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = time(NULL);
time_t catrecTime;
time_t recTime;
@@ -20007,7 +19993,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
SendEquipmentSetList();
data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4);
- data << uint32(secsToTimeBitFields(sGameTime.GetGameTime()));
+ data << uint32(secsToTimeBitFields(sWorld.GetGameTime()));
data << (float)0.01666667f; // game speed
data << uint32(0); // added in 3.1.2
GetSession()->SendPacket( &data );
@@ -20138,7 +20124,7 @@ void Player::ApplyEquipCooldown( Item * pItem )
if( spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE )
continue;
- AddSpellCooldown(spellData.SpellId, pItem->GetEntry(), sGameTime.GetGameTime() + 30);
+ AddSpellCooldown(spellData.SpellId, pItem->GetEntry(), time(NULL) + 30);
WorldPacket data(SMSG_ITEM_COOLDOWN, 12);
data << pItem->GetGUID();
@@ -20389,7 +20375,7 @@ void Player::SetDailyQuestStatus( uint32 quest_id )
if(!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx))
{
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id);
- m_lastDailyQuestTime = sGameTime.GetGameTime(); // last daily quest time
+ m_lastDailyQuestTime = time(NULL); // last daily quest time
m_DailyQuestChanged = true;
break;
}
@@ -20559,15 +20545,6 @@ void Player::UpdateForQuestWorldObjects()
GetSession()->SendPacket(&packet);
}
-void Player::SetSummonPoint(uint32 mapid, float x, float y, float z)
-{
- m_summon_expire = sGameTime.GetGameTime() + MAX_PLAYER_SUMMON_DELAY;
- m_summon_mapid = mapid;
- m_summon_x = x;
- m_summon_y = y;
- m_summon_z = z;
-}
-
void Player::SummonIfPossible(bool agree)
{
if (!agree)
@@ -20577,7 +20554,7 @@ void Player::SummonIfPossible(bool agree)
}
// expire and auto declined
- if (m_summon_expire < sGameTime.GetGameTime())
+ if (m_summon_expire < time(NULL))
return;
// stop taxi flight at summon
@@ -21070,7 +21047,7 @@ uint32 Player::GetCorpseReclaimDelay(bool pvp) const
else if(!sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE) )
return 0;
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
// 0..2 full period
// should be ceil(x)-1 but not floor(x)
uint32 count = (now < m_deathExpireTime - 1) ? (m_deathExpireTime - 1 - now)/DEATH_EXPIRE_STEP : 0;
@@ -21085,7 +21062,7 @@ void Player::UpdateCorpseReclaimDelay()
(!pvp && !sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE) ))
return;
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
if(now < m_deathExpireTime)
{
// full and partly periods 1..3
@@ -21130,7 +21107,7 @@ void Player::SendCorpseReclaimDelay(bool load)
time_t expected_time = corpse->GetGhostTime()+copseReclaimDelay[count];
- time_t now = sGameTime.GetGameTime();
+ time_t now = time(NULL);
if(now >= expected_time)
return;
diff --git a/src/game/Player.h b/src/game/Player.h
index 8d1af04e72d..db6e72b5768 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -39,7 +39,6 @@
#include "ReputationMgr.h"
#include "BattleGround.h"
#include "DBCEnums.h"
-#include "TimeMgr.h"
#include<string>
#include<vector>
@@ -988,7 +987,14 @@ class TRINITY_DLL_SPEC Player : public Unit
bool TeleportToBGEntryPoint();
- void SetSummonPoint(uint32 mapid, float x, float y, float z);
+ void SetSummonPoint(uint32 mapid, float x, float y, float z)
+ {
+ m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY;
+ m_summon_mapid = mapid;
+ m_summon_x = x;
+ m_summon_y = y;
+ m_summon_z = z;
+ }
void SummonIfPossible(bool agree);
bool Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId );
@@ -1565,8 +1571,17 @@ class TRINITY_DLL_SPEC Player : public Unit
static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check
static uint32 const infinityCooldownDelayCheck = MONTH/2;
- bool HasSpellCooldown(uint32 spell_id) const;
- uint32 GetSpellCooldownDelay(uint32 spell_id) const;
+ bool HasSpellCooldown(uint32 spell_id) const
+ {
+ SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
+ return itr != m_spellCooldowns.end() && itr->second.end > time(NULL);
+ }
+ uint32 GetSpellCooldownDelay(uint32 spell_id) const
+ {
+ SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
+ time_t t = time(NULL);
+ return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0;
+ }
void AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false );
void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
void SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId = 0, Spell* spell = NULL);
diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp
index f0f70fde55c..4ce59eef384 100644
--- a/src/game/QueryHandler.cpp
+++ b/src/game/QueryHandler.cpp
@@ -33,7 +33,6 @@
#include "NPCHandler.h"
#include "Pet.h"
#include "MapManager.h"
-#include "TimeMgr.h"
void WorldSession::SendNameQueryOpcode(Player *p)
{
@@ -143,7 +142,7 @@ void WorldSession::HandleNameQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleQueryTimeOpcode( WorldPacket & /*recv_data*/ )
{
WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 );
- data << (uint32)sGameTime.GetGameTime();
+ data << (uint32)time(NULL);
data << (uint32)0;
SendPacket( &data );
}
diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp
index 5e23648660c..c8872c6fef6 100644
--- a/src/game/RandomMovementGenerator.cpp
+++ b/src/game/RandomMovementGenerator.cpp
@@ -170,7 +170,7 @@ RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff
{
if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED))
{
- i_nextMoveTime.Update(i_nextMoveTime.GetExpireTime()); // Expire the timer
+ i_nextMoveTime.Update(i_nextMoveTime.GetExpiry()); // Expire the timer
creature.clearUnitState(UNIT_STAT_ROAMING);
return true;
}
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 446065607c6..e7295fd7e74 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -49,7 +49,6 @@
#include "GridNotifiersImpl.h"
#include "Vehicle.h"
#include "CellImpl.h"
-#include "TimeMgr.h"
#define Aura AuraEffect
pAuraHandler AuraHandler[TOTAL_AURAS]=
@@ -367,7 +366,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
Aura::Aura(SpellEntry const* spellproto, uint32 effMask, Unit *target, WorldObject *source, Unit *caster, int32 *currentBasePoints, Item* castItem) :
m_spellProto(spellproto),
m_target(target), m_sourceGuid(source->GetGUID()), m_casterGuid(caster->GetGUID()), m_castItemGuid(castItem ? castItem->GetGUID() : 0),
- m_applyTime(sGameTime.GetGameTime()),
+ m_applyTime(time(NULL)),
m_timeCla(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1), m_isRemoved(false)
{
@@ -1331,7 +1330,7 @@ void Aura::HandleAuraSpecificMods(bool apply)
return;
player->RemoveSpellCooldown(m_spellProto->Id, true);
- player->AddSpellCooldown(m_spellProto->Id, 0, uint32(sGameTime.GetGameTime() + aurEff->GetAmount()));
+ player->AddSpellCooldown(m_spellProto->Id, 0, uint32(time(NULL) + aurEff->GetAmount()));
WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4+4);
data << uint64(player->GetGUID());
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 72a6ad32bb9..f535033b0e6 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -61,7 +61,6 @@
#include "SkillDiscovery.h"
#include "Formulas.h"
#include "Vehicle.h"
-#include "TimeMgr.h"
pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
{
@@ -999,7 +998,7 @@ void Spell::EffectDummy(uint32 i)
Creature* creatureTarget = (Creature*)unitTarget;
- GameObject* Crystal_Prison = m_caster->SummonGameObject(179644, creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(), creatureTarget->GetOrientation(), 0, 0, 0, 0, creatureTarget->GetRespawnTime()-sGameTime.GetGameTime());
+ GameObject* Crystal_Prison = m_caster->SummonGameObject(179644, creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(), creatureTarget->GetOrientation(), 0, 0, 0, 0, creatureTarget->GetRespawnTime()-time(NULL));
sLog.outDebug("SummonGameObject at SpellEfects.cpp EffectDummy for Spell 23019");
creatureTarget->ForcedDespawn();
diff --git a/src/game/TicketHandler.cpp b/src/game/TicketHandler.cpp
index b0158963ae0..ac6675beba0 100644
--- a/src/game/TicketHandler.cpp
+++ b/src/game/TicketHandler.cpp
@@ -24,7 +24,6 @@
#include "ObjectMgr.h"
#include "Player.h"
#include "World.h"
-#include "TimeMgr.h"
void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
{
@@ -53,12 +52,12 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
ticket->guid = objmgr.GenerateGMTicketId();
ticket->playerGuid = GetPlayer()->GetGUID();
ticket->message = ticketText;
- ticket->createtime = sGameTime.GetGameTime();
+ ticket->createtime = time(NULL);
ticket->map = map;
ticket->pos_x = x;
ticket->pos_y = y;
ticket->pos_z = z;
- ticket->timestamp = sGameTime.GetGameTime();
+ ticket->timestamp = time(NULL);
ticket->closed = 0;
ticket->assignedToGM = 0;
ticket->comment = "";
@@ -88,7 +87,7 @@ void WorldSession::HandleGMTicketUpdateOpcode( WorldPacket & recv_data)
}
ticket->message = message;
- ticket->timestamp = sGameTime.GetGameTime();
+ ticket->timestamp = time(NULL);
objmgr.AddOrUpdateGMTicket(*ticket);
@@ -118,7 +117,7 @@ void WorldSession::HandleGMTicketDeleteOpcode( WorldPacket & /*recv_data*/)
void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/)
{
WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 );
- data << (uint32)sGameTime.GetGameTime();
+ data << (uint32)time(NULL);
data << (uint32)0;
SendPacket( &data );
diff --git a/src/game/TotemAI.h b/src/game/TotemAI.h
index 68e44e04c4c..003f5d5ca13 100644
--- a/src/game/TotemAI.h
+++ b/src/game/TotemAI.h
@@ -22,7 +22,7 @@
#define TRINITY_TOTEMAI_H
#include "CreatureAI.h"
-#include "TimeMgr.h"
+#include "Timer.h"
class Creature;
class Totem;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 30fee0eeb45..230478dd9ec 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -54,7 +54,6 @@
#include "Vehicle.h"
#include "Transports.h"
#include "ScriptCalls.h"
-#include "TimeMgr.h"
#include <math.h>
@@ -2008,7 +2007,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
int32 healAmount = pVictim->GetMaxHealth() * (*i)->GetAmount() / 100.0f * pctFromDefense;
pVictim->CastCustomSpell(pVictim, 66235, &healAmount, NULL, NULL, true);
- ((Player*)pVictim)->AddSpellCooldown(66235,0,sGameTime.GetGameTime() + 120);
+ ((Player*)pVictim)->AddSpellCooldown(66235,0,time(NULL) + 120);
}
else if (remainingHealth < allowedHealth)
{
@@ -2255,7 +2254,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
if (preventDeathSpell->SpellIconID == 2109)
{
pVictim->CastSpell(pVictim,31231,true);
- ((Player*)pVictim)->AddSpellCooldown(31231,0,sGameTime.GetGameTime()+60);
+ ((Player*)pVictim)->AddSpellCooldown(31231,0,time(NULL)+60);
// with health > 10% lost health until health==10%, in other case no losses
uint32 health10 = pVictim->GetMaxHealth()/10;
RemainingDamage = pVictim->GetHealth() > health10 ? pVictim->GetHealth() - health10 : 0;
@@ -4899,7 +4898,7 @@ bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura);
if (cooldown && GetTypeId() == TYPEID_PLAYER)
- ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown);
return true;
}
@@ -4961,7 +4960,7 @@ bool Unit::HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 /*damage*/, AuraE
CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura);
if( cooldown && GetTypeId() == TYPEID_PLAYER )
- ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown);
return true;
}
@@ -6718,7 +6717,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
// apply cooldown before cast to prevent processing itself
if( cooldown )
- ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown);
// Attack Twice
for (uint32 i = 0; i<2; ++i )
@@ -6958,7 +6957,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
((Player*)this)->AddSpellMod(mod, false);
if( cooldown && GetTypeId() == TYPEID_PLAYER )
- ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown);
return true;
}
@@ -7241,7 +7240,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura, originalCaster);
if( cooldown && GetTypeId() == TYPEID_PLAYER )
- ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown);
return true;
}
@@ -7299,7 +7298,7 @@ bool Unit::HandleObsModEnergyAuraProc(Unit *pVictim, uint32 damage, AuraEffect*
CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura);
if( cooldown && GetTypeId() == TYPEID_PLAYER )
- ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown);
return true;
}
bool Unit::HandleModDamagePctTakenAuraProc(Unit *pVictim, uint32 damage, AuraEffect* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown)
@@ -7357,7 +7356,7 @@ bool Unit::HandleModDamagePctTakenAuraProc(Unit *pVictim, uint32 damage, AuraEff
CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura);
if( cooldown && GetTypeId() == TYPEID_PLAYER )
- ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown);
return true;
}
@@ -7995,7 +7994,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
target->CastSpell(target,trigger_spell_id,true,castItem,triggeredByAura);
if( cooldown && GetTypeId() == TYPEID_PLAYER )
- ((Player*)this)->AddSpellCooldown(trigger_spell_id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(trigger_spell_id,0,time(NULL) + cooldown);
return true;
}
// Cast positive spell on enemy target
@@ -8167,7 +8166,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
CastSpell(target,trigger_spell_id,true,castItem,triggeredByAura);
if( cooldown && GetTypeId() == TYPEID_PLAYER )
- ((Player*)this)->AddSpellCooldown(trigger_spell_id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(trigger_spell_id,0,time(NULL) + cooldown);
return true;
}
@@ -8265,7 +8264,7 @@ bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, uint32 damage, AuraE
CastSpell(pVictim, triggered_spell_id, true, castItem, triggeredByAura);
if( cooldown && GetTypeId() == TYPEID_PLAYER )
- ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,sGameTime.GetGameTime() + cooldown);
+ ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown);
return true;
}
@@ -14596,7 +14595,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true);
//if charmed two demons the same session, the 2nd gets the 1st one's name
- SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, sGameTime.GetGameTime());
+ SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
}
}
((Player*)charmer)->CharmSpellInitialize();
diff --git a/src/game/Weather.cpp b/src/game/Weather.cpp
index 62c2532a3cd..5d8d1fbd9ba 100644
--- a/src/game/Weather.cpp
+++ b/src/game/Weather.cpp
@@ -88,7 +88,7 @@ bool Weather::ReGenerate()
//78 days between January 1st and March 20nd; 365/4=91 days by season
// season source http://aa.usno.navy.mil/data/docs/EarthSeasons.html
- time_t gtime = sGameTime.GetGameTime();
+ time_t gtime = sWorld.GetGameTime();
struct tm * ltime = localtime(&gtime);
uint32 season = ((ltime->tm_yday - 78 + 365)/91)%4;
diff --git a/src/game/Weather.h b/src/game/Weather.h
index 9b824f9df21..e312f004060 100644
--- a/src/game/Weather.h
+++ b/src/game/Weather.h
@@ -27,7 +27,7 @@
#include "Common.h"
#include "SharedDefines.h"
-#include "TimeMgr.h"
+#include "Timer.h"
class Player;
diff --git a/src/game/World.cpp b/src/game/World.cpp
index aa5222b707a..21b1372f1af 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -68,7 +68,6 @@
#include "CreatureGroups.h"
#include "Transports.h"
#include "ProgressBar.h"
-#include "TimeMgr.h"
INSTANTIATE_SINGLETON_1(World);
@@ -97,7 +96,7 @@ World::World()
m_allowMovement = true;
m_ShutdownMask = 0;
m_ShutdownTimer = 0;
- m_gameTime=sGameTime.GetGameTime();
+ m_gameTime=time(NULL);
m_startTime=m_gameTime;
m_maxActiveSessionCount = 0;
m_maxQueuedSessionCount = 0;
@@ -288,7 +287,7 @@ bool World::HasRecentlyDisconnected(WorldSession* session)
{
for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end();)
{
- if (difftime(i->second, sGameTime.GetGameTime()) < tolerance)
+ if (difftime(i->second, time(NULL)) < tolerance)
{
if (i->first == session->GetAccountId())
return true;
@@ -1235,7 +1234,7 @@ void World::LoadConfigSettings(bool reload)
void World::SetInitialWorldSettings()
{
///- Initialize the random number generator
- srand((unsigned int)sGameTime.GetGameTime());
+ srand((unsigned int)time(NULL));
///- Initialize config settings
LoadConfigSettings();
@@ -1626,7 +1625,7 @@ void World::SetInitialWorldSettings()
///- Initialize game time and timers
sLog.outDebug("DEBUG:: Initialize game time and timers");
- m_gameTime=sGameTime.GetGameTime();
+ m_gameTime = time(NULL);
m_startTime=m_gameTime;
tm local;
@@ -1638,7 +1637,7 @@ void World::SetInitialWorldSettings()
local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);
loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime, revision) VALUES('%u', " UI64FMTD ", '%s', 0, '%s')",
- realmID, m_startTime, isoDate, _FULLVERSION);
+ realmID, uint64(m_startTime), isoDate, _FULLVERSION);
static uint32 abtimer = 0;
abtimer = sConfig.GetIntDefault("AutoBroadcast.Timer", 60000);
@@ -1657,7 +1656,7 @@ void World::SetInitialWorldSettings()
//to set mailtimer to return mails every day between 4 and 5 am
//mailtimer is increased when updating auctions
//one second is 1000 -(tested on win system)
- mail_timer = ((((localtime(&sGameTime.GetGameTime())->tm_hour + 20) % 24)* HOUR * IN_MILISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval());
+ mail_timer = ((((localtime(&m_gameTime)->tm_hour + 20) % 24)* HOUR * IN_MILISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval());
//1440
mail_timer_expires = ((DAY * IN_MILISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval()));
sLog.outDebug("Mail timer set to: %u, mail return is called every %u minutes", mail_timer, mail_timer_expires);
@@ -1858,7 +1857,7 @@ void World::Update(uint32 diff)
_UpdateGameTime();
/// Handle daily quests reset time
- if (sGameTime.GetGameTime() > m_NextDailyQuestReset)
+ if (m_gameTime > m_NextDailyQuestReset)
{
ResetDailyQuests();
m_NextDailyQuestReset += DAY;
@@ -1915,7 +1914,7 @@ void World::Update(uint32 diff)
uint32 maxClientsNum = GetMaxActiveSessionCount();
m_timers[WUPDATE_UPTIME].Reset();
- loginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " UI64FMTD, tmpDiff, maxClientsNum, realmID, m_startTime);
+ loginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " UI64FMTD, tmpDiff, maxClientsNum, realmID, uint64(m_startTime));
}
/// <li> Clean logs table
@@ -2282,9 +2281,9 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
void World::_UpdateGameTime()
{
///- update the time
- time_t thisTime = sGameTime.GetGameTime();
- uint32 elapsed = uint32(thisTime - sGameTime.GetGameTime());
- sGameTime.SetGameTime();
+ time_t thisTime = time(NULL);
+ uint32 elapsed = uint32(thisTime - m_gameTime);
+ m_gameTime = thisTime;
///- if there is a shutdown timer
if (!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0)
@@ -2413,7 +2412,7 @@ void World::UpdateSessions(uint32 diff)
if (!itr->second->Update(diff)) // As interval = 0
{
if (!RemoveQueuedPlayer(itr->second) && itr->second && getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
- m_disconnects[itr->second->GetAccountId()] = sGameTime.GetGameTime();
+ m_disconnects[itr->second->GetAccountId()] = time(NULL);
delete itr->second;
m_sessions.erase(itr);
}
@@ -2524,7 +2523,7 @@ void World::InitDailyQuestResetTime()
// client built-in time for reset is 6:00 AM
// FIX ME: client not show day start time
- time_t curTime = sGameTime.GetGameTime();
+ time_t curTime = time(NULL);
tm localTm = *localtime(&curTime);
localTm.tm_hour = 6;
localTm.tm_min = 0;
diff --git a/src/game/World.h b/src/game/World.h
index a1e01b55b2b..ed16d03307a 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -26,7 +26,7 @@
#define __WORLD_H
#include "Common.h"
-#include "TimeMgr.h"
+#include "Timer.h"
#include "Policies/Singleton.h"
#include "SharedDefines.h"
#include "ace/Atomic_Op.h"
@@ -516,6 +516,12 @@ class World
/// Get the path where data (dbc, maps) are stored on disk
std::string GetDataPath() const { return m_dataPath; }
+ /// When server started?
+ time_t const& GetStartTime() const { return m_startTime; }
+ /// What time is it?
+ time_t const& GetGameTime() const { return m_gameTime; }
+ /// Uptime (in secs)
+ uint32 GetUptime() const { return uint32(m_gameTime - m_startTime); }
/// Update time
uint32 GetUpdateTime() const { return m_updateTime; }
void SetRecordDiffInterval(int32 t) { if(t >= 0) m_configs[CONFIG_INTERVAL_LOG_UPDATE] = (uint32)t; }
diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp
index bb7950de222..569c8fade62 100644
--- a/src/game/WorldSession.cpp
+++ b/src/game/WorldSession.cpp
@@ -39,7 +39,6 @@
#include "OutdoorPvPMgr.h"
#include "MapManager.h"
#include "SocialMgr.h"
-#include "TimeMgr.h"
#include "zlib/zlib.h"
#include "ScriptCalls.h"
@@ -107,13 +106,13 @@ void WorldSession::SendPacket(WorldPacket const* packet)
static uint64 sendPacketCount = 0;
static uint64 sendPacketBytes = 0;
- static time_t firstTime = sGameTime.GetGameTime();
+ static time_t firstTime = time(NULL);
static time_t lastTime = firstTime; // next 60 secs start time
static uint64 sendLastPacketCount = 0;
static uint64 sendLastPacketBytes = 0;
- time_t cur_time = sGameTime.GetGameTime();
+ time_t cur_time = time(NULL);
if((cur_time - lastTime) < 60)
{
@@ -282,7 +281,7 @@ bool WorldSession::Update(uint32 /*diff*/)
}
///- If necessary, log the player out
- time_t currTime = sGameTime.GetGameTime();
+ time_t currTime = time(NULL);
if (!m_Socket || (ShouldLogOut(currTime) && !m_playerLoading))
LogoutPlayer(true);
@@ -659,7 +658,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
void WorldSession::SendAccountDataTimes(uint32 mask)
{
WorldPacket data( SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4 ); // changed in WotLK
- data << uint32(sGameTime.GetGameTime()); // unix time of something
+ data << uint32(time(NULL)); // unix time of something
data << uint8(1);
data << uint32(mask); // type mask
for(uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
diff --git a/src/shared/Timer.h b/src/shared/Timer.h
index d21407b8e42..46bba5475bc 100644
--- a/src/shared/Timer.h
+++ b/src/shared/Timer.h
@@ -18,13 +18,21 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TIMER_H
-#define _TIMER_H
+#ifndef TRINITY_TIMER_H
+#define TRINITY_TIMER_H
-#include "Platform/Define.h"
+#include "Platform/CompilerDefs.h"
-#if (PLATFORM != PLATFORM_WINDOWS)
+#if PLATFORM == PLATFORM_WINDOWS
+# include <ace/config-all.h>
+# include <mmsystem.h>
+# include <time.h>
+#else
+# if defined(__APPLE_CC__)
+# include <time.h>
+# endif
# include <sys/time.h>
+# include <sys/timeb.h>
#endif
#if PLATFORM == PLATFORM_WINDOWS
@@ -48,4 +56,67 @@ inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
return newMSTime - oldMSTime;
}
+class IntervalTimer
+{
+ public:
+ IntervalTimer() : _interval(0), _current(0) {}
+
+ void Update(time_t diff) { _current += diff; if(_current<0) _current=0;}
+ bool Passed() { return _current >= _interval; }
+ void Reset() { if(_current >= _interval) _current -= _interval; }
+
+ void SetCurrent(time_t current) { _current = current; }
+ void SetInterval(time_t interval) { _interval = interval; }
+ time_t GetInterval() const { return _interval; }
+ time_t GetCurrent() const { return _current; }
+
+ private:
+ time_t _interval;
+ time_t _current;
+};
+
+struct TimeTracker
+{
+ TimeTracker(time_t expiry) : i_expiryTime(expiry) {}
+ void Update(time_t diff) { i_expiryTime -= diff; }
+ bool Passed(void) const { return (i_expiryTime <= 0); }
+ void Reset(time_t interval) { i_expiryTime = interval; }
+ time_t GetExpiry(void) const { return i_expiryTime; }
+ time_t i_expiryTime;
+};
+
+struct TimeTrackerSmall
+{
+ TimeTrackerSmall(int32 expiry) : i_expiryTime(expiry) {}
+ void Update(int32 diff) { i_expiryTime -= diff; }
+ bool Passed(void) const { return (i_expiryTime <= 0); }
+ void Reset(int32 interval) { i_expiryTime = interval; }
+ int32 GetExpiry(void) const { return i_expiryTime; }
+ int32 i_expiryTime;
+};
+
+struct PeriodicTimer
+{
+ PeriodicTimer(int32 period, int32 start_time) :
+ i_expireTime(start_time), i_period(period) {}
+
+ bool Update(const uint32 &diff)
+ {
+ if((i_expireTime -= diff) > 0)
+ return false;
+
+ i_expireTime += i_period > diff ? i_period : diff;
+ return true;
+ }
+
+ void SetPeriodic(int32 period, int32 start_time)
+ {
+ i_expireTime=start_time, i_period=period;
+ }
+
+ int32 i_period;
+ int32 i_expireTime;
+};
+
#endif
+
diff --git a/src/trinitycore/Master.cpp b/src/trinitycore/Master.cpp
index f62168fa9be..ba293ec841a 100644
--- a/src/trinitycore/Master.cpp
+++ b/src/trinitycore/Master.cpp
@@ -39,7 +39,7 @@
#include "Master.h"
#include "RASocket.h"
#include "ScriptCalls.h"
-#include "TimeMgr.h"
+#include "Timer.h"
#include "Util.h"
#include "sockets/TcpSocket.h"
diff --git a/src/trinitycore/WorldRunnable.cpp b/src/trinitycore/WorldRunnable.cpp
index 2125ba435db..67ffe7c474e 100644
--- a/src/trinitycore/WorldRunnable.cpp
+++ b/src/trinitycore/WorldRunnable.cpp
@@ -30,7 +30,7 @@
#include "BattleGroundMgr.h"
#include "MapManager.h"
-#include "TimeMgr.h"
+#include "Timer.h"
#include "WorldRunnable.h"
#define WORLD_SLEEP_CONST 50