Working working working on adding profiling, also switched to multi-threaded profiler (slower but need it).

This commit is contained in:
KimLS 2015-01-31 19:06:14 -08:00
parent 2acf84ce4a
commit 444b652c4f
31 changed files with 409 additions and 392 deletions

View File

@ -11,7 +11,7 @@ ADD_EXECUTABLE(export_client_files ${export_sources} ${export_headers})
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
TARGET_LINK_LIBRARIES(export_client_files common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(export_client_files common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(export_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") SET_TARGET_PROPERTIES(export_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")

View File

@ -11,7 +11,7 @@ ADD_EXECUTABLE(import_client_files ${import_sources} ${import_headers})
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
TARGET_LINK_LIBRARIES(import_client_files common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(import_client_files common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(import_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") SET_TARGET_PROPERTIES(import_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")

View File

@ -1620,7 +1620,7 @@ uint32 Database::GetGroupID(const char* name){
if (results.RowCount() == 0) if (results.RowCount() == 0)
{ {
// Commenting this out until logging levels can prevent this from going to console // Commenting this out until logging levels can prevent this from going to console
//Log.Out(Logs::General, Logs::None,, "Character not in a group: %s", name); //Log.Out(Logs::General, Logs::None, "Character not in a group: %s", name);
return 0; return 0;
} }

View File

@ -39,9 +39,11 @@ EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len), : BasePacket(buf, len),
emu_opcode(op) emu_opcode(op)
{ {
_eqp_mt
} }
void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const { void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
_eqp_mt
BasePacket::build_raw_header_dump(buffer, seq); BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer); buffer += strlen(buffer);
@ -50,17 +52,20 @@ void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
void EQPacket::DumpRawHeader(uint16 seq, FILE *to) const void EQPacket::DumpRawHeader(uint16 seq, FILE *to) const
{ {
_eqp_mt
char buff[196]; char buff[196];
build_raw_header_dump(buff, seq); build_raw_header_dump(buff, seq);
fprintf(to, "%s", buff); fprintf(to, "%s", buff);
} }
void EQPacket::build_header_dump(char *buffer) const { void EQPacket::build_header_dump(char *buffer) const {
_eqp_mt
sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]", emu_opcode, size); sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]", emu_opcode, size);
} }
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
_eqp_mt
if (src_ip) { if (src_ip) {
std::string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
@ -75,6 +80,7 @@ void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
{ {
_eqp_mt
BasePacket::build_raw_header_dump(buffer, seq); BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer); buffer += strlen(buffer);
@ -83,6 +89,7 @@ void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
void EQProtocolPacket::DumpRawHeader(uint16 seq, FILE *to) const void EQProtocolPacket::DumpRawHeader(uint16 seq, FILE *to) const
{ {
_eqp_mt
char buff[196]; char buff[196];
build_raw_header_dump(buff, seq); build_raw_header_dump(buff, seq);
fprintf(to, "%s", buff); fprintf(to, "%s", buff);
@ -90,11 +97,13 @@ void EQProtocolPacket::DumpRawHeader(uint16 seq, FILE *to) const
void EQProtocolPacket::build_header_dump(char *buffer) const void EQProtocolPacket::build_header_dump(char *buffer) const
{ {
_eqp_mt
sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]",opcode,size); sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]",opcode,size);
} }
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
_eqp_mt
if (src_ip) { if (src_ip) {
std::string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
@ -109,6 +118,7 @@ void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
{ {
_eqp_mt
BasePacket::build_raw_header_dump(buffer, seq); BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer); buffer += strlen(buffer);
@ -121,6 +131,7 @@ void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
void EQApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const void EQApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
{ {
_eqp_mt
char buff[196]; char buff[196];
build_raw_header_dump(buff, seq); build_raw_header_dump(buff, seq);
fprintf(to, "%s", buff); fprintf(to, "%s", buff);
@ -128,6 +139,7 @@ void EQApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
void EQApplicationPacket::build_header_dump(char *buffer) const void EQApplicationPacket::build_header_dump(char *buffer) const
{ {
_eqp_mt
#ifdef STATIC_OPCODE #ifdef STATIC_OPCODE
sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size); sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
#else #else
@ -137,6 +149,7 @@ void EQApplicationPacket::build_header_dump(char *buffer) const
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
_eqp_mt
if (src_ip) { if (src_ip) {
std::string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
@ -155,6 +168,7 @@ void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
{ {
_eqp_mt
BasePacket::build_raw_header_dump(buffer, seq); BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer); buffer += strlen(buffer);
@ -167,6 +181,7 @@ void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) con
void EQRawApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const void EQRawApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
{ {
_eqp_mt
char buff[196]; char buff[196];
build_raw_header_dump(buff, seq); build_raw_header_dump(buff, seq);
fprintf(to, "%s", buff); fprintf(to, "%s", buff);
@ -174,6 +189,7 @@ void EQRawApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
void EQRawApplicationPacket::build_header_dump(char *buffer) const void EQRawApplicationPacket::build_header_dump(char *buffer) const
{ {
_eqp_mt
#ifdef STATIC_OPCODE #ifdef STATIC_OPCODE
sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size); sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
#else #else
@ -183,6 +199,7 @@ void EQRawApplicationPacket::build_header_dump(char *buffer) const
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
_eqp_mt
if (src_ip) { if (src_ip) {
std::string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
@ -201,6 +218,7 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
uint32 EQProtocolPacket::serialize(unsigned char *dest) const uint32 EQProtocolPacket::serialize(unsigned char *dest) const
{ {
_eqp_mt
if (opcode>0xff) { if (opcode>0xff) {
*(uint16 *)dest=opcode; *(uint16 *)dest=opcode;
} else { } else {
@ -214,6 +232,7 @@ uint32 EQProtocolPacket::serialize(unsigned char *dest) const
uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
{ {
_eqp_mt
uint8 OpCodeBytes = app_opcode_size; uint8 OpCodeBytes = app_opcode_size;
if (app_opcode_size==1) if (app_opcode_size==1)
@ -235,29 +254,10 @@ uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
return size+OpCodeBytes; return size+OpCodeBytes;
} }
/*EQProtocolPacket::EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len),
opcode(op)
{
uint32 offset;
opcode=ntohs(*(const uint16 *)buf);
offset=2;
if (len-offset) {
pBuffer= new unsigned char[len-offset];
memcpy(pBuffer,buf+offset,len-offset);
size=len-offset;
} else {
pBuffer=nullptr;
size=0;
}
OpMgr=&RawOpcodeManager;
}*/
bool EQProtocolPacket::combine(const EQProtocolPacket *rhs) bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
{ {
bool result=false; _eqp_mt
bool result=false;
if (opcode==OP_Combined && size+rhs->size+5<256) { if (opcode==OP_Combined && size+rhs->size+5<256) {
unsigned char *tmpbuffer=new unsigned char [size+rhs->size+3]; unsigned char *tmpbuffer=new unsigned char [size+rhs->size+3];
memcpy(tmpbuffer,pBuffer,size); memcpy(tmpbuffer,pBuffer,size);
@ -286,58 +286,10 @@ bool result=false;
} }
/*
this is the code to do app-layer combining, instead of protocol layer.
this was taken out due to complex interactions with the opcode manager,
and will require a bit more thinking (likely moving into EQStream) to
get running again... but might be a good thing some day.
bool EQApplicationPacket::combine(const EQApplicationPacket *rhs)
{
uint32 newsize=0, offset=0;
unsigned char *tmpbuffer=nullptr;
if (opcode!=OP_AppCombined) {
newsize=app_opcode_size+size+(size>254?3:1)+app_opcode_size+rhs->size+(rhs->size>254?3:1);
tmpbuffer=new unsigned char [newsize];
offset=0;
if (size>254) {
tmpbuffer[offset++]=0xff;
*(uint16 *)(tmpbuffer+offset)=htons(size);
offset+=1;
} else {
tmpbuffer[offset++]=size;
}
offset+=serialize(tmpbuffer+offset);
} else {
newsize=size+app_opcode_size+rhs->size+(rhs->size>254?3:1);
tmpbuffer=new unsigned char [newsize];
memcpy(tmpbuffer,pBuffer,size);
offset=size;
}
if (rhs->size>254) {
tmpbuffer[offset++]=0xff;
*(uint16 *)(tmpbuffer+offset)=htons(rhs->size);
offset+=1;
} else {
tmpbuffer[offset++]=rhs->size;
}
offset+=rhs->serialize(tmpbuffer+offset);
size=offset;
opcode=OP_AppCombined;
delete[] pBuffer;
pBuffer=tmpbuffer;
return true;
}
*/
bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint32 Key) bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint32 Key)
{ {
bool valid=false; _eqp_mt
bool valid=false;
// OP_SessionRequest, OP_SessionResponse, OP_OutOfSession are not CRC'd // 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)) { if (buffer[0]==0x00 && (buffer[1]==OP_SessionRequest || buffer[1]==OP_SessionResponse || buffer[1]==OP_OutOfSession)) {
valid=true; valid=true;
@ -356,8 +308,9 @@ bool valid=false;
uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize)
{ {
uint32 newlen=0; _eqp_mt
uint32 flag_offset=0; uint32 newlen=0;
uint32 flag_offset=0;
newbuf[0]=buffer[0]; newbuf[0]=buffer[0];
if (buffer[0]==0x00) { if (buffer[0]==0x00) {
flag_offset=2; flag_offset=2;
@ -381,7 +334,8 @@ uint32 flag_offset=0;
} }
uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) { uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) {
uint32 flag_offset=1,newlength; _eqp_mt
uint32 flag_offset=1,newlength;
//dump_message_column(buffer,length,"Before: "); //dump_message_column(buffer,length,"Before: ");
newbuf[0]=buffer[0]; newbuf[0]=buffer[0];
if (buffer[0]==0) { if (buffer[0]==0) {
@ -404,6 +358,7 @@ uint32 flag_offset=1,newlength;
void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey) void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey)
{ {
_eqp_mt
if ((size >= 2) && buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) { if ((size >= 2) && buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
int Key=DecodeKey; int Key=DecodeKey;
unsigned char *test=(unsigned char *)malloc(size); unsigned char *test=(unsigned char *)malloc(size);
@ -429,6 +384,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey) void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey)
{ {
_eqp_mt
if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) { if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
int Key=EncodeKey; int Key=EncodeKey;
char *test=(char*)malloc(size); char *test=(char*)malloc(size);
@ -452,10 +408,12 @@ void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey
} }
EQApplicationPacket *EQApplicationPacket::Copy() const { EQApplicationPacket *EQApplicationPacket::Copy() const {
_eqp_mt
return(new EQApplicationPacket(*this)); return(new EQApplicationPacket(*this));
} }
EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const { EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
_eqp_mt
EQRawApplicationPacket *res = new EQRawApplicationPacket(opcode, pBuffer, size); EQRawApplicationPacket *res = new EQRawApplicationPacket(opcode, pBuffer, size);
res->copyInfo(this); res->copyInfo(this);
return(res); return(res);
@ -465,10 +423,12 @@ EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned cha
: EQApplicationPacket(OP_Unknown, buf, len), : EQApplicationPacket(OP_Unknown, buf, len),
opcode(opcode) opcode(opcode)
{ {
_eqp_mt
} }
EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len) EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len)
: EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16)) : EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16))
{ {
_eqp_mt
if(GetExecutablePlatform() != ExePlatformUCS) { if(GetExecutablePlatform() != ExePlatformUCS) {
opcode = *((const uint16 *) buf); opcode = *((const uint16 *) buf);
if(opcode == 0x0000) if(opcode == 0x0000)
@ -502,11 +462,11 @@ EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const u
} }
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) { void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
_eqp_mt
if (iShowInfo) { if (iShowInfo) {
std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec; std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
std::cout << " size:" << app->size << std::endl; std::cout << " size:" << app->size << std::endl;
} }
DumpPacketHex(app->pBuffer, app->size); DumpPacketHex(app->pBuffer, app->size);
// DumpPacketAscii(app->pBuffer, app->size);
} }

View File

@ -49,6 +49,7 @@
uint16 EQStream::MaxWindowSize=2048; uint16 EQStream::MaxWindowSize=2048;
void EQStream::init(bool resetSession) { void EQStream::init(bool resetSession) {
_eqp_mt
// we only reset these statistics if it is a 'new' connection // we only reset these statistics if it is a 'new' connection
if ( resetSession ) if ( resetSession )
{ {
@ -91,6 +92,7 @@ void EQStream::init(bool resetSession) {
EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p) EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
{ {
_eqp_mt
EQRawApplicationPacket *ap=nullptr; EQRawApplicationPacket *ap=nullptr;
Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, p->size); Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, p->size);
// _raw(NET__APP_CREATE_HEX, 0xFFFF, p); // _raw(NET__APP_CREATE_HEX, 0xFFFF, p);
@ -100,6 +102,7 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len) EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len)
{ {
_eqp_mt
EQRawApplicationPacket *ap=nullptr; EQRawApplicationPacket *ap=nullptr;
Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, len); Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, len);
ap = new EQRawApplicationPacket(buf, len); ap = new EQRawApplicationPacket(buf, len);
@ -107,6 +110,7 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf
} }
EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32 len) { EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32 len) {
_eqp_mt
uint16 proto_opcode = ntohs(*(const uint16 *)buf); uint16 proto_opcode = ntohs(*(const uint16 *)buf);
//advance over opcode. //advance over opcode.
@ -118,6 +122,7 @@ EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32
void EQStream::ProcessPacket(EQProtocolPacket *p) void EQStream::ProcessPacket(EQProtocolPacket *p)
{ {
_eqp_mt
uint32 processed=0, subpacket_length=0; uint32 processed=0, subpacket_length=0;
if (p == nullptr) if (p == nullptr)
return; return;
@ -515,6 +520,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req) void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
{ {
_eqp_mt
if(p == nullptr) if(p == nullptr)
return; return;
@ -526,6 +532,7 @@ void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req) void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
{ {
_eqp_mt
EQApplicationPacket *pack=*p; EQApplicationPacket *pack=*p;
*p = nullptr; //clear caller's pointer.. effectively takes ownership *p = nullptr; //clear caller's pointer.. effectively takes ownership
@ -555,6 +562,7 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p) void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
{ {
_eqp_mt
uint32 chunksize,used; uint32 chunksize,used;
uint32 length; uint32 length;
@ -599,6 +607,7 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
void EQStream::SequencedPush(EQProtocolPacket *p) void EQStream::SequencedPush(EQProtocolPacket *p)
{ {
_eqp_mt
#ifdef COLLECTOR #ifdef COLLECTOR
delete p; delete p;
#else #else
@ -627,6 +636,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
void EQStream::NonSequencedPush(EQProtocolPacket *p) void EQStream::NonSequencedPush(EQProtocolPacket *p)
{ {
_eqp_mt
#ifdef COLLECTOR #ifdef COLLECTOR
delete p; delete p;
#else #else
@ -639,7 +649,8 @@ void EQStream::NonSequencedPush(EQProtocolPacket *p)
void EQStream::SendAck(uint16 seq) void EQStream::SendAck(uint16 seq)
{ {
uint16 Seq=htons(seq); _eqp_mt
uint16 Seq=htons(seq);
Log.Out(Logs::Detail, Logs::Netcode, _L "Sending ack with sequence %d" __L, seq); Log.Out(Logs::Detail, Logs::Netcode, _L "Sending ack with sequence %d" __L, seq);
SetLastAckSent(seq); SetLastAckSent(seq);
NonSequencedPush(new EQProtocolPacket(OP_Ack,(unsigned char *)&Seq,sizeof(uint16))); NonSequencedPush(new EQProtocolPacket(OP_Ack,(unsigned char *)&Seq,sizeof(uint16)));
@ -647,6 +658,7 @@ uint16 Seq=htons(seq);
void EQStream::SendOutOfOrderAck(uint16 seq) void EQStream::SendOutOfOrderAck(uint16 seq)
{ {
_eqp_mt
Log.Out(Logs::Detail, Logs::Netcode, _L "Sending out of order ack with sequence %d" __L, seq); 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))); NonSequencedPush(new EQProtocolPacket(OP_OutOfOrderAck,(unsigned char *)&Seq,sizeof(uint16)));
@ -654,6 +666,7 @@ uint16 Seq=htons(seq);
void EQStream::Write(int eq_fd) void EQStream::Write(int eq_fd)
{ {
_eqp_mt
std::queue<EQProtocolPacket *> ReadyToSend; std::queue<EQProtocolPacket *> ReadyToSend;
bool SeqEmpty=false, NonSeqEmpty=false; bool SeqEmpty=false, NonSeqEmpty=false;
std::deque<EQProtocolPacket *>::iterator sitr; std::deque<EQProtocolPacket *>::iterator sitr;
@ -849,8 +862,9 @@ void EQStream::Write(int eq_fd)
void EQStream::WritePacket(int eq_fd, EQProtocolPacket *p) void EQStream::WritePacket(int eq_fd, EQProtocolPacket *p)
{ {
uint32 length; _eqp_mt
sockaddr_in address; uint32 length;
sockaddr_in address;
address.sin_family = AF_INET; address.sin_family = AF_INET;
address.sin_addr.s_addr=remote_ip; address.sin_addr.s_addr=remote_ip;
address.sin_port=remote_port; address.sin_port=remote_port;
@ -887,7 +901,8 @@ sockaddr_in address;
void EQStream::SendSessionResponse() void EQStream::SendSessionResponse()
{ {
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(SessionResponse)); _eqp_mt
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(SessionResponse));
SessionResponse *Response=(SessionResponse *)out->pBuffer; SessionResponse *Response=(SessionResponse *)out->pBuffer;
Response->Session=htonl(Session); Response->Session=htonl(Session);
Response->MaxLength=htonl(MaxLen); Response->MaxLength=htonl(MaxLen);
@ -909,7 +924,8 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(Ses
void EQStream::SendSessionRequest() void EQStream::SendSessionRequest()
{ {
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(SessionRequest)); _eqp_mt
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(SessionRequest));
SessionRequest *Request=(SessionRequest *)out->pBuffer; SessionRequest *Request=(SessionRequest *)out->pBuffer;
memset(Request,0,sizeof(SessionRequest)); memset(Request,0,sizeof(SessionRequest));
Request->Session=htonl(time(nullptr)); Request->Session=htonl(time(nullptr));
@ -922,6 +938,7 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(Sess
void EQStream::_SendDisconnect() void EQStream::_SendDisconnect()
{ {
_eqp_mt
if(GetState() == CLOSED) if(GetState() == CLOSED)
return; return;
@ -934,6 +951,7 @@ void EQStream::_SendDisconnect()
void EQStream::InboundQueuePush(EQRawApplicationPacket *p) void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
{ {
_eqp_mt
MInboundQueue.lock(); MInboundQueue.lock();
InboundQueue.push_back(p); InboundQueue.push_back(p);
MInboundQueue.unlock(); MInboundQueue.unlock();
@ -941,7 +959,8 @@ void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
EQApplicationPacket *EQStream::PopPacket() EQApplicationPacket *EQStream::PopPacket()
{ {
EQRawApplicationPacket *p=nullptr; _eqp_mt
EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
@ -968,7 +987,8 @@ EQRawApplicationPacket *p=nullptr;
EQRawApplicationPacket *EQStream::PopRawPacket() EQRawApplicationPacket *EQStream::PopRawPacket()
{ {
EQRawApplicationPacket *p=nullptr; _eqp_mt
EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
@ -995,7 +1015,8 @@ EQRawApplicationPacket *p=nullptr;
EQRawApplicationPacket *EQStream::PeekPacket() EQRawApplicationPacket *EQStream::PeekPacket()
{ {
EQRawApplicationPacket *p=nullptr; _eqp_mt
EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
@ -1009,7 +1030,8 @@ EQRawApplicationPacket *p=nullptr;
void EQStream::InboundQueueClear() void EQStream::InboundQueueClear()
{ {
EQApplicationPacket *p=nullptr; _eqp_mt
EQApplicationPacket *p=nullptr;
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing inbound queue" __L); Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing inbound queue" __L);
@ -1027,7 +1049,8 @@ EQApplicationPacket *p=nullptr;
bool EQStream::HasOutgoingData() bool EQStream::HasOutgoingData()
{ {
bool flag; _eqp_mt
bool flag;
//once closed, we have nothing more to say //once closed, we have nothing more to say
if(CheckClosed()) if(CheckClosed())
@ -1052,7 +1075,8 @@ bool flag;
void EQStream::OutboundQueueClear() void EQStream::OutboundQueueClear()
{ {
EQProtocolPacket *p=nullptr; _eqp_mt
EQProtocolPacket *p=nullptr;
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing outbound queue" __L); Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing outbound queue" __L);
@ -1074,7 +1098,8 @@ EQProtocolPacket *p=nullptr;
void EQStream::PacketQueueClear() void EQStream::PacketQueueClear()
{ {
EQProtocolPacket *p=nullptr; _eqp_mt
EQProtocolPacket *p=nullptr;
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing future packet queue" __L); Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing future packet queue" __L);
@ -1090,8 +1115,9 @@ EQProtocolPacket *p=nullptr;
void EQStream::Process(const unsigned char *buffer, const uint32 length) void EQStream::Process(const unsigned char *buffer, const uint32 length)
{ {
static unsigned char newbuffer[2048]; _eqp_mt
uint32 newlength=0; static unsigned char newbuffer[2048];
uint32 newlength=0;
if (EQProtocolPacket::ValidateCRC(buffer,length,Key)) { if (EQProtocolPacket::ValidateCRC(buffer,length,Key)) {
if (compressed) { if (compressed) {
newlength=EQProtocolPacket::Decompress(buffer,length,newbuffer,2048); newlength=EQProtocolPacket::Decompress(buffer,length,newbuffer,2048);
@ -1114,6 +1140,7 @@ uint32 newlength=0;
long EQStream::GetNextAckToSend() long EQStream::GetNextAckToSend()
{ {
_eqp_mt
MAcks.lock(); MAcks.lock();
long l=NextAckToSend; long l=NextAckToSend;
MAcks.unlock(); MAcks.unlock();
@ -1123,6 +1150,7 @@ long EQStream::GetNextAckToSend()
long EQStream::GetLastAckSent() long EQStream::GetLastAckSent()
{ {
_eqp_mt
MAcks.lock(); MAcks.lock();
long l=LastAckSent; long l=LastAckSent;
MAcks.unlock(); MAcks.unlock();
@ -1132,16 +1160,17 @@ long EQStream::GetLastAckSent()
void EQStream::AckPackets(uint16 seq) void EQStream::AckPackets(uint16 seq)
{ {
std::deque<EQProtocolPacket *>::iterator itr, tmp; _eqp_mt
std::deque<EQProtocolPacket *>::iterator itr, tmp;
MOutboundQueue.lock(); MOutboundQueue.lock();
//do a bit of sanity checking. //do a bit of sanity checking.
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Ack Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Ack Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
} }
if(NextSequencedSend > SequencedQueue.size()) { if(NextSequencedSend > SequencedQueue.size()) {
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Ack 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 "Pre-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
} }
SeqOrder ord = CompareSequence(SequencedBase, seq); SeqOrder ord = CompareSequence(SequencedBase, seq);
if(ord == SeqInOrder) { if(ord == SeqInOrder) {
@ -1157,12 +1186,12 @@ if(NextSequencedSend > SequencedQueue.size()) {
//this is a good ack, we get to ack some blocks. //this is a good ack, we get to ack some blocks.
seq++; //we stop at the block right after their ack, counting on the wrap of both numbers. seq++; //we stop at the block right after their ack, counting on the wrap of both numbers.
while(SequencedBase != seq) { while(SequencedBase != seq) {
if(SequencedQueue.empty()) { if(SequencedQueue.empty()) {
Log.Out(Logs::Detail, Logs::Netcode, _L "OUT OF PACKETS acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, NextSequencedSend); Log.Out(Logs::Detail, Logs::Netcode, _L "OUT OF PACKETS acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, NextSequencedSend);
SequencedBase = NextOutSeq; SequencedBase = NextOutSeq;
NextSequencedSend = 0; NextSequencedSend = 0;
break; break;
} }
Log.Out(Logs::Detail, Logs::Netcode, _L "Removing acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, NextSequencedSend); Log.Out(Logs::Detail, Logs::Netcode, _L "Removing acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, NextSequencedSend);
//clean out the acked packet //clean out the acked packet
delete SequencedQueue.front(); delete SequencedQueue.front();
@ -1173,12 +1202,12 @@ Log.Out(Logs::Detail, Logs::Netcode, _L "OUT OF PACKETS acked packet with sequen
//advance the base sequence number to the seq of the block after the one we just got rid of. //advance the base sequence number to the seq of the block after the one we just got rid of.
SequencedBase++; SequencedBase++;
} }
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
Log.Out(Logs::Detail, Logs::Netcode, _L "Post-Ack on %d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, seq, SequencedBase, SequencedQueue.size(), NextOutSeq); Log.Out(Logs::Detail, Logs::Netcode, _L "Post-Ack on %d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, seq, SequencedBase, SequencedQueue.size(), NextOutSeq);
} }
if(NextSequencedSend > SequencedQueue.size()) { if(NextSequencedSend > SequencedQueue.size()) {
Log.Out(Logs::Detail, Logs::Netcode, _L "Post-Ack 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 "Post-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
} }
} }
MOutboundQueue.unlock(); MOutboundQueue.unlock();
@ -1186,6 +1215,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
void EQStream::SetNextAckToSend(uint32 seq) void EQStream::SetNextAckToSend(uint32 seq)
{ {
_eqp_mt
MAcks.lock(); MAcks.lock();
Log.Out(Logs::Detail, Logs::Netcode, _L "Set Next Ack To Send to %lu" __L, (unsigned long)seq); Log.Out(Logs::Detail, Logs::Netcode, _L "Set Next Ack To Send to %lu" __L, (unsigned long)seq);
NextAckToSend=seq; NextAckToSend=seq;
@ -1194,6 +1224,7 @@ void EQStream::SetNextAckToSend(uint32 seq)
void EQStream::SetLastAckSent(uint32 seq) void EQStream::SetLastAckSent(uint32 seq)
{ {
_eqp_mt
MAcks.lock(); MAcks.lock();
Log.Out(Logs::Detail, Logs::Netcode, _L "Set Last Ack Sent to %lu" __L, (unsigned long)seq); Log.Out(Logs::Detail, Logs::Netcode, _L "Set Last Ack Sent to %lu" __L, (unsigned long)seq);
LastAckSent=seq; LastAckSent=seq;
@ -1202,6 +1233,7 @@ void EQStream::SetLastAckSent(uint32 seq)
void EQStream::ProcessQueue() void EQStream::ProcessQueue()
{ {
_eqp_mt
if(PacketQueue.empty()) { if(PacketQueue.empty()) {
return; return;
} }
@ -1217,8 +1249,9 @@ void EQStream::ProcessQueue()
EQProtocolPacket *EQStream::RemoveQueue(uint16 seq) EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
{ {
std::map<unsigned short,EQProtocolPacket *>::iterator itr; _eqp_mt
EQProtocolPacket *qp=nullptr; std::map<unsigned short,EQProtocolPacket *>::iterator itr;
EQProtocolPacket *qp=nullptr;
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) { if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
qp=itr->second; qp=itr->second;
PacketQueue.erase(itr); PacketQueue.erase(itr);
@ -1229,6 +1262,7 @@ EQProtocolPacket *qp=nullptr;
void EQStream::SetStreamType(EQStreamType type) void EQStream::SetStreamType(EQStreamType type)
{ {
_eqp_mt
Log.Out(Logs::Detail, Logs::Netcode, _L "Changing stream type from %s to %s" __L, StreamTypeString(StreamType), StreamTypeString(type)); Log.Out(Logs::Detail, Logs::Netcode, _L "Changing stream type from %s to %s" __L, StreamTypeString(StreamType), StreamTypeString(type));
StreamType=type; StreamType=type;
switch (StreamType) { switch (StreamType) {
@ -1259,6 +1293,7 @@ void EQStream::SetStreamType(EQStreamType type)
const char *EQStream::StreamTypeString(EQStreamType t) const char *EQStream::StreamTypeString(EQStreamType t)
{ {
_eqp_mt
switch (t) { switch (t) {
case LoginStream: case LoginStream:
return "Login"; return "Login";
@ -1288,6 +1323,7 @@ const char *EQStream::StreamTypeString(EQStreamType t)
//returns SeqFuture if `seq` is later than `expected_seq` //returns SeqFuture if `seq` is later than `expected_seq`
EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq) EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
{ {
_eqp_mt
if (expected_seq==seq) { if (expected_seq==seq) {
// Curent // Curent
return SeqInOrder; return SeqInOrder;
@ -1301,6 +1337,7 @@ EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
} }
void EQStream::SetState(EQStreamState state) { void EQStream::SetState(EQStreamState state) {
_eqp_mt
MState.lock(); MState.lock();
Log.Out(Logs::Detail, Logs::Netcode, _L "Changing state from %d to %d" __L, State, state); Log.Out(Logs::Detail, Logs::Netcode, _L "Changing state from %d to %d" __L, State, state);
State=state; State=state;
@ -1309,7 +1346,7 @@ void EQStream::SetState(EQStreamState state) {
void EQStream::CheckTimeout(uint32 now, uint32 timeout) { void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
_eqp_mt
bool outgoing_data = HasOutgoingData(); //up here to avoid recursive locking bool outgoing_data = HasOutgoingData(); //up here to avoid recursive locking
EQStreamState orig_state = GetState(); EQStreamState orig_state = GetState();
@ -1348,6 +1385,7 @@ void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
void EQStream::Decay() void EQStream::Decay()
{ {
_eqp_mt
MRate.lock(); MRate.lock();
uint32 rate=DecayRate; uint32 rate=DecayRate;
MRate.unlock(); MRate.unlock();
@ -1360,6 +1398,7 @@ void EQStream::Decay()
void EQStream::AdjustRates(uint32 average_delta) void EQStream::AdjustRates(uint32 average_delta)
{ {
_eqp_mt
if(GetExecutablePlatform() == ExePlatformWorld || GetExecutablePlatform() == ExePlatformZone) { if(GetExecutablePlatform() == ExePlatformWorld || GetExecutablePlatform() == ExePlatformZone) {
if (average_delta && (average_delta <= AVERAGE_DELTA_MAX)) { if (average_delta && (average_delta <= AVERAGE_DELTA_MAX)) {
MRate.lock(); MRate.lock();
@ -1385,6 +1424,7 @@ void EQStream::AdjustRates(uint32 average_delta)
} }
void EQStream::Close() { void EQStream::Close() {
_eqp_mt
if(HasOutgoingData()) { if(HasOutgoingData()) {
//there is pending data, wait for it to go out. //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); Log.Out(Logs::Detail, Logs::Netcode, _L "Stream requested to Close(), but there is pending data, waiting for it." __L);
@ -1401,6 +1441,7 @@ void EQStream::Close() {
//this could be expanded to check more than the fitst opcode if //this could be expanded to check more than the fitst opcode if
//we needed more complex matching //we needed more complex matching
EQStream::MatchState EQStream::CheckSignature(const Signature *sig) { EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
_eqp_mt
EQRawApplicationPacket *p = nullptr; EQRawApplicationPacket *p = nullptr;
MatchState res = MatchNotReady; MatchState res = MatchNotReady;

View File

@ -23,7 +23,7 @@
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs) ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
{ {
EQStreamFactory *fs=(EQStreamFactory *)eqfs; EQStreamFactory *fs = (EQStreamFactory*)eqfs;
#ifndef WIN32 #ifndef WIN32
Log.Out(Logs::Detail, Logs::None, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self()); Log.Out(Logs::Detail, Logs::None, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
@ -40,7 +40,7 @@ EQStreamFactory *fs=(EQStreamFactory *)eqfs;
ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs) ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
{ {
EQStreamFactory *fs=(EQStreamFactory *)eqfs; EQStreamFactory *fs = (EQStreamFactory*)eqfs;
#ifndef WIN32 #ifndef WIN32
Log.Out(Logs::Detail, Logs::None, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self()); Log.Out(Logs::Detail, Logs::None, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
@ -65,6 +65,7 @@ EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
void EQStreamFactory::Close() void EQStreamFactory::Close()
{ {
_eqp_mt
Stop(); Stop();
#ifdef _WINDOWS #ifdef _WINDOWS
@ -77,7 +78,8 @@ void EQStreamFactory::Close()
bool EQStreamFactory::Open() bool EQStreamFactory::Open()
{ {
struct sockaddr_in address; _eqp_mt
struct sockaddr_in address;
#ifndef WIN32 #ifndef WIN32
pthread_t t1,t2; pthread_t t1,t2;
#endif #endif
@ -118,6 +120,7 @@ struct sockaddr_in address;
std::shared_ptr<EQStream> EQStreamFactory::Pop() std::shared_ptr<EQStream> EQStreamFactory::Pop()
{ {
_eqp_mt
std::shared_ptr<EQStream> s = nullptr; std::shared_ptr<EQStream> s = nullptr;
MNewStreams.lock(); MNewStreams.lock();
if (NewStreams.size()) { if (NewStreams.size()) {
@ -132,6 +135,7 @@ std::shared_ptr<EQStream> EQStreamFactory::Pop()
void EQStreamFactory::Push(std::shared_ptr<EQStream> s) void EQStreamFactory::Push(std::shared_ptr<EQStream> s)
{ {
_eqp_mt
MNewStreams.lock(); MNewStreams.lock();
NewStreams.push(s); NewStreams.push(s);
MNewStreams.unlock(); MNewStreams.unlock();
@ -216,6 +220,7 @@ void EQStreamFactory::ReaderLoop()
void EQStreamFactory::CheckTimeout() void EQStreamFactory::CheckTimeout()
{ {
_eqp_mt
//lock streams the entire time were checking timeouts, it should be fast. //lock streams the entire time were checking timeouts, it should be fast.
MStreams.lock(); MStreams.lock();

View File

@ -89,6 +89,7 @@ EQEmuLogSys::~EQEmuLogSys()
void EQEmuLogSys::LoadLogSettingsDefaults() void EQEmuLogSys::LoadLogSettingsDefaults()
{ {
_eqp_mt
/* Get Executable platform currently running this code (Zone/World/etc) */ /* Get Executable platform currently running this code (Zone/World/etc) */
log_platform = GetExecutablePlatformInt(); log_platform = GetExecutablePlatformInt();
@ -96,6 +97,7 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
memset(log_settings, 0, sizeof(LogSettings) * Logs::LogCategory::MaxCategoryID); memset(log_settings, 0, sizeof(LogSettings) * Logs::LogCategory::MaxCategoryID);
/* Set Defaults */ /* Set Defaults */
log_settings[Logs::LoginServer].log_to_console = Logs::General;
log_settings[Logs::World_Server].log_to_console = Logs::General; log_settings[Logs::World_Server].log_to_console = Logs::General;
log_settings[Logs::Zone_Server].log_to_console = Logs::General; log_settings[Logs::Zone_Server].log_to_console = Logs::General;
log_settings[Logs::QS_Server].log_to_console = Logs::General; log_settings[Logs::QS_Server].log_to_console = Logs::General;
@ -116,12 +118,13 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
platform_file_name = "ucs"; platform_file_name = "ucs";
else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformLogin) else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformLogin)
platform_file_name = "login"; platform_file_name = "login";
else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformLogin) else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformLaunch)
platform_file_name = "launcher"; platform_file_name = "launcher";
} }
std::string EQEmuLogSys::FormatOutMessageString(uint16 log_category, const std::string &in_message) std::string EQEmuLogSys::FormatOutMessageString(uint16 log_category, const std::string &in_message)
{ {
_eqp_mt
std::string category_string; std::string category_string;
if (log_category > 0 && Logs::LogCategoryName[log_category]) if (log_category > 0 && Logs::LogCategoryName[log_category])
category_string = StringFormat("[%s] ", Logs::LogCategoryName[log_category]); category_string = StringFormat("[%s] ", Logs::LogCategoryName[log_category]);
@ -130,6 +133,7 @@ std::string EQEmuLogSys::FormatOutMessageString(uint16 log_category, const std::
void EQEmuLogSys::ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message) void EQEmuLogSys::ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message)
{ {
_eqp_mt
/* Check if category enabled for process */ /* Check if category enabled for process */
if (log_settings[log_category].log_to_gmsay == 0) if (log_settings[log_category].log_to_gmsay == 0)
return; return;
@ -149,6 +153,7 @@ void EQEmuLogSys::ProcessGMSay(uint16 debug_level, uint16 log_category, const st
void EQEmuLogSys::ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message) void EQEmuLogSys::ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message)
{ {
_eqp_mt
if (log_category == Logs::Crash) { if (log_category == Logs::Crash) {
char time_stamp[80]; char time_stamp[80];
EQEmuLogSys::SetCurrentTimeStamp(time_stamp); EQEmuLogSys::SetCurrentTimeStamp(time_stamp);
@ -175,6 +180,7 @@ void EQEmuLogSys::ProcessLogWrite(uint16 debug_level, uint16 log_category, const
} }
uint16 EQEmuLogSys::GetWindowsConsoleColorFromCategory(uint16 log_category) { uint16 EQEmuLogSys::GetWindowsConsoleColorFromCategory(uint16 log_category) {
_eqp_mt
switch (log_category) { switch (log_category) {
case Logs::Status: case Logs::Status:
case Logs::Normal: case Logs::Normal:
@ -198,6 +204,7 @@ uint16 EQEmuLogSys::GetWindowsConsoleColorFromCategory(uint16 log_category) {
} }
std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category) { std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category) {
_eqp_mt
switch (log_category) { switch (log_category) {
case Logs::Status: case Logs::Status:
case Logs::Normal: case Logs::Normal:
@ -221,6 +228,7 @@ std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category) {
} }
uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category) { uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category) {
_eqp_mt
switch (log_category) { switch (log_category) {
case Logs::Status: case Logs::Status:
case Logs::Normal: case Logs::Normal:
@ -245,6 +253,7 @@ uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category) {
void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message) void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message)
{ {
_eqp_mt
/* Check if category enabled for process */ /* Check if category enabled for process */
if (log_settings[log_category].log_to_console == 0) if (log_settings[log_category].log_to_console == 0)
return; return;
@ -272,6 +281,7 @@ void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category,
void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...) void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...)
{ {
_eqp_mt
const bool log_to_console = log_settings[log_category].log_to_console > 0; const bool log_to_console = log_settings[log_category].log_to_console > 0;
const bool log_to_file = log_settings[log_category].log_to_file > 0; const bool log_to_file = log_settings[log_category].log_to_file > 0;
const bool log_to_gmsay = log_settings[log_category].log_to_gmsay > 0; const bool log_to_gmsay = log_settings[log_category].log_to_gmsay > 0;
@ -293,6 +303,7 @@ void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::st
void EQEmuLogSys::SetCurrentTimeStamp(char* time_stamp) void EQEmuLogSys::SetCurrentTimeStamp(char* time_stamp)
{ {
_eqp_mt
time_t raw_time; time_t raw_time;
struct tm * time_info; struct tm * time_info;
time(&raw_time); time(&raw_time);
@ -302,6 +313,7 @@ void EQEmuLogSys::SetCurrentTimeStamp(char* time_stamp)
void EQEmuLogSys::MakeDirectory(const std::string &directory_name) void EQEmuLogSys::MakeDirectory(const std::string &directory_name)
{ {
_eqp_mt
#ifdef _WINDOWS #ifdef _WINDOWS
struct _stat st; struct _stat st;
if (_stat(directory_name.c_str(), &st) == 0) // exists if (_stat(directory_name.c_str(), &st) == 0) // exists
@ -317,6 +329,7 @@ void EQEmuLogSys::MakeDirectory(const std::string &directory_name)
void EQEmuLogSys::CloseFileLogs() void EQEmuLogSys::CloseFileLogs()
{ {
_eqp_mt
if (process_log.is_open()) { if (process_log.is_open()) {
process_log.close(); process_log.close();
} }
@ -324,6 +337,7 @@ void EQEmuLogSys::CloseFileLogs()
void EQEmuLogSys::StartFileLogs(const std::string &log_name) void EQEmuLogSys::StartFileLogs(const std::string &log_name)
{ {
_eqp_mt
EQEmuLogSys::CloseFileLogs(); EQEmuLogSys::CloseFileLogs();
/* When loading settings, we must have been given a reason in category based logging to output to a file in order to even create or open one... */ /* When loading settings, we must have been given a reason in category based logging to output to a file in order to even create or open one... */

View File

@ -48,12 +48,14 @@ namespace Logs {
Combat, Combat,
Commands, Commands,
Crash, Crash,
Database,
Debug, Debug,
Doors, Doors,
Error, Error,
Guilds, Guilds,
Inventory, Inventory,
Launcher, Launcher,
LoginServer,
Netcode, Netcode,
Normal, Normal,
Object, Object,
@ -92,12 +94,14 @@ namespace Logs {
"Combat", "Combat",
"Commands", "Commands",
"Crash", "Crash",
"Database",
"Debug", "Debug",
"Doors", "Doors",
"Error", "Error",
"Guilds", "Guilds",
"Inventory", "Inventory",
"Launcher", "Launcher",
"LoginServer",
"Netcode", "Netcode",
"Normal", "Normal",
"Object", "Object",
@ -118,10 +122,10 @@ namespace Logs {
"WebInterface Server", "WebInterface Server",
"World Server", "World Server",
"Zone Server", "Zone Server",
"MySQL Error", "MySQLError",
"MySQL Query", "MySQLQuery",
"Mercenaries", "Mercenaries",
"Quest Debug" "QuestDebug"
}; };
} }

View File

@ -43,7 +43,7 @@ void TimeoutManager::CheckTimeouts() {
Timeoutable *it = *cur; Timeoutable *it = *cur;
if(it->next_check.Check()) { if(it->next_check.Check()) {
#ifdef TIMEOUT_DEBUG #ifdef TIMEOUT_DEBUG
Log.Out(Logs::General, Logs::None,, "Checking timeout on 0x%x\n", it); Log.Out(Logs::General, Logs::None, "Checking timeout on 0x%x\n", it);
#endif #endif
it->CheckTimeout(); it->CheckTimeout();
} }
@ -58,13 +58,13 @@ void TimeoutManager::AddMember(Timeoutable *who) {
DeleteMember(who); //just in case... prolly not needed. DeleteMember(who); //just in case... prolly not needed.
members.push_back(who); members.push_back(who);
#ifdef TIMEOUT_DEBUG #ifdef TIMEOUT_DEBUG
Log.Out(Logs::General, Logs::None,, "Adding timeoutable 0x%x\n", who); Log.Out(Logs::General, Logs::None, "Adding timeoutable 0x%x\n", who);
#endif #endif
} }
void TimeoutManager::DeleteMember(Timeoutable *who) { void TimeoutManager::DeleteMember(Timeoutable *who) {
#ifdef TIMEOUT_DEBUG #ifdef TIMEOUT_DEBUG
Log.Out(Logs::General, Logs::None,, "Removing timeoutable 0x%x\n", who); Log.Out(Logs::General, Logs::None, "Removing timeoutable 0x%x\n", who);
#endif #endif
std::vector<Timeoutable *>::iterator cur,end; std::vector<Timeoutable *>::iterator cur,end;
cur = members.begin(); cur = members.begin();

View File

@ -15,7 +15,7 @@ ADD_EXECUTABLE(eqlaunch ${eqlaunch_sources} ${eqlaunch_headers})
INSTALL(TARGETS eqlaunch RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) INSTALL(TARGETS eqlaunch RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
TARGET_LINK_LIBRARIES(eqlaunch common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(eqlaunch common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(eqlaunch PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") SET_TARGET_PROPERTIES(eqlaunch PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")

View File

@ -67,7 +67,7 @@ void EQP::CPU::ST::Profiler::Clear() {
current_ = root_; current_ = root_;
} }
void EQP::CPU::ST::Profiler::Dump(std::ostream &stream) { void EQP::CPU::ST::Profiler::Dump(std::ostream &stream, int num) {
uint64_t total = 0; uint64_t total = 0;
std::vector<ProfilerNodeDump> sorted_vec; std::vector<ProfilerNodeDump> sorted_vec;
sorted_vec.reserve(root_->GetNodes().size() + 1); sorted_vec.reserve(root_->GetNodes().size() + 1);
@ -77,14 +77,21 @@ void EQP::CPU::ST::Profiler::Dump(std::ostream &stream) {
n.name = iter.first; n.name = iter.first;
n.node = iter.second; n.node = iter.second;
sorted_vec.push_back(n); sorted_vec.push_back(n);
total += iter.second->GetTime(); total += iter.second->GetTime();
} }
std::sort(sorted_vec.begin(), sorted_vec.end(), std::sort(sorted_vec.begin(), sorted_vec.end(),
[](const ProfilerNodeDump& a, const ProfilerNodeDump& b) { return a.node->GetTime() > b.node->GetTime(); }); [](const ProfilerNodeDump& a, const ProfilerNodeDump& b) { return a.node->GetTime() > b.node->GetTime(); });
int i = 0;
for(auto &iter : sorted_vec) { for(auto &iter : sorted_vec) {
iter.node->Dump(stream, iter.name, total, 0); if(num > 0 && i >= num) {
break;
}
iter.node->Dump(stream, iter.name, total, 0, num);
++i;
} }
} }
@ -164,7 +171,7 @@ void EQP::CPU::MT::Profiler::Clear() {
imp_->lock_.unlock(); imp_->lock_.unlock();
} }
void EQP::CPU::MT::Profiler::Dump(std::ostream &stream) { void EQP::CPU::MT::Profiler::Dump(std::ostream &stream, int num) {
imp_->lock_.lock(); imp_->lock_.lock();
for(auto &iter : imp_->nodes_) { for(auto &iter : imp_->nodes_) {
stream << "Thread: " << iter.first << std::endl; stream << "Thread: " << iter.first << std::endl;
@ -177,14 +184,20 @@ void EQP::CPU::MT::Profiler::Dump(std::ostream &stream) {
n.name = t_iter.first; n.name = t_iter.first;
n.node = t_iter.second; n.node = t_iter.second;
sorted_vec.push_back(n); sorted_vec.push_back(n);
total += t_iter.second->GetTime(); total += t_iter.second->GetTime();
} }
std::sort(sorted_vec.begin(), sorted_vec.end(), std::sort(sorted_vec.begin(), sorted_vec.end(),
[](const ProfilerNodeDump& a, const ProfilerNodeDump& b) { return a.node->GetTime() > b.node->GetTime(); }); [](const ProfilerNodeDump& a, const ProfilerNodeDump& b) { return a.node->GetTime() > b.node->GetTime(); });
int i = 0;
for(auto &t_iter : sorted_vec) { for(auto &t_iter : sorted_vec) {
t_iter.node->Dump(stream, t_iter.name, total, 1); if(num > 0 && i >= num) {
break;
}
t_iter.node->Dump(stream, t_iter.name, total, 1, num);
++i;
} }
stream << std::endl; stream << std::endl;

View File

@ -29,7 +29,7 @@ namespace EQP
void EventStarted(const char *func, const char *name); void EventStarted(const char *func, const char *name);
void EventFinished(uint64_t time); void EventFinished(uint64_t time);
void Clear(); void Clear();
void Dump(std::ostream &stream); void Dump(std::ostream &stream, int num = 0);
private: private:
Node *root_; Node *root_;
Node *current_; Node *current_;
@ -57,7 +57,7 @@ namespace EQP
void EventStarted(const char *func, const char *name); void EventStarted(const char *func, const char *name);
void EventFinished(uint64_t time); void EventFinished(uint64_t time);
void Clear(); void Clear();
void Dump(std::ostream &stream); void Dump(std::ostream &stream, int num = 0);
private: private:
struct impl; struct impl;
impl *imp_; impl *imp_;

View File

@ -15,7 +15,7 @@ EQP::CPU::ProfilerNode::~ProfilerNode() {
} }
} }
void EQP::CPU::ProfilerNode::Dump(std::ostream &stream, const std::string &func, uint64_t total_time, int node_level) { 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) { if(node_level >= 1) {
stream << std::setw(node_level * 2) << " "; stream << std::setw(node_level * 2) << " ";
@ -48,7 +48,12 @@ void EQP::CPU::ProfilerNode::Dump(std::ostream &stream, const std::string &func,
std::sort(sorted_vec.begin(), sorted_vec.end(), std::sort(sorted_vec.begin(), sorted_vec.end(),
[](const ProfilerNodeDump& a, const ProfilerNodeDump& b) { return a.node->GetTime() > b.node->GetTime(); }); [](const ProfilerNodeDump& a, const ProfilerNodeDump& b) { return a.node->GetTime() > b.node->GetTime(); });
int i = 0;
for(auto &iter : sorted_vec) { for(auto &iter : sorted_vec) {
iter.node->Dump(stream, iter.name, total_time, node_level + 1); if(num > 0 && i >= num) {
break;
}
iter.node->Dump(stream, iter.name, total_time, node_level + 1, num);
++i;
} }
} }

View File

@ -25,7 +25,7 @@ namespace EQP
inline std::unordered_map<std::string, ProfilerNode*>& GetNodes() { return nodes_; } inline std::unordered_map<std::string, ProfilerNode*>& GetNodes() { return nodes_; }
void Dump(std::ostream &stream, const std::string &func, uint64_t total_time, int node_level); void Dump(std::ostream &stream, const std::string &func, uint64_t total_time, int node_level, int num);
private: private:
uint64_t count_; uint64_t count_;
uint64_t time_; uint64_t time_;

View File

@ -20,13 +20,13 @@
#include "login_server.h" #include "login_server.h"
#include "login_structures.h" #include "login_structures.h"
#include "../common/misc_functions.h" #include "../common/misc_functions.h"
#include "../common/eqemu_logsys.h"
extern ErrorLog *server_log;
extern LoginServer server; extern LoginServer server;
Client::Client(std::shared_ptr<EQStream> c, LSClientVersion v) Client::Client(std::shared_ptr<EQStream> c, LSClientVersion v)
{ {
_eqp _eqp_mt
connection = c; connection = c;
version = v; version = v;
status = cs_not_sent_session_ready; status = cs_not_sent_session_ready;
@ -37,13 +37,13 @@ Client::Client(std::shared_ptr<EQStream> c, LSClientVersion v)
bool Client::Process() bool Client::Process()
{ {
_eqp _eqp_mt
EQApplicationPacket *app = connection->PopPacket(); EQApplicationPacket *app = connection->PopPacket();
while(app) while(app)
{ {
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_network, "Application packet received from client (size %u)", app->Size()); Log.Out(Logs::General, Logs::Netcode, "Application packet received from client (size %u)", app->Size());
} }
if(server.options.IsDumpInPacketsOn()) if(server.options.IsDumpInPacketsOn())
@ -57,7 +57,7 @@ bool Client::Process()
{ {
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_network, "Session ready received from client."); Log.Out(Logs::General, Logs::Netcode, "Session ready received from client.");
} }
Handle_SessionReady((const char*)app->pBuffer, app->Size()); Handle_SessionReady((const char*)app->pBuffer, app->Size());
break; break;
@ -66,13 +66,13 @@ bool Client::Process()
{ {
if(app->Size() < 20) if(app->Size() < 20)
{ {
server_log->Log(log_network_error, "Login received but it is too small, discarding."); Log.Out(Logs::General, Logs::Netcode, "Login received but it is too small, discarding.");
break; break;
} }
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_network, "Login received from client."); Log.Out(Logs::General, Logs::Netcode, "Login received from client.");
} }
Handle_Login((const char*)app->pBuffer, app->Size()); Handle_Login((const char*)app->pBuffer, app->Size());
@ -82,7 +82,7 @@ bool Client::Process()
{ {
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_network, "Server list request received from client."); Log.Out(Logs::General, Logs::Netcode, "Server list request received from client.");
} }
SendServerListPacket(); SendServerListPacket();
@ -92,7 +92,7 @@ bool Client::Process()
{ {
if(app->Size() < sizeof(PlayEverquestRequest_Struct)) if(app->Size() < sizeof(PlayEverquestRequest_Struct))
{ {
server_log->Log(log_network_error, "Play received but it is too small, discarding."); Log.Out(Logs::General, Logs::Netcode, "Play received but it is too small, discarding.");
break; break;
} }
@ -103,7 +103,7 @@ bool Client::Process()
{ {
char dump[64]; char dump[64];
app->build_header_dump(dump); app->build_header_dump(dump);
server_log->Log(log_network_error, "Recieved unhandled application packet from the client: %s.", dump); Log.Out(Logs::General, Logs::Netcode, "Recieved unhandled application packet from the client: %s.", dump);
} }
} }
@ -116,23 +116,23 @@ bool Client::Process()
void Client::Handle_SessionReady(const char* data, unsigned int size) void Client::Handle_SessionReady(const char* data, unsigned int size)
{ {
_eqp _eqp_mt
if(status != cs_not_sent_session_ready) if(status != cs_not_sent_session_ready)
{ {
server_log->Log(log_network_error, "Session ready received again after already being received."); Log.Out(Logs::General, Logs::Netcode, "Session ready received again after already being received.");
return; return;
} }
if(size < sizeof(unsigned int)) if(size < sizeof(unsigned int))
{ {
server_log->Log(log_network_error, "Session ready was too small."); Log.Out(Logs::General, Logs::Netcode, "Session ready was too small.");
return; return;
} }
unsigned int mode = *((unsigned int*)data); unsigned int mode = *((unsigned int*)data);
if(mode == (unsigned int)lm_from_world) if(mode == (unsigned int)lm_from_world)
{ {
server_log->Log(log_network, "Session ready indicated logged in from world(unsupported feature), disconnecting."); Log.Out(Logs::General, Logs::Netcode, "Session ready indicated logged in from world(unsupported feature), disconnecting.");
connection->Close(); connection->Close();
return; return;
} }
@ -178,16 +178,16 @@ void Client::Handle_SessionReady(const char* data, unsigned int size)
void Client::Handle_Login(const char* data, unsigned int size) void Client::Handle_Login(const char* data, unsigned int size)
{ {
_eqp _eqp_mt
if(status != cs_waiting_for_login) if(status != cs_waiting_for_login)
{ {
server_log->Log(log_network_error, "Login received after already having logged in."); Log.Out(Logs::General, Logs::Netcode, "Login received after already having logged in.");
return; return;
} }
if((size - 12) % 8 != 0) if((size - 12) % 8 != 0)
{ {
server_log->Log(log_network_error, "Login received packet of size: %u, this would cause a block corruption, discarding.", size); Log.Out(Logs::General, Logs::Netcode, "Login received packet of size: %u, this would cause a block corruption, discarding.", size);
return; return;
} }
@ -208,8 +208,8 @@ void Client::Handle_Login(const char* data, unsigned int size)
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_client, "User: %s", e_user.c_str()); Log.Out(Logs::General, Logs::LoginServer, "User: %s", e_user.c_str());
server_log->Log(log_client, "Hash: %s", e_hash.c_str()); Log.Out(Logs::General, Logs::LoginServer, "Hash: %s", e_hash.c_str());
} }
server.eq_crypto->DeleteHeap(e_buffer); server.eq_crypto->DeleteHeap(e_buffer);
@ -222,8 +222,8 @@ void Client::Handle_Login(const char* data, unsigned int size)
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_client, "User: %s", e_user.c_str()); Log.Out(Logs::General, Logs::LoginServer, "User: %s", e_user.c_str());
server_log->Log(log_client, "Hash: %s", e_hash.c_str()); Log.Out(Logs::General, Logs::LoginServer, "Hash: %s", e_hash.c_str());
} }
_HeapDeleteCharBuffer(e_buffer); _HeapDeleteCharBuffer(e_buffer);
@ -232,7 +232,7 @@ void Client::Handle_Login(const char* data, unsigned int size)
bool result; bool result;
if(server.db->GetLoginDataFromAccountName(e_user, d_pass_hash, d_account_id) == false) if(server.db->GetLoginDataFromAccountName(e_user, d_pass_hash, d_account_id) == false)
{ {
server_log->Log(log_client_error, "Error logging in, user %s does not exist in the database.", e_user.c_str()); Log.Out(Logs::General, Logs::Error, "Error logging in, user %s does not exist in the database.", e_user.c_str());
result = false; result = false;
} }
else else
@ -333,10 +333,10 @@ void Client::Handle_Login(const char* data, unsigned int size)
void Client::Handle_Play(const char* data) void Client::Handle_Play(const char* data)
{ {
_eqp _eqp_mt
if(status != cs_logged_in) if(status != cs_logged_in)
{ {
server_log->Log(log_client_error, "Client sent a play request when they either were not logged in, discarding."); Log.Out(Logs::General, Logs::Error, "Client sent a play request when they either were not logged in, discarding.");
return; return;
} }
@ -346,7 +346,7 @@ void Client::Handle_Play(const char* data)
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_network, "Play received from client, server number %u sequence %u.", server_id_in, sequence_in); Log.Out(Logs::General, Logs::Netcode, "Play received from client, server number %u sequence %u.", server_id_in, sequence_in);
} }
this->play_server_id = (unsigned int)play->ServerNumber; this->play_server_id = (unsigned int)play->ServerNumber;
@ -357,7 +357,7 @@ void Client::Handle_Play(const char* data)
void Client::SendServerListPacket() void Client::SendServerListPacket()
{ {
_eqp _eqp_mt
EQApplicationPacket *outapp = server.SM->CreateServerListPacket(this); EQApplicationPacket *outapp = server.SM->CreateServerListPacket(this);
if(server.options.IsDumpOutPacketsOn()) if(server.options.IsDumpOutPacketsOn())
@ -371,11 +371,11 @@ void Client::SendServerListPacket()
void Client::SendPlayResponse(EQApplicationPacket *outapp) void Client::SendPlayResponse(EQApplicationPacket *outapp)
{ {
_eqp _eqp_mt
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_network_trace, "Sending play response for %s.", GetAccountName().c_str()); Log.Out(Logs::Detail, Logs::Netcode, "Sending play response for %s.", GetAccountName().c_str());
server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size); //server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size);
} }
connection->QueuePacket(outapp); connection->QueuePacket(outapp);
status = cs_logged_in; status = cs_logged_in;
@ -383,7 +383,7 @@ void Client::SendPlayResponse(EQApplicationPacket *outapp)
void Client::GenerateKey() void Client::GenerateKey()
{ {
_eqp _eqp_mt
key.clear(); key.clear();
int count = 0; int count = 0;
while(count < 10) while(count < 10)

View File

@ -18,31 +18,31 @@
#include "client_manager.h" #include "client_manager.h"
#include "error_log.h" #include "error_log.h"
#include "login_server.h" #include "login_server.h"
#include "../common/eqemu_logsys.h"
extern ErrorLog *server_log;
extern LoginServer server; extern LoginServer server;
extern bool run_server; extern bool run_server;
ClientManager::ClientManager() ClientManager::ClientManager()
{ {
_eqp _eqp_mt
int titanium_port = atoi(server.config->GetVariable("Titanium", "port").c_str()); int titanium_port = atoi(server.config->GetVariable("Titanium", "port").c_str());
titanium_stream = new EQStreamFactory(LoginStream, titanium_port); titanium_stream = new EQStreamFactory(LoginStream, titanium_port);
titanium_ops = new RegularOpcodeManager; titanium_ops = new RegularOpcodeManager;
if(!titanium_ops->LoadOpcodes(server.config->GetVariable("Titanium", "opcodes").c_str())) if(!titanium_ops->LoadOpcodes(server.config->GetVariable("Titanium", "opcodes").c_str()))
{ {
server_log->Log(log_error, "ClientManager fatal error: couldn't load opcodes for Titanium file %s.", Log.Out(Logs::Detail, Logs::Error, "ClientManager fatal error: couldn't load opcodes for Titanium file %s.",
server.config->GetVariable("Titanium", "opcodes").c_str()); server.config->GetVariable("Titanium", "opcodes").c_str());
run_server = false; run_server = false;
} }
if(titanium_stream->Open()) if(titanium_stream->Open())
{ {
server_log->Log(log_network, "ClientManager listening on Titanium stream."); Log.Out(Logs::General, Logs::Netcode, "ClientManager listening on Titanium stream.");
} }
else else
{ {
server_log->Log(log_error, "ClientManager fatal error: couldn't open Titanium stream."); Log.Out(Logs::Detail, Logs::Error, "ClientManager fatal error: couldn't open Titanium stream.");
run_server = false; run_server = false;
} }
@ -51,25 +51,25 @@ ClientManager::ClientManager()
sod_ops = new RegularOpcodeManager; sod_ops = new RegularOpcodeManager;
if(!sod_ops->LoadOpcodes(server.config->GetVariable("SoD", "opcodes").c_str())) if(!sod_ops->LoadOpcodes(server.config->GetVariable("SoD", "opcodes").c_str()))
{ {
server_log->Log(log_error, "ClientManager fatal error: couldn't load opcodes for SoD file %s.", Log.Out(Logs::Detail, Logs::Error, "ClientManager fatal error: couldn't load opcodes for SoD file %s.",
server.config->GetVariable("SoD", "opcodes").c_str()); server.config->GetVariable("SoD", "opcodes").c_str());
run_server = false; run_server = false;
} }
if(sod_stream->Open()) if(sod_stream->Open())
{ {
server_log->Log(log_network, "ClientManager listening on SoD stream."); Log.Out(Logs::General, Logs::Netcode, "ClientManager listening on SoD stream.");
} }
else else
{ {
server_log->Log(log_error, "ClientManager fatal error: couldn't open SoD stream."); Log.Out(Logs::Detail, Logs::Error, "ClientManager fatal error: couldn't open SoD stream.");
run_server = false; run_server = false;
} }
} }
ClientManager::~ClientManager() ClientManager::~ClientManager()
{ {
_eqp _eqp_mt
if(titanium_stream) if(titanium_stream)
{ {
titanium_stream->Close(); titanium_stream->Close();
@ -95,14 +95,14 @@ ClientManager::~ClientManager()
void ClientManager::Process() void ClientManager::Process()
{ {
_eqp _eqp_mt
ProcessDisconnect(); ProcessDisconnect();
std::shared_ptr<EQStream> cur = titanium_stream->Pop(); std::shared_ptr<EQStream> cur = titanium_stream->Pop();
while(cur) while(cur)
{ {
struct in_addr in; struct in_addr in;
in.s_addr = cur->GetRemoteIP(); in.s_addr = cur->GetRemoteIP();
server_log->Log(log_network, "New Titanium client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort())); Log.Out(Logs::General, Logs::Netcode, "New Titanium client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort()));
cur->SetOpcodeManager(&titanium_ops); cur->SetOpcodeManager(&titanium_ops);
Client *c = new Client(cur, cv_titanium); Client *c = new Client(cur, cv_titanium);
@ -115,7 +115,7 @@ void ClientManager::Process()
{ {
struct in_addr in; struct in_addr in;
in.s_addr = cur->GetRemoteIP(); in.s_addr = cur->GetRemoteIP();
server_log->Log(log_network, "New SoD client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort())); Log.Out(Logs::General, Logs::Netcode, "New SoD client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort()));
cur->SetOpcodeManager(&sod_ops); cur->SetOpcodeManager(&sod_ops);
Client *c = new Client(cur, cv_sod); Client *c = new Client(cur, cv_sod);
@ -128,7 +128,7 @@ void ClientManager::Process()
{ {
if((*iter)->Process() == false) if((*iter)->Process() == false)
{ {
server_log->Log(log_client, "Client had a fatal error and had to be removed from the login."); Log.Out(Logs::General, Logs::LoginServer, "Client had a fatal error and had to be removed from the login.");
delete (*iter); delete (*iter);
iter = clients.erase(iter); iter = clients.erase(iter);
} }
@ -141,14 +141,14 @@ void ClientManager::Process()
void ClientManager::ProcessDisconnect() void ClientManager::ProcessDisconnect()
{ {
_eqp _eqp_mt
list<Client*>::iterator iter = clients.begin(); list<Client*>::iterator iter = clients.begin();
while(iter != clients.end()) while(iter != clients.end())
{ {
std::shared_ptr<EQStream> c = (*iter)->GetConnection(); std::shared_ptr<EQStream> c = (*iter)->GetConnection();
if(c->CheckClosed()) if(c->CheckClosed())
{ {
server_log->Log(log_network, "Client disconnected from the server, removing client."); Log.Out(Logs::General, Logs::Netcode, "Client disconnected from the server, removing client.");
delete (*iter); delete (*iter);
iter = clients.erase(iter); iter = clients.erase(iter);
} }
@ -161,7 +161,7 @@ void ClientManager::ProcessDisconnect()
void ClientManager::UpdateServerList() void ClientManager::UpdateServerList()
{ {
_eqp _eqp_mt
list<Client*>::iterator iter = clients.begin(); list<Client*>::iterator iter = clients.begin();
while(iter != clients.end()) while(iter != clients.end())
{ {
@ -172,13 +172,13 @@ void ClientManager::UpdateServerList()
void ClientManager::RemoveExistingClient(unsigned int account_id) void ClientManager::RemoveExistingClient(unsigned int account_id)
{ {
_eqp _eqp_mt
list<Client*>::iterator iter = clients.begin(); list<Client*>::iterator iter = clients.begin();
while(iter != clients.end()) while(iter != clients.end())
{ {
if((*iter)->GetAccountID() == account_id) if((*iter)->GetAccountID() == account_id)
{ {
server_log->Log(log_network, "Client attempting to log in and existing client already logged in, removing existing client."); Log.Out(Logs::General, Logs::Netcode, "Client attempting to log in and existing client already logged in, removing existing client.");
delete (*iter); delete (*iter);
iter = clients.erase(iter); iter = clients.erase(iter);
} }
@ -191,7 +191,7 @@ void ClientManager::RemoveExistingClient(unsigned int account_id)
Client *ClientManager::GetClient(unsigned int account_id) Client *ClientManager::GetClient(unsigned int account_id)
{ {
_eqp _eqp_mt
Client *cur = nullptr; Client *cur = nullptr;
int count = 0; int count = 0;
list<Client*>::iterator iter = clients.begin(); list<Client*>::iterator iter = clients.begin();
@ -207,7 +207,7 @@ Client *ClientManager::GetClient(unsigned int account_id)
if(count > 1) if(count > 1)
{ {
server_log->Log(log_client_error, "More than one client with a given account_id existed in the client list."); Log.Out(Logs::General, Logs::Error, "More than one client with a given account_id existed in the client list.");
} }
return cur; return cur;
} }

View File

@ -18,8 +18,8 @@
#include "../common/global_define.h" #include "../common/global_define.h"
#include "config.h" #include "config.h"
#include "error_log.h" #include "error_log.h"
#include "../common/eqemu_logsys.h"
extern ErrorLog *server_log;
/** /**
* Retrieves the variable we want from our title or theme * Retrieves the variable we want from our title or theme
* First gets the map from the title * First gets the map from the title
@ -27,7 +27,7 @@ extern ErrorLog *server_log;
*/ */
std::string Config::GetVariable(std::string title, std::string parameter) std::string Config::GetVariable(std::string title, std::string parameter)
{ {
_eqp _eqp_mt
std::map<std::string, std::map<std::string, std::string> >::iterator iter = vars.find(title); std::map<std::string, std::map<std::string, std::string> >::iterator iter = vars.find(title);
if(iter != vars.end()) if(iter != vars.end())
{ {
@ -47,10 +47,10 @@ std::string Config::GetVariable(std::string title, std::string parameter)
*/ */
void Config::Parse(const char *file_name) void Config::Parse(const char *file_name)
{ {
_eqp _eqp_mt
if(file_name == nullptr) if(file_name == nullptr)
{ {
server_log->Log(log_error, "Config::Parse(), file_name passed was null."); Log.Out(Logs::Detail, Logs::Error, "Config::Parse(), file_name passed was null.");
return; return;
} }
@ -73,7 +73,7 @@ void Config::Parse(const char *file_name)
++iter; ++iter;
if(iter == tokens.end()) if(iter == tokens.end())
{ {
server_log->Log(log_error, "Config::Parse(), EOF before title done parsing."); Log.Out(Logs::Detail, Logs::Error, "Config::Parse(), EOF before title done parsing.");
fclose(input); fclose(input);
vars.clear(); vars.clear();
return; return;
@ -106,7 +106,7 @@ void Config::Parse(const char *file_name)
mode++; mode++;
if((*iter).compare("=") != 0) if((*iter).compare("=") != 0)
{ {
server_log->Log(log_error, "Config::Parse(), invalid parse token where = should be."); Log.Out(Logs::Detail, Logs::Error, "Config::Parse(), invalid parse token where = should be.");
fclose(input); fclose(input);
vars.clear(); vars.clear();
return; return;
@ -135,7 +135,7 @@ void Config::Parse(const char *file_name)
} }
else else
{ {
server_log->Log(log_error, "Config::Parse(), file was unable to be opened for parsing."); Log.Out(Logs::Detail, Logs::Error, "Config::Parse(), file was unable to be opened for parsing.");
} }
} }
@ -146,7 +146,7 @@ void Config::Parse(const char *file_name)
*/ */
void Config::Tokenize(FILE *input, std::list<std::string> &tokens) void Config::Tokenize(FILE *input, std::list<std::string> &tokens)
{ {
_eqp _eqp_mt
char c = fgetc(input); char c = fgetc(input);
std::string lexeme; std::string lexeme;

View File

@ -22,15 +22,15 @@
#include "database_mysql.h" #include "database_mysql.h"
#include "error_log.h" #include "error_log.h"
#include "login_server.h" #include "login_server.h"
#include "../common/eqemu_logsys.h"
extern ErrorLog *server_log;
extern LoginServer server; extern LoginServer server;
#pragma comment(lib, "mysqlclient.lib") #pragma comment(lib, "mysqlclient.lib")
DatabaseMySQL::DatabaseMySQL(string user, string pass, string host, string port, string name) DatabaseMySQL::DatabaseMySQL(string user, string pass, string host, string port, string name)
{ {
_eqp _eqp_mt
this->user = user; this->user = user;
this->pass = pass; this->pass = pass;
this->host = host; this->host = host;
@ -44,19 +44,19 @@ DatabaseMySQL::DatabaseMySQL(string user, string pass, string host, string port,
if(!mysql_real_connect(db, host.c_str(), user.c_str(), pass.c_str(), name.c_str(), atoi(port.c_str()), nullptr, 0)) if(!mysql_real_connect(db, host.c_str(), user.c_str(), pass.c_str(), name.c_str(), atoi(port.c_str()), nullptr, 0))
{ {
mysql_close(db); mysql_close(db);
server_log->Log(log_database, "Failed to connect to MySQL database. Error: %s", mysql_error(db)); Log.Out(Logs::General, Logs::Database,"Failed to connect to MySQL database. Error: %s", mysql_error(db));
exit(1); exit(1);
} }
} }
else else
{ {
server_log->Log(log_database, "Failed to create db object in MySQL database."); Log.Out(Logs::General, Logs::Database,"Failed to create db object in MySQL database.");
} }
} }
DatabaseMySQL::~DatabaseMySQL() DatabaseMySQL::~DatabaseMySQL()
{ {
_eqp _eqp_mt
if(db) if(db)
{ {
mysql_close(db); mysql_close(db);
@ -65,7 +65,7 @@ DatabaseMySQL::~DatabaseMySQL()
bool DatabaseMySQL::GetLoginDataFromAccountName(string name, string &password, unsigned int &id) bool DatabaseMySQL::GetLoginDataFromAccountName(string name, string &password, unsigned int &id)
{ {
_eqp _eqp_mt
if(!db) if(!db)
{ {
return false; return false;
@ -80,7 +80,7 @@ bool DatabaseMySQL::GetLoginDataFromAccountName(string name, string &password, u
if(mysql_query(db, query.str().c_str()) != 0) if(mysql_query(db, query.str().c_str()) != 0)
{ {
server_log->Log(log_database, "Mysql query failed: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query failed: %s", query.str().c_str());
return false; return false;
} }
@ -97,14 +97,14 @@ bool DatabaseMySQL::GetLoginDataFromAccountName(string name, string &password, u
} }
} }
server_log->Log(log_database, "Mysql query returned no result: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query returned no result: %s", query.str().c_str());
return false; return false;
} }
bool DatabaseMySQL::GetWorldRegistration(string long_name, string short_name, unsigned int &id, string &desc, unsigned int &list_id, bool DatabaseMySQL::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) unsigned int &trusted, string &list_desc, string &account, string &password)
{ {
_eqp _eqp_mt
if(!db) if(!db)
{ {
return false; return false;
@ -126,7 +126,7 @@ bool DatabaseMySQL::GetWorldRegistration(string long_name, string short_name, un
if(mysql_query(db, query.str().c_str()) != 0) if(mysql_query(db, query.str().c_str()) != 0)
{ {
server_log->Log(log_database, "Mysql query failed: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query failed: %s", query.str().c_str());
return false; return false;
} }
@ -151,7 +151,7 @@ bool DatabaseMySQL::GetWorldRegistration(string long_name, string short_name, un
if(mysql_query(db, query.str().c_str()) != 0) if(mysql_query(db, query.str().c_str()) != 0)
{ {
server_log->Log(log_database, "Mysql query failed: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query failed: %s", query.str().c_str());
return false; return false;
} }
@ -167,20 +167,20 @@ bool DatabaseMySQL::GetWorldRegistration(string long_name, string short_name, un
} }
} }
server_log->Log(log_database, "Mysql query returned no result: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query returned no result: %s", query.str().c_str());
return false; return false;
} }
return true; return true;
} }
} }
server_log->Log(log_database, "Mysql query returned no result: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query returned no result: %s", query.str().c_str());
return false; return false;
} }
void DatabaseMySQL::UpdateLSAccountData(unsigned int id, string ip_address) void DatabaseMySQL::UpdateLSAccountData(unsigned int id, string ip_address)
{ {
_eqp _eqp_mt
if(!db) if(!db)
{ {
return; return;
@ -194,13 +194,13 @@ void DatabaseMySQL::UpdateLSAccountData(unsigned int id, string ip_address)
if(mysql_query(db, query.str().c_str()) != 0) if(mysql_query(db, query.str().c_str()) != 0)
{ {
server_log->Log(log_database, "Mysql query failed: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query failed: %s", query.str().c_str());
} }
} }
void DatabaseMySQL::UpdateLSAccountInfo(unsigned int id, string name, string password, string email) void DatabaseMySQL::UpdateLSAccountInfo(unsigned int id, string name, string password, string email)
{ {
_eqp _eqp_mt
if(!db) if(!db)
{ {
return; return;
@ -214,13 +214,13 @@ void DatabaseMySQL::UpdateLSAccountInfo(unsigned int id, string name, string pas
if(mysql_query(db, query.str().c_str()) != 0) if(mysql_query(db, query.str().c_str()) != 0)
{ {
server_log->Log(log_database, "Mysql query failed: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query failed: %s", query.str().c_str());
} }
} }
void DatabaseMySQL::UpdateWorldRegistration(unsigned int id, string long_name, string ip_address) void DatabaseMySQL::UpdateWorldRegistration(unsigned int id, string long_name, string ip_address)
{ {
_eqp _eqp_mt
if(!db) if(!db)
{ {
return; return;
@ -240,13 +240,13 @@ void DatabaseMySQL::UpdateWorldRegistration(unsigned int id, string long_name, s
if(mysql_query(db, query.str().c_str()) != 0) if(mysql_query(db, query.str().c_str()) != 0)
{ {
server_log->Log(log_database, "Mysql query failed: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query failed: %s", query.str().c_str());
} }
} }
bool DatabaseMySQL::CreateWorldRegistration(string long_name, string short_name, unsigned int &id) bool DatabaseMySQL::CreateWorldRegistration(string long_name, string short_name, unsigned int &id)
{ {
_eqp _eqp_mt
if(!db) if(!db)
{ {
return false; return false;
@ -266,7 +266,7 @@ bool DatabaseMySQL::CreateWorldRegistration(string long_name, string short_name,
if(mysql_query(db, query.str().c_str()) != 0) if(mysql_query(db, query.str().c_str()) != 0)
{ {
server_log->Log(log_database, "Mysql query failed: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query failed: %s", query.str().c_str());
return false; return false;
} }
@ -285,13 +285,13 @@ bool DatabaseMySQL::CreateWorldRegistration(string long_name, string short_name,
if(mysql_query(db, query.str().c_str()) != 0) if(mysql_query(db, query.str().c_str()) != 0)
{ {
server_log->Log(log_database, "Mysql query failed: %s", query.str().c_str()); Log.Out(Logs::General, Logs::Database,"Mysql query failed: %s", query.str().c_str());
return false; return false;
} }
return true; return true;
} }
} }
server_log->Log(log_database, "World registration did not exist in the database for %s %s", long_name.c_str(), short_name.c_str()); Log.Out(Logs::General, Logs::Database,"World registration did not exist in the database for %s %s", long_name.c_str(), short_name.c_str());
return false; return false;
} }

View File

@ -22,25 +22,25 @@
#include "database_postgresql.h" #include "database_postgresql.h"
#include "error_log.h" #include "error_log.h"
#include "login_server.h" #include "login_server.h"
#include "../common/eqemu_logsys.h"
extern ErrorLog *server_log;
extern LoginServer server; extern LoginServer server;
#pragma comment(lib, "libpq.lib") #pragma comment(lib, "libpq.lib")
DatabasePostgreSQL::DatabasePostgreSQL(string user, string pass, string host, string port, string name) DatabasePostgreSQL::DatabasePostgreSQL(string user, string pass, string host, string port, string name)
{ {
_eqp _eqp_mt_mt
db = nullptr; db = nullptr;
db = PQsetdbLogin(host.c_str(), port.c_str(), nullptr, nullptr, name.c_str(), user.c_str(), pass.c_str()); db = PQsetdbLogin(host.c_str(), port.c_str(), nullptr, nullptr, name.c_str(), user.c_str(), pass.c_str());
if(!db) if(!db)
{ {
server_log->Log(log_database, "Failed to connect to PostgreSQL Database."); Log.Out(Logs::General, Logs::Database,"Failed to connect to PostgreSQL Database.");
} }
if(PQstatus(db) != CONNECTION_OK) if(PQstatus(db) != CONNECTION_OK)
{ {
server_log->Log(log_database, "Failed to connect to PostgreSQL Database."); Log.Out(Logs::General, Logs::Database,"Failed to connect to PostgreSQL Database.");
PQfinish(db); PQfinish(db);
db = nullptr; db = nullptr;
} }
@ -48,7 +48,7 @@ DatabasePostgreSQL::DatabasePostgreSQL(string user, string pass, string host, st
DatabasePostgreSQL::~DatabasePostgreSQL() DatabasePostgreSQL::~DatabasePostgreSQL()
{ {
_eqp _eqp_mt_mt
if(db) if(db)
{ {
PQfinish(db); PQfinish(db);
@ -57,7 +57,7 @@ DatabasePostgreSQL::~DatabasePostgreSQL()
bool DatabasePostgreSQL::GetLoginDataFromAccountName(string name, string &password, unsigned int &id) bool DatabasePostgreSQL::GetLoginDataFromAccountName(string name, string &password, unsigned int &id)
{ {
_eqp _eqp_mt_mt
if(!db) if(!db)
{ {
return false; return false;
@ -86,7 +86,7 @@ bool DatabasePostgreSQL::GetLoginDataFromAccountName(string name, string &passwo
char *error = PQresultErrorMessage(res); char *error = PQresultErrorMessage(res);
if(strlen(error) > 0) if(strlen(error) > 0)
{ {
server_log->Log(log_database, "Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error); Log.Out(Logs::General, Logs::Database,"Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error);
PQclear(res); PQclear(res);
return false; 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, 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) unsigned int &trusted, string &list_desc, string &account, string &password)
{ {
_eqp _eqp_mt_mt
if(!db) if(!db)
{ {
return false; return false;
@ -139,7 +139,7 @@ bool DatabasePostgreSQL::GetWorldRegistration(string long_name, string short_nam
char *error = PQresultErrorMessage(res); char *error = PQresultErrorMessage(res);
if(strlen(error) > 0) if(strlen(error) > 0)
{ {
server_log->Log(log_database, "Database error in DatabasePostgreSQL::GetWorldRegistration(): %s", error); Log.Out(Logs::General, Logs::Database,"Database error in DatabasePostgreSQL::GetWorldRegistration(): %s", error);
PQclear(res); PQclear(res);
return false; return false;
} }
@ -164,7 +164,7 @@ bool DatabasePostgreSQL::GetWorldRegistration(string long_name, string short_nam
void DatabasePostgreSQL::UpdateLSAccountData(unsigned int id, string ip_address) void DatabasePostgreSQL::UpdateLSAccountData(unsigned int id, string ip_address)
{ {
_eqp _eqp_mt_mt
if(!db) if(!db)
{ {
return; return;
@ -193,14 +193,14 @@ void DatabasePostgreSQL::UpdateLSAccountData(unsigned int id, string ip_address)
char *error = PQresultErrorMessage(res); char *error = PQresultErrorMessage(res);
if(strlen(error) > 0) if(strlen(error) > 0)
{ {
server_log->Log(log_database, "Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error); Log.Out(Logs::General, Logs::Database,"Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error);
} }
PQclear(res); PQclear(res);
} }
void DatabasePostgreSQL::UpdateWorldRegistration(unsigned int id, string long_name, string ip_address) void DatabasePostgreSQL::UpdateWorldRegistration(unsigned int id, string long_name, string ip_address)
{ {
_eqp _eqp_mt_mt
if(!db) if(!db)
{ {
return; return;
@ -231,7 +231,7 @@ void DatabasePostgreSQL::UpdateWorldRegistration(unsigned int id, string long_na
char *error = PQresultErrorMessage(res); char *error = PQresultErrorMessage(res);
if(strlen(error) > 0) if(strlen(error) > 0)
{ {
server_log->Log(log_database, "Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error); Log.Out(Logs::General, Logs::Database,"Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error);
} }
PQclear(res); PQclear(res);
} }

View File

@ -16,18 +16,17 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/eqemu_logsys.h"
#include "encryption.h" #include "encryption.h"
#include "error_log.h" #include "error_log.h"
#include <string> #include <string>
extern ErrorLog *server_log;
bool Encryption::LoadCrypto(std::string name) bool Encryption::LoadCrypto(std::string name)
{ {
_eqp _eqp_mt
if(!Load(name.c_str())) if(!Load(name.c_str()))
{ {
server_log->Log(log_error, "Failed to load %s from the operating system.", name.c_str()); Log.Out(Logs::Detail, Logs::Error, "Failed to load %s from the operating system.", name.c_str());
return false; return false;
} }
else else
@ -35,21 +34,21 @@ bool Encryption::LoadCrypto(std::string name)
encrypt_func = (DLLFUNC_Encrypt)GetSym("Encrypt"); encrypt_func = (DLLFUNC_Encrypt)GetSym("Encrypt");
if(encrypt_func == NULL) if(encrypt_func == NULL)
{ {
server_log->Log(log_error, "Failed to attach Encrypt."); Log.Out(Logs::Detail, Logs::Error, "Failed to attach Encrypt.");
Unload(); Unload();
return false; return false;
} }
decrypt_func = (DLLFUNC_DecryptUsernamePassword)GetSym("DecryptUsernamePassword"); decrypt_func = (DLLFUNC_DecryptUsernamePassword)GetSym("DecryptUsernamePassword");
if(decrypt_func == NULL) if(decrypt_func == NULL)
{ {
server_log->Log(log_error, "Failed to attach DecryptUsernamePassword."); Log.Out(Logs::Detail, Logs::Error, "Failed to attach DecryptUsernamePassword.");
Unload(); Unload();
return false; return false;
} }
delete_func = (DLLFUNC_HeapDelete)GetSym("_HeapDeleteCharBuffer"); delete_func = (DLLFUNC_HeapDelete)GetSym("_HeapDeleteCharBuffer");
if(delete_func == NULL) if(delete_func == NULL)
{ {
server_log->Log(log_error, "Failed to attach _HeapDeleteCharBuffer."); Log.Out(Logs::Detail, Logs::Error, "Failed to attach _HeapDeleteCharBuffer.");
Unload(); Unload();
return false; return false;
} }
@ -59,7 +58,7 @@ bool Encryption::LoadCrypto(std::string name)
char *Encryption::DecryptUsernamePassword(const char* encrypted_buffer, unsigned int buffer_size, int mode) char *Encryption::DecryptUsernamePassword(const char* encrypted_buffer, unsigned int buffer_size, int mode)
{ {
_eqp _eqp_mt
if(decrypt_func) if(decrypt_func)
{ {
return decrypt_func(encrypted_buffer, buffer_size, mode); return decrypt_func(encrypted_buffer, buffer_size, mode);
@ -69,7 +68,7 @@ char *Encryption::DecryptUsernamePassword(const char* encrypted_buffer, unsigned
char *Encryption::Encrypt(const char* buffer, unsigned int buffer_size, unsigned int &out_size) char *Encryption::Encrypt(const char* buffer, unsigned int buffer_size, unsigned int &out_size)
{ {
_eqp _eqp_mt
if(encrypt_func) if(encrypt_func)
{ {
return encrypt_func(buffer, buffer_size, out_size); return encrypt_func(buffer, buffer_size, out_size);
@ -79,7 +78,7 @@ char *Encryption::Encrypt(const char* buffer, unsigned int buffer_size, unsigned
void Encryption::DeleteHeap(char *buffer) void Encryption::DeleteHeap(char *buffer)
{ {
_eqp _eqp_mt
if(delete_func) if(delete_func)
{ {
delete_func(buffer); delete_func(buffer);
@ -88,7 +87,7 @@ void Encryption::DeleteHeap(char *buffer)
bool Encryption::Load(const char *name) bool Encryption::Load(const char *name)
{ {
_eqp _eqp_mt
SetLastError(0); SetLastError(0);
#ifdef UNICODE #ifdef UNICODE
int name_length = strlen(name); int name_length = strlen(name);
@ -116,7 +115,7 @@ bool Encryption::Load(const char *name)
void Encryption::Unload() void Encryption::Unload()
{ {
_eqp _eqp_mt
if(h_dll) if(h_dll)
{ {
FreeLibrary(h_dll); FreeLibrary(h_dll);
@ -126,7 +125,7 @@ void Encryption::Unload()
bool Encryption::GetSym(const char *name, void **sym) bool Encryption::GetSym(const char *name, void **sym)
{ {
_eqp _eqp_mt
if(Loaded()) if(Loaded())
{ {
*sym = GetProcAddress(h_dll, name); *sym = GetProcAddress(h_dll, name);
@ -140,7 +139,7 @@ bool Encryption::GetSym(const char *name, void **sym)
void *Encryption::GetSym(const char *name) void *Encryption::GetSym(const char *name)
{ {
_eqp _eqp_mt
if(Loaded()) if(Loaded())
{ {
return GetProcAddress(h_dll, name); return GetProcAddress(h_dll, name);

View File

@ -34,14 +34,14 @@ const char *eqLogTypes[_log_largest_type] =
ErrorLog::ErrorLog(const char* file_name) ErrorLog::ErrorLog(const char* file_name)
{ {
_eqp _eqp_mt
log_mutex = new Mutex(); log_mutex = new Mutex();
error_log = fopen(file_name, "w"); error_log = fopen(file_name, "w");
} }
ErrorLog::~ErrorLog() ErrorLog::~ErrorLog()
{ {
_eqp _eqp_mt
log_mutex->lock(); log_mutex->lock();
if(error_log) if(error_log)
{ {
@ -53,7 +53,7 @@ ErrorLog::~ErrorLog()
void ErrorLog::Log(eqLogType type, const char *message, ...) void ErrorLog::Log(eqLogType type, const char *message, ...)
{ {
_eqp _eqp_mt
if(type >= _log_largest_type) if(type >= _log_largest_type)
{ {
return; return;
@ -101,7 +101,7 @@ void ErrorLog::Log(eqLogType type, const char *message, ...)
void ErrorLog::LogPacket(eqLogType type, const char *data, size_t size) void ErrorLog::LogPacket(eqLogType type, const char *data, size_t size)
{ {
_eqp _eqp_mt
if(type >= _log_largest_type) if(type >= _log_largest_type)
{ {
return; return;

View File

@ -34,7 +34,6 @@
TimeoutManager timeout_manager; TimeoutManager timeout_manager;
LoginServer server; LoginServer server;
EQEmuLogSys Log; EQEmuLogSys Log;
ErrorLog *server_log;
bool run_server = true; bool run_server = true;
void CatchSignal(int sig_num) void CatchSignal(int sig_num)
@ -50,7 +49,7 @@ void CatchSignal(int sig_num)
std::ofstream profile_out(prof_name, std::ofstream::out); std::ofstream profile_out(prof_name, std::ofstream::out);
if(profile_out.good()) { if(profile_out.good()) {
EQP::CPU::ST::GetProfiler().Dump(profile_out); EQP::CPU::MT::GetProfiler().Dump(profile_out, 5);
} }
#endif #endif
} }
@ -59,30 +58,39 @@ int main()
{ {
RegisterExecutablePlatform(ExePlatformLogin); RegisterExecutablePlatform(ExePlatformLogin);
set_exception_handler(); set_exception_handler();
Log.LoadLogSettingsDefaults();
//Create our error log, is of format login_<number>.log //log_settings
time_t current_time = time(nullptr); Log.log_settings[Logs::LogCategory::Crash].log_to_file = true;
std::stringstream log_name(std::stringstream::in | std::stringstream::out); Log.log_settings[Logs::LogCategory::Error].log_to_console = true;
log_name << "./logs/login_" << (unsigned int)current_time << ".log"; Log.log_settings[Logs::LogCategory::Error].log_to_file = true;
server_log = new ErrorLog(log_name.str().c_str()); Log.log_settings[Logs::LogCategory::Debug].log_to_console = true;
server_log->Log(log_debug, "Logging System Init."); Log.log_settings[Logs::LogCategory::Debug].log_to_file = true;
Log.log_settings[Logs::LogCategory::Database].log_to_console = true;
Log.log_settings[Logs::LogCategory::Database].log_to_file = true;
Log.log_settings[Logs::LogCategory::World_Server].log_to_console = true;
Log.log_settings[Logs::LogCategory::World_Server].log_to_file = true;
Log.log_settings[Logs::LogCategory::Netcode].log_to_console = true;
Log.log_settings[Logs::LogCategory::Netcode].log_to_file = true;
Log.file_logs_enabled = true;
Log.StartFileLogs();
if(signal(SIGINT, CatchSignal) == SIG_ERR) { if(signal(SIGINT, CatchSignal) == SIG_ERR) {
server_log->Log(log_error, "Could not set signal handler"); Log.Out(Logs::Detail, Logs::Error, "Could not set signal handler");
return 1; return 1;
} }
if(signal(SIGTERM, CatchSignal) == SIG_ERR) { if(signal(SIGTERM, CatchSignal) == SIG_ERR) {
server_log->Log(log_error, "Could not set signal handler"); Log.Out(Logs::Detail, Logs::Error, "Could not set signal handler");
return 1; return 1;
} }
if(signal(SIGBREAK, CatchSignal) == SIG_ERR) { if(signal(SIGBREAK, CatchSignal) == SIG_ERR) {
server_log->Log(log_error, "Could not set signal handler"); Log.Out(Logs::Detail, Logs::Error, "Could not set signal handler");
return 1; return 1;
} }
//Create our subsystem and parse the ini file. //Create our subsystem and parse the ini file.
server.config = new Config(); server.config = new Config();
server_log->Log(log_debug, "Config System Init."); Log.Out(Logs::General, Logs::Debug, "Config System Init.");
server.config->Parse("login.ini"); server.config->Parse("login.ini");
//Parse unregistered allowed option. //Parse unregistered allowed option.
@ -167,7 +175,7 @@ int main()
if(server.config->GetVariable("database", "subsystem").compare("MySQL") == 0) if(server.config->GetVariable("database", "subsystem").compare("MySQL") == 0)
{ {
#ifdef EQEMU_MYSQL_ENABLED #ifdef EQEMU_MYSQL_ENABLED
server_log->Log(log_debug, "MySQL Database Init."); Log.Out(Logs::General, Logs::Debug, "MySQL Database Init.");
server.db = (Database*)new DatabaseMySQL( server.db = (Database*)new DatabaseMySQL(
server.config->GetVariable("database", "user"), server.config->GetVariable("database", "user"),
server.config->GetVariable("database", "password"), server.config->GetVariable("database", "password"),
@ -179,7 +187,7 @@ int main()
else if(server.config->GetVariable("database", "subsystem").compare("PostgreSQL") == 0) else if(server.config->GetVariable("database", "subsystem").compare("PostgreSQL") == 0)
{ {
#ifdef EQEMU_POSTGRESQL_ENABLED #ifdef EQEMU_POSTGRESQL_ENABLED
server_log->Log(log_debug, "PostgreSQL Database Init."); Log.Out(Logs::General, Logs::Debug, "PostgreSQL Database Init.");
server.db = (Database*)new DatabasePostgreSQL( server.db = (Database*)new DatabasePostgreSQL(
server.config->GetVariable("database", "user"), server.config->GetVariable("database", "user"),
server.config->GetVariable("database", "password"), server.config->GetVariable("database", "password"),
@ -192,75 +200,67 @@ int main()
//Make sure our database got created okay, otherwise cleanup and exit. //Make sure our database got created okay, otherwise cleanup and exit.
if(!server.db) if(!server.db)
{ {
server_log->Log(log_error, "Database Initialization Failure."); Log.Out(Logs::Detail, Logs::Error, "Database Initialization Failure.");
server_log->Log(log_debug, "Config System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Config System Shutdown.");
delete server.config; delete server.config;
server_log->Log(log_debug, "Log System Shutdown.");
delete server_log;
return 1; return 1;
} }
#if WIN32 #if WIN32
//initialize our encryption. //initialize our encryption.
server_log->Log(log_debug, "Encryption Initialize."); Log.Out(Logs::General, Logs::Debug, "Encryption Initialize.");
server.eq_crypto = new Encryption(); server.eq_crypto = new Encryption();
if(server.eq_crypto->LoadCrypto(server.config->GetVariable("security", "plugin"))) if(server.eq_crypto->LoadCrypto(server.config->GetVariable("security", "plugin")))
{ {
server_log->Log(log_debug, "Encryption Loaded Successfully."); Log.Out(Logs::General, Logs::Debug, "Encryption Loaded Successfully.");
} }
else else
{ {
//We can't run without encryption, cleanup and exit. //We can't run without encryption, cleanup and exit.
server_log->Log(log_error, "Encryption Failed to Load."); Log.Out(Logs::Detail, Logs::Error, "Encryption Failed to Load.");
server_log->Log(log_debug, "Database System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Database System Shutdown.");
delete server.db; delete server.db;
server_log->Log(log_debug, "Config System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Config System Shutdown.");
delete server.config; delete server.config;
server_log->Log(log_debug, "Log System Shutdown.");
delete server_log;
return 1; return 1;
} }
#endif #endif
//create our server manager. //create our server manager.
server_log->Log(log_debug, "Server Manager Initialize."); Log.Out(Logs::General, Logs::Debug, "Server Manager Initialize.");
server.SM = new ServerManager(); server.SM = new ServerManager();
if(!server.SM) if(!server.SM)
{ {
//We can't run without a server manager, cleanup and exit. //We can't run without a server manager, cleanup and exit.
server_log->Log(log_error, "Server Manager Failed to Start."); Log.Out(Logs::Detail, Logs::Error, "Server Manager Failed to Start.");
#ifdef WIN32 #ifdef WIN32
server_log->Log(log_debug, "Encryption System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Encryption System Shutdown.");
delete server.eq_crypto; delete server.eq_crypto;
#endif #endif
server_log->Log(log_debug, "Database System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Database System Shutdown.");
delete server.db; delete server.db;
server_log->Log(log_debug, "Config System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Config System Shutdown.");
delete server.config; delete server.config;
server_log->Log(log_debug, "Log System Shutdown.");
delete server_log;
return 1; return 1;
} }
//create our client manager. //create our client manager.
server_log->Log(log_debug, "Client Manager Initialize."); Log.Out(Logs::General, Logs::Debug, "Client Manager Initialize.");
server.CM = new ClientManager(); server.CM = new ClientManager();
if(!server.CM) if(!server.CM)
{ {
//We can't run without a client manager, cleanup and exit. //We can't run without a client manager, cleanup and exit.
server_log->Log(log_error, "Client Manager Failed to Start."); Log.Out(Logs::Detail, Logs::Error, "Client Manager Failed to Start.");
server_log->Log(log_debug, "Server Manager Shutdown."); Log.Out(Logs::General, Logs::Debug, "Server Manager Shutdown.");
delete server.SM; delete server.SM;
#ifdef WIN32 #ifdef WIN32
server_log->Log(log_debug, "Encryption System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Encryption System Shutdown.");
delete server.eq_crypto; delete server.eq_crypto;
#endif #endif
server_log->Log(log_debug, "Database System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Database System Shutdown.");
delete server.db; delete server.db;
server_log->Log(log_debug, "Config System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Config System Shutdown.");
delete server.config; delete server.config;
server_log->Log(log_debug, "Log System Shutdown.");
delete server_log;
return 1; return 1;
} }
@ -272,7 +272,7 @@ int main()
#endif #endif
#endif #endif
server_log->Log(log_debug, "Server Started."); Log.Out(Logs::General, Logs::Debug, "Server Started.");
while(run_server) while(run_server)
{ {
Timer::SetCurrentTime(); Timer::SetCurrentTime();
@ -281,21 +281,19 @@ int main()
Sleep(100); Sleep(100);
} }
server_log->Log(log_debug, "Server Shutdown."); Log.Out(Logs::General, Logs::Debug, "Server Shutdown.");
server_log->Log(log_debug, "Client Manager Shutdown."); Log.Out(Logs::General, Logs::Debug, "Client Manager Shutdown.");
delete server.CM; delete server.CM;
server_log->Log(log_debug, "Server Manager Shutdown."); Log.Out(Logs::General, Logs::Debug, "Server Manager Shutdown.");
delete server.SM; delete server.SM;
#ifdef WIN32 #ifdef WIN32
server_log->Log(log_debug, "Encryption System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Encryption System Shutdown.");
delete server.eq_crypto; delete server.eq_crypto;
#endif #endif
server_log->Log(log_debug, "Database System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Database System Shutdown.");
delete server.db; delete server.db;
server_log->Log(log_debug, "Config System Shutdown."); Log.Out(Logs::General, Logs::Debug, "Config System Shutdown.");
delete server.config; delete server.config;
server_log->Log(log_debug, "Log System Shutdown.");
delete server_log;
return 0; return 0;
} }

View File

@ -19,33 +19,33 @@
#include "login_server.h" #include "login_server.h"
#include "error_log.h" #include "error_log.h"
#include "login_structures.h" #include "login_structures.h"
#include "../common/eqemu_logsys.h"
#include <stdlib.h> #include <stdlib.h>
extern ErrorLog *server_log;
extern LoginServer server; extern LoginServer server;
extern bool run_server; extern bool run_server;
ServerManager::ServerManager() ServerManager::ServerManager()
{ {
_eqp _eqp_mt
char error_buffer[TCPConnection_ErrorBufferSize]; char error_buffer[TCPConnection_ErrorBufferSize];
int listen_port = atoi(server.config->GetVariable("options", "listen_port").c_str()); int listen_port = atoi(server.config->GetVariable("options", "listen_port").c_str());
tcps = new EmuTCPServer(listen_port, true); tcps = new EmuTCPServer(listen_port, true);
if(tcps->Open(listen_port, error_buffer)) if(tcps->Open(listen_port, error_buffer))
{ {
server_log->Log(log_network, "ServerManager listening on port %u", listen_port); Log.Out(Logs::General, Logs::Netcode, "ServerManager listening on port %u", listen_port);
} }
else else
{ {
server_log->Log(log_error, "ServerManager fatal error opening port on %u: %s", listen_port, error_buffer); Log.Out(Logs::Detail, Logs::Error, "ServerManager fatal error opening port on %u: %s", listen_port, error_buffer);
run_server = false; run_server = false;
} }
} }
ServerManager::~ServerManager() ServerManager::~ServerManager()
{ {
_eqp _eqp_mt
if(tcps) if(tcps)
{ {
tcps->Close(); tcps->Close();
@ -55,19 +55,19 @@ ServerManager::~ServerManager()
void ServerManager::Process() void ServerManager::Process()
{ {
_eqp _eqp_mt
ProcessDisconnect(); ProcessDisconnect();
EmuTCPConnection *tcp_c = nullptr; EmuTCPConnection *tcp_c = nullptr;
while(tcp_c = tcps->NewQueuePop()) while(tcp_c = tcps->NewQueuePop())
{ {
in_addr tmp; in_addr tmp;
tmp.s_addr = tcp_c->GetrIP(); tmp.s_addr = tcp_c->GetrIP();
server_log->Log(log_network, "New world server connection from %s:%d", inet_ntoa(tmp), tcp_c->GetrPort()); Log.Out(Logs::General, Logs::Netcode, "New world server connection from %s:%d", inet_ntoa(tmp), tcp_c->GetrPort());
WorldServer *cur = GetServerByAddress(tcp_c->GetrIP()); WorldServer *cur = GetServerByAddress(tcp_c->GetrIP());
if(cur) if(cur)
{ {
server_log->Log(log_network, "World server already existed for %s, removing existing connection and updating current.", inet_ntoa(tmp)); Log.Out(Logs::General, Logs::Netcode, "World server already existed for %s, removing existing connection and updating current.", inet_ntoa(tmp));
cur->GetConnection()->Free(); cur->GetConnection()->Free();
cur->SetConnection(tcp_c); cur->SetConnection(tcp_c);
cur->Reset(); cur->Reset();
@ -84,7 +84,7 @@ void ServerManager::Process()
{ {
if((*iter)->Process() == false) if((*iter)->Process() == false)
{ {
server_log->Log(log_world, "World server %s had a fatal error and had to be removed from the login.", (*iter)->GetLongName().c_str()); Log.Out(Logs::General, Logs::World_Server, "World server %s had a fatal error and had to be removed from the login.", (*iter)->GetLongName().c_str());
delete (*iter); delete (*iter);
iter = world_servers.erase(iter); iter = world_servers.erase(iter);
} }
@ -97,7 +97,7 @@ void ServerManager::Process()
void ServerManager::ProcessDisconnect() void ServerManager::ProcessDisconnect()
{ {
_eqp _eqp_mt
list<WorldServer*>::iterator iter = world_servers.begin(); list<WorldServer*>::iterator iter = world_servers.begin();
while(iter != world_servers.end()) while(iter != world_servers.end())
{ {
@ -106,7 +106,7 @@ void ServerManager::ProcessDisconnect()
{ {
in_addr tmp; in_addr tmp;
tmp.s_addr = c->GetrIP(); tmp.s_addr = c->GetrIP();
server_log->Log(log_network, "World server disconnected from the server, removing server and freeing connection."); Log.Out(Logs::General, Logs::Netcode, "World server disconnected from the server, removing server and freeing connection.");
c->Free(); c->Free();
delete (*iter); delete (*iter);
iter = world_servers.erase(iter); iter = world_servers.erase(iter);
@ -120,7 +120,7 @@ void ServerManager::ProcessDisconnect()
WorldServer* ServerManager::GetServerByAddress(unsigned int address) WorldServer* ServerManager::GetServerByAddress(unsigned int address)
{ {
_eqp _eqp_mt
list<WorldServer*>::iterator iter = world_servers.begin(); list<WorldServer*>::iterator iter = world_servers.begin();
while(iter != world_servers.end()) while(iter != world_servers.end())
{ {
@ -136,7 +136,7 @@ WorldServer* ServerManager::GetServerByAddress(unsigned int address)
EQApplicationPacket *ServerManager::CreateServerListPacket(Client *c) EQApplicationPacket *ServerManager::CreateServerListPacket(Client *c)
{ {
_eqp _eqp_mt
unsigned int packet_size = sizeof(ServerListHeader_Struct); unsigned int packet_size = sizeof(ServerListHeader_Struct);
unsigned int server_count = 0; unsigned int server_count = 0;
in_addr in; in_addr in;
@ -274,7 +274,7 @@ EQApplicationPacket *ServerManager::CreateServerListPacket(Client *c)
void ServerManager::SendUserToWorldRequest(unsigned int server_id, unsigned int client_account_id) void ServerManager::SendUserToWorldRequest(unsigned int server_id, unsigned int client_account_id)
{ {
_eqp _eqp_mt
list<WorldServer*>::iterator iter = world_servers.begin(); list<WorldServer*>::iterator iter = world_servers.begin();
bool found = false; bool found = false;
while(iter != world_servers.end()) while(iter != world_servers.end())
@ -299,13 +299,13 @@ void ServerManager::SendUserToWorldRequest(unsigned int server_id, unsigned int
if(!found && server.options.IsTraceOn()) if(!found && server.options.IsTraceOn())
{ {
server_log->Log(log_client_error, "Client requested a user to world but supplied an invalid id of %u.", server_id); Log.Out(Logs::General, Logs::Error, "Client requested a user to world but supplied an invalid id of %u.", server_id);
} }
} }
bool ServerManager::ServerExists(string l_name, string s_name, WorldServer *ignore) bool ServerManager::ServerExists(string l_name, string s_name, WorldServer *ignore)
{ {
_eqp _eqp_mt
list<WorldServer*>::iterator iter = world_servers.begin(); list<WorldServer*>::iterator iter = world_servers.begin();
while(iter != world_servers.end()) while(iter != world_servers.end())
{ {
@ -327,7 +327,7 @@ bool ServerManager::ServerExists(string l_name, string s_name, WorldServer *igno
void ServerManager::DestroyServerByName(string l_name, string s_name, WorldServer *ignore) void ServerManager::DestroyServerByName(string l_name, string s_name, WorldServer *ignore)
{ {
_eqp _eqp_mt
list<WorldServer*>::iterator iter = world_servers.begin(); list<WorldServer*>::iterator iter = world_servers.begin();
while(iter != world_servers.end()) while(iter != world_servers.end())
{ {

View File

@ -19,13 +19,13 @@
#include "error_log.h" #include "error_log.h"
#include "login_server.h" #include "login_server.h"
#include "login_structures.h" #include "login_structures.h"
#include "../common/eqemu_logsys.h"
extern ErrorLog *server_log;
extern LoginServer server; extern LoginServer server;
WorldServer::WorldServer(EmuTCPConnection *c) WorldServer::WorldServer(EmuTCPConnection *c)
{ {
_eqp _eqp_mt
connection = c; connection = c;
zones_booted = 0; zones_booted = 0;
players_online = 0; players_online = 0;
@ -40,7 +40,7 @@ WorldServer::WorldServer(EmuTCPConnection *c)
WorldServer::~WorldServer() WorldServer::~WorldServer()
{ {
_eqp _eqp_mt
if(connection) if(connection)
{ {
connection->Free(); connection->Free();
@ -49,7 +49,7 @@ WorldServer::~WorldServer()
void WorldServer::Reset() void WorldServer::Reset()
{ {
_eqp _eqp_mt
zones_booted = 0; zones_booted = 0;
players_online = 0; players_online = 0;
status = 0; status = 0;
@ -62,13 +62,13 @@ void WorldServer::Reset()
bool WorldServer::Process() bool WorldServer::Process()
{ {
_eqp _eqp_mt
ServerPacket *app = nullptr; ServerPacket *app = nullptr;
while(app = connection->PopPacket()) while(app = connection->PopPacket())
{ {
if(server.options.IsWorldTraceOn()) if(server.options.IsWorldTraceOn())
{ {
server_log->Log(log_network_trace, "Application packet received from server: 0x%.4X, (size %u)", app->opcode, app->size); Log.Out(Logs::Detail, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", app->opcode, app->size);
} }
if(server.options.IsDumpInPacketsOn()) if(server.options.IsDumpInPacketsOn())
@ -82,14 +82,14 @@ bool WorldServer::Process()
{ {
if(app->size < sizeof(ServerNewLSInfo_Struct)) if(app->size < sizeof(ServerNewLSInfo_Struct))
{ {
server_log->Log(log_network_error, "Received application packet from server that had opcode ServerOP_NewLSInfo, " Log.Out(Logs::General, Logs::Netcode, "Received application packet from server that had opcode ServerOP_NewLSInfo, "
"but was too small. Discarded to avoid buffer overrun."); "but was too small. Discarded to avoid buffer overrun.");
break; break;
} }
if(server.options.IsWorldTraceOn()) if(server.options.IsWorldTraceOn())
{ {
server_log->Log(log_network_trace, "New Login Info Recieved."); Log.Out(Logs::Detail, Logs::Netcode, "New Login Info Recieved.");
} }
ServerNewLSInfo_Struct *info = (ServerNewLSInfo_Struct*)app->pBuffer; ServerNewLSInfo_Struct *info = (ServerNewLSInfo_Struct*)app->pBuffer;
@ -100,14 +100,14 @@ bool WorldServer::Process()
{ {
if(app->size < sizeof(ServerLSStatus_Struct)) if(app->size < sizeof(ServerLSStatus_Struct))
{ {
server_log->Log(log_network_error, "Recieved application packet from server that had opcode ServerOP_LSStatus, " Log.Out(Logs::General, Logs::Netcode, "Recieved application packet from server that had opcode ServerOP_LSStatus, "
"but was too small. Discarded to avoid buffer overrun."); "but was too small. Discarded to avoid buffer overrun.");
break; break;
} }
if(server.options.IsWorldTraceOn()) if(server.options.IsWorldTraceOn())
{ {
server_log->Log(log_network_trace, "World Server Status Recieved."); Log.Out(Logs::Detail, Logs::Netcode, "World Server Status Recieved.");
} }
ServerLSStatus_Struct *ls_status = (ServerLSStatus_Struct*)app->pBuffer; ServerLSStatus_Struct *ls_status = (ServerLSStatus_Struct*)app->pBuffer;
@ -131,7 +131,7 @@ bool WorldServer::Process()
{ {
if(app->size < sizeof(UsertoWorldResponse_Struct)) if(app->size < sizeof(UsertoWorldResponse_Struct))
{ {
server_log->Log(log_network_error, "Recieved application packet from server that had opcode ServerOP_UsertoWorldResp, " Log.Out(Logs::General, Logs::Netcode, "Recieved application packet from server that had opcode ServerOP_UsertoWorldResp, "
"but was too small. Discarded to avoid buffer overrun."); "but was too small. Discarded to avoid buffer overrun.");
break; break;
} }
@ -141,21 +141,21 @@ bool WorldServer::Process()
//While keeping world server spam with multiple servers connected almost impossible. //While keeping world server spam with multiple servers connected almost impossible.
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_network_trace, "User-To-World Response received."); Log.Out(Logs::Detail, Logs::Netcode, "User-To-World Response received.");
} }
UsertoWorldResponse_Struct *utwr = (UsertoWorldResponse_Struct*)app->pBuffer; UsertoWorldResponse_Struct *utwr = (UsertoWorldResponse_Struct*)app->pBuffer;
server_log->Log(log_client, "Trying to find client with user id of %u.", utwr->lsaccountid); Log.Out(Logs::General, Logs::LoginServer, "Trying to find client with user id of %u.", utwr->lsaccountid);
Client *c = server.CM->GetClient(utwr->lsaccountid); Client *c = server.CM->GetClient(utwr->lsaccountid);
if(c) if(c)
{ {
server_log->Log(log_client, "Found client with user id of %u and account name of %s.", utwr->lsaccountid, c->GetAccountName().c_str()); Log.Out(Logs::General, Logs::LoginServer, "Found client with user id of %u and account name of %s.", utwr->lsaccountid, c->GetAccountName().c_str());
EQApplicationPacket *outapp = new EQApplicationPacket(OP_PlayEverquestResponse, sizeof(PlayEverquestResponse_Struct)); EQApplicationPacket *outapp = new EQApplicationPacket(OP_PlayEverquestResponse, sizeof(PlayEverquestResponse_Struct));
PlayEverquestResponse_Struct *per = (PlayEverquestResponse_Struct*)outapp->pBuffer; PlayEverquestResponse_Struct *per = (PlayEverquestResponse_Struct*)outapp->pBuffer;
per->Sequence = c->GetPlaySequence(); per->Sequence = c->GetPlaySequence();
per->ServerNumber = c->GetPlayServerID(); per->ServerNumber = c->GetPlayServerID();
server_log->Log(log_client, "Found sequence and play of %u %u", c->GetPlaySequence(), c->GetPlayServerID()); Log.Out(Logs::General, Logs::LoginServer, "Found sequence and play of %u %u", c->GetPlaySequence(), c->GetPlayServerID());
server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size); //server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size);
if(utwr->response > 0) if(utwr->response > 0)
{ {
@ -184,9 +184,9 @@ bool WorldServer::Process()
if(server.options.IsTraceOn()) if(server.options.IsTraceOn())
{ {
server_log->Log(log_network_trace, "Sending play response with following data, allowed %u, sequence %u, server number %u, message %u", Log.Out(Logs::Detail, Logs::Netcode, "Sending play response with following data, allowed %u, sequence %u, server number %u, message %u",
per->Allowed, per->Sequence, per->ServerNumber, per->Message); per->Allowed, per->Sequence, per->ServerNumber, per->Message);
server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size); //server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size);
} }
if(server.options.IsDumpOutPacketsOn()) if(server.options.IsDumpOutPacketsOn())
@ -199,7 +199,7 @@ bool WorldServer::Process()
} }
else else
{ {
server_log->Log(log_client_error, "Recieved User-To-World Response for %u but could not find the client referenced!.", utwr->lsaccountid); Log.Out(Logs::General, Logs::Error, "Recieved User-To-World Response for %u but could not find the client referenced!.", utwr->lsaccountid);
} }
break; break;
} }
@ -207,16 +207,16 @@ bool WorldServer::Process()
{ {
if(app->size < sizeof(ServerLSAccountUpdate_Struct)) if(app->size < sizeof(ServerLSAccountUpdate_Struct))
{ {
server_log->Log(log_network_error, "Recieved application packet from server that had opcode ServerLSAccountUpdate_Struct, " Log.Out(Logs::General, Logs::Netcode, "Recieved application packet from server that had opcode ServerLSAccountUpdate_Struct, "
"but was too small. Discarded to avoid buffer overrun."); "but was too small. Discarded to avoid buffer overrun.");
break; break;
} }
server_log->Log(log_network_trace, "ServerOP_LSAccountUpdate packet received from: %s", short_name.c_str()); Log.Out(Logs::Detail, Logs::Netcode, "ServerOP_LSAccountUpdate packet received from: %s", short_name.c_str());
ServerLSAccountUpdate_Struct *lsau = (ServerLSAccountUpdate_Struct*)app->pBuffer; ServerLSAccountUpdate_Struct *lsau = (ServerLSAccountUpdate_Struct*)app->pBuffer;
if(trusted) if(trusted)
{ {
server_log->Log(log_network_trace, "ServerOP_LSAccountUpdate update processed for: %s", lsau->useraccount); Log.Out(Logs::Detail, Logs::Netcode, "ServerOP_LSAccountUpdate update processed for: %s", lsau->useraccount);
string name; string name;
string password; string password;
string email; string email;
@ -229,7 +229,7 @@ bool WorldServer::Process()
} }
default: default:
{ {
server_log->Log(log_network_error, "Recieved application packet from server that had an unknown operation code 0x%.4X.", app->opcode); Log.Out(Logs::General, Logs::Netcode, "Recieved application packet from server that had an unknown operation code 0x%.4X.", app->opcode);
} }
} }
@ -241,10 +241,10 @@ bool WorldServer::Process()
void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
{ {
_eqp _eqp_mt
if(logged_in) if(logged_in)
{ {
server_log->Log(log_network_error, "WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting."); Log.Out(Logs::General, Logs::Netcode, "WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting.");
return; return;
} }
@ -254,7 +254,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else else
{ {
server_log->Log(log_network_error, "Handle_NewLSInfo error, account name was too long."); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, account name was too long.");
return; return;
} }
@ -264,7 +264,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else else
{ {
server_log->Log(log_network_error, "Handle_NewLSInfo error, account password was too long."); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, account password was too long.");
return; return;
} }
@ -274,7 +274,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else else
{ {
server_log->Log(log_network_error, "Handle_NewLSInfo error, long name was too long."); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, long name was too long.");
return; return;
} }
@ -284,7 +284,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else else
{ {
server_log->Log(log_network_error, "Handle_NewLSInfo error, short name was too long."); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, short name was too long.");
return; return;
} }
@ -292,7 +292,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
{ {
if(strlen(i->local_address) == 0) if(strlen(i->local_address) == 0)
{ {
server_log->Log(log_network_error, "Handle_NewLSInfo error, local address was null, defaulting to localhost"); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, local address was null, defaulting to localhost");
local_ip = "127.0.0.1"; local_ip = "127.0.0.1";
} }
else else
@ -302,7 +302,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else else
{ {
server_log->Log(log_network_error, "Handle_NewLSInfo error, local address was too long."); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, local address was too long.");
return; return;
} }
@ -313,7 +313,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
in_addr in; in_addr in;
in.s_addr = GetConnection()->GetrIP(); in.s_addr = GetConnection()->GetrIP();
remote_ip = inet_ntoa(in); remote_ip = inet_ntoa(in);
server_log->Log(log_network_error, "Handle_NewLSInfo error, remote address was null, defaulting to stream address %s.", remote_ip.c_str()); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, remote address was null, defaulting to stream address %s.", remote_ip.c_str());
} }
else else
{ {
@ -325,7 +325,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
in_addr in; in_addr in;
in.s_addr = GetConnection()->GetrIP(); in.s_addr = GetConnection()->GetrIP();
remote_ip = inet_ntoa(in); remote_ip = inet_ntoa(in);
server_log->Log(log_network_error, "Handle_NewLSInfo error, remote address was too long, defaulting to stream address %s.", remote_ip.c_str()); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, remote address was too long, defaulting to stream address %s.", remote_ip.c_str());
} }
if(strlen(i->serverversion) <= 64) if(strlen(i->serverversion) <= 64)
@ -334,7 +334,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else else
{ {
server_log->Log(log_network_error, "Handle_NewLSInfo error, server version was too long."); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, server version was too long.");
return; return;
} }
@ -344,7 +344,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else else
{ {
server_log->Log(log_network_error, "Handle_NewLSInfo error, protocol version was too long."); Log.Out(Logs::General, Logs::Netcode, "Handle_NewLSInfo error, protocol version was too long.");
return; return;
} }
@ -355,7 +355,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
{ {
if(server.SM->ServerExists(long_name, short_name, this)) if(server.SM->ServerExists(long_name, short_name, this))
{ {
server_log->Log(log_world_error, "World tried to login but there already exists a server that has that name."); Log.Out(Logs::General, Logs::Error, "World tried to login but there already exists a server that has that name.");
return; return;
} }
} }
@ -363,7 +363,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
{ {
if(server.SM->ServerExists(long_name, short_name, this)) if(server.SM->ServerExists(long_name, short_name, this))
{ {
server_log->Log(log_world_error, "World tried to login but there already exists a server that has that name."); Log.Out(Logs::General, Logs::Error, "World tried to login but there already exists a server that has that name.");
server.SM->DestroyServerByName(long_name, short_name, this); server.SM->DestroyServerByName(long_name, short_name, this);
} }
} }
@ -383,7 +383,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
{ {
if(s_acct_name.size() == 0 || s_acct_pass.size() == 0) if(s_acct_name.size() == 0 || s_acct_pass.size() == 0)
{ {
server_log->Log(log_world, "Server %s(%s) successfully logged into account that had no user/password requirement.", Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged into account that had no user/password requirement.",
long_name.c_str(), short_name.c_str()); long_name.c_str(), short_name.c_str());
authorized = true; authorized = true;
SetRuntimeID(s_id); SetRuntimeID(s_id);
@ -392,7 +392,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else if(s_acct_name.compare(account_name) == 0 && s_acct_pass.compare(account_password) == 0) else if(s_acct_name.compare(account_name) == 0 && s_acct_pass.compare(account_password) == 0)
{ {
server_log->Log(log_world, "Server %s(%s) successfully logged in.", Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged in.",
long_name.c_str(), short_name.c_str()); long_name.c_str(), short_name.c_str());
authorized = true; authorized = true;
SetRuntimeID(s_id); SetRuntimeID(s_id);
@ -400,7 +400,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
desc = s_desc; desc = s_desc;
if(s_trusted) if(s_trusted)
{ {
server_log->Log(log_network_trace, "ServerOP_LSAccountUpdate sent to world"); Log.Out(Logs::Detail, Logs::Netcode, "ServerOP_LSAccountUpdate sent to world");
trusted = true; trusted = true;
ServerPacket *outapp = new ServerPacket(ServerOP_LSAccountUpdate, 0); ServerPacket *outapp = new ServerPacket(ServerOP_LSAccountUpdate, 0);
connection->SendPacket(outapp); connection->SendPacket(outapp);
@ -408,21 +408,21 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else else
{ {
server_log->Log(log_world, "Server %s(%s) attempted to log in but account and password did not match the entry in the database, and only" Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but account and password did not match the entry in the database, and only"
" registered servers are allowed.", long_name.c_str(), short_name.c_str()); " registered servers are allowed.", long_name.c_str(), short_name.c_str());
return; return;
} }
} }
else else
{ {
server_log->Log(log_world, "Server %s(%s) attempted to log in but database couldn't find an entry and only registered servers are allowed.", Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but database couldn't find an entry and only registered servers are allowed.",
long_name.c_str(), short_name.c_str()); long_name.c_str(), short_name.c_str());
return; return;
} }
} }
else else
{ {
server_log->Log(log_world, "Server %s(%s) did not attempt to log in but only registered servers are allowed.", Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but only registered servers are allowed.",
long_name.c_str(), short_name.c_str()); long_name.c_str(), short_name.c_str());
return; return;
} }
@ -442,7 +442,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
{ {
if(s_acct_name.compare(account_name) == 0 && s_acct_pass.compare(account_password) == 0) if(s_acct_name.compare(account_name) == 0 && s_acct_pass.compare(account_password) == 0)
{ {
server_log->Log(log_world, "Server %s(%s) successfully logged in.", Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged in.",
long_name.c_str(), short_name.c_str()); long_name.c_str(), short_name.c_str());
authorized = true; authorized = true;
SetRuntimeID(s_id); SetRuntimeID(s_id);
@ -450,7 +450,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
desc = s_desc; desc = s_desc;
if(s_trusted) if(s_trusted)
{ {
server_log->Log(log_network_trace, "ServerOP_LSAccountUpdate sent to world"); Log.Out(Logs::Detail, Logs::Netcode, "ServerOP_LSAccountUpdate sent to world");
trusted = true; trusted = true;
ServerPacket *outapp = new ServerPacket(ServerOP_LSAccountUpdate, 0); ServerPacket *outapp = new ServerPacket(ServerOP_LSAccountUpdate, 0);
connection->SendPacket(outapp); connection->SendPacket(outapp);
@ -459,7 +459,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
else else
{ {
// this is the first of two cases where we should deny access even if unregistered is allowed // this is the first of two cases where we should deny access even if unregistered is allowed
server_log->Log(log_world, "Server %s(%s) attempted to log in but account and password did not match the entry in the database.", Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but account and password did not match the entry in the database.",
long_name.c_str(), short_name.c_str()); long_name.c_str(), short_name.c_str());
} }
} }
@ -468,12 +468,12 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
if(s_acct_name.size() > 0 || s_acct_pass.size() > 0) if(s_acct_name.size() > 0 || s_acct_pass.size() > 0)
{ {
// this is the second of two cases where we should deny access even if unregistered is allowed // this is the second of two cases where we should deny access even if unregistered is allowed
server_log->Log(log_world, "Server %s(%s) did not attempt to log in but this server requires a password.", Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but this server requires a password.",
long_name.c_str(), short_name.c_str()); long_name.c_str(), short_name.c_str());
} }
else else
{ {
server_log->Log(log_world, "Server %s(%s) did not attempt to log in but unregistered servers are allowed.", Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but unregistered servers are allowed.",
long_name.c_str(), short_name.c_str()); long_name.c_str(), short_name.c_str());
authorized = true; authorized = true;
SetRuntimeID(s_id); SetRuntimeID(s_id);
@ -483,7 +483,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
} }
else else
{ {
server_log->Log(log_world, "Server %s(%s) attempted to log in but database couldn't find an entry but unregistered servers are allowed.", Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but database couldn't find an entry but unregistered servers are allowed.",
long_name.c_str(), short_name.c_str()); long_name.c_str(), short_name.c_str());
if(server.db->CreateWorldRegistration(long_name, short_name, s_id)) if(server.db->CreateWorldRegistration(long_name, short_name, s_id))
{ {
@ -506,7 +506,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i)
void WorldServer::Handle_LSStatus(ServerLSStatus_Struct *s) void WorldServer::Handle_LSStatus(ServerLSStatus_Struct *s)
{ {
_eqp _eqp_mt
players_online = s->num_players; players_online = s->num_players;
zones_booted = s->num_zones; zones_booted = s->num_zones;
status = s->status; status = s->status;
@ -514,7 +514,7 @@ void WorldServer::Handle_LSStatus(ServerLSStatus_Struct *s)
void WorldServer::SendClientAuth(unsigned int ip, string account, string key, unsigned int account_id) void WorldServer::SendClientAuth(unsigned int ip, string account, string key, unsigned int account_id)
{ {
_eqp _eqp_mt
ServerPacket *outapp = new ServerPacket(ServerOP_LSClientAuth, sizeof(ServerLSClientAuth)); ServerPacket *outapp = new ServerPacket(ServerOP_LSClientAuth, sizeof(ServerLSClientAuth));
ServerLSClientAuth* slsca = (ServerLSClientAuth*)outapp->pBuffer; ServerLSClientAuth* slsca = (ServerLSClientAuth*)outapp->pBuffer;

View File

@ -21,7 +21,7 @@ INSTALL(TARGETS queryserv RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
ADD_DEFINITIONS(-DQSERV) ADD_DEFINITIONS(-DQSERV)
TARGET_LINK_LIBRARIES(queryserv common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(queryserv common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(queryserv PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") SET_TARGET_PROPERTIES(queryserv PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")

View File

@ -23,7 +23,7 @@ ADD_EXECUTABLE(shared_memory ${shared_memory_sources} ${shared_memory_headers})
INSTALL(TARGETS shared_memory RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) INSTALL(TARGETS shared_memory RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
TARGET_LINK_LIBRARIES(shared_memory common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(shared_memory common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(shared_memory PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") SET_TARGET_PROPERTIES(shared_memory PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")

View File

@ -20,7 +20,7 @@ SET(tests_headers
ADD_EXECUTABLE(tests ${tests_sources} ${tests_headers}) ADD_EXECUTABLE(tests ${tests_sources} ${tests_headers})
TARGET_LINK_LIBRARIES(tests common cppunit) TARGET_LINK_LIBRARIES(tests common ${PERF_LIBS} cppunit)
INSTALL(TARGETS tests RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) INSTALL(TARGETS tests RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})

View File

@ -23,7 +23,7 @@ INSTALL(TARGETS ucs RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
ADD_DEFINITIONS(-DUCS) ADD_DEFINITIONS(-DUCS)
TARGET_LINK_LIBRARIES(ucs common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(ucs common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(ucs PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") SET_TARGET_PROPERTIES(ucs PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")

View File

@ -68,7 +68,7 @@ INSTALL(TARGETS world RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
ADD_DEFINITIONS(-DWORLD) ADD_DEFINITIONS(-DWORLD)
TARGET_LINK_LIBRARIES(world common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(world common ${PERF_LIBS} ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(world PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") SET_TARGET_PROPERTIES(world PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")

View File

@ -307,29 +307,7 @@ bool EQWHTTPServer::Start(uint16 port, const char *mime_file) {
m_running = true; m_running = true;
m_port = port; m_port = port;
/*
#ifdef _WINDOWS
_beginthread(ThreadProc, 0, this);
#else
pthread_create(&m_thread, nullptr, ThreadProc, this);
#endif*/
return(true); return(true);
} }
/*
void EQWHTTPServer::Run() {
Log.LogDebugType(Logs::Detail, Logs::World_Server, "HTTP Processing thread started on port %d", m_port);
do {
#warning DELETE THIS IF YOU DONT USE IT
Sleep(10);
} while(m_running);
Log.LogDebugType(Logs::Detail, Logs::World_Server, "HTTP Processing thread terminating on port %d", m_port);
}
ThreadReturnType EQWHTTPServer::ThreadProc(void *data) {
((EQWHTTPServer *) data)->Run();
THREAD_RETURN(nullptr);
}*/

View File

@ -219,7 +219,7 @@ INSTALL(TARGETS zone RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
ADD_DEFINITIONS(-DZONE) ADD_DEFINITIONS(-DZONE)
TARGET_LINK_LIBRARIES(zone common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(zone common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(EQEMU_BUILD_PERL) IF(EQEMU_BUILD_PERL)
TARGET_LINK_LIBRARIES(zone ${PERL_LIBRARY}) TARGET_LINK_LIBRARIES(zone ${PERL_LIBRARY})