mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-28 08:51:39 +00:00
Some of these really slow down profiling without adding much (short functions)
This commit is contained in:
parent
8e45fd2253
commit
b26d9c07f1
@ -23,7 +23,6 @@
|
||||
|
||||
BasePacket::BasePacket(const unsigned char *buf, uint32 len)
|
||||
{
|
||||
_eqp
|
||||
this->pBuffer=nullptr;
|
||||
this->size=0;
|
||||
this->_wpos = 0;
|
||||
@ -42,7 +41,6 @@ BasePacket::BasePacket(const unsigned char *buf, uint32 len)
|
||||
|
||||
BasePacket::~BasePacket()
|
||||
{
|
||||
_eqp
|
||||
if (pBuffer)
|
||||
delete[] pBuffer;
|
||||
pBuffer=nullptr;
|
||||
@ -51,7 +49,6 @@ BasePacket::~BasePacket()
|
||||
|
||||
void BasePacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
_eqp
|
||||
if (timestamp.tv_sec) {
|
||||
char temp[20];
|
||||
strftime(temp,20,"%F %T",localtime((const time_t *)×tamp.tv_sec));
|
||||
@ -69,7 +66,6 @@ void BasePacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
|
||||
void BasePacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
char buff[128];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
@ -77,13 +73,11 @@ void BasePacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
|
||||
void BasePacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
_eqp
|
||||
sprintf(buffer, "[packet]\n");
|
||||
}
|
||||
|
||||
void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
@ -96,7 +90,6 @@ void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
|
||||
void BasePacket::DumpRaw(FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
DumpRawHeader();
|
||||
if (pBuffer && size)
|
||||
dump_message_column(pBuffer, size, " ", to);
|
||||
@ -105,7 +98,6 @@ void BasePacket::DumpRaw(FILE *to) const
|
||||
|
||||
void BasePacket::ReadString(char *str, uint32 Offset, uint32 MaxLength) const
|
||||
{
|
||||
_eqp
|
||||
uint32 i = 0, j = Offset;
|
||||
|
||||
do
|
||||
@ -119,18 +111,15 @@ void BasePacket::ReadString(char *str, uint32 Offset, uint32 MaxLength) const
|
||||
|
||||
void DumpPacketHex(const BasePacket* app)
|
||||
{
|
||||
_eqp
|
||||
DumpPacketHex(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
void DumpPacketAscii(const BasePacket* app)
|
||||
{
|
||||
_eqp
|
||||
DumpPacketAscii(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
void DumpPacketBin(const BasePacket* app) {
|
||||
_eqp
|
||||
DumpPacketBin(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
#endif
|
||||
|
||||
DBcore::DBcore() {
|
||||
_eqp
|
||||
mysql_init(&mysql);
|
||||
pHost = 0;
|
||||
pUser = 0;
|
||||
@ -42,7 +41,6 @@ DBcore::DBcore() {
|
||||
}
|
||||
|
||||
DBcore::~DBcore() {
|
||||
_eqp
|
||||
mysql_close(&mysql);
|
||||
safe_delete_array(pHost);
|
||||
safe_delete_array(pUser);
|
||||
@ -52,7 +50,6 @@ DBcore::~DBcore() {
|
||||
|
||||
// Sends the MySQL server a keepalive
|
||||
void DBcore::ping() {
|
||||
_eqp
|
||||
if (!MDatabase.trylock()) {
|
||||
// well, if's it's locked, someone's using it. If someone's using it, it doesnt need a keepalive
|
||||
return;
|
||||
@ -63,13 +60,11 @@ void DBcore::ping() {
|
||||
|
||||
MySQLRequestResult DBcore::QueryDatabase(std::string query, bool retryOnFailureOnce)
|
||||
{
|
||||
_eqp
|
||||
return QueryDatabase(query.c_str(), query.length(), retryOnFailureOnce);
|
||||
}
|
||||
|
||||
MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce)
|
||||
{
|
||||
_eqp
|
||||
LockMutex lock(&MDatabase);
|
||||
|
||||
// Reconnect if we are not connected before hand.
|
||||
@ -139,29 +134,24 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo
|
||||
}
|
||||
|
||||
void DBcore::TransactionBegin() {
|
||||
_eqp
|
||||
QueryDatabase("START TRANSACTION");
|
||||
}
|
||||
|
||||
void DBcore::TransactionCommit() {
|
||||
_eqp
|
||||
QueryDatabase("COMMIT");
|
||||
}
|
||||
|
||||
void DBcore::TransactionRollback() {
|
||||
_eqp
|
||||
QueryDatabase("ROLLBACK");
|
||||
}
|
||||
|
||||
uint32 DBcore::DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen) {
|
||||
_eqp
|
||||
// No good reason to lock the DB, we only need it in the first place to check char encoding.
|
||||
// LockMutex lock(&MDatabase);
|
||||
return mysql_real_escape_string(&mysql, tobuf, frombuf, fromlen);
|
||||
}
|
||||
|
||||
bool DBcore::Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase,uint32 iPort, uint32* errnum, char* errbuf, bool iCompress, bool iSSL) {
|
||||
_eqp
|
||||
LockMutex lock(&MDatabase);
|
||||
safe_delete(pHost);
|
||||
safe_delete(pUser);
|
||||
@ -178,7 +168,6 @@ bool DBcore::Open(const char* iHost, const char* iUser, const char* iPassword, c
|
||||
}
|
||||
|
||||
bool DBcore::Open(uint32* errnum, char* errbuf) {
|
||||
_eqp
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
LockMutex lock(&MDatabase);
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
|
||||
|
||||
EQStreamIdentifier::~EQStreamIdentifier() {
|
||||
_eqp
|
||||
while(!m_identified.empty()) {
|
||||
m_identified.front()->ReleaseFromUse();
|
||||
m_identified.pop();
|
||||
@ -26,7 +25,6 @@ EQStreamIdentifier::~EQStreamIdentifier() {
|
||||
}
|
||||
|
||||
void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs) {
|
||||
_eqp
|
||||
Patch *p = new Patch;
|
||||
p->signature = sig;
|
||||
p->name = name;
|
||||
@ -36,7 +34,6 @@ void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const cha
|
||||
}
|
||||
|
||||
void EQStreamIdentifier::Process() {
|
||||
_eqp
|
||||
std::vector<Record>::iterator cur;
|
||||
std::vector<Patch *>::iterator curp, endp;
|
||||
|
||||
@ -146,13 +143,11 @@ void EQStreamIdentifier::Process() {
|
||||
}
|
||||
|
||||
void EQStreamIdentifier::AddStream(std::shared_ptr<EQStream> &eqs) {
|
||||
_eqp
|
||||
m_streams.push_back(Record(eqs));
|
||||
eqs = nullptr;
|
||||
}
|
||||
|
||||
EQStreamInterface *EQStreamIdentifier::PopIdentified() {
|
||||
_eqp
|
||||
if(m_identified.empty())
|
||||
return(nullptr);
|
||||
EQStreamInterface *res = m_identified.front();
|
||||
@ -164,6 +159,5 @@ EQStreamIdentifier::Record::Record(std::shared_ptr<EQStream> s)
|
||||
: stream(s),
|
||||
expire(STREAM_IDENT_WAIT_MS)
|
||||
{
|
||||
_eqp
|
||||
}
|
||||
|
||||
|
||||
@ -10,28 +10,23 @@ EQStreamProxy::EQStreamProxy(std::shared_ptr<EQStream> &stream, const StructStra
|
||||
m_structs(structs),
|
||||
m_opcodes(opcodes)
|
||||
{
|
||||
_eqp
|
||||
stream = nullptr; //take the stream.
|
||||
m_stream->SetOpcodeManager(m_opcodes);
|
||||
}
|
||||
|
||||
EQStreamProxy::~EQStreamProxy() {
|
||||
_eqp
|
||||
}
|
||||
|
||||
std::string EQStreamProxy::Describe() const {
|
||||
_eqp
|
||||
return(m_structs->Describe());
|
||||
}
|
||||
|
||||
const ClientVersion EQStreamProxy::GetClientVersion() const
|
||||
{
|
||||
_eqp
|
||||
return m_structs->GetClientVersion();
|
||||
}
|
||||
|
||||
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
|
||||
_eqp
|
||||
if(p == nullptr)
|
||||
return;
|
||||
|
||||
@ -40,14 +35,12 @@ void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
|
||||
}
|
||||
|
||||
void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) {
|
||||
_eqp
|
||||
if(p == nullptr || *p == nullptr)
|
||||
return;
|
||||
m_structs->Encode(p, m_stream, ack_req);
|
||||
}
|
||||
|
||||
EQApplicationPacket *EQStreamProxy::PopPacket() {
|
||||
_eqp
|
||||
EQApplicationPacket *pack = m_stream->PopPacket();
|
||||
if(pack == nullptr)
|
||||
return(nullptr);
|
||||
@ -58,56 +51,46 @@ EQApplicationPacket *EQStreamProxy::PopPacket() {
|
||||
}
|
||||
|
||||
void EQStreamProxy::Close() {
|
||||
_eqp
|
||||
m_stream->Close();
|
||||
}
|
||||
|
||||
uint32 EQStreamProxy::GetRemoteIP() const {
|
||||
_eqp
|
||||
return(m_stream->GetRemoteIP());
|
||||
}
|
||||
|
||||
uint16 EQStreamProxy::GetRemotePort() const {
|
||||
_eqp
|
||||
return(m_stream->GetRemotePort());
|
||||
}
|
||||
|
||||
const uint32 EQStreamProxy::GetBytesSent() const
|
||||
{
|
||||
_eqp
|
||||
return(m_stream->GetBytesSent());
|
||||
}
|
||||
|
||||
const uint32 EQStreamProxy::GetBytesRecieved() const
|
||||
{
|
||||
_eqp
|
||||
return(m_stream->GetBytesRecieved());
|
||||
}
|
||||
|
||||
const uint32 EQStreamProxy::GetBytesSentPerSecond() const
|
||||
{
|
||||
_eqp
|
||||
return(m_stream->GetBytesSentPerSecond());
|
||||
}
|
||||
|
||||
const uint32 EQStreamProxy::GetBytesRecvPerSecond() const
|
||||
{
|
||||
_eqp
|
||||
return(m_stream->GetBytesRecvPerSecond());
|
||||
}
|
||||
|
||||
void EQStreamProxy::ReleaseFromUse() {
|
||||
_eqp
|
||||
m_stream->ReleaseFromUse();
|
||||
}
|
||||
|
||||
void EQStreamProxy::RemoveData() {
|
||||
_eqp
|
||||
m_stream->RemoveData();
|
||||
}
|
||||
|
||||
bool EQStreamProxy::CheckState(EQStreamState state) {
|
||||
_eqp
|
||||
if(m_stream)
|
||||
return(m_stream->CheckState(state));
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ MySQLRequestResult::MySQLRequestResult()
|
||||
MySQLRequestResult::MySQLRequestResult(MYSQL_RES* result, uint32 rowsAffected, uint32 rowCount, uint32 columnCount, uint32 lastInsertedID, uint32 errorNumber, char *errorBuffer)
|
||||
: m_CurrentRow(result), m_OneBeyondRow()
|
||||
{
|
||||
_eqp
|
||||
m_Result = result;
|
||||
m_RowsAffected = rowsAffected;
|
||||
m_RowCount = rowCount;
|
||||
@ -33,7 +32,6 @@ MySQLRequestResult::MySQLRequestResult(MYSQL_RES* result, uint32 rowsAffected, u
|
||||
|
||||
void MySQLRequestResult::FreeInternals()
|
||||
{
|
||||
_eqp
|
||||
safe_delete_array(m_ErrorBuffer);
|
||||
|
||||
if (m_Result != nullptr)
|
||||
@ -44,7 +42,6 @@ void MySQLRequestResult::FreeInternals()
|
||||
|
||||
void MySQLRequestResult::ZeroOut()
|
||||
{
|
||||
_eqp
|
||||
m_Success = false;
|
||||
m_Result = nullptr;
|
||||
m_ErrorBuffer = nullptr;
|
||||
@ -57,13 +54,11 @@ void MySQLRequestResult::ZeroOut()
|
||||
|
||||
MySQLRequestResult::~MySQLRequestResult()
|
||||
{
|
||||
_eqp
|
||||
FreeInternals();
|
||||
}
|
||||
|
||||
uint32 MySQLRequestResult::LengthOfColumn(int columnIndex)
|
||||
{
|
||||
_eqp
|
||||
if (m_ColumnLengths == nullptr && m_Result != nullptr)
|
||||
m_ColumnLengths = mysql_fetch_lengths(m_Result);
|
||||
|
||||
@ -86,7 +81,6 @@ uint32 MySQLRequestResult::LengthOfColumn(int columnIndex)
|
||||
|
||||
const std::string MySQLRequestResult::FieldName(int columnIndex)
|
||||
{
|
||||
_eqp
|
||||
if (columnIndex >= m_ColumnCount || m_Result == nullptr)
|
||||
return std::string();
|
||||
|
||||
@ -99,7 +93,6 @@ const std::string MySQLRequestResult::FieldName(int columnIndex)
|
||||
MySQLRequestResult::MySQLRequestResult(MySQLRequestResult&& moveItem)
|
||||
: m_CurrentRow(moveItem.m_CurrentRow), m_OneBeyondRow()
|
||||
{
|
||||
_eqp
|
||||
m_Result = moveItem.m_Result;
|
||||
m_ErrorBuffer = moveItem.m_ErrorBuffer;
|
||||
m_Success = moveItem.m_Success;
|
||||
@ -117,7 +110,6 @@ MySQLRequestResult::MySQLRequestResult(MySQLRequestResult&& moveItem)
|
||||
|
||||
MySQLRequestResult& MySQLRequestResult::operator=(MySQLRequestResult&& other)
|
||||
{
|
||||
_eqp
|
||||
// Assigning something to itself?
|
||||
// Silly! (but happens)
|
||||
if (this == &other)
|
||||
|
||||
@ -12,7 +12,6 @@ MySQLRequestRow::MySQLRequestRow()
|
||||
|
||||
MySQLRequestRow::MySQLRequestRow(MySQLRequestRow&& moveItem)
|
||||
{
|
||||
_eqp
|
||||
m_Result = moveItem.m_Result;
|
||||
m_MySQLRow = moveItem.m_MySQLRow;
|
||||
|
||||
@ -22,7 +21,6 @@ MySQLRequestRow::MySQLRequestRow(MySQLRequestRow&& moveItem)
|
||||
|
||||
MySQLRequestRow& MySQLRequestRow::operator=(MySQLRequestRow& moveItem)
|
||||
{
|
||||
_eqp
|
||||
m_Result = moveItem.m_Result;
|
||||
m_MySQLRow = moveItem.m_MySQLRow;
|
||||
|
||||
@ -35,14 +33,12 @@ MySQLRequestRow& MySQLRequestRow::operator=(MySQLRequestRow& moveItem)
|
||||
|
||||
MySQLRequestRow MySQLRequestRow::operator*()
|
||||
{
|
||||
_eqp
|
||||
return *this;
|
||||
}
|
||||
|
||||
MySQLRequestRow::MySQLRequestRow(MYSQL_RES *result)
|
||||
: m_Result(result)
|
||||
{
|
||||
_eqp
|
||||
if (result != nullptr)
|
||||
m_MySQLRow = mysql_fetch_row(result);
|
||||
else
|
||||
@ -51,14 +47,12 @@ MySQLRequestRow::MySQLRequestRow(MYSQL_RES *result)
|
||||
|
||||
MySQLRequestRow& MySQLRequestRow::operator++()
|
||||
{
|
||||
_eqp
|
||||
m_MySQLRow = mysql_fetch_row(m_Result);
|
||||
return *this;
|
||||
}
|
||||
|
||||
MySQLRequestRow MySQLRequestRow::operator++(int)
|
||||
{
|
||||
_eqp
|
||||
MySQLRequestRow tmp(*this);
|
||||
operator++();
|
||||
return tmp;
|
||||
@ -66,18 +60,15 @@ MySQLRequestRow MySQLRequestRow::operator++(int)
|
||||
|
||||
bool MySQLRequestRow::operator==(const MySQLRequestRow& rhs)
|
||||
{
|
||||
_eqp
|
||||
return m_MySQLRow == rhs.m_MySQLRow;
|
||||
}
|
||||
|
||||
bool MySQLRequestRow::operator!=(const MySQLRequestRow& rhs)
|
||||
{
|
||||
_eqp
|
||||
return m_MySQLRow != rhs.m_MySQLRow;
|
||||
}
|
||||
|
||||
char* MySQLRequestRow::operator[](int index)
|
||||
{
|
||||
_eqp
|
||||
return m_MySQLRow[index];
|
||||
}
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
#include "../common/servertalk.h"
|
||||
|
||||
void DumpPacketAscii(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
||||
_eqp
|
||||
// Output as ASCII
|
||||
for(uint32 i=skip; i<size; i++)
|
||||
{
|
||||
@ -50,7 +49,6 @@ void DumpPacketAscii(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
||||
}
|
||||
|
||||
void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
||||
_eqp
|
||||
if (size == 0 || size > 39565)
|
||||
return;
|
||||
// Output as HEX
|
||||
@ -93,7 +91,6 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
||||
}
|
||||
|
||||
std::string DumpPacketHexToString(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
||||
_eqp
|
||||
std::ostringstream out;
|
||||
if (size == 0 || size > 39565)
|
||||
return "";
|
||||
@ -143,13 +140,11 @@ std::string DumpPacketHexToString(const uchar* buf, uint32 size, uint32 cols, ui
|
||||
|
||||
void DumpPacket(const uchar* buf, uint32 size)
|
||||
{
|
||||
_eqp
|
||||
DumpPacketHex(buf, size);
|
||||
// DumpPacketAscii(buf,size);
|
||||
}
|
||||
|
||||
void DumpPacket(const ServerPacket* pack, bool iShowInfo) {
|
||||
_eqp
|
||||
if (iShowInfo) {
|
||||
std::cout << "Dumping ServerPacket: 0x" << std::hex << std::setfill('0') << std::setw(4) << pack->opcode << std::dec;
|
||||
std::cout << " size:" << pack->size << std::endl;
|
||||
@ -158,28 +153,23 @@ void DumpPacket(const ServerPacket* pack, bool iShowInfo) {
|
||||
}
|
||||
|
||||
void DumpPacketBin(const ServerPacket* pack) {
|
||||
_eqp
|
||||
DumpPacketBin(pack->pBuffer, pack->size);
|
||||
}
|
||||
|
||||
void DumpPacketBin(uint32 data) {
|
||||
_eqp
|
||||
DumpPacketBin((uchar*)&data, sizeof(uint32));
|
||||
}
|
||||
|
||||
void DumpPacketBin(uint16 data) {
|
||||
_eqp
|
||||
DumpPacketBin((uchar*)&data, sizeof(uint16));
|
||||
}
|
||||
|
||||
void DumpPacketBin(uint8 data) {
|
||||
_eqp
|
||||
DumpPacketBin((uchar*)&data, sizeof(uint8));
|
||||
}
|
||||
|
||||
|
||||
void DumpPacketBin(const void* iData, uint32 len) {
|
||||
_eqp
|
||||
if (!len)
|
||||
return;
|
||||
const uint8* data = (const uint8*) iData;
|
||||
|
||||
@ -41,7 +41,6 @@
|
||||
#include "packet_dump_file.h"
|
||||
|
||||
void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
||||
_eqp
|
||||
std::ofstream logfile(filename, std::ios::app);
|
||||
// Output as ASCII
|
||||
for(uint32 i=skip; i<size; i++)
|
||||
@ -68,7 +67,6 @@ void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, ui
|
||||
|
||||
void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip)
|
||||
{
|
||||
_eqp
|
||||
std::ofstream logfile(filename, std::ios::app);
|
||||
// Output as HEX
|
||||
char output[4];
|
||||
@ -91,7 +89,6 @@ void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, u
|
||||
|
||||
void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip)
|
||||
{
|
||||
_eqp
|
||||
if (size == 0)
|
||||
return;
|
||||
std::ofstream logfile(filename, std::ios::app);
|
||||
@ -134,19 +131,16 @@ void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint
|
||||
|
||||
void FileDumpPacketHex(const char* filename, const EQApplicationPacket* app)
|
||||
{
|
||||
_eqp
|
||||
FileDumpPacketHex(filename, app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
void FileDumpPacketAscii(const char* filename, const EQApplicationPacket* app)
|
||||
{
|
||||
_eqp
|
||||
FileDumpPacketAscii(filename, app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
void FileDumpPacket(const char* filename, const uchar* buf, uint32 size)
|
||||
{
|
||||
_eqp
|
||||
FilePrintLine(filename, true, "Size: %5i", size);
|
||||
FileDumpPacketHex(filename, buf, size);
|
||||
// FileDumpPacketAscii(filename, buf,size);
|
||||
@ -154,7 +148,6 @@ void FileDumpPacket(const char* filename, const uchar* buf, uint32 size)
|
||||
|
||||
void FileDumpPacket(const char* filename, const EQApplicationPacket* app)
|
||||
{
|
||||
_eqp
|
||||
FilePrintLine(filename, true, "Size: %5i, OPCode: 0x%04x", app->size, app->GetOpcode());
|
||||
FileDumpPacketHex(filename, app->pBuffer, app->size);
|
||||
// FileDumpPacketAscii(filename, app->pBuffer, app->size);
|
||||
@ -165,7 +158,6 @@ void FileDumpPacket(const char* filename, const EQApplicationPacket* app)
|
||||
if prefix_timestamp specified, prints the current date/time to the file + ": " + text
|
||||
*/
|
||||
void FilePrintLine(const char* filename, bool prefix_timestamp, const char* text, ...) {
|
||||
_eqp
|
||||
std::ofstream logfile(filename, std::ios::app);
|
||||
if (prefix_timestamp) {
|
||||
time_t rawtime;
|
||||
@ -190,7 +182,6 @@ void FilePrintLine(const char* filename, bool prefix_timestamp, const char* text
|
||||
}
|
||||
|
||||
void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const char* text, ...) {
|
||||
_eqp
|
||||
std::ofstream logfile(filename, std::ios::app);
|
||||
if (prefix_timestamp) {
|
||||
time_t rawtime;
|
||||
|
||||
@ -88,7 +88,6 @@ CREATE TABLE timers (
|
||||
|
||||
|
||||
PersistentTimer *PersistentTimer::LoadTimer(Database *db, uint32 char_id, pTimerType type) {
|
||||
_eqp
|
||||
PersistentTimer *p;
|
||||
p = new PersistentTimer(char_id, type, 0);
|
||||
if(p->Load(db))
|
||||
@ -98,7 +97,6 @@ PersistentTimer *PersistentTimer::LoadTimer(Database *db, uint32 char_id, pTimer
|
||||
}
|
||||
|
||||
PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_timer_time) {
|
||||
_eqp
|
||||
_char_id = char_id;
|
||||
_type = type;
|
||||
|
||||
@ -115,7 +113,6 @@ PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_time
|
||||
}
|
||||
|
||||
PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_start_time, uint32 in_timer_time, bool in_enable) {
|
||||
_eqp
|
||||
_char_id = char_id;
|
||||
_type = type;
|
||||
|
||||
@ -128,7 +125,6 @@ PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_star
|
||||
}
|
||||
|
||||
bool PersistentTimer::Load(Database *db) {
|
||||
_eqp
|
||||
|
||||
#ifdef DEBUG_PTIMERS
|
||||
printf("Loading timer: char %lu of type %u\n", (unsigned long)_char_id, _type);
|
||||
@ -155,7 +151,6 @@ bool PersistentTimer::Load(Database *db) {
|
||||
}
|
||||
|
||||
bool PersistentTimer::Store(Database *db) {
|
||||
_eqp
|
||||
if(Expired(db, false)) //dont need to store expired timers.
|
||||
return true;
|
||||
|
||||
@ -180,7 +175,6 @@ bool PersistentTimer::Store(Database *db) {
|
||||
}
|
||||
|
||||
bool PersistentTimer::Clear(Database *db) {
|
||||
_eqp
|
||||
std::string query = StringFormat("DELETE FROM timers "
|
||||
"WHERE char_id = %lu AND type = %u ",
|
||||
(unsigned long)_char_id, _type);
|
||||
@ -202,7 +196,6 @@ bool PersistentTimer::Clear(Database *db) {
|
||||
|
||||
/* This function checks if the timer triggered */
|
||||
bool PersistentTimer::Expired(Database *db, bool iReset) {
|
||||
_eqp
|
||||
if (this == nullptr) {
|
||||
Log.Out(Logs::General, Logs::Error, "Null timer during ->Check()!?\n");
|
||||
return(true);
|
||||
@ -222,7 +215,6 @@ bool PersistentTimer::Expired(Database *db, bool iReset) {
|
||||
|
||||
/* This function set the timer and restart it */
|
||||
void PersistentTimer::Start(uint32 set_timer_time) {
|
||||
_eqp
|
||||
start_time = get_current_time();
|
||||
enabled = true;
|
||||
if (set_timer_time != 0) {
|
||||
@ -235,7 +227,6 @@ void PersistentTimer::Start(uint32 set_timer_time) {
|
||||
|
||||
// This timer updates the timer without restarting it
|
||||
void PersistentTimer::SetTimer(uint32 set_timer_time) {
|
||||
_eqp
|
||||
// If we were disabled before => restart the timer
|
||||
timer_time = set_timer_time;
|
||||
if (!enabled) {
|
||||
@ -248,7 +239,6 @@ void PersistentTimer::SetTimer(uint32 set_timer_time) {
|
||||
}
|
||||
|
||||
uint32 PersistentTimer::GetRemainingTime() {
|
||||
_eqp
|
||||
if (enabled) {
|
||||
uint32 current_time = get_current_time();
|
||||
if (current_time-start_time > timer_time)
|
||||
@ -263,19 +253,16 @@ uint32 PersistentTimer::GetRemainingTime() {
|
||||
|
||||
|
||||
uint32 PersistentTimer::get_current_time() {
|
||||
_eqp
|
||||
timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
return(tv.tv_sec);
|
||||
}
|
||||
|
||||
PTimerList::PTimerList(uint32 char_id) {
|
||||
_eqp
|
||||
_char_id = char_id;
|
||||
}
|
||||
|
||||
PTimerList::~PTimerList() {
|
||||
_eqp
|
||||
std::map<pTimerType, PersistentTimer *>::iterator s;
|
||||
s = _list.begin();
|
||||
while(s != _list.end()) {
|
||||
@ -287,7 +274,6 @@ PTimerList::~PTimerList() {
|
||||
|
||||
|
||||
bool PTimerList::Load(Database *db) {
|
||||
_eqp
|
||||
|
||||
for (auto timerIterator = _list.begin(); timerIterator != _list.end(); ++timerIterator)
|
||||
if(timerIterator->second != nullptr)
|
||||
@ -332,7 +318,6 @@ bool PTimerList::Load(Database *db) {
|
||||
}
|
||||
|
||||
bool PTimerList::Store(Database *db) {
|
||||
_eqp
|
||||
#ifdef DEBUG_PTIMERS
|
||||
printf("Storing all timers for char %lu\n", (unsigned long)_char_id);
|
||||
#endif
|
||||
@ -354,7 +339,6 @@ bool PTimerList::Store(Database *db) {
|
||||
}
|
||||
|
||||
bool PTimerList::Clear(Database *db) {
|
||||
_eqp
|
||||
_list.clear();
|
||||
|
||||
std::string query = StringFormat("DELETE FROM timers WHERE char_id=%lu ", (unsigned long)_char_id);
|
||||
@ -373,7 +357,6 @@ bool PTimerList::Clear(Database *db) {
|
||||
}
|
||||
|
||||
void PTimerList::Start(pTimerType type, uint32 duration) {
|
||||
_eqp
|
||||
if(_list.count(type) == 1 && _list[type] != nullptr) {
|
||||
_list[type]->Start(duration);
|
||||
} else {
|
||||
@ -382,7 +365,6 @@ void PTimerList::Start(pTimerType type, uint32 duration) {
|
||||
}
|
||||
|
||||
void PTimerList::Clear(Database *db, pTimerType type) {
|
||||
_eqp
|
||||
if(_list.count(type) == 1) {
|
||||
if(_list[type] != nullptr) {
|
||||
_list[type]->Clear(db);
|
||||
@ -393,7 +375,6 @@ void PTimerList::Clear(Database *db, pTimerType type) {
|
||||
}
|
||||
|
||||
bool PTimerList::Expired(Database *db, pTimerType type, bool reset) {
|
||||
_eqp
|
||||
if(_list.count(type) != 1)
|
||||
return(true);
|
||||
if(_list[type] == nullptr)
|
||||
@ -402,7 +383,6 @@ bool PTimerList::Expired(Database *db, pTimerType type, bool reset) {
|
||||
}
|
||||
|
||||
bool PTimerList::Enabled(pTimerType type) {
|
||||
_eqp
|
||||
if(_list.count(type) != 1)
|
||||
return(false);
|
||||
if(_list[type] == nullptr)
|
||||
@ -411,19 +391,16 @@ bool PTimerList::Enabled(pTimerType type) {
|
||||
}
|
||||
|
||||
void PTimerList::Enable(pTimerType type) {
|
||||
_eqp
|
||||
if(_list.count(type) == 1 && _list[type] != nullptr)
|
||||
_list[type]->Enable();
|
||||
}
|
||||
|
||||
void PTimerList::Disable(pTimerType type) {
|
||||
_eqp
|
||||
if(_list.count(type) == 1 && _list[type] != nullptr)
|
||||
_list[type]->Disable();
|
||||
}
|
||||
|
||||
uint32 PTimerList::GetRemainingTime(pTimerType type) {
|
||||
_eqp
|
||||
if(_list.count(type) != 1)
|
||||
return(0);
|
||||
if(_list[type] == nullptr)
|
||||
@ -432,14 +409,12 @@ uint32 PTimerList::GetRemainingTime(pTimerType type) {
|
||||
}
|
||||
|
||||
PersistentTimer *PTimerList::Get(pTimerType type) {
|
||||
_eqp
|
||||
if(_list.count(type) != 1)
|
||||
return(nullptr);
|
||||
return(_list[type]);
|
||||
}
|
||||
|
||||
void PTimerList::ToVector(std::vector< std::pair<pTimerType, PersistentTimer *> > &out) {
|
||||
_eqp
|
||||
std::pair<pTimerType, PersistentTimer *> p;
|
||||
|
||||
std::map<pTimerType, PersistentTimer *>::iterator s;
|
||||
@ -455,7 +430,6 @@ void PTimerList::ToVector(std::vector< std::pair<pTimerType, PersistentTimer *>
|
||||
}
|
||||
|
||||
bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) {
|
||||
_eqp
|
||||
std::string query = StringFormat("DELETE FROM timers WHERE char_id=%lu AND type=%u ",(unsigned long)char_id, type);
|
||||
|
||||
#ifdef DEBUG_PTIMERS
|
||||
|
||||
@ -30,7 +30,6 @@ uint32 current_time = 0;
|
||||
uint32 last_time = 0;
|
||||
|
||||
Timer::Timer() {
|
||||
_eqp
|
||||
timer_time = 0;
|
||||
start_time = current_time;
|
||||
set_at_trigger = timer_time;
|
||||
@ -39,7 +38,6 @@ Timer::Timer() {
|
||||
}
|
||||
|
||||
Timer::Timer(uint32 in_timer_time, bool iUseAcurateTiming) {
|
||||
_eqp
|
||||
timer_time = in_timer_time;
|
||||
start_time = current_time;
|
||||
set_at_trigger = timer_time;
|
||||
@ -53,7 +51,6 @@ Timer::Timer(uint32 in_timer_time, bool iUseAcurateTiming) {
|
||||
}
|
||||
|
||||
Timer::Timer(uint32 start, uint32 timer, bool iUseAcurateTiming = false) {
|
||||
_eqp
|
||||
timer_time = timer;
|
||||
start_time = start;
|
||||
set_at_trigger = timer_time;
|
||||
@ -101,18 +98,15 @@ bool Timer::Check(bool iReset)
|
||||
|
||||
/* This function disables the timer */
|
||||
void Timer::Disable() {
|
||||
_eqp
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
void Timer::Enable() {
|
||||
_eqp
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
/* This function set the timer and restart it */
|
||||
void Timer::Start(uint32 set_timer_time, bool ChangeResetTimer) {
|
||||
_eqp
|
||||
start_time = current_time;
|
||||
enabled = true;
|
||||
if (set_timer_time != 0)
|
||||
@ -125,7 +119,6 @@ void Timer::Start(uint32 set_timer_time, bool ChangeResetTimer) {
|
||||
|
||||
/* This timer updates the timer without restarting it */
|
||||
void Timer::SetTimer(uint32 set_timer_time) {
|
||||
_eqp
|
||||
/* If we were disabled before => restart the timer */
|
||||
if (!enabled) {
|
||||
start_time = current_time;
|
||||
@ -138,7 +131,6 @@ void Timer::SetTimer(uint32 set_timer_time) {
|
||||
}
|
||||
|
||||
uint32 Timer::GetRemainingTime() {
|
||||
_eqp
|
||||
if (enabled) {
|
||||
if (current_time-start_time > timer_time)
|
||||
return 0;
|
||||
@ -151,7 +143,6 @@ uint32 Timer::GetRemainingTime() {
|
||||
}
|
||||
|
||||
void Timer::SetAtTrigger(uint32 in_set_at_trigger, bool iEnableIfDisabled, bool ChangeTimerTime) {
|
||||
_eqp
|
||||
set_at_trigger = in_set_at_trigger;
|
||||
if (!Enabled() && iEnableIfDisabled) {
|
||||
Enable();
|
||||
@ -162,7 +153,6 @@ void Timer::SetAtTrigger(uint32 in_set_at_trigger, bool iEnableIfDisabled, bool
|
||||
|
||||
void Timer::Trigger()
|
||||
{
|
||||
_eqp
|
||||
enabled = true;
|
||||
|
||||
timer_time = set_at_trigger;
|
||||
@ -171,13 +161,11 @@ void Timer::Trigger()
|
||||
|
||||
const uint32 Timer::GetCurrentTime()
|
||||
{
|
||||
_eqp
|
||||
return current_time;
|
||||
}
|
||||
|
||||
//just to keep all time related crap in one place... not really related to timers.
|
||||
const uint32 Timer::GetTimeSeconds() {
|
||||
_eqp
|
||||
struct timeval read_time;
|
||||
|
||||
gettimeofday(&read_time,0);
|
||||
@ -186,7 +174,6 @@ const uint32 Timer::GetTimeSeconds() {
|
||||
|
||||
const uint32 Timer::SetCurrentTime()
|
||||
{
|
||||
_eqp
|
||||
struct timeval read_time;
|
||||
uint32 this_time;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user