Tab cleanup

This commit is contained in:
Antz 2021-03-05 23:30:15 +00:00
parent c0411110cb
commit 4421496edd
16 changed files with 1121 additions and 1121 deletions

2
dep

@ -1 +1 @@
Subproject commit 1d89480290e87be41393a2fa4765837c15e023b9
Subproject commit d00434acaab2a257f410079afcc6d600ca954557

View File

@ -28,7 +28,7 @@
#include "GameEventMgr.h"
/**********************************************************************
CommandTable : eventCommandTable
CommandTable : eventCommandTable
/***********************************************************************/
bool ChatHandler::HandleEventListCommand(char* args)

View File

@ -23,7 +23,7 @@
*/
/*
CUSTOM COMMANDS HANDLERS
CUSTOM COMMANDS HANDLERS
Code your custom command handlers here !
*/

View File

@ -9228,7 +9228,7 @@ void ObjectMgr::LoadCoreSideGossipTextIdCache()
"`gm`.`text_id` "
"FROM `creature_template` `ct` "
"LEFT JOIN ("
" SELECT "
" SELECT "
" `entry`, MIN(`text_id`) as `text_id` "
" FROM `gossip_menu` "
" GROUP BY `entry` "

View File

@ -17936,7 +17936,7 @@ void Player::SaveToDB()
"`watchedFaction`, `drunk`, `health`, `power1`, `power2`, `power3`, "
"`power4`, `power5`, `exploredZones`, `equipmentCache`, `ammoId`, `actionBars`) "
"VALUES ( ?, ?, ?, ?, ?, ?, "
"?, ?, ?, ?, ?, ?, "
"?, ?, ?, ?, ?, ?, "
"?, ?, ?, ?, ?, "
"?, ?, ?, "
"?, ?, ?, ?, ?, ?, ?, "

View File

@ -27,10 +27,10 @@
namespace GameTime
{
time_t const StartTime = time(nullptr);
time_t const StartTime = time(nullptr);
time_t GameTime = 0;
uint32 GameMSTime = 0;
time_t GameTime = 0;
uint32 GameMSTime = 0;
std::chrono::system_clock::time_point GameTimeSystemPoint = std::chrono::system_clock::time_point::min();
std::chrono::steady_clock::time_point GameTimeSteadyPoint = std::chrono::steady_clock::time_point::min();

View File

@ -31,25 +31,25 @@
namespace GameTime
{
// Server Start Time
time_t GetStartTime();
// Server Start Time
time_t GetStartTime();
// Current Server Time (unix) in seconds
time_t GetGameTime();
// Current Server Time (unix) in seconds
time_t GetGameTime();
// Milliseconds since Server Start
uint32 GetGameTimeMS();
// Milliseconds since Server Start
uint32 GetGameTimeMS();
// Current chrono system_clock time point
std::chrono::system_clock::time_point GetGameTimeSystemPoint();
// Current chrono system_clock time point
std::chrono::system_clock::time_point GetGameTimeSystemPoint();
// Current chrono steady_clock time point
std::chrono::steady_clock::time_point GetGameTimeSteadyPoint();
// Current chrono steady_clock time point
std::chrono::steady_clock::time_point GetGameTimeSteadyPoint();
// Uptime (in seconds)
uint32 GetUptime();
// Uptime (in seconds)
uint32 GetUptime();
void UpdateGameTimers();
void UpdateGameTimers();
}
#endif

View File

@ -35,49 +35,49 @@
class UpdateTime
{
using DiffTableArray = std::array<uint32, AVG_DIFF_COUNT>;
using DiffTableArray = std::array<uint32, AVG_DIFF_COUNT>;
public:
uint32 GetAverageUpdateTime() const;
uint32 GetTimeWeightedAverageUpdateTime() const;
uint32 GetMaxUpdateTime() const;
uint32 GetMaxUpdatTimeOfCurrentTable() const;
uint32 GetLastUpdateTime() const;
uint32 GetAverageUpdateTime() const;
uint32 GetTimeWeightedAverageUpdateTime() const;
uint32 GetMaxUpdateTime() const;
uint32 GetMaxUpdatTimeOfCurrentTable() const;
uint32 GetLastUpdateTime() const;
void UpdateWithDiff(uint32 diff);
void UpdateWithDiff(uint32 diff);
void RecordUpdateTimeReset();
void RecordUpdateTimeReset();
protected:
UpdateTime();
UpdateTime();
void _RecordUpdateTimeDuration(std::string const& text, uint32 minUpdateTime);
void _RecordUpdateTimeDuration(std::string const& text, uint32 minUpdateTime);
private:
DiffTableArray _updateTimeDataTable;
uint32 _averageUpdateTime;
uint32 _totalUpdateTime;
uint32 _updateTimeTableIndex;
uint32 _maxUpdateTime;
uint32 _maxUpdateTimeOfLastTable;
uint32 _maxUpdateTimeOfCurrentTable;
DiffTableArray _updateTimeDataTable;
uint32 _averageUpdateTime;
uint32 _totalUpdateTime;
uint32 _updateTimeTableIndex;
uint32 _maxUpdateTime;
uint32 _maxUpdateTimeOfLastTable;
uint32 _maxUpdateTimeOfCurrentTable;
uint32 _recordedTime;
uint32 _recordedTime;
};
class WorldUpdateTime : public UpdateTime
{
public:
WorldUpdateTime() : UpdateTime(), _recordUpdateTimeInverval(0), _recordUpdateTimeMin(0), _lastRecordTime(0) { }
void LoadFromConfig();
void SetRecordUpdateTimeInterval(uint32 t);
void RecordUpdateTime(uint32 gameTimeMs, uint32 diff, uint32 sessionCount);
void RecordUpdateTimeDuration(std::string const& text);
WorldUpdateTime() : UpdateTime(), _recordUpdateTimeInverval(0), _recordUpdateTimeMin(0), _lastRecordTime(0) { }
void LoadFromConfig();
void SetRecordUpdateTimeInterval(uint32 t);
void RecordUpdateTime(uint32 gameTimeMs, uint32 diff, uint32 sessionCount);
void RecordUpdateTimeDuration(std::string const& text);
private:
uint32 _recordUpdateTimeInverval;
uint32 _recordUpdateTimeMin;
uint32 _lastRecordTime;
uint32 _recordUpdateTimeInverval;
uint32 _recordUpdateTimeMin;
uint32 _lastRecordTime;
};
extern WorldUpdateTime sWorldUpdateTime;

File diff suppressed because it is too large Load Diff

View File

@ -233,11 +233,11 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
// for riding spells, override the levels with the levels from the configuration file
switch (tSpell->spell) {
case 33388:
case 33388:
case 33389: // Apprentice Riding
reqLevel = AccountTypes(sWorld.getConfig(CONFIG_UINT32_MIN_TRAIN_MOUNT_LEVEL));
break;
case 33391:
case 33391:
case 33392: // Journeyman Riding
reqLevel = AccountTypes(sWorld.getConfig(CONFIG_UINT32_MIN_TRAIN_EPIC_MOUNT_LEVEL));
break;

View File

@ -32,111 +32,111 @@
void SoapThread(const std::string& host, uint16 port)
{
struct soap soap;
soap_init(&soap);
soap_set_imode(&soap, SOAP_C_UTFSTRING);
soap_set_omode(&soap, SOAP_C_UTFSTRING);
struct soap soap;
soap_init(&soap);
soap_set_imode(&soap, SOAP_C_UTFSTRING);
soap_set_omode(&soap, SOAP_C_UTFSTRING);
// check every 3 seconds if world ended
soap.accept_timeout = 3;
soap.recv_timeout = 5;
soap.send_timeout = 5;
// check every 3 seconds if world ended
soap.accept_timeout = 3;
soap.recv_timeout = 5;
soap.send_timeout = 5;
if (!soap_valid_socket(soap_bind(&soap, host.c_str(), port, 100)))
{
sLog.outError("SoapThread: couldn't bind to %s:%d", host.c_str(), port);
exit(-1);
}
if (!soap_valid_socket(soap_bind(&soap, host.c_str(), port, 100)))
{
sLog.outError("SoapThread: couldn't bind to %s:%d", host.c_str(), port);
exit(-1);
}
sLog.outString("SoapThread: Bound to http://%s:%d", host.c_str(), port);
sLog.outString("SoapThread: Bound to http://%s:%d", host.c_str(), port);
while (!World::IsStopped())
{
if (!soap_valid_socket(soap_accept(&soap)))
{
continue; // ran into an accept timeout
}
while (!World::IsStopped())
{
if (!soap_valid_socket(soap_accept(&soap)))
{
continue; // ran into an accept timeout
}
sLog.outString("Accepted connection from IP %d.%d.%d.%d", (int)(soap.ip >> 24) & 0xFF, (int)(soap.ip >> 16) & 0xFF, (int)(soap.ip >> 8) & 0xFF, (int)soap.ip & 0xFF);
struct soap* thread_soap = soap_copy(&soap); // make a safe copy
process_message(thread_soap);
}
sLog.outString("Accepted connection from IP %d.%d.%d.%d", (int)(soap.ip >> 24) & 0xFF, (int)(soap.ip >> 16) & 0xFF, (int)(soap.ip >> 8) & 0xFF, (int)soap.ip & 0xFF);
struct soap* thread_soap = soap_copy(&soap); // make a safe copy
process_message(thread_soap);
}
soap_done(&soap);
soap_done(&soap);
}
void process_message(struct soap* soap_message)
{
soap_serve(soap_message);
soap_destroy(soap_message); // dealloc C++ data
soap_end(soap_message); // dealloc data and clean up
soap_done(soap_message); // detach soap struct
free(soap_message);
soap_serve(soap_message);
soap_destroy(soap_message); // dealloc C++ data
soap_end(soap_message); // dealloc data and clean up
soap_done(soap_message); // detach soap struct
free(soap_message);
}
int ns1__executeCommand(soap* soap, char* command, char** result)
{
// security check
if (!soap->userid || !soap->passwd)
{
sLog.outString("SoapThread: Client didn't provide login information");
return 401;
}
// security check
if (!soap->userid || !soap->passwd)
{
sLog.outString("SoapThread: Client didn't provide login information");
return 401;
}
uint32 accountId = sAccountMgr.GetId(soap->userid);
if (!accountId)
{
sLog.outString("SoapThread: Client used invalid username %s", soap->userid);
return 401;
}
uint32 accountId = sAccountMgr.GetId(soap->userid);
if (!accountId)
{
sLog.outString("SoapThread: Client used invalid username %s", soap->userid);
return 401;
}
if (!sAccountMgr.CheckPassword(accountId, soap->passwd))
{
sLog.outString("SoapThread: Client sent an invalid password for account %s", soap->passwd);
return 401;
}
if (!sAccountMgr.CheckPassword(accountId, soap->passwd))
{
sLog.outString("SoapThread: Client sent an invalid password for account %s", soap->passwd);
return 401;
}
/* ToDo: Add realm check */
if (sAccountMgr.GetSecurity(accountId) < SEC_ADMINISTRATOR)
{
sLog.outString("SoapThread: %s's account security level is to low", soap->userid);
return 403;
}
/* ToDo: Add realm check */
if (sAccountMgr.GetSecurity(accountId) < SEC_ADMINISTRATOR)
{
sLog.outString("SoapThread: %s's account security level is to low", soap->userid);
return 403;
}
if (!command || !*command)
{
return soap_sender_fault(soap, "Command can not be empty", "The supplied command was an empty string");
}
if (!command || !*command)
{
return soap_sender_fault(soap, "Command can not be empty", "The supplied command was an empty string");
}
sLog.outString("SoapThread: Recieved command %s", command);
SOAPCommand connection;
sLog.outString("SoapThread: Recieved command %s", command);
SOAPCommand connection;
// commands are executed in the world thread and have to wait till they are completed.
{
CliCommandHolder* cmd = new CliCommandHolder(accountId, SEC_CONSOLE, &connection, command, &SOAPCommand::print, &SOAPCommand::commandFinished);
sWorld.QueueCliCommand(cmd);
}
// commands are executed in the world thread and have to wait till they are completed.
{
CliCommandHolder* cmd = new CliCommandHolder(accountId, SEC_CONSOLE, &connection, command, &SOAPCommand::print, &SOAPCommand::commandFinished);
sWorld.QueueCliCommand(cmd);
}
// wait until the command has finished executing
connection.finishedPromise.get_future().wait();
// wait until the command has finished executing
connection.finishedPromise.get_future().wait();
// the command has finished executing already
char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str());
if (connection.hasCommandSucceeded())
{
*result = printBuffer;
return SOAP_OK;
}
else
{
return soap_sender_fault(soap, printBuffer, printBuffer);
}
// the command has finished executing already
char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str());
if (connection.hasCommandSucceeded())
{
*result = printBuffer;
return SOAP_OK;
}
else
{
return soap_sender_fault(soap, printBuffer, printBuffer);
}
}
void SOAPCommand::commandFinished(void* soapconnection, bool success)
{
SOAPCommand* con = (SOAPCommand*)soapconnection;
con->setCommandSuccess(success);
SOAPCommand* con = (SOAPCommand*)soapconnection;
con->setCommandSuccess(success);
}
////////////////////////////////////////////////////////////////////////////////
@ -147,10 +147,10 @@ void SOAPCommand::commandFinished(void* soapconnection, bool success)
struct Namespace namespaces[] =
{
{ "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/" }, // must be first
{ "SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/" }, // must be second
{ "xsi", "http://www.w3.org/1999/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance" },
{ "xsd", "http://www.w3.org/1999/XMLSchema", "http://www.w3.org/*/XMLSchema" },
{ "ns1", "urn:MaNGOS" }, // "ns1" namespace prefix
{ NULL, NULL }
{ "SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/" }, // must be first
{ "SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/" }, // must be second
{ "xsi", "http://www.w3.org/1999/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance" },
{ "xsd", "http://www.w3.org/1999/XMLSchema", "http://www.w3.org/*/XMLSchema" },
{ "ns1", "urn:MaNGOS" }, // "ns1" namespace prefix
{ NULL, NULL }
};

View File

@ -37,35 +37,35 @@ void SoapThread(const std::string& host, uint16 port);
class SOAPCommand
{
public:
SOAPCommand() : m_success(false) { }
~SOAPCommand() { }
SOAPCommand() : m_success(false) { }
~SOAPCommand() { }
void appendToPrintBuffer(std::string msg)
{
m_printBuffer += msg;
}
void appendToPrintBuffer(std::string msg)
{
m_printBuffer += msg;
}
void setCommandSuccess(bool val)
{
m_success = val;
finishedPromise.set_value();
}
void setCommandSuccess(bool val)
{
m_success = val;
finishedPromise.set_value();
}
bool hasCommandSucceeded() const
{
return m_success;
}
bool hasCommandSucceeded() const
{
return m_success;
}
static void print(void* callbackArg, const char* msg)
{
((SOAPCommand*)callbackArg)->appendToPrintBuffer(msg);
}
static void print(void* callbackArg, const char* msg)
{
((SOAPCommand*)callbackArg)->appendToPrintBuffer(msg);
}
static void commandFinished(void* callbackArg, bool success);
static void commandFinished(void* callbackArg, bool success);
bool m_success;
std::string m_printBuffer;
std::promise<void> finishedPromise;
bool m_success;
std::string m_printBuffer;
std::promise<void> finishedPromise;
};
#endif

View File

@ -289,9 +289,9 @@ void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot)
vector<WorldLocation> locs;
QueryResult* results = WorldDatabase.PQuery("SELECT `map`, `position_x`, `position_y`, `position_z` FROM ("
"SELECT MIN(`c`.`map`) `map`, MIN(`c`.`position_x`) `position_x`, MIN(`c`.`position_y`) `position_y`, "
"MIN(`c`.`position_z`) `position_z`, AVG(`t`.`maxlevel`), AVG(`t`.`minlevel`), "
"MIN(`c`.`position_z`) `position_z`, AVG(`t`.`maxlevel`), AVG(`t`.`minlevel`), "
"%u - (AVG(`t`.`maxlevel`) + AVG(`t`.`minlevel`)) / 2 `delta` FROM `creature` `c` "
"INNER JOIN `creature_template` `t` ON `c`.`id` = `t`.`entry` GROUP BY `t`.`entry`) `q` "
"INNER JOIN `creature_template` `t` ON `c`.`id` = `t`.`entry` GROUP BY `t`.`entry`) `q` "
"WHERE `delta` >= 0 AND `delta` <= %u AND `map` IN (%s)",
bot->getLevel(), sPlayerbotAIConfig.randomBotTeleLevel, sPlayerbotAIConfig.randomBotMapsAsString.c_str());

@ -1 +1 @@
Subproject commit 822868222f6f210eb7a34e773ad62a18c407e4f3
Subproject commit 47cbde362f5886dc6a19735856276b1d9a00e660

View File

@ -537,19 +537,19 @@ bool Database::RollbackTransaction()
// TODO : Depending on the case do not use Error but Warning, so will need to ad a function pointer in args
void PrintYouHaveDatabaseVersion(uint32 current_db_version, uint32 current_db_structure, uint32 current_db_content, std::string description)
{
sLog.outErrorDb(" [A] You have database Version: %u", current_db_version);
sLog.outErrorDb(" Structure: %u", current_db_structure);
sLog.outErrorDb(" Content: %u", current_db_content);
sLog.outErrorDb(" Description: %s", description.c_str());
sLog.outErrorDb(" [A] You have database Version: %u", current_db_version);
sLog.outErrorDb(" Structure: %u", current_db_structure);
sLog.outErrorDb(" Content: %u", current_db_content);
sLog.outErrorDb(" Description: %s", description.c_str());
}
// TODO : Depending on the case do not use Error but Warning, so will need to ad a function pointer in args
void PrintYouNeedDatabaseVersionExpectedByCore(const DBVersion& core_db_requirements)
{
sLog.outErrorDb(" [B] The core needs database Version: %u", core_db_requirements.expected_version);
sLog.outErrorDb(" Structure: %u", core_db_requirements.expected_structure);
sLog.outErrorDb(" Content: %u", core_db_requirements.minimal_expected_content);
sLog.outErrorDb(" Description: %s", core_db_requirements.description.c_str());
sLog.outErrorDb(" [B] The core needs database Version: %u", core_db_requirements.expected_version);
sLog.outErrorDb(" Structure: %u", core_db_requirements.expected_structure);
sLog.outErrorDb(" Content: %u", core_db_requirements.minimal_expected_content);
sLog.outErrorDb(" Description: %s", core_db_requirements.description.c_str());
}
bool Database::CheckDatabaseVersion(DatabaseTypes database)
@ -596,15 +596,15 @@ bool Database::CheckDatabaseVersion(DatabaseTypes database)
return false;
}
bool db_vs_core_content_version_mismatch = false;
bool db_vs_core_content_version_mismatch = false;
// DB is not up to date, but structure is correct.
// The 'content' version in the 'db_version' table can be < from the one required by the core
// See enum values for :
// WORLD_DB_CONTENT_NR
// CHAR_DB_CONTENT_NR
// REALMD_DB_CONTENT_NR
// for more information.
// The 'content' version in the 'db_version' table can be < from the one required by the core
// See enum values for :
// WORLD_DB_CONTENT_NR
// CHAR_DB_CONTENT_NR
// REALMD_DB_CONTENT_NR
// for more information.
if (current_db_content < core_db_requirements.minimal_expected_content)
{
// TODO : Should not display with error color but warning (e.g YELLOW) => Create a sLog.outWarningDb() and sLog.outWarning()
@ -615,7 +615,7 @@ bool Database::CheckDatabaseVersion(DatabaseTypes database)
sLog.outErrorDb("This is ok for now but should not last long.");
db_vs_core_content_version_mismatch = true;
}
// Else if the 'content' version in the 'db_version' table is > to the on expected by the core
// Else if the 'content' version in the 'db_version' table is > to the on expected by the core
else if (current_db_content > core_db_requirements.minimal_expected_content)
{
// TODO : Should not display with error color but warning (e.g YELLOW) => Create a sLog.outWarningDb() and sLog.outWarning()
@ -625,16 +625,16 @@ bool Database::CheckDatabaseVersion(DatabaseTypes database)
db_vs_core_content_version_mismatch = true;
};
// In anys cases if there are differences in content : output a recap of the differences :
if (db_vs_core_content_version_mismatch)
{
// In anys cases if there are differences in content : output a recap of the differences :
if (db_vs_core_content_version_mismatch)
{
// TODO : Should not display with error color but warning (e.g YELLOW) => Create a sLog.outWarningDb() and sLog.outWarning()
sLog.outErrorDb("The table `db_version` indicates that your [%s] database does not match the expected version!", core_db_requirements.dbname.c_str());
sLog.outErrorDb();
PrintYouHaveDatabaseVersion(current_db_version, current_db_structure, current_db_content, description);
sLog.outErrorDb();
PrintYouNeedDatabaseVersionExpectedByCore(core_db_requirements);
}
}
return true;
}

View File

@ -31,171 +31,171 @@
// New Method
inline std::chrono::steady_clock::time_point GetApplicationStartTime()
{
using namespace std::chrono;
using namespace std::chrono;
static const steady_clock::time_point ApplicationStartTime = steady_clock::now();
static const steady_clock::time_point ApplicationStartTime = steady_clock::now();
return ApplicationStartTime;
return ApplicationStartTime;
}
inline uint32 getMSTime()
{
using namespace std::chrono;
using namespace std::chrono;
return uint32(duration_cast<milliseconds>(steady_clock::now() - GetApplicationStartTime()).count());
return uint32(duration_cast<milliseconds>(steady_clock::now() - GetApplicationStartTime()).count());
}
inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
{
// getMSTime() have limited data range and this is case when it overflow in this tick
if (oldMSTime > newMSTime)
{
return (0xFFFFFFFF - oldMSTime) + newMSTime;
}
else
{
return newMSTime - oldMSTime;
}
// getMSTime() have limited data range and this is case when it overflow in this tick
if (oldMSTime > newMSTime)
{
return (0xFFFFFFFF - oldMSTime) + newMSTime;
}
else
{
return newMSTime - oldMSTime;
}
}
inline uint32 getMSTimeDiff(uint32 oldMSTime, std::chrono::steady_clock::time_point newTime)
{
using namespace std::chrono;
using namespace std::chrono;
uint32 newMSTime = uint32(duration_cast<milliseconds>(newTime - GetApplicationStartTime()).count());
return getMSTimeDiff(oldMSTime, newMSTime);
uint32 newMSTime = uint32(duration_cast<milliseconds>(newTime - GetApplicationStartTime()).count());
return getMSTimeDiff(oldMSTime, newMSTime);
}
inline uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
{
return getMSTimeDiff(oldMSTime, getMSTime());
return getMSTimeDiff(oldMSTime, getMSTime());
}
struct IntervalTimer
{
public:
IntervalTimer() : _interval(0), _current(0) { }
IntervalTimer() : _interval(0), _current(0) { }
void Update(time_t diff)
{
_current += diff;
if (_current < 0)
{
_current = 0;
}
}
void Update(time_t diff)
{
_current += diff;
if (_current < 0)
{
_current = 0;
}
}
bool Passed()
{
return _current >= _interval;
}
bool Passed()
{
return _current >= _interval;
}
void Reset()
{
if (_current >= _interval)
{
_current %= _interval;
}
}
void Reset()
{
if (_current >= _interval)
{
_current %= _interval;
}
}
void SetCurrent(time_t current)
{
_current = current;
}
void SetCurrent(time_t current)
{
_current = current;
}
void SetInterval(time_t interval)
{
_interval = interval;
}
void SetInterval(time_t interval)
{
_interval = interval;
}
time_t GetInterval() const
{
return _interval;
}
time_t GetInterval() const
{
return _interval;
}
time_t GetCurrent() const
{
return _current;
}
time_t GetCurrent() const
{
return _current;
}
private:
time_t _interval;
time_t _current;
time_t _interval;
time_t _current;
};
struct TimeTracker
{
public:
TimeTracker(int32 expiry = 0) : _expiryTime(expiry) { }
TimeTracker(Milliseconds expiry) : _expiryTime(expiry) { }
TimeTracker(int32 expiry = 0) : _expiryTime(expiry) { }
TimeTracker(Milliseconds expiry) : _expiryTime(expiry) { }
void Update(int32 diff)
{
Update(Milliseconds(diff));
}
void Update(int32 diff)
{
Update(Milliseconds(diff));
}
void Update(Milliseconds diff)
{
_expiryTime -= diff;
}
void Update(Milliseconds diff)
{
_expiryTime -= diff;
}
bool Passed() const
{
return _expiryTime <= Seconds(0);
}
bool Passed() const
{
return _expiryTime <= Seconds(0);
}
void Reset(int32 expiry)
{
Reset(Milliseconds(expiry));
}
void Reset(int32 expiry)
{
Reset(Milliseconds(expiry));
}
void Reset(Milliseconds expiry)
{
_expiryTime = expiry;
}
void Reset(Milliseconds expiry)
{
_expiryTime = expiry;
}
Milliseconds GetExpiry() const
{
return _expiryTime;
}
Milliseconds GetExpiry() const
{
return _expiryTime;
}
private:
Milliseconds _expiryTime;
Milliseconds _expiryTime;
};
struct PeriodicTimer
{
public:
PeriodicTimer(int32 period, int32 start_time) :
i_period(period), i_expireTime(start_time) { }
PeriodicTimer(int32 period, int32 start_time) :
i_period(period), i_expireTime(start_time) { }
bool Update(const uint32 diff)
{
if ((i_expireTime -= diff) > 0)
{
return false;
}
bool Update(const uint32 diff)
{
if ((i_expireTime -= diff) > 0)
{
return false;
}
i_expireTime += i_period > int32(diff) ? i_period : diff;
return true;
}
i_expireTime += i_period > int32(diff) ? i_period : diff;
return true;
}
void SetPeriodic(int32 period, int32 start_time)
{
i_expireTime = start_time;
i_period = period;
}
void SetPeriodic(int32 period, int32 start_time)
{
i_expireTime = start_time;
i_period = period;
}
// Tracker interface
void TUpdate(int32 diff) { i_expireTime -= diff; }
bool TPassed() const { return i_expireTime <= 0; }
void TReset(int32 diff, int32 period) { i_expireTime += period > diff ? period : diff; }
// Tracker interface
void TUpdate(int32 diff) { i_expireTime -= diff; }
bool TPassed() const { return i_expireTime <= 0; }
void TReset(int32 diff, int32 period) { i_expireTime += period > diff ? period : diff; }
private:
int32 i_period;
int32 i_expireTime;
int32 i_period;
int32 i_expireTime;
};
#endif