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" #include "GameEventMgr.h"
/********************************************************************** /**********************************************************************
CommandTable : eventCommandTable CommandTable : eventCommandTable
/***********************************************************************/ /***********************************************************************/
bool ChatHandler::HandleEventListCommand(char* args) bool ChatHandler::HandleEventListCommand(char* args)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,49 +35,49 @@
class UpdateTime class UpdateTime
{ {
using DiffTableArray = std::array<uint32, AVG_DIFF_COUNT>; using DiffTableArray = std::array<uint32, AVG_DIFF_COUNT>;
public: public:
uint32 GetAverageUpdateTime() const; uint32 GetAverageUpdateTime() const;
uint32 GetTimeWeightedAverageUpdateTime() const; uint32 GetTimeWeightedAverageUpdateTime() const;
uint32 GetMaxUpdateTime() const; uint32 GetMaxUpdateTime() const;
uint32 GetMaxUpdatTimeOfCurrentTable() const; uint32 GetMaxUpdatTimeOfCurrentTable() const;
uint32 GetLastUpdateTime() const; uint32 GetLastUpdateTime() const;
void UpdateWithDiff(uint32 diff); void UpdateWithDiff(uint32 diff);
void RecordUpdateTimeReset(); void RecordUpdateTimeReset();
protected: protected:
UpdateTime(); UpdateTime();
void _RecordUpdateTimeDuration(std::string const& text, uint32 minUpdateTime); void _RecordUpdateTimeDuration(std::string const& text, uint32 minUpdateTime);
private: private:
DiffTableArray _updateTimeDataTable; DiffTableArray _updateTimeDataTable;
uint32 _averageUpdateTime; uint32 _averageUpdateTime;
uint32 _totalUpdateTime; uint32 _totalUpdateTime;
uint32 _updateTimeTableIndex; uint32 _updateTimeTableIndex;
uint32 _maxUpdateTime; uint32 _maxUpdateTime;
uint32 _maxUpdateTimeOfLastTable; uint32 _maxUpdateTimeOfLastTable;
uint32 _maxUpdateTimeOfCurrentTable; uint32 _maxUpdateTimeOfCurrentTable;
uint32 _recordedTime; uint32 _recordedTime;
}; };
class WorldUpdateTime : public UpdateTime class WorldUpdateTime : public UpdateTime
{ {
public: public:
WorldUpdateTime() : UpdateTime(), _recordUpdateTimeInverval(0), _recordUpdateTimeMin(0), _lastRecordTime(0) { } WorldUpdateTime() : UpdateTime(), _recordUpdateTimeInverval(0), _recordUpdateTimeMin(0), _lastRecordTime(0) { }
void LoadFromConfig(); void LoadFromConfig();
void SetRecordUpdateTimeInterval(uint32 t); void SetRecordUpdateTimeInterval(uint32 t);
void RecordUpdateTime(uint32 gameTimeMs, uint32 diff, uint32 sessionCount); void RecordUpdateTime(uint32 gameTimeMs, uint32 diff, uint32 sessionCount);
void RecordUpdateTimeDuration(std::string const& text); void RecordUpdateTimeDuration(std::string const& text);
private: private:
uint32 _recordUpdateTimeInverval; uint32 _recordUpdateTimeInverval;
uint32 _recordUpdateTimeMin; uint32 _recordUpdateTimeMin;
uint32 _lastRecordTime; uint32 _lastRecordTime;
}; };
extern WorldUpdateTime sWorldUpdateTime; 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 // for riding spells, override the levels with the levels from the configuration file
switch (tSpell->spell) { switch (tSpell->spell) {
case 33388: case 33388:
case 33389: // Apprentice Riding case 33389: // Apprentice Riding
reqLevel = AccountTypes(sWorld.getConfig(CONFIG_UINT32_MIN_TRAIN_MOUNT_LEVEL)); reqLevel = AccountTypes(sWorld.getConfig(CONFIG_UINT32_MIN_TRAIN_MOUNT_LEVEL));
break; break;
case 33391: case 33391:
case 33392: // Journeyman Riding case 33392: // Journeyman Riding
reqLevel = AccountTypes(sWorld.getConfig(CONFIG_UINT32_MIN_TRAIN_EPIC_MOUNT_LEVEL)); reqLevel = AccountTypes(sWorld.getConfig(CONFIG_UINT32_MIN_TRAIN_EPIC_MOUNT_LEVEL));
break; break;

View File

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

View File

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

View File

@ -289,9 +289,9 @@ void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot)
vector<WorldLocation> locs; vector<WorldLocation> locs;
QueryResult* results = WorldDatabase.PQuery("SELECT `map`, `position_x`, `position_y`, `position_z` FROM (" 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`, " "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` " "%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)", "WHERE `delta` >= 0 AND `delta` <= %u AND `map` IN (%s)",
bot->getLevel(), sPlayerbotAIConfig.randomBotTeleLevel, sPlayerbotAIConfig.randomBotMapsAsString.c_str()); 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 // 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) 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(" [A] You have database Version: %u", current_db_version);
sLog.outErrorDb(" Structure: %u", current_db_structure); sLog.outErrorDb(" Structure: %u", current_db_structure);
sLog.outErrorDb(" Content: %u", current_db_content); sLog.outErrorDb(" Content: %u", current_db_content);
sLog.outErrorDb(" Description: %s", description.c_str()); 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 // 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) void PrintYouNeedDatabaseVersionExpectedByCore(const DBVersion& core_db_requirements)
{ {
sLog.outErrorDb(" [B] The core needs database Version: %u", core_db_requirements.expected_version); 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(" Structure: %u", core_db_requirements.expected_structure);
sLog.outErrorDb(" Content: %u", core_db_requirements.minimal_expected_content); sLog.outErrorDb(" Content: %u", core_db_requirements.minimal_expected_content);
sLog.outErrorDb(" Description: %s", core_db_requirements.description.c_str()); sLog.outErrorDb(" Description: %s", core_db_requirements.description.c_str());
} }
bool Database::CheckDatabaseVersion(DatabaseTypes database) bool Database::CheckDatabaseVersion(DatabaseTypes database)
@ -596,15 +596,15 @@ bool Database::CheckDatabaseVersion(DatabaseTypes database)
return false; 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. // 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 // The 'content' version in the 'db_version' table can be < from the one required by the core
// See enum values for : // See enum values for :
// WORLD_DB_CONTENT_NR // WORLD_DB_CONTENT_NR
// CHAR_DB_CONTENT_NR // CHAR_DB_CONTENT_NR
// REALMD_DB_CONTENT_NR // REALMD_DB_CONTENT_NR
// for more information. // for more information.
if (current_db_content < core_db_requirements.minimal_expected_content) 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() // 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."); sLog.outErrorDb("This is ok for now but should not last long.");
db_vs_core_content_version_mismatch = true; 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) 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() // 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; db_vs_core_content_version_mismatch = true;
}; };
// In anys cases if there are differences in content : output a recap of the differences : // In anys cases if there are differences in content : output a recap of the differences :
if (db_vs_core_content_version_mismatch) 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() // 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("The table `db_version` indicates that your [%s] database does not match the expected version!", core_db_requirements.dbname.c_str());
sLog.outErrorDb(); sLog.outErrorDb();
PrintYouHaveDatabaseVersion(current_db_version, current_db_structure, current_db_content, description); PrintYouHaveDatabaseVersion(current_db_version, current_db_structure, current_db_content, description);
sLog.outErrorDb(); sLog.outErrorDb();
PrintYouNeedDatabaseVersionExpectedByCore(core_db_requirements); PrintYouNeedDatabaseVersionExpectedByCore(core_db_requirements);
} }
return true; return true;
} }

View File

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