Merge from master

This commit is contained in:
KimLS 2013-05-06 00:05:50 -07:00
commit ac1d931b5e
216 changed files with 4167 additions and 4142 deletions

View File

@ -24,7 +24,7 @@
BasePacket::BasePacket(const unsigned char *buf, uint32 len) BasePacket::BasePacket(const unsigned char *buf, uint32 len)
{ {
this->pBuffer=NULL; this->pBuffer=nullptr;
this->size=0; this->size=0;
this->_wpos = 0; this->_wpos = 0;
this->_rpos = 0; this->_rpos = 0;
@ -44,7 +44,7 @@ BasePacket::~BasePacket()
{ {
if (pBuffer) if (pBuffer)
delete[] pBuffer; delete[] pBuffer;
pBuffer=NULL; pBuffer=nullptr;
} }

View File

@ -79,7 +79,7 @@ public:
protected: protected:
virtual ~BasePacket(); virtual ~BasePacket();
BasePacket() { pBuffer=NULL; size=0; _wpos = 0; _rpos = 0; } BasePacket() { pBuffer=nullptr; size=0; _wpos = 0; _rpos = 0; }
BasePacket(const unsigned char *buf, const uint32 len); BasePacket(const unsigned char *buf, const uint32 len);
}; };

View File

@ -31,14 +31,14 @@
Condition::Condition() Condition::Condition()
{ {
m_events[SignalEvent] = CreateEvent (NULL, // security m_events[SignalEvent] = CreateEvent (nullptr, // security
FALSE, // is auto-reset event? FALSE, // is auto-reset event?
FALSE, // is signaled initially? FALSE, // is signaled initially?
NULL); // name nullptr); // name
m_events[BroadcastEvent] = CreateEvent (NULL, // security m_events[BroadcastEvent] = CreateEvent (nullptr, // security
TRUE, // is auto-reset event? TRUE, // is auto-reset event?
FALSE, // is signaled initially? FALSE, // is signaled initially?
NULL); // name nullptr); // name
m_waiters = 0; m_waiters = 0;
InitializeCriticalSection(&CSMutex); InitializeCriticalSection(&CSMutex);
} }
@ -92,8 +92,8 @@ void Condition::Wait()
Condition::Condition() Condition::Condition()
{ {
pthread_cond_init(&cond,NULL); pthread_cond_init(&cond,nullptr);
pthread_mutex_init(&mutex,NULL); pthread_mutex_init(&mutex,nullptr);
} }
void Condition::Signal() void Condition::Signal()
@ -129,7 +129,7 @@ struct timeval now;
struct timespec timeout; struct timespec timeout;
int retcode=0; int retcode=0;
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
gettimeofday(&now,NULL); gettimeofday(&now,nullptr);
now.tv_usec+=usec; now.tv_usec+=usec;
timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000); timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000);
timeout.tv_nsec = (now.tv_usec%1000000) *1000; timeout.tv_nsec = (now.tv_usec%1000000) *1000;

View File

@ -53,11 +53,11 @@ EQDBRes * EQDB::query(Const_char *q) {
return new EQDBRes(r); return new EQDBRes(r);
} else { } else {
//no result, give them back a 'true but empty' result set //no result, give them back a 'true but empty' result set
return(new EQDBRes(NULL)); return(new EQDBRes(nullptr));
} }
} }
return NULL; return nullptr;
} }
//NOT THREAD SAFE! //NOT THREAD SAFE!

View File

@ -21,7 +21,7 @@
vector<string> EQDBRes::fetch_row_array() { vector<string> EQDBRes::fetch_row_array() {
vector<string> array; vector<string> array;
if(res == NULL) if(res == nullptr)
return(array); return(array);
int count=mysql_num_fields(res); int count=mysql_num_fields(res);
@ -34,14 +34,14 @@ vector<string> EQDBRes::fetch_row_array() {
map<string,string> EQDBRes::fetch_row_hash() { map<string,string> EQDBRes::fetch_row_hash() {
map<string,string> rowhash; map<string,string> rowhash;
if(res == NULL) if(res == nullptr)
return(rowhash); return(rowhash);
MYSQL_FIELD *fields; MYSQL_FIELD *fields;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long num_fields,i; unsigned long num_fields,i;
if (res && (num_fields=mysql_num_fields(res)) && (row = mysql_fetch_row(res))!=NULL && (fields = mysql_fetch_fields(res))!=NULL) { if (res && (num_fields=mysql_num_fields(res)) && (row = mysql_fetch_row(res))!=nullptr && (fields = mysql_fetch_fields(res))!=nullptr) {
for(i=0;i<num_fields;i++) { for(i=0;i<num_fields;i++) {
rowhash[fields[i].name]=(row[i] ? row[i] : ""); rowhash[fields[i].name]=(row[i] ? row[i] : "");
} }

View File

@ -35,7 +35,7 @@ public:
unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; } unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; }
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; } unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
void DESTROY() { } void DESTROY() { }
void finish() { if (res) mysql_free_result(res); res=NULL; }; void finish() { if (res) mysql_free_result(res); res=nullptr; };
vector<string> fetch_row_array(); vector<string> fetch_row_array();
map<string,string> fetch_row_hash(); map<string,string> fetch_row_hash();
unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; } unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; }

View File

@ -22,7 +22,7 @@
#include <sstream> #include <sstream>
string EQEmuConfig::ConfigFile = "eqemu_config.xml"; string EQEmuConfig::ConfigFile = "eqemu_config.xml";
EQEmuConfig *EQEmuConfig::_config = NULL; EQEmuConfig *EQEmuConfig::_config = nullptr;
void EQEmuConfig::do_world(TiXmlElement *ele) { void EQEmuConfig::do_world(TiXmlElement *ele) {
const char *text; const char *text;
@ -100,12 +100,12 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
// Check for locked // Check for locked
sub_ele = ele->FirstChildElement("locked"); sub_ele = ele->FirstChildElement("locked");
if (sub_ele != NULL) if (sub_ele != nullptr)
Locked=true; Locked=true;
// Get the <tcp> element // Get the <tcp> element
sub_ele = ele->FirstChildElement("tcp"); sub_ele = ele->FirstChildElement("tcp");
if(sub_ele != NULL) { if(sub_ele != nullptr) {
text = sub_ele->Attribute("ip"); text = sub_ele->Attribute("ip");
if (text) if (text)
@ -123,7 +123,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
// Get the <http> element // Get the <http> element
sub_ele = ele->FirstChildElement("http"); sub_ele = ele->FirstChildElement("http");
if(sub_ele != NULL) { if(sub_ele != nullptr) {
// text = sub_ele->Attribute("ip"); // text = sub_ele->Attribute("ip");
// if (text) // if (text)
@ -228,7 +228,7 @@ void EQEmuConfig::do_zones(TiXmlElement *ele) {
// Get the <ports> element // Get the <ports> element
sub_ele = ele->FirstChildElement("ports"); sub_ele = ele->FirstChildElement("ports");
if(sub_ele != NULL) { if(sub_ele != nullptr) {
text = sub_ele->Attribute("low"); text = sub_ele->Attribute("low");
if (text) if (text)
@ -296,7 +296,7 @@ void EQEmuConfig::do_launcher(TiXmlElement *ele) {
// Get the <timers> element // Get the <timers> element
sub_ele = ele->FirstChildElement("timers"); sub_ele = ele->FirstChildElement("timers");
if(sub_ele != NULL) { if(sub_ele != nullptr) {
text = sub_ele->Attribute("restart"); text = sub_ele->Attribute("restart");
if (text) if (text)
RestartWait = atoi(text); RestartWait = atoi(text);

View File

@ -204,7 +204,7 @@ public:
// Produce a const singleton // Produce a const singleton
static const EQEmuConfig *get() { static const EQEmuConfig *get() {
if (_config == NULL) if (_config == nullptr)
LoadConfig(); LoadConfig();
return(_config); return(_config);
} }
@ -214,7 +214,7 @@ public:
// Load the config // Load the config
static bool LoadConfig() { static bool LoadConfig() {
if (_config != NULL) if (_config != nullptr)
delete _config; delete _config;
_config=new EQEmuConfig; _config=new EQEmuConfig;

View File

@ -248,7 +248,7 @@ uint32 offset;
memcpy(pBuffer,buf+offset,len-offset); memcpy(pBuffer,buf+offset,len-offset);
size=len-offset; size=len-offset;
} else { } else {
pBuffer=NULL; pBuffer=nullptr;
size=0; size=0;
} }
OpMgr=&RawOpcodeManager; OpMgr=&RawOpcodeManager;
@ -294,7 +294,7 @@ get running again... but might be a good thing some day.
bool EQApplicationPacket::combine(const EQApplicationPacket *rhs) bool EQApplicationPacket::combine(const EQApplicationPacket *rhs)
{ {
uint32 newsize=0, offset=0; uint32 newsize=0, offset=0;
unsigned char *tmpbuffer=NULL; unsigned char *tmpbuffer=nullptr;
if (opcode!=OP_AppCombined) { if (opcode!=OP_AppCombined) {
newsize=app_opcode_size+size+(size>254?3:1)+app_opcode_size+rhs->size+(rhs->size>254?3:1); newsize=app_opcode_size+size+(size>254?3:1)+app_opcode_size+rhs->size+(rhs->size>254?3:1);

View File

@ -58,7 +58,7 @@ protected:
EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len); EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len);
// EQPacket(const EQPacket &p) { } // EQPacket(const EQPacket &p) { }
EQPacket() { emu_opcode=OP_Unknown; pBuffer=NULL; size=0; } EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; }
}; };
@ -102,11 +102,11 @@ class EQApplicationPacket : public EQPacket {
// friend class EQProtocolPacket; // friend class EQProtocolPacket;
friend class EQStream; friend class EQStream;
public: public:
EQApplicationPacket() : EQPacket(OP_Unknown,NULL,0) EQApplicationPacket() : EQPacket(OP_Unknown,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op) : EQPacket(op,NULL,0) EQApplicationPacket(const EmuOpcode op) : EQPacket(op,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,NULL,len) EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,nullptr,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len) EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }

View File

@ -65,7 +65,7 @@ void EQStream::init() {
LastAckSent=-1; LastAckSent=-1;
MaxSends=5; MaxSends=5;
LastPacket=0; LastPacket=0;
oversize_buffer=NULL; oversize_buffer=nullptr;
oversize_length=0; oversize_length=0;
oversize_offset=0; oversize_offset=0;
RateThreshold=RATEBASE/250; RateThreshold=RATEBASE/250;
@ -77,7 +77,7 @@ void EQStream::init() {
retransmittimer = Timer::GetCurrentTime(); retransmittimer = Timer::GetCurrentTime();
retransmittimeout = 500 * RuleR(EQStream, RetransmitTimeoutMult); //use 500ms as base before we have connection stats retransmittimeout = 500 * RuleR(EQStream, RetransmitTimeoutMult); //use 500ms as base before we have connection stats
#endif #endif
OpMgr = NULL; OpMgr = nullptr;
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
_log(NET__ERROR, _L "init Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); _log(NET__ERROR, _L "init Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
} }
@ -88,7 +88,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p) EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
{ {
EQRawApplicationPacket *ap=NULL; EQRawApplicationPacket *ap=nullptr;
_log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, p->size); _log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, p->size);
_raw(NET__APP_CREATE_HEX, 0xFFFF, p); _raw(NET__APP_CREATE_HEX, 0xFFFF, p);
ap = p->MakeAppPacket(); ap = p->MakeAppPacket();
@ -97,7 +97,7 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len) EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len)
{ {
EQRawApplicationPacket *ap=NULL; EQRawApplicationPacket *ap=nullptr;
_log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, len); _log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, len);
_hex(NET__APP_CREATE_HEX, buf, len); _hex(NET__APP_CREATE_HEX, buf, len);
ap = new EQRawApplicationPacket(buf, len); ap = new EQRawApplicationPacket(buf, len);
@ -117,7 +117,7 @@ EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32
void EQStream::ProcessPacket(EQProtocolPacket *p) void EQStream::ProcessPacket(EQProtocolPacket *p)
{ {
uint32 processed=0,subpacket_length=0; uint32 processed=0,subpacket_length=0;
if (p == NULL) if (p == nullptr)
return; return;
// Raw Application packet // Raw Application packet
if (p->opcode > 0xff) { if (p->opcode > 0xff) {
@ -153,7 +153,7 @@ uint32 processed=0,subpacket_length=0;
case OP_AppCombined: { case OP_AppCombined: {
processed=0; processed=0;
while(processed<p->size) { while(processed<p->size) {
EQRawApplicationPacket *ap=NULL; EQRawApplicationPacket *ap=nullptr;
if ((subpacket_length=(unsigned char)*(p->pBuffer+processed))!=0xff) { if ((subpacket_length=(unsigned char)*(p->pBuffer+processed))!=0xff) {
_log(NET__NET_CREATE, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length); _log(NET__NET_CREATE, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length);
ap=MakeApplicationPacket(p->pBuffer+processed+1,subpacket_length); ap=MakeApplicationPacket(p->pBuffer+processed+1,subpacket_length);
@ -273,7 +273,7 @@ uint32 processed=0,subpacket_length=0;
} }
} }
delete[] oversize_buffer; delete[] oversize_buffer;
oversize_buffer=NULL; oversize_buffer=nullptr;
oversize_offset=0; oversize_offset=0;
} }
} else { } else {
@ -500,24 +500,24 @@ if(NextSequencedSend > SequencedQueue.size()) {
void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req) void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
{ {
if(p == NULL) if(p == nullptr)
return; return;
EQApplicationPacket *newp = p->Copy(); EQApplicationPacket *newp = p->Copy();
if (newp != NULL) if (newp != nullptr)
FastQueuePacket(&newp, ack_req); FastQueuePacket(&newp, ack_req);
} }
void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req) void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
{ {
EQApplicationPacket *pack=*p; EQApplicationPacket *pack=*p;
*p = NULL; //clear caller's pointer.. effectively takes ownership *p = nullptr; //clear caller's pointer.. effectively takes ownership
if(pack == NULL) if(pack == nullptr)
return; return;
if(OpMgr == NULL || *OpMgr == NULL) { if(OpMgr == nullptr || *OpMgr == nullptr) {
_log(NET__DEBUG, _L "Packet enqueued into a stream with no opcode manager, dropping." __L); _log(NET__DEBUG, _L "Packet enqueued into a stream with no opcode manager, dropping." __L);
delete pack; delete pack;
return; return;
@ -557,7 +557,7 @@ uint32 length;
unsigned char *tmpbuff=new unsigned char[p->size+3]; unsigned char *tmpbuff=new unsigned char[p->size+3];
length=p->serialize(opcode, tmpbuff); length=p->serialize(opcode, tmpbuff);
EQProtocolPacket *out=new EQProtocolPacket(OP_Fragment,NULL,MaxLen-4); EQProtocolPacket *out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
*(uint32 *)(out->pBuffer+2)=htonl(p->Size()); *(uint32 *)(out->pBuffer+2)=htonl(p->Size());
used=MaxLen-10; used=MaxLen-10;
memcpy(out->pBuffer+6,tmpbuff,used); memcpy(out->pBuffer+6,tmpbuff,used);
@ -566,7 +566,7 @@ uint32 length;
while (used<length) { while (used<length) {
out=new EQProtocolPacket(OP_Fragment,NULL,MaxLen-4); out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
chunksize=min(length-used,MaxLen-6); chunksize=min(length-used,MaxLen-6);
memcpy(out->pBuffer+2,tmpbuff+used,chunksize); memcpy(out->pBuffer+2,tmpbuff+used,chunksize);
out->size=chunksize+2; out->size=chunksize+2;
@ -669,7 +669,7 @@ deque<EQProtocolPacket *>::iterator sitr;
MOutboundQueue.lock(); MOutboundQueue.lock();
// Place to hold the base packet t combine into // Place to hold the base packet t combine into
EQProtocolPacket *p=NULL; EQProtocolPacket *p=nullptr;
#ifdef RETRANSMITS #ifdef RETRANSMITS
// if we have a timeout defined and we have not received an ack recently enough, retransmit from beginning of queue // if we have a timeout defined and we have not received an ack recently enough, retransmit from beginning of queue
@ -702,7 +702,7 @@ deque<EQProtocolPacket *>::iterator sitr;
_log(NET__NET_COMBINE, _L "Combined packet full at len %d, next non-seq packet is len %d" __L, p->size, (NonSequencedQueue.front())->size); _log(NET__NET_COMBINE, _L "Combined packet full at len %d, next non-seq packet is len %d" __L, p->size, (NonSequencedQueue.front())->size);
ReadyToSend.push(p); ReadyToSend.push(p);
BytesWritten+=p->size; BytesWritten+=p->size;
p=NULL; p=nullptr;
if (BytesWritten > threshold) { if (BytesWritten > threshold) {
// Sent enough this round, lets stop to be fair // Sent enough this round, lets stop to be fair
@ -761,7 +761,7 @@ continue;
_log(NET__NET_COMBINE, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send, (*sitr)->size); _log(NET__NET_COMBINE, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send, (*sitr)->size);
ReadyToSend.push(p); ReadyToSend.push(p);
BytesWritten+=p->size; BytesWritten+=p->size;
p=NULL; p=nullptr;
if (BytesWritten > threshold) { if (BytesWritten > threshold) {
// Sent enough this round, lets stop to be fair // Sent enough this round, lets stop to be fair
@ -864,7 +864,7 @@ EQProtocolPacket *EQStream::Read(int eq_fd, sockaddr_in *from)
{ {
int socklen; int socklen;
int length=0; int length=0;
EQProtocolPacket *p=NULL; EQProtocolPacket *p=nullptr;
char temp[15]; char temp[15];
socklen=sizeof(sockaddr); socklen=sizeof(sockaddr);
@ -893,7 +893,7 @@ char temp[15];
void EQStream::SendSessionResponse() void EQStream::SendSessionResponse()
{ {
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,NULL,sizeof(SessionResponse)); 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);
@ -915,10 +915,10 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,NULL,sizeof(Sessio
void EQStream::SendSessionRequest() void EQStream::SendSessionRequest()
{ {
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,NULL,sizeof(SessionRequest)); 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(NULL)); Request->Session=htonl(time(nullptr));
Request->MaxLength=htonl(512); Request->MaxLength=htonl(512);
_log(NET__NET_TRACE, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength)); _log(NET__NET_TRACE, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength));
@ -931,7 +931,7 @@ void EQStream::_SendDisconnect()
if(GetState() == CLOSED) if(GetState() == CLOSED)
return; return;
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionDisconnect,NULL,sizeof(uint32)); EQProtocolPacket *out=new EQProtocolPacket(OP_SessionDisconnect,nullptr,sizeof(uint32));
*(uint32 *)out->pBuffer=htonl(Session); *(uint32 *)out->pBuffer=htonl(Session);
NonSequencedPush(out); NonSequencedPush(out);
@ -947,7 +947,7 @@ void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
EQApplicationPacket *EQStream::PopPacket() EQApplicationPacket *EQStream::PopPacket()
{ {
EQRawApplicationPacket *p=NULL; EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
@ -959,7 +959,7 @@ EQRawApplicationPacket *p=NULL;
//resolve the opcode if we can. //resolve the opcode if we can.
if(p) { if(p) {
if(OpMgr != NULL && *OpMgr != NULL) { if(OpMgr != nullptr && *OpMgr != nullptr) {
EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode); EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode);
#if EQDEBUG >= 4 #if EQDEBUG >= 4
if(emu_op == OP_Unknown) { if(emu_op == OP_Unknown) {
@ -975,7 +975,7 @@ EQRawApplicationPacket *p=NULL;
EQRawApplicationPacket *EQStream::PopRawPacket() EQRawApplicationPacket *EQStream::PopRawPacket()
{ {
EQRawApplicationPacket *p=NULL; EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
@ -987,7 +987,7 @@ EQRawApplicationPacket *p=NULL;
//resolve the opcode if we can. //resolve the opcode if we can.
if(p) { if(p) {
if(OpMgr != NULL && *OpMgr != NULL) { if(OpMgr != nullptr && *OpMgr != nullptr) {
EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode); EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode);
#if EQDEBUG >= 4 #if EQDEBUG >= 4
if(emu_op == OP_Unknown) { if(emu_op == OP_Unknown) {
@ -1003,7 +1003,7 @@ EQRawApplicationPacket *p=NULL;
EQRawApplicationPacket *EQStream::PeekPacket() EQRawApplicationPacket *EQStream::PeekPacket()
{ {
EQRawApplicationPacket *p=NULL; EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
@ -1017,7 +1017,7 @@ EQRawApplicationPacket *p=NULL;
void EQStream::InboundQueueClear() void EQStream::InboundQueueClear()
{ {
EQApplicationPacket *p=NULL; EQApplicationPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing inbound queue" __L); _log(NET__APP_TRACE, _L "Clearing inbound queue" __L);
@ -1060,7 +1060,7 @@ bool flag;
void EQStream::OutboundQueueClear() void EQStream::OutboundQueueClear()
{ {
EQProtocolPacket *p=NULL; EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing outbound queue" __L); _log(NET__APP_TRACE, _L "Clearing outbound queue" __L);
@ -1090,7 +1090,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
void EQStream::PacketQueueClear() void EQStream::PacketQueueClear()
{ {
EQProtocolPacket *p=NULL; EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L); _log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
@ -1223,8 +1223,8 @@ void EQStream::ProcessQueue()
return; return;
} }
EQProtocolPacket *qp=NULL; EQProtocolPacket *qp=nullptr;
while((qp=RemoveQueue(NextInSeq))!=NULL) { while((qp=RemoveQueue(NextInSeq))!=nullptr) {
_log(NET__DEBUG, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq); _log(NET__DEBUG, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq);
ProcessPacket(qp); ProcessPacket(qp);
delete qp; delete qp;
@ -1235,7 +1235,7 @@ void EQStream::ProcessQueue()
EQProtocolPacket *EQStream::RemoveQueue(uint16 seq) EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
{ {
map<unsigned short,EQProtocolPacket *>::iterator itr; map<unsigned short,EQProtocolPacket *>::iterator itr;
EQProtocolPacket *qp=NULL; 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);
@ -1408,7 +1408,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) {
EQRawApplicationPacket *p = NULL; EQRawApplicationPacket *p = nullptr;
MatchState res = MatchNotReady; MatchState res = MatchNotReady;
MInboundQueue.lock(); MInboundQueue.lock();
@ -1419,10 +1419,10 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
if(InboundQueue.size() > 1) { if(InboundQueue.size() > 1) {
p = InboundQueue[1]; p = InboundQueue[1];
} else { } else {
p = NULL; p = nullptr;
} }
} }
if(p == NULL) { if(p == nullptr) {
//first opcode is ignored, and nothing else remains... keep waiting //first opcode is ignored, and nothing else remains... keep waiting
} else if(p->opcode == sig->first_eq_opcode) { } else if(p->opcode == sig->first_eq_opcode) {
//opcode matches, check length.. //opcode matches, check length..

View File

@ -35,7 +35,7 @@ EQStreamFactory *fs=(EQStreamFactory *)eqfs;
_log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs) ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
@ -52,7 +52,7 @@ ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
_log(COMMON__THREADS, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout) EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
@ -112,15 +112,15 @@ struct sockaddr_in address;
_beginthread(EQStreamFactoryReaderLoop,0, this); _beginthread(EQStreamFactoryReaderLoop,0, this);
_beginthread(EQStreamFactoryWriterLoop,0, this); _beginthread(EQStreamFactoryWriterLoop,0, this);
#else #else
pthread_create(&t1,NULL,EQStreamFactoryReaderLoop,this); pthread_create(&t1,nullptr,EQStreamFactoryReaderLoop,this);
pthread_create(&t2,NULL,EQStreamFactoryWriterLoop,this); pthread_create(&t2,nullptr,EQStreamFactoryWriterLoop,this);
#endif #endif
return true; return true;
} }
EQStream *EQStreamFactory::Pop() EQStream *EQStreamFactory::Pop()
{ {
EQStream *s=NULL; EQStream *s=nullptr;
//cout << "Pop():Locking MNewStreams" << endl; //cout << "Pop():Locking MNewStreams" << endl;
MNewStreams.lock(); MNewStreams.lock();
if (NewStreams.size()) { if (NewStreams.size()) {
@ -167,7 +167,7 @@ timeval sleep_time;
sleep_time.tv_sec=30; sleep_time.tv_sec=30;
sleep_time.tv_usec=0; sleep_time.tv_usec=0;
if ((num=select(sock+1,&readset,NULL,NULL,&sleep_time))<0) { if ((num=select(sock+1,&readset,nullptr,nullptr,&sleep_time))<0) {
// What do we wanna do? // What do we wanna do?
continue; continue;
} else if (num==0) } else if (num==0)
@ -204,7 +204,7 @@ timeval sleep_time;
EQStream *curstream = stream_itr->second; EQStream *curstream = stream_itr->second;
//dont bother processing incoming packets for closed connections //dont bother processing incoming packets for closed connections
if(curstream->CheckClosed()) if(curstream->CheckClosed())
curstream = NULL; curstream = nullptr;
else else
curstream->PutInUse(); curstream->PutInUse();
MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it. MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it.
@ -293,8 +293,8 @@ Timer DecayTimer(20);
stream_itr->second->Decay(); stream_itr->second->Decay();
//bullshit checking, to see if this is really happening, GDB seems to think so... //bullshit checking, to see if this is really happening, GDB seems to think so...
if(stream_itr->second == NULL) { if(stream_itr->second == nullptr) {
fprintf(stderr, "ERROR: NULL Stream encountered in EQStreamFactory::WriterLoop for: %s", stream_itr->first.c_str()); fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %s", stream_itr->first.c_str());
continue; continue;
} }

View File

@ -146,12 +146,12 @@ void EQStreamIdentifier::Process() {
void EQStreamIdentifier::AddStream(EQStream *&eqs) { void EQStreamIdentifier::AddStream(EQStream *&eqs) {
m_streams.push_back(new Record(eqs)); m_streams.push_back(new Record(eqs));
eqs = NULL; eqs = nullptr;
} }
EQStreamInterface *EQStreamIdentifier::PopIdentified() { EQStreamInterface *EQStreamIdentifier::PopIdentified() {
if(m_identified.empty()) if(m_identified.empty())
return(NULL); return(nullptr);
EQStreamInterface *res = m_identified.front(); EQStreamInterface *res = m_identified.front();
m_identified.pop(); m_identified.pop();
return(res); return(res);

View File

@ -99,7 +99,7 @@ inline bool operator==(const EQStreamInfo &l, const EQStreamInfo &r) {
return(l.src_ip == r.src_ip && l.src_port == r.src_port && l.dst_ip == r.dst_ip && l.dst_port == r.dst_port); return(l.src_ip == r.src_ip && l.src_port == r.src_port && l.dst_ip == r.dst_ip && l.dst_port == r.dst_port);
} }
//Forces the pointer T thing so we can return NULL //Forces the pointer T thing so we can return nullptr
template <class T> template <class T>
class EQStreamLocator { class EQStreamLocator {
protected: protected:
@ -157,7 +157,7 @@ public:
//may not be a constant time operation in theory, and update our //may not be a constant time operation in theory, and update our
//stored copy only on insert or delete //stored copy only on insert or delete
if(res == streams.end()) if(res == streams.end())
return(NULL); return(nullptr);
return(res->second); return(res->second);
} }

View File

@ -10,7 +10,7 @@ EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, O
m_structs(structs), m_structs(structs),
m_opcodes(opcodes) m_opcodes(opcodes)
{ {
stream = NULL; //take the stream. stream = nullptr; //take the stream.
m_stream->SetOpcodeManager(m_opcodes); m_stream->SetOpcodeManager(m_opcodes);
} }
@ -28,7 +28,7 @@ const EQClientVersion EQStreamProxy::ClientVersion() const
} }
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) { void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
if(p == NULL) if(p == nullptr)
return; return;
EQApplicationPacket *newp = p->Copy(); EQApplicationPacket *newp = p->Copy();
@ -36,15 +36,15 @@ void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
} }
void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) { void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) {
if(p == NULL || *p == NULL) if(p == nullptr || *p == nullptr)
return; return;
m_structs->Encode(p, m_stream, ack_req); m_structs->Encode(p, m_stream, ack_req);
} }
EQApplicationPacket *EQStreamProxy::PopPacket() { EQApplicationPacket *EQStreamProxy::PopPacket() {
EQApplicationPacket *pack = m_stream->PopPacket(); EQApplicationPacket *pack = m_stream->PopPacket();
if(pack == NULL) if(pack == nullptr)
return(NULL); return(nullptr);
//pass this packet through the struct strategy. //pass this packet through the struct strategy.
m_structs->Decode(pack); m_structs->Decode(pack);

View File

@ -76,7 +76,7 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_s
timeout_timer(SERVER_TIMEOUT * 2) timeout_timer(SERVER_TIMEOUT * 2)
{ {
id = 0; id = 0;
Server = NULL; Server = nullptr;
pOldFormat = iOldFormat; pOldFormat = iOldFormat;
#ifdef MINILOGIN #ifdef MINILOGIN
TCPMode = modePacket; TCPMode = modePacket;
@ -282,7 +282,7 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
ServerPacket* EmuTCPConnection::PopPacket() { ServerPacket* EmuTCPConnection::PopPacket() {
ServerPacket* ret; ServerPacket* ret;
if (!MOutQueueLock.trylock()) if (!MOutQueueLock.trylock())
return NULL; return nullptr;
ret = OutQueue.pop(); ret = OutQueue.pop();
MOutQueueLock.unlock(); MOutQueueLock.unlock();
return ret; return ret;

View File

@ -42,7 +42,7 @@ void EmuTCPServer::SendPacket(EmuTCPNetPacket_Struct** tnps) {
MInQueue.lock(); MInQueue.lock();
m_InQueue.push(*tnps); m_InQueue.push(*tnps);
MInQueue.unlock(); MInQueue.unlock();
tnps = NULL; tnps = nullptr;
} }
void EmuTCPServer::CheckInQueue() { void EmuTCPServer::CheckInQueue() {
@ -61,7 +61,7 @@ void EmuTCPServer::CheckInQueue() {
} }
EmuTCPNetPacket_Struct* EmuTCPServer::InQueuePop() { EmuTCPNetPacket_Struct* EmuTCPServer::InQueuePop() {
EmuTCPNetPacket_Struct* ret = NULL; EmuTCPNetPacket_Struct* ret = nullptr;
MInQueue.lock(); MInQueue.lock();
if(!m_InQueue.empty()) { if(!m_InQueue.empty()) {
ret = m_InQueue.front(); ret = m_InQueue.front();
@ -80,7 +80,7 @@ EmuTCPConnection *EmuTCPServer::FindConnection(uint32 iID) {
if ((*cur)->GetID() == iID) if ((*cur)->GetID() == iID)
return *cur; return *cur;
} }
return(NULL); return(nullptr);
} }

View File

@ -162,13 +162,13 @@ ItemInst::ItemInst(const ItemInst& copy)
iter_contents it; iter_contents it;
for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) { for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = NULL; ItemInst* inst_new = nullptr;
if (inst_old) { if (inst_old) {
inst_new = inst_old->Clone(); inst_new = inst_old->Clone();
} }
if (inst_new != NULL) { if (inst_new != nullptr) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
} }
@ -293,7 +293,7 @@ uint32 ItemInst::GetItemID(uint8 slot) const
{ {
const ItemInst *item; const ItemInst *item;
uint32 id=0; uint32 id=0;
if ((item=GetItem(slot))!=NULL) if ((item=GetItem(slot))!=nullptr)
id= item->GetItem()->ID; id= item->GetItem()->ID;
return id; return id;
@ -330,7 +330,7 @@ ItemInst* ItemInst::GetAugment(uint8 slot) const
if (m_item->ItemClass == ItemClassCommon) if (m_item->ItemClass == ItemClassCommon)
return GetItem(slot); return GetItem(slot);
return NULL; return nullptr;
} }
// Remove augment from item and destroy it // Remove augment from item and destroy it
@ -346,7 +346,7 @@ ItemInst* ItemInst::RemoveAugment(uint8 index)
if (m_item->ItemClass == ItemClassCommon) if (m_item->ItemClass == ItemClassCommon)
return PopItem(index); return PopItem(index);
return NULL; return nullptr;
} }
// Add an augment to the item // Add an augment to the item
@ -377,7 +377,7 @@ ItemInst* ItemInst::GetItem(uint8 index) const
return inst; return inst;
} }
return NULL; return nullptr;
} }
void ItemInst::PutItem(uint8 index, const ItemInst& inst) void ItemInst::PutItem(uint8 index, const ItemInst& inst)
@ -472,7 +472,7 @@ ItemInst* ItemInst::PopItem(uint8 index)
} }
// Return pointer that needs to be deleted (or otherwise managed) // Return pointer that needs to be deleted (or otherwise managed)
return NULL; return nullptr;
} }
// Put item onto back of queue // Put item onto back of queue
@ -491,7 +491,7 @@ void ItemInstQueue::push_front(ItemInst* inst)
ItemInst* ItemInstQueue::pop() ItemInst* ItemInstQueue::pop()
{ {
if (m_list.size() == 0) if (m_list.size() == 0)
return NULL; return nullptr;
ItemInst* inst = m_list.front(); ItemInst* inst = m_list.front();
m_list.pop_front(); m_list.pop_front();
@ -501,14 +501,14 @@ ItemInst* ItemInstQueue::pop()
// Look at item at front of queue // Look at item at front of queue
ItemInst* ItemInstQueue::peek_front() const ItemInst* ItemInstQueue::peek_front() const
{ {
return (m_list.size()==0) ? NULL : m_list.front(); return (m_list.size()==0) ? nullptr : m_list.front();
} }
// Retrieve item at specified slot; returns false if item not found // Retrieve item at specified slot; returns false if item not found
ItemInst* Inventory::GetItem(int16 slot_id) const ItemInst* Inventory::GetItem(int16 slot_id) const
{ {
_CP(Inventory_GetItem); _CP(Inventory_GetItem);
ItemInst* result = NULL; ItemInst* result = nullptr;
// Cursor // Cursor
if (slot_id == SLOT_CURSOR) { if (slot_id == SLOT_CURSOR) {
@ -979,7 +979,7 @@ bool Inventory::CheckNoDrop(int16 slot_id) {
// Returns item pointer if full delete was successful // Returns item pointer if full delete was successful
ItemInst* Inventory::PopItem(int16 slot_id) ItemInst* Inventory::PopItem(int16 slot_id)
{ {
ItemInst* p = NULL; ItemInst* p = nullptr;
if (slot_id==SLOT_CURSOR) { // Cursor if (slot_id==SLOT_CURSOR) { // Cursor
p = m_cursor.pop(); p = m_cursor.pop();
@ -1007,7 +1007,7 @@ ItemInst* Inventory::PopItem(int16 slot_id)
else { else {
// Is slot inside bag? // Is slot inside bag?
ItemInst* baginst = GetItem(Inventory::CalcSlotId(slot_id)); ItemInst* baginst = GetItem(Inventory::CalcSlotId(slot_id));
if (baginst != NULL && baginst->IsType(ItemClassContainer)) { if (baginst != nullptr && baginst->IsType(ItemClassContainer)) {
p = baginst->PopItem(Inventory::CalcBagIdx(slot_id)); p = baginst->PopItem(Inventory::CalcBagIdx(slot_id));
} }
} }
@ -1063,7 +1063,7 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
void Inventory::dumpInventory() { void Inventory::dumpInventory() {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = NULL; ItemInst* inst = nullptr;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
printf("Worn items:\n"); printf("Worn items:\n");
@ -1168,15 +1168,15 @@ ItemInst* Inventory::_GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id
} }
// Not found! // Not found!
return NULL; return nullptr;
} }
// Internal Method: "put" item into bucket, without regard for what is currently in bucket // Internal Method: "put" item into bucket, without regard for what is currently in bucket
// Assumes item has already been allocated // Assumes item has already been allocated
int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst) int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
{ {
// If putting a NULL into slot, we need to remove slot without memory delete // If putting a nullptr into slot, we need to remove slot without memory delete
if (inst == NULL) { if (inst == nullptr) {
//Why do we not delete the poped item here???? //Why do we not delete the poped item here????
PopItem(slot_id); PopItem(slot_id);
return slot_id; return slot_id;
@ -1232,7 +1232,7 @@ int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 q
{ {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = NULL; ItemInst* inst = nullptr;
uint8 quantity_found = 0; uint8 quantity_found = 0;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
@ -1322,7 +1322,7 @@ int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 q
{ {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = NULL; ItemInst* inst = nullptr;
uint8 quantity_found = 0; uint8 quantity_found = 0;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
@ -1390,7 +1390,7 @@ int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loreg
{ {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = NULL; ItemInst* inst = nullptr;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
for (it=bucket.begin(); it!=bucket.end(); it++) { for (it=bucket.begin(); it!=bucket.end(); it++) {
@ -1690,13 +1690,13 @@ EvoItemInst::EvoItemInst(const EvoItemInst &copy) {
iter_contents it; iter_contents it;
for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) { for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = NULL; ItemInst* inst_new = nullptr;
if (inst_old) { if (inst_old) {
inst_new = inst_old->Clone(); inst_new = inst_old->Clone();
} }
if (inst_new != NULL) { if (inst_new != nullptr) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
} }
@ -1708,11 +1708,11 @@ EvoItemInst::EvoItemInst(const EvoItemInst &copy) {
m_exp = copy.m_exp; m_exp = copy.m_exp;
m_evolveLvl = copy.m_evolveLvl; m_evolveLvl = copy.m_evolveLvl;
m_activated = copy.m_activated; m_activated = copy.m_activated;
m_evolveInfo = NULL; m_evolveInfo = nullptr;
if (copy.m_scaledItem) if (copy.m_scaledItem)
m_scaledItem = new Item_Struct(*copy.m_scaledItem); m_scaledItem = new Item_Struct(*copy.m_scaledItem);
else else
m_scaledItem = NULL; m_scaledItem = nullptr;
} }
EvoItemInst::EvoItemInst(const ItemInst &basecopy) { EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
@ -1731,13 +1731,13 @@ EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
iter_contents it; iter_contents it;
for (it=copy->m_contents.begin(); it!=copy->m_contents.end(); it++) { for (it=copy->m_contents.begin(); it!=copy->m_contents.end(); it++) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = NULL; ItemInst* inst_new = nullptr;
if (inst_old) { if (inst_old) {
inst_new = inst_old->Clone(); inst_new = inst_old->Clone();
} }
if (inst_new != NULL) { if (inst_new != nullptr) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
} }
@ -1750,8 +1750,8 @@ EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
m_exp = 0; m_exp = 0;
m_evolveLvl = 0; m_evolveLvl = 0;
m_activated = false; m_activated = false;
m_evolveInfo = NULL; m_evolveInfo = nullptr;
m_scaledItem = NULL; m_scaledItem = nullptr;
} }
EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) { EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
@ -1770,8 +1770,8 @@ EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
m_exp = 0; m_exp = 0;
m_evolveLvl = 0; m_evolveLvl = 0;
m_activated = false; m_activated = false;
m_evolveInfo = NULL; m_evolveInfo = nullptr;
m_scaledItem = NULL; m_scaledItem = nullptr;
} }
EvoItemInst::~EvoItemInst() { EvoItemInst::~EvoItemInst() {

View File

@ -247,13 +247,13 @@ public:
///////////////////////// /////////////////////////
// Constructors/Destructor // Constructors/Destructor
ItemInst(const Item_Struct* item = NULL, int16 charges = 0); ItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
ItemInst(SharedDatabase *db, uint32 item_id, int16 charges = 0); ItemInst(SharedDatabase *db, uint32 item_id, int16 charges = 0);
ItemInst(ItemUseType use_type) { ItemInst(ItemUseType use_type) {
m_use_type = use_type; m_use_type = use_type;
m_item = NULL; m_item = nullptr;
m_charges = 0; m_charges = 0;
m_price = 0; m_price = 0;
m_instnodrop = false; m_instnodrop = false;
@ -357,7 +357,7 @@ public:
void DeleteCustomData(std::string identifier); void DeleteCustomData(std::string identifier);
// Allows treatment of this object as though it were a pointer to m_item // Allows treatment of this object as though it were a pointer to m_item
operator bool() const { return (m_item != NULL); } operator bool() const { return (m_item != nullptr); }
// Compare inner Item_Struct of two ItemInst objects // Compare inner Item_Struct of two ItemInst objects
bool operator==(const ItemInst& right) const { return (this->m_item == right.m_item); } bool operator==(const ItemInst& right) const { return (this->m_item == right.m_item); }
@ -408,7 +408,7 @@ public:
// constructor and destructor // constructor and destructor
EvoItemInst(const EvoItemInst& copy); EvoItemInst(const EvoItemInst& copy);
EvoItemInst(const ItemInst& copy); EvoItemInst(const ItemInst& copy);
EvoItemInst(const Item_Struct* item = NULL, int16 charges = 0); EvoItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
~EvoItemInst(); ~EvoItemInst();
// accessors... a lot of these are for evolving items (not complete yet) // accessors... a lot of these are for evolving items (not complete yet)
@ -424,7 +424,7 @@ public:
EvoItemInst* Clone() const; EvoItemInst* Clone() const;
const Item_Struct* GetItem() const; const Item_Struct* GetItem() const;
const Item_Struct* GetUnscaledItem() const; const Item_Struct* GetUnscaledItem() const;
void Initialize(SharedDatabase *db = NULL); void Initialize(SharedDatabase *db = nullptr);
void ScaleItem(); void ScaleItem();
bool EvolveOnAllKills() const; bool EvolveOnAllKills() const;
int8 GetMaxEvolveLvl() const; int8 GetMaxEvolveLvl() const;

View File

@ -123,7 +123,7 @@ bool strn0cpyt(char* dest, const char* source, uint32 size) {
const char *MakeUpperString(const char *source) { const char *MakeUpperString(const char *source) {
static char str[128]; static char str[128];
if (!source) if (!source)
return NULL; return nullptr;
MakeUpperString(source, str); MakeUpperString(source, str);
return str; return str;
} }
@ -144,7 +144,7 @@ void MakeUpperString(const char *source, char *target) {
const char *MakeLowerString(const char *source) { const char *MakeLowerString(const char *source) {
static char str[128]; static char str[128];
if (!source) if (!source)
return NULL; return nullptr;
MakeLowerString(source, str); MakeLowerString(source, str);
return str; return str;
} }
@ -316,12 +316,12 @@ uint32 ResolveIP(const char* hostname, char* errbuf) {
} }
struct sockaddr_in server_sin; struct sockaddr_in server_sin;
#ifdef _WINDOWS #ifdef _WINDOWS
PHOSTENT phostent = NULL; PHOSTENT phostent = nullptr;
#else #else
struct hostent *phostent = NULL; struct hostent *phostent = nullptr;
#endif #endif
server_sin.sin_family = AF_INET; server_sin.sin_family = AF_INET;
if ((phostent = gethostbyname(hostname)) == NULL) { if ((phostent = gethostbyname(hostname)) == nullptr) {
#ifdef _WINDOWS #ifdef _WINDOWS
if (errbuf) if (errbuf)
snprintf(errbuf, ERRBUF_SIZE, "Unable to get the host name. Error: %i", WSAGetLastError()); snprintf(errbuf, ERRBUF_SIZE, "Unable to get the host name. Error: %i", WSAGetLastError());
@ -396,7 +396,7 @@ int MakeRandomInt(int low, int high)
//return (rand()%(high-low+1) + (low)); //return (rand()%(high-low+1) + (low));
if(!WELLRNG_init) { if(!WELLRNG_init) {
WELLRNG_init = true; WELLRNG_init = true;
oneseed( rnd_hash( time(NULL), clock() ) ); oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1; WELLRNG19937 = case_1;
} }
unsigned int randomnum = ((WELLRNG19937)()); unsigned int randomnum = ((WELLRNG19937)());
@ -414,7 +414,7 @@ double MakeRandomFloat(double low, double high)
//return (rand() / (double)RAND_MAX * (high - low) + low); //return (rand() / (double)RAND_MAX * (high - low) + low);
if(!WELLRNG_init) { if(!WELLRNG_init) {
WELLRNG_init = true; WELLRNG_init = true;
oneseed( rnd_hash( time(NULL), clock() ) ); oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1; WELLRNG19937 = case_1;
} }
return ((WELLRNG19937)() / (double)0xffffffffUL * (high - low) + low); return ((WELLRNG19937)() / (double)0xffffffffUL * (high - low) + low);

View File

@ -149,7 +149,7 @@ public:
AutoDelete(T** iVar, T* iSetTo = 0) { AutoDelete(T** iVar, T* iSetTo = 0) {
init(iVar, iSetTo); init(iVar, iSetTo);
} }
AutoDelete() { pVar = NULL; } AutoDelete() { pVar = nullptr; }
void init(T** iVar, T* iSetTo = 0) void init(T** iVar, T* iSetTo = 0)
{ {
pVar = iVar; pVar = iVar;
@ -157,11 +157,11 @@ public:
*pVar = iSetTo; *pVar = iSetTo;
} }
~AutoDelete() { ~AutoDelete() {
if(pVar != NULL) if(pVar != nullptr)
safe_delete(*pVar); safe_delete(*pVar);
} }
void ReallyClearIt() { void ReallyClearIt() {
pVar = NULL; pVar = nullptr;
} }
private: private:
T** pVar; T** pVar;

View File

@ -107,7 +107,7 @@ void ProcLauncher::Process() {
void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) { void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) {
if(it->second->handler != NULL) if(it->second->handler != nullptr)
it->second->handler->OnTerminate(it->first, it->second); it->second->handler->OnTerminate(it->first, it->second);
#ifdef _WINDOWS #ifdef _WINDOWS
@ -121,7 +121,7 @@ void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) {
ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) { ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
//consume the pointer //consume the pointer
Spec *it = to_launch; Spec *it = to_launch;
to_launch = NULL; to_launch = nullptr;
#ifdef _WINDOWS #ifdef _WINDOWS
STARTUPINFO siStartInfo; STARTUPINFO siStartInfo;
@ -138,7 +138,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
siStartInfo.dwFlags = 0; siStartInfo.dwFlags = 0;
//handle output redirection. //handle output redirection.
HANDLE logOut = NULL; HANDLE logOut = nullptr;
BOOL inherit_handles = FALSE; BOOL inherit_handles = FALSE;
if(it->logFile.length() > 0) { if(it->logFile.length() > 0) {
inherit_handles = TRUE; inherit_handles = TRUE;
@ -146,7 +146,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
SECURITY_ATTRIBUTES saAttr; SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE; //we want this handle to be inherited by the child. saAttr.bInheritHandle = TRUE; //we want this handle to be inherited by the child.
saAttr.lpSecurityDescriptor = NULL; saAttr.lpSecurityDescriptor = nullptr;
logOut = CreateFile( logOut = CreateFile(
it->logFile.c_str(), //lpFileName it->logFile.c_str(), //lpFileName
FILE_WRITE_DATA, //dwDesiredAccess FILE_WRITE_DATA, //dwDesiredAccess
@ -154,12 +154,12 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
&saAttr, //lpSecurityAttributes &saAttr, //lpSecurityAttributes
CREATE_ALWAYS, //dwCreationDisposition CREATE_ALWAYS, //dwCreationDisposition
FILE_FLAG_NO_BUFFERING, //dwFlagsAndAttributes FILE_FLAG_NO_BUFFERING, //dwFlagsAndAttributes
NULL ); //hTemplateFile nullptr ); //hTemplateFile
//configure the startup info to redirect output appropriately. //configure the startup info to redirect output appropriately.
siStartInfo.hStdError = logOut; siStartInfo.hStdError = logOut;
siStartInfo.hStdOutput = logOut; siStartInfo.hStdOutput = logOut;
siStartInfo.hStdInput = NULL; siStartInfo.hStdInput = nullptr;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES; siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
} }
@ -179,12 +179,12 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
bFuncRetn = CreateProcess(it->program.c_str(), bFuncRetn = CreateProcess(it->program.c_str(),
const_cast<char *>(args.c_str()), // command line const_cast<char *>(args.c_str()), // command line
NULL, // process security attributes nullptr, // process security attributes
NULL, // primary thread security attributes nullptr, // primary thread security attributes
inherit_handles, // handles are not inherited inherit_handles, // handles are not inherited
0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe) 0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe)
NULL, // use parent's environment nullptr, // use parent's environment
NULL, // use parent's current directory nullptr, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer &siStartInfo, // STARTUPINFO pointer
&it->proc_info); // receives PROCESS_INFORMATION &it->proc_info); // receives PROCESS_INFORMATION
@ -197,7 +197,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
//keep process handle open to get exit code //keep process handle open to get exit code
CloseHandle(it->proc_info.hThread); //we dont need their thread handle CloseHandle(it->proc_info.hThread); //we dont need their thread handle
if(logOut != NULL) if(logOut != nullptr)
CloseHandle(logOut); //we dont want their output handle either. CloseHandle(logOut); //we dont want their output handle either.
ProcRef res = it->proc_info.dwProcessId; ProcRef res = it->proc_info.dwProcessId;
@ -216,7 +216,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
for(r = 1; r <= it->args.size(); r++) { for(r = 1; r <= it->args.size(); r++) {
argv[r] = const_cast<char *>(it->args[r-1].c_str()); argv[r] = const_cast<char *>(it->args[r-1].c_str());
} }
argv[r] = NULL; argv[r] = nullptr;
ProcRef res = fork(); //cant use vfork since we are opening the log file. ProcRef res = fork(); //cant use vfork since we are opening the log file.
if(res == -1) { if(res == -1) {
@ -334,7 +334,7 @@ void ProcLauncher::HandleSigChild(int signum) {
ProcLauncher::Spec::Spec() { ProcLauncher::Spec::Spec() {
handler = NULL; handler = nullptr;
} }
ProcLauncher::Spec::Spec(const Spec &other) { ProcLauncher::Spec::Spec(const Spec &other) {

View File

@ -43,7 +43,7 @@ namespace SOCKETS_NAMESPACE {
File::File() File::File()
:m_fil(NULL) :m_fil(nullptr)
{ {
} }
@ -85,7 +85,7 @@ size_t File::fwrite(const char *ptr, size_t size, size_t nmemb)
char *File::fgets(char *s, int size) char *File::fgets(char *s, int size)
{ {
return m_fil ? ::fgets(s, size, m_fil) : NULL; return m_fil ? ::fgets(s, size, m_fil) : nullptr;
} }

View File

@ -93,14 +93,14 @@ bool HttpdCookies::getvalue(const std::string& name,std::string& buffer) //char
void HttpdCookies::replacevalue(const std::string& name,const std::string& value) void HttpdCookies::replacevalue(const std::string& name,const std::string& value)
{ {
COOKIE *c = NULL; COOKIE *c = nullptr;
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++) for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
{ {
c = *it; c = *it;
if (!strcasecmp(c -> name.c_str(),name.c_str())) if (!strcasecmp(c -> name.c_str(),name.c_str()))
break; break;
c = NULL; c = nullptr;
} }
if (c) if (c)
@ -126,14 +126,14 @@ void HttpdCookies::replacevalue(const std::string& name,int i)
size_t HttpdCookies::getlength(const std::string& name) size_t HttpdCookies::getlength(const std::string& name)
{ {
COOKIE *c = NULL; COOKIE *c = nullptr;
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++) for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
{ {
c = *it; c = *it;
if (!strcasecmp(c -> name.c_str(),name.c_str())) if (!strcasecmp(c -> name.c_str(),name.c_str()))
break; break;
c = NULL; c = nullptr;
} }
return c ? c -> value.size() : 0; return c ? c -> value.size() : 0;
} }
@ -223,7 +223,7 @@ void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const
const std::string& HttpdCookies::expiredatetime() const std::string& HttpdCookies::expiredatetime()
{ {
time_t t = time(NULL); time_t t = time(nullptr);
struct tm * tp = gmtime(&t); struct tm * tp = gmtime(&t);
const char *days[7] = {"Sunday", "Monday", const char *days[7] = {"Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

View File

@ -47,7 +47,7 @@ namespace SOCKETS_NAMESPACE {
HttpdForm::HttpdForm(IFile *infil) : raw(false) HttpdForm::HttpdForm(IFile *infil) : raw(false)
{ {
CGI *cgi = NULL; CGI *cgi = nullptr;
char *c_t = getenv("CONTENT_TYPE"); char *c_t = getenv("CONTENT_TYPE");
char *c_l = getenv("CONTENT_LENGTH"); char *c_l = getenv("CONTENT_LENGTH");
size_t extra = 2; size_t extra = 2;
@ -59,7 +59,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
if (c_t && !strncmp(c_t, "multipart/form-data",19)) if (c_t && !strncmp(c_t, "multipart/form-data",19))
{ {
Parse pa(c_t,";="); Parse pa(c_t,";=");
char *tempcmp = NULL; char *tempcmp = nullptr;
size_t tc = 0; size_t tc = 0;
size_t l = 0; size_t l = 0;
std::string str = pa.getword(); std::string str = pa.getword();
@ -209,7 +209,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
#else #else
sprintf(fn,"/tmp/%s",current_filename.c_str()); sprintf(fn,"/tmp/%s",current_filename.c_str());
#endif #endif
if ((fil = fopen(fn, "wb")) != NULL) if ((fil = fopen(fn, "wb")) != nullptr)
{ {
infil -> fread(&c,1,1); infil -> fread(&c,1,1);
while (!infil -> eof()) while (!infil -> eof())
@ -353,7 +353,7 @@ HttpdForm::HttpdForm(IFile *infil) : raw(false)
HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false) HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false)
{ {
CGI *cgi = NULL; CGI *cgi = nullptr;
char slask[8888]; char slask[8888];
char name[200]; char name[200];
int i = 0; int i = 0;
@ -424,7 +424,7 @@ HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false)
HttpdForm::~HttpdForm() HttpdForm::~HttpdForm()
{ {
CGI *cgi = NULL; //,*tmp; CGI *cgi = nullptr; //,*tmp;
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++) for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
{ {
@ -525,7 +525,7 @@ bool HttpdForm::getnext(std::string& n,std::string& v) //char *n,size_t len,char
int HttpdForm::getvalue(const std::string& n,std::string& v) //char *v,size_t len) int HttpdForm::getvalue(const std::string& n,std::string& v) //char *v,size_t len)
{ {
CGI *cgi = NULL; CGI *cgi = nullptr;
int r = 0; int r = 0;
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++) for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
@ -533,7 +533,7 @@ int HttpdForm::getvalue(const std::string& n,std::string& v) //char *v,size_t le
cgi = *it; cgi = *it;
if (cgi -> name == n) if (cgi -> name == n)
break; break;
cgi = NULL; cgi = nullptr;
} }
if (cgi) if (cgi)
{ {
@ -572,7 +572,7 @@ std::string HttpdForm::getvalue(const std::string& n)
size_t HttpdForm::getlength(const std::string& n) size_t HttpdForm::getlength(const std::string& n)
{ {
CGI *cgi = NULL; CGI *cgi = nullptr;
size_t l; size_t l;
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++) for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
@ -580,7 +580,7 @@ size_t HttpdForm::getlength(const std::string& n)
cgi = *it; cgi = *it;
if (cgi -> name == n) if (cgi -> name == n)
break; break;
cgi = NULL; cgi = nullptr;
} }
l = cgi ? cgi -> value.size() : 0; l = cgi ? cgi -> value.size() : 0;
if (cgi && !raw) if (cgi && !raw)

View File

@ -64,11 +64,11 @@ std::string HttpdSocket::m_start = "";
HttpdSocket::HttpdSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) HttpdSocket::HttpdSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
: HTTPSocket(ID,in_socket,irIP,irPort) : HTTPSocket(ID,in_socket,irIP,irPort)
,m_content_length(0) ,m_content_length(0)
,m_file(NULL) ,m_file(nullptr)
,m_received(0) ,m_received(0)
,m_request_id(++m_request_count) ,m_request_id(++m_request_count)
,m_cookies(NULL) ,m_cookies(nullptr)
,m_form(NULL) ,m_form(nullptr)
{ {
m_http_date = datetime2httpdate(GetDate()); m_http_date = datetime2httpdate(GetDate());
if (!m_start.size()) if (!m_start.size())
@ -289,7 +289,7 @@ std::string HttpdSocket::datetime2httpdate(const std::string& dt)
std::string HttpdSocket::GetDate() std::string HttpdSocket::GetDate()
{ {
time_t t = time(NULL); time_t t = time(nullptr);
struct tm* tp = localtime(&t); struct tm* tp = localtime(&t);
char slask[40]; char slask[40];
if (tp) if (tp)
@ -315,16 +315,16 @@ void HttpdSocket::Reset()
if (m_file) if (m_file)
{ {
delete m_file; delete m_file;
m_file = NULL; m_file = nullptr;
} }
m_received = 0; m_received = 0;
m_request_id = ++m_request_count; m_request_id = ++m_request_count;
if (m_cookies) if (m_cookies)
delete m_cookies; delete m_cookies;
m_cookies = NULL; m_cookies = nullptr;
if (m_form) if (m_form)
delete m_form; delete m_form;
m_form = NULL; m_form = nullptr;
} }

View File

@ -66,8 +66,8 @@ MemFile::MemFile(const std::string& path)
:m_path(path) :m_path(path)
,m_temporary(false) ,m_temporary(false)
,m_base(m_files[path]) ,m_base(m_files[path])
,m_current_read(NULL) ,m_current_read(nullptr)
,m_current_write(NULL) ,m_current_write(nullptr)
,m_read_ptr(0) ,m_read_ptr(0)
,m_write_ptr(0) ,m_write_ptr(0)
{ {

View File

@ -48,7 +48,7 @@ public:
/** File block structure. /** File block structure.
\ingroup file */ \ingroup file */
struct block_t { struct block_t {
block_t() : next(NULL) {} block_t() : next(nullptr) {}
struct block_t *next; struct block_t *next;
char data[BLOCKSIZE]; char data[BLOCKSIZE];
}; };

View File

@ -37,7 +37,7 @@ Mime::Mime(const std::string& filename) {
bool Mime::LoadMimeFile(const std::string& filename) { bool Mime::LoadMimeFile(const std::string& filename) {
FILE *fil; FILE *fil;
if ((fil = fopen(filename.c_str(),"rt")) != NULL) { if ((fil = fopen(filename.c_str(),"rt")) != nullptr) {
char * slask = new char[1000]; char * slask = new char[1000];
fgets(slask,1000,fil); fgets(slask,1000,fil);
while (!feof(fil)) while (!feof(fil))

View File

@ -104,7 +104,7 @@ typedef struct _tagSTACKFRAME64 {
ADDRESS64 AddrFrame; // frame pointer ADDRESS64 AddrFrame; // frame pointer
ADDRESS64 AddrStack; // stack pointer ADDRESS64 AddrStack; // stack pointer
ADDRESS64 AddrBStore; // backing store pointer ADDRESS64 AddrBStore; // backing store pointer
PVOID FuncTableEntry; // pointer to pdata/fpo or NULL PVOID FuncTableEntry; // pointer to pdata/fpo or nullptr
DWORD64 Params[4]; // possible arguments to the function DWORD64 Params[4]; // possible arguments to the function
BOOL Far; // WOW far call BOOL Far; // WOW far call
BOOL Virtual; // is this a virtual frame? BOOL Virtual; // is this a virtual frame?
@ -187,44 +187,44 @@ public:
StackWalkerInternal(StackWalker *parent, HANDLE hProcess) StackWalkerInternal(StackWalker *parent, HANDLE hProcess)
{ {
m_parent = parent; m_parent = parent;
m_hDbhHelp = NULL; m_hDbhHelp = nullptr;
pSC = NULL; pSC = nullptr;
m_hProcess = hProcess; m_hProcess = hProcess;
m_szSymPath = NULL; m_szSymPath = nullptr;
pSFTA = NULL; pSFTA = nullptr;
pSGLFA = NULL; pSGLFA = nullptr;
pSGMB = NULL; pSGMB = nullptr;
pSGMI = NULL; pSGMI = nullptr;
pSGO = NULL; pSGO = nullptr;
pSGSFA = NULL; pSGSFA = nullptr;
pSI = NULL; pSI = nullptr;
pSLM = NULL; pSLM = nullptr;
pSSO = NULL; pSSO = nullptr;
pSW = NULL; pSW = nullptr;
pUDSN = NULL; pUDSN = nullptr;
pSGSP = NULL; pSGSP = nullptr;
} }
~StackWalkerInternal() ~StackWalkerInternal()
{ {
if (pSC != NULL) if (pSC != nullptr)
pSC(m_hProcess); // SymCleanup pSC(m_hProcess); // SymCleanup
if (m_hDbhHelp != NULL) if (m_hDbhHelp != nullptr)
FreeLibrary(m_hDbhHelp); FreeLibrary(m_hDbhHelp);
m_hDbhHelp = NULL; m_hDbhHelp = nullptr;
m_parent = NULL; m_parent = nullptr;
if(m_szSymPath != NULL) if(m_szSymPath != nullptr)
free(m_szSymPath); free(m_szSymPath);
m_szSymPath = NULL; m_szSymPath = nullptr;
} }
BOOL Init(LPCSTR szSymPath) BOOL Init(LPCSTR szSymPath)
{ {
if (m_parent == NULL) if (m_parent == nullptr)
return FALSE; return FALSE;
// Dynamically load the Entry-Points for dbghelp.dll: // Dynamically load the Entry-Points for dbghelp.dll:
// First try to load the newsest one from // First try to load the newsest one from
TCHAR szTemp[4096]; TCHAR szTemp[4096];
// But before wqe do this, we first check if the ".local" file exists // But before wqe do this, we first check if the ".local" file exists
if (GetModuleFileName(NULL, szTemp, 4096) > 0) if (GetModuleFileName(nullptr, szTemp, 4096) > 0)
{ {
_tcscat_s(szTemp, _T(".local")); _tcscat_s(szTemp, _T(".local"));
if (GetFileAttributes(szTemp) == INVALID_FILE_ATTRIBUTES) if (GetFileAttributes(szTemp) == INVALID_FILE_ATTRIBUTES)
@ -240,7 +240,7 @@ public:
} }
} }
// Still not found? Then try to load the 64-Bit version: // Still not found? Then try to load the 64-Bit version:
if ( (m_hDbhHelp == NULL) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) ) if ( (m_hDbhHelp == nullptr) && (GetEnvironmentVariable(_T("ProgramFiles"), szTemp, 4096) > 0) )
{ {
_tcscat_s(szTemp, _T("\\Debugging Tools for Windows 64-Bit\\dbghelp.dll")); _tcscat_s(szTemp, _T("\\Debugging Tools for Windows 64-Bit\\dbghelp.dll"));
if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES) if (GetFileAttributes(szTemp) != INVALID_FILE_ATTRIBUTES)
@ -250,9 +250,9 @@ public:
} }
} }
} }
if (m_hDbhHelp == NULL) // if not already loaded, try to load a default-one if (m_hDbhHelp == nullptr) // if not already loaded, try to load a default-one
m_hDbhHelp = LoadLibrary( _T("dbghelp.dll") ); m_hDbhHelp = LoadLibrary( _T("dbghelp.dll") );
if (m_hDbhHelp == NULL) if (m_hDbhHelp == nullptr)
return FALSE; return FALSE;
pSI = (tSI) GetProcAddress(m_hDbhHelp, "SymInitialize" ); pSI = (tSI) GetProcAddress(m_hDbhHelp, "SymInitialize" );
pSC = (tSC) GetProcAddress(m_hDbhHelp, "SymCleanup" ); pSC = (tSC) GetProcAddress(m_hDbhHelp, "SymCleanup" );
@ -271,18 +271,18 @@ public:
pSLM = (tSLM) GetProcAddress(m_hDbhHelp, "SymLoadModule64" ); pSLM = (tSLM) GetProcAddress(m_hDbhHelp, "SymLoadModule64" );
pSGSP =(tSGSP) GetProcAddress(m_hDbhHelp, "SymGetSearchPath" ); pSGSP =(tSGSP) GetProcAddress(m_hDbhHelp, "SymGetSearchPath" );
if ( pSC == NULL || pSFTA == NULL || pSGMB == NULL || pSGMI == NULL || if ( pSC == nullptr || pSFTA == nullptr || pSGMB == nullptr || pSGMI == nullptr ||
pSGO == NULL || pSGSFA == NULL || pSI == NULL || pSSO == NULL || pSGO == nullptr || pSGSFA == nullptr || pSI == nullptr || pSSO == nullptr ||
pSW == NULL || pUDSN == NULL || pSLM == NULL ) pSW == nullptr || pUDSN == nullptr || pSLM == nullptr )
{ {
FreeLibrary(m_hDbhHelp); FreeLibrary(m_hDbhHelp);
m_hDbhHelp = NULL; m_hDbhHelp = nullptr;
pSC = NULL; pSC = nullptr;
return FALSE; return FALSE;
} }
// SymInitialize // SymInitialize
if (szSymPath != NULL) if (szSymPath != nullptr)
m_szSymPath = _strdup(szSymPath); m_szSymPath = _strdup(szSymPath);
if (this->pSI(m_hProcess, m_szSymPath, FALSE) == FALSE) if (this->pSI(m_hProcess, m_szSymPath, FALSE) == FALSE)
this->m_parent->OnDbgHelpErr("SymInitialize", GetLastError(), 0); this->m_parent->OnDbgHelpErr("SymInitialize", GetLastError(), 0);
@ -295,7 +295,7 @@ public:
symOptions = this->pSSO(symOptions); symOptions = this->pSSO(symOptions);
char buf[StackWalker::STACKWALK_MAX_NAMELEN] = {0}; char buf[StackWalker::STACKWALK_MAX_NAMELEN] = {0};
if (this->pSGSP != NULL) if (this->pSGSP != nullptr)
{ {
if (this->pSGSP(m_hProcess, buf, StackWalker::STACKWALK_MAX_NAMELEN) == FALSE) if (this->pSGSP(m_hProcess, buf, StackWalker::STACKWALK_MAX_NAMELEN) == FALSE)
this->m_parent->OnDbgHelpErr("SymGetSearchPath", GetLastError(), 0); this->m_parent->OnDbgHelpErr("SymGetSearchPath", GetLastError(), 0);
@ -458,10 +458,10 @@ private:
// try both dlls... // try both dlls...
const TCHAR *dllname[] = { _T("kernel32.dll"), _T("tlhelp32.dll") }; const TCHAR *dllname[] = { _T("kernel32.dll"), _T("tlhelp32.dll") };
HINSTANCE hToolhelp = NULL; HINSTANCE hToolhelp = nullptr;
tCT32S pCT32S = NULL; tCT32S pCT32S = nullptr;
tM32F pM32F = NULL; tM32F pM32F = nullptr;
tM32N pM32N = NULL; tM32N pM32N = nullptr;
HANDLE hSnap; HANDLE hSnap;
MODULEENTRY32 me; MODULEENTRY32 me;
@ -472,18 +472,18 @@ private:
for (i = 0; i<(sizeof(dllname) / sizeof(dllname[0])); i++ ) for (i = 0; i<(sizeof(dllname) / sizeof(dllname[0])); i++ )
{ {
hToolhelp = LoadLibrary( dllname[i] ); hToolhelp = LoadLibrary( dllname[i] );
if (hToolhelp == NULL) if (hToolhelp == nullptr)
continue; continue;
pCT32S = (tCT32S) GetProcAddress(hToolhelp, "CreateToolhelp32Snapshot"); pCT32S = (tCT32S) GetProcAddress(hToolhelp, "CreateToolhelp32Snapshot");
pM32F = (tM32F) GetProcAddress(hToolhelp, "Module32First"); pM32F = (tM32F) GetProcAddress(hToolhelp, "Module32First");
pM32N = (tM32N) GetProcAddress(hToolhelp, "Module32Next"); pM32N = (tM32N) GetProcAddress(hToolhelp, "Module32Next");
if ( (pCT32S != NULL) && (pM32F != NULL) && (pM32N != NULL) ) if ( (pCT32S != nullptr) && (pM32F != nullptr) && (pM32N != nullptr) )
break; // found the functions! break; // found the functions!
FreeLibrary(hToolhelp); FreeLibrary(hToolhelp);
hToolhelp = NULL; hToolhelp = nullptr;
} }
if (hToolhelp == NULL) if (hToolhelp == nullptr)
return FALSE; return FALSE;
hSnap = pCT32S( TH32CS_SNAPMODULE, pid ); hSnap = pCT32S( TH32CS_SNAPMODULE, pid );
@ -534,20 +534,20 @@ private:
DWORD cbNeeded; DWORD cbNeeded;
MODULEINFO mi; MODULEINFO mi;
HMODULE *hMods = 0; HMODULE *hMods = 0;
char *tt = NULL; char *tt = nullptr;
char *tt2 = NULL; char *tt2 = nullptr;
const SIZE_T TTBUFLEN = 8096; const SIZE_T TTBUFLEN = 8096;
int cnt = 0; int cnt = 0;
hPsapi = LoadLibrary( _T("psapi.dll") ); hPsapi = LoadLibrary( _T("psapi.dll") );
if (hPsapi == NULL) if (hPsapi == nullptr)
return FALSE; return FALSE;
pEPM = (tEPM) GetProcAddress( hPsapi, "EnumProcessModules" ); pEPM = (tEPM) GetProcAddress( hPsapi, "EnumProcessModules" );
pGMFNE = (tGMFNE) GetProcAddress( hPsapi, "GetModuleFileNameExA" ); pGMFNE = (tGMFNE) GetProcAddress( hPsapi, "GetModuleFileNameExA" );
pGMBN = (tGMFNE) GetProcAddress( hPsapi, "GetModuleBaseNameA" ); pGMBN = (tGMFNE) GetProcAddress( hPsapi, "GetModuleBaseNameA" );
pGMI = (tGMI) GetProcAddress( hPsapi, "GetModuleInformation" ); pGMI = (tGMI) GetProcAddress( hPsapi, "GetModuleInformation" );
if ( (pEPM == NULL) || (pGMFNE == NULL) || (pGMBN == NULL) || (pGMI == NULL) ) if ( (pEPM == nullptr) || (pGMFNE == nullptr) || (pGMBN == nullptr) || (pGMI == nullptr) )
{ {
// we couldn?t find all functions // we couldn?t find all functions
FreeLibrary(hPsapi); FreeLibrary(hPsapi);
@ -557,7 +557,7 @@ private:
hMods = (HMODULE*) malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof HMODULE)); hMods = (HMODULE*) malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof HMODULE));
tt = (char*) malloc(sizeof(char) * TTBUFLEN); tt = (char*) malloc(sizeof(char) * TTBUFLEN);
tt2 = (char*) malloc(sizeof(char) * TTBUFLEN); tt2 = (char*) malloc(sizeof(char) * TTBUFLEN);
if ( (hMods == NULL) || (tt == NULL) || (tt2 == NULL) ) if ( (hMods == nullptr) || (tt == nullptr) || (tt2 == nullptr) )
goto cleanup; goto cleanup;
if ( ! pEPM( hProcess, hMods, TTBUFLEN, &cbNeeded ) ) if ( ! pEPM( hProcess, hMods, TTBUFLEN, &cbNeeded ) )
@ -590,10 +590,10 @@ private:
} }
cleanup: cleanup:
if (hPsapi != NULL) FreeLibrary(hPsapi); if (hPsapi != nullptr) FreeLibrary(hPsapi);
if (tt2 != NULL) free(tt2); if (tt2 != nullptr) free(tt2);
if (tt != NULL) free(tt); if (tt != nullptr) free(tt);
if (hMods != NULL) free(hMods); if (hMods != nullptr) free(hMods);
return cnt != 0; return cnt != 0;
} // GetModuleListPSAPI } // GetModuleListPSAPI
@ -603,7 +603,7 @@ private:
CHAR *szImg = _strdup(img); CHAR *szImg = _strdup(img);
CHAR *szMod = _strdup(mod); CHAR *szMod = _strdup(mod);
DWORD result = ERROR_SUCCESS; DWORD result = ERROR_SUCCESS;
if ( (szImg == NULL) || (szMod == NULL) ) if ( (szImg == nullptr) || (szMod == nullptr) )
result = ERROR_NOT_ENOUGH_MEMORY; result = ERROR_NOT_ENOUGH_MEMORY;
else else
{ {
@ -611,25 +611,25 @@ private:
result = GetLastError(); result = GetLastError();
} }
ULONGLONG fileVersion = 0; ULONGLONG fileVersion = 0;
if ( (m_parent != NULL) && (szImg != NULL) ) if ( (m_parent != nullptr) && (szImg != nullptr) )
{ {
// try to retrive the file-version: // try to retrive the file-version:
if ( (this->m_parent->m_options & StackWalker::RetrieveFileVersion) != 0) if ( (this->m_parent->m_options & StackWalker::RetrieveFileVersion) != 0)
{ {
VS_FIXEDFILEINFO *fInfo = NULL; VS_FIXEDFILEINFO *fInfo = nullptr;
DWORD dwHandle; DWORD dwHandle;
DWORD dwSize = GetFileVersionInfoSizeA(szImg, &dwHandle); DWORD dwSize = GetFileVersionInfoSizeA(szImg, &dwHandle);
if (dwSize > 0) if (dwSize > 0)
{ {
LPVOID vData = malloc(dwSize); LPVOID vData = malloc(dwSize);
if (vData != NULL) if (vData != nullptr)
{ {
if (GetFileVersionInfoA(szImg, dwHandle, dwSize, vData) != 0) if (GetFileVersionInfoA(szImg, dwHandle, dwSize, vData) != 0)
{ {
UINT len; UINT len;
TCHAR szSubBlock[] = _T("\\"); TCHAR szSubBlock[] = _T("\\");
if (VerQueryValue(vData, szSubBlock, (LPVOID*) &fInfo, &len) == 0) if (VerQueryValue(vData, szSubBlock, (LPVOID*) &fInfo, &len) == 0)
fInfo = NULL; fInfo = nullptr;
else else
{ {
fileVersion = ((ULONGLONG)fInfo->dwFileVersionLS) + ((ULONGLONG)fInfo->dwFileVersionMS << 32); fileVersion = ((ULONGLONG)fInfo->dwFileVersionLS) + ((ULONGLONG)fInfo->dwFileVersionMS << 32);
@ -678,8 +678,8 @@ private:
} }
this->m_parent->OnLoadModule(img, mod, baseAddr, size, result, szSymType, Module.LoadedImageName, fileVersion); this->m_parent->OnLoadModule(img, mod, baseAddr, size, result, szSymType, Module.LoadedImageName, fileVersion);
} }
if (szImg != NULL) free(szImg); if (szImg != nullptr) free(szImg);
if (szMod != NULL) free(szMod); if (szMod != nullptr) free(szMod);
return result; return result;
} }
public: public:
@ -695,7 +695,7 @@ public:
BOOL GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V2 *pModuleInfo) BOOL GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V2 *pModuleInfo)
{ {
if(this->pSGMI == NULL) if(this->pSGMI == nullptr)
{ {
SetLastError(ERROR_DLL_INIT_FAILED); SetLastError(ERROR_DLL_INIT_FAILED);
return FALSE; return FALSE;
@ -703,7 +703,7 @@ public:
// First try to use the larger ModuleInfo-Structure // First try to use the larger ModuleInfo-Structure
// memset(pModuleInfo, 0, sizeof(IMAGEHLP_MODULE64_V3)); // memset(pModuleInfo, 0, sizeof(IMAGEHLP_MODULE64_V3));
// pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V3); // pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V3);
// if (this->pSGMI_V3 != NULL) // if (this->pSGMI_V3 != nullptr)
// { // {
// if (this->pSGMI_V3(hProcess, baseAddr, pModuleInfo) != FALSE) // if (this->pSGMI_V3(hProcess, baseAddr, pModuleInfo) != FALSE)
// return TRUE; // return TRUE;
@ -714,7 +714,7 @@ public:
// could not retrive the bigger structure, try with the smaller one (as defined in VC7.1)... // could not retrive the bigger structure, try with the smaller one (as defined in VC7.1)...
pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2); pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2);
void *pData = malloc(4096); // reserve enough memory, so the bug in v6.3.5.1 does not lead to memory-overwrites... void *pData = malloc(4096); // reserve enough memory, so the bug in v6.3.5.1 does not lead to memory-overwrites...
if (pData == NULL) if (pData == nullptr)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE; return FALSE;
@ -742,7 +742,7 @@ StackWalker::StackWalker(DWORD dwProcessId, HANDLE hProcess)
this->m_hProcess = hProcess; this->m_hProcess = hProcess;
this->m_sw = new StackWalkerInternal(this, this->m_hProcess); this->m_sw = new StackWalkerInternal(this, this->m_hProcess);
this->m_dwProcessId = dwProcessId; this->m_dwProcessId = dwProcessId;
this->m_szSymPath = NULL; this->m_szSymPath = nullptr;
} }
StackWalker::StackWalker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDLE hProcess) StackWalker::StackWalker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDLE hProcess)
{ {
@ -751,28 +751,28 @@ StackWalker::StackWalker(int options, LPCSTR szSymPath, DWORD dwProcessId, HANDL
this->m_hProcess = hProcess; this->m_hProcess = hProcess;
this->m_sw = new StackWalkerInternal(this, this->m_hProcess); this->m_sw = new StackWalkerInternal(this, this->m_hProcess);
this->m_dwProcessId = dwProcessId; this->m_dwProcessId = dwProcessId;
if (szSymPath != NULL) if (szSymPath != nullptr)
{ {
this->m_szSymPath = _strdup(szSymPath); this->m_szSymPath = _strdup(szSymPath);
this->m_options |= SymBuildPath; this->m_options |= SymBuildPath;
} }
else else
this->m_szSymPath = NULL; this->m_szSymPath = nullptr;
} }
StackWalker::~StackWalker() StackWalker::~StackWalker()
{ {
if (m_szSymPath != NULL) if (m_szSymPath != nullptr)
free(m_szSymPath); free(m_szSymPath);
m_szSymPath = NULL; m_szSymPath = nullptr;
if (this->m_sw != NULL) if (this->m_sw != nullptr)
delete this->m_sw; delete this->m_sw;
this->m_sw = NULL; this->m_sw = nullptr;
} }
BOOL StackWalker::LoadModules() BOOL StackWalker::LoadModules()
{ {
if (this->m_sw == NULL) if (this->m_sw == nullptr)
{ {
SetLastError(ERROR_DLL_INIT_FAILED); SetLastError(ERROR_DLL_INIT_FAILED);
return FALSE; return FALSE;
@ -781,19 +781,19 @@ BOOL StackWalker::LoadModules()
return TRUE; return TRUE;
// Build the sym-path: // Build the sym-path:
char *szSymPath = NULL; char *szSymPath = nullptr;
if ( (this->m_options & SymBuildPath) != 0) if ( (this->m_options & SymBuildPath) != 0)
{ {
const size_t nSymPathLen = 4096; const size_t nSymPathLen = 4096;
szSymPath = (char*) malloc(nSymPathLen); szSymPath = (char*) malloc(nSymPathLen);
if (szSymPath == NULL) if (szSymPath == nullptr)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE; return FALSE;
} }
szSymPath[0] = 0; szSymPath[0] = 0;
// Now first add the (optional) provided sympath: // Now first add the (optional) provided sympath:
if (this->m_szSymPath != NULL) if (this->m_szSymPath != nullptr)
{ {
strcat_s(szSymPath, nSymPathLen, this->m_szSymPath); strcat_s(szSymPath, nSymPathLen, this->m_szSymPath);
strcat_s(szSymPath, nSymPathLen, ";"); strcat_s(szSymPath, nSymPathLen, ";");
@ -812,7 +812,7 @@ BOOL StackWalker::LoadModules()
} }
// Now add the path for the main-module: // Now add the path for the main-module:
if (GetModuleFileNameA(NULL, szTemp, nTempLen) > 0) if (GetModuleFileNameA(nullptr, szTemp, nTempLen) > 0)
{ {
szTemp[nTempLen-1] = 0; szTemp[nTempLen-1] = 0;
for (char *p = (szTemp+strlen(szTemp)-1); p >= szTemp; --p) for (char *p = (szTemp+strlen(szTemp)-1); p >= szTemp; --p)
@ -870,7 +870,7 @@ BOOL StackWalker::LoadModules()
// First Init the whole stuff... // First Init the whole stuff...
BOOL bRet = this->m_sw->Init(szSymPath); BOOL bRet = this->m_sw->Init(szSymPath);
if (szSymPath != NULL) free(szSymPath); szSymPath = NULL; if (szSymPath != nullptr) free(szSymPath); szSymPath = nullptr;
if (bRet == FALSE) if (bRet == FALSE)
{ {
this->OnDbgHelpErr("Error while initializing dbghelp.dll", 0, 0); this->OnDbgHelpErr("Error while initializing dbghelp.dll", 0, 0);
@ -889,14 +889,14 @@ BOOL StackWalker::LoadModules()
// This has to be done due to a problem with the "hProcess"-parameter in x64... // This has to be done due to a problem with the "hProcess"-parameter in x64...
// Because this class is in no case multi-threading-enabled (because of the limitations // Because this class is in no case multi-threading-enabled (because of the limitations
// of dbghelp.dll) it is "safe" to use a static-variable // of dbghelp.dll) it is "safe" to use a static-variable
static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = NULL; static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = nullptr;
static LPVOID s_readMemoryFunction_UserData = NULL; static LPVOID s_readMemoryFunction_UserData = nullptr;
BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadProcessMemoryRoutine readMemoryFunction, LPVOID pUserData) BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadProcessMemoryRoutine readMemoryFunction, LPVOID pUserData)
{ {
CONTEXT c;; CONTEXT c;;
CallstackEntry csEntry; CallstackEntry csEntry;
IMAGEHLP_SYMBOL64 *pSym = NULL; IMAGEHLP_SYMBOL64 *pSym = nullptr;
StackWalkerInternal::IMAGEHLP_MODULE64_V2 Module; StackWalkerInternal::IMAGEHLP_MODULE64_V2 Module;
IMAGEHLP_LINE64 Line; IMAGEHLP_LINE64 Line;
int frameNum; int frameNum;
@ -904,7 +904,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
if (m_modulesLoaded == FALSE) if (m_modulesLoaded == FALSE)
this->LoadModules(); // ignore the result... this->LoadModules(); // ignore the result...
if (this->m_sw->m_hDbhHelp == NULL) if (this->m_sw->m_hDbhHelp == nullptr)
{ {
SetLastError(ERROR_DLL_INIT_FAILED); SetLastError(ERROR_DLL_INIT_FAILED);
return FALSE; return FALSE;
@ -913,7 +913,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
s_readMemoryFunction = readMemoryFunction; s_readMemoryFunction = readMemoryFunction;
s_readMemoryFunction_UserData = pUserData; s_readMemoryFunction_UserData = pUserData;
if (context == NULL) if (context == nullptr)
{ {
// If no context is provided, capture the context // If no context is provided, capture the context
if (hThread == GetCurrentThread()) if (hThread == GetCurrentThread())
@ -989,7 +989,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
// assume that either you are done, or that the stack is so hosed that the next // assume that either you are done, or that the stack is so hosed that the next
// deeper frame could not be found. // deeper frame could not be found.
// CONTEXT need not to be suplied if imageTyp is IMAGE_FILE_MACHINE_I386! // CONTEXT need not to be suplied if imageTyp is IMAGE_FILE_MACHINE_I386!
if ( ! this->m_sw->pSW(imageType, this->m_hProcess, hThread, &s, &c, myReadProcMem, this->m_sw->pSFTA, this->m_sw->pSGMB, NULL) ) if ( ! this->m_sw->pSW(imageType, this->m_hProcess, hThread, &s, &c, myReadProcMem, this->m_sw->pSFTA, this->m_sw->pSGMB, nullptr) )
{ {
this->OnDbgHelpErr("StackWalk64", GetLastError(), s.AddrPC.Offset); this->OnDbgHelpErr("StackWalk64", GetLastError(), s.AddrPC.Offset);
break; break;
@ -1028,7 +1028,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
} }
// show line number info, NT5.0-method (SymGetLineFromAddr64()) // show line number info, NT5.0-method (SymGetLineFromAddr64())
if (this->m_sw->pSGLFA != NULL ) if (this->m_sw->pSGLFA != nullptr )
{ // yes, we have SymGetLineFromAddr64() { // yes, we have SymGetLineFromAddr64()
if (this->m_sw->pSGLFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromLine), &Line) != FALSE) if (this->m_sw->pSGLFA(this->m_hProcess, s.AddrPC.Offset, &(csEntry.offsetFromLine), &Line) != FALSE)
{ {
@ -1078,7 +1078,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
break; break;
default: default:
//_snprintf( ty, sizeof ty, "symtype=%ld", (long) Module.SymType ); //_snprintf( ty, sizeof ty, "symtype=%ld", (long) Module.SymType );
csEntry.symTypeString = NULL; csEntry.symTypeString = nullptr;
break; break;
} }
@ -1109,7 +1109,7 @@ BOOL StackWalker::ShowCallstack(HANDLE hThread, const CONTEXT *context, PReadPro
cleanup: cleanup:
if (pSym) free( pSym ); if (pSym) free( pSym );
if (context == NULL) if (context == nullptr)
ResumeThread(hThread); ResumeThread(hThread);
return TRUE; return TRUE;
@ -1123,7 +1123,7 @@ BOOL __stdcall StackWalker::myReadProcMem(
LPDWORD lpNumberOfBytesRead LPDWORD lpNumberOfBytesRead
) )
{ {
if (s_readMemoryFunction == NULL) if (s_readMemoryFunction == nullptr)
{ {
SIZE_T st; SIZE_T st;
BOOL bRet = ReadProcessMemory(hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, &st); BOOL bRet = ReadProcessMemory(hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, &st);

View File

@ -66,7 +66,7 @@ public:
StackWalker( StackWalker(
int options = OptionsAll, // 'int' is by design, to combine the enum-flags int options = OptionsAll, // 'int' is by design, to combine the enum-flags
LPCSTR szSymPath = NULL, LPCSTR szSymPath = nullptr,
DWORD dwProcessId = GetCurrentProcessId(), DWORD dwProcessId = GetCurrentProcessId(),
HANDLE hProcess = GetCurrentProcess() HANDLE hProcess = GetCurrentProcess()
); );
@ -86,9 +86,9 @@ public:
BOOL ShowCallstack( BOOL ShowCallstack(
HANDLE hThread = GetCurrentThread(), HANDLE hThread = GetCurrentThread(),
const CONTEXT *context = NULL, const CONTEXT *context = nullptr,
PReadProcessMemoryRoutine readMemoryFunction = NULL, PReadProcessMemoryRoutine readMemoryFunction = nullptr,
LPVOID pUserData = NULL // optional to identify some data in the 'readMemoryFunction'-callback LPVOID pUserData = nullptr // optional to identify some data in the 'readMemoryFunction'-callback
); );
#if _MSC_VER >= 1300 #if _MSC_VER >= 1300
@ -157,11 +157,11 @@ protected:
#define GET_CURRENT_CONTEXT(c, contextFlags) \ #define GET_CURRENT_CONTEXT(c, contextFlags) \
do { \ do { \
memset(&c, 0, sizeof(CONTEXT)); \ memset(&c, 0, sizeof(CONTEXT)); \
EXCEPTION_POINTERS *pExp = NULL; \ EXCEPTION_POINTERS *pExp = nullptr; \
__try { \ __try { \
throw 0; \ throw 0; \
} __except( ( (pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_EXECUTE_HANDLER)) {} \ } __except( ( (pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_EXECUTE_HANDLER)) {} \
if (pExp != NULL) \ if (pExp != nullptr) \
memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \ memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \
c.ContextFlags = contextFlags; \ c.ContextFlags = contextFlags; \
} while(0); } while(0);

View File

@ -31,7 +31,7 @@ void StructStrategy::Decode(EQApplicationPacket *p) const {
void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bool ack_req) { void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bool ack_req) {
EQApplicationPacket *p = *in_p; EQApplicationPacket *p = *in_p;
*in_p = NULL; *in_p = nullptr;
_log(NET__STRUCTS, "Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode())); _log(NET__STRUCTS, "Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode()));
@ -67,7 +67,7 @@ namespace StructStrategyFactory {
map<EmuOpcode, const StructStrategy *>::const_iterator res; map<EmuOpcode, const StructStrategy *>::const_iterator res;
res = strategies.find(first_opcode); res = strategies.find(first_opcode);
if(res == strategies.end()) if(res == strategies.end())
return(NULL); return(nullptr);
return(res->second); return(res->second);
} }

View File

@ -56,8 +56,8 @@ TCPConnection::TCPConnection()
pState = TCPS_Ready; pState = TCPS_Ready;
pFree = false; pFree = false;
pEcho = false; pEcho = false;
recvbuf = NULL; recvbuf = nullptr;
sendbuf = NULL; sendbuf = nullptr;
pRunLoop = false; pRunLoop = false;
charAsyncConnect = 0; charAsyncConnect = 0;
pAsyncConnect = false; pAsyncConnect = false;
@ -78,8 +78,8 @@ TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 ir
pState = TCPS_Connected; pState = TCPS_Connected;
pFree = false; pFree = false;
pEcho = false; pEcho = false;
recvbuf = NULL; recvbuf = nullptr;
sendbuf = NULL; sendbuf = nullptr;
pRunLoop = false; pRunLoop = false;
charAsyncConnect = 0; charAsyncConnect = 0;
pAsyncConnect = false; pAsyncConnect = false;
@ -180,7 +180,7 @@ bool TCPConnection::Send(const uchar* data, int32 size) {
void TCPConnection::ServerSendQueuePushEnd(const uchar* data, int32 size) { void TCPConnection::ServerSendQueuePushEnd(const uchar* data, int32 size) {
MSendQueue.lock(); MSendQueue.lock();
if (sendbuf == NULL) { if (sendbuf == nullptr) {
sendbuf = new uchar[size]; sendbuf = new uchar[size];
sendbuf_size = size; sendbuf_size = size;
sendbuf_used = 0; sendbuf_used = 0;
@ -387,7 +387,7 @@ void TCPConnection::AsyncConnect(uint32 irIP, uint16 irPort) {
_beginthread(TCPConnectionLoop, 0, this); _beginthread(TCPConnectionLoop, 0, this);
#else #else
pthread_t thread; pthread_t thread;
pthread_create(&thread, NULL, TCPConnectionLoop, this); pthread_create(&thread, nullptr, TCPConnectionLoop, this);
#endif #endif
} }
return; return;
@ -433,7 +433,7 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
_beginthread(TCPConnectionLoop, 0, this); _beginthread(TCPConnectionLoop, 0, this);
#else #else
pthread_t thread; pthread_t thread;
pthread_create(&thread, NULL, TCPConnectionLoop, this); pthread_create(&thread, nullptr, TCPConnectionLoop, this);
#endif #endif
} }
@ -729,7 +729,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
case 10: case 10:
case 13: // newline marker case 13: // newline marker
{ {
char *line = NULL; char *line = nullptr;
if (i==0) { // empty line if (i==0) { // empty line
if(!m_previousLineEnd) { if(!m_previousLineEnd) {
//char right before this was NOT a CR, report the empty line. //char right before this was NOT a CR, report the empty line.
@ -772,7 +772,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
} }
if(line != NULL) { if(line != nullptr) {
bool finish_proc = false; bool finish_proc = false;
finish_proc = LineOutQueuePush(line); finish_proc = LineOutQueuePush(line);
if(finish_proc) if(finish_proc)
@ -896,7 +896,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif #endif
if (tmp == 0) { if (tmp == 0) {
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
TCPConnection* tcpc = (TCPConnection*) tmp; TCPConnection* tcpc = (TCPConnection*) tmp;
#ifndef WIN32 #ifndef WIN32
@ -932,7 +932,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
_log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
bool TCPConnection::RunLoop() { bool TCPConnection::RunLoop() {

View File

@ -33,7 +33,7 @@ BaseTCPServer::BaseTCPServer(uint16 in_port) {
_beginthread(BaseTCPServer::TCPServerLoop, 0, this); _beginthread(BaseTCPServer::TCPServerLoop, 0, this);
#else #else
pthread_t thread; pthread_t thread;
pthread_create(&thread, NULL, &BaseTCPServer::TCPServerLoop, this); pthread_create(&thread, nullptr, &BaseTCPServer::TCPServerLoop, this);
#endif #endif
} }
@ -67,7 +67,7 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif #endif
if (tmp == 0) { if (tmp == 0) {
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
BaseTCPServer* tcps = (BaseTCPServer*) tmp; BaseTCPServer* tcps = (BaseTCPServer*) tmp;
@ -87,7 +87,7 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
_log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
void BaseTCPServer::Process() { void BaseTCPServer::Process() {

View File

@ -71,7 +71,7 @@ public:
} }
T * NewQueuePop() { T * NewQueuePop() {
T * ret = NULL; T * ret = nullptr;
MNewQueue.lock(); MNewQueue.lock();
if(!m_NewQueue.empty()) { if(!m_NewQueue.empty()) {
ret = m_NewQueue.front(); ret = m_NewQueue.front();

View File

@ -31,14 +31,14 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
} }
TiXmlElement *root = doc.FirstChildElement( root_ele ); TiXmlElement *root = doc.FirstChildElement( root_ele );
if(root == NULL) { if(root == nullptr) {
printf("Unable to find root '%s' in %s\n",root_ele, file); printf("Unable to find root '%s' in %s\n",root_ele, file);
return(false); return(false);
} }
ParseOkay=true; ParseOkay=true;
TiXmlNode *main_element = NULL; TiXmlNode *main_element = nullptr;
while( (main_element = root->IterateChildren( main_element )) ) { while( (main_element = root->IterateChildren( main_element )) ) {
if(main_element->Type() != TiXmlNode::ELEMENT) if(main_element->Type() != TiXmlNode::ELEMENT)
continue; //skip crap we dont care about continue; //skip crap we dont care about
@ -71,30 +71,30 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
const char *XMLParser::ParseTextBlock(TiXmlNode *within, const char *name, bool optional) { const char *XMLParser::ParseTextBlock(TiXmlNode *within, const char *name, bool optional) {
TiXmlElement * txt = within->FirstChildElement(name); TiXmlElement * txt = within->FirstChildElement(name);
if(txt == NULL) { if(txt == nullptr) {
if(!optional) { if(!optional) {
printf("Unable to find a '%s' element on %s element at line %d\n", name, within->Value(), within->Row()); printf("Unable to find a '%s' element on %s element at line %d\n", name, within->Value(), within->Row());
ParseOkay=false; ParseOkay=false;
} }
return(NULL); return(nullptr);
} }
TiXmlNode *contents = txt->FirstChild(); TiXmlNode *contents = txt->FirstChild();
if(contents == NULL || contents->Type() != TiXmlNode::TEXT) { if(contents == nullptr || contents->Type() != TiXmlNode::TEXT) {
if(!optional) if(!optional)
printf("Node '%s' was expected to be a text element in %s element at line %d\n", name, txt->Value(), txt->Row()); printf("Node '%s' was expected to be a text element in %s element at line %d\n", name, txt->Value(), txt->Row());
return(NULL); return(nullptr);
} }
return(contents->Value()); return(contents->Value());
} }
const char *XMLParser::GetText(TiXmlNode *within, bool optional) { const char *XMLParser::GetText(TiXmlNode *within, bool optional) {
TiXmlNode *contents = within->FirstChild(); TiXmlNode *contents = within->FirstChild();
if(contents == NULL || contents->Type() != TiXmlNode::TEXT) { if(contents == nullptr || contents->Type() != TiXmlNode::TEXT) {
if(!optional) { if(!optional) {
printf("Node was expected to be a text element in %s element at line %d\n", within->Value(), within->Row()); printf("Node was expected to be a text element in %s element at line %d\n", within->Value(), within->Row());
ParseOkay=false; ParseOkay=false;
} }
return(NULL); return(nullptr);
} }
return(contents->Value()); return(contents->Value());
} }

View File

@ -428,7 +428,7 @@ bool Database::ReserveName(uint32 account_id, char* name)
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=NULL", account_id, name), errbuf)) { if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=nullptr", account_id, name), errbuf)) {
cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl; cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
@ -465,7 +465,7 @@ bool Database::DeleteCharacter(char *name)
if (query) if (query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
matches = mysql_num_rows(result); matches = mysql_num_rows(result);
if(matches == 1) if(matches == 1)
@ -482,7 +482,7 @@ bool Database::DeleteCharacter(char *name)
if(result) if(result)
{ {
mysql_free_result(result); mysql_free_result(result);
result = NULL; result = nullptr;
} }
return false; return false;
} }
@ -490,7 +490,7 @@ bool Database::DeleteCharacter(char *name)
if(result) if(result)
{ {
mysql_free_result(result); mysql_free_result(result);
result = NULL; result = nullptr;
} }
@ -499,195 +499,195 @@ bool Database::DeleteCharacter(char *name)
printf("DeleteCharacter: deleting '%s' (id %d): ", name, charid); printf("DeleteCharacter: deleting '%s' (id %d): ", name, charid);
printf(" quest_globals"); printf(" quest_globals");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from quest_globals WHERE charid='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from quest_globals WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" character_tasks"); printf(" character_tasks");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from character_tasks WHERE charid='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from character_tasks WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" character_activities"); printf(" character_activities");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from character_activities WHERE charid='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from character_activities WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" character_enabledtasks"); printf(" character_enabledtasks");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from character_enabledtasks WHERE charid='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from character_enabledtasks WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" completed_tasks"); printf(" completed_tasks");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from completed_tasks WHERE charid='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from completed_tasks WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" friends"); printf(" friends");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from friends WHERE charid='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from friends WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" mail"); printf(" mail");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from mail WHERE charid='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from mail WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" ptimers"); printf(" ptimers");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from timers WHERE char_id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from timers WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" inventory"); printf(" inventory");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from inventory WHERE charid='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from inventory WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" guild_members"); printf(" guild_members");
#endif #endif
#ifdef BOTS #ifdef BOTS
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM guild_members WHERE char_id='%d' AND GetMobTypeById(%i) = 'C'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM guild_members WHERE char_id='%d' AND GetMobTypeById(%i) = 'C'", charid), errbuf, nullptr, &affected_rows);
#else #else
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM guild_members WHERE char_id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM guild_members WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
#endif #endif
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" recipes"); printf(" recipes");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM char_recipe_list WHERE char_id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM char_recipe_list WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" adventure_stats"); printf(" adventure_stats");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM adventure_stats WHERE player_id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM adventure_stats WHERE player_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" zone_flags"); printf(" zone_flags");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM zone_flags WHERE charID='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM zone_flags WHERE charID='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" titles"); printf(" titles");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM titles WHERE char_id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM titles WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" titlesets"); printf(" titlesets");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM player_titlesets WHERE char_id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM player_titlesets WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" keyring"); printf(" keyring");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM keyring WHERE char_id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM keyring WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" factions"); printf(" factions");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM faction_values WHERE char_id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM faction_values WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" instances"); printf(" instances");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM instance_lockout_player WHERE charid='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM instance_lockout_player WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" _character"); printf(" _character");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE from character_ WHERE id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE from character_ WHERE id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
if(affected_rows != 1) // here we have to have a match or it's an error if(affected_rows != 1) // here we have to have a match or it's an error
{ {
@ -698,11 +698,11 @@ bool Database::DeleteCharacter(char *name)
#if DEBUG >= 5 #if DEBUG >= 5
printf(" alternate currency"); printf(" alternate currency");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM character_alt_currency WHERE char_id='%d'", charid), errbuf, NULL, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM character_alt_currency WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = NULL; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
@ -764,7 +764,7 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inven
} }
const char *zname = GetZoneName(pp->zone_id); const char *zname = GetZoneName(pp->zone_id);
if(zname == NULL) { if(zname == nullptr) {
//zone not in the DB, something to prevent crash... //zone not in the DB, something to prevent crash...
strn0cpy(zone, "qeynos", 49); strn0cpy(zone, "qeynos", 49);
pp->zone_id = 1; pp->zone_id = 1;
@ -1184,7 +1184,7 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe
*minstatus = atoi(row[3]); *minstatus = atoi(row[3]);
if (minlevel != 0) if (minlevel != 0)
*minlevel = atoi(row[4]); *minlevel = atoi(row[4]);
if (flag_needed != NULL) if (flag_needed != nullptr)
strcpy(flag_needed, row[5]); strcpy(flag_needed, row[5]);
mysql_free_result(result); mysql_free_result(result);
return true; return true;
@ -1196,9 +1196,9 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe
{ {
cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << endl; cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << endl;
cerr << "If it errors, run the following querys:\n"; cerr << "If it errors, run the following querys:\n";
cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n"; cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT nullptr;\n";
cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n"; cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT nullptr;\n";
cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n"; cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT nullptr DEFAULT '';\n";
safe_delete_array(query); safe_delete_array(query);
} }
@ -1682,7 +1682,7 @@ bool Database::MoveCharacterToZone(const char* charname, const char* zonename,ui
char *query = 0; char *query = 0;
uint32 affected_rows = 0; uint32 affected_rows = 0;
if(zonename == NULL || strlen(zonename) == 0) if(zonename == nullptr || strlen(zonename) == 0)
return(false); return(false);
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s',zoneid=%i,x=-1, y=-1, z=-1 WHERE name='%s'", zonename,zoneid, charname), errbuf, 0,&affected_rows)) { if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s',zoneid=%i,x=-1, y=-1, z=-1 WHERE name='%s'", zonename,zoneid, charname), errbuf, 0,&affected_rows)) {
@ -2113,7 +2113,7 @@ char *Database::GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* mainta
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
unsigned long* Lengths = mysql_fetch_lengths(result); unsigned long* Lengths = mysql_fetch_lengths(result);
if(row != NULL){ if(row != nullptr){
if(leaderbuf) if(leaderbuf)
strcpy(leaderbuf, row[0]); strcpy(leaderbuf, row[0]);
@ -2178,7 +2178,7 @@ MYSQL_ROW row;
unsigned long num_fields,i; unsigned long num_fields,i;
bool retval=false; bool retval=false;
rowmap.clear(); rowmap.clear();
if (result && (num_fields=mysql_num_fields(result)) && (row = mysql_fetch_row(result))!=NULL && (fields = mysql_fetch_fields(result))!=NULL) { if (result && (num_fields=mysql_num_fields(result)) && (row = mysql_fetch_row(result))!=nullptr && (fields = mysql_fetch_fields(result))!=nullptr) {
retval=true; retval=true;
for(i=0;i<num_fields;i++) { for(i=0;i<num_fields;i++) {
rowmap[fields[i].name]=(row[i] ? row[i] : ""); rowmap[fields[i].name]=(row[i] ? row[i] : "");
@ -2285,7 +2285,7 @@ const char *Database::GetRaidLeaderName(uint32 rid)
if (RunQuery(query, MakeAnyLenString(&query, "SELECT name FROM raid_members WHERE raidid=%u AND israidleader=1", if (RunQuery(query, MakeAnyLenString(&query, "SELECT name FROM raid_members WHERE raidid=%u AND israidleader=1",
rid), errbuf, &result)) { rid), errbuf, &result)) {
if((row = mysql_fetch_row(result)) != NULL) if((row = mysql_fetch_row(result)) != nullptr)
{ {
memset(name, 0, 128); memset(name, 0, 128);
strcpy(name, row[0]); strcpy(name, row[0]);
@ -2432,7 +2432,7 @@ bool Database::CheckInstanceExpired(uint16 instance_id)
} }
timeval tv; timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, nullptr);
if((start_time + duration) <= tv.tv_sec) if((start_time + duration) <= tv.tv_sec)
{ {
return true; return true;
@ -2553,7 +2553,7 @@ uint32 Database::GetTimeRemainingInstance(uint16 instance_id, bool &is_perma)
} }
timeval tv; timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, nullptr);
return ((start_time + duration) - tv.tv_sec); return ((start_time + duration) - tv.tv_sec);
} }
@ -2666,7 +2666,7 @@ void Database::PurgeExpiredInstances()
if (mysql_num_rows(result) > 0) if (mysql_num_rows(result) > 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
while(row != NULL) while(row != nullptr)
{ {
id = atoi(row[0]); id = atoi(row[0]);
DeleteInstance(id); DeleteInstance(id);
@ -2895,7 +2895,7 @@ void Database::AssignGroupToInstance(uint32 gid, uint32 instance_id)
errbuf, &result)) errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
while((row = mysql_fetch_row(result)) != NULL) while((row = mysql_fetch_row(result)) != nullptr)
{ {
uint32 charid = atoi(row[0]); uint32 charid = atoi(row[0]);
if(GetInstanceID(zone_id, charid, version) == 0) if(GetInstanceID(zone_id, charid, version) == 0)
@ -2924,7 +2924,7 @@ void Database::AssignRaidToInstance(uint32 rid, uint32 instance_id)
errbuf, &result)) errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
while((row = mysql_fetch_row(result)) != NULL) while((row = mysql_fetch_row(result)) != nullptr)
{ {
uint32 charid = atoi(row[0]); uint32 charid = atoi(row[0]);
if(GetInstanceID(zone_id, charid, version) == 0) if(GetInstanceID(zone_id, charid, version) == 0)
@ -3100,7 +3100,7 @@ void Database::UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win)
} }
if(RunQuery(query, MakeAnyLenString(&query, "UPDATE `adventure_stats` SET %s=%s+1 WHERE player_id=%u", if(RunQuery(query, MakeAnyLenString(&query, "UPDATE `adventure_stats` SET %s=%s+1 WHERE player_id=%u",
field.c_str(), field.c_str(), char_id), errbuf, NULL, &affected)) field.c_str(), field.c_str(), char_id), errbuf, nullptr, &affected))
{ {
safe_delete_array(query); safe_delete_array(query);
} }
@ -3138,7 +3138,7 @@ bool Database::GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, u
char_id), errbuf, &result)) char_id), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
while((row = mysql_fetch_row(result)) != NULL) while((row = mysql_fetch_row(result)) != nullptr)
{ {
guk_w = atoi(row[0]); guk_w = atoi(row[0]);
mir_w = atoi(row[1]); mir_w = atoi(row[1]);

View File

@ -38,7 +38,7 @@
using namespace std; using namespace std;
//atoi is not uint32 or uint32 safe!!!! //atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, NULL, 10) #define atoul(str) strtoul(str, nullptr, 10)
//class Spawn; //class Spawn;
class Corpse; class Corpse;
@ -204,8 +204,8 @@ public:
char* GetGroupLeaderForLogin(const char* name,char* leaderbuf); char* GetGroupLeaderForLogin(const char* name,char* leaderbuf);
void SetGroupLeaderName(uint32 gid, const char* name); void SetGroupLeaderName(uint32 gid, const char* name);
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = NULL, char* assist = NULL, char* puller = NULL, char *marknpc = NULL, char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr,
GroupLeadershipAA_Struct* GLAA = NULL); GroupLeadershipAA_Struct* GLAA = nullptr);
void ClearGroupLeader(uint32 gid = 0); void ClearGroupLeader(uint32 gid = 0);
/* /*
@ -236,8 +236,8 @@ public:
uint8 GetPEQZone(uint32 zoneID, uint32 version); uint8 GetPEQZone(uint32 zoneID, uint32 version);
const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false); const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false);
uint8 GetServerType(); uint8 GetServerType();
bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = NULL); bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr);
bool GetSafePoints(uint32 zoneID, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = NULL) { return GetSafePoints(GetZoneName(zoneID), version, safe_x, safe_y, safe_z, minstatus, minlevel, flag_needed); } bool GetSafePoints(uint32 zoneID, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr) { return GetSafePoints(GetZoneName(zoneID), version, safe_x, safe_y, safe_z, minstatus, minlevel, flag_needed); }
uint8 GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level); uint8 GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level);
uint8 GetRaceSkill(uint8 skillid, uint8 in_race); uint8 GetRaceSkill(uint8 skillid, uint8 in_race);
bool LoadPTimers(uint32 charid, PTimerList &into); bool LoadPTimers(uint32 charid, PTimerList &into);

View File

@ -65,7 +65,7 @@ ThreadReturnType DBAsyncLoop(void* tmp) {
_log(COMMON__THREADS, "Ending DBAsyncLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending DBAsyncLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(NULL); THREAD_RETURN(nullptr);
} }
DBAsync::DBAsync(DBcore* iDBC) DBAsync::DBAsync(DBcore* iDBC)
@ -78,7 +78,7 @@ DBAsync::DBAsync(DBcore* iDBC)
_beginthread(DBAsyncLoop, 0, this); _beginthread(DBAsyncLoop, 0, this);
#else #else
pthread_t thread; pthread_t thread;
pthread_create(&thread, NULL, DBAsyncLoop, this); pthread_create(&thread, nullptr, DBAsyncLoop, this);
#endif #endif
} }

View File

@ -45,9 +45,9 @@ EQEMuLog::EQEMuLog() {
#else #else
pLogStatus[i] = 0; pLogStatus[i] = 0;
#endif #endif
logCallbackFmt[i] = NULL; logCallbackFmt[i] = nullptr;
logCallbackBuf[i] = NULL; logCallbackBuf[i] = nullptr;
logCallbackPva[i] = NULL; logCallbackPva[i] = nullptr;
} }
// TODO: Make this read from an ini or something, everyone has different opinions on what it should be // TODO: Make this read from an ini or something, everyone has different opinions on what it should be
#if EQDEBUG < 2 #if EQDEBUG < 2

View File

@ -23,7 +23,7 @@ public:
~EQTime(); ~EQTime();
//Get functions //Get functions
int getEQTimeOfDay( TimeOfDay_Struct *eqTimeOfDay ) { return(getEQTimeOfDay(time(NULL), eqTimeOfDay)); } int getEQTimeOfDay( TimeOfDay_Struct *eqTimeOfDay ) { return(getEQTimeOfDay(time(nullptr), eqTimeOfDay)); }
int getEQTimeOfDay( time_t timeConvert, TimeOfDay_Struct *eqTimeOfDay ); int getEQTimeOfDay( time_t timeConvert, TimeOfDay_Struct *eqTimeOfDay );
TimeOfDay_Struct getStartEQTime() { return eqTime.start_eqtime; } TimeOfDay_Struct getStartEQTime() { return eqTime.start_eqtime; }
time_t getStartRealTime() { return eqTime.start_realtime; } time_t getStartRealTime() { return eqTime.start_realtime; }

View File

@ -26,7 +26,7 @@ void InitExtendedProfile(ExtendedProfile_Struct *p) {
} }
bool SetExtendedProfile(ExtendedProfile_Struct *to, char *old, unsigned int len) { bool SetExtendedProfile(ExtendedProfile_Struct *to, char *old, unsigned int len) {
if(len == 0 || old == NULL) { if(len == 0 || old == nullptr) {
//handle old chars without an extended profile... //handle old chars without an extended profile...
InitExtendedProfile(to); InitExtendedProfile(to);
return(true); return(true);

View File

@ -31,7 +31,7 @@ const char *const BaseGuildManager::GuildActionNames[_MaxGuildAction] =
{ "HearGuildChat", "SpeakGuildChat", "Invite", "Remove", "Promote", "Demote", "Set_MOTD", "War/Peace" }; { "HearGuildChat", "SpeakGuildChat", "Invite", "Remove", "Promote", "Demote", "Set_MOTD", "War/Peace" };
BaseGuildManager::BaseGuildManager() BaseGuildManager::BaseGuildManager()
: m_db(NULL) : m_db(nullptr)
{ {
} }
@ -43,7 +43,7 @@ bool BaseGuildManager::LoadGuilds() {
ClearGuilds(); ClearGuilds();
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested to load guilds when we have no database object."); _log(GUILDS__DB, "Requested to load guilds when we have no database object.");
return(false); return(false);
} }
@ -107,7 +107,7 @@ bool BaseGuildManager::LoadGuilds() {
} }
bool BaseGuildManager::RefreshGuild(uint32 guild_id) { bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested to refresh guild %d when we have no database object.", guild_id); _log(GUILDS__DB, "Requested to refresh guild %d when we have no database object.", guild_id);
return(false); return(false);
} }
@ -217,7 +217,7 @@ BaseGuildManager::GuildInfo *BaseGuildManager::_CreateGuild(uint32 guild_id, con
} }
bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) { bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested to store guild %d when we have no database object.", guild_id); _log(GUILDS__DB, "Requested to store guild %d when we have no database object.", guild_id);
return(false); return(false);
} }
@ -310,7 +310,7 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
} }
uint32 BaseGuildManager::_GetFreeGuildID() { uint32 BaseGuildManager::_GetFreeGuildID() {
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested find a free guild ID when we have no database object."); _log(GUILDS__DB, "Requested find a free guild ID when we have no database object.");
return(GUILD_NONE); return(GUILD_NONE);
} }
@ -523,7 +523,7 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) {
m_guilds.erase(res); m_guilds.erase(res);
} }
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested to delete guild %d when we have no database object.", guild_id); _log(GUILDS__DB, "Requested to delete guild %d when we have no database object.", guild_id);
return(false); return(false);
} }
@ -552,7 +552,7 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) {
} }
bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) { bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested to rename guild %d when we have no database object.", guild_id); _log(GUILDS__DB, "Requested to rename guild %d when we have no database object.", guild_id);
return(false); return(false);
} }
@ -592,7 +592,7 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
} }
bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) { bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested to set the leader for guild %d when we have no database object.", guild_id); _log(GUILDS__DB, "Requested to set the leader for guild %d when we have no database object.", guild_id);
return(false); return(false);
} }
@ -632,7 +632,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
} }
bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const char *setter) { bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const char *setter) {
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested to set the MOTD for guild %d when we have no database object.", guild_id); _log(GUILDS__DB, "Requested to set the MOTD for guild %d when we have no database object.", guild_id);
return(false); return(false);
} }
@ -679,7 +679,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL) bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
{ {
if(m_db == NULL) if(m_db == nullptr)
return(false); return(false);
map<uint32, GuildInfo *>::const_iterator res; map<uint32, GuildInfo *>::const_iterator res;
@ -720,7 +720,7 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel) bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
{ {
if(m_db == NULL) if(m_db == nullptr)
return(false); return(false);
map<uint32, GuildInfo *>::const_iterator res; map<uint32, GuildInfo *>::const_iterator res;
@ -760,7 +760,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
} }
bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) { bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested to set char to guild %d when we have no database object.", guild_id); _log(GUILDS__DB, "Requested to set char to guild %d when we have no database object.", guild_id);
return(false); return(false);
} }
@ -891,7 +891,7 @@ bool BaseGuildManager::DBSetTributeFlag(uint32 charid, bool enabled) {
} }
bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) { bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) {
if(m_db == NULL) if(m_db == nullptr)
return(false); return(false);
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
@ -921,7 +921,7 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) {
} }
bool BaseGuildManager::_RunQuery(char *&query, int len, const char *errmsg) { bool BaseGuildManager::_RunQuery(char *&query, int len, const char *errmsg) {
if(m_db == NULL) if(m_db == nullptr)
return(false); return(false);
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
@ -981,7 +981,7 @@ static void ProcessGuildMember(MYSQL_ROW &row, CharGuildInfo &into) {
bool BaseGuildManager::GetEntireGuild(uint32 guild_id, vector<CharGuildInfo *> &members) { bool BaseGuildManager::GetEntireGuild(uint32 guild_id, vector<CharGuildInfo *> &members) {
members.clear(); members.clear();
if(m_db == NULL) if(m_db == nullptr)
return(false); return(false);
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
@ -1012,7 +1012,7 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, vector<CharGuildInfo *> &
} }
bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) { bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested char info on %s when we have no database object.", char_name); _log(GUILDS__DB, "Requested char info on %s when we have no database object.", char_name);
return(false); return(false);
} }
@ -1054,7 +1054,7 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
} }
bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) { bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
if(m_db == NULL) { if(m_db == nullptr) {
_log(GUILDS__DB, "Requested char info on %d when we have no database object.", char_id); _log(GUILDS__DB, "Requested char info on %d when we have no database object.", char_id);
return(false); return(false);
} }

View File

@ -44,7 +44,7 @@ namespace EQEmu {
std::string final_name = "EQEmuMutex_"; std::string final_name = "EQEmuMutex_";
final_name += name; final_name += name;
imp_->mut_ = CreateMutex(NULL, imp_->mut_ = CreateMutex(nullptr,
FALSE, FALSE,
final_name.c_str()); final_name.c_str());

View File

@ -88,11 +88,11 @@ void log_toggle(LogType t) {
bool load_log_settings(const char *filename) { bool load_log_settings(const char *filename) {
//this is a terrible algorithm, but im lazy today //this is a terrible algorithm, but im lazy today
FILE *f = fopen(filename, "r"); FILE *f = fopen(filename, "r");
if(f == NULL) if(f == nullptr)
return(false); return(false);
char linebuf[512], type_name[256], value[256]; char linebuf[512], type_name[256], value[256];
while(!feof(f)) { while(!feof(f)) {
if(fgets(linebuf, 512, f) == NULL) if(fgets(linebuf, 512, f) == nullptr)
continue; continue;
#ifdef _WINDOWS #ifdef _WINDOWS
if (sscanf(linebuf, "%[^=]=%[^\n]\n", type_name, value) != 2) if (sscanf(linebuf, "%[^=]=%[^\n]\n", type_name, value) != 2)

View File

@ -49,17 +49,17 @@ namespace EQEmu {
HANDLE file = CreateFile(filename.c_str(), HANDLE file = CreateFile(filename.c_str(),
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, nullptr,
OPEN_ALWAYS, OPEN_ALWAYS,
0, 0,
NULL); nullptr);
if(file == INVALID_HANDLE_VALUE) { if(file == INVALID_HANDLE_VALUE) {
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
} }
imp_->mapped_object_ = CreateFileMapping(file, imp_->mapped_object_ = CreateFileMapping(file,
NULL, nullptr,
PAGE_READWRITE, PAGE_READWRITE,
0, 0,
total_size, total_size,
@ -91,7 +91,7 @@ namespace EQEmu {
} }
memory_ = reinterpret_cast<shared_memory_struct*>( memory_ = reinterpret_cast<shared_memory_struct*>(
mmap(NULL, total_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, imp_->fd_, 0)); mmap(nullptr, total_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, imp_->fd_, 0));
if(memory_ == MAP_FAILED) { if(memory_ == MAP_FAILED) {
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file."); EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");
@ -118,17 +118,17 @@ namespace EQEmu {
HANDLE file = CreateFile(filename.c_str(), HANDLE file = CreateFile(filename.c_str(),
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, nullptr,
OPEN_ALWAYS, OPEN_ALWAYS,
0, 0,
NULL); nullptr);
if(file == INVALID_HANDLE_VALUE) { if(file == INVALID_HANDLE_VALUE) {
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
} }
imp_->mapped_object_ = CreateFileMapping(file, imp_->mapped_object_ = CreateFileMapping(file,
NULL, nullptr,
PAGE_READWRITE, PAGE_READWRITE,
0, 0,
total_size, total_size,
@ -160,7 +160,7 @@ namespace EQEmu {
} }
memory_ = reinterpret_cast<shared_memory_struct*>( memory_ = reinterpret_cast<shared_memory_struct*>(
mmap(NULL, total_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, imp_->fd_, 0)); mmap(nullptr, total_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, imp_->fd_, 0));
if(memory_ == MAP_FAILED) { if(memory_ == MAP_FAILED) {
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file."); EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");

View File

@ -41,7 +41,7 @@ int print_stacktrace()
if (n != 0) if (n != 0)
{ {
char **names = backtrace_symbols (ba, n); char **names = backtrace_symbols (ba, n);
if (names != NULL) if (names != nullptr)
{ {
int i; int i;
cerr << "called from " << (char*)names[0] << endl; cerr << "called from " << (char*)names[0] << endl;
@ -82,9 +82,9 @@ bool ItemParse(const char *data, int length, map<int,map<int,string> > &items, i
int i; int i;
char *end,*ptr; char *end,*ptr;
map<int,string> field; map<int,string> field;
static char *buffer=NULL; static char *buffer=nullptr;
static int buffsize=0; static int buffsize=0;
static char *temp=NULL; static char *temp=nullptr;
if (!buffsize || buffsize<(length+1)) { if (!buffsize || buffsize<(length+1)) {
buffer=(char *)realloc(buffer,length+1); buffer=(char *)realloc(buffer,length+1);
temp=(char *)realloc(temp,length+1); temp=(char *)realloc(temp,length+1);
@ -97,7 +97,7 @@ static char *temp=NULL;
for(i=0;i<name_pos-1;i++) { for(i=0;i<name_pos-1;i++) {
end=ptr-1; end=ptr-1;
while((end=strchr(end+1,'|'))!=NULL) { while((end=strchr(end+1,'|'))!=nullptr) {
if (*(end-1)!='\\') if (*(end-1)!='\\')
break; break;
} }
@ -121,7 +121,7 @@ static char *temp=NULL;
for(i=(name_pos-1);i<(max_field-1);i++) { for(i=(name_pos-1);i<(max_field-1);i++) {
end=ptr-1; end=ptr-1;
while((end=strchr(end+1,'|'))!=NULL) { while((end=strchr(end+1,'|'))!=nullptr) {
if (*(end-1)!='\\') if (*(end-1)!='\\')
break; break;
} }
@ -160,7 +160,7 @@ static char *temp=NULL;
for(i=0;i<10;i++) { for(i=0;i<10;i++) {
if (*ptr=='"') { if (*ptr=='"') {
end=ptr; end=ptr;
while((end=strchr(end+1,'"'))!=NULL && *(end-1)=='\\'); while((end=strchr(end+1,'"'))!=nullptr && *(end-1)=='\\');
if (end) { if (end) {
string sub; string sub;
sub.assign(ptr+1,end-ptr-1); sub.assign(ptr+1,end-ptr-1);
@ -532,7 +532,7 @@ int i;
timeval now; timeval now;
static const char *chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; static const char *chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for(i=0;i<length;i++) { for(i=0;i<length;i++) {
gettimeofday(&now,NULL); gettimeofday(&now,nullptr);
srand(now.tv_sec^now.tv_usec); srand(now.tv_sec^now.tv_usec);
key+=(char)chars[(int) (36.0*rand()/(RAND_MAX+1.0))]; key+=(char)chars[(int) (36.0*rand()/(RAND_MAX+1.0))];
} }

View File

@ -33,7 +33,7 @@ OpcodeManager::OpcodeManager() {
bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors) { bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors) {
FILE *opf = fopen(filename, "r"); FILE *opf = fopen(filename, "r");
if(opf == NULL) { if(opf == nullptr) {
fprintf(stderr, "Unable to open opcodes file '%s'. Thats bad.\n", filename); fprintf(stderr, "Unable to open opcodes file '%s'. Thats bad.\n", filename);
return(false); return(false);
} }
@ -47,7 +47,7 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
while(!feof(opf)) { while(!feof(opf)) {
lineno++; lineno++;
line[0] = '\0'; //for blank line at end of file line[0] = '\0'; //for blank line at end of file
if(fgets(line, sizeof(line), opf) == NULL) if(fgets(line, sizeof(line), opf) == nullptr)
break; break;
//ignore any line that dosent start with OP_ //ignore any line that dosent start with OP_
@ -135,8 +135,8 @@ EmuOpcode OpcodeManager::NameSearch(const char *name) {
RegularOpcodeManager::RegularOpcodeManager() RegularOpcodeManager::RegularOpcodeManager()
: MutableOpcodeManager() : MutableOpcodeManager()
{ {
emu_to_eq = NULL; emu_to_eq = nullptr;
eq_to_emu = NULL; eq_to_emu = nullptr;
} }
RegularOpcodeManager::~RegularOpcodeManager() { RegularOpcodeManager::~RegularOpcodeManager() {

View File

@ -102,7 +102,7 @@ int DeflatePacket(const unsigned char* in_data, int in_length, unsigned char* ou
static z_stream zstream; static z_stream zstream;
int zerror; int zerror;
if(in_data == NULL && out_data == NULL && in_length == 0 && max_out_length == 0) { if(in_data == nullptr && out_data == nullptr && in_length == 0 && max_out_length == 0) {
//special delete state //special delete state
deflateEnd(&zstream); deflateEnd(&zstream);
return(0); return(0);
@ -138,7 +138,7 @@ int DeflatePacket(const unsigned char* in_data, int in_length, unsigned char* ou
return 0; return 0;
} }
#else #else
if(in_data == NULL) { if(in_data == nullptr) {
return(0); return(0);
} }
@ -175,7 +175,7 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
static z_stream zstream; static z_stream zstream;
int zerror; int zerror;
if(indata == NULL && outdata == NULL && indatalen == 0 && outdatalen == 0) { if(indata == nullptr && outdata == nullptr && indatalen == 0 && outdatalen == 0) {
//special delete state //special delete state
inflateEnd(&zstream); inflateEnd(&zstream);
return(0); return(0);
@ -226,7 +226,7 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
return 0; return 0;
} }
#else #else
if(indata == NULL) if(indata == nullptr)
return(0); return(0);
z_stream zstream; z_stream zstream;

View File

@ -15,14 +15,14 @@
namespace Client62 { namespace Client62 {
static const char *name = "6.2"; static const char *name = "6.2";
static OpcodeManager *opcodes = NULL; static OpcodeManager *opcodes = nullptr;
static Strategy struct_strategy; static Strategy struct_strategy;
char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth); char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth);
void Register(EQStreamIdentifier &into) { void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == NULL) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -64,7 +64,7 @@ void Reload() {
//opcode managers because we need to change the manager pointer, which means //opcode managers because we need to change the manager pointer, which means
//we need to go to every stream and replace it's manager. //we need to go to every stream and replace it's manager.
if(opcodes != NULL) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -372,7 +372,7 @@ ENCODE(OP_Track)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
Track_Struct *emu = (Track_Struct *) __emu_buffer; Track_Struct *emu = (Track_Struct *) __emu_buffer;
@ -407,7 +407,7 @@ ENCODE(OP_ZoneEntry){ ENCODE_FORWARD(OP_ZoneSpawns); }
ENCODE(OP_ZoneSpawns) { ENCODE(OP_ZoneSpawns) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -502,7 +502,7 @@ ENCODE(OP_ItemLinkResponse) { ENCODE_FORWARD(OP_ItemPacket); }
ENCODE(OP_ItemPacket) { ENCODE(OP_ItemPacket) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -531,7 +531,7 @@ ENCODE(OP_ItemPacket) {
ENCODE(OP_CharInventory) { ENCODE(OP_CharInventory) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -570,7 +570,7 @@ ENCODE(OP_CharInventory) {
ENCODE(OP_GuildMemberList) { ENCODE(OP_GuildMemberList) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -660,7 +660,7 @@ ENCODE(OP_GuildMemberList) {
ENCODE(OP_ReadBook) { ENCODE(OP_ReadBook) {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -709,7 +709,7 @@ ENCODE(OP_Illusion) {
ENCODE(OP_BazaarSearch) ENCODE(OP_BazaarSearch)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *Buffer = (char *)in->pBuffer; char *Buffer = (char *)in->pBuffer;
@ -949,10 +949,10 @@ DECODE(OP_FaceChange) {
} }
char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth) { char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth) {
char *serialization = NULL; char *serialization = nullptr;
char *instance = NULL; char *instance = nullptr;
const char *protection=(const char *)"\\\\\\\\\\"; const char *protection=(const char *)"\\\\\\\\\\";
char *sub_items[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; char *sub_items[10] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
bool stackable=inst->IsStackable(); bool stackable=inst->IsStackable();
uint32 merchant_slot=inst->GetMerchantSlot(); uint32 merchant_slot=inst->GetMerchantSlot();
int16 charges=inst->GetCharges(); int16 charges=inst->GetCharges();

View File

@ -18,14 +18,14 @@
namespace RoF { namespace RoF {
static const char *name = "RoF"; static const char *name = "RoF";
static OpcodeManager *opcodes = NULL; static OpcodeManager *opcodes = nullptr;
static Strategy struct_strategy; static Strategy struct_strategy;
char* SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth); char* SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth);
void Register(EQStreamIdentifier &into) { void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == NULL) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -69,7 +69,7 @@ void Reload() {
//opcode managers because we need to change the manager pointer, which means //opcode managers because we need to change the manager pointer, which means
//we need to go to every stream and replace it's manager. //we need to go to every stream and replace it's manager.
if(opcodes != NULL) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -403,7 +403,7 @@ static inline structs::MainInvItemSlotStruct MainInvTitaniumToRoFSlot(uint32 Tit
ENCODE(OP_TaskHistoryReply) ENCODE(OP_TaskHistoryReply)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
// First we need to calculate the length of the new packet // First we need to calculate the length of the new packet
in->SetReadPosition(4); in->SetReadPosition(4);
@ -522,7 +522,7 @@ ENCODE(OP_TaskHistoryReply)
ENCODE(OP_TaskDescription) ENCODE(OP_TaskDescription)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
EQApplicationPacket *outapp = new EQApplicationPacket(OP_TaskDescription, in->size + 1); EQApplicationPacket *outapp = new EQApplicationPacket(OP_TaskDescription, in->size + 1);
// Set the Write pointer as we don't know what has been done with the packet before we get it. // Set the Write pointer as we don't know what has been done with the packet before we get it.
@ -539,7 +539,7 @@ ENCODE(OP_TaskDescription)
outapp->WriteUInt32(in->ReadUInt32()); // Duration outapp->WriteUInt32(in->ReadUInt32()); // Duration
outapp->WriteUInt32(in->ReadUInt32()); // Unknown outapp->WriteUInt32(in->ReadUInt32()); // Unknown
uint32 StartTime = in->ReadUInt32(); uint32 StartTime = in->ReadUInt32();
outapp->WriteUInt32(time(NULL) - StartTime); // RoF has elapsed time here rather than starttime outapp->WriteUInt32(time(nullptr) - StartTime); // RoF has elapsed time here rather than starttime
// Copy the rest of the packet verbatim // Copy the rest of the packet verbatim
uint32 BytesLeftToCopy = in->size - in->GetReadPosition(); uint32 BytesLeftToCopy = in->size - in->GetReadPosition();
@ -564,7 +564,7 @@ ENCODE(OP_OpenNewTasksWindow) {
structs::AvailableTaskTrailer_Struct* __eq_AvailableTaskTrailer; structs::AvailableTaskTrailer_Struct* __eq_AvailableTaskTrailer;
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -847,7 +847,7 @@ ENCODE(OP_LeadershipExpUpdate) {
ENCODE(OP_PlayerProfile) ENCODE(OP_PlayerProfile)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
PlayerProfile_Struct *emu = (PlayerProfile_Struct *) __emu_buffer; PlayerProfile_Struct *emu = (PlayerProfile_Struct *) __emu_buffer;
@ -1631,7 +1631,7 @@ ENCODE(OP_NewZone) {
ENCODE(OP_Track) ENCODE(OP_Track)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
Track_Struct *emu = (Track_Struct *) __emu_buffer; Track_Struct *emu = (Track_Struct *) __emu_buffer;
@ -1709,7 +1709,7 @@ ENCODE(OP_PetBuffWindow)
ENCODE(OP_Barter) ENCODE(OP_Barter)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *Buffer = (char *)in->pBuffer; char *Buffer = (char *)in->pBuffer;
@ -1750,7 +1750,7 @@ ENCODE(OP_Barter)
ENCODE(OP_BazaarSearch) ENCODE(OP_BazaarSearch)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *Buffer = (char *)in->pBuffer; char *Buffer = (char *)in->pBuffer;
@ -1807,7 +1807,7 @@ ENCODE(OP_ZoneSpawns)
{ {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -2074,7 +2074,7 @@ ENCODE(OP_ZoneSpawns)
ENCODE(OP_MercenaryDataResponse) { ENCODE(OP_MercenaryDataResponse) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -2138,7 +2138,7 @@ ENCODE(OP_MercenaryDataResponse) {
ENCODE(OP_MercenaryDataUpdate) { ENCODE(OP_MercenaryDataUpdate) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -2218,7 +2218,7 @@ ENCODE(OP_ItemLinkResponse) { ENCODE_FORWARD(OP_ItemPacket); }
ENCODE(OP_ItemPacket) { ENCODE(OP_ItemPacket) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer; ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer;
@ -2247,7 +2247,7 @@ ENCODE(OP_CharInventory) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
if(in->size == 0) { if(in->size == 0) {
@ -2325,7 +2325,7 @@ ENCODE(OP_CharInventory) {
ENCODE(OP_GuildMemberList) { ENCODE(OP_GuildMemberList) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -2456,7 +2456,7 @@ ENCODE(OP_GroundSpawn)
// We are not encoding the spawn_id field here, but it doesn't appear to matter. // We are not encoding the spawn_id field here, but it doesn't appear to matter.
// //
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
Object_Struct *emu = (Object_Struct *) in->pBuffer; Object_Struct *emu = (Object_Struct *) in->pBuffer;
@ -2782,7 +2782,7 @@ ENCODE(OP_Buff) {
eq->bufffade = 2; eq->bufffade = 2;
// Bit of a hack. OP_Buff appears to add/remove the buff while OP_BuffCreate adds/removes the actual buff icon // Bit of a hack. OP_Buff appears to add/remove the buff while OP_BuffCreate adds/removes the actual buff icon
EQApplicationPacket *outapp = NULL; EQApplicationPacket *outapp = nullptr;
if(eq->bufffade == 1) if(eq->bufffade == 1)
{ {
outapp = new EQApplicationPacket(OP_BuffCreate, 29); outapp = new EQApplicationPacket(OP_BuffCreate, 29);
@ -3086,7 +3086,7 @@ ENCODE(OP_AdventureMerchantSell) {
ENCODE(OP_RaidUpdate) ENCODE(OP_RaidUpdate)
{ {
EQApplicationPacket *inapp = *p; EQApplicationPacket *inapp = *p;
*p = NULL; *p = nullptr;
unsigned char * __emu_buffer = inapp->pBuffer; unsigned char * __emu_buffer = inapp->pBuffer;
RaidGeneral_Struct *raid_gen = (RaidGeneral_Struct*)__emu_buffer; RaidGeneral_Struct *raid_gen = (RaidGeneral_Struct*)__emu_buffer;
@ -3150,7 +3150,7 @@ ENCODE(OP_VetRewardsAvaliable)
unsigned char * __emu_buffer = inapp->pBuffer; unsigned char * __emu_buffer = inapp->pBuffer;
uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward));
*p = NULL; *p = nullptr;
EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count));
uchar *old_data = __emu_buffer; uchar *old_data = __emu_buffer;
@ -3181,7 +3181,7 @@ ENCODE(OP_VetRewardsAvaliable)
ENCODE(OP_WhoAllResponse) ENCODE(OP_WhoAllResponse)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *InBuffer = (char *)in->pBuffer; char *InBuffer = (char *)in->pBuffer;
@ -3481,7 +3481,7 @@ ENCODE(OP_GroupUpdate)
ENCODE(OP_ChannelMessage) ENCODE(OP_ChannelMessage)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
ChannelMessage_Struct *emu = (ChannelMessage_Struct *) in->pBuffer; ChannelMessage_Struct *emu = (ChannelMessage_Struct *) in->pBuffer;
@ -3517,7 +3517,7 @@ ENCODE(OP_ChannelMessage)
ENCODE(OP_GuildsList) ENCODE(OP_GuildsList)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
uint32 NumberOfGuilds = in->size / 64; uint32 NumberOfGuilds = in->size / 64;
@ -3768,7 +3768,7 @@ ENCODE(OP_WearChange)
ENCODE(OP_SpawnAppearance) ENCODE(OP_SpawnAppearance)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *emu_buffer = in->pBuffer; unsigned char *emu_buffer = in->pBuffer;
@ -3872,7 +3872,7 @@ ENCODE(OP_AltCurrencySell)
ENCODE(OP_AltCurrency) ENCODE(OP_AltCurrency)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *emu_buffer = in->pBuffer; unsigned char *emu_buffer = in->pBuffer;
uint32 opcode = *((uint32*)emu_buffer); uint32 opcode = *((uint32*)emu_buffer);
@ -5307,7 +5307,7 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
for(int x = 0; x < 10; ++x) { for(int x = 0; x < 10; ++x) {
SubSerializations[x] = NULL; SubSerializations[x] = nullptr;
const ItemInst* subitem = ((const ItemInst*)inst)->GetItem(x); const ItemInst* subitem = ((const ItemInst*)inst)->GetItem(x);

View File

@ -18,7 +18,7 @@
#define FASTQUEUE(packet) dest->FastQueuePacket(&packet, ack_req); #define FASTQUEUE(packet) dest->FastQueuePacket(&packet, ack_req);
#define TAKE(packet_name) \ #define TAKE(packet_name) \
EQApplicationPacket *packet_name = *p; \ EQApplicationPacket *packet_name = *p; \
*p = NULL; *p = nullptr;
//simple buffer-to-buffer movement for fixed length packets //simple buffer-to-buffer movement for fixed length packets
//the eq packet is mapped into `eq`, the emu packet into `emu` //the eq packet is mapped into `eq`, the emu packet into `emu`
@ -29,7 +29,7 @@
//like a direct encode, but for variable length packets (two stage) //like a direct encode, but for variable length packets (two stage)
#define SETUP_VAR_ENCODE(emu_struct) \ #define SETUP_VAR_ENCODE(emu_struct) \
EQApplicationPacket *__packet = *p; \ EQApplicationPacket *__packet = *p; \
*p = NULL; \ *p = nullptr; \
unsigned char *__emu_buffer = __packet->pBuffer; \ unsigned char *__emu_buffer = __packet->pBuffer; \
emu_struct *emu = (emu_struct *) __emu_buffer; \ emu_struct *emu = (emu_struct *) __emu_buffer; \
uint32 __i = 0; \ uint32 __i = 0; \
@ -67,7 +67,7 @@
_log(NET__STRUCTS, "Wrong size on outbound %s (" #struct_ "): Got %d, expected %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \ _log(NET__STRUCTS, "Wrong size on outbound %s (" #struct_ "): Got %d, expected %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \
_hex(NET__STRUCT_HEX, (*p)->pBuffer, (*p)->size); \ _hex(NET__STRUCT_HEX, (*p)->pBuffer, (*p)->size); \
delete *p; \ delete *p; \
*p = NULL; \ *p = nullptr; \
return; \ return; \
} }
#define ENCODE_LENGTH_ATLEAST(struct_) \ #define ENCODE_LENGTH_ATLEAST(struct_) \
@ -75,7 +75,7 @@
_log(NET__STRUCTS, "Wrong size on outbound %s (" #struct_ "): Got %d, expected at least %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \ _log(NET__STRUCTS, "Wrong size on outbound %s (" #struct_ "): Got %d, expected at least %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \
_hex(NET__STRUCT_HEX, (*p)->pBuffer, (*p)->size); \ _hex(NET__STRUCT_HEX, (*p)->pBuffer, (*p)->size); \
delete *p; \ delete *p; \
*p = NULL; \ *p = nullptr; \
return; \ return; \
} }
@ -87,7 +87,7 @@
#define EAT_ENCODE(op) \ #define EAT_ENCODE(op) \
ENCODE(op) { \ ENCODE(op) { \
delete *p; \ delete *p; \
*p = NULL; \ *p = nullptr; \
} }

View File

@ -18,14 +18,14 @@
namespace SoD { namespace SoD {
static const char *name = "SoD"; static const char *name = "SoD";
static OpcodeManager *opcodes = NULL; static OpcodeManager *opcodes = nullptr;
static Strategy struct_strategy; static Strategy struct_strategy;
char* SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth); char* SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth);
void Register(EQStreamIdentifier &into) { void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == NULL) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -69,7 +69,7 @@ void Reload() {
//opcode managers because we need to change the manager pointer, which means //opcode managers because we need to change the manager pointer, which means
//we need to go to every stream and replace it's manager. //we need to go to every stream and replace it's manager.
if(opcodes != NULL) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -185,7 +185,7 @@ ENCODE(OP_OpenNewTasksWindow) {
structs::AvailableTaskTrailer_Struct* __eq_AvailableTaskTrailer; structs::AvailableTaskTrailer_Struct* __eq_AvailableTaskTrailer;
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -749,7 +749,7 @@ ENCODE(OP_NewZone) {
ENCODE(OP_Track) ENCODE(OP_Track)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
Track_Struct *emu = (Track_Struct *) __emu_buffer; Track_Struct *emu = (Track_Struct *) __emu_buffer;
@ -795,7 +795,7 @@ ENCODE(OP_Track)
ENCODE(OP_PetBuffWindow) ENCODE(OP_PetBuffWindow)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -832,7 +832,7 @@ ENCODE(OP_PetBuffWindow)
ENCODE(OP_Barter) ENCODE(OP_Barter)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *Buffer = (char *)in->pBuffer; char *Buffer = (char *)in->pBuffer;
@ -889,7 +889,7 @@ DECODE(OP_InspectRequest) {
ENCODE(OP_BazaarSearch) ENCODE(OP_BazaarSearch)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *Buffer = (char *)in->pBuffer; char *Buffer = (char *)in->pBuffer;
@ -945,7 +945,7 @@ ENCODE(OP_ZoneEntry){ ENCODE_FORWARD(OP_ZoneSpawns); }
ENCODE(OP_ZoneSpawns) { ENCODE(OP_ZoneSpawns) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1261,7 +1261,7 @@ ENCODE(OP_ZoneSpawns) {
ENCODE(OP_MercenaryDataResponse) { ENCODE(OP_MercenaryDataResponse) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1328,7 +1328,7 @@ ENCODE(OP_MercenaryDataResponse) {
ENCODE(OP_MercenaryDataUpdate) { ENCODE(OP_MercenaryDataUpdate) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1399,7 +1399,7 @@ ENCODE(OP_ItemLinkResponse) { ENCODE_FORWARD(OP_ItemPacket); }
ENCODE(OP_ItemPacket) { ENCODE(OP_ItemPacket) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer; ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer;
@ -1428,7 +1428,7 @@ ENCODE(OP_CharInventory) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
if(in->size == 0) { if(in->size == 0) {
@ -1506,7 +1506,7 @@ ENCODE(OP_CharInventory) {
ENCODE(OP_GuildMemberList) { ENCODE(OP_GuildMemberList) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1875,7 +1875,7 @@ ENCODE(OP_Trader) {
if((*p)->size != sizeof(TraderBuy_Struct)) { if((*p)->size != sizeof(TraderBuy_Struct)) {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
dest->FastQueuePacket(&in, ack_req); dest->FastQueuePacket(&in, ack_req);
return; return;
} }
@ -2033,7 +2033,7 @@ ENCODE(OP_AdventureMerchantSell) {
ENCODE(OP_RaidUpdate) ENCODE(OP_RaidUpdate)
{ {
EQApplicationPacket *inapp = *p; EQApplicationPacket *inapp = *p;
*p = NULL; *p = nullptr;
unsigned char * __emu_buffer = inapp->pBuffer; unsigned char * __emu_buffer = inapp->pBuffer;
RaidGeneral_Struct *raid_gen = (RaidGeneral_Struct*)__emu_buffer; RaidGeneral_Struct *raid_gen = (RaidGeneral_Struct*)__emu_buffer;
@ -2097,7 +2097,7 @@ ENCODE(OP_VetRewardsAvaliable)
unsigned char * __emu_buffer = inapp->pBuffer; unsigned char * __emu_buffer = inapp->pBuffer;
uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward));
*p = NULL; *p = nullptr;
EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count));
uchar *old_data = __emu_buffer; uchar *old_data = __emu_buffer;
@ -2128,7 +2128,7 @@ ENCODE(OP_VetRewardsAvaliable)
ENCODE(OP_WhoAllResponse) ENCODE(OP_WhoAllResponse)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *InBuffer = (char *)in->pBuffer; char *InBuffer = (char *)in->pBuffer;
@ -3453,7 +3453,7 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
for(int x = 0; x < 10; ++x) { for(int x = 0; x < 10; ++x) {
SubSerializations[x] = NULL; SubSerializations[x] = nullptr;
const ItemInst* subitem = ((const ItemInst*)inst)->GetItem(x); const ItemInst* subitem = ((const ItemInst*)inst)->GetItem(x);

View File

@ -18,14 +18,14 @@
namespace SoF { namespace SoF {
static const char *name = "SoF"; static const char *name = "SoF";
static OpcodeManager *opcodes = NULL; static OpcodeManager *opcodes = nullptr;
static Strategy struct_strategy; static Strategy struct_strategy;
char* SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth); char* SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth);
void Register(EQStreamIdentifier &into) { void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == NULL) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -69,7 +69,7 @@ void Reload() {
//opcode managers because we need to change the manager pointer, which means //opcode managers because we need to change the manager pointer, which means
//we need to go to every stream and replace it's manager. //we need to go to every stream and replace it's manager.
if(opcodes != NULL) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -185,7 +185,7 @@ ENCODE(OP_OpenNewTasksWindow) {
structs::AvailableTaskTrailer_Struct* __eq_AvailableTaskTrailer; structs::AvailableTaskTrailer_Struct* __eq_AvailableTaskTrailer;
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -748,7 +748,7 @@ ENCODE(OP_NewZone) {
ENCODE(OP_Track) ENCODE(OP_Track)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
Track_Struct *emu = (Track_Struct *) __emu_buffer; Track_Struct *emu = (Track_Struct *) __emu_buffer;
@ -783,7 +783,7 @@ ENCODE(OP_ZoneEntry){ ENCODE_FORWARD(OP_ZoneSpawns); }
ENCODE(OP_ZoneSpawns) { ENCODE(OP_ZoneSpawns) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -903,7 +903,7 @@ ENCODE(OP_ZoneSpawns) {
uint32 ofs; uint32 ofs;
uint32 val; uint32 val;
uint8 rnd = rand() & 0x0F; uint8 rnd = rand() & 0x0F;
if (sep == NULL) if (sep == nullptr)
{ {
ofs = 0; ofs = 0;
if ((emu->lastName[2] < '0') || (emu->lastName[2] > '9')) if ((emu->lastName[2] < '0') || (emu->lastName[2] > '9'))
@ -917,7 +917,7 @@ ENCODE(OP_ZoneSpawns) {
} }
else else
{ {
sep[0] = NULL; sep[0] = nullptr;
ofs = atoi(&emu->lastName[2]); ofs = atoi(&emu->lastName[2]);
sep[0] = '='; sep[0] = '=';
if ((sep[1] < '0') || (sep[1] > '9')) if ((sep[1] < '0') || (sep[1] > '9'))
@ -1012,7 +1012,7 @@ ENCODE(OP_ItemLinkResponse) { ENCODE_FORWARD(OP_ItemPacket); }
ENCODE(OP_ItemPacket) { ENCODE(OP_ItemPacket) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer; ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer;
@ -1041,7 +1041,7 @@ ENCODE(OP_CharInventory) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
if(in->size == 0) { if(in->size == 0) {
@ -1119,7 +1119,7 @@ ENCODE(OP_CharInventory) {
ENCODE(OP_GuildMemberList) { ENCODE(OP_GuildMemberList) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1460,14 +1460,14 @@ ENCODE(OP_BazaarSearch) {
if(((*p)->size == sizeof(BazaarReturnDone_Struct)) || ((*p)->size == sizeof(BazaarWelcome_Struct))) { if(((*p)->size == sizeof(BazaarReturnDone_Struct)) || ((*p)->size == sizeof(BazaarWelcome_Struct))) {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
dest->FastQueuePacket(&in, ack_req); dest->FastQueuePacket(&in, ack_req);
return; return;
} }
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1513,7 +1513,7 @@ ENCODE(OP_Trader) {
if((*p)->size != sizeof(TraderBuy_Struct)) { if((*p)->size != sizeof(TraderBuy_Struct)) {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
dest->FastQueuePacket(&in, ack_req); dest->FastQueuePacket(&in, ack_req);
return; return;
} }
@ -1671,7 +1671,7 @@ ENCODE(OP_AdventureMerchantSell) {
ENCODE(OP_RaidUpdate) ENCODE(OP_RaidUpdate)
{ {
EQApplicationPacket *inapp = *p; EQApplicationPacket *inapp = *p;
*p = NULL; *p = nullptr;
unsigned char * __emu_buffer = inapp->pBuffer; unsigned char * __emu_buffer = inapp->pBuffer;
RaidGeneral_Struct *raid_gen = (RaidGeneral_Struct*)__emu_buffer; RaidGeneral_Struct *raid_gen = (RaidGeneral_Struct*)__emu_buffer;
@ -1735,7 +1735,7 @@ ENCODE(OP_VetRewardsAvaliable)
unsigned char * __emu_buffer = inapp->pBuffer; unsigned char * __emu_buffer = inapp->pBuffer;
uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward));
*p = NULL; *p = nullptr;
EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count));
uchar *old_data = __emu_buffer; uchar *old_data = __emu_buffer;
@ -2772,7 +2772,7 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
for(int x = 0; x < 10; ++x) { for(int x = 0; x < 10; ++x) {
SubSerializations[x] = NULL; SubSerializations[x] = nullptr;
const ItemInst* subitem = ((const ItemInst*)inst)->GetItem(x); const ItemInst* subitem = ((const ItemInst*)inst)->GetItem(x);

View File

@ -16,14 +16,14 @@
namespace Titanium { namespace Titanium {
static const char *name = "Titanium"; static const char *name = "Titanium";
static OpcodeManager *opcodes = NULL; static OpcodeManager *opcodes = nullptr;
static Strategy struct_strategy; static Strategy struct_strategy;
char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth); char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth);
void Register(EQStreamIdentifier &into) { void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == NULL) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -67,7 +67,7 @@ void Reload() {
//opcode managers because we need to change the manager pointer, which means //opcode managers because we need to change the manager pointer, which means
//we need to go to every stream and replace it's manager. //we need to go to every stream and replace it's manager.
if(opcodes != NULL) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -422,7 +422,7 @@ ENCODE(OP_Track)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
Track_Struct *emu = (Track_Struct *) __emu_buffer; Track_Struct *emu = (Track_Struct *) __emu_buffer;
@ -457,7 +457,7 @@ ENCODE(OP_ZoneEntry){ ENCODE_FORWARD(OP_ZoneSpawns); }
ENCODE(OP_ZoneSpawns) { ENCODE(OP_ZoneSpawns) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -594,7 +594,7 @@ ENCODE(OP_ItemLinkResponse) { ENCODE_FORWARD(OP_ItemPacket); }
ENCODE(OP_ItemPacket) { ENCODE(OP_ItemPacket) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -624,7 +624,7 @@ ENCODE(OP_ItemPacket) {
ENCODE(OP_CharInventory) { ENCODE(OP_CharInventory) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -666,14 +666,14 @@ ENCODE(OP_BazaarSearch) {
if(((*p)->size == sizeof(BazaarReturnDone_Struct)) || ((*p)->size == sizeof(BazaarWelcome_Struct))) { if(((*p)->size == sizeof(BazaarReturnDone_Struct)) || ((*p)->size == sizeof(BazaarWelcome_Struct))) {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
dest->FastQueuePacket(&in, ack_req); dest->FastQueuePacket(&in, ack_req);
return; return;
} }
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -719,7 +719,7 @@ ENCODE(OP_Trader) {
if((*p)->size != sizeof(TraderBuy_Struct)) { if((*p)->size != sizeof(TraderBuy_Struct)) {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
dest->FastQueuePacket(&in, ack_req); dest->FastQueuePacket(&in, ack_req);
return; return;
} }
@ -745,7 +745,7 @@ ENCODE(OP_TraderBuy) {
ENCODE(OP_GuildMemberList) { ENCODE(OP_GuildMemberList) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -839,7 +839,7 @@ ENCODE(OP_GuildMemberList) {
ENCODE(OP_ReadBook) { ENCODE(OP_ReadBook) {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -898,7 +898,7 @@ ENCODE(OP_VetRewardsAvaliable)
unsigned char * __emu_buffer = inapp->pBuffer; unsigned char * __emu_buffer = inapp->pBuffer;
uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward));
*p = NULL; *p = nullptr;
EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count));
uchar *old_data = __emu_buffer; uchar *old_data = __emu_buffer;
@ -1212,7 +1212,7 @@ DECODE(OP_InspectAnswer) {
ENCODE(OP_LFGuild) ENCODE(OP_LFGuild)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
uint32 Command = in->ReadUInt32(); uint32 Command = in->ReadUInt32();
@ -1367,10 +1367,10 @@ DECODE(OP_LFGuild)
} }
char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth) { char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth) {
char *serialization = NULL; char *serialization = nullptr;
char *instance = NULL; char *instance = nullptr;
const char *protection=(const char *)"\\\\\\\\\\"; const char *protection=(const char *)"\\\\\\\\\\";
char *sub_items[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; char *sub_items[10] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
bool stackable=inst->IsStackable(); bool stackable=inst->IsStackable();
uint32 merchant_slot=inst->GetMerchantSlot(); uint32 merchant_slot=inst->GetMerchantSlot();
int16 charges=inst->GetCharges(); int16 charges=inst->GetCharges();

View File

@ -19,14 +19,14 @@ namespace Underfoot
{ {
static const char *name = "Underfoot"; static const char *name = "Underfoot";
static OpcodeManager *opcodes = NULL; static OpcodeManager *opcodes = nullptr;
static Strategy struct_strategy; static Strategy struct_strategy;
char* SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth); char* SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 depth);
void Register(EQStreamIdentifier &into) { void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == NULL) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -70,7 +70,7 @@ void Reload() {
//opcode managers because we need to change the manager pointer, which means //opcode managers because we need to change the manager pointer, which means
//we need to go to every stream and replace it's manager. //we need to go to every stream and replace it's manager.
if(opcodes != NULL) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; string opfile = "patch_";
opfile += name; opfile += name;
@ -186,7 +186,7 @@ ENCODE(OP_OpenNewTasksWindow) {
structs::AvailableTaskTrailer_Struct* __eq_AvailableTaskTrailer; structs::AvailableTaskTrailer_Struct* __eq_AvailableTaskTrailer;
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -775,7 +775,7 @@ ENCODE(OP_NewZone) {
ENCODE(OP_Track) ENCODE(OP_Track)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
Track_Struct *emu = (Track_Struct *) __emu_buffer; Track_Struct *emu = (Track_Struct *) __emu_buffer;
@ -821,7 +821,7 @@ ENCODE(OP_Track)
ENCODE(OP_PetBuffWindow) ENCODE(OP_PetBuffWindow)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -860,7 +860,7 @@ ENCODE(OP_PetBuffWindow)
ENCODE(OP_Barter) ENCODE(OP_Barter)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *Buffer = (char *)in->pBuffer; char *Buffer = (char *)in->pBuffer;
@ -901,7 +901,7 @@ ENCODE(OP_Barter)
ENCODE(OP_BazaarSearch) ENCODE(OP_BazaarSearch)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *Buffer = (char *)in->pBuffer; char *Buffer = (char *)in->pBuffer;
@ -957,7 +957,7 @@ ENCODE(OP_ZoneEntry){ ENCODE_FORWARD(OP_ZoneSpawns); }
ENCODE(OP_ZoneSpawns) { ENCODE(OP_ZoneSpawns) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1272,7 +1272,7 @@ ENCODE(OP_ZoneSpawns) {
ENCODE(OP_MercenaryDataResponse) { ENCODE(OP_MercenaryDataResponse) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1335,7 +1335,7 @@ ENCODE(OP_MercenaryDataResponse) {
ENCODE(OP_MercenaryDataUpdate) { ENCODE(OP_MercenaryDataUpdate) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1411,7 +1411,7 @@ ENCODE(OP_ItemLinkResponse) { ENCODE_FORWARD(OP_ItemPacket); }
ENCODE(OP_ItemPacket) { ENCODE(OP_ItemPacket) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer; ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer;
@ -1440,7 +1440,7 @@ ENCODE(OP_CharInventory) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
if(in->size == 0) { if(in->size == 0) {
@ -1518,7 +1518,7 @@ ENCODE(OP_CharInventory) {
ENCODE(OP_GuildMemberList) { ENCODE(OP_GuildMemberList) {
//consume the packet //consume the packet
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
//store away the emu struct //store away the emu struct
unsigned char *__emu_buffer = in->pBuffer; unsigned char *__emu_buffer = in->pBuffer;
@ -1646,7 +1646,7 @@ ENCODE(OP_GroundSpawn)
// We are not encoding the spawn_id field here, or a size but it doesn't appear to matter. // We are not encoding the spawn_id field here, or a size but it doesn't appear to matter.
// //
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
Object_Struct *emu = (Object_Struct *) in->pBuffer; Object_Struct *emu = (Object_Struct *) in->pBuffer;
@ -1935,7 +1935,7 @@ ENCODE(OP_Trader) {
if((*p)->size != sizeof(TraderBuy_Struct)) { if((*p)->size != sizeof(TraderBuy_Struct)) {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
dest->FastQueuePacket(&in, ack_req); dest->FastQueuePacket(&in, ack_req);
return; return;
} }
@ -2093,7 +2093,7 @@ ENCODE(OP_AdventureMerchantSell) {
ENCODE(OP_RaidUpdate) ENCODE(OP_RaidUpdate)
{ {
EQApplicationPacket *inapp = *p; EQApplicationPacket *inapp = *p;
*p = NULL; *p = nullptr;
unsigned char * __emu_buffer = inapp->pBuffer; unsigned char * __emu_buffer = inapp->pBuffer;
RaidGeneral_Struct *raid_gen = (RaidGeneral_Struct*)__emu_buffer; RaidGeneral_Struct *raid_gen = (RaidGeneral_Struct*)__emu_buffer;
@ -2157,7 +2157,7 @@ ENCODE(OP_VetRewardsAvaliable)
unsigned char * __emu_buffer = inapp->pBuffer; unsigned char * __emu_buffer = inapp->pBuffer;
uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward)); uint32 count = ((*p)->Size() / sizeof(InternalVeteranReward));
*p = NULL; *p = nullptr;
EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count)); EQApplicationPacket *outapp_create = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(structs::VeteranReward)*count));
uchar *old_data = __emu_buffer; uchar *old_data = __emu_buffer;
@ -2188,7 +2188,7 @@ ENCODE(OP_VetRewardsAvaliable)
ENCODE(OP_WhoAllResponse) ENCODE(OP_WhoAllResponse)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
char *InBuffer = (char *)in->pBuffer; char *InBuffer = (char *)in->pBuffer;
@ -2438,7 +2438,7 @@ ENCODE(OP_GroupUpdate)
ENCODE(OP_ChannelMessage) ENCODE(OP_ChannelMessage)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
ChannelMessage_Struct *emu = (ChannelMessage_Struct *) in->pBuffer; ChannelMessage_Struct *emu = (ChannelMessage_Struct *) in->pBuffer;
@ -2474,7 +2474,7 @@ ENCODE(OP_ChannelMessage)
ENCODE(OP_GuildsList) ENCODE(OP_GuildsList)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
uint32 NumberOfGuilds = in->size / 64; uint32 NumberOfGuilds = in->size / 64;
@ -2742,7 +2742,7 @@ ENCODE(OP_WearChange)
ENCODE(OP_SpawnAppearance) ENCODE(OP_SpawnAppearance)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *emu_buffer = in->pBuffer; unsigned char *emu_buffer = in->pBuffer;
@ -2793,7 +2793,7 @@ ENCODE(OP_AltCurrencySell)
ENCODE(OP_AltCurrency) ENCODE(OP_AltCurrency)
{ {
EQApplicationPacket *in = *p; EQApplicationPacket *in = *p;
*p = NULL; *p = nullptr;
unsigned char *emu_buffer = in->pBuffer; unsigned char *emu_buffer = in->pBuffer;
uint32 opcode = *((uint32*)emu_buffer); uint32 opcode = *((uint32*)emu_buffer);
@ -3881,7 +3881,7 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
for(int x = 0; x < 10; ++x) { for(int x = 0; x < 10; ++x) {
SubSerializations[x] = NULL; SubSerializations[x] = nullptr;
const ItemInst* subitem = ((const ItemInst*)inst)->GetItem(x); const ItemInst* subitem = ((const ItemInst*)inst)->GetItem(x);

View File

@ -54,8 +54,8 @@ XS(XS_EQDB_field_count)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDB"); Perl_croak(aTHX_ "THIS is not of type EQDB");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->field_count(); RETVAL = THIS->field_count();
XSprePUSH; PUSHu((UV)RETVAL); XSprePUSH; PUSHu((UV)RETVAL);
@ -80,8 +80,8 @@ XS(XS_EQDB_affected_rows)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDB"); Perl_croak(aTHX_ "THIS is not of type EQDB");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->affected_rows(); RETVAL = THIS->affected_rows();
XSprePUSH; PUSHu((UV)RETVAL); XSprePUSH; PUSHu((UV)RETVAL);
@ -106,8 +106,8 @@ XS(XS_EQDB_insert_id)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDB"); Perl_croak(aTHX_ "THIS is not of type EQDB");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->insert_id(); RETVAL = THIS->insert_id();
XSprePUSH; PUSHu((UV)RETVAL); XSprePUSH; PUSHu((UV)RETVAL);
@ -132,8 +132,8 @@ XS(XS_EQDB_get_errno)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDB"); Perl_croak(aTHX_ "THIS is not of type EQDB");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->get_errno(); RETVAL = THIS->get_errno();
XSprePUSH; PUSHu((UV)RETVAL); XSprePUSH; PUSHu((UV)RETVAL);
@ -158,8 +158,8 @@ XS(XS_EQDB_error)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDB"); Perl_croak(aTHX_ "THIS is not of type EQDB");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->error(); RETVAL = THIS->error();
sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
@ -184,8 +184,8 @@ XS(XS_EQDB_query)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDB"); Perl_croak(aTHX_ "THIS is not of type EQDB");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->query(q); RETVAL = THIS->query(q);
ST(0) = sv_newmortal(); ST(0) = sv_newmortal();
@ -212,8 +212,8 @@ XS(XS_EQDB_escape_string)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDB"); Perl_croak(aTHX_ "THIS is not of type EQDB");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->escape_string(from); RETVAL = THIS->escape_string(from);
sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;

View File

@ -50,8 +50,8 @@ XS(XS_EQDBRes_num_rows)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDBRes"); Perl_croak(aTHX_ "THIS is not of type EQDBRes");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->num_rows(); RETVAL = THIS->num_rows();
XSprePUSH; PUSHu((UV)RETVAL); XSprePUSH; PUSHu((UV)RETVAL);
@ -76,8 +76,8 @@ XS(XS_EQDBRes_num_fields)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDBRes"); Perl_croak(aTHX_ "THIS is not of type EQDBRes");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->num_fields(); RETVAL = THIS->num_fields();
XSprePUSH; PUSHu((UV)RETVAL); XSprePUSH; PUSHu((UV)RETVAL);
@ -100,8 +100,8 @@ XS(XS_EQDBRes_DESTROY)
} }
else else
Perl_croak(aTHX_ "THIS is not a reference"); Perl_croak(aTHX_ "THIS is not a reference");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
delete THIS; delete THIS;
} }
@ -123,8 +123,8 @@ XS(XS_EQDBRes_finish)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDBRes"); Perl_croak(aTHX_ "THIS is not of type EQDBRes");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
THIS->finish(); THIS->finish();
} }
@ -147,8 +147,8 @@ XS(XS_EQDBRes_fetch_row_array)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDBRes"); Perl_croak(aTHX_ "THIS is not of type EQDBRes");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->fetch_row_array(); RETVAL = THIS->fetch_row_array();
ST(0) = sv_newmortal(); ST(0) = sv_newmortal();
@ -187,8 +187,8 @@ XS(XS_EQDBRes_fetch_row_hash)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDBRes"); Perl_croak(aTHX_ "THIS is not of type EQDBRes");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->fetch_row_hash(); RETVAL = THIS->fetch_row_hash();
ST(0) = sv_newmortal(); ST(0) = sv_newmortal();
@ -205,7 +205,7 @@ XS(XS_EQDBRes_fetch_row_hash)
for(; cur != end; cur++) { for(; cur != end; cur++) {
/* get the element from the hash, creating if needed (will be needed) */ /* get the element from the hash, creating if needed (will be needed) */
SV**ele = hv_fetch(hv, cur->first.c_str(), cur->first.length(), TRUE); SV**ele = hv_fetch(hv, cur->first.c_str(), cur->first.length(), TRUE);
if(ele == NULL) { if(ele == nullptr) {
Perl_croak(aTHX_ "Unable to create a hash element for RETVAL"); Perl_croak(aTHX_ "Unable to create a hash element for RETVAL");
break; break;
} }
@ -251,8 +251,8 @@ XS(XS_EQDBRes_fetch_lengths)
} }
else else
Perl_croak(aTHX_ "THIS is not of type EQDBRes"); Perl_croak(aTHX_ "THIS is not of type EQDBRes");
if(THIS == NULL) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->fetch_lengths(); RETVAL = THIS->fetch_lengths();
XSprePUSH; PUSHp((char *)RETVAL, sizeof(*RETVAL)); XSprePUSH; PUSHp((char *)RETVAL, sizeof(*RETVAL));

View File

@ -74,11 +74,11 @@ To use ptimers, you need to create the table below in your DB:
Schema: Schema:
CREATE TABLE timers ( CREATE TABLE timers (
char_id INT(11) NOT NULL, char_id INT(11) NOT nullptr,
type MEDIUMINT UNSIGNED NOT NULL, type MEDIUMINT UNSIGNED NOT nullptr,
start INT UNSIGNED NOT NULL, start INT UNSIGNED NOT nullptr,
duration INT UNSIGNED NOT NULL, duration INT UNSIGNED NOT nullptr,
enable TINYINT NOT NULL, enable TINYINT NOT nullptr,
PRIMARY KEY(char_id, type) PRIMARY KEY(char_id, type)
); );
@ -95,7 +95,7 @@ PersistentTimer *PersistentTimer::LoadTimer(Database *db, uint32 char_id, pTimer
if(p->Load(db)) if(p->Load(db))
return(p); return(p);
delete p; delete p;
return(NULL); return(nullptr);
} }
PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_timer_time) { PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_timer_time) {
@ -153,8 +153,8 @@ bool PersistentTimer::Load(Database *db) {
bool res = false; bool res = false;
qcount = mysql_num_rows(result); qcount = mysql_num_rows(result);
if(qcount == 1 && (row = mysql_fetch_row(result)) ) { if(qcount == 1 && (row = mysql_fetch_row(result)) ) {
start_time = strtoul(row[0], NULL, 10); start_time = strtoul(row[0], nullptr, 10);
timer_time = strtoul(row[1], NULL, 10); timer_time = strtoul(row[1], nullptr, 10);
enabled = (row[2][0] == '1'); enabled = (row[2][0] == '1');
res = true; res = true;
@ -222,7 +222,7 @@ bool PersistentTimer::Clear(Database *db) {
/* This function checks if the timer triggered */ /* This function checks if the timer triggered */
bool PersistentTimer::Expired(Database *db, bool iReset) { bool PersistentTimer::Expired(Database *db, bool iReset) {
if (this == NULL) { if (this == nullptr) {
LogFile->write(EQEMuLog::Error, "Null timer during ->Check()!?\n"); LogFile->write(EQEMuLog::Error, "Null timer during ->Check()!?\n");
return(true); return(true);
} }
@ -280,7 +280,7 @@ uint32 PersistentTimer::GetRemainingTime() {
uint32 PersistentTimer::get_current_time() { uint32 PersistentTimer::get_current_time() {
timeval tv; timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, nullptr);
return(tv.tv_sec); return(tv.tv_sec);
} }
@ -292,7 +292,7 @@ PTimerList::~PTimerList() {
map<pTimerType, PersistentTimer *>::iterator s; map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin(); s = _list.begin();
while(s != _list.end()) { while(s != _list.end()) {
if(s->second != NULL) if(s->second != nullptr)
delete s->second; delete s->second;
s++; s++;
} }
@ -303,7 +303,7 @@ bool PTimerList::Load(Database *db) {
map<pTimerType, PersistentTimer *>::iterator s; map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin(); s = _list.begin();
while(s != _list.end()) { while(s != _list.end()) {
if(s->second != NULL) if(s->second != nullptr)
delete s->second; delete s->second;
s++; s++;
} }
@ -340,14 +340,14 @@ bool PTimerList::Load(Database *db) {
qcount = mysql_num_rows(result); qcount = mysql_num_rows(result);
while((row = mysql_fetch_row(result)) ) { while((row = mysql_fetch_row(result)) ) {
type = atoi(row[0]); type = atoi(row[0]);
start_time = strtoul(row[1], NULL, 10); start_time = strtoul(row[1], nullptr, 10);
timer_time = strtoul(row[2], NULL, 10); timer_time = strtoul(row[2], nullptr, 10);
enabled = (row[3][0] == '1'); enabled = (row[3][0] == '1');
//if it expired allready, dont bother. //if it expired allready, dont bother.
cur = new PersistentTimer(_char_id, type, start_time, timer_time, enabled); cur = new PersistentTimer(_char_id, type, start_time, timer_time, enabled);
if(!cur->Expired(NULL)) if(!cur->Expired(nullptr))
_list[type] = cur; _list[type] = cur;
else else
delete cur; delete cur;
@ -366,7 +366,7 @@ bool PTimerList::Store(Database *db) {
s = _list.begin(); s = _list.begin();
bool res = true; bool res = true;
while(s != _list.end()) { while(s != _list.end()) {
if(s->second != NULL) { if(s->second != nullptr) {
#ifdef DEBUG_PTIMERS #ifdef DEBUG_PTIMERS
printf("Storing timer %u for char %lu\n", s->first, (unsigned long)_char_id); printf("Storing timer %u for char %lu\n", s->first, (unsigned long)_char_id);
#endif #endif
@ -405,7 +405,7 @@ bool PTimerList::Clear(Database *db) {
} }
void PTimerList::Start(pTimerType type, uint32 duration) { void PTimerList::Start(pTimerType type, uint32 duration) {
if(_list.count(type) == 1 && _list[type] != NULL) { if(_list.count(type) == 1 && _list[type] != nullptr) {
_list[type]->Start(duration); _list[type]->Start(duration);
} else { } else {
_list[type] = new PersistentTimer(_char_id, type, duration); _list[type] = new PersistentTimer(_char_id, type, duration);
@ -414,7 +414,7 @@ void PTimerList::Start(pTimerType type, uint32 duration) {
void PTimerList::Clear(Database *db, pTimerType type) { void PTimerList::Clear(Database *db, pTimerType type) {
if(_list.count(type) == 1) { if(_list.count(type) == 1) {
if(_list[type] != NULL) { if(_list[type] != nullptr) {
_list[type]->Clear(db); _list[type]->Clear(db);
delete _list[type]; delete _list[type];
} }
@ -425,7 +425,7 @@ void PTimerList::Clear(Database *db, pTimerType type) {
bool PTimerList::Expired(Database *db, pTimerType type, bool reset) { bool PTimerList::Expired(Database *db, pTimerType type, bool reset) {
if(_list.count(type) != 1) if(_list.count(type) != 1)
return(true); return(true);
if(_list[type] == NULL) if(_list[type] == nullptr)
return(true); return(true);
return(_list[type]->Expired(db, reset)); return(_list[type]->Expired(db, reset));
} }
@ -433,32 +433,32 @@ bool PTimerList::Expired(Database *db, pTimerType type, bool reset) {
bool PTimerList::Enabled(pTimerType type) { bool PTimerList::Enabled(pTimerType type) {
if(_list.count(type) != 1) if(_list.count(type) != 1)
return(false); return(false);
if(_list[type] == NULL) if(_list[type] == nullptr)
return(false); return(false);
return(_list[type]->Enabled()); return(_list[type]->Enabled());
} }
void PTimerList::Enable(pTimerType type) { void PTimerList::Enable(pTimerType type) {
if(_list.count(type) == 1 && _list[type] != NULL) if(_list.count(type) == 1 && _list[type] != nullptr)
_list[type]->Enable(); _list[type]->Enable();
} }
void PTimerList::Disable(pTimerType type) { void PTimerList::Disable(pTimerType type) {
if(_list.count(type) == 1 && _list[type] != NULL) if(_list.count(type) == 1 && _list[type] != nullptr)
_list[type]->Disable(); _list[type]->Disable();
} }
uint32 PTimerList::GetRemainingTime(pTimerType type) { uint32 PTimerList::GetRemainingTime(pTimerType type) {
if(_list.count(type) != 1) if(_list.count(type) != 1)
return(0); return(0);
if(_list[type] == NULL) if(_list[type] == nullptr)
return(0); return(0);
return(_list[type]->GetRemainingTime()); return(_list[type]->GetRemainingTime());
} }
PersistentTimer *PTimerList::Get(pTimerType type) { PersistentTimer *PTimerList::Get(pTimerType type) {
if(_list.count(type) != 1) if(_list.count(type) != 1)
return(NULL); return(nullptr);
return(_list[type]); return(_list[type]);
} }
@ -469,7 +469,7 @@ void PTimerList::ToVector(vector< pair<pTimerType, PersistentTimer *> > &out) {
map<pTimerType, PersistentTimer *>::iterator s; map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin(); s = _list.begin();
while(s != _list.end()) { while(s != _list.end()) {
if(s->second != NULL) { if(s->second != nullptr) {
p.first = s->first; p.first = s->first;
p.second = s->second; p.second = s->second;
out.push_back(p); out.push_back(p);

View File

@ -81,7 +81,7 @@ int64 RDTSC_Timer::rdtsc() {
#else #else
//fall back to get time of day //fall back to get time of day
timeval t; timeval t;
gettimeofday(&t, NULL); gettimeofday(&t, nullptr);
res = ((int64)t.tv_sec) * 1000 + t.tv_usec; res = ((int64)t.tv_sec) * 1000 + t.tv_usec;
#endif #endif
#endif #endif

View File

@ -35,17 +35,17 @@ Requred SQL:
CREATE TABLE rule_sets ( CREATE TABLE rule_sets (
ruleset_id TINYINT UNSIGNED NOT NULL auto_increment, ruleset_id TINYINT UNSIGNED NOT nullptr auto_increment,
name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT nullptr,
PRIMARY KEY(ruleset_id) PRIMARY KEY(ruleset_id)
); );
INSERT INTO rule_sets VALUES(0, "default"); INSERT INTO rule_sets VALUES(0, "default");
UPDATE rule_sets SET ruleset_id=0; UPDATE rule_sets SET ruleset_id=0;
CREATE TABLE rule_values ( CREATE TABLE rule_values (
ruleset_id TINYINT UNSIGNED NOT NULL, ruleset_id TINYINT UNSIGNED NOT nullptr,
rule_name VARCHAR(64) NOT NULL, rule_name VARCHAR(64) NOT nullptr,
rule_value VARCHAR(10) NOT NULL, rule_value VARCHAR(10) NOT nullptr,
INDEX(ruleset_id), INDEX(ruleset_id),
PRIMARY KEY(ruleset_id,rule_name) PRIMARY KEY(ruleset_id,rule_name)
); );
@ -107,7 +107,7 @@ RuleManager::CategoryType RuleManager::FindCategory(const char *catname) {
bool RuleManager::ListRules(const char *catname, std::vector<const char *> &into) { bool RuleManager::ListRules(const char *catname, std::vector<const char *> &into) {
CategoryType cat = InvalidCategory; CategoryType cat = InvalidCategory;
if(catname != NULL) { if(catname != nullptr) {
cat = FindCategory(catname); cat = FindCategory(catname);
if(cat == InvalidCategory) { if(cat == InvalidCategory) {
_log(RULES__ERROR, "Unable to find category '%s'", catname); _log(RULES__ERROR, "Unable to find category '%s'", catname);
@ -118,7 +118,7 @@ bool RuleManager::ListRules(const char *catname, std::vector<const char *> &into
int rcount = CountRules(); int rcount = CountRules();
for(r = 0; r < rcount; r++) { for(r = 0; r < rcount; r++) {
const RuleInfo &rule = s_RuleInfo[r]; const RuleInfo &rule = s_RuleInfo[r];
if(catname == NULL || cat == rule.category) { if(catname == nullptr || cat == rule.category) {
into.push_back(rule.name); into.push_back(rule.name);
} }
} }
@ -160,7 +160,7 @@ bool RuleManager::GetRule(const char *rule_name, std::string &ret_val) {
} }
bool RuleManager::SetRule(const char *rule_name, const char *rule_value, Database *db, bool db_save) { bool RuleManager::SetRule(const char *rule_name, const char *rule_value, Database *db, bool db_save) {
if(rule_name == NULL || rule_value == NULL) if(rule_name == nullptr || rule_value == nullptr)
return(false); return(false);
RuleType type; RuleType type;
@ -204,7 +204,7 @@ void RuleManager::ResetRules() {
} }
bool RuleManager::_FindRule(const char *rule_name, RuleType &type_into, uint16 &index_into) { bool RuleManager::_FindRule(const char *rule_name, RuleType &type_into, uint16 &index_into) {
if(rule_name == NULL) if(rule_name == nullptr)
return(false); return(false);
int r; int r;
@ -237,7 +237,7 @@ const char *RuleManager::_GetRuleName(RuleType type, uint16 index) {
void RuleManager::SaveRules(Database *db, const char *ruleset) { void RuleManager::SaveRules(Database *db, const char *ruleset) {
if(ruleset != NULL) { if(ruleset != nullptr) {
//saving to a specific name //saving to a specific name
if(m_activeName != ruleset) { if(m_activeName != ruleset) {
//a new name... //a new name...
@ -292,7 +292,7 @@ bool RuleManager::LoadRules(Database *db, const char *ruleset) {
{ {
safe_delete_array(query); safe_delete_array(query);
while((row = mysql_fetch_row(result))) { while((row = mysql_fetch_row(result))) {
if(!SetRule(row[0], row[1], NULL, false)) if(!SetRule(row[0], row[1], nullptr, false))
_log(RULES__ERROR, "Unable to interpret rule record for %s", row[0]); _log(RULES__ERROR, "Unable to interpret rule record for %s", row[0]);
} }
mysql_free_result(result); mysql_free_result(result);
@ -380,7 +380,7 @@ int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) {
if (!db->RunQuery(query, MakeAnyLenString(&query, if (!db->RunQuery(query, MakeAnyLenString(&query,
"INSERT INTO rule_sets (ruleset_id, name) " "INSERT INTO rule_sets (ruleset_id, name) "
" VALUES(0, '%s')", " VALUES(0, '%s')",
rst),errbuf,NULL,NULL,&new_id)) rst),errbuf,nullptr,nullptr,&new_id))
{ {
_log(RULES__ERROR, "Fauled to create rule set in the database: %s: %s", query,errbuf); _log(RULES__ERROR, "Fauled to create rule set in the database: %s: %s", query,errbuf);
res = -1; res = -1;

View File

@ -102,7 +102,7 @@ public:
bool ListRules(const char *catname, std::vector<const char *> &into); bool ListRules(const char *catname, std::vector<const char *> &into);
bool ListCategories(std::vector<const char *> &into); bool ListCategories(std::vector<const char *> &into);
bool GetRule(const char *rule_name, std::string &ret_val); bool GetRule(const char *rule_name, std::string &ret_val);
bool SetRule(const char *rule_name, const char *rule_value, Database *db = NULL, bool db_save = false); bool SetRule(const char *rule_name, const char *rule_value, Database *db = nullptr, bool db_save = false);
int GetActiveRulesetID() const { return(m_activeRuleset); } int GetActiveRulesetID() const { return(m_activeRuleset); }
const char *GetActiveRuleset() const { return(m_activeName.c_str()); } const char *GetActiveRuleset() const { return(m_activeName.c_str()); }
@ -111,8 +111,8 @@ public:
static bool ListRulesets(Database *db, std::map<int, std::string> &into); static bool ListRulesets(Database *db, std::map<int, std::string> &into);
void ResetRules(); void ResetRules();
bool LoadRules(Database *db, const char *ruleset = NULL); bool LoadRules(Database *db, const char *ruleset = nullptr);
void SaveRules(Database *db, const char *ruleset = NULL); void SaveRules(Database *db, const char *ruleset = nullptr);
private: private:
RuleManager(); RuleManager();

View File

@ -21,15 +21,15 @@
using namespace std; using namespace std;
SharedDatabase::SharedDatabase() SharedDatabase::SharedDatabase()
: Database(), skill_caps_mmf(NULL), items_mmf(NULL), items_hash(NULL), faction_mmf(NULL), faction_hash(NULL), : Database(), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr), faction_mmf(nullptr), faction_hash(nullptr),
loot_table_mmf(NULL), loot_drop_mmf(NULL), loot_table_hash(NULL), loot_drop_hash(NULL) loot_table_mmf(nullptr), loot_drop_mmf(nullptr), loot_table_hash(nullptr), loot_drop_hash(nullptr)
{ {
} }
SharedDatabase::SharedDatabase(const char* host, const char* user, const char* passwd, const char* database, uint32 port) SharedDatabase::SharedDatabase(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
: Database(host, user, passwd, database, port), skill_caps_mmf(NULL), items_mmf(NULL), items_hash(NULL), : Database(host, user, passwd, database, port), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr),
faction_mmf(NULL), faction_hash(NULL), loot_table_mmf(NULL), loot_drop_mmf(NULL), loot_table_hash(NULL), faction_mmf(nullptr), faction_hash(nullptr), loot_table_mmf(nullptr), loot_drop_mmf(nullptr), loot_table_hash(nullptr),
loot_drop_hash(NULL) loot_drop_hash(nullptr)
{ {
} }
@ -487,7 +487,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
((is_charid==true) ? "charid" : "acctid"), id, item_id, slot_id); ((is_charid==true) ? "charid" : "acctid"), id, item_id, slot_id);
if(is_charid) if(is_charid)
SaveInventory(id,NULL,slot_id); SaveInventory(id,nullptr,slot_id);
} }
} }
else { else {
@ -727,7 +727,7 @@ void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) {
char query[] = "SELECT MAX(id), count(*) FROM items"; char query[] = "SELECT MAX(id), count(*) FROM items";
if (RunQuery(query, static_cast<uint32>(strlen(query)), errbuf, &result)) { if (RunQuery(query, static_cast<uint32>(strlen(query)), errbuf, &result)) {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
if (row != NULL && row[1] != 0) { if (row != nullptr && row[1] != 0) {
item_count = atoi(row[1]); item_count = atoi(row[1]);
if(row[0]) if(row[0])
max_id = atoi(row[0]); max_id = atoi(row[0]);
@ -1020,19 +1020,19 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
const Item_Struct* SharedDatabase::GetItem(uint32 id) { const Item_Struct* SharedDatabase::GetItem(uint32 id) {
if(!items_hash || id > items_hash->max_key()) { if(!items_hash || id > items_hash->max_key()) {
return NULL; return nullptr;
} }
if(items_hash->exists(id)) { if(items_hash->exists(id)) {
return &(items_hash->at(id)); return &(items_hash->at(id));
} }
return NULL; return nullptr;
} }
const Item_Struct* SharedDatabase::IterateItems(uint32* id) { const Item_Struct* SharedDatabase::IterateItems(uint32* id) {
if(!items_hash || !id) { if(!items_hash || !id) {
return NULL; return nullptr;
} }
for(;;) { for(;;) {
@ -1047,7 +1047,7 @@ const Item_Struct* SharedDatabase::IterateItems(uint32* id) {
} }
} }
return NULL; return nullptr;
} }
string SharedDatabase::GetBook(const char *txtfile) string SharedDatabase::GetBook(const char *txtfile)
@ -1104,14 +1104,14 @@ void SharedDatabase::GetFactionListInfo(uint32 &list_count, uint32 &max_lists) {
const NPCFactionList* SharedDatabase::GetNPCFactionEntry(uint32 id) { const NPCFactionList* SharedDatabase::GetNPCFactionEntry(uint32 id) {
if(!faction_hash) { if(!faction_hash) {
return NULL; return nullptr;
} }
if(faction_hash->exists(id)) { if(faction_hash->exists(id)) {
return &(faction_hash->at(id)); return &(faction_hash->at(id));
} }
return NULL; return nullptr;
} }
void SharedDatabase::LoadNPCFactionLists(void *data, uint32 size, uint32 list_count, uint32 max_lists) { void SharedDatabase::LoadNPCFactionLists(void *data, uint32 size, uint32 list_count, uint32 max_lists) {
@ -1305,8 +1305,8 @@ uint32 SharedDatabase::SetPlayerProfile_MQ(char** query, uint32 account_id, uint
// Create appropriate ItemInst class // Create appropriate ItemInst class
ItemInst* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5) ItemInst* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5)
{ {
const Item_Struct* item = NULL; const Item_Struct* item = nullptr;
ItemInst* inst = NULL; ItemInst* inst = nullptr;
item = GetItem(item_id); item = GetItem(item_id);
if (item) { if (item) {
inst = CreateBaseItem(item, charges); inst = CreateBaseItem(item, charges);
@ -1324,7 +1324,7 @@ ItemInst* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1,
// Create appropriate ItemInst class // Create appropriate ItemInst class
ItemInst* SharedDatabase::CreateItem(const Item_Struct* item, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5) ItemInst* SharedDatabase::CreateItem(const Item_Struct* item, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5)
{ {
ItemInst* inst = NULL; ItemInst* inst = nullptr;
if (item) { if (item) {
inst = CreateBaseItem(item, charges); inst = CreateBaseItem(item, charges);
inst->PutAugment(this, 0, aug1); inst->PutAugment(this, 0, aug1);
@ -1338,7 +1338,7 @@ ItemInst* SharedDatabase::CreateItem(const Item_Struct* item, int16 charges, uin
} }
ItemInst* SharedDatabase::CreateBaseItem(const Item_Struct* item, int16 charges) { ItemInst* SharedDatabase::CreateBaseItem(const Item_Struct* item, int16 charges) {
ItemInst* inst = NULL; ItemInst* inst = nullptr;
if (item) { if (item) {
// if maxcharges is -1 that means it is an unlimited use item. // if maxcharges is -1 that means it is an unlimited use item.
// set it to 1 charge so that it is usable on creation // set it to 1 charge so that it is usable on creation
@ -1592,12 +1592,12 @@ void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpe
} }
const EvolveInfo* SharedDatabase::GetEvolveInfo(uint32 loregroup) { const EvolveInfo* SharedDatabase::GetEvolveInfo(uint32 loregroup) {
return NULL; // nothing here for now... database and/or sharemem pulls later return nullptr; // nothing here for now... database and/or sharemem pulls later
} }
int SharedDatabase::GetMaxSpellID() { int SharedDatabase::GetMaxSpellID() {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = NULL; char *query = nullptr;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
int32 ret = 0; int32 ret = 0;
@ -1930,7 +1930,7 @@ bool SharedDatabase::LoadLoot() {
const LootTable_Struct* SharedDatabase::GetLootTable(uint32 loottable_id) { const LootTable_Struct* SharedDatabase::GetLootTable(uint32 loottable_id) {
if(!loot_table_hash) if(!loot_table_hash)
return NULL; return nullptr;
try { try {
if(loot_table_hash->exists(loottable_id)) { if(loot_table_hash->exists(loottable_id)) {
@ -1939,12 +1939,12 @@ const LootTable_Struct* SharedDatabase::GetLootTable(uint32 loottable_id) {
} catch(std::exception &ex) { } catch(std::exception &ex) {
LogFile->write(EQEMuLog::Error, "Could not get loot table: %s", ex.what()); LogFile->write(EQEMuLog::Error, "Could not get loot table: %s", ex.what());
} }
return NULL; return nullptr;
} }
const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) { const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) {
if(!loot_drop_hash) if(!loot_drop_hash)
return NULL; return nullptr;
try { try {
if(loot_drop_hash->exists(lootdrop_id)) { if(loot_drop_hash->exists(lootdrop_id)) {
@ -1953,7 +1953,7 @@ const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) {
} catch(std::exception &ex) { } catch(std::exception &ex) {
LogFile->write(EQEMuLog::Error, "Could not get loot drop: %s", ex.what()); LogFile->write(EQEMuLog::Error, "Could not get loot drop: %s", ex.what());
} }
return NULL; return nullptr;
} }
void SharedDatabase::GetPlayerInspectMessage(char* playername, InspectMessage_Struct* message) { void SharedDatabase::GetPlayerInspectMessage(char* playername, InspectMessage_Struct* message) {

View File

@ -52,7 +52,7 @@ void TimeoutManager::CheckTimeouts() {
//methods called by Timeoutable objects: //methods called by Timeoutable objects:
void TimeoutManager::AddMember(Timeoutable *who) { void TimeoutManager::AddMember(Timeoutable *who) {
if(who == NULL) if(who == nullptr)
return; return;
DeleteMember(who); //just in case... prolly not needed. DeleteMember(who); //just in case... prolly not needed.

View File

@ -42,7 +42,7 @@ TiXmlString::TiXmlString (const char* instring)
if (!instring) if (!instring)
{ {
allocated = 0; allocated = 0;
cstring = NULL; cstring = nullptr;
current_length = 0; current_length = 0;
return; return;
} }
@ -68,7 +68,7 @@ TiXmlString::TiXmlString (const TiXmlString& copy)
if (! copy . allocated) if (! copy . allocated)
{ {
allocated = 0; allocated = 0;
cstring = NULL; cstring = nullptr;
current_length = 0; current_length = 0;
return; return;
} }

View File

@ -55,7 +55,7 @@ class TiXmlString
TiXmlString () TiXmlString ()
{ {
allocated = 0; allocated = 0;
cstring = NULL; cstring = nullptr;
current_length = 0; current_length = 0;
} }
@ -184,7 +184,7 @@ class TiXmlString
{ {
if (cstring) if (cstring)
delete [] cstring; delete [] cstring;
cstring = NULL; cstring = nullptr;
allocated = 0; allocated = 0;
current_length = 0; current_length = 0;
} }

View File

@ -495,7 +495,7 @@ public:
#endif #endif
/** Add a new node related to this. Adds a child past the LastChild. /** Add a new node related to this. Adds a child past the LastChild.
Returns a pointer to the new object or NULL if an error occured. Returns a pointer to the new object or nullptr if an error occured.
*/ */
TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
@ -512,17 +512,17 @@ public:
TiXmlNode* LinkEndChild( TiXmlNode* addThis ); TiXmlNode* LinkEndChild( TiXmlNode* addThis );
/** Add a new node related to this. Adds a child before the specified child. /** Add a new node related to this. Adds a child before the specified child.
Returns a pointer to the new object or NULL if an error occured. Returns a pointer to the new object or nullptr if an error occured.
*/ */
TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
/** Add a new node related to this. Adds a child after the specified child. /** Add a new node related to this. Adds a child after the specified child.
Returns a pointer to the new object or NULL if an error occured. Returns a pointer to the new object or nullptr if an error occured.
*/ */
TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
/** Replace a child of this node. /** Replace a child of this node.
Returns a pointer to the new object or NULL if an error occured. Returns a pointer to the new object or nullptr if an error occured.
*/ */
TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );

View File

@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
*/ */
//the storage passed to putenv must remain valid... crazy unix people //the storage passed to putenv must remain valid... crazy unix people
const char *pv = getenv("LD_LIBRARY_PATH"); const char *pv = getenv("LD_LIBRARY_PATH");
if(pv == NULL) { if(pv == nullptr) {
putenv(strdup("LD_LIBRARY_PATH=.")); putenv(strdup("LD_LIBRARY_PATH=."));
} else { } else {
char *v = (char *) malloc(strlen(pv) + 19); char *v = (char *) malloc(strlen(pv) + 19);

View File

@ -191,7 +191,7 @@ void Client::Handle_Login(const char* data, unsigned int size)
string e_user; string e_user;
string e_hash; string e_hash;
char *e_buffer = NULL; char *e_buffer = nullptr;
unsigned int d_account_id = 0; unsigned int d_account_id = 0;
string d_pass_hash; string d_pass_hash;

View File

@ -185,7 +185,7 @@ void ClientManager::RemoveExistingClient(unsigned int account_id)
Client *ClientManager::GetClient(unsigned int account_id) Client *ClientManager::GetClient(unsigned int account_id)
{ {
Client *cur = NULL; Client *cur = nullptr;
int count = 0; int count = 0;
list<Client*>::iterator iter = clients.begin(); list<Client*>::iterator iter = clients.begin();
while(iter != clients.end()) while(iter != clients.end())

View File

@ -46,7 +46,7 @@ string Config::GetVariable(string title, string parameter)
*/ */
void Config::Parse(const char *file_name) void Config::Parse(const char *file_name)
{ {
if(file_name == NULL) if(file_name == nullptr)
{ {
server_log->Log(log_error, "Config::Parse(), file_name passed was null."); server_log->Log(log_error, "Config::Parse(), file_name passed was null.");
return; return;

View File

@ -35,12 +35,12 @@ DatabaseMySQL::DatabaseMySQL(string user, string pass, string host, string port,
this->host = host; this->host = host;
this->name = name; this->name = name;
db = mysql_init(NULL); db = mysql_init(nullptr);
if(db) if(db)
{ {
my_bool r = 1; my_bool r = 1;
mysql_options(db, MYSQL_OPT_RECONNECT, &r); mysql_options(db, MYSQL_OPT_RECONNECT, &r);
if(!mysql_real_connect(db, host.c_str(), user.c_str(), pass.c_str(), name.c_str(), atoi(port.c_str()), NULL, 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."); server_log->Log(log_database, "Failed to connect to MySQL database.");
@ -84,7 +84,7 @@ bool DatabaseMySQL::GetLoginDataFromAccountName(string name, string &password, u
if(res) if(res)
{ {
while((row = mysql_fetch_row(res)) != NULL) while((row = mysql_fetch_row(res)) != nullptr)
{ {
id = atoi(row[0]); id = atoi(row[0]);
password = row[1]; password = row[1];
@ -128,7 +128,7 @@ bool DatabaseMySQL::GetWorldRegistration(string long_name, string short_name, un
res = mysql_use_result(db); res = mysql_use_result(db);
if(res) if(res)
{ {
if((row = mysql_fetch_row(res)) != NULL) if((row = mysql_fetch_row(res)) != nullptr)
{ {
id = atoi(row[0]); id = atoi(row[0]);
desc = row[1]; desc = row[1];
@ -153,7 +153,7 @@ bool DatabaseMySQL::GetWorldRegistration(string long_name, string short_name, un
res = mysql_use_result(db); res = mysql_use_result(db);
if(res) if(res)
{ {
if((row = mysql_fetch_row(res)) != NULL) if((row = mysql_fetch_row(res)) != nullptr)
{ {
account = row[0]; account = row[0];
password = row[1]; password = row[1];
@ -264,7 +264,7 @@ bool DatabaseMySQL::CreateWorldRegistration(string long_name, string short_name,
res = mysql_use_result(db); res = mysql_use_result(db);
if(res) if(res)
{ {
if((row = mysql_fetch_row(res)) != NULL) if((row = mysql_fetch_row(res)) != nullptr)
{ {
id = atoi(row[0]) + 1; id = atoi(row[0]) + 1;
mysql_free_result(res); mysql_free_result(res);

View File

@ -37,7 +37,7 @@ public:
/** /**
* Constructor, sets our database to null. * Constructor, sets our database to null.
*/ */
DatabaseMySQL() { db = NULL; } DatabaseMySQL() { db = nullptr; }
/** /**
* Constructor, tries to set our database to connect to the supplied options. * Constructor, tries to set our database to connect to the supplied options.
@ -52,7 +52,7 @@ public:
/** /**
* @return Returns true if the database successfully connected. * @return Returns true if the database successfully connected.
*/ */
virtual bool IsConnected() { return (db != NULL); } virtual bool IsConnected() { return (db != nullptr); }
/** /**
* Retrieves the login data (password hash and account id) from the account name provided * Retrieves the login data (password hash and account id) from the account name provided

View File

@ -30,8 +30,8 @@ extern LoginServer server;
DatabasePostgreSQL::DatabasePostgreSQL(string user, string pass, string host, string port, string name) DatabasePostgreSQL::DatabasePostgreSQL(string user, string pass, string host, string port, string name)
{ {
db = NULL; db = nullptr;
db = PQsetdbLogin(host.c_str(), port.c_str(), NULL, NULL, 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."); server_log->Log(log_database, "Failed to connect to PostgreSQL Database.");
@ -41,7 +41,7 @@ DatabasePostgreSQL::DatabasePostgreSQL(string user, string pass, string host, st
{ {
server_log->Log(log_database, "Failed to connect to PostgreSQL Database."); server_log->Log(log_database, "Failed to connect to PostgreSQL Database.");
PQfinish(db); PQfinish(db);
db = NULL; db = nullptr;
} }
} }

View File

@ -37,7 +37,7 @@ public:
/** /**
* Constructor, sets our database to null. * Constructor, sets our database to null.
*/ */
DatabasePostgreSQL() { db = NULL; } DatabasePostgreSQL() { db = nullptr; }
/** /**
* Constructor, tries to set our database to connect to the supplied options. * Constructor, tries to set our database to connect to the supplied options.
@ -52,7 +52,7 @@ public:
/** /**
* Returns true if the database successfully connected. * Returns true if the database successfully connected.
*/ */
virtual bool IsConnected() { return (db != NULL); } virtual bool IsConnected() { return (db != nullptr); }
/** /**
* Retrieves the login data (password hash and account id) from the account name provided * Retrieves the login data (password hash and account id) from the account name provided

View File

@ -36,9 +36,9 @@ class Encryption
{ {
public: public:
/** /**
* Constructor, sets all member pointers to NULL. * Constructor, sets all member pointers to nullptr.
*/ */
Encryption() : h_dll(NULL), encrypt_func(NULL), decrypt_func(NULL), delete_func(NULL) { }; Encryption() : h_dll(nullptr), encrypt_func(nullptr), decrypt_func(nullptr), delete_func(nullptr) { };
/** /**
* Destructor, if it's loaded it unloads this library. * Destructor, if it's loaded it unloads this library.
@ -48,7 +48,7 @@ public:
/** /**
* Returns true if the dll is loaded, otherwise false. * Returns true if the dll is loaded, otherwise false.
*/ */
inline bool Loaded() { return (h_dll != NULL); } inline bool Loaded() { return (h_dll != nullptr); }
/** /**
* Loads the plugin. * Loads the plugin.

View File

@ -40,9 +40,9 @@ public:
* but it's the most trivial way to do this. * but it's the most trivial way to do this.
*/ */
#ifdef WIN32 #ifdef WIN32
LoginServer() : config(NULL), db(NULL), eq_crypto(NULL), SM(NULL) { } LoginServer() : config(nullptr), db(nullptr), eq_crypto(nullptr), SM(nullptr) { }
#else #else
LoginServer() : config(NULL), db(NULL) { } LoginServer() : config(nullptr), db(nullptr) { }
#endif #endif
Config *config; Config *config;

View File

@ -44,7 +44,7 @@ int main()
set_exception_handler(); set_exception_handler();
//Create our error log, is of format login_<number>.log //Create our error log, is of format login_<number>.log
time_t current_time = time(NULL); time_t current_time = time(nullptr);
stringstream log_name(stringstream::in | stringstream::out); stringstream log_name(stringstream::in | stringstream::out);
#ifdef WIN32 #ifdef WIN32
log_name << ".\\logs\\login_" << (unsigned int)current_time << ".log"; log_name << ".\\logs\\login_" << (unsigned int)current_time << ".log";

View File

@ -54,7 +54,7 @@ ServerManager::~ServerManager()
void ServerManager::Process() void ServerManager::Process()
{ {
ProcessDisconnect(); ProcessDisconnect();
EmuTCPConnection *tcp_c = NULL; EmuTCPConnection *tcp_c = nullptr;
while(tcp_c = tcps->NewQueuePop()) while(tcp_c = tcps->NewQueuePop())
{ {
in_addr tmp; in_addr tmp;
@ -126,7 +126,7 @@ WorldServer* ServerManager::GetServerByAddress(unsigned int address)
iter++; iter++;
} }
return NULL; return nullptr;
} }
EQApplicationPacket *ServerManager::CreateServerListPacket(Client *c) EQApplicationPacket *ServerManager::CreateServerListPacket(Client *c)

View File

@ -64,12 +64,12 @@ public:
/** /**
* Checks to see if there is a server exists with this name, ignoring option. * Checks to see if there is a server exists with this name, ignoring option.
*/ */
bool ServerExists(string l_name, string s_name, WorldServer *ignore = NULL); bool ServerExists(string l_name, string s_name, WorldServer *ignore = nullptr);
/** /**
* Destroys a server with this name, ignoring option. * Destroys a server with this name, ignoring option.
*/ */
void DestroyServerByName(string l_name, string s_name, WorldServer *ignore = NULL); void DestroyServerByName(string l_name, string s_name, WorldServer *ignore = nullptr);
private: private:
/** /**

View File

@ -59,7 +59,7 @@ void WorldServer::Reset()
bool WorldServer::Process() bool WorldServer::Process()
{ {
ServerPacket *app = NULL; ServerPacket *app = nullptr;
while(app = connection->PopPacket()) while(app = connection->PopPacket())
{ {
if(server.options.IsWorldTraceOn()) if(server.options.IsWorldTraceOn())
@ -223,7 +223,7 @@ bool WorldServer::Process()
} }
delete app; delete app;
app = NULL; app = nullptr;
} }
return true; return true;
} }

View File

@ -36,7 +36,7 @@
using namespace std; using namespace std;
//atoi is not uint32 or uint32 safe!!!! //atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, NULL, 10) #define atoul(str) strtoul(str, nullptr, 10)
class Database : public DBcore { class Database : public DBcore {
public: public:

View File

@ -262,7 +262,7 @@ void LFGuildManager::TogglePlayer(uint32 FromZoneID, uint32 FromInstanceID, char
safe_delete_array(query); safe_delete_array(query);
uint32 Now = time(NULL); uint32 Now = time(nullptr);
if(Toggle == 1) if(Toggle == 1)
{ {
@ -313,7 +313,7 @@ void LFGuildManager::ToggleGuild(uint32 FromZoneID, uint32 FromInstanceID, char
safe_delete_array(query); safe_delete_array(query);
uint32 Now = time(NULL); uint32 Now = time(nullptr);
if(Toggle == 1) if(Toggle == 1)
{ {
@ -351,7 +351,7 @@ void LFGuildManager::ExpireEntries()
for(it = Players.begin(); it != Players.end(); ++it) for(it = Players.begin(); it != Players.end(); ++it)
{ {
if((*it).TimePosted + 604800 <= (uint32)time(NULL)) if((*it).TimePosted + 604800 <= (uint32)time(nullptr))
{ {
if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE from `lfguild` WHERE `type` = 0 AND `name` = '%s'", (*it).Name.c_str()), errbuf, 0, 0)) if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE from `lfguild` WHERE `type` = 0 AND `name` = '%s'", (*it).Name.c_str()), errbuf, 0, 0))
_log(QUERYSERV__ERROR, "Error expiring player LFGuild entry, query was %s, %s", query, errbuf); _log(QUERYSERV__ERROR, "Error expiring player LFGuild entry, query was %s, %s", query, errbuf);
@ -364,7 +364,7 @@ void LFGuildManager::ExpireEntries()
for(it2 = Guilds.begin(); it2 != Guilds.end(); ++it2) for(it2 = Guilds.begin(); it2 != Guilds.end(); ++it2)
{ {
if((*it2).TimePosted + 2592000 <= time(NULL)) if((*it2).TimePosted + 2592000 <= time(nullptr))
{ {
if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE from `lfguild` WHERE `type` = 1 AND `name` = '%s'", (*it2).Name.c_str()), errbuf, 0, 0)) if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE from `lfguild` WHERE `type` = 1 AND `name` = '%s'", (*it2).Name.c_str()), errbuf, 0, 0))
_log(QUERYSERV__ERROR, "Error removing guild LFGuild entry, query was %s, %s", query, errbuf); _log(QUERYSERV__ERROR, "Error removing guild LFGuild entry, query was %s, %s", query, errbuf);

View File

@ -22,7 +22,7 @@
#include "../common/debug.h" #include "../common/debug.h"
#include "queryservconfig.h" #include "queryservconfig.h"
queryservconfig *queryservconfig::_chat_config = NULL; queryservconfig *queryservconfig::_chat_config = nullptr;
string queryservconfig::GetByName(const string &var_name) const { string queryservconfig::GetByName(const string &var_name) const {
return(EQEmuConfig::GetByName(var_name)); return(EQEmuConfig::GetByName(var_name));

View File

@ -36,14 +36,14 @@ public:
// Produce a const singleton // Produce a const singleton
static const queryservconfig *get() { static const queryservconfig *get() {
if (_chat_config == NULL) if (_chat_config == nullptr)
LoadConfig(); LoadConfig();
return(_chat_config); return(_chat_config);
} }
// Load the config // Load the config
static bool LoadConfig() { static bool LoadConfig() {
if (_chat_config != NULL) if (_chat_config != nullptr)
delete _chat_config; delete _chat_config;
_chat_config=new queryservconfig; _chat_config=new queryservconfig;
_config=_chat_config; _config=_chat_config;

View File

@ -40,7 +40,7 @@ public:
TEST_ASSERT(mmf.Size() == 512); TEST_ASSERT(mmf.Size() == 512);
unsigned char *data = reinterpret_cast<unsigned char*>(mmf.Get()); unsigned char *data = reinterpret_cast<unsigned char*>(mmf.Get());
TEST_ASSERT(data != NULL); TEST_ASSERT(data != nullptr);
*reinterpret_cast<uint32*>(data) = 562; *reinterpret_cast<uint32*>(data) = 562;
} }
@ -50,7 +50,7 @@ public:
TEST_ASSERT(mmf.Size() == 512); TEST_ASSERT(mmf.Size() == 512);
unsigned char *data = reinterpret_cast<unsigned char*>(mmf.Get()); unsigned char *data = reinterpret_cast<unsigned char*>(mmf.Get());
TEST_ASSERT(data != NULL); TEST_ASSERT(data != nullptr);
uint32 val = *reinterpret_cast<uint32*>(data); uint32 val = *reinterpret_cast<uint32*>(data);
TEST_ASSERT(val == 562); TEST_ASSERT(val == 562);

View File

@ -85,7 +85,7 @@ ChatChannel* ChatChannelList::FindChannel(string Name) {
iterator.Advance(); iterator.Advance();
} }
return NULL; return nullptr;
} }
void ChatChannelList::SendAllChannels(Client *c) { void ChatChannelList::SendAllChannels(Client *c) {
@ -452,13 +452,13 @@ bool ChatChannel::IsClientInChannel(Client *c) {
ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c) { ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c) {
if(!c) return NULL; if(!c) return nullptr;
if((ChannelName.length() > 0) && (isdigit(ChannelName[0]))) { if((ChannelName.length() > 0) && (isdigit(ChannelName[0]))) {
c->GeneralChannelMessage("The channel name can not begin with a number."); c->GeneralChannelMessage("The channel name can not begin with a number.");
return NULL; return nullptr;
} }
string NormalisedName, Password; string NormalisedName, Password;
@ -477,7 +477,7 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
c->GeneralChannelMessage("The channel name or password cannot exceed 64 characters."); c->GeneralChannelMessage("The channel name or password cannot exceed 64 characters.");
return NULL; return nullptr;
} }
_log(UCS__TRACE, "AddClient to channel [%s] with password [%s]", NormalisedName.c_str(), Password.c_str()); _log(UCS__TRACE, "AddClient to channel [%s] with password [%s]", NormalisedName.c_str(), Password.c_str());
@ -493,11 +493,11 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
c->GeneralChannelMessage(Message); c->GeneralChannelMessage(Message);
return NULL; return nullptr;
} }
if(RequiredChannel->IsClientInChannel(c)) if(RequiredChannel->IsClientInChannel(c))
return NULL; return nullptr;
if(RequiredChannel->IsInvitee(c->GetName())) { if(RequiredChannel->IsInvitee(c->GetName())) {
@ -518,12 +518,12 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
c->GeneralChannelMessage("Incorrect password for channel " + (NormalisedName)); c->GeneralChannelMessage("Incorrect password for channel " + (NormalisedName));
return NULL; return nullptr;
} }
ChatChannel *ChatChannelList::RemoveClientFromChannel(string inChannelName, Client *c) { ChatChannel *ChatChannelList::RemoveClientFromChannel(string inChannelName, Client *c) {
if(!c) return NULL; if(!c) return nullptr;
string ChannelName = inChannelName; string ChannelName = inChannelName;
@ -533,7 +533,7 @@ ChatChannel *ChatChannelList::RemoveClientFromChannel(string inChannelName, Clie
ChatChannel *RequiredChannel = FindChannel(ChannelName); ChatChannel *RequiredChannel = FindChannel(ChannelName);
if(!RequiredChannel) if(!RequiredChannel)
return NULL; return nullptr;
// RemoveClient will return false if there is no-one left in the channel, and the channel is not permanent and has // RemoveClient will return false if there is no-one left in the channel, and the channel is not permanent and has
// no password. // no password.

View File

@ -69,7 +69,7 @@ void Client::SendUptime() {
ms -= m * 60000; ms -= m * 60000;
uint32 s = ms / 1000; uint32 s = ms / 1000;
char *Buffer = NULL; char *Buffer = nullptr;
MakeAnyLenString(&Buffer, "UCS has been up for %02id %02ih %02im %02is", d, h, m, s); MakeAnyLenString(&Buffer, "UCS has been up for %02id %02ih %02im %02is", d, h, m, s);
GeneralChannelMessage(Buffer); GeneralChannelMessage(Buffer);
@ -510,7 +510,7 @@ Client::Client(EQStream *eqs) {
Revoked = false; Revoked = false;
for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) for(int i = 0; i < MAX_JOINED_CHANNELS ; i++)
JoinedChannels[i] = NULL; JoinedChannels[i] = nullptr;
TotalKarma = 0; TotalKarma = 0;
AttemptedMessages = 0; AttemptedMessages = 0;
@ -533,13 +533,13 @@ Client::~Client() {
if(AccountGrabUpdateTimer) if(AccountGrabUpdateTimer)
{ {
delete AccountGrabUpdateTimer; delete AccountGrabUpdateTimer;
AccountGrabUpdateTimer = NULL; AccountGrabUpdateTimer = nullptr;
} }
if(GlobalChatLimiterTimer) if(GlobalChatLimiterTimer)
{ {
delete GlobalChatLimiterTimer; delete GlobalChatLimiterTimer;
GlobalChatLimiterTimer = NULL; GlobalChatLimiterTimer = nullptr;
} }
} }
@ -964,7 +964,7 @@ Client *Clientlist::FindCharacter(string CharacterName) {
} }
return NULL; return nullptr;
} }
void Client::AddToChannelList(ChatChannel *JoinedChannel) { void Client::AddToChannelList(ChatChannel *JoinedChannel) {
@ -972,7 +972,7 @@ void Client::AddToChannelList(ChatChannel *JoinedChannel) {
if(!JoinedChannel) return; if(!JoinedChannel) return;
for(int i = 0; i < MAX_JOINED_CHANNELS; i++) for(int i = 0; i < MAX_JOINED_CHANNELS; i++)
if(JoinedChannels[i] == NULL) { if(JoinedChannels[i] == nullptr) {
JoinedChannels[i] = JoinedChannel; JoinedChannels[i] = JoinedChannel;
_log(UCS__TRACE, "Added Channel %s to slot %i for %s", JoinedChannel->GetName().c_str(), i + 1, GetName().c_str()); _log(UCS__TRACE, "Added Channel %s to slot %i for %s", JoinedChannel->GetName().c_str(), i + 1, GetName().c_str());
return; return;
@ -989,7 +989,7 @@ void Client::RemoveFromChannelList(ChatChannel *JoinedChannel) {
for(int j = i; j < (MAX_JOINED_CHANNELS - 1); j++) for(int j = i; j < (MAX_JOINED_CHANNELS - 1); j++)
JoinedChannels[j] = JoinedChannels[j + 1]; JoinedChannels[j] = JoinedChannels[j + 1];
JoinedChannels[MAX_JOINED_CHANNELS - 1] = NULL; JoinedChannels[MAX_JOINED_CHANNELS - 1] = nullptr;
break; break;
} }
@ -1066,7 +1066,7 @@ void Client::JoinChannels(string ChannelNameList) {
for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) { for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) {
if(JoinedChannels[i] != NULL) { if(JoinedChannels[i] != nullptr) {
if(ChannelCount) { if(ChannelCount) {
@ -1155,7 +1155,7 @@ void Client::LeaveChannels(string ChannelNameList) {
for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) { for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) {
if(JoinedChannels[i] != NULL) { if(JoinedChannels[i] != nullptr) {
if(ChannelCount) { if(ChannelCount) {
@ -1213,7 +1213,7 @@ void Client::LeaveAllChannels(bool SendUpdatedChannelList) {
ChannelList->RemoveClientFromChannel(JoinedChannels[i]->GetName(), this); ChannelList->RemoveClientFromChannel(JoinedChannels[i]->GetName(), this);
JoinedChannels[i] = NULL; JoinedChannels[i] = nullptr;
} }
} }
@ -1258,7 +1258,7 @@ void Client::SendChannelList() {
for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) { for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) {
if(JoinedChannels[i] != NULL) { if(JoinedChannels[i] != nullptr) {
if(ChannelCount) if(ChannelCount)
ChannelMessage = ChannelMessage + ","; ChannelMessage = ChannelMessage + ",";
@ -1313,7 +1313,7 @@ void Client::SendChannelMessage(string Message)
{ {
if(GetKarma() < RuleI(Chat, KarmaGlobalChatLimit)) if(GetKarma() < RuleI(Chat, KarmaGlobalChatLimit))
{ {
CharacterEntry *char_ent = NULL; CharacterEntry *char_ent = nullptr;
for(int x = 0; x < Characters.size(); ++x) for(int x = 0; x < Characters.size(); ++x)
{ {
if(Characters[x].Name.compare(GetName()) == 0) if(Characters[x].Name.compare(GetName()) == 0)
@ -1426,7 +1426,7 @@ void Client::SendChannelMessageByNumber(string Message) {
{ {
if(GetKarma() < RuleI(Chat, KarmaGlobalChatLimit)) if(GetKarma() < RuleI(Chat, KarmaGlobalChatLimit))
{ {
CharacterEntry *char_ent = NULL; CharacterEntry *char_ent = nullptr;
for(int x = 0; x < Characters.size(); ++x) for(int x = 0; x < Characters.size(); ++x)
{ {
if(Characters[x].Name.compare(GetName()) == 0) if(Characters[x].Name.compare(GetName()) == 0)
@ -2171,7 +2171,7 @@ string Client::ChannelSlotName(int SlotNumber) {
if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS)) if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS))
return ""; return "";
if(JoinedChannels[SlotNumber - 1] == NULL) if(JoinedChannels[SlotNumber - 1] == nullptr)
return ""; return "";
return JoinedChannels[SlotNumber - 1]->GetName(); return JoinedChannels[SlotNumber - 1]->GetName();
@ -2261,7 +2261,7 @@ Client *Clientlist::IsCharacterOnline(string CharacterName) {
} }
return NULL; return nullptr;
} }
int Client::GetMailBoxNumber(string CharacterName) { int Client::GetMailBoxNumber(string CharacterName) {
@ -2281,7 +2281,7 @@ void Client::SendNotification(int MailBoxNumber, string Subject, string From, in
char Sequence[100]; char Sequence[100];
sprintf(TimeStamp, "%i", (int)time(NULL)); sprintf(TimeStamp, "%i", (int)time(nullptr));
sprintf(sMessageID, "%i", MessageID); sprintf(sMessageID, "%i", MessageID);

View File

@ -583,7 +583,7 @@ bool Database::SendMail(string Recipient, string From, string Subject, string Bo
uint32 LastMsgID; uint32 LastMsgID;
int Now = time(NULL); // time returns a 64 bit int on Windows at least, which vsnprintf doesn't like. int Now = time(nullptr); // time returns a 64 bit int on Windows at least, which vsnprintf doesn't like.
if(!RunQuery(query, MakeAnyLenString(&query, MailQuery, CharacterID, Now, From.c_str(), EscSubject, EscBody, if(!RunQuery(query, MakeAnyLenString(&query, MailQuery, CharacterID, Now, From.c_str(), EscSubject, EscBody,
RecipientsString.c_str(), 1), errbuf, 0, 0, &LastMsgID)) { RecipientsString.c_str(), 1), errbuf, 0, 0, &LastMsgID)) {
@ -661,7 +661,7 @@ void Database::ExpireMail() {
// Expire Trash // Expire Trash
if(RuleI(Mail, ExpireTrash) >= 0) { if(RuleI(Mail, ExpireTrash) >= 0) {
if(RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `status`=4 and `timestamp` < %i", if(RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `status`=4 and `timestamp` < %i",
time(NULL) - RuleI(Mail, ExpireTrash)), errbuf, 0, &AffectedRows)) { time(nullptr) - RuleI(Mail, ExpireTrash)), errbuf, 0, &AffectedRows)) {
_log(UCS__INIT, "Expired %i trash messages.", AffectedRows); _log(UCS__INIT, "Expired %i trash messages.", AffectedRows);
} }
else { else {
@ -672,7 +672,7 @@ void Database::ExpireMail() {
// Expire Read // Expire Read
if(RuleI(Mail, ExpireRead) >= 0) { if(RuleI(Mail, ExpireRead) >= 0) {
if(RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `status`=3 and `timestamp` < %i", if(RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `status`=3 and `timestamp` < %i",
time(NULL) - RuleI(Mail, ExpireRead)), errbuf, 0, &AffectedRows)) { time(nullptr) - RuleI(Mail, ExpireRead)), errbuf, 0, &AffectedRows)) {
_log(UCS__INIT, "Expired %i read messages.", AffectedRows); _log(UCS__INIT, "Expired %i read messages.", AffectedRows);
} }
else { else {
@ -683,7 +683,7 @@ void Database::ExpireMail() {
// Expire Unread // Expire Unread
if(RuleI(Mail, ExpireUnread) >= 0) { if(RuleI(Mail, ExpireUnread) >= 0) {
if(RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `status`=1 and `timestamp` < %i", if(RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `status`=1 and `timestamp` < %i",
time(NULL) - RuleI(Mail, ExpireUnread)), errbuf, 0, &AffectedRows)) { time(nullptr) - RuleI(Mail, ExpireUnread)), errbuf, 0, &AffectedRows)) {
_log(UCS__INIT, "Expired %i unread messages.", AffectedRows); _log(UCS__INIT, "Expired %i unread messages.", AffectedRows);
} }
else { else {

View File

@ -36,7 +36,7 @@
using namespace std; using namespace std;
//atoi is not uint32 or uint32 safe!!!! //atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, NULL, 10) #define atoul(str) strtoul(str, nullptr, 10)
class Database : public DBcore { class Database : public DBcore {
public: public:

View File

@ -22,7 +22,7 @@
#include "../common/debug.h" #include "../common/debug.h"
#include "ucsconfig.h" #include "ucsconfig.h"
ucsconfig *ucsconfig::_chat_config = NULL; ucsconfig *ucsconfig::_chat_config = nullptr;
string ucsconfig::GetByName(const string &var_name) const { string ucsconfig::GetByName(const string &var_name) const {
return(EQEmuConfig::GetByName(var_name)); return(EQEmuConfig::GetByName(var_name));

View File

@ -36,14 +36,14 @@ public:
// Produce a const singleton // Produce a const singleton
static const ucsconfig *get() { static const ucsconfig *get() {
if (_chat_config == NULL) if (_chat_config == nullptr)
LoadConfig(); LoadConfig();
return(_chat_config); return(_chat_config);
} }
// Load the config // Load the config
static bool LoadConfig() { static bool LoadConfig() {
if (_chat_config != NULL) if (_chat_config != nullptr)
delete _chat_config; delete _chat_config;
_chat_config=new ucsconfig; _chat_config=new ucsconfig;
_config=_chat_config; _config=_chat_config;

View File

@ -63,7 +63,7 @@ struct Texture {
class Model { class Model {
public: public:
Model() { IncludeInMap = false; verts = NULL; vert_count = 0; polys = NULL; poly_count = 0; tex = NULL; tex_count = 0; name = NULL; } Model() { IncludeInMap = false; verts = nullptr; vert_count = 0; polys = nullptr; poly_count = 0; tex = nullptr; tex_count = 0; name = nullptr; }
~Model() {} ~Model() {}
Vertex **verts; Vertex **verts;

View File

@ -120,7 +120,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
archive = new PFSLoader(); archive = new PFSLoader();
FILE *s3df = fopen(bufs, "rb"); FILE *s3df = fopen(bufs, "rb");
if(s3df == NULL) { if(s3df == nullptr) {
// One day we may try EQG, but not today. // One day we may try EQG, but not today.
printf("Unable to open s3d file '%s'.\n", bufs); printf("Unable to open s3d file '%s'.\n", bufs);
return(false); return(false);
@ -133,7 +133,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
fileloader = new WLDLoader(); fileloader = new WLDLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) { if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading WLD from %s\n", bufs); printf("Error reading WLD from %s\n", bufs);
return(false); return(false);
} }
@ -173,7 +173,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
} }
if(tree==NULL) { if(tree==nullptr) {
printf("No BSP Tree. Bailing out\n"); printf("No BSP Tree. Bailing out\n");
return(false); return(false);
} }
@ -200,7 +200,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
sprintf(bufm, "%s.wtr", shortname); sprintf(bufm, "%s.wtr", shortname);
FILE *WaterFile = fopen(bufm, "wb"); FILE *WaterFile = fopen(bufm, "wb");
if(WaterFile == NULL) { if(WaterFile == nullptr) {
printf("Failed to open %s for writing\n", bufm); printf("Failed to open %s for writing\n", bufm);
return(false); return(false);
} }

View File

@ -100,10 +100,10 @@ int main(int argc, char *argv[]) {
} }
QTBuilder::QTBuilder() { QTBuilder::QTBuilder() {
_root = NULL; _root = nullptr;
faceCount = 0; faceCount = 0;
faceBlock = NULL; faceBlock = nullptr;
#ifdef COUNT_MACTHES #ifdef COUNT_MACTHES
gEasyMatches = 0; gEasyMatches = 0;
@ -114,12 +114,12 @@ QTBuilder::QTBuilder() {
} }
QTBuilder::~QTBuilder() { QTBuilder::~QTBuilder() {
if(_root != NULL) if(_root != nullptr)
delete _root; delete _root;
_root = NULL; _root = nullptr;
if(faceBlock != NULL) if(faceBlock != nullptr)
delete [] faceBlock; delete [] faceBlock;
faceBlock = NULL; faceBlock = nullptr;
} }
bool QTBuilder::build(const char *shortname) { bool QTBuilder::build(const char *shortname) {
@ -138,12 +138,12 @@ bool QTBuilder::build(const char *shortname) {
archive = new PFSLoader(); archive = new PFSLoader();
fff = fopen(bufs, "rb"); fff = fopen(bufs, "rb");
if(fff != NULL) if(fff != nullptr)
FileType = S3D; FileType = S3D;
else { else {
sprintf(bufs, "%s.eqg", shortname); sprintf(bufs, "%s.eqg", shortname);
fff = fopen(bufs, "rb"); fff = fopen(bufs, "rb");
if(fff != NULL) if(fff != nullptr)
FileType = EQG; FileType = EQG;
} }
@ -160,17 +160,17 @@ bool QTBuilder::build(const char *shortname) {
switch(FileType) { switch(FileType) {
case S3D: case S3D:
fileloader = new WLDLoader(); fileloader = new WLDLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) { if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading WLD from %s\n", bufs); printf("Error reading WLD from %s\n", bufs);
return(false); return(false);
} }
break; break;
case EQG: case EQG:
fileloader = new ZonLoader(); fileloader = new ZonLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) { if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
delete fileloader; delete fileloader;
fileloader = new Zonv4Loader(); fileloader = new Zonv4Loader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) { if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading ZON/TER from %s\n", bufs); printf("Error reading ZON/TER from %s\n", bufs);
return(false); return(false);
} }
@ -296,7 +296,7 @@ bool QTBuilder::build(const char *shortname) {
printf("Building quadtree.\n"); printf("Building quadtree.\n");
_root = new QTNode(this, minx, maxx, miny, maxy); _root = new QTNode(this, minx, maxx, miny, maxy);
if(_root == NULL) { if(_root == nullptr) {
printf("Unable to allocate new QTNode.\n"); printf("Unable to allocate new QTNode.\n");
return(false); return(false);
} }
@ -332,13 +332,13 @@ bool QTBuilder::build(const char *shortname) {
bool QTBuilder::writeMap(const char *file) { bool QTBuilder::writeMap(const char *file) {
if(_root == NULL) if(_root == nullptr)
return(false); return(false);
printf("Writing map file.\n"); printf("Writing map file.\n");
FILE *out = fopen(file, "wb"); FILE *out = fopen(file, "wb");
if(out == NULL) { if(out == nullptr) {
printf("Unable to open output file '%s'.\n", file); printf("Unable to open output file '%s'.\n", file);
return(1); return(1);
} }
@ -370,7 +370,7 @@ bool QTBuilder::writeMap(const char *file) {
//make our node blocks to write out... //make our node blocks to write out...
nodeHeader *nodes = new nodeHeader[head.node_count]; nodeHeader *nodes = new nodeHeader[head.node_count];
unsigned long *facelist = new unsigned long[head.facelist_count]; unsigned long *facelist = new unsigned long[head.facelist_count];
if(nodes == NULL || facelist == NULL) { if(nodes == nullptr || facelist == nullptr) {
printf("Error allocating temporary memory for output.\n"); printf("Error allocating temporary memory for output.\n");
fclose(out); fclose(out);
return(1); //no memory return(1); //no memory
@ -404,10 +404,10 @@ bool QTBuilder::writeMap(const char *file) {
QTNode::QTNode(QTBuilder *b, float Tminx, float Tmaxx, float Tminy, float Tmaxy) { QTNode::QTNode(QTBuilder *b, float Tminx, float Tmaxx, float Tminy, float Tmaxy) {
node1 = NULL; node1 = nullptr;
node2 = NULL; node2 = nullptr;
node3 = NULL; node3 = nullptr;
node4 = NULL; node4 = nullptr;
minx = Tminx; minx = Tminx;
maxx = Tmaxx; maxx = Tmaxx;
miny = Tminy; miny = Tminy;
@ -423,18 +423,18 @@ QTNode::~QTNode() {
} }
void QTNode::clearNodes() { void QTNode::clearNodes() {
if(node1 != NULL) if(node1 != nullptr)
delete node1; delete node1;
if(node2 != NULL) if(node2 != nullptr)
delete node2; delete node2;
if(node3 != NULL) if(node3 != nullptr)
delete node3; delete node3;
if(node4 != NULL) if(node4 != nullptr)
delete node4; delete node4;
node1 = NULL; node1 = nullptr;
node2 = NULL; node2 = nullptr;
node3 = NULL; node3 = nullptr;
node4 = NULL; node4 = nullptr;
} }
//assumes that both supplied arrays are big enough per countNodes/Facelists //assumes that both supplied arrays are big enough per countNodes/Facelists
@ -463,25 +463,25 @@ void QTNode::fillBlocks(nodeHeader *heads, unsigned long *flist, unsigned long &
//branch node. //branch node.
head->flags = 0; head->flags = 0;
if(node1 != NULL) { if(node1 != nullptr) {
head->nodes[0] = hindex; head->nodes[0] = hindex;
node1->fillBlocks(heads, flist, hindex, findex); node1->fillBlocks(heads, flist, hindex, findex);
} else { } else {
head->nodes[0] = NODE_NONE; head->nodes[0] = NODE_NONE;
} }
if(node2 != NULL) { if(node2 != nullptr) {
head->nodes[1] = hindex; head->nodes[1] = hindex;
node2->fillBlocks(heads, flist, hindex, findex); node2->fillBlocks(heads, flist, hindex, findex);
} else { } else {
head->nodes[1] = NODE_NONE; head->nodes[1] = NODE_NONE;
} }
if(node3 != NULL) { if(node3 != nullptr) {
head->nodes[2] = hindex; head->nodes[2] = hindex;
node3->fillBlocks(heads, flist, hindex, findex); node3->fillBlocks(heads, flist, hindex, findex);
} else { } else {
head->nodes[2] = NODE_NONE; head->nodes[2] = NODE_NONE;
} }
if(node4 != NULL) { if(node4 != nullptr) {
head->nodes[3] = hindex; head->nodes[3] = hindex;
node4->fillBlocks(heads, flist, hindex, findex); node4->fillBlocks(heads, flist, hindex, findex);
} else { } else {
@ -492,26 +492,26 @@ void QTNode::fillBlocks(nodeHeader *heads, unsigned long *flist, unsigned long &
unsigned long QTNode::countNodes() const { unsigned long QTNode::countNodes() const {
unsigned long c = 1; unsigned long c = 1;
if(node1 != NULL) if(node1 != nullptr)
c += node1->countNodes(); c += node1->countNodes();
if(node2 != NULL) if(node2 != nullptr)
c += node2->countNodes(); c += node2->countNodes();
if(node3 != NULL) if(node3 != nullptr)
c += node3->countNodes(); c += node3->countNodes();
if(node4 != NULL) if(node4 != nullptr)
c += node4->countNodes(); c += node4->countNodes();
return(c); return(c);
} }
unsigned long QTNode::countFacelists() const { unsigned long QTNode::countFacelists() const {
unsigned long c = final? faces.size() : 0; unsigned long c = final? faces.size() : 0;
if(node1 != NULL) if(node1 != nullptr)
c += node1->countFacelists(); c += node1->countFacelists();
if(node2 != NULL) if(node2 != nullptr)
c += node2->countFacelists(); c += node2->countFacelists();
if(node3 != NULL) if(node3 != nullptr)
c += node3->countFacelists(); c += node3->countFacelists();
if(node4 != NULL) if(node4 != nullptr)
c += node4->countFacelists(); c += node4->countFacelists();
return(c); return(c);
} }
@ -607,13 +607,13 @@ printf("Stopping (empty) on box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d
depth++; depth++;
if(node1 != NULL) if(node1 != nullptr)
node1->divideYourself(depth); node1->divideYourself(depth);
if(node2 != NULL) if(node2 != nullptr)
node2->divideYourself(depth); node2->divideYourself(depth);
if(node3 != NULL) if(node3 != nullptr)
node3->divideYourself(depth); node3->divideYourself(depth);
if(node4 != NULL) if(node4 != nullptr)
node4->divideYourself(depth); node4->divideYourself(depth);
@ -854,7 +854,7 @@ void QTNode::doSplit() {
node2 = new QTNode(builder, minx, midx, midy, maxy); node2 = new QTNode(builder, minx, midx, midy, maxy);
node3 = new QTNode(builder, minx, midx, miny, midy); node3 = new QTNode(builder, minx, midx, miny, midy);
node4 = new QTNode(builder, midx, maxx, miny, midy); node4 = new QTNode(builder, midx, maxx, miny, midy);
if(node1 == NULL || node2 == NULL || node3 == NULL || node4 == NULL) { if(node1 == nullptr || node2 == nullptr || node3 == nullptr || node4 == nullptr) {
printf("Error: unable to allocate new QTNode, giving up.\n"); printf("Error: unable to allocate new QTNode, giving up.\n");
return; return;
} }
@ -876,19 +876,19 @@ void QTNode::doSplit() {
//clean up empty sets. //clean up empty sets.
if(node1->faces.size() == 0) { if(node1->faces.size() == 0) {
delete node1; delete node1;
node1 = NULL; node1 = nullptr;
} }
if(node2->faces.size() == 0) { if(node2->faces.size() == 0) {
delete node2; delete node2;
node2 = NULL; node2 = nullptr;
} }
if(node3->faces.size() == 0) { if(node3->faces.size() == 0) {
delete node3; delete node3;
node3 = NULL; node3 = nullptr;
} }
if(node4->faces.size() == 0) { if(node4->faces.size() == 0) {
delete node4; delete node4;
node4 = NULL; node4 = nullptr;
} }
} }
@ -1178,8 +1178,8 @@ void QTBuilder::AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool Li
for(int i = 0; i < fileloader->model_data.plac_count; ++i) { for(int i = 0; i < fileloader->model_data.plac_count; ++i) {
if(fileloader->model_data.placeable[i]->model==-1) continue; if(fileloader->model_data.placeable[i]->model==-1) continue;
// The model pointer should only really be NULL for the zone model, as we process that separately. // The model pointer should only really be nullptr for the zone model, as we process that separately.
if(fileloader->model_data.models[fileloader->model_data.placeable[i]->model] == NULL) continue; if(fileloader->model_data.models[fileloader->model_data.placeable[i]->model] == nullptr) continue;
if(ListPlaceable) if(ListPlaceable)
printf("Placeable Object %4d @ (%9.2f, %9.2f, %9.2f uses model %4d %s\n",i, printf("Placeable Object %4d @ (%9.2f, %9.2f, %9.2f uses model %4d %s\n",i,
fileloader->model_data.placeable[i]->y, fileloader->model_data.placeable[i]->y,

View File

@ -125,9 +125,9 @@ int AddModelName(Content_3D *C3D, string ModelName)
DATLoader::DATLoader() DATLoader::DATLoader()
{ {
this->buffer = NULL; this->buffer = nullptr;
this->buf_len = -1; this->buf_len = -1;
this->archive = NULL; this->archive = nullptr;
this->status = 0; this->status = 0;
} }

View File

@ -9,8 +9,8 @@
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#ifndef NULL #ifndef nullptr
#define NULL 0 #define nullptr 0
#endif #endif
typedef unsigned long uint32; typedef unsigned long uint32;

View File

@ -70,12 +70,12 @@ bool ProcessZoneFile(const char *shortname) {
archive = new PFSLoader(); archive = new PFSLoader();
fff = fopen(bufs, "rb"); fff = fopen(bufs, "rb");
if(fff != NULL) if(fff != nullptr)
FileType = S3D; FileType = S3D;
else { else {
sprintf(bufs, "%s.eqg", shortname); sprintf(bufs, "%s.eqg", shortname);
fff = fopen(bufs, "rb"); fff = fopen(bufs, "rb");
if(fff != NULL) if(fff != nullptr)
FileType = EQG; FileType = EQG;
} }
@ -94,7 +94,7 @@ bool ProcessZoneFile(const char *shortname) {
switch(FileType) { switch(FileType) {
case S3D: case S3D:
fileloader = new WLDLoader(); fileloader = new WLDLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) { if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading WLD from %s\n", bufs); printf("Error reading WLD from %s\n", bufs);
return(false); return(false);
} }
@ -102,10 +102,10 @@ bool ProcessZoneFile(const char *shortname) {
case EQG: case EQG:
fileloader = new ZonLoader(); fileloader = new ZonLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) { if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
delete fileloader; delete fileloader;
fileloader = new Zonv4Loader(); fileloader = new Zonv4Loader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) { if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading ZON/TER from %s\n", bufs); printf("Error reading ZON/TER from %s\n", bufs);
return(false); return(false);
} }
@ -131,7 +131,7 @@ void ListPlaceable(FileLoader *fileloader, char *ZoneFileName) {
for(int i = 0; i < fileloader->model_data.plac_count; ++i) { for(int i = 0; i < fileloader->model_data.plac_count; ++i) {
if(fileloader->model_data.placeable[i]->model==-1) continue; if(fileloader->model_data.placeable[i]->model==-1) continue;
if(fileloader->model_data.models[fileloader->model_data.placeable[i]->model] == NULL) continue; if(fileloader->model_data.models[fileloader->model_data.placeable[i]->model] == nullptr) continue;
printf("Placeable Object %4d @ (%9.2f, %9.2f, %9.2f uses model %4d %s\n",i, printf("Placeable Object %4d @ (%9.2f, %9.2f, %9.2f uses model %4d %s\n",i,
fileloader->model_data.placeable[i]->y, fileloader->model_data.placeable[i]->y,
fileloader->model_data.placeable[i]->x, fileloader->model_data.placeable[i]->x,

View File

@ -67,7 +67,7 @@ inline void Lower(char *str) {
PFSLoader::PFSLoader() { PFSLoader::PFSLoader() {
// Set the status of the loader that nothing is loaded. // Set the status of the loader that nothing is loaded.
this->buffer = NULL; this->buffer = nullptr;
this->buf_len = -1; this->buf_len = -1;
this->status = 0; this->status = 0;
} }
@ -195,7 +195,7 @@ int PFSLoader::Close()
else else
return 0; return 0;
this->buffer = NULL; this->buffer = nullptr;
this->buf_len = -1; this->buf_len = -1;
this->status = 0; this->status = 0;
@ -214,7 +214,7 @@ const char *PFSLoader::FindExtension(const char *ext) {
if(!strcmp(this->filenames[i]+(flen-elen), ext)) if(!strcmp(this->filenames[i]+(flen-elen), ext))
return(this->filenames[i]); return(this->filenames[i]);
} }
return(NULL); return(nullptr);
} }
int PFSLoader::GetFile(char *name, uchar **buf, int *len) { int PFSLoader::GetFile(char *name, uchar **buf, int *len) {

View File

@ -10,9 +10,9 @@
//#define DEBUGTER //#define DEBUGTER
TERLoader::TERLoader() { TERLoader::TERLoader() {
this->buffer = NULL; this->buffer = nullptr;
this->buf_len = -1; this->buf_len = -1;
this->archive = NULL; this->archive = nullptr;
this->status = 0; this->status = 0;
} }
@ -84,8 +84,8 @@ int TERLoader::Open(char *base_path, char *zone_name, Archive *archive) {
return 0; return 0;
for(i = 0; i < thdr->mat_count; ++i) { for(i = 0; i < thdr->mat_count; ++i) {
mlist[i].name = NULL; mlist[i].name = nullptr;
mlist[i].basetex = NULL; mlist[i].basetex = nullptr;
} }
StartOfNameList = buffer; StartOfNameList = buffer;

Some files were not shown because too many files have changed in this diff Show More