mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-28 21:21:30 +00:00
Fix for not writing logs, added profiling to a bunch of common lib stuff.
This commit is contained in:
parent
d39e886459
commit
76cdedccb8
@ -335,6 +335,7 @@ ENDIF(EQEMU_BUILD_LUA)
|
||||
|
||||
IF(EQEMU_ENABLE_PROFILING)
|
||||
ADD_DEFINITIONS(-DEQPERF_ENABLED)
|
||||
ADD_DEFINITIONS(-DEQP_MULTITHREAD)
|
||||
INCLUDE_DIRECTORIES("eqperf")
|
||||
ADD_SUBDIRECTORY(eqperf)
|
||||
SET(PERF_LIBS eqperf)
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
BasePacket::BasePacket(const unsigned char *buf, uint32 len)
|
||||
{
|
||||
_eqp
|
||||
this->pBuffer=nullptr;
|
||||
this->size=0;
|
||||
this->_wpos = 0;
|
||||
@ -41,6 +42,7 @@ BasePacket::BasePacket(const unsigned char *buf, uint32 len)
|
||||
|
||||
BasePacket::~BasePacket()
|
||||
{
|
||||
_eqp
|
||||
if (pBuffer)
|
||||
delete[] pBuffer;
|
||||
pBuffer=nullptr;
|
||||
@ -49,6 +51,7 @@ 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));
|
||||
@ -66,6 +69,7 @@ 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);
|
||||
@ -73,11 +77,13 @@ 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);
|
||||
@ -90,6 +96,7 @@ 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);
|
||||
@ -98,6 +105,7 @@ void BasePacket::DumpRaw(FILE *to) const
|
||||
|
||||
void BasePacket::ReadString(char *str, uint32 Offset, uint32 MaxLength) const
|
||||
{
|
||||
_eqp
|
||||
uint32 i = 0, j = Offset;
|
||||
|
||||
do
|
||||
@ -111,15 +119,18 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@ -57,11 +57,13 @@ Establish a connection to a mysql database with the supplied parameters
|
||||
|
||||
Database::Database(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
||||
{
|
||||
_eqp
|
||||
DBInitVars();
|
||||
Connect(host, user, passwd, database, port);
|
||||
}
|
||||
|
||||
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port) {
|
||||
_eqp
|
||||
uint32 errnum= 0;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
if (!Open(host, user, passwd, database, port, &errnum, errbuf)) {
|
||||
@ -75,6 +77,7 @@ bool Database::Connect(const char* host, const char* user, const char* passwd, c
|
||||
}
|
||||
|
||||
void Database::DBInitVars() {
|
||||
_eqp
|
||||
varcache_array = 0;
|
||||
varcache_max = 0;
|
||||
varcache_lastupdate = 0;
|
||||
@ -86,6 +89,7 @@ void Database::DBInitVars() {
|
||||
|
||||
Database::~Database()
|
||||
{
|
||||
_eqp
|
||||
unsigned int x;
|
||||
if (varcache_array) {
|
||||
for (x=0; x<varcache_max; x++) {
|
||||
@ -101,7 +105,7 @@ Database::~Database()
|
||||
Zero will also be returned if there is a database error.
|
||||
*/
|
||||
uint32 Database::CheckLogin(const char* name, const char* password, int16* oStatus) {
|
||||
|
||||
_eqp
|
||||
if(strlen(name) >= 50 || strlen(password) >= 50)
|
||||
return(0);
|
||||
|
||||
@ -137,6 +141,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, int16* oStat
|
||||
//Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table.
|
||||
bool Database::CheckBannedIPs(const char* loginIP)
|
||||
{
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT ip_address FROM Banned_IPs WHERE ip_address='%s'", loginIP);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
@ -153,6 +158,7 @@ bool Database::CheckBannedIPs(const char* loginIP)
|
||||
}
|
||||
|
||||
bool Database::AddBannedIP(char* bannedIP, const char* notes) {
|
||||
_eqp
|
||||
std::string query = StringFormat("INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
@ -162,6 +168,7 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes) {
|
||||
}
|
||||
|
||||
bool Database::CheckGMIPs(const char* ip_address, uint32 account_id) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT * FROM `gm_ips` WHERE `ip_address` = '%s' AND `account_id` = %i", ip_address, account_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -175,17 +182,20 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes) {
|
||||
}
|
||||
|
||||
bool Database::AddGMIP(char* ip_address, char* name) {
|
||||
_eqp
|
||||
std::string query = StringFormat("INSERT into `gm_ips` SET `ip_address` = '%s', `name` = '%s'", ip_address, name);
|
||||
auto results = QueryDatabase(query);
|
||||
return results.Success();
|
||||
}
|
||||
|
||||
void Database::LoginIP(uint32 AccountID, const char* LoginIP) {
|
||||
_eqp
|
||||
std::string query = StringFormat("INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP);
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
int16 Database::CheckStatus(uint32 account_id) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `status`, UNIX_TIMESTAMP(`suspendeduntil`) as `suspendeduntil`, UNIX_TIMESTAMP() as `current`"
|
||||
" FROM `account` WHERE `id` = %i", account_id);
|
||||
|
||||
@ -215,6 +225,7 @@ int16 Database::CheckStatus(uint32 account_id) {
|
||||
}
|
||||
|
||||
uint32 Database::CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id) {
|
||||
_eqp
|
||||
std::string query;
|
||||
|
||||
if (password)
|
||||
@ -238,6 +249,7 @@ uint32 Database::CreateAccount(const char* name, const char* password, int16 sta
|
||||
}
|
||||
|
||||
bool Database::DeleteAccount(const char* name) {
|
||||
_eqp
|
||||
std::string query = StringFormat("DELETE FROM account WHERE name='%s';",name);
|
||||
Log.Out(Logs::General, Logs::World_Server, "Account Attempting to be deleted:'%s'", name);
|
||||
|
||||
@ -250,6 +262,7 @@ bool Database::DeleteAccount(const char* name) {
|
||||
}
|
||||
|
||||
bool Database::SetLocalPassword(uint32 accid, const char* password) {
|
||||
_eqp
|
||||
std::string query = StringFormat("UPDATE account SET password=MD5('%s') where id=%i;", EscapeString(password).c_str(), accid);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
@ -262,6 +275,7 @@ bool Database::SetLocalPassword(uint32 accid, const char* password) {
|
||||
}
|
||||
|
||||
bool Database::SetAccountStatus(const char* name, int16 status) {
|
||||
_eqp
|
||||
std::string query = StringFormat("UPDATE account SET status=%i WHERE name='%s';", status, name);
|
||||
|
||||
std::cout << "Account being GM Flagged:" << name << ", Level: " << (int16) status << std::endl;
|
||||
@ -282,6 +296,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
|
||||
|
||||
/* This initially creates the character during character create */
|
||||
bool Database::ReserveName(uint32 account_id, char* name) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `account_id`, `name` FROM `character_data` WHERE `name` = '%s'", name);
|
||||
auto results = QueryDatabase(query);
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
@ -302,6 +317,7 @@ bool Database::ReserveName(uint32 account_id, char* name) {
|
||||
returns false on failure, true otherwise
|
||||
*/
|
||||
bool Database::DeleteCharacter(char *name) {
|
||||
_eqp
|
||||
uint32 charid = 0;
|
||||
if(!name || !strlen(name)) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "DeleteCharacter: request to delete without a name (empty char slot)");
|
||||
@ -359,6 +375,7 @@ bool Database::DeleteCharacter(char *name) {
|
||||
}
|
||||
|
||||
bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp){
|
||||
_eqp
|
||||
std::string query = StringFormat(
|
||||
"REPLACE INTO `character_data` ("
|
||||
"id,"
|
||||
@ -678,6 +695,7 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
|
||||
|
||||
/* This only for new Character creation storing */
|
||||
bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inventory* inv) {
|
||||
_eqp
|
||||
uint32 charid = 0;
|
||||
char zone[50];
|
||||
float x, y, z;
|
||||
@ -732,6 +750,7 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inven
|
||||
}
|
||||
|
||||
uint32 Database::GetCharacterID(const char *name) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `id` FROM `character_data` WHERE `name` = '%s'", name);
|
||||
auto results = QueryDatabase(query);
|
||||
auto row = results.begin();
|
||||
@ -748,6 +767,7 @@ uint32 Database::GetCharacterID(const char *name) {
|
||||
Zero will also be returned if there is a database error.
|
||||
*/
|
||||
uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `account_id`, `id` FROM `character_data` WHERE name='%s'", EscapeString(charname).c_str());
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
@ -772,6 +792,7 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
|
||||
|
||||
// Retrieve account_id for a given char_id
|
||||
uint32 Database::GetAccountIDByChar(uint32 char_id) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `account_id` FROM `character_data` WHERE `id` = %i LIMIT 1", char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
@ -786,6 +807,7 @@ uint32 Database::GetAccountIDByChar(uint32 char_id) {
|
||||
}
|
||||
|
||||
uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32* lsid) {
|
||||
_eqp
|
||||
if (!isAlphaNumeric(accname))
|
||||
return 0;
|
||||
|
||||
@ -817,6 +839,7 @@ uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32*
|
||||
}
|
||||
|
||||
void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `name`, `lsaccount_id` FROM `account` WHERE `id` = '%i'", accountid);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -837,6 +860,7 @@ void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID
|
||||
}
|
||||
|
||||
void Database::GetCharName(uint32 char_id, char* name) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `name` FROM `character_data` WHERE id='%i'", char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -851,6 +875,7 @@ void Database::GetCharName(uint32 char_id, char* name) {
|
||||
}
|
||||
|
||||
bool Database::LoadVariables() {
|
||||
_eqp
|
||||
char *query = nullptr;
|
||||
|
||||
auto results = QueryDatabase(query, LoadVariables_MQ(&query));
|
||||
@ -867,12 +892,14 @@ bool Database::LoadVariables() {
|
||||
|
||||
uint32 Database::LoadVariables_MQ(char** query)
|
||||
{
|
||||
_eqp
|
||||
return MakeAnyLenString(query, "SELECT varname, value, unix_timestamp() FROM variables where unix_timestamp(ts) >= %d", varcache_lastupdate);
|
||||
}
|
||||
|
||||
// always returns true? not sure about this.
|
||||
bool Database::LoadVariables_result(MySQLRequestResult results)
|
||||
{
|
||||
_eqp
|
||||
uint32 i = 0;
|
||||
LockMutex lock(&Mvarcache);
|
||||
|
||||
@ -935,6 +962,7 @@ bool Database::LoadVariables_result(MySQLRequestResult results)
|
||||
|
||||
// Gets variable from 'variables' table
|
||||
bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) {
|
||||
_eqp
|
||||
varvalue[0] = '\0';
|
||||
|
||||
LockMutex lock(&Mvarcache);
|
||||
@ -956,7 +984,7 @@ bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_
|
||||
}
|
||||
|
||||
bool Database::SetVariable(const char* varname_in, const char* varvalue_in) {
|
||||
|
||||
_eqp
|
||||
char *varname,*varvalue;
|
||||
|
||||
varname=(char *)malloc(strlen(varname_in)*2+1);
|
||||
@ -996,6 +1024,7 @@ bool Database::SetVariable(const char* varname_in, const char* varvalue_in) {
|
||||
|
||||
uint32 Database::GetMiniLoginAccount(char* ip)
|
||||
{
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `id` FROM `account` WHERE `minilogin_ip` = '%s'", ip);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1008,7 +1037,7 @@ uint32 Database::GetMiniLoginAccount(char* ip)
|
||||
|
||||
// Get zone starting points from DB
|
||||
bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe_x, float* safe_y, float* safe_z, int16* minstatus, uint8* minlevel, char *flag_needed) {
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT safe_x, safe_y, safe_z, min_status, min_level, flag_needed FROM zone "
|
||||
" WHERE short_name='%s' AND (version=%i OR version=0) ORDER BY version DESC", short_name, version);
|
||||
auto results = QueryDatabase(query);
|
||||
@ -1038,7 +1067,7 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe
|
||||
}
|
||||
|
||||
bool Database::GetZoneLongName(const char* short_name, char** long_name, char* file_name, float* safe_x, float* safe_y, float* safe_z, uint32* graveyard_id, uint32* maxclients) {
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT long_name, file_name, safe_x, safe_y, safe_z, graveyard_id, maxclients FROM zone WHERE short_name='%s' AND version=0", short_name);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1076,7 +1105,7 @@ bool Database::GetZoneLongName(const char* short_name, char** long_name, char* f
|
||||
}
|
||||
|
||||
uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) {
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT graveyard_id FROM zone WHERE zoneidnumber='%u' AND (version=%i OR version=0) ORDER BY version DESC", zone_id, version);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1091,7 +1120,7 @@ uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) {
|
||||
}
|
||||
|
||||
bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid, float* graveyard_x, float* graveyard_y, float* graveyard_z, float* graveyard_heading) {
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT zone_id, x, y, z, heading FROM graveyard WHERE id=%i", graveyard_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1119,6 +1148,7 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon
|
||||
}
|
||||
|
||||
bool Database::LoadZoneNames() {
|
||||
_eqp
|
||||
std::string query("SELECT zoneidnumber, short_name FROM zone");
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
@ -1139,7 +1169,7 @@ bool Database::LoadZoneNames() {
|
||||
}
|
||||
|
||||
uint32 Database::GetZoneID(const char* zonename) {
|
||||
|
||||
_eqp
|
||||
if (zonename == nullptr)
|
||||
return 0;
|
||||
|
||||
@ -1151,6 +1181,7 @@ uint32 Database::GetZoneID(const char* zonename) {
|
||||
}
|
||||
|
||||
const char* Database::GetZoneName(uint32 zoneID, bool ErrorUnknown) {
|
||||
_eqp
|
||||
auto iter = zonename_array.find(zoneID);
|
||||
|
||||
if (iter != zonename_array.end())
|
||||
@ -1163,7 +1194,7 @@ const char* Database::GetZoneName(uint32 zoneID, bool ErrorUnknown) {
|
||||
}
|
||||
|
||||
uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT peqzone from zone where zoneidnumber='%i' AND (version=%i OR version=0) ORDER BY version DESC", zoneID, version);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1181,6 +1212,7 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
|
||||
|
||||
bool Database::CheckNameFilter(const char* name, bool surname)
|
||||
{
|
||||
_eqp
|
||||
std::string str_name = name;
|
||||
|
||||
if(surname)
|
||||
@ -1257,7 +1289,7 @@ bool Database::CheckNameFilter(const char* name, bool surname)
|
||||
}
|
||||
|
||||
bool Database::AddToNameFilter(const char* name) {
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("INSERT INTO name_filter (name) values ('%s')", name);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1273,6 +1305,7 @@ bool Database::AddToNameFilter(const char* name) {
|
||||
}
|
||||
|
||||
uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* oStatus) {
|
||||
_eqp
|
||||
uint32 account_id = 0;
|
||||
std::string query = StringFormat("SELECT id, name, status FROM account WHERE lsaccount_id=%i", iLSID);
|
||||
auto results = QueryDatabase(query);
|
||||
@ -1297,7 +1330,7 @@ uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* o
|
||||
}
|
||||
|
||||
void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT name, status FROM account WHERE id=%i", id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1317,10 +1350,12 @@ void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
|
||||
}
|
||||
|
||||
void Database::ClearMerchantTemp(){
|
||||
_eqp
|
||||
QueryDatabase("DELETE FROM merchantlist_temp");
|
||||
}
|
||||
|
||||
bool Database::UpdateName(const char* oldname, const char* newname) {
|
||||
_eqp
|
||||
std::cout << "Renaming " << oldname << " to " << newname << "..." << std::endl;
|
||||
std::string query = StringFormat("UPDATE `character_data` SET `name` = '%s' WHERE `name` = '%s';", newname, oldname);
|
||||
auto results = QueryDatabase(query);
|
||||
@ -1336,6 +1371,7 @@ bool Database::UpdateName(const char* oldname, const char* newname) {
|
||||
|
||||
// If the name is used or an error occurs, it returns false, otherwise it returns true
|
||||
bool Database::CheckUsedName(const char* name) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `id` FROM `character_data` WHERE `name` = '%s'", name);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
@ -1349,6 +1385,7 @@ bool Database::CheckUsedName(const char* name) {
|
||||
}
|
||||
|
||||
uint8 Database::GetServerType() {
|
||||
_eqp
|
||||
std::string query("SELECT `value` FROM `variables` WHERE `varname` = 'ServerType' LIMIT 1");
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
@ -1363,6 +1400,7 @@ uint8 Database::GetServerType() {
|
||||
}
|
||||
|
||||
bool Database::MoveCharacterToZone(const char* charname, const char* zonename, uint32 zoneid) {
|
||||
_eqp
|
||||
if(zonename == nullptr || strlen(zonename) == 0)
|
||||
return false;
|
||||
|
||||
@ -1380,10 +1418,12 @@ bool Database::MoveCharacterToZone(const char* charname, const char* zonename, u
|
||||
}
|
||||
|
||||
bool Database::MoveCharacterToZone(const char* charname, const char* zonename) {
|
||||
_eqp
|
||||
return MoveCharacterToZone(charname, zonename, GetZoneID(zonename));
|
||||
}
|
||||
|
||||
bool Database::MoveCharacterToZone(uint32 iCharID, const char* iZonename) {
|
||||
_eqp
|
||||
std::string query = StringFormat("UPDATE `character_data` SET `zone_id` = %i, `x` = -1, `y` = -1, `z` = -1 WHERE `id` = %i", iZonename, GetZoneID(iZonename), iCharID);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1395,6 +1435,7 @@ bool Database::MoveCharacterToZone(uint32 iCharID, const char* iZonename) {
|
||||
}
|
||||
|
||||
bool Database::SetHackerFlag(const char* accountname, const char* charactername, const char* hacked) {
|
||||
_eqp
|
||||
std::string query = StringFormat("INSERT INTO `hackers` (account, name, hacked) values('%s','%s','%s')", accountname, charactername, hacked);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1406,6 +1447,7 @@ bool Database::SetHackerFlag(const char* accountname, const char* charactername,
|
||||
}
|
||||
|
||||
bool Database::SetMQDetectionFlag(const char* accountname, const char* charactername, const char* hacked, const char* zone) {
|
||||
_eqp
|
||||
//Utilize the "hacker" table, but also give zone information.
|
||||
std::string query = StringFormat("INSERT INTO hackers(account,name,hacked,zone) values('%s','%s','%s','%s')", accountname, charactername, hacked, zone);
|
||||
auto results = QueryDatabase(query);
|
||||
@ -1420,6 +1462,7 @@ bool Database::SetMQDetectionFlag(const char* accountname, const char* character
|
||||
|
||||
uint8 Database::GetRaceSkill(uint8 skillid, uint8 in_race)
|
||||
{
|
||||
_eqp
|
||||
uint16 race_cap = 0;
|
||||
|
||||
//Check for a racial cap!
|
||||
@ -1438,6 +1481,7 @@ uint8 Database::GetRaceSkill(uint8 skillid, uint8 in_race)
|
||||
|
||||
uint8 Database::GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level)
|
||||
{
|
||||
_eqp
|
||||
uint8 skill_level = 0, skill_formula = 0;
|
||||
uint16 base_cap = 0, skill_cap = 0, skill_cap2 = 0, skill_cap3 = 0;
|
||||
|
||||
@ -1487,6 +1531,7 @@ uint8 Database::GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16
|
||||
}
|
||||
|
||||
uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZoneID, uint32* oInstanceID, float* oX, float* oY, float* oZ) {
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `id`, `account_id`, `zone_id`, `zone_instance`, `x`, `y`, `z` FROM `character_data` WHERE `name` = '%s'", iName);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1510,7 +1555,7 @@ uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZo
|
||||
}
|
||||
|
||||
bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) {
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1522,7 +1567,7 @@ bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) {
|
||||
}
|
||||
|
||||
bool Database::GetLiveChar(uint32 account_id, char* cname) {
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT charname FROM account WHERE id=%i", account_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1541,26 +1586,31 @@ bool Database::GetLiveChar(uint32 account_id, char* cname) {
|
||||
}
|
||||
|
||||
void Database::SetLFP(uint32 CharID, bool LFP) {
|
||||
_eqp
|
||||
std::string query = StringFormat("UPDATE `character_data` SET `lfp` = %i WHERE `id` = %i",LFP, CharID);
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon) {
|
||||
_eqp
|
||||
std::string query = StringFormat("update `character_data` SET `lfp` = %i, `lfg` = %i, `firstlogon` = %i WHERE `id` = %i",LFP, LFG, firstlogon, CharID);
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::SetLFG(uint32 CharID, bool LFG) {
|
||||
_eqp
|
||||
std::string query = StringFormat("update `character_data` SET `lfg` = %i WHERE `id` = %i",LFG, CharID);
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::SetFirstLogon(uint32 CharID, uint8 firstlogon) {
|
||||
_eqp
|
||||
std::string query = StringFormat( "UPDATE `character_data` SET `firstlogon` = %i WHERE `id` = %i",firstlogon, CharID);
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::AddReport(std::string who, std::string against, std::string lines) {
|
||||
_eqp
|
||||
char *escape_str = new char[lines.size()*2+1];
|
||||
DoEscapeString(escape_str, lines.c_str(), lines.size());
|
||||
|
||||
@ -1570,6 +1620,7 @@ void Database::AddReport(std::string who, std::string against, std::string lines
|
||||
}
|
||||
|
||||
void Database::SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ismerc) {
|
||||
_eqp
|
||||
std::string query;
|
||||
if (id == 0) {
|
||||
// removing from group
|
||||
@ -1589,12 +1640,14 @@ void Database::SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ism
|
||||
|
||||
void Database::ClearAllGroups(void)
|
||||
{
|
||||
_eqp
|
||||
std::string query("DELETE FROM `group_id`");
|
||||
QueryDatabase(query);
|
||||
return;
|
||||
}
|
||||
|
||||
void Database::ClearGroup(uint32 gid) {
|
||||
_eqp
|
||||
ClearGroupLeader(gid);
|
||||
|
||||
if(gid == 0)
|
||||
@ -1610,6 +1663,7 @@ void Database::ClearGroup(uint32 gid) {
|
||||
}
|
||||
|
||||
uint32 Database::GetGroupID(const char* name){
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT groupid from group_id where name='%s'", name);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1631,6 +1685,7 @@ uint32 Database::GetGroupID(const char* name){
|
||||
|
||||
/* Is this really getting used properly... A half implementation ? Akkadius */
|
||||
char* Database::GetGroupLeaderForLogin(const char* name, char* leaderbuf) {
|
||||
_eqp
|
||||
strcpy(leaderbuf, "");
|
||||
uint32 group_id = 0;
|
||||
|
||||
@ -1655,6 +1710,7 @@ char* Database::GetGroupLeaderForLogin(const char* name, char* leaderbuf) {
|
||||
}
|
||||
|
||||
void Database::SetGroupLeaderName(uint32 gid, const char* name) {
|
||||
_eqp
|
||||
std::string query = StringFormat("UPDATE group_leaders SET leadername = '%s' WHERE gid = %u", EscapeString(name).c_str(), gid);
|
||||
auto result = QueryDatabase(query);
|
||||
|
||||
@ -1673,6 +1729,7 @@ void Database::SetGroupLeaderName(uint32 gid, const char* name) {
|
||||
|
||||
char *Database::GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank, char* assist, char* puller, char *marknpc, char *mentoree, int *mentor_percent, GroupLeadershipAA_Struct* GLAA)
|
||||
{
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `leadername`, `maintank`, `assist`, `puller`, `marknpc`, `mentoree`, `mentor_percent`, `leadershipaa` FROM `group_leaders` WHERE `gid` = %lu",(unsigned long)gid);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1732,6 +1789,7 @@ char *Database::GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* mainta
|
||||
|
||||
// Clearing all group leaders
|
||||
void Database::ClearAllGroupLeaders(void) {
|
||||
_eqp
|
||||
std::string query("DELETE from group_leaders");
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1742,7 +1800,7 @@ void Database::ClearAllGroupLeaders(void) {
|
||||
}
|
||||
|
||||
void Database::ClearGroupLeader(uint32 gid) {
|
||||
|
||||
_eqp
|
||||
if(gid == 0)
|
||||
{
|
||||
ClearAllGroupLeaders();
|
||||
@ -1757,7 +1815,7 @@ void Database::ClearGroupLeader(uint32 gid) {
|
||||
}
|
||||
|
||||
uint8 Database::GetAgreementFlag(uint32 acctid) {
|
||||
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT rulesflag FROM account WHERE id=%i",acctid);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1773,11 +1831,13 @@ uint8 Database::GetAgreementFlag(uint32 acctid) {
|
||||
}
|
||||
|
||||
void Database::SetAgreementFlag(uint32 acctid) {
|
||||
_eqp
|
||||
std::string query = StringFormat("UPDATE account SET rulesflag=1 where id=%i", acctid);
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::ClearRaid(uint32 rid) {
|
||||
_eqp
|
||||
if(rid == 0)
|
||||
{
|
||||
//clear all raids
|
||||
@ -1794,7 +1854,7 @@ void Database::ClearRaid(uint32 rid) {
|
||||
}
|
||||
|
||||
void Database::ClearAllRaids(void) {
|
||||
|
||||
_eqp
|
||||
std::string query("delete from raid_members");
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1804,7 +1864,7 @@ void Database::ClearAllRaids(void) {
|
||||
|
||||
void Database::ClearAllRaidDetails(void)
|
||||
{
|
||||
|
||||
_eqp
|
||||
std::string query("delete from raid_details");
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1813,7 +1873,7 @@ void Database::ClearAllRaidDetails(void)
|
||||
}
|
||||
|
||||
void Database::ClearRaidDetails(uint32 rid) {
|
||||
|
||||
_eqp
|
||||
if(rid == 0)
|
||||
{
|
||||
//clear all raids
|
||||
@ -1832,7 +1892,8 @@ void Database::ClearRaidDetails(uint32 rid) {
|
||||
// returns 0 on error or no raid for that character, or
|
||||
// the raid id that the character is a member of.
|
||||
uint32 Database::GetRaidID(const char* name)
|
||||
{
|
||||
{
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT `raidid` FROM `raid_members` WHERE `name` = '%s'", name);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -1853,6 +1914,7 @@ uint32 Database::GetRaidID(const char* name)
|
||||
|
||||
const char* Database::GetRaidLeaderName(uint32 raid_id)
|
||||
{
|
||||
_eqp
|
||||
// Would be a good idea to fix this to be a passed in variable and
|
||||
// make the caller responsible. static local variables like this are
|
||||
// not guaranteed to be thread safe (nor is the internal guard
|
||||
@ -1884,6 +1946,7 @@ const char* Database::GetRaidLeaderName(uint32 raid_id)
|
||||
void Database::GetGroupLeadershipInfo(uint32 gid, uint32 rid, char *maintank,
|
||||
char *assist, char *puller, char *marknpc, char *mentoree, int *mentor_percent, GroupLeadershipAA_Struct *GLAA)
|
||||
{
|
||||
_eqp
|
||||
std::string query = StringFormat(
|
||||
"SELECT maintank, assist, puller, marknpc, mentoree, mentor_percent, leadershipaa FROM raid_leaders WHERE gid = %lu AND rid = %lu",
|
||||
(unsigned long)gid, (unsigned long)rid);
|
||||
@ -1941,6 +2004,7 @@ void Database::GetGroupLeadershipInfo(uint32 gid, uint32 rid, char *maintank,
|
||||
void Database::GetRaidLeadershipInfo(uint32 rid, char *maintank,
|
||||
char *assist, char *puller, char *marknpc, RaidLeadershipAA_Struct *RLAA)
|
||||
{
|
||||
_eqp
|
||||
std::string query = StringFormat(
|
||||
"SELECT maintank, assist, puller, marknpc, leadershipaa FROM raid_leaders WHERE gid = %lu AND rid = %lu",
|
||||
(unsigned long)0xFFFFFFFF, (unsigned long)rid);
|
||||
@ -1984,6 +2048,7 @@ void Database::GetRaidLeadershipInfo(uint32 rid, char *maintank,
|
||||
|
||||
void Database::SetRaidGroupLeaderInfo(uint32 gid, uint32 rid)
|
||||
{
|
||||
_eqp
|
||||
std::string query = StringFormat("UPDATE raid_leaders SET leadershipaa = '' WHERE gid = %lu AND rid = %lu",
|
||||
(unsigned long)gid, (unsigned long)rid);
|
||||
auto results = QueryDatabase(query);
|
||||
@ -2001,6 +2066,7 @@ void Database::SetRaidGroupLeaderInfo(uint32 gid, uint32 rid)
|
||||
// Clearing all raid leaders
|
||||
void Database::ClearAllRaidLeaders(void)
|
||||
{
|
||||
_eqp
|
||||
std::string query("DELETE from raid_leaders");
|
||||
QueryDatabase(query);
|
||||
return;
|
||||
@ -2008,6 +2074,7 @@ void Database::ClearAllRaidLeaders(void)
|
||||
|
||||
void Database::ClearRaidLeader(uint32 gid, uint32 rid)
|
||||
{
|
||||
_eqp
|
||||
if (rid == 0) {
|
||||
ClearAllRaidLeaders();
|
||||
return;
|
||||
@ -2019,7 +2086,7 @@ void Database::ClearRaidLeader(uint32 gid, uint32 rid)
|
||||
|
||||
void Database::UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win)
|
||||
{
|
||||
|
||||
_eqp
|
||||
std::string field;
|
||||
|
||||
switch(theme)
|
||||
@ -2072,6 +2139,7 @@ void Database::UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win)
|
||||
|
||||
bool Database::GetAdventureStats(uint32 char_id, AdventureStats_Struct *as)
|
||||
{
|
||||
_eqp
|
||||
std::string query = StringFormat(
|
||||
"SELECT "
|
||||
"`guk_wins`, "
|
||||
@ -2118,6 +2186,7 @@ bool Database::GetAdventureStats(uint32 char_id, AdventureStats_Struct *as)
|
||||
|
||||
uint32 Database::GetGuildIDByCharID(uint32 character_id)
|
||||
{
|
||||
_eqp
|
||||
std::string query = StringFormat("SELECT guild_id FROM guild_members WHERE char_id='%i'", character_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
@ -2133,6 +2202,7 @@ uint32 Database::GetGuildIDByCharID(uint32 character_id)
|
||||
|
||||
void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings)
|
||||
{
|
||||
_eqp
|
||||
std::string query =
|
||||
"SELECT "
|
||||
"log_category_id, "
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#endif
|
||||
|
||||
DBcore::DBcore() {
|
||||
_eqp
|
||||
mysql_init(&mysql);
|
||||
pHost = 0;
|
||||
pUser = 0;
|
||||
@ -41,6 +42,7 @@ DBcore::DBcore() {
|
||||
}
|
||||
|
||||
DBcore::~DBcore() {
|
||||
_eqp
|
||||
mysql_close(&mysql);
|
||||
safe_delete_array(pHost);
|
||||
safe_delete_array(pUser);
|
||||
@ -50,6 +52,7 @@ 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;
|
||||
@ -60,11 +63,13 @@ 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.
|
||||
@ -134,24 +139,29 @@ 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);
|
||||
@ -168,6 +178,7 @@ 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);
|
||||
|
||||
@ -50,6 +50,7 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_s
|
||||
keepalive_timer(SERVER_TIMEOUT),
|
||||
timeout_timer(SERVER_TIMEOUT * 2)
|
||||
{
|
||||
_eqp
|
||||
id = 0;
|
||||
Server = nullptr;
|
||||
pOldFormat = iOldFormat;
|
||||
@ -76,6 +77,7 @@ EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer,
|
||||
keepalive_timer(SERVER_TIMEOUT),
|
||||
timeout_timer(SERVER_TIMEOUT * 2)
|
||||
{
|
||||
_eqp
|
||||
Server = iRelayServer;
|
||||
if (Server)
|
||||
RelayServer = true;
|
||||
@ -98,6 +100,7 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConne
|
||||
keepalive_timer(SERVER_TIMEOUT),
|
||||
timeout_timer(SERVER_TIMEOUT * 2)
|
||||
{
|
||||
_eqp
|
||||
Server = iServer;
|
||||
RelayLink = iRelayLink;
|
||||
RelayServer = true;
|
||||
@ -117,6 +120,7 @@ EmuTCPConnection::~EmuTCPConnection() {
|
||||
}
|
||||
|
||||
EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32 iDestination) {
|
||||
_eqp
|
||||
int32 size = sizeof(EmuTCPNetPacket_Struct) + pack->size;
|
||||
if (pack->compressed) {
|
||||
size += 4;
|
||||
@ -144,6 +148,7 @@ EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32
|
||||
}
|
||||
|
||||
SPackSendQueue* EmuTCPConnection::MakeOldPacket(ServerPacket* pack) {
|
||||
_eqp
|
||||
SPackSendQueue* spsq = (SPackSendQueue*) new uchar[sizeof(SPackSendQueue) + pack->size + 4];
|
||||
if (pack->pBuffer != 0 && pack->size != 0)
|
||||
memcpy((char *) &spsq->buffer[4], (char *) pack->pBuffer, pack->size);
|
||||
@ -154,6 +159,7 @@ SPackSendQueue* EmuTCPConnection::MakeOldPacket(ServerPacket* pack) {
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
|
||||
_eqp
|
||||
if (!Connected())
|
||||
return false;
|
||||
eTCPMode tmp = GetMode();
|
||||
@ -214,6 +220,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
|
||||
_eqp
|
||||
if (RemoteID)
|
||||
return false;
|
||||
if (!Connected())
|
||||
@ -254,6 +261,7 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
|
||||
}
|
||||
|
||||
ServerPacket* EmuTCPConnection::PopPacket() {
|
||||
_eqp
|
||||
ServerPacket* ret;
|
||||
if (!MOutQueueLock.trylock())
|
||||
return nullptr;
|
||||
@ -263,12 +271,14 @@ ServerPacket* EmuTCPConnection::PopPacket() {
|
||||
}
|
||||
|
||||
void EmuTCPConnection::InModeQueuePush(EmuTCPNetPacket_Struct* tnps) {
|
||||
_eqp
|
||||
MSendQueue.lock();
|
||||
InModeQueue.push(tnps);
|
||||
MSendQueue.unlock();
|
||||
}
|
||||
|
||||
void EmuTCPConnection::OutQueuePush(ServerPacket* pack) {
|
||||
_eqp
|
||||
MOutQueueLock.lock();
|
||||
OutQueue.push(pack);
|
||||
MOutQueueLock.unlock();
|
||||
@ -276,6 +286,7 @@ void EmuTCPConnection::OutQueuePush(ServerPacket* pack) {
|
||||
|
||||
|
||||
bool EmuTCPConnection::LineOutQueuePush(char* line) {
|
||||
_eqp
|
||||
#if defined(GOTFRAGS) && 0
|
||||
if (strcmp(line, "**CRASHME**") == 0) {
|
||||
int i = 0;
|
||||
@ -369,6 +380,7 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
|
||||
}
|
||||
|
||||
void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
|
||||
_eqp
|
||||
TCPConnection::Disconnect();
|
||||
|
||||
if (RelayLink) {
|
||||
@ -378,6 +390,7 @@ void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
|
||||
_eqp
|
||||
if(!TCPConnection::ConnectIP(irIP, irPort, errbuf))
|
||||
return(false);
|
||||
|
||||
@ -432,6 +445,7 @@ bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
|
||||
}
|
||||
|
||||
void EmuTCPConnection::ClearBuffers() {
|
||||
_eqp
|
||||
TCPConnection::ClearBuffers();
|
||||
|
||||
LockMutex lock2(&MOutQueueLock);
|
||||
@ -448,6 +462,7 @@ void EmuTCPConnection::ClearBuffers() {
|
||||
}
|
||||
|
||||
void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
|
||||
_eqp
|
||||
#if TCPC_DEBUG >= 1
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
@ -469,6 +484,7 @@ void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
|
||||
}
|
||||
|
||||
void EmuTCPConnection::RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect) {
|
||||
_eqp
|
||||
if (iSendRelayDisconnect) {
|
||||
ServerPacket* pack = new ServerPacket(0, 5);
|
||||
pack->pBuffer[0] = 3;
|
||||
@ -482,6 +498,7 @@ void EmuTCPConnection::RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisco
|
||||
|
||||
|
||||
bool EmuTCPConnection::ProcessReceivedData(char* errbuf) {
|
||||
_eqp
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
timeout_timer.Start();
|
||||
@ -505,6 +522,7 @@ bool EmuTCPConnection::ProcessReceivedData(char* errbuf) {
|
||||
|
||||
|
||||
bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
|
||||
_eqp
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
int32 base = 0;
|
||||
@ -621,6 +639,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
|
||||
_eqp
|
||||
int32 base = 0;
|
||||
int32 size = 4;
|
||||
uchar* buffer;
|
||||
@ -695,6 +714,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
|
||||
}
|
||||
|
||||
void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
|
||||
_eqp
|
||||
uint8 opcode = pack->pBuffer[0];
|
||||
uint8* data = &pack->pBuffer[1];
|
||||
switch (opcode) {
|
||||
@ -780,6 +800,7 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
|
||||
_eqp
|
||||
sent_something = false;
|
||||
if(!TCPConnection::SendData(sent_something, errbuf))
|
||||
return(false);
|
||||
@ -799,6 +820,7 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::RecvData(char* errbuf) {
|
||||
_eqp
|
||||
if(!TCPConnection::RecvData(errbuf)) {
|
||||
if (OutQueue.count())
|
||||
return(true);
|
||||
|
||||
@ -9,6 +9,7 @@ EmuTCPServer::EmuTCPServer(uint16 iPort, bool iOldFormat)
|
||||
}
|
||||
|
||||
EmuTCPServer::~EmuTCPServer() {
|
||||
_eqp
|
||||
MInQueue.lock();
|
||||
while(!m_InQueue.empty()) {
|
||||
delete m_InQueue.front();
|
||||
@ -18,23 +19,27 @@ EmuTCPServer::~EmuTCPServer() {
|
||||
}
|
||||
|
||||
void EmuTCPServer::Process() {
|
||||
_eqp
|
||||
CheckInQueue();
|
||||
TCPServer<EmuTCPConnection>::Process();
|
||||
}
|
||||
|
||||
void EmuTCPServer::CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
|
||||
{
|
||||
_eqp
|
||||
EmuTCPConnection *conn = new EmuTCPConnection(ID, this, in_socket, irIP, irPort, pOldFormat);
|
||||
AddConnection(conn);
|
||||
}
|
||||
|
||||
|
||||
void EmuTCPServer::SendPacket(ServerPacket* pack) {
|
||||
_eqp
|
||||
EmuTCPNetPacket_Struct* tnps = EmuTCPConnection::MakePacket(pack);
|
||||
SendPacket(&tnps);
|
||||
}
|
||||
|
||||
void EmuTCPServer::SendPacket(EmuTCPNetPacket_Struct** tnps) {
|
||||
_eqp
|
||||
MInQueue.lock();
|
||||
m_InQueue.push(*tnps);
|
||||
MInQueue.unlock();
|
||||
@ -42,6 +47,7 @@ void EmuTCPServer::SendPacket(EmuTCPNetPacket_Struct** tnps) {
|
||||
}
|
||||
|
||||
void EmuTCPServer::CheckInQueue() {
|
||||
_eqp
|
||||
EmuTCPNetPacket_Struct* tnps = 0;
|
||||
|
||||
while (( tnps = InQueuePop() )) {
|
||||
@ -57,6 +63,7 @@ void EmuTCPServer::CheckInQueue() {
|
||||
}
|
||||
|
||||
EmuTCPNetPacket_Struct* EmuTCPServer::InQueuePop() {
|
||||
_eqp
|
||||
EmuTCPNetPacket_Struct* ret = nullptr;
|
||||
MInQueue.lock();
|
||||
if(!m_InQueue.empty()) {
|
||||
@ -69,6 +76,7 @@ EmuTCPNetPacket_Struct* EmuTCPServer::InQueuePop() {
|
||||
|
||||
|
||||
EmuTCPConnection *EmuTCPServer::FindConnection(uint32 iID) {
|
||||
_eqp
|
||||
vitr cur, end;
|
||||
cur = m_list.begin();
|
||||
end = m_list.end();
|
||||
|
||||
@ -40,9 +40,11 @@ EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
|
||||
: BasePacket(buf, len),
|
||||
emu_opcode(op)
|
||||
{
|
||||
_eqp
|
||||
}
|
||||
|
||||
void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
|
||||
_eqp
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
@ -51,17 +53,20 @@ void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
|
||||
|
||||
void EQPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQPacket::build_header_dump(char *buffer) const {
|
||||
_eqp
|
||||
sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]", emu_opcode, size);
|
||||
}
|
||||
|
||||
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
@ -76,6 +81,7 @@ void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
|
||||
void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
_eqp
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
@ -84,6 +90,7 @@ void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
|
||||
void EQProtocolPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
@ -91,11 +98,13 @@ void EQProtocolPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
|
||||
void EQProtocolPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
_eqp
|
||||
sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]",opcode,size);
|
||||
}
|
||||
|
||||
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
@ -110,6 +119,7 @@ void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
|
||||
void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
_eqp
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
@ -122,6 +132,7 @@ void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
|
||||
void EQApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
@ -129,6 +140,7 @@ void EQApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
|
||||
void EQApplicationPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
_eqp
|
||||
#ifdef STATIC_OPCODE
|
||||
sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||
#else
|
||||
@ -138,6 +150,7 @@ void EQApplicationPacket::build_header_dump(char *buffer) const
|
||||
|
||||
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
@ -156,6 +169,7 @@ void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
|
||||
void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
_eqp
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
@ -168,6 +182,7 @@ void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) con
|
||||
|
||||
void EQRawApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
@ -175,6 +190,7 @@ void EQRawApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
|
||||
void EQRawApplicationPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
_eqp
|
||||
#ifdef STATIC_OPCODE
|
||||
sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
|
||||
#else
|
||||
@ -184,6 +200,7 @@ void EQRawApplicationPacket::build_header_dump(char *buffer) const
|
||||
|
||||
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
@ -202,6 +219,7 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
|
||||
uint32 EQProtocolPacket::serialize(unsigned char *dest) const
|
||||
{
|
||||
_eqp
|
||||
if (opcode>0xff) {
|
||||
*(uint16 *)dest=opcode;
|
||||
} else {
|
||||
@ -215,6 +233,7 @@ uint32 EQProtocolPacket::serialize(unsigned char *dest) const
|
||||
|
||||
uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
|
||||
{
|
||||
_eqp
|
||||
uint8 OpCodeBytes = app_opcode_size;
|
||||
|
||||
if (app_opcode_size==1)
|
||||
@ -238,6 +257,7 @@ uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
|
||||
|
||||
bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
|
||||
{
|
||||
_eqp
|
||||
bool result=false;
|
||||
if (opcode==OP_Combined && size+rhs->size+5<256) {
|
||||
unsigned char *tmpbuffer=new unsigned char [size+rhs->size+3];
|
||||
@ -264,11 +284,11 @@ bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint32 Key)
|
||||
{
|
||||
_eqp
|
||||
bool valid=false;
|
||||
// OP_SessionRequest, OP_SessionResponse, OP_OutOfSession are not CRC'd
|
||||
if (buffer[0]==0x00 && (buffer[1]==OP_SessionRequest || buffer[1]==OP_SessionResponse || buffer[1]==OP_OutOfSession)) {
|
||||
@ -288,6 +308,7 @@ bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint
|
||||
|
||||
uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize)
|
||||
{
|
||||
_eqp
|
||||
uint32 newlen=0;
|
||||
uint32 flag_offset=0;
|
||||
newbuf[0]=buffer[0];
|
||||
@ -313,6 +334,7 @@ uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 le
|
||||
}
|
||||
|
||||
uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) {
|
||||
_eqp
|
||||
uint32 flag_offset=1,newlength;
|
||||
//dump_message_column(buffer,length,"Before: ");
|
||||
newbuf[0]=buffer[0];
|
||||
@ -336,6 +358,7 @@ uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 leng
|
||||
|
||||
void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey)
|
||||
{
|
||||
_eqp
|
||||
if ((size >= 2) && buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
|
||||
int Key=DecodeKey;
|
||||
unsigned char *test=(unsigned char *)malloc(size);
|
||||
@ -361,6 +384,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
|
||||
|
||||
void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey)
|
||||
{
|
||||
_eqp
|
||||
if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
|
||||
int Key=EncodeKey;
|
||||
char *test=(char*)malloc(size);
|
||||
@ -384,10 +408,12 @@ void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey
|
||||
}
|
||||
|
||||
EQApplicationPacket *EQApplicationPacket::Copy() const {
|
||||
_eqp
|
||||
return(new EQApplicationPacket(*this));
|
||||
}
|
||||
|
||||
EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
|
||||
_eqp
|
||||
EQRawApplicationPacket *res = new EQRawApplicationPacket(opcode, pBuffer, size);
|
||||
res->copyInfo(this);
|
||||
return(res);
|
||||
@ -397,10 +423,13 @@ EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned cha
|
||||
: EQApplicationPacket(OP_Unknown, buf, len),
|
||||
opcode(opcode)
|
||||
{
|
||||
_eqp
|
||||
}
|
||||
|
||||
EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len)
|
||||
: EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16))
|
||||
{
|
||||
_eqp
|
||||
if(GetExecutablePlatform() != ExePlatformUCS) {
|
||||
opcode = *((const uint16 *) buf);
|
||||
if(opcode == 0x0000)
|
||||
@ -434,6 +463,7 @@ EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const u
|
||||
}
|
||||
|
||||
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
|
||||
_eqp
|
||||
if (iShowInfo) {
|
||||
std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
|
||||
std::cout << " size:" << app->size << std::endl;
|
||||
@ -442,6 +472,7 @@ void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
|
||||
}
|
||||
|
||||
std::string DumpPacketToString(const EQApplicationPacket* app){
|
||||
_eqp
|
||||
std::ostringstream out;
|
||||
out << DumpPacketHexToString(app->pBuffer, app->size);
|
||||
return out.str();
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
uint16 EQStream::MaxWindowSize=2048;
|
||||
|
||||
void EQStream::init(bool resetSession) {
|
||||
_eqp
|
||||
// we only reset these statistics if it is a 'new' connection
|
||||
if ( resetSession )
|
||||
{
|
||||
@ -92,6 +93,7 @@ void EQStream::init(bool resetSession) {
|
||||
|
||||
EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
|
||||
{
|
||||
_eqp
|
||||
EQRawApplicationPacket *ap=nullptr;
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, p->size);
|
||||
// _raw(NET__APP_CREATE_HEX, 0xFFFF, p);
|
||||
@ -101,6 +103,7 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
|
||||
|
||||
EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len)
|
||||
{
|
||||
_eqp
|
||||
EQRawApplicationPacket *ap=nullptr;
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, len);
|
||||
ap = new EQRawApplicationPacket(buf, len);
|
||||
@ -108,6 +111,7 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf
|
||||
}
|
||||
|
||||
EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32 len) {
|
||||
_eqp
|
||||
uint16 proto_opcode = ntohs(*(const uint16 *)buf);
|
||||
|
||||
//advance over opcode.
|
||||
@ -119,6 +123,7 @@ EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32
|
||||
|
||||
void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
{
|
||||
_eqp
|
||||
uint32 processed=0, subpacket_length=0;
|
||||
if (p == nullptr)
|
||||
return;
|
||||
@ -516,6 +521,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
|
||||
void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
|
||||
{
|
||||
_eqp
|
||||
if(p == nullptr)
|
||||
return;
|
||||
|
||||
@ -527,6 +533,7 @@ void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
|
||||
|
||||
void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
|
||||
{
|
||||
_eqp
|
||||
EQApplicationPacket *pack=*p;
|
||||
*p = nullptr; //clear caller's pointer.. effectively takes ownership
|
||||
|
||||
@ -556,6 +563,7 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
|
||||
|
||||
void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
||||
{
|
||||
_eqp
|
||||
uint32 chunksize, used;
|
||||
uint32 length;
|
||||
|
||||
@ -612,34 +620,36 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
||||
|
||||
void EQStream::SequencedPush(EQProtocolPacket *p)
|
||||
{
|
||||
_eqp
|
||||
#ifdef COLLECTOR
|
||||
delete p;
|
||||
#else
|
||||
MOutboundQueue.lock();
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Push Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Push Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pushing sequenced packet %d of length %d. Base Seq is %d." __L, NextOutSeq, p->size, SequencedBase);
|
||||
*(uint16 *)(p->pBuffer)=htons(NextOutSeq);
|
||||
SequencedQueue.push_back(p);
|
||||
NextOutSeq++;
|
||||
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Push Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Push Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
MOutboundQueue.unlock();
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQStream::NonSequencedPush(EQProtocolPacket *p)
|
||||
{
|
||||
_eqp
|
||||
#ifdef COLLECTOR
|
||||
delete p;
|
||||
#else
|
||||
@ -652,6 +662,7 @@ void EQStream::NonSequencedPush(EQProtocolPacket *p)
|
||||
|
||||
void EQStream::SendAck(uint16 seq)
|
||||
{
|
||||
_eqp
|
||||
uint16 Seq=htons(seq);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Sending ack with sequence %d" __L, seq);
|
||||
SetLastAckSent(seq);
|
||||
@ -660,8 +671,9 @@ void EQStream::SendAck(uint16 seq)
|
||||
|
||||
void EQStream::SendOutOfOrderAck(uint16 seq)
|
||||
{
|
||||
_eqp
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Sending out of order ack with sequence %d" __L, seq);
|
||||
uint16 Seq=htons(seq);
|
||||
uint16 Seq=htons(seq);
|
||||
NonSequencedPush(new EQProtocolPacket(OP_OutOfOrderAck,(unsigned char *)&Seq,sizeof(uint16)));
|
||||
}
|
||||
|
||||
@ -862,6 +874,7 @@ void EQStream::Write(int eq_fd)
|
||||
|
||||
void EQStream::WritePacket(int eq_fd, EQProtocolPacket *p)
|
||||
{
|
||||
_eqp
|
||||
uint32 length;
|
||||
sockaddr_in address;
|
||||
address.sin_family = AF_INET;
|
||||
@ -900,6 +913,7 @@ void EQStream::WritePacket(int eq_fd, EQProtocolPacket *p)
|
||||
|
||||
void EQStream::SendSessionResponse()
|
||||
{
|
||||
_eqp
|
||||
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(SessionResponse));
|
||||
SessionResponse *Response=(SessionResponse *)out->pBuffer;
|
||||
Response->Session=htonl(Session);
|
||||
@ -922,6 +936,7 @@ void EQStream::SendSessionResponse()
|
||||
|
||||
void EQStream::SendSessionRequest()
|
||||
{
|
||||
_eqp
|
||||
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(SessionRequest));
|
||||
SessionRequest *Request=(SessionRequest *)out->pBuffer;
|
||||
memset(Request,0,sizeof(SessionRequest));
|
||||
@ -935,6 +950,7 @@ void EQStream::SendSessionRequest()
|
||||
|
||||
void EQStream::_SendDisconnect()
|
||||
{
|
||||
_eqp
|
||||
if(GetState() == CLOSED)
|
||||
return;
|
||||
|
||||
@ -947,6 +963,7 @@ void EQStream::_SendDisconnect()
|
||||
|
||||
void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
|
||||
{
|
||||
_eqp
|
||||
MInboundQueue.lock();
|
||||
InboundQueue.push_back(p);
|
||||
MInboundQueue.unlock();
|
||||
@ -954,6 +971,7 @@ void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
|
||||
|
||||
EQApplicationPacket *EQStream::PopPacket()
|
||||
{
|
||||
_eqp
|
||||
EQRawApplicationPacket *p=nullptr;
|
||||
|
||||
MInboundQueue.lock();
|
||||
@ -979,6 +997,7 @@ EQApplicationPacket *EQStream::PopPacket()
|
||||
|
||||
EQRawApplicationPacket *EQStream::PopRawPacket()
|
||||
{
|
||||
_eqp
|
||||
EQRawApplicationPacket *p=nullptr;
|
||||
|
||||
MInboundQueue.lock();
|
||||
@ -1006,6 +1025,7 @@ EQRawApplicationPacket *EQStream::PopRawPacket()
|
||||
|
||||
EQRawApplicationPacket *EQStream::PeekPacket()
|
||||
{
|
||||
_eqp
|
||||
EQRawApplicationPacket *p=nullptr;
|
||||
|
||||
MInboundQueue.lock();
|
||||
@ -1020,6 +1040,7 @@ EQRawApplicationPacket *EQStream::PeekPacket()
|
||||
|
||||
void EQStream::InboundQueueClear()
|
||||
{
|
||||
_eqp
|
||||
EQApplicationPacket *p=nullptr;
|
||||
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing inbound queue" __L);
|
||||
@ -1038,6 +1059,7 @@ void EQStream::InboundQueueClear()
|
||||
|
||||
bool EQStream::HasOutgoingData()
|
||||
{
|
||||
_eqp
|
||||
bool flag;
|
||||
|
||||
//once closed, we have nothing more to say
|
||||
@ -1063,6 +1085,7 @@ bool EQStream::HasOutgoingData()
|
||||
|
||||
void EQStream::OutboundQueueClear()
|
||||
{
|
||||
_eqp
|
||||
EQProtocolPacket *p=nullptr;
|
||||
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing outbound queue" __L);
|
||||
@ -1085,6 +1108,7 @@ void EQStream::OutboundQueueClear()
|
||||
|
||||
void EQStream::PacketQueueClear()
|
||||
{
|
||||
_eqp
|
||||
EQProtocolPacket *p=nullptr;
|
||||
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing future packet queue" __L);
|
||||
@ -1101,6 +1125,7 @@ void EQStream::PacketQueueClear()
|
||||
|
||||
void EQStream::Process(const unsigned char *buffer, const uint32 length)
|
||||
{
|
||||
_eqp
|
||||
static unsigned char newbuffer[2048];
|
||||
uint32 newlength=0;
|
||||
if (EQProtocolPacket::ValidateCRC(buffer,length,Key)) {
|
||||
@ -1125,6 +1150,7 @@ void EQStream::Process(const unsigned char *buffer, const uint32 length)
|
||||
|
||||
long EQStream::GetNextAckToSend()
|
||||
{
|
||||
_eqp
|
||||
MAcks.lock();
|
||||
long l=NextAckToSend;
|
||||
MAcks.unlock();
|
||||
@ -1134,6 +1160,7 @@ long EQStream::GetNextAckToSend()
|
||||
|
||||
long EQStream::GetLastAckSent()
|
||||
{
|
||||
_eqp
|
||||
MAcks.lock();
|
||||
long l=LastAckSent;
|
||||
MAcks.unlock();
|
||||
@ -1143,6 +1170,7 @@ long EQStream::GetLastAckSent()
|
||||
|
||||
void EQStream::AckPackets(uint16 seq)
|
||||
{
|
||||
_eqp
|
||||
std::deque<EQProtocolPacket *>::iterator itr, tmp;
|
||||
|
||||
MOutboundQueue.lock();
|
||||
@ -1197,6 +1225,7 @@ void EQStream::AckPackets(uint16 seq)
|
||||
|
||||
void EQStream::SetNextAckToSend(uint32 seq)
|
||||
{
|
||||
_eqp
|
||||
MAcks.lock();
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Set Next Ack To Send to %lu" __L, (unsigned long)seq);
|
||||
NextAckToSend=seq;
|
||||
@ -1205,6 +1234,7 @@ void EQStream::SetNextAckToSend(uint32 seq)
|
||||
|
||||
void EQStream::SetLastAckSent(uint32 seq)
|
||||
{
|
||||
_eqp
|
||||
MAcks.lock();
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Set Last Ack Sent to %lu" __L, (unsigned long)seq);
|
||||
LastAckSent=seq;
|
||||
@ -1213,6 +1243,7 @@ void EQStream::SetLastAckSent(uint32 seq)
|
||||
|
||||
void EQStream::ProcessQueue()
|
||||
{
|
||||
_eqp
|
||||
if(PacketQueue.empty()) {
|
||||
return;
|
||||
}
|
||||
@ -1228,6 +1259,7 @@ void EQStream::ProcessQueue()
|
||||
|
||||
EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
|
||||
{
|
||||
_eqp
|
||||
std::map<unsigned short,EQProtocolPacket *>::iterator itr;
|
||||
EQProtocolPacket *qp=nullptr;
|
||||
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
|
||||
@ -1240,6 +1272,7 @@ EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
|
||||
|
||||
void EQStream::SetStreamType(EQStreamType type)
|
||||
{
|
||||
_eqp
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Changing stream type from %s to %s" __L, StreamTypeString(StreamType), StreamTypeString(type));
|
||||
StreamType=type;
|
||||
switch (StreamType) {
|
||||
@ -1270,6 +1303,7 @@ void EQStream::SetStreamType(EQStreamType type)
|
||||
|
||||
const char *EQStream::StreamTypeString(EQStreamType t)
|
||||
{
|
||||
_eqp
|
||||
switch (t) {
|
||||
case LoginStream:
|
||||
return "Login";
|
||||
@ -1299,6 +1333,7 @@ const char *EQStream::StreamTypeString(EQStreamType t)
|
||||
//returns SeqFuture if `seq` is later than `expected_seq`
|
||||
EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
|
||||
{
|
||||
_eqp
|
||||
if (expected_seq==seq) {
|
||||
// Curent
|
||||
return SeqInOrder;
|
||||
@ -1312,6 +1347,7 @@ EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
|
||||
}
|
||||
|
||||
void EQStream::SetState(EQStreamState state) {
|
||||
_eqp
|
||||
MState.lock();
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Changing state from %d to %d" __L, State, state);
|
||||
State=state;
|
||||
@ -1320,6 +1356,7 @@ void EQStream::SetState(EQStreamState state) {
|
||||
|
||||
|
||||
void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
|
||||
_eqp
|
||||
bool outgoing_data = HasOutgoingData(); //up here to avoid recursive locking
|
||||
|
||||
EQStreamState orig_state = GetState();
|
||||
@ -1358,6 +1395,7 @@ void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
|
||||
|
||||
void EQStream::Decay()
|
||||
{
|
||||
_eqp
|
||||
MRate.lock();
|
||||
uint32 rate=DecayRate;
|
||||
MRate.unlock();
|
||||
@ -1370,6 +1408,7 @@ void EQStream::Decay()
|
||||
|
||||
void EQStream::AdjustRates(uint32 average_delta)
|
||||
{
|
||||
_eqp
|
||||
if(GetExecutablePlatform() == ExePlatformWorld || GetExecutablePlatform() == ExePlatformZone) {
|
||||
if (average_delta && (average_delta <= AVERAGE_DELTA_MAX)) {
|
||||
MRate.lock();
|
||||
@ -1395,6 +1434,7 @@ void EQStream::AdjustRates(uint32 average_delta)
|
||||
}
|
||||
|
||||
void EQStream::Close() {
|
||||
_eqp
|
||||
if(HasOutgoingData()) {
|
||||
//there is pending data, wait for it to go out.
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Stream requested to Close(), but there is pending data, waiting for it." __L);
|
||||
@ -1411,6 +1451,7 @@ void EQStream::Close() {
|
||||
//this could be expanded to check more than the fitst opcode if
|
||||
//we needed more complex matching
|
||||
EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
|
||||
_eqp
|
||||
EQRawApplicationPacket *p = nullptr;
|
||||
MatchState res = MatchNotReady;
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "eqp_profiler.h"
|
||||
#include "eqp_profile_timer.h"
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
@ -51,6 +52,8 @@ std::string EQP::CPU::ST::Profiler::EventStarted(const char *func, const char *n
|
||||
current_ = t;
|
||||
}
|
||||
|
||||
current_->GetCount()++;
|
||||
current_->SetStarted(GetCurrentTimer());
|
||||
return identifier_;
|
||||
}
|
||||
|
||||
@ -58,8 +61,9 @@ void EQP::CPU::ST::Profiler::EventFinished(uint64_t time, std::string ident) {
|
||||
if(ident.compare(identifier_) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
current_->SetStarted(0);
|
||||
current_->GetTime() += time;
|
||||
current_->GetCount()++;
|
||||
current_ = current_->GetParent();
|
||||
}
|
||||
|
||||
@ -87,6 +91,9 @@ void EQP::CPU::ST::Profiler::Dump(std::ostream &stream, int num) {
|
||||
sorted_vec.push_back(n);
|
||||
|
||||
total += iter.second->GetTime();
|
||||
if(iter.second->GetStarted() > 0) {
|
||||
total += GetCurrentTimer() - iter.second->GetStarted();
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(sorted_vec.begin(), sorted_vec.end(),
|
||||
@ -158,6 +165,8 @@ std::string EQP::CPU::MT::Profiler::EventStarted(const char *func, const char *n
|
||||
ti->current_ = t;
|
||||
}
|
||||
|
||||
ti->current_->GetCount()++;
|
||||
ti->current_->SetStarted(GetCurrentTimer());
|
||||
return imp_->identifier_;
|
||||
}
|
||||
|
||||
@ -176,8 +185,8 @@ void EQP::CPU::MT::Profiler::EventFinished(uint64_t time, std::string ident) {
|
||||
ti = ti_search->second;
|
||||
}
|
||||
|
||||
ti->current_->SetStarted(0);
|
||||
ti->current_->GetTime() += time;
|
||||
ti->current_->GetCount()++;
|
||||
ti->current_ = ti->current_->GetParent();
|
||||
}
|
||||
|
||||
@ -205,6 +214,9 @@ void EQP::CPU::MT::Profiler::Dump(std::ostream &stream, int num) {
|
||||
sorted_vec.push_back(n);
|
||||
|
||||
total += t_iter.second->GetTime();
|
||||
if(t_iter.second->GetStarted() > 0) {
|
||||
total += GetCurrentTimer() - t_iter.second->GetStarted();
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(sorted_vec.begin(), sorted_vec.end(),
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#define _eqp_dump(strm, count) EQP::CPU::ST::GetProfiler().Dump(strm, count)
|
||||
#define _eqp_dump_file(name) char time_str[128]; \
|
||||
time_t result = time(nullptr); \
|
||||
strftime(time_str, sizeof(time_str), "%Y_%m_%d_%H:%M:%S", localtime(&result)); \
|
||||
strftime(time_str, sizeof(time_str), "%Y_%m_%d_%H_%M_%S", localtime(&result)); \
|
||||
std::string prof_name = "./profile/"; \
|
||||
prof_name += name; \
|
||||
prof_name += "_"; \
|
||||
@ -32,7 +32,18 @@
|
||||
#define _eqpn(x) EQP::CPU::MT::Event eqp_comb(eq_perf_event_, __LINE__) (__PRETTY_FUNCTION__, x);
|
||||
#define _eqp_clear() EQP::CPU::MT::GetProfiler().Clear()
|
||||
#define _eqp_dump(strm, count) EQP::CPU::MT::GetProfiler().Dump(strm, count)
|
||||
#define _eqp_dump_file()
|
||||
#define _eqp_dump_file(name) char time_str[128]; \
|
||||
time_t result = time(nullptr); \
|
||||
strftime(time_str, sizeof(time_str), "%Y_%m_%d_%H_%M_%S", localtime(&result)); \
|
||||
std::string prof_name = "./profile/"; \
|
||||
prof_name += name; \
|
||||
prof_name += "_"; \
|
||||
prof_name += time_str; \
|
||||
prof_name += ".log"; \
|
||||
std::ofstream profile_out(prof_name, std::ofstream::out); \
|
||||
if(profile_out.good()) { \
|
||||
_eqp_dump(profile_out, 10); \
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace EQP
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "eqp_profiler_node.h"
|
||||
#include "eqp_profile_timer.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
@ -6,6 +7,7 @@
|
||||
EQP::CPU::ProfilerNode::ProfilerNode() {
|
||||
count_ = 0;
|
||||
time_ = 0;
|
||||
started_ = 0;
|
||||
parent_ = nullptr;;
|
||||
}
|
||||
|
||||
@ -18,12 +20,17 @@ EQP::CPU::ProfilerNode::~ProfilerNode() {
|
||||
void EQP::CPU::ProfilerNode::Dump(std::ostream &stream, const std::string &func, uint64_t total_time, int node_level, int num) {
|
||||
|
||||
if(node_level >= 1) {
|
||||
stream << std::setw(node_level * 2) << " ";
|
||||
stream << std::setw(node_level * 4) << " ";
|
||||
}
|
||||
|
||||
double m_cycles = time_ / 1000.0;
|
||||
double m_cycles = static_cast<double>(time_);
|
||||
if(started_) {
|
||||
m_cycles += GetCurrentTimer() - started_;
|
||||
}
|
||||
|
||||
double percentage = m_cycles * 100 / static_cast<double>(total_time);
|
||||
m_cycles = m_cycles / 1000.0;
|
||||
double m_avg_cycles = m_cycles / count_;
|
||||
double percentage = time_ * 100 / static_cast<double>(total_time);
|
||||
|
||||
std::streamsize p = stream.precision();
|
||||
|
||||
|
||||
@ -19,6 +19,9 @@ namespace EQP
|
||||
|
||||
inline void SetTime(uint64_t t) { time_ = t; }
|
||||
inline uint64_t& GetTime() { return time_; }
|
||||
|
||||
inline void SetStarted(uint64_t t) { started_ = t; }
|
||||
inline uint64_t& GetStarted() { return started_; }
|
||||
|
||||
inline void SetParent(ProfilerNode *p) { parent_ = p; }
|
||||
inline ProfilerNode* GetParent() { return parent_; }
|
||||
@ -29,6 +32,7 @@ namespace EQP
|
||||
private:
|
||||
uint64_t count_;
|
||||
uint64_t time_;
|
||||
uint64_t started_;
|
||||
ProfilerNode *parent_;
|
||||
std::unordered_map<std::string, ProfilerNode*> nodes_;
|
||||
};
|
||||
|
||||
@ -30,7 +30,7 @@ extern LoginServer server;
|
||||
|
||||
DatabasePostgreSQL::DatabasePostgreSQL(string user, string pass, string host, string port, string name)
|
||||
{
|
||||
_eqp_mt
|
||||
_eqp
|
||||
db = nullptr;
|
||||
db = PQsetdbLogin(host.c_str(), port.c_str(), nullptr, nullptr, name.c_str(), user.c_str(), pass.c_str());
|
||||
if(!db)
|
||||
@ -48,7 +48,7 @@ DatabasePostgreSQL::DatabasePostgreSQL(string user, string pass, string host, st
|
||||
|
||||
DatabasePostgreSQL::~DatabasePostgreSQL()
|
||||
{
|
||||
_eqp_mt
|
||||
_eqp
|
||||
if(db)
|
||||
{
|
||||
PQfinish(db);
|
||||
@ -57,7 +57,7 @@ DatabasePostgreSQL::~DatabasePostgreSQL()
|
||||
|
||||
bool DatabasePostgreSQL::GetLoginDataFromAccountName(string name, string &password, unsigned int &id)
|
||||
{
|
||||
_eqp_mt
|
||||
_eqp
|
||||
if(!db)
|
||||
{
|
||||
return false;
|
||||
@ -106,7 +106,7 @@ bool DatabasePostgreSQL::GetLoginDataFromAccountName(string name, string &passwo
|
||||
bool DatabasePostgreSQL::GetWorldRegistration(string long_name, string short_name, unsigned int &id, string &desc, unsigned int &list_id,
|
||||
unsigned int &trusted, string &list_desc, string &account, string &password)
|
||||
{
|
||||
_eqp_mt
|
||||
_eqp
|
||||
if(!db)
|
||||
{
|
||||
return false;
|
||||
@ -164,7 +164,7 @@ bool DatabasePostgreSQL::GetWorldRegistration(string long_name, string short_nam
|
||||
|
||||
void DatabasePostgreSQL::UpdateLSAccountData(unsigned int id, string ip_address)
|
||||
{
|
||||
_eqp_mt
|
||||
_eqp
|
||||
if(!db)
|
||||
{
|
||||
return;
|
||||
@ -200,7 +200,7 @@ void DatabasePostgreSQL::UpdateLSAccountData(unsigned int id, string ip_address)
|
||||
|
||||
void DatabasePostgreSQL::UpdateWorldRegistration(unsigned int id, string long_name, string ip_address)
|
||||
{
|
||||
_eqp_mt
|
||||
_eqp
|
||||
if(!db)
|
||||
{
|
||||
return;
|
||||
|
||||
@ -45,6 +45,8 @@ int main()
|
||||
{
|
||||
RegisterExecutablePlatform(ExePlatformLogin);
|
||||
set_exception_handler();
|
||||
_eqp
|
||||
|
||||
Log.LoadLogSettingsDefaults();
|
||||
|
||||
//log_settings
|
||||
@ -262,13 +264,10 @@ int main()
|
||||
Log.Out(Logs::General, Logs::Debug, "Server Started.");
|
||||
while(run_server)
|
||||
{
|
||||
{
|
||||
_eqpn("Main loop");
|
||||
Timer::SetCurrentTime();
|
||||
server.CM->Process();
|
||||
server.SM->Process();
|
||||
}
|
||||
Sleep(100);
|
||||
Timer::SetCurrentTime();
|
||||
server.CM->Process();
|
||||
server.SM->Process();
|
||||
Sleep(50);
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::Debug, "Server Shutdown.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user