mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-13 02:38:45 +00:00
Back to ST profiling, wont bother profiling the common library for now.
This commit is contained in:
@@ -62,6 +62,7 @@ SET(common_sources
|
||||
timeoutmgr.cpp
|
||||
timer.cpp
|
||||
unix.cpp
|
||||
uuid.cpp
|
||||
worldconn.cpp
|
||||
xml_parser.cpp
|
||||
platform.cpp
|
||||
@@ -181,6 +182,7 @@ SET(common_headers
|
||||
types.h
|
||||
unix.h
|
||||
useperl.h
|
||||
uuid.h
|
||||
version.h
|
||||
worldconn.h
|
||||
xml_parser.h
|
||||
|
||||
@@ -39,11 +39,9 @@ EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
|
||||
: BasePacket(buf, len),
|
||||
emu_opcode(op)
|
||||
{
|
||||
_eqp_mt
|
||||
}
|
||||
|
||||
void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
|
||||
_eqp_mt
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
@@ -52,20 +50,17 @@ void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
|
||||
|
||||
void EQPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp_mt
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQPacket::build_header_dump(char *buffer) const {
|
||||
_eqp_mt
|
||||
sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]", emu_opcode, size);
|
||||
}
|
||||
|
||||
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp_mt
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
@@ -80,7 +75,6 @@ void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
|
||||
void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
_eqp_mt
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
@@ -89,7 +83,6 @@ void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
|
||||
void EQProtocolPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp_mt
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
@@ -97,13 +90,11 @@ void EQProtocolPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
|
||||
void EQProtocolPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
_eqp_mt
|
||||
sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]",opcode,size);
|
||||
}
|
||||
|
||||
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp_mt
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
@@ -118,7 +109,6 @@ void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
|
||||
void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
_eqp_mt
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
@@ -131,7 +121,6 @@ void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
|
||||
void EQApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp_mt
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
@@ -139,7 +128,6 @@ void EQApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
|
||||
void EQApplicationPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
_eqp_mt
|
||||
#ifdef STATIC_OPCODE
|
||||
sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||
#else
|
||||
@@ -149,7 +137,6 @@ void EQApplicationPacket::build_header_dump(char *buffer) const
|
||||
|
||||
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp_mt
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
@@ -168,7 +155,6 @@ void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
|
||||
void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
_eqp_mt
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
@@ -181,7 +167,6 @@ void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) con
|
||||
|
||||
void EQRawApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp_mt
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
@@ -189,7 +174,6 @@ void EQRawApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
|
||||
void EQRawApplicationPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
_eqp_mt
|
||||
#ifdef STATIC_OPCODE
|
||||
sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
|
||||
#else
|
||||
@@ -199,7 +183,6 @@ void EQRawApplicationPacket::build_header_dump(char *buffer) const
|
||||
|
||||
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
_eqp_mt
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
@@ -218,7 +201,6 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
|
||||
uint32 EQProtocolPacket::serialize(unsigned char *dest) const
|
||||
{
|
||||
_eqp_mt
|
||||
if (opcode>0xff) {
|
||||
*(uint16 *)dest=opcode;
|
||||
} else {
|
||||
@@ -232,7 +214,6 @@ uint32 EQProtocolPacket::serialize(unsigned char *dest) const
|
||||
|
||||
uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
|
||||
{
|
||||
_eqp_mt
|
||||
uint8 OpCodeBytes = app_opcode_size;
|
||||
|
||||
if (app_opcode_size==1)
|
||||
@@ -256,7 +237,6 @@ uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
|
||||
|
||||
bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
|
||||
{
|
||||
_eqp_mt
|
||||
bool result=false;
|
||||
if (opcode==OP_Combined && size+rhs->size+5<256) {
|
||||
unsigned char *tmpbuffer=new unsigned char [size+rhs->size+3];
|
||||
@@ -288,7 +268,6 @@ bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
|
||||
|
||||
bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint32 Key)
|
||||
{
|
||||
_eqp_mt
|
||||
bool valid=false;
|
||||
// OP_SessionRequest, OP_SessionResponse, OP_OutOfSession are not CRC'd
|
||||
if (buffer[0]==0x00 && (buffer[1]==OP_SessionRequest || buffer[1]==OP_SessionResponse || buffer[1]==OP_OutOfSession)) {
|
||||
@@ -308,7 +287,6 @@ bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint
|
||||
|
||||
uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize)
|
||||
{
|
||||
_eqp_mt
|
||||
uint32 newlen=0;
|
||||
uint32 flag_offset=0;
|
||||
newbuf[0]=buffer[0];
|
||||
@@ -334,7 +312,6 @@ uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 le
|
||||
}
|
||||
|
||||
uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) {
|
||||
_eqp_mt
|
||||
uint32 flag_offset=1,newlength;
|
||||
//dump_message_column(buffer,length,"Before: ");
|
||||
newbuf[0]=buffer[0];
|
||||
@@ -358,7 +335,6 @@ uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 leng
|
||||
|
||||
void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey)
|
||||
{
|
||||
_eqp_mt
|
||||
if ((size >= 2) && buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
|
||||
int Key=DecodeKey;
|
||||
unsigned char *test=(unsigned char *)malloc(size);
|
||||
@@ -384,7 +360,6 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
|
||||
|
||||
void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey)
|
||||
{
|
||||
_eqp_mt
|
||||
if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
|
||||
int Key=EncodeKey;
|
||||
char *test=(char*)malloc(size);
|
||||
@@ -408,12 +383,10 @@ void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey
|
||||
}
|
||||
|
||||
EQApplicationPacket *EQApplicationPacket::Copy() const {
|
||||
_eqp_mt
|
||||
return(new EQApplicationPacket(*this));
|
||||
}
|
||||
|
||||
EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
|
||||
_eqp_mt
|
||||
EQRawApplicationPacket *res = new EQRawApplicationPacket(opcode, pBuffer, size);
|
||||
res->copyInfo(this);
|
||||
return(res);
|
||||
@@ -423,12 +396,10 @@ EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned cha
|
||||
: EQApplicationPacket(OP_Unknown, buf, len),
|
||||
opcode(opcode)
|
||||
{
|
||||
_eqp_mt
|
||||
}
|
||||
EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len)
|
||||
: EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16))
|
||||
{
|
||||
_eqp_mt
|
||||
if(GetExecutablePlatform() != ExePlatformUCS) {
|
||||
opcode = *((const uint16 *) buf);
|
||||
if(opcode == 0x0000)
|
||||
@@ -462,7 +433,6 @@ EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const u
|
||||
}
|
||||
|
||||
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
|
||||
_eqp_mt
|
||||
if (iShowInfo) {
|
||||
std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
|
||||
std::cout << " size:" << app->size << std::endl;
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
uint16 EQStream::MaxWindowSize=2048;
|
||||
|
||||
void EQStream::init(bool resetSession) {
|
||||
_eqp_mt
|
||||
// we only reset these statistics if it is a 'new' connection
|
||||
if ( resetSession )
|
||||
{
|
||||
@@ -92,7 +91,6 @@ void EQStream::init(bool resetSession) {
|
||||
|
||||
EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
|
||||
{
|
||||
_eqp_mt
|
||||
EQRawApplicationPacket *ap=nullptr;
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, p->size);
|
||||
// _raw(NET__APP_CREATE_HEX, 0xFFFF, p);
|
||||
@@ -102,7 +100,6 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
|
||||
|
||||
EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len)
|
||||
{
|
||||
_eqp_mt
|
||||
EQRawApplicationPacket *ap=nullptr;
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, len);
|
||||
ap = new EQRawApplicationPacket(buf, len);
|
||||
@@ -110,7 +107,6 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf
|
||||
}
|
||||
|
||||
EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32 len) {
|
||||
_eqp_mt
|
||||
uint16 proto_opcode = ntohs(*(const uint16 *)buf);
|
||||
|
||||
//advance over opcode.
|
||||
@@ -122,7 +118,6 @@ EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32
|
||||
|
||||
void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
{
|
||||
_eqp_mt
|
||||
uint32 processed=0, subpacket_length=0;
|
||||
if (p == nullptr)
|
||||
return;
|
||||
@@ -520,7 +515,6 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
|
||||
void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
|
||||
{
|
||||
_eqp_mt
|
||||
if(p == nullptr)
|
||||
return;
|
||||
|
||||
@@ -532,7 +526,6 @@ void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
|
||||
|
||||
void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
|
||||
{
|
||||
_eqp_mt
|
||||
EQApplicationPacket *pack=*p;
|
||||
*p = nullptr; //clear caller's pointer.. effectively takes ownership
|
||||
|
||||
@@ -562,7 +555,6 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
|
||||
|
||||
void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
||||
{
|
||||
_eqp_mt
|
||||
uint32 chunksize,used;
|
||||
uint32 length;
|
||||
|
||||
@@ -607,7 +599,6 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
||||
|
||||
void EQStream::SequencedPush(EQProtocolPacket *p)
|
||||
{
|
||||
_eqp_mt
|
||||
#ifdef COLLECTOR
|
||||
delete p;
|
||||
#else
|
||||
@@ -636,7 +627,6 @@ if(NextSequencedSend > SequencedQueue.size()) {
|
||||
|
||||
void EQStream::NonSequencedPush(EQProtocolPacket *p)
|
||||
{
|
||||
_eqp_mt
|
||||
#ifdef COLLECTOR
|
||||
delete p;
|
||||
#else
|
||||
@@ -649,7 +639,6 @@ void EQStream::NonSequencedPush(EQProtocolPacket *p)
|
||||
|
||||
void EQStream::SendAck(uint16 seq)
|
||||
{
|
||||
_eqp_mt
|
||||
uint16 Seq=htons(seq);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Sending ack with sequence %d" __L, seq);
|
||||
SetLastAckSent(seq);
|
||||
@@ -658,7 +647,6 @@ void EQStream::SendAck(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);
|
||||
uint16 Seq=htons(seq);
|
||||
NonSequencedPush(new EQProtocolPacket(OP_OutOfOrderAck,(unsigned char *)&Seq,sizeof(uint16)));
|
||||
@@ -666,7 +654,6 @@ uint16 Seq=htons(seq);
|
||||
|
||||
void EQStream::Write(int eq_fd)
|
||||
{
|
||||
_eqp_mt
|
||||
std::queue<EQProtocolPacket *> ReadyToSend;
|
||||
bool SeqEmpty=false, NonSeqEmpty=false;
|
||||
std::deque<EQProtocolPacket *>::iterator sitr;
|
||||
@@ -862,7 +849,6 @@ void EQStream::Write(int eq_fd)
|
||||
|
||||
void EQStream::WritePacket(int eq_fd, EQProtocolPacket *p)
|
||||
{
|
||||
_eqp_mt
|
||||
uint32 length;
|
||||
sockaddr_in address;
|
||||
address.sin_family = AF_INET;
|
||||
@@ -901,7 +887,6 @@ void EQStream::WritePacket(int eq_fd, EQProtocolPacket *p)
|
||||
|
||||
void EQStream::SendSessionResponse()
|
||||
{
|
||||
_eqp_mt
|
||||
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(SessionResponse));
|
||||
SessionResponse *Response=(SessionResponse *)out->pBuffer;
|
||||
Response->Session=htonl(Session);
|
||||
@@ -924,7 +909,6 @@ void EQStream::SendSessionResponse()
|
||||
|
||||
void EQStream::SendSessionRequest()
|
||||
{
|
||||
_eqp_mt
|
||||
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(SessionRequest));
|
||||
SessionRequest *Request=(SessionRequest *)out->pBuffer;
|
||||
memset(Request,0,sizeof(SessionRequest));
|
||||
@@ -938,7 +922,6 @@ void EQStream::SendSessionRequest()
|
||||
|
||||
void EQStream::_SendDisconnect()
|
||||
{
|
||||
_eqp_mt
|
||||
if(GetState() == CLOSED)
|
||||
return;
|
||||
|
||||
@@ -951,7 +934,6 @@ void EQStream::_SendDisconnect()
|
||||
|
||||
void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
|
||||
{
|
||||
_eqp_mt
|
||||
MInboundQueue.lock();
|
||||
InboundQueue.push_back(p);
|
||||
MInboundQueue.unlock();
|
||||
@@ -959,7 +941,6 @@ void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
|
||||
|
||||
EQApplicationPacket *EQStream::PopPacket()
|
||||
{
|
||||
_eqp_mt
|
||||
EQRawApplicationPacket *p=nullptr;
|
||||
|
||||
MInboundQueue.lock();
|
||||
@@ -987,7 +968,6 @@ EQApplicationPacket *EQStream::PopPacket()
|
||||
|
||||
EQRawApplicationPacket *EQStream::PopRawPacket()
|
||||
{
|
||||
_eqp_mt
|
||||
EQRawApplicationPacket *p=nullptr;
|
||||
|
||||
MInboundQueue.lock();
|
||||
@@ -1015,7 +995,6 @@ EQRawApplicationPacket *EQStream::PopRawPacket()
|
||||
|
||||
EQRawApplicationPacket *EQStream::PeekPacket()
|
||||
{
|
||||
_eqp_mt
|
||||
EQRawApplicationPacket *p=nullptr;
|
||||
|
||||
MInboundQueue.lock();
|
||||
@@ -1030,7 +1009,6 @@ EQRawApplicationPacket *EQStream::PeekPacket()
|
||||
|
||||
void EQStream::InboundQueueClear()
|
||||
{
|
||||
_eqp_mt
|
||||
EQApplicationPacket *p=nullptr;
|
||||
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing inbound queue" __L);
|
||||
@@ -1049,7 +1027,6 @@ void EQStream::InboundQueueClear()
|
||||
|
||||
bool EQStream::HasOutgoingData()
|
||||
{
|
||||
_eqp_mt
|
||||
bool flag;
|
||||
|
||||
//once closed, we have nothing more to say
|
||||
@@ -1075,7 +1052,6 @@ bool EQStream::HasOutgoingData()
|
||||
|
||||
void EQStream::OutboundQueueClear()
|
||||
{
|
||||
_eqp_mt
|
||||
EQProtocolPacket *p=nullptr;
|
||||
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing outbound queue" __L);
|
||||
@@ -1098,7 +1074,6 @@ void EQStream::OutboundQueueClear()
|
||||
|
||||
void EQStream::PacketQueueClear()
|
||||
{
|
||||
_eqp_mt
|
||||
EQProtocolPacket *p=nullptr;
|
||||
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing future packet queue" __L);
|
||||
@@ -1115,7 +1090,6 @@ void EQStream::PacketQueueClear()
|
||||
|
||||
void EQStream::Process(const unsigned char *buffer, const uint32 length)
|
||||
{
|
||||
_eqp_mt
|
||||
static unsigned char newbuffer[2048];
|
||||
uint32 newlength=0;
|
||||
if (EQProtocolPacket::ValidateCRC(buffer,length,Key)) {
|
||||
@@ -1140,7 +1114,6 @@ void EQStream::Process(const unsigned char *buffer, const uint32 length)
|
||||
|
||||
long EQStream::GetNextAckToSend()
|
||||
{
|
||||
_eqp_mt
|
||||
MAcks.lock();
|
||||
long l=NextAckToSend;
|
||||
MAcks.unlock();
|
||||
@@ -1150,7 +1123,6 @@ long EQStream::GetNextAckToSend()
|
||||
|
||||
long EQStream::GetLastAckSent()
|
||||
{
|
||||
_eqp_mt
|
||||
MAcks.lock();
|
||||
long l=LastAckSent;
|
||||
MAcks.unlock();
|
||||
@@ -1160,7 +1132,6 @@ long EQStream::GetLastAckSent()
|
||||
|
||||
void EQStream::AckPackets(uint16 seq)
|
||||
{
|
||||
_eqp_mt
|
||||
std::deque<EQProtocolPacket *>::iterator itr, tmp;
|
||||
|
||||
MOutboundQueue.lock();
|
||||
@@ -1215,7 +1186,6 @@ void EQStream::AckPackets(uint16 seq)
|
||||
|
||||
void EQStream::SetNextAckToSend(uint32 seq)
|
||||
{
|
||||
_eqp_mt
|
||||
MAcks.lock();
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Set Next Ack To Send to %lu" __L, (unsigned long)seq);
|
||||
NextAckToSend=seq;
|
||||
@@ -1224,7 +1194,6 @@ void EQStream::SetNextAckToSend(uint32 seq)
|
||||
|
||||
void EQStream::SetLastAckSent(uint32 seq)
|
||||
{
|
||||
_eqp_mt
|
||||
MAcks.lock();
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Set Last Ack Sent to %lu" __L, (unsigned long)seq);
|
||||
LastAckSent=seq;
|
||||
@@ -1233,7 +1202,6 @@ void EQStream::SetLastAckSent(uint32 seq)
|
||||
|
||||
void EQStream::ProcessQueue()
|
||||
{
|
||||
_eqp_mt
|
||||
if(PacketQueue.empty()) {
|
||||
return;
|
||||
}
|
||||
@@ -1249,7 +1217,6 @@ void EQStream::ProcessQueue()
|
||||
|
||||
EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
|
||||
{
|
||||
_eqp_mt
|
||||
std::map<unsigned short,EQProtocolPacket *>::iterator itr;
|
||||
EQProtocolPacket *qp=nullptr;
|
||||
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
|
||||
@@ -1262,7 +1229,6 @@ EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
|
||||
|
||||
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));
|
||||
StreamType=type;
|
||||
switch (StreamType) {
|
||||
@@ -1293,7 +1259,6 @@ void EQStream::SetStreamType(EQStreamType type)
|
||||
|
||||
const char *EQStream::StreamTypeString(EQStreamType t)
|
||||
{
|
||||
_eqp_mt
|
||||
switch (t) {
|
||||
case LoginStream:
|
||||
return "Login";
|
||||
@@ -1323,7 +1288,6 @@ const char *EQStream::StreamTypeString(EQStreamType t)
|
||||
//returns SeqFuture if `seq` is later than `expected_seq`
|
||||
EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
|
||||
{
|
||||
_eqp_mt
|
||||
if (expected_seq==seq) {
|
||||
// Curent
|
||||
return SeqInOrder;
|
||||
@@ -1337,7 +1301,6 @@ EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
|
||||
}
|
||||
|
||||
void EQStream::SetState(EQStreamState state) {
|
||||
_eqp_mt
|
||||
MState.lock();
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Changing state from %d to %d" __L, State, state);
|
||||
State=state;
|
||||
@@ -1346,7 +1309,6 @@ void EQStream::SetState(EQStreamState state) {
|
||||
|
||||
|
||||
void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
|
||||
_eqp_mt
|
||||
bool outgoing_data = HasOutgoingData(); //up here to avoid recursive locking
|
||||
|
||||
EQStreamState orig_state = GetState();
|
||||
@@ -1385,7 +1347,6 @@ void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
|
||||
|
||||
void EQStream::Decay()
|
||||
{
|
||||
_eqp_mt
|
||||
MRate.lock();
|
||||
uint32 rate=DecayRate;
|
||||
MRate.unlock();
|
||||
@@ -1398,7 +1359,6 @@ void EQStream::Decay()
|
||||
|
||||
void EQStream::AdjustRates(uint32 average_delta)
|
||||
{
|
||||
_eqp_mt
|
||||
if(GetExecutablePlatform() == ExePlatformWorld || GetExecutablePlatform() == ExePlatformZone) {
|
||||
if (average_delta && (average_delta <= AVERAGE_DELTA_MAX)) {
|
||||
MRate.lock();
|
||||
@@ -1424,7 +1384,6 @@ void EQStream::AdjustRates(uint32 average_delta)
|
||||
}
|
||||
|
||||
void EQStream::Close() {
|
||||
_eqp_mt
|
||||
if(HasOutgoingData()) {
|
||||
//there is pending data, wait for it to go out.
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Stream requested to Close(), but there is pending data, waiting for it." __L);
|
||||
@@ -1441,7 +1400,6 @@ void EQStream::Close() {
|
||||
//this could be expanded to check more than the fitst opcode if
|
||||
//we needed more complex matching
|
||||
EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
|
||||
_eqp_mt
|
||||
EQRawApplicationPacket *p = nullptr;
|
||||
MatchState res = MatchNotReady;
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
|
||||
|
||||
void EQStreamFactory::Close()
|
||||
{
|
||||
_eqp_mt
|
||||
Stop();
|
||||
|
||||
#ifdef _WINDOWS
|
||||
@@ -78,7 +77,6 @@ void EQStreamFactory::Close()
|
||||
|
||||
bool EQStreamFactory::Open()
|
||||
{
|
||||
_eqp_mt
|
||||
struct sockaddr_in address;
|
||||
#ifndef WIN32
|
||||
pthread_t t1,t2;
|
||||
@@ -120,7 +118,6 @@ bool EQStreamFactory::Open()
|
||||
|
||||
std::shared_ptr<EQStream> EQStreamFactory::Pop()
|
||||
{
|
||||
_eqp_mt
|
||||
std::shared_ptr<EQStream> s = nullptr;
|
||||
MNewStreams.lock();
|
||||
if (NewStreams.size()) {
|
||||
@@ -135,7 +132,6 @@ std::shared_ptr<EQStream> EQStreamFactory::Pop()
|
||||
|
||||
void EQStreamFactory::Push(std::shared_ptr<EQStream> s)
|
||||
{
|
||||
_eqp_mt
|
||||
MNewStreams.lock();
|
||||
NewStreams.push(s);
|
||||
MNewStreams.unlock();
|
||||
@@ -220,7 +216,6 @@ void EQStreamFactory::ReaderLoop()
|
||||
|
||||
void EQStreamFactory::CheckTimeout()
|
||||
{
|
||||
_eqp_mt
|
||||
//lock streams the entire time were checking timeouts, it should be fast.
|
||||
MStreams.lock();
|
||||
|
||||
|
||||
@@ -89,7 +89,6 @@ EQEmuLogSys::~EQEmuLogSys()
|
||||
|
||||
void EQEmuLogSys::LoadLogSettingsDefaults()
|
||||
{
|
||||
_eqp_mt
|
||||
/* Get Executable platform currently running this code (Zone/World/etc) */
|
||||
log_platform = GetExecutablePlatformInt();
|
||||
|
||||
@@ -124,7 +123,6 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
|
||||
|
||||
std::string EQEmuLogSys::FormatOutMessageString(uint16 log_category, const std::string &in_message)
|
||||
{
|
||||
_eqp_mt
|
||||
std::string category_string;
|
||||
if (log_category > 0 && Logs::LogCategoryName[log_category])
|
||||
category_string = StringFormat("[%s] ", Logs::LogCategoryName[log_category]);
|
||||
@@ -133,7 +131,6 @@ std::string EQEmuLogSys::FormatOutMessageString(uint16 log_category, const std::
|
||||
|
||||
void EQEmuLogSys::ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message)
|
||||
{
|
||||
_eqp_mt
|
||||
/* Check if category enabled for process */
|
||||
if (log_settings[log_category].log_to_gmsay == 0)
|
||||
return;
|
||||
@@ -153,7 +150,6 @@ void EQEmuLogSys::ProcessGMSay(uint16 debug_level, uint16 log_category, const st
|
||||
|
||||
void EQEmuLogSys::ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message)
|
||||
{
|
||||
_eqp_mt
|
||||
if (log_category == Logs::Crash) {
|
||||
char time_stamp[80];
|
||||
EQEmuLogSys::SetCurrentTimeStamp(time_stamp);
|
||||
@@ -180,7 +176,6 @@ void EQEmuLogSys::ProcessLogWrite(uint16 debug_level, uint16 log_category, const
|
||||
}
|
||||
|
||||
uint16 EQEmuLogSys::GetWindowsConsoleColorFromCategory(uint16 log_category) {
|
||||
_eqp_mt
|
||||
switch (log_category) {
|
||||
case Logs::Status:
|
||||
case Logs::Normal:
|
||||
@@ -204,7 +199,6 @@ uint16 EQEmuLogSys::GetWindowsConsoleColorFromCategory(uint16 log_category) {
|
||||
}
|
||||
|
||||
std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category) {
|
||||
_eqp_mt
|
||||
switch (log_category) {
|
||||
case Logs::Status:
|
||||
case Logs::Normal:
|
||||
@@ -228,7 +222,6 @@ std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category) {
|
||||
}
|
||||
|
||||
uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category) {
|
||||
_eqp_mt
|
||||
switch (log_category) {
|
||||
case Logs::Status:
|
||||
case Logs::Normal:
|
||||
@@ -253,7 +246,6 @@ uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category) {
|
||||
|
||||
void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message)
|
||||
{
|
||||
_eqp_mt
|
||||
/* Check if category enabled for process */
|
||||
if (log_settings[log_category].log_to_console == 0)
|
||||
return;
|
||||
@@ -281,7 +273,6 @@ void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category,
|
||||
|
||||
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_file = log_settings[log_category].log_to_file > 0;
|
||||
const bool log_to_gmsay = log_settings[log_category].log_to_gmsay > 0;
|
||||
@@ -303,7 +294,6 @@ void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::st
|
||||
|
||||
void EQEmuLogSys::SetCurrentTimeStamp(char* time_stamp)
|
||||
{
|
||||
_eqp_mt
|
||||
time_t raw_time;
|
||||
struct tm * time_info;
|
||||
time(&raw_time);
|
||||
@@ -313,7 +303,6 @@ void EQEmuLogSys::SetCurrentTimeStamp(char* time_stamp)
|
||||
|
||||
void EQEmuLogSys::MakeDirectory(const std::string &directory_name)
|
||||
{
|
||||
_eqp_mt
|
||||
#ifdef _WINDOWS
|
||||
struct _stat st;
|
||||
if (_stat(directory_name.c_str(), &st) == 0) // exists
|
||||
@@ -329,7 +318,6 @@ void EQEmuLogSys::MakeDirectory(const std::string &directory_name)
|
||||
|
||||
void EQEmuLogSys::CloseFileLogs()
|
||||
{
|
||||
_eqp_mt
|
||||
if (process_log.is_open()) {
|
||||
process_log.close();
|
||||
}
|
||||
@@ -337,7 +325,6 @@ void EQEmuLogSys::CloseFileLogs()
|
||||
|
||||
void EQEmuLogSys::StartFileLogs(const std::string &log_name)
|
||||
{
|
||||
_eqp_mt
|
||||
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... */
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "uuid.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <rpc.h>
|
||||
#else
|
||||
#include <uuid/uuid.h>
|
||||
#endif
|
||||
|
||||
std::string CreateUUID() {
|
||||
#ifdef WIN32
|
||||
UUID uuid;
|
||||
UuidCreate(&uuid);
|
||||
unsigned char *str = nullptr;
|
||||
UuidToStringA(&uuid, &str);
|
||||
std::string s((char*)str);
|
||||
RpcStringFreeA(&str);
|
||||
return s;
|
||||
#else
|
||||
char str[64] = { 0 };
|
||||
uuid_t uuid;
|
||||
uuid_generate_random(uuid);
|
||||
uuid_unparse(uuid, str);
|
||||
return str;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef COMMON_UUID_H
|
||||
#define COMMON_UUID_H
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string CreateUUID();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user