Merge from master

This commit is contained in:
KimLS
2013-05-23 12:50:34 -07:00
214 changed files with 2422 additions and 2373 deletions
+2 -2
View File
@@ -56,7 +56,7 @@ void BasePacket::build_raw_header_dump(char *buffer, uint16 seq) const
buffer += sprintf(buffer, "%s.%06lu ",temp,timestamp.tv_usec);
}
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
buffer += sprintf(buffer, "[%s:%d->%s:%d]\n",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -80,7 +80,7 @@ void BasePacket::build_header_dump(char *buffer) const
void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
+2 -1
View File
@@ -55,6 +55,7 @@ SET(common_sources
serverinfo.cpp
shareddb.cpp
spdat.cpp
StringUtil.cpp
StructStrategy.cpp
TCPConnection.cpp
TCPServer.cpp
@@ -170,6 +171,7 @@ SET(common_headers
shareddb.h
skills.h
spdat.h
StringUtil.h
StructStrategy.h
TCPBasicServer.h
TCPConnection.h
@@ -313,7 +315,6 @@ INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML)
ADD_LIBRARY(Common ${common_sources} ${common_headers})
IF(UNIX)
ADD_DEFINITIONS(-fPIC)
SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0)
+1 -1
View File
@@ -46,7 +46,7 @@ public:
//END PERL EXPORT
private:
string m_escapeBuffer;
std::string m_escapeBuffer;
static EQDB s_EQDB;
MYSQL *mysql_ref;
};
+4 -4
View File
@@ -19,8 +19,8 @@
#include "EQDBRes.h"
#include <mysql.h>
vector<string> EQDBRes::fetch_row_array() {
vector<string> array;
std::vector<std::string> EQDBRes::fetch_row_array() {
std::vector<std::string> array;
if(res == nullptr)
return(array);
@@ -32,8 +32,8 @@ vector<string> EQDBRes::fetch_row_array() {
return array;
}
map<string,string> EQDBRes::fetch_row_hash() {
map<string,string> rowhash;
std::map<std::string,std::string> EQDBRes::fetch_row_hash() {
std::map<std::string,std::string> rowhash;
if(res == nullptr)
return(rowhash);
+2 -2
View File
@@ -36,8 +36,8 @@ public:
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
void DESTROY() { }
void finish() { if (res) mysql_free_result(res); res=nullptr; };
vector<string> fetch_row_array();
map<string,string> fetch_row_hash();
std::vector<std::string> fetch_row_array();
std::map<std::string,std::string> fetch_row_hash();
unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; }
//END PERL EXPORT
+41 -41
View File
@@ -21,7 +21,7 @@
#include <iostream>
#include <sstream>
string EQEmuConfig::ConfigFile = "eqemu_config.xml";
std::string EQEmuConfig::ConfigFile = "eqemu_config.xml";
EQEmuConfig *EQEmuConfig::_config = nullptr;
void EQEmuConfig::do_world(TiXmlElement *ele) {
@@ -315,7 +315,7 @@ void EQEmuConfig::do_launcher(TiXmlElement *ele) {
}
}
string EQEmuConfig::GetByName(const string &var_name) const {
std::string EQEmuConfig::GetByName(const std::string &var_name) const {
if(var_name == "ShortName")
return(ShortName);
if(var_name == "LongName")
@@ -405,44 +405,44 @@ string EQEmuConfig::GetByName(const string &var_name) const {
void EQEmuConfig::Dump() const
{
cout << "ShortName = " << ShortName << endl;
cout << "LongName = " << LongName << endl;
cout << "WorldAddress = " << WorldAddress << endl;
cout << "LoginHost = " << LoginHost << endl;
cout << "LoginAccount = " << LoginAccount << endl;
cout << "LoginPassword = " << LoginPassword << endl;
cout << "LoginPort = " << LoginPort << endl;
cout << "Locked = " << Locked << endl;
cout << "WorldTCPPort = " << WorldTCPPort << endl;
cout << "WorldIP = " << WorldIP << endl;
cout << "TelnetEnabled = " << TelnetEnabled << endl;
cout << "WorldHTTPPort = " << WorldHTTPPort << endl;
cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << endl;
cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << endl;
cout << "ChatHost = " << ChatHost << endl;
cout << "ChatPort = " << ChatPort << endl;
cout << "MailHost = " << MailHost << endl;
cout << "MailPort = " << MailPort << endl;
cout << "DatabaseHost = " << DatabaseHost << endl;
cout << "DatabaseUsername = " << DatabaseUsername << endl;
cout << "DatabasePassword = " << DatabasePassword << endl;
cout << "DatabaseDB = " << DatabaseDB << endl;
cout << "DatabasePort = " << DatabasePort << endl;
cout << "QSDatabaseHost = " << QSDatabaseHost << endl;
cout << "QSDatabaseUsername = " << QSDatabaseUsername << endl;
cout << "QSDatabasePassword = " << QSDatabasePassword << endl;
cout << "QSDatabaseDB = " << QSDatabaseDB << endl;
cout << "QSDatabasePort = " << QSDatabasePort << endl;
cout << "SpellsFile = " << SpellsFile << endl;
cout << "OpCodesFile = " << OpCodesFile << endl;
cout << "EQTimeFile = " << EQTimeFile << endl;
cout << "LogSettingsFile = " << LogSettingsFile << endl;
cout << "MapDir = " << MapDir << endl;
cout << "QuestDir = " << QuestDir << endl;
cout << "PluginDir = " << PluginDir << endl;
cout << "ZonePortLow = " << ZonePortLow << endl;
cout << "ZonePortHigh = " << ZonePortHigh << endl;
cout << "DefaultStatus = " << (int)DefaultStatus << endl;
// cout << "DynamicCount = " << DynamicCount << endl;
std::cout << "ShortName = " << ShortName << std::endl;
std::cout << "LongName = " << LongName << std::endl;
std::cout << "WorldAddress = " << WorldAddress << std::endl;
std::cout << "LoginHost = " << LoginHost << std::endl;
std::cout << "LoginAccount = " << LoginAccount << std::endl;
std::cout << "LoginPassword = " << LoginPassword << std::endl;
std::cout << "LoginPort = " << LoginPort << std::endl;
std::cout << "Locked = " << Locked << std::endl;
std::cout << "WorldTCPPort = " << WorldTCPPort << std::endl;
std::cout << "WorldIP = " << WorldIP << std::endl;
std::cout << "TelnetEnabled = " << TelnetEnabled << std::endl;
std::cout << "WorldHTTPPort = " << WorldHTTPPort << std::endl;
std::cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << std::endl;
std::cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << std::endl;
std::cout << "ChatHost = " << ChatHost << std::endl;
std::cout << "ChatPort = " << ChatPort << std::endl;
std::cout << "MailHost = " << MailHost << std::endl;
std::cout << "MailPort = " << MailPort << std::endl;
std::cout << "DatabaseHost = " << DatabaseHost << std::endl;
std::cout << "DatabaseUsername = " << DatabaseUsername << std::endl;
std::cout << "DatabasePassword = " << DatabasePassword << std::endl;
std::cout << "DatabaseDB = " << DatabaseDB << std::endl;
std::cout << "DatabasePort = " << DatabasePort << std::endl;
std::cout << "QSDatabaseHost = " << QSDatabaseHost << std::endl;
std::cout << "QSDatabaseUsername = " << QSDatabaseUsername << std::endl;
std::cout << "QSDatabasePassword = " << QSDatabasePassword << std::endl;
std::cout << "QSDatabaseDB = " << QSDatabaseDB << std::endl;
std::cout << "QSDatabasePort = " << QSDatabasePort << std::endl;
std::cout << "SpellsFile = " << SpellsFile << std::endl;
std::cout << "OpCodesFile = " << OpCodesFile << std::endl;
std::cout << "EQTimeFile = " << EQTimeFile << std::endl;
std::cout << "LogSettingsFile = " << LogSettingsFile << std::endl;
std::cout << "MapDir = " << MapDir << std::endl;
std::cout << "QuestDir = " << QuestDir << std::endl;
std::cout << "PluginDir = " << PluginDir << std::endl;
std::cout << "ZonePortLow = " << ZonePortLow << std::endl;
std::cout << "ZonePortHigh = " << ZonePortHigh << std::endl;
std::cout << "DefaultStatus = " << (int)DefaultStatus << std::endl;
// std::cout << "DynamicCount = " << DynamicCount << std::endl;
}
+36 -36
View File
@@ -22,74 +22,74 @@
#include "linked_list.h"
struct LoginConfig {
string LoginHost;
string LoginAccount;
string LoginPassword;
std::string LoginHost;
std::string LoginAccount;
std::string LoginPassword;
uint16 LoginPort;
};
class EQEmuConfig : public XMLParser {
public:
virtual string GetByName(const string &var_name) const;
virtual std::string GetByName(const std::string &var_name) const;
// From <world/>
string ShortName;
string LongName;
string WorldAddress;
string LocalAddress;
string LoginHost;
string LoginAccount;
string LoginPassword;
std::string ShortName;
std::string LongName;
std::string WorldAddress;
std::string LocalAddress;
std::string LoginHost;
std::string LoginAccount;
std::string LoginPassword;
uint16 LoginPort;
uint32 LoginCount;
LinkedList<LoginConfig*> loginlist;
bool Locked;
uint16 WorldTCPPort;
string WorldIP;
std::string WorldIP;
bool TelnetEnabled;
int32 MaxClients;
bool WorldHTTPEnabled;
uint16 WorldHTTPPort;
string WorldHTTPMimeFile;
string SharedKey;
std::string WorldHTTPMimeFile;
std::string SharedKey;
// From <chatserver/>
string ChatHost;
std::string ChatHost;
uint16 ChatPort;
// From <mailserver/>
string MailHost;
std::string MailHost;
uint16 MailPort;
// From <database/>
string DatabaseHost;
string DatabaseUsername;
string DatabasePassword;
string DatabaseDB;
std::string DatabaseHost;
std::string DatabaseUsername;
std::string DatabasePassword;
std::string DatabaseDB;
uint16 DatabasePort;
// From <qsdatabase> // QueryServ
string QSDatabaseHost;
string QSDatabaseUsername;
string QSDatabasePassword;
string QSDatabaseDB;
std::string QSDatabaseHost;
std::string QSDatabaseUsername;
std::string QSDatabasePassword;
std::string QSDatabaseDB;
uint16 QSDatabasePort;
// From <files/>
string SpellsFile;
string OpCodesFile;
string EQTimeFile;
string LogSettingsFile;
std::string SpellsFile;
std::string OpCodesFile;
std::string EQTimeFile;
std::string LogSettingsFile;
// From <directories/>
string MapDir;
string QuestDir;
string PluginDir;
std::string MapDir;
std::string QuestDir;
std::string PluginDir;
// From <launcher/>
string LogPrefix;
string LogSuffix;
string ZoneExe;
std::string LogPrefix;
std::string LogSuffix;
std::string ZoneExe;
uint32 RestartWait;
uint32 TerminateWait;
uint32 InitialBootWait;
@@ -108,7 +108,7 @@ protected:
static EQEmuConfig *_config;
static string ConfigFile;
static std::string ConfigFile;
#define ELEMENT(name) \
void do_##name(TiXmlElement *ele);
@@ -210,7 +210,7 @@ public:
}
// Allow the use to set the conf file to be used.
static void SetConfigFile(string file) { EQEmuConfig::ConfigFile = file; }
static void SetConfigFile(std::string file) { EQEmuConfig::ConfigFile = file; }
// Load the config
static bool LoadConfig() {
+4 -6
View File
@@ -46,8 +46,6 @@
#include "../common/crc32.h"
#include "../common/eq_packet_structs.h"
using namespace std;
#define EQN_DEBUG 0
#define EQN_DEBUG_Error 0
#define EQN_DEBUG_Packet 0
@@ -230,19 +228,19 @@ void EQStreamServer::Process() {
}
}
map <string, EQStream*>::iterator connection;
std::map <std::string, EQStream*>::iterator connection;
for (connection = connection_list.begin( ); connection != connection_list.end( );)
{
if(!connection->second)
{
map <string, EQStream*>::iterator tmp=connection;
std::map <std::string, EQStream*>::iterator tmp=connection;
connection++;
connection_list.erase(tmp);
continue;
}
EQStream* eqs_data = connection->second;
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
map <string, EQStream*>::iterator tmp=connection;
std::map <std::string, EQStream*>::iterator tmp=connection;
connection++;
safe_delete(eqs_data);
connection_list.erase(tmp);
@@ -277,7 +275,7 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
sprintf(temp,"%lu:%u",(unsigned long)irIP,irPort);
cout << "Data from " << temp << endl;
EQStream* tmp = NULL;
map <string, EQStream*>::iterator connection;
std::map <std::string, EQStream*>::iterator connection;
if ((connection=connection_list.find(temp))!=connection_list.end())
tmp=connection->second;
if(tmp != NULL && tmp->GetrPort() == irPort)
+2 -3
View File
@@ -30,7 +30,6 @@
#include <map>
#include <list>
#include <queue>
using namespace std;
#include "../common/types.h"
#include "../common/timer.h"
@@ -114,8 +113,8 @@ private:
Mutex MNewQueue;
Mutex MOpen;
map<string,EQStream*> connection_list;
queue<EQStream *> NewQueue;
std::map<std::string,EQStream*> connection_list;
std::queue<EQStream *> NewQueue;
};
#endif
+6 -8
View File
@@ -32,8 +32,6 @@
#include <cstdlib>
#include <cstring>
using namespace std;
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len),
emu_opcode(op)
@@ -61,7 +59,7 @@ void EQPacket::build_header_dump(char *buffer) const {
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -95,7 +93,7 @@ void EQProtocolPacket::build_header_dump(char *buffer) const
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -137,7 +135,7 @@ void EQApplicationPacket::build_header_dump(char *buffer) const
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -183,7 +181,7 @@ void EQRawApplicationPacket::build_header_dump(char *buffer) const
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{
if (src_ip) {
string sIP,dIP;;
std::string sIP,dIP;;
sIP=long2ip(src_ip);
dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
@@ -502,8 +500,8 @@ EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const u
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
if (iShowInfo) {
cout << "Dumping Applayer: 0x" << hex << setfill('0') << setw(4) << app->GetOpcode() << dec;
cout << " size:" << app->size << endl;
std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
std::cout << " size:" << app->size << std::endl;
}
DumpPacketHex(app->pBuffer, app->size);
// DumpPacketAscii(app->pBuffer, app->size);
-2
View File
@@ -30,8 +30,6 @@
#include "emu_opcodes.h"
#endif
using namespace std;
class EQStream;
class EQStreamPair;
+12 -13
View File
@@ -20,7 +20,6 @@
#include <iomanip>
#include <iostream>
#include <vector>
#include <time.h>
#include <sys/types.h>
#ifdef _WINDOWS
#include <time.h>
@@ -424,7 +423,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
uint16 index = seq - SequencedBase;
_log(NET__NET_TRACE, _L "OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
if (index < sqsize) {
deque<EQProtocolPacket *>::iterator sitr;
std::deque<EQProtocolPacket *>::iterator sitr;
sitr = SequencedQueue.begin();
sitr += index;
(*sitr)->acked = true;
@@ -567,7 +566,7 @@ uint32 length;
while (used<length) {
out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
chunksize=min(length-used,MaxLen-6);
chunksize=std::min(length-used,MaxLen-6);
memcpy(out->pBuffer+2,tmpbuff+used,chunksize);
out->size=chunksize+2;
SequencedPush(out);
@@ -646,9 +645,9 @@ uint16 Seq=htons(seq);
void EQStream::Write(int eq_fd)
{
queue<EQProtocolPacket *> ReadyToSend;
std::queue<EQProtocolPacket *> ReadyToSend;
bool SeqEmpty=false,NonSeqEmpty=false;
deque<EQProtocolPacket *>::iterator sitr;
std::deque<EQProtocolPacket *>::iterator sitr;
// Check our rate to make sure we can send more
MRate.lock();
@@ -951,7 +950,7 @@ EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock();
if (InboundQueue.size()) {
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
p=*itr;
InboundQueue.erase(itr);
}
@@ -979,7 +978,7 @@ EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock();
if (InboundQueue.size()) {
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
p=*itr;
InboundQueue.erase(itr);
}
@@ -1007,7 +1006,7 @@ EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock();
if (InboundQueue.size()) {
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
p=*itr;
}
MInboundQueue.unlock();
@@ -1023,7 +1022,7 @@ EQApplicationPacket *p=nullptr;
MInboundQueue.lock();
if (!InboundQueue.empty()) {
vector<EQRawApplicationPacket *>::iterator itr;
std::vector<EQRawApplicationPacket *>::iterator itr;
for(itr=InboundQueue.begin();itr!=InboundQueue.end();itr++) {
p=*itr;
delete p;
@@ -1070,7 +1069,7 @@ EQProtocolPacket *p=nullptr;
NonSequencedQueue.pop();
}
if(!SequencedQueue.empty()) {
deque<EQProtocolPacket *>::iterator itr;
std::deque<EQProtocolPacket *>::iterator itr;
for(itr=SequencedQueue.begin();itr!=SequencedQueue.end();itr++) {
p=*itr;
delete p;
@@ -1095,7 +1094,7 @@ EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
if(!PacketQueue.empty()) {
map<unsigned short,EQProtocolPacket *>::iterator itr;
std::map<unsigned short,EQProtocolPacket *>::iterator itr;
for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) {
p=itr->second;
delete p;
@@ -1149,7 +1148,7 @@ long EQStream::GetLastAckSent()
void EQStream::AckPackets(uint16 seq)
{
deque<EQProtocolPacket *>::iterator itr, tmp;
std::deque<EQProtocolPacket *>::iterator itr, tmp;
MOutboundQueue.lock();
//do a bit of sanity checking.
@@ -1234,7 +1233,7 @@ void EQStream::ProcessQueue()
EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
{
map<unsigned short,EQProtocolPacket *>::iterator itr;
std::map<unsigned short,EQProtocolPacket *>::iterator itr;
EQProtocolPacket *qp=nullptr;
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
qp=itr->second;
+4 -6
View File
@@ -18,8 +18,6 @@
#include "../common/Condition.h"
#include "../common/timer.h"
using namespace std;
#define FLAG_COMPRESSED 0x01
#define FLAG_ENCODED 0x04
@@ -113,8 +111,8 @@ class EQStream : public EQStreamInterface {
Mutex MAcks;
// Packets waiting to be sent (all protected by MOutboundQueue)
queue<EQProtocolPacket *> NonSequencedQueue;
deque<EQProtocolPacket *> SequencedQueue;
std::queue<EQProtocolPacket *> NonSequencedQueue;
std::deque<EQProtocolPacket *> SequencedQueue;
uint16 NextOutSeq;
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
long NextSequencedSend; //index into SequencedQueue
@@ -124,8 +122,8 @@ class EQStream : public EQStreamInterface {
unsigned char _tempBuffer[2048];
// Packets waiting to be processed
vector<EQRawApplicationPacket *> InboundQueue;
map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
std::vector<EQRawApplicationPacket *> InboundQueue;
std::map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
Mutex MInboundQueue;
static uint16 MaxWindowSize;
+6 -8
View File
@@ -19,8 +19,6 @@
#include "EQStream.h"
#include "logsys.h"
using namespace std;
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
{
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
@@ -146,7 +144,7 @@ void EQStreamFactory::Push(EQStream *s)
void EQStreamFactory::ReaderLoop()
{
fd_set readset;
map<string,EQStream *>::iterator stream_itr;
std::map<std::string,EQStream *>::iterator stream_itr;
int num;
int length;
unsigned char buffer[2048];
@@ -227,7 +225,7 @@ void EQStreamFactory::CheckTimeout()
MStreams.lock();
unsigned long now=Timer::GetCurrentTime();
map<string,EQStream *>::iterator stream_itr;
std::map<std::string,EQStream *>::iterator stream_itr;
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
EQStream *s = stream_itr->second;
@@ -243,7 +241,7 @@ void EQStreamFactory::CheckTimeout()
} else {
//everybody is done, we can delete it now
//cout << "Removing connection" << endl;
map<string,EQStream *>::iterator temp=stream_itr;
std::map<std::string,EQStream *>::iterator temp=stream_itr;
stream_itr++;
//let whoever has the stream outside delete it
delete temp->second;
@@ -259,10 +257,10 @@ void EQStreamFactory::CheckTimeout()
void EQStreamFactory::WriterLoop()
{
map<string,EQStream *>::iterator stream_itr;
std::map<std::string,EQStream *>::iterator stream_itr;
bool havework=true;
vector<EQStream *> wants_write;
vector<EQStream *>::iterator cur,end;
std::vector<EQStream *> wants_write;
std::vector<EQStream *>::iterator cur,end;
bool decay=false;
uint32 stream_count;
+2 -2
View File
@@ -24,10 +24,10 @@ class EQStreamFactory : private Timeoutable {
EQStreamType StreamType;
queue<EQStream *> NewStreams;
std::queue<EQStream *> NewStreams;
Mutex MNewStreams;
map<string,EQStream *> Streams;
std::map<std::string,EQStream *> Streams;
Mutex MStreams;
virtual void CheckTimeout();
+4 -6
View File
@@ -3,14 +3,12 @@
#include "EQStreamProxy.h"
#include "logsys.h"
using namespace std;
EQStreamIdentifier::~EQStreamIdentifier() {
while(!m_identified.empty()) {
m_identified.front()->ReleaseFromUse();
m_identified.pop();
}
vector<Record *>::iterator cur, end;
std::vector<Record *>::iterator cur, end;
cur = m_streams.begin();
end = m_streams.end();
for(; cur != end; cur++) {
@@ -18,7 +16,7 @@ EQStreamIdentifier::~EQStreamIdentifier() {
r->stream->ReleaseFromUse();
delete r;
}
vector<Patch *>::iterator curp, endp;
std::vector<Patch *>::iterator curp, endp;
curp = m_patches.begin();
endp = m_patches.end();
for(; curp != endp; curp++) {
@@ -36,8 +34,8 @@ void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const cha
}
void EQStreamIdentifier::Process() {
vector<Record *>::iterator cur;
vector<Patch *>::iterator curp, endp;
std::vector<Record *>::iterator cur;
std::vector<Patch *>::iterator curp, endp;
//foreach pending stream.
cur = m_streams.begin();
+2 -3
View File
@@ -24,7 +24,6 @@ This did not turn out nearly as nice as I hoped.
#include <map>
#include <string>
using namespace std;
class EQStreamInfo {
public:
@@ -103,7 +102,7 @@ inline bool operator==(const EQStreamInfo &l, const EQStreamInfo &r) {
template <class T>
class EQStreamLocator {
protected:
typedef typename map<const EQStreamInfo, T *>::iterator iterator;
typedef typename std::map<const EQStreamInfo, T *>::iterator iterator;
public:
void Clear() {
@@ -167,7 +166,7 @@ public:
// inline iterator end() const { return(streams.end()); }
protected:
map<const EQStreamInfo, T *> streams;
std::map<const EQStreamInfo, T *> streams;
};
#endif
+23 -25
View File
@@ -26,11 +26,9 @@ tremendously.
#include "../common/debug.h"
#include <iostream>
using namespace std;
#include <string.h>
#include <stdio.h>
#include <iomanip>
using namespace std;
#include "EmuTCPConnection.h"
#include "EmuTCPServer.h"
@@ -93,7 +91,7 @@ EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer,
TCPMode = iMode;
PacketMode = packetModeZone;
#if TCPN_DEBUG_Memory >= 7
cout << "Constructor #1 on outgoing TCP# " << GetID() << endl;
std::cout << "Constructor #1 on outgoing TCP# " << GetID() << std::endl;
#endif
}
@@ -113,7 +111,7 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConne
TCPMode = modePacket;
PacketMode = packetModeZone;
#if TCPN_DEBUG_Memory >= 7
cout << "Constructor #3 on outgoing TCP# " << GetID() << endl;
std::cout << "Constructor #3 on outgoing TCP# " << GetID() << std::endl;
#endif
}
@@ -173,7 +171,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Logging outgoing TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl;
std::cout << ": Logging outgoing TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
@@ -200,7 +198,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Logging outgoing TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl;
std::cout << ": Logging outgoing TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
@@ -239,10 +237,10 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << tnps->opcode << dec << ", size: " << setw(5) << setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
std::cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << tnps->opcode << dec << ", size: " << setw(5) << setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
if (pOldFormat)
cout << " (OldFormat)";
cout << endl;
std::cout << " (OldFormat)";
std::cout << std::endl;
#if TCPN_LOG_PACKETS == 2
if (tnps->size >= 32)
DumpPacket((uchar*) tnps, 32);
@@ -284,7 +282,7 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
#if defined(GOTFRAGS) && 0
if (strcmp(line, "**CRASHME**") == 0) {
int i = 0;
cout << (5 / i) << endl;
std::cout << (5 / i) << std::endl;
}
#endif
if(line[0] == '*') {
@@ -456,10 +454,10 @@ void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
#if TCPC_DEBUG >= 1
struct in_addr in;
in.s_addr = GetrIP();
cout "NetError: '";
std::cout "NetError: '";
if (reason)
cout << reason;
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl;
std::cout << reason;
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif
ServerPacket* pack = new ServerPacket(0);
pack->size = 1;
@@ -522,7 +520,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
size = tnps->size;
if (size >= MaxTCPReceiveBuffferSize) {
#if TCPN_DEBUG_Memory >= 1
cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << endl;
std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
DumpPacket(&recvbuf[base], 16);
#endif
if (errbuf)
@@ -562,13 +560,13 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
if (pack->opcode == 0) {
if (pack->size) {
#if TCPN_DEBUG >= 2
cout << "Received TCP Network layer packet" << endl;
std::cout << "Received TCP Network layer packet" << std::endl;
#endif
ProcessNetworkLayerPacket(pack);
}
#if TCPN_DEBUG >= 5
else {
cout << "Received TCP keepalive packet. (opcode=0)" << endl;
std::cout << "Received TCP keepalive packet. (opcode=0)" << std::endl;
}
#endif
// keepalive, no need to process
@@ -580,7 +578,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Logging incoming TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl;
std::cout << ": Logging incoming TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
@@ -596,7 +594,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
EmuTCPConnection* con = Server->FindConnection(pack->destination);
if (!con) {
#if TCPN_DEBUG >= 1
cout << "Error relaying packet: con = 0" << endl;
std::cout << "Error relaying packet: con = 0" << std::endl;
#endif
safe_delete(pack);
}
@@ -635,7 +633,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
memcpy(&size, &buffer[2], 2);
if (size >= MaxTCPReceiveBuffferSize) {
#if TCPN_DEBUG_Memory >= 1
cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << endl;
std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
#endif
if (errbuf)
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
@@ -665,7 +663,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Logging incoming TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl;
std::cout << ": Logging incoming TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
@@ -726,7 +724,7 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
#if TCPC_DEBUG >= 3
struct in_addr in;
in.s_addr = GetrIP();
cout << "Switching to RelayServer mode: " << inet_ntoa(in) << ":" << GetPort() << endl;
std::cout << "Switching to RelayServer mode: " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif
RelayServer = true;
break;
@@ -774,10 +772,10 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
#if TCPC_DEBUG >= 1
struct in_addr in;
in.s_addr = GetrIP();
cout "Received NetError: '";
std::cout "Received NetError: '";
if (pack->size > 1)
cout << (char*) data;
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl;
std::cout << (char*) data;
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif
break;
}
@@ -796,7 +794,7 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
SendPacket(pack);
safe_delete(pack);
#if TCPN_DEBUG >= 5
cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << endl;
std::cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << std::endl;
#endif
}
+8 -9
View File
@@ -36,7 +36,6 @@
#include "races.h"
#include "shareddb.h"
#include "classes.h"
using namespace std;
int32 NextItemInstSerialNumber = 1;
@@ -102,7 +101,7 @@ ItemInstQueue::~ItemInstQueue() {
}
Inventory::~Inventory() {
map<int16, ItemInst*>::iterator cur,end;
std::map<int16, ItemInst*>::iterator cur,end;
cur = m_worn.begin();
@@ -580,7 +579,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
std::string ItemInst::GetCustomDataString() const {
std::string ret_val;
map<std::string, std::string>::const_iterator iter = m_custom_data.begin();
std::map<std::string, std::string>::const_iterator iter = m_custom_data.begin();
while(iter != m_custom_data.end()) {
if(ret_val.length() > 0) {
ret_val += "^";
@@ -624,14 +623,14 @@ void ItemInst::SetCustomData(std::string identifier, bool value) {
}
void ItemInst::DeleteCustomData(std::string identifier) {
map<std::string, std::string>::iterator iter = m_custom_data.find(identifier);
std::map<std::string, std::string>::iterator iter = m_custom_data.find(identifier);
if(iter != m_custom_data.end()) {
m_custom_data.erase(iter);
}
}
std::string ItemInst::GetCustomData(std::string identifier) {
map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier);
std::map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier);
if(iter != m_custom_data.end()) {
return iter->second;
}
@@ -1160,7 +1159,7 @@ void Inventory::dumpInventory() {
}
// Internal Method: Retrieves item within an inventory bucket
ItemInst* Inventory::_GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const
ItemInst* Inventory::_GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const
{
iter_inst it = bucket.find(slot_id);
if (it != bucket.end()) {
@@ -1228,7 +1227,7 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
}
// Internal Method: Checks an inventory bucket for a particular item
int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
int16 Inventory::_HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
{
iter_inst it;
iter_contents itb;
@@ -1318,7 +1317,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
}
// Internal Method: Checks an inventory bucket for a particular item
int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity)
int16 Inventory::_HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity)
{
iter_inst it;
iter_contents itb;
@@ -1386,7 +1385,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
return SLOT_INVALID;
}
int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup)
int16 Inventory::_HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup)
{
iter_inst it;
iter_contents itb;
+17 -18
View File
@@ -34,15 +34,14 @@ class EvolveInfo; // Stores information about an evolving item family
#include <vector>
#include <map>
#include <list>
using namespace std;
#include "../common/eq_packet_structs.h"
#include "../common/eq_constants.h"
#include "../common/item_struct.h"
// Helper typedefs
typedef list<ItemInst*>::const_iterator iter_queue;
typedef map<int16, ItemInst*>::const_iterator iter_inst;
typedef map<uint8, ItemInst*>::const_iterator iter_contents;
typedef std::list<ItemInst*>::const_iterator iter_queue;
typedef std::map<int16, ItemInst*>::const_iterator iter_inst;
typedef std::map<uint8, ItemInst*>::const_iterator iter_contents;
namespace ItemField {
enum {
@@ -120,7 +119,7 @@ protected:
// Protected Members
/////////////////////////
list<ItemInst*> m_list;
std::list<ItemInst*> m_list;
};
@@ -209,26 +208,26 @@ protected:
///////////////////////////////
// Retrieves item within an inventory bucket
ItemInst* _GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const;
ItemInst* _GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const;
// Private "put" item into bucket, without regard for what is currently in bucket
int16 _PutItem(int16 slot_id, ItemInst* inst);
// Checks an inventory bucket for a particular item
int16 _HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity);
int16 _HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity);
int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity);
int16 _HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity);
int16 _HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity);
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
int16 _HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup);
int16 _HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup);
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
// Player inventory
map<int16, ItemInst*> m_worn; // Items worn by character
map<int16, ItemInst*> m_inv; // Items in character personal inventory
map<int16, ItemInst*> m_bank; // Items in character bank
map<int16, ItemInst*> m_shbank; // Items in character shared bank
map<int16, ItemInst*> m_trade; // Items in a trade session
std::map<int16, ItemInst*> m_worn; // Items worn by character
std::map<int16, ItemInst*> m_inv; // Items in character personal inventory
std::map<int16, ItemInst*> m_bank; // Items in character bank
std::map<int16, ItemInst*> m_shbank; // Items in character shared bank
std::map<int16, ItemInst*> m_trade; // Items in a trade session
ItemInstQueue m_cursor; // Items on cursor: FIFO
};
@@ -300,7 +299,7 @@ public:
uint8 FirstOpenSlot() const;
uint8 GetTotalItemCount() const;
bool IsNoneEmptyContainer();
map<uint8, ItemInst*>* GetContents() { return &m_contents; }
std::map<uint8, ItemInst*>* GetContents() { return &m_contents; }
//
// Augments
@@ -368,7 +367,7 @@ public:
virtual bool IsScaling() const { return false; }
virtual bool IsEvolving() const { return false; }
string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id=slot_id; s.inst=(const void *)this; string ser; ser.assign((char *)&s,sizeof(InternalSerializedItem_Struct)); return ser; }
std::string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id=slot_id; s.inst=(const void *)this; std::string ser; ser.assign((char *)&s,sizeof(InternalSerializedItem_Struct)); return ser; }
inline int32 GetSerialNumber() const { return m_SerialNumber; }
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
@@ -396,8 +395,8 @@ protected:
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
//
// Items inside of this item (augs or contents);
map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
map<std::string, std::string> m_custom_data;
std::map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
std::map<std::string, std::string> m_custom_data;
};
class EvoItemInst: public ItemInst {
+3 -262
View File
@@ -32,15 +32,10 @@
#include "../common/timer.h"
#include "../common/seperator.h"
using namespace std;
#ifdef _WINDOWS
#include <windows.h>
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
@@ -59,10 +54,6 @@ using namespace std;
#include <errno.h>
#endif
#ifndef va_copy
#define va_copy(d,s) ((d) = (s))
#endif
static bool WELLRNG_init = false;
static int state_i = 0;
static unsigned int STATE[R];
@@ -86,207 +77,12 @@ void CoutTimestamp(bool ms) {
struct timeval read_time;
gettimeofday(&read_time,0);
cout << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec;
std::cout << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec;
if (ms)
cout << "." << setw(3) << setfill('0') << (read_time.tv_usec / 1000);
cout << " GMT";
std::cout << "." << std::setw(3) << std::setfill('0') << (read_time.tv_usec / 1000);
std::cout << " GMT";
}
// normal strncpy doesnt put a null term on copied strings, this one does
// ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecrt/htm/_wcecrt_strncpy_wcsncpy.asp
char* strn0cpy(char* dest, const char* source, uint32 size) {
if (!dest)
return 0;
if (size == 0 || source == 0) {
dest[0] = 0;
return dest;
}
strncpy(dest, source, size);
dest[size - 1] = 0;
return dest;
}
// String N w/null Copy Truncated?
// return value =true if entire string(source) fit, false if it was truncated
bool strn0cpyt(char* dest, const char* source, uint32 size) {
if (!dest)
return 0;
if (size == 0 || source == 0) {
dest[0] = 0;
return false;
}
strncpy(dest, source, size);
dest[size - 1] = 0;
return (bool) (source[strlen(dest)] == 0);
}
const char *MakeUpperString(const char *source) {
static char str[128];
if (!source)
return nullptr;
MakeUpperString(source, str);
return str;
}
void MakeUpperString(const char *source, char *target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = toupper(*source);
target++;source++;
}
*target = 0;
}
const char *MakeLowerString(const char *source) {
static char str[128];
if (!source)
return nullptr;
MakeLowerString(source, str);
return str;
}
void MakeLowerString(const char *source, char *target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = tolower(*source);
target++;source++;
}
*target = 0;
}
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
if (chars == -1)
buf_len *= 2;
else
buf_len = chars + 1;
*ret = new char[buf_len];
va_copy(tmpargptr, argptr);
chars = vsnprintf(*ret, buf_len, format, tmpargptr);
}
va_end(argptr);
return chars;
}
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...) {
if (*bufsize == 0)
*bufsize = 256;
if (*ret == 0)
*strlen = 0;
int chars = -1;
char* oldret = 0;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= (int32)(*bufsize-*strlen)) {
if (chars == -1)
*bufsize += 256;
else
*bufsize += chars + 25;
oldret = *ret;
*ret = new char[*bufsize];
if (oldret) {
if (*strlen)
memcpy(*ret, oldret, *strlen);
safe_delete_array(oldret);
}
va_copy(tmpargptr, argptr);
chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
}
va_end(argptr);
*strlen += chars;
return *strlen;
}
uint32 hextoi(char* num) {
int len = strlen(num);
if (len < 3)
return 0;
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
return 0;
uint32 ret = 0;
int mul = 1;
for (int i=len-1; i>=2; i--) {
if (num[i] >= 'A' && num[i] <= 'F')
ret += ((num[i] - 'A') + 10) * mul;
else if (num[i] >= 'a' && num[i] <= 'f')
ret += ((num[i] - 'a') + 10) * mul;
else if (num[i] >= '0' && num[i] <= '9')
ret += (num[i] - '0') * mul;
else
return 0;
mul *= 16;
}
return ret;
}
uint64 hextoi64(char* num) {
int len = strlen(num);
if (len < 3)
return 0;
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
return 0;
uint64 ret = 0;
int mul = 1;
for (int i=len-1; i>=2; i--) {
if (num[i] >= 'A' && num[i] <= 'F')
ret += ((num[i] - 'A') + 10) * mul;
else if (num[i] >= 'a' && num[i] <= 'f')
ret += ((num[i] - 'a') + 10) * mul;
else if (num[i] >= '0' && num[i] <= '9')
ret += (num[i] - '0') * mul;
else
return 0;
mul *= 16;
}
return ret;
}
bool atobool(char* iBool) {
if (!strcasecmp(iBool, "true"))
return true;
if (!strcasecmp(iBool, "false"))
return false;
if (!strcasecmp(iBool, "yes"))
return true;
if (!strcasecmp(iBool, "no"))
return false;
if (!strcasecmp(iBool, "on"))
return true;
if (!strcasecmp(iBool, "off"))
return false;
if (!strcasecmp(iBool, "enable"))
return true;
if (!strcasecmp(iBool, "disable"))
return false;
if (!strcasecmp(iBool, "enabled"))
return true;
if (!strcasecmp(iBool, "disabled"))
return false;
if (!strcasecmp(iBool, "y"))
return true;
if (!strcasecmp(iBool, "n"))
return false;
if (atoi(iBool))
return true;
return false;
}
int32 filesize(FILE* fp) {
#ifdef _WINDOWS
@@ -549,40 +345,6 @@ static unsigned int case_6 (void){
// end WELL RNG code
// solar: removes the crap and turns the underscores into spaces.
char *CleanMobName(const char *in, char *out)
{
unsigned i, j;
for(i = j = 0; i < strlen(in); i++)
{
// convert _ to space.. any other conversions like this? I *think* this
// is the only non alpha char that's not stripped but converted.
if(in[i] == '_')
{
out[j++] = ' ';
}
else
{
if(isalpha(in[i]) || (in[i] == '`')) // numbers, #, or any other crap just gets skipped
out[j++] = in[i];
}
}
out[j] = 0; // terimnate the string before returning it
return out;
}
const char *ConvertArray(int input, char *returnchar)
{
sprintf(returnchar, "%i" ,input);
return returnchar;
}
const char *ConvertArrayF(float input, char *returnchar)
{
sprintf(returnchar, "%0.2f", input);
return returnchar;
}
float EQ13toFloat(int d)
{
@@ -627,24 +389,3 @@ float EQHtoFloat(int d)
{
return(360.0f - float((d * 360) >> 11));
}
void RemoveApostrophes(std::string &s)
{
for(unsigned int i = 0; i < s.length(); ++i)
if(s[i] == '\'')
s[i] = '_';
}
char *RemoveApostrophes(const char *s)
{
char *NewString = new char[strlen(s) + 1];
strcpy(NewString, s);
for(unsigned int i = 0 ; i < strlen(NewString); ++i)
if(NewString[i] == '\'')
NewString[i] = '_';
return NewString;
}
-27
View File
@@ -86,39 +86,14 @@
#define BITMASK 0x41180000
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i: source - allocated null-terminated string
// return: pointer to static buffer with the target string
const char *MakeUpperString(const char *source);
const char *MakeLowerString(const char *source);
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i : source - allocated null-terminated string
// io: target - allocated buffer, at least of size strlen(source)+1
void MakeUpperString(const char *source, char *target);
void MakeLowerString(const char *source, char *target);
int MakeAnyLenString(char** ret, const char* format, ...);
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...);
uint32 hextoi(char* num);
uint64 hextoi64(char* num);
bool atobool(char* iBool);
int32 filesize(FILE* fp);
uint32 ResolveIP(const char* hostname, char* errbuf = 0);
bool ParseAddress(const char* iAddress, uint32* oIP, uint16* oPort, char* errbuf = 0);
void CoutTimestamp(bool ms = true);
char* strn0cpy(char* dest, const char* source, uint32 size);
// return value =true if entire string(source) fit, false if it was truncated
bool strn0cpyt(char* dest, const char* source, uint32 size);
int MakeRandomInt(int low, int high);
double MakeRandomFloat(double low, double high);
char *CleanMobName(const char *in, char *out);
const char *ConvertArray(int input, char *returnchar);
const char *ConvertArrayF(float input, char *returnchar);
float EQ13toFloat(int d);
float NewEQ13toFloat(int d);
float EQ19toFloat(int d);
@@ -127,8 +102,6 @@ int FloatToEQ13(float d);
int NewFloatToEQ13(float d);
int FloatToEQ19(float d);
int FloatToEQH(float d);
void RemoveApostrophes(std::string &s);
char *RemoveApostrophes(const char *s);
+19 -19
View File
@@ -19,7 +19,6 @@
#include "../common/Mutex.h"
#include <iostream>
using namespace std;
#define DEBUG_MUTEX_CLASS 0
#if DEBUG_MUTEX_CLASS >= 1
@@ -43,7 +42,7 @@ bool IsTryLockSupported() {
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) {
#if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() NOT supported" << endl;
std::cout << "Mutex::trylock() NOT supported" << std::endl;
#endif
return false;
}
@@ -52,13 +51,13 @@ bool IsTryLockSupported() {
// Tests for Windows NT product family.
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 4) {
#if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() SUPPORTED" << endl;
std::cout << "Mutex::trylock() SUPPORTED" << std::endl;
#endif
return true;
}
else {
#if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() NOT supported" << endl;
std::cout << "Mutex::trylock() NOT supported" << std::endl;
#endif
return false;
}
@@ -66,27 +65,28 @@ bool IsTryLockSupported() {
#endif
Mutex::Mutex() {
#if DEBUG_MUTEX_CLASS >= 7
cout << "Constructing Mutex" << endl;
std::cout << "Constructing Mutex" << std::endl;
#endif
#ifdef _WINDOWS
InitializeCriticalSection(&CSMutex);
InitializeCriticalSection(&CSMutex);
#else
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
#if defined(__CYGWIN__) || defined(__APPLE__) || defined(FREEBSD)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
#else
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
#endif
pthread_mutex_init(&CSMutex, &attr);
pthread_mutexattr_destroy(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
#endif
pthread_mutex_init(&CSMutex, &attr);
pthread_mutexattr_destroy(&attr);
#endif
}
Mutex::~Mutex() {
#if DEBUG_MUTEX_CLASS >= 7
cout << "Deconstructing Mutex" << endl;
std::cout << "Deconstructing Mutex" << std::endl;
#endif
#ifdef _WINDOWS
DeleteCriticalSection(&CSMutex);
@@ -98,11 +98,11 @@ Mutex::~Mutex() {
void Mutex::lock() {
_CP(Mutex_lock);
#if DEBUG_MUTEX_CLASS >= 9
cout << "Locking Mutex" << endl;
std::cout << "Locking Mutex" << std::endl;
#endif
#if DEBUG_MUTEX_CLASS >= 5
if (!trylock()) {
cout << "Locking Mutex: Having to wait" << endl;
std::cout << "Locking Mutex: Having to wait" << std::endl;
#ifdef _WINDOWS
EnterCriticalSection(&CSMutex);
#else
@@ -120,7 +120,7 @@ void Mutex::lock() {
bool Mutex::trylock() {
#if DEBUG_MUTEX_CLASS >= 9
cout << "TryLocking Mutex" << endl;
std::cout << "TryLocking Mutex" << std::endl;
#endif
#ifdef _WINDOWS
#if(_WIN32_WINNT >= 0x0400)
@@ -141,7 +141,7 @@ bool Mutex::trylock() {
void Mutex::unlock() {
#if DEBUG_MUTEX_CLASS >= 9
cout << "Unlocking Mutex" << endl;
std::cout << "Unlocking Mutex" << std::endl;
#endif
#ifdef _WINDOWS
LeaveCriticalSection(&CSMutex);
@@ -187,7 +187,7 @@ MRMutex::MRMutex() {
MRMutex::~MRMutex() {
#ifdef _EQDEBUG
if (wl || rl) {
cout << "MRMutex::~MRMutex: poor cleanup detected: rl=" << rl << ", wl=" << wl << endl;
std::cout << "MRMutex::~MRMutex: poor cleanup detected: rl=" << rl << ", wl=" << wl << std::endl;
}
#endif
}
+4 -7
View File
@@ -32,8 +32,6 @@
#include <string.h>
#endif
using namespace std;
ProcLauncher ProcLauncher::s_launcher;
#ifdef _WINDOWS
@@ -51,10 +49,9 @@ ProcLauncher::ProcLauncher()
#endif
}
void ProcLauncher::Process() {
#ifdef _WINDOWS
map<ProcRef, Spec *>::iterator cur, end, tmp;
std::map<ProcRef, Spec *>::iterator cur, end, tmp;
cur = m_running.begin();
end = m_running.end();
while(cur != end) {
@@ -91,7 +88,7 @@ void ProcLauncher::Process() {
break;
} else {
//one died...
map<ProcRef, Spec *>::iterator ref;
std::map<ProcRef, Spec *>::iterator ref;
ref = m_running.find(died);
if(ref == m_running.end()) {
//unable to find this process in our list...
@@ -168,8 +165,8 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
// Create the child process.
//glue together all the nice command line arguments
string args(it->program);
vector<string>::iterator cur, end;
std::string args(it->program);
std::vector<std::string>::iterator cur, end;
cur = it->args.begin();
end = it->args.end();
for(; cur != end; cur++) {
+351
View File
@@ -0,0 +1,351 @@
/*
* Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "StringUtil.h"
#include <string>
#include <cstdarg>
#include <cstring> // for strncpy
#include <stdexcept>
#ifdef _WINDOWS
#include <windows.h>
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
#include <stdlib.h>
#include <stdio.h>
#endif
#ifndef va_copy
#define va_copy(d,s) ((d) = (s))
#endif
// original source:
// https://github.com/facebook/folly/blob/master/folly/String.cpp
//
void vStringFormat(std::string& output, const char* format, va_list args)
{
va_list tmpargs;
va_copy(tmpargs,args);
int characters_used = vsnprintf(nullptr, 0, format, tmpargs);
va_end(tmpargs);
if (characters_used < 0) {
// Looks like we have an invalid format string.
// error out.
std::string errorMessage("Invalid format string; snprintf returned negative with format string: ");
errorMessage.append(format);
throw std::runtime_error(errorMessage);
}
else if ((unsigned int)characters_used > output.capacity()) {
output.resize(characters_used+1);
va_copy(tmpargs,args);
characters_used = vsnprintf(&output[0], output.capacity(), format, tmpargs);
va_end(tmpargs);
if (characters_used < 0) {
// We shouldn't have a format error by this point, but I can't imagine what error we
// could have by this point. Still, error out and report it.
std::string errorMessage("Invalid format string or unknown vsnprintf error; vsnprintf returned negative with format string: ");
errorMessage.append(format);
throw std::runtime_error(errorMessage);
}
}
else {
output.resize(characters_used + 1);
va_copy(tmpargs,args);
characters_used = vsnprintf(&output[0], output.capacity(), format, tmpargs);
va_end(tmpargs);
if (characters_used < 0) {
// We shouldn't have a format error by this point, but I can't imagine what error we
// could have by this point. still error out and report it.
std::string errorMessage("Invalid format string or unknown vsnprintf error; vsnprintf returned negative with format string: ");
errorMessage.append(format);
throw std::runtime_error(errorMessage);
}
}
}
void StringFormat(std::string& output, const char* format, ...)
{
va_list args;
va_start(args, format);
vStringFormat(output,format,args);
va_end(args);
}
// normal strncpy doesnt put a null term on copied strings, this one does
// ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecrt/htm/_wcecrt_strncpy_wcsncpy.asp
char* strn0cpy(char* dest, const char* source, uint32 size) {
if (!dest)
return 0;
if (size == 0 || source == 0) {
dest[0] = 0;
return dest;
}
strncpy(dest, source, size);
dest[size - 1] = 0;
return dest;
}
// String N w/null Copy Truncated?
// return value =true if entire string(source) fit, false if it was truncated
bool strn0cpyt(char* dest, const char* source, uint32 size) {
if (!dest)
return 0;
if (size == 0 || source == 0) {
dest[0] = 0;
return false;
}
strncpy(dest, source, size);
dest[size - 1] = 0;
return (bool) (source[strlen(dest)] == 0);
}
const char *MakeUpperString(const char *source) {
static char str[128];
if (!source)
return nullptr;
MakeUpperString(source, str);
return str;
}
void MakeUpperString(const char *source, char *target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = toupper(*source);
target++;source++;
}
*target = 0;
}
const char *MakeLowerString(const char *source) {
static char str[128];
if (!source)
return nullptr;
MakeLowerString(source, str);
return str;
}
void MakeLowerString(const char *source, char *target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = tolower(*source);
target++;source++;
}
*target = 0;
}
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
if (chars == -1)
buf_len *= 2;
else
buf_len = chars + 1;
*ret = new char[buf_len];
va_copy(tmpargptr, argptr);
chars = vsnprintf(*ret, buf_len, format, tmpargptr);
}
va_end(argptr);
return chars;
}
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...) {
if (*bufsize == 0)
*bufsize = 256;
if (*ret == 0)
*strlen = 0;
int chars = -1;
char* oldret = 0;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= (int32)(*bufsize-*strlen)) {
if (chars == -1)
*bufsize += 256;
else
*bufsize += chars + 25;
oldret = *ret;
*ret = new char[*bufsize];
if (oldret) {
if (*strlen)
memcpy(*ret, oldret, *strlen);
safe_delete_array(oldret);
}
va_copy(tmpargptr, argptr);
chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
}
va_end(argptr);
*strlen += chars;
return *strlen;
}
uint32 hextoi(char* num) {
int len = strlen(num);
if (len < 3)
return 0;
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
return 0;
uint32 ret = 0;
int mul = 1;
for (int i=len-1; i>=2; i--) {
if (num[i] >= 'A' && num[i] <= 'F')
ret += ((num[i] - 'A') + 10) * mul;
else if (num[i] >= 'a' && num[i] <= 'f')
ret += ((num[i] - 'a') + 10) * mul;
else if (num[i] >= '0' && num[i] <= '9')
ret += (num[i] - '0') * mul;
else
return 0;
mul *= 16;
}
return ret;
}
uint64 hextoi64(char* num) {
int len = strlen(num);
if (len < 3)
return 0;
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
return 0;
uint64 ret = 0;
int mul = 1;
for (int i=len-1; i>=2; i--) {
if (num[i] >= 'A' && num[i] <= 'F')
ret += ((num[i] - 'A') + 10) * mul;
else if (num[i] >= 'a' && num[i] <= 'f')
ret += ((num[i] - 'a') + 10) * mul;
else if (num[i] >= '0' && num[i] <= '9')
ret += (num[i] - '0') * mul;
else
return 0;
mul *= 16;
}
return ret;
}
bool atobool(char* iBool) {
if (!strcasecmp(iBool, "true"))
return true;
if (!strcasecmp(iBool, "false"))
return false;
if (!strcasecmp(iBool, "yes"))
return true;
if (!strcasecmp(iBool, "no"))
return false;
if (!strcasecmp(iBool, "on"))
return true;
if (!strcasecmp(iBool, "off"))
return false;
if (!strcasecmp(iBool, "enable"))
return true;
if (!strcasecmp(iBool, "disable"))
return false;
if (!strcasecmp(iBool, "enabled"))
return true;
if (!strcasecmp(iBool, "disabled"))
return false;
if (!strcasecmp(iBool, "y"))
return true;
if (!strcasecmp(iBool, "n"))
return false;
if (atoi(iBool))
return true;
return false;
}
// solar: removes the crap and turns the underscores into spaces.
char *CleanMobName(const char *in, char *out)
{
unsigned i, j;
for(i = j = 0; i < strlen(in); i++)
{
// convert _ to space.. any other conversions like this? I *think* this
// is the only non alpha char that's not stripped but converted.
if(in[i] == '_')
{
out[j++] = ' ';
}
else
{
if(isalpha(in[i]) || (in[i] == '`')) // numbers, #, or any other crap just gets skipped
out[j++] = in[i];
}
}
out[j] = 0; // terimnate the string before returning it
return out;
}
void RemoveApostrophes(std::string &s)
{
for(unsigned int i = 0; i < s.length(); ++i)
if(s[i] == '\'')
s[i] = '_';
}
char *RemoveApostrophes(const char *s)
{
char *NewString = new char[strlen(s) + 1];
strcpy(NewString, s);
for(unsigned int i = 0 ; i < strlen(NewString); ++i)
if(NewString[i] == '\'')
NewString[i] = '_';
return NewString;
}
const char *ConvertArray(int input, char *returnchar)
{
sprintf(returnchar, "%i" ,input);
return returnchar;
}
const char *ConvertArrayF(float input, char *returnchar)
{
sprintf(returnchar, "%0.2f", input);
return returnchar;
}
+61
View File
@@ -0,0 +1,61 @@
/*
* Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _STRINGUTIL_H_
#define _STRINGUTIL_H_
#include <string>
#include <cstdarg>
#include "types.h"
void vStringFormat(std::string& output, const char* format, va_list args);
void StringFormat(std::string& output, const char* format, ...);
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i : source - allocated null-terminated string
// return: pointer to static buffer with the target string
const char *MakeUpperString(const char *source);
const char *MakeLowerString(const char *source);
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i : source - allocated null-terminated string
// io: target - allocated buffer, at least of size strlen(source)+1
void MakeUpperString(const char *source, char *target);
void MakeLowerString(const char *source, char *target);
int MakeAnyLenString(char** ret, const char* format, ...);
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...);
uint32 hextoi(char* num);
uint64 hextoi64(char* num);
bool atobool(char* iBool);
char* strn0cpy(char* dest, const char* source, uint32 size);
// return value =true if entire string(source) fit, false if it was truncated
bool strn0cpyt(char* dest, const char* source, uint32 size);
char *CleanMobName(const char *in, char *out);
const char *ConvertArray(int input, char *returnchar);
const char *ConvertArrayF(float input, char *returnchar);
void RemoveApostrophes(std::string &s);
char *RemoveApostrophes(const char *s);
#endif
+2 -2
View File
@@ -57,14 +57,14 @@ void StructStrategy::PassDecoder(EQApplicationPacket *p) {
//effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory {
static map<EmuOpcode, const StructStrategy *> strategies;
static std::map<EmuOpcode, const StructStrategy *> strategies;
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
strategies[first_opcode] = structs;
}
const StructStrategy *FindPatch(EmuOpcode first_opcode) {
map<EmuOpcode, const StructStrategy *>::const_iterator res;
std::map<EmuOpcode, const StructStrategy *>::const_iterator res;
res = strategies.find(first_opcode);
if(res == strategies.end())
return(nullptr);
+19 -21
View File
@@ -18,11 +18,9 @@
#include "../common/debug.h"
#include <iostream>
using namespace std;
#include <string.h>
#include <stdio.h>
#include <iomanip>
using namespace std;
#include "TCPConnection.h"
#include "../common/servertalk.h"
@@ -63,7 +61,7 @@ TCPConnection::TCPConnection()
pAsyncConnect = false;
m_previousLineEnd = false;
#if TCPN_DEBUG_Memory >= 7
cout << "Constructor #2 on outgoing TCP# " << GetID() << endl;
std::cout << "Constructor #2 on outgoing TCP# " << GetID() << std::endl;
#endif
}
@@ -85,7 +83,7 @@ TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 ir
pAsyncConnect = false;
m_previousLineEnd = false;
#if TCPN_DEBUG_Memory >= 7
cout << "Constructor #2 on incoming TCP# " << GetID() << endl;
std::cout << "Constructor #2 on incoming TCP# " << GetID() << std::endl;
#endif
}
@@ -99,12 +97,12 @@ TCPConnection::~TCPConnection() {
MLoopRunning.lock();
MLoopRunning.unlock();
#if TCPN_DEBUG_Memory >= 6
cout << "Deconstructor on outgoing TCP# " << GetID() << endl;
std::cout << "Deconstructor on outgoing TCP# " << GetID() << std::endl;
#endif
}
#if TCPN_DEBUG_Memory >= 5
else {
cout << "Deconstructor on incomming TCP# " << GetID() << endl;
std::cout << "Deconstructor on incomming TCP# " << GetID() << std::endl;
}
#endif
safe_delete_array(recvbuf);
@@ -587,7 +585,7 @@ bool TCPConnection::Process() {
if (!SendData(sent_something, errbuf)) {
struct in_addr in;
in.s_addr = GetrIP();
cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
std::cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << std::endl;
return false;
}
@@ -628,8 +626,8 @@ bool TCPConnection::RecvData(char* errbuf) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort();
cout << endl;
std::cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort();
std::cout << std::endl;
#if TCPN_LOG_RAW_DATA_IN == 2
int32 tmp = status;
if (tmp > 32)
@@ -683,7 +681,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
return true;
#if TCPN_DEBUG_Console >= 4
if (recvbuf_used) {
cout << "Starting Processing: recvbuf=" << recvbuf_used << endl;
std::cout << "Starting Processing: recvbuf=" << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used);
}
#endif
@@ -715,13 +713,13 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
}
}
#if TCPN_DEBUG_Console >= 5
cout << "Removed 0x00" << endl;
std::cout << "Removed 0x00" << std::endl;
if (recvbuf_used) {
cout << "recvbuf left: " << recvbuf_used << endl;
std::cout << "recvbuf left: " << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used);
}
else
cout << "recbuf left: None" << endl;
std::cout << "recbuf left: None" << std::endl;
#endif
m_previousLineEnd = false;
break;
@@ -748,7 +746,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
memset(line, 0, i+1);
memcpy(line, recvbuf, i);
#if TCPN_DEBUG_Console >= 3
cout << "Line Out: " << endl;
std::cout << "Line Out: " << std::endl;
DumpPacket((uchar*) line, i);
#endif
//line[i] = 0;
@@ -758,13 +756,13 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
recvbuf_echo -= i+1;
memcpy(recvbuf, &tmpdel[i+1], recvbuf_used);
#if TCPN_DEBUG_Console >= 5
cout << "i+1=" << i+1 << endl;
std::cout << "i+1=" << i+1 << std::endl;
if (recvbuf_used) {
cout << "recvbuf left: " << recvbuf_used << endl;
std::cout << "recvbuf left: " << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used);
}
else
cout << "recbuf left: None" << endl;
std::cout << "recbuf left: None" << std::endl;
#endif
safe_delete_array(tmpdel);
i = -1;
@@ -829,8 +827,8 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort();
cout << endl;
std::cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort();
std::cout << std::endl;
#if TCPN_LOG_RAW_DATA_OUT == 2
int32 tmp = status;
if (tmp > 32)
@@ -846,8 +844,8 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort();
cout << endl;
std::cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort();
std::cout << std::endl;
#endif
// If there's network congestion, the number of bytes sent can be less than
// what we tried to give it... Push the extra back on the queue for later
-3
View File
@@ -24,9 +24,6 @@
#ifdef _WINDOWS
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
+1 -1
View File
@@ -23,7 +23,7 @@ XMLParser::XMLParser() {
}
bool XMLParser::ParseFile(const char *file, const char *root_ele) {
map<string,ElementHandler>::iterator handler;
std::map<std::string,ElementHandler>::iterator handler;
TiXmlDocument doc( file );
if(!doc.LoadFile()) {
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());
+1 -5
View File
@@ -24,9 +24,6 @@
#include <string>
#include <map>
using namespace std;
/*
* See note in XMLParser::ParseFile() before inheriting this class.
@@ -45,12 +42,11 @@ protected:
const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false);
const char *GetText(TiXmlNode *within, bool optional = false);
map<string,ElementHandler> Handlers;
std::map<std::string,ElementHandler> Handlers;
bool ParseOkay;
};
#endif
+53 -57
View File
@@ -18,7 +18,6 @@
#include "../common/debug.h"
#include "../common/rulesys.h"
#include <iostream>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -44,7 +43,8 @@ using namespace std;
#include "database.h"
#include "eq_packet_structs.h"
#include "guilds.h"
#include "MiscFunctions.h"
//#include "MiscFunctions.h"
#include "StringUtil.h"
#include "extprofile.h"
extern Client client;
@@ -193,7 +193,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, int16* oStat
}
else
{
cerr << "Error in CheckLogin query '" << query << "' " << errbuf << endl;
std::cerr << "Error in CheckLogin query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -227,7 +227,7 @@ bool Database::CheckBannedIPs(const char* loginIP)
}
else
{
cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << endl;
std::cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return true;
}
@@ -240,7 +240,7 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes)
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes), errbuf)) {
cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl;
std::cerr << "Error in ReserveName query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -290,7 +290,7 @@ void Database::LoginIP(uint32 AccountID, const char* LoginIP)
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP), errbuf)) {
cerr << "Error in Log IP query '" << query << "' " << errbuf << endl;
std::cerr << "Error in Log IP query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
}
@@ -333,7 +333,7 @@ int16 Database::CheckStatus(uint32 account_id)
}
else
{
cerr << "Error in CheckStatus query '" << query << "' " << errbuf << endl;
std::cerr << "Error in CheckStatus query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -352,16 +352,16 @@ uint32 Database::CreateAccount(const char* name, const char* password, int16 sta
else
querylen = MakeAnyLenString(&query, "INSERT INTO account SET name='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name, status, lsaccount_id);
cerr << "Account Attempting to be created:" << name << " " << (int16) status << endl;
std::cerr << "Account Attempting to be created:" << name << " " << (int16) status << std::endl;
if (!RunQuery(query, querylen, errbuf, 0, 0, &last_insert_id)) {
cerr << "Error in CreateAccount query '" << query << "' " << errbuf << endl;
std::cerr << "Error in CreateAccount query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return 0;
}
safe_delete_array(query);
if (last_insert_id == 0) {
cerr << "Error in CreateAccount query '" << query << "' " << errbuf << endl;
std::cerr << "Error in CreateAccount query '" << query << "' " << errbuf << std::endl;
return 0;
}
@@ -373,7 +373,7 @@ bool Database::DeleteAccount(const char* name) {
char *query = 0;
uint32 affected_rows = 0;
cerr << "Account Attempting to be deleted:" << name << endl;
std::cerr << "Account Attempting to be deleted:" << name << std::endl;
if (RunQuery(query, MakeAnyLenString(&query, "DELETE FROM account WHERE name='%s';",name), errbuf, 0, &affected_rows)) {
safe_delete_array(query);
if (affected_rows == 1) {
@@ -382,7 +382,7 @@ bool Database::DeleteAccount(const char* name) {
}
else {
cerr << "Error in DeleteAccount query '" << query << "' " << errbuf << endl;
std::cerr << "Error in DeleteAccount query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
@@ -394,7 +394,7 @@ bool Database::SetLocalPassword(uint32 accid, const char* password) {
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET password=MD5('%s') where id=%i;", password, accid), errbuf)) {
cerr << "Error in SetLocalPassword query '" << query << "' " << errbuf << endl;
std::cerr << "Error in SetLocalPassword query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -408,7 +408,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
char *query = 0;
uint32 affected_rows = 0;
cout << "Account being GM Flagged:" << name << ", Level: " << (int16) status << endl;
std::cout << "Account being GM Flagged:" << name << ", Level: " << (int16) status << std::endl;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET status=%i WHERE name='%s';", status, name), errbuf, 0, &affected_rows)) {
safe_delete_array(query);
return false;
@@ -416,7 +416,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
safe_delete_array(query);
if (affected_rows == 0) {
cout << "Account: " << name << " does not exist, therefore it cannot be flagged\n";
std::cout << "Account: " << name << " does not exist, therefore it cannot be flagged\n";
return false;
}
@@ -429,7 +429,7 @@ bool Database::ReserveName(uint32 account_id, char* name)
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=NULL", account_id, name), errbuf)) {
cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl;
std::cerr << "Error in ReserveName query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -877,7 +877,7 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
mysql_free_result(result);
}
else {
cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
@@ -940,7 +940,7 @@ uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32*
mysql_free_result(result);
}
else {
cerr << "Error in GetAccountIDByAcc query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetAccountIDByAcc query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
@@ -968,7 +968,7 @@ void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID
}
else {
safe_delete_array(query);
cerr << "Error in GetAccountName query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetAccountName query '" << query << "' " << errbuf << std::endl;
}
}
@@ -990,7 +990,7 @@ void Database::GetCharName(uint32 char_id, char* name) {
}
else {
safe_delete_array(query);
cerr << "Error in GetCharName query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetCharName query '" << query << "' " << errbuf << std::endl;
}
}
@@ -1007,7 +1007,7 @@ bool Database::LoadVariables() {
return ret;
}
else {
cerr << "Error in LoadVariables query '" << query << "' " << errbuf << endl;
std::cerr << "Error in LoadVariables query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
return false;
@@ -1130,7 +1130,7 @@ bool Database::SetVariable(const char* varname_in, const char* varvalue_in) {
}
}
else {
cerr << "Error in SetVariable query '" << query << "' " << errbuf << endl;
std::cerr << "Error in SetVariable query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
free(varname);
@@ -1152,7 +1152,7 @@ uint32 Database::GetMiniLoginAccount(char* ip){
}
else
{
cerr << "Error in GetMiniLoginAccount query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetMiniLoginAccount query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
return retid;
@@ -1194,11 +1194,11 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe
}
else
{
cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << endl;
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_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n";
cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n";
std::cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << std::endl;
std::cerr << "If it errors, run the following querys:\n";
std::cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n";
std::cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n";
std::cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n";
safe_delete_array(query);
}
@@ -1243,7 +1243,7 @@ bool Database::GetZoneLongName(const char* short_name, char** long_name, char* f
}
else
{
cerr << "Error in GetZoneLongName query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetZoneLongName query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -1269,7 +1269,7 @@ uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) {
}
else
{
cerr << "Error in GetZoneGraveyardID query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetZoneGraveyardID query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
return GraveyardID;
@@ -1303,7 +1303,7 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon
}
else
{
cerr << "Error in GetZoneGraveyard query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetZoneGraveyard query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -1342,7 +1342,7 @@ bool Database::LoadZoneNames() {
mysql_free_result(result);
}
else {
cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << endl;
std::cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -1352,7 +1352,7 @@ bool Database::LoadZoneNames() {
}
}
else {
cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << endl;
std::cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -1419,7 +1419,7 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
}
else
{
cerr << "Error in GetPEQZone query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetPEQZone query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
return peqzone;
@@ -1503,7 +1503,7 @@ bool Database::CheckNameFilter(const char* name, bool surname)
}
else
{
cerr << "Error in CheckNameFilter query '" << query << "' " << errbuf << endl;
std::cerr << "Error in CheckNameFilter query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
@@ -1516,7 +1516,7 @@ bool Database::AddToNameFilter(const char* name) {
uint32 affected_rows = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO name_filter (name) values ('%s')", name), errbuf, 0, &affected_rows)) {
cerr << "Error in AddToNameFilter query '" << query << "' " << errbuf << endl;
std::cerr << "Error in AddToNameFilter query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -1557,7 +1557,7 @@ uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* o
mysql_free_result(result);
}
else {
cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return 0;
}
@@ -1583,7 +1583,7 @@ void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
mysql_free_result(result);
}
else
cerr << "Error in GetAccountFromID query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetAccountFromID query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
@@ -1592,7 +1592,7 @@ void Database::ClearMerchantTemp(){
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "delete from merchantlist_temp"), errbuf)) {
cerr << "Error in ClearMerchantTemp query '" << query << "' " << errbuf << endl;
std::cerr << "Error in ClearMerchantTemp query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
}
@@ -1602,7 +1602,7 @@ bool Database::UpdateName(const char* oldname, const char* newname) {
char *query = 0;
uint32 affected_rows = 0;
cout << "Renaming " << oldname << " to " << newname << "..." << endl;
std::cout << "Renaming " << oldname << " to " << newname << "..." << std::endl;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET name='%s' WHERE name='%s';", newname, oldname), errbuf, 0, &affected_rows)) {
safe_delete_array(query);
return false;
@@ -1626,7 +1626,7 @@ bool Database::CheckUsedName(const char* name)
//if (strlen(name) > 15)
// return false;
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM character_ where name='%s'", name), errbuf, &result)) {
cerr << "Error in CheckUsedName query '" << query << "' " << errbuf << endl;
std::cerr << "Error in CheckUsedName query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -1664,15 +1664,11 @@ uint8 Database::GetServerType()
mysql_free_result(result);
}
else
{
cerr << "Error in GetServerType query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetServerType query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
return 0;
}
@@ -1686,7 +1682,7 @@ bool Database::MoveCharacterToZone(const char* charname, const char* zonename,ui
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)) {
cerr << "Error in MoveCharacterToZone(name) query '" << query << "' " << errbuf << endl;
std::cerr << "Error in MoveCharacterToZone(name) query '" << query << "' " << errbuf << std::endl;
return false;
}
safe_delete_array(query);
@@ -1706,7 +1702,7 @@ bool Database::MoveCharacterToZone(uint32 iCharID, const char* iZonename) {
char *query = 0;
uint32 affected_rows = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s', zoneid=%i, x=-1, y=-1, z=-1 WHERE id=%i", iZonename, GetZoneID(iZonename), iCharID), errbuf, 0,&affected_rows)) {
cerr << "Error in MoveCharacterToZone(id) query '" << query << "' " << errbuf << endl;
std::cerr << "Error in MoveCharacterToZone(id) query '" << query << "' " << errbuf << std::endl;
return false;
}
safe_delete_array(query);
@@ -1739,7 +1735,7 @@ uint8 Database::CopyCharacter(const char* oldname, const char* newname, uint32 a
}
else {
cerr << "Error in CopyCharacter read query '" << query << "' " << errbuf << endl;
std::cerr << "Error in CopyCharacter read query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return 0;
}
@@ -1755,7 +1751,7 @@ uint8 Database::CopyCharacter(const char* oldname, const char* newname, uint32 a
end += sprintf(end, "\', account_id=%d, name='%s'", acctid, newname);
if (!RunQuery(query2, (uint32) (end - query2), errbuf, 0, &affected_rows)) {
cerr << "Error in CopyCharacter query '" << query << "' " << errbuf << endl;
std::cerr << "Error in CopyCharacter query '" << query << "' " << errbuf << std::endl;
return 0;
}
@@ -1772,7 +1768,7 @@ bool Database::SetHackerFlag(const char* accountname, const char* charactername,
char *query = 0;
uint32 affected_rows = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO hackers(account,name,hacked) values('%s','%s','%s')", accountname, charactername, hacked), errbuf, 0,&affected_rows)) {
cerr << "Error in SetHackerFlag query '" << query << "' " << errbuf << endl;
std::cerr << "Error in SetHackerFlag query '" << query << "' " << errbuf << std::endl;
return false;
}
safe_delete_array(query);
@@ -1792,7 +1788,7 @@ bool Database::SetMQDetectionFlag(const char* accountname, const char* character
uint32 affected_rows = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO hackers(account,name,hacked,zone) values('%s','%s','%s','%s')", accountname, charactername, hacked, zone), errbuf, 0,&affected_rows)) {
cerr << "Error in SetMQDetectionFlag query '" << query << "' " << errbuf << endl;
std::cerr << "Error in SetMQDetectionFlag query '" << query << "' " << errbuf << std::endl;
return false;
}
@@ -1911,7 +1907,7 @@ uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZo
mysql_free_result(result);
}
else {
cerr << "Error in GetCharacterInfo query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetCharacterInfo query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
return 0;
@@ -1921,7 +1917,7 @@ bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id), errbuf)) {
cerr << "Error in UpdateLiveChar query '" << query << "' " << errbuf << endl;
std::cerr << "Error in UpdateLiveChar query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -1946,7 +1942,7 @@ bool Database::GetLiveChar(uint32 account_id, char* cname) {
mysql_free_result(result);
}
else {
cerr << "Error in GetLiveChar query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetLiveChar query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
@@ -2171,7 +2167,7 @@ void Database::ClearGroupLeader(uint32 gid){
safe_delete_array(query);
}
bool FetchRowMap(MYSQL_RES *result, map<string,string> &rowmap)
bool FetchRowMap(MYSQL_RES *result, std::map<std::string,std::string> &rowmap)
{
MYSQL_FIELD *fields;
MYSQL_ROW row;
@@ -3175,7 +3171,7 @@ uint32 Database::GetGuildDBIDByCharID(uint32 char_id) {
mysql_free_result(result);
}
else {
cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
return retVal;
+1 -2
View File
@@ -35,7 +35,6 @@
#include <string>
#include <vector>
#include <map>
using namespace std;
//atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10)
@@ -265,5 +264,5 @@ private:
uint32 varcache_lastupdate;
};
bool FetchRowMap(MYSQL_RES *result, map<string,string> &rowmap);
bool FetchRowMap(MYSQL_RES *result, std::map<std::string,std::string> &rowmap);
#endif
+14 -14
View File
@@ -5,7 +5,6 @@
#include <winsock2.h>
#endif
#include <iostream>
using namespace std;
#include "dbasync.h"
#include "database.h"
#include <errmsg.h>
@@ -14,7 +13,8 @@ using namespace std;
#include "dbcore.h"
#include "common_profile.h"
#include <string.h>
#include "../common/MiscFunctions.h"
//#include "../common/MiscFunctions.h"
#include "StringUtil.h"
#define ASYNC_LOOP_GRANULARITY 4 //# of ms between checking our work
bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) {
@@ -24,7 +24,7 @@ bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) {
if (dbaq->GetAnswer(errbuf, &result))
iWork->GetDB()->LoadVariables_result(result);
else
cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << endl;
std::cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << std::endl;
return true;
}
@@ -115,8 +115,8 @@ uint32 DBAsync::AddWork(DBAsyncWork** iWork, uint32 iDelay) {
if (iDelay)
(*iWork)->pExecuteAfter = Timer::GetCurrentTime() + iDelay;
#if DEBUG_MYSQL_QUERIES >= 2
cout << "Adding AsyncWork #" << (*iWork)->GetWorkID() << endl;
cout << "ExecuteAfter = " << (*iWork)->pExecuteAfter << " (" << Timer::GetCurrentTime() << " + " << iDelay << ")" << endl;
std::cout << "Adding AsyncWork #" << (*iWork)->GetWorkID() << std::endl;
std::cout << "ExecuteAfter = " << (*iWork)->pExecuteAfter << " (" << Timer::GetCurrentTime() << " + " << iDelay << ")" << std::endl;
#endif
*iWork = 0;
MInList.unlock();
@@ -131,7 +131,7 @@ bool DBAsync::CancelWork(uint32 iWorkID) {
if (iWorkID == 0)
return false;
#if DEBUG_MYSQL_QUERIES >= 2
cout << "DBAsync::CancelWork: " << iWorkID << endl;
std::cout << "DBAsync::CancelWork: " << iWorkID << std::endl;
#endif
MCurrentWork.lock();
if (CurrentWork && CurrentWork->GetWorkID() == iWorkID) {
@@ -174,8 +174,8 @@ DBAsyncWork* DBAsync::InListPop() {
if (iterator.GetData()->pExecuteAfter <= Timer::GetCurrentTime()) {
ret = iterator.GetData();
#if DEBUG_MYSQL_QUERIES >= 2
cout << "Poping AsyncWork #" << ret->GetWorkID() << endl;
cout << ret->pExecuteAfter << " <= " << Timer::GetCurrentTime() << endl;
std::cout << "Poping AsyncWork #" << ret->GetWorkID() << std::endl;
std::cout << ret->pExecuteAfter << " <= " << Timer::GetCurrentTime() << std::endl;
#endif
iterator.RemoveCurrent(false);
break;
@@ -232,7 +232,7 @@ void DBAsync::Process() {
tmpStatus = tmpWork->SetStatus(DBAsync::Finished);
if (tmpStatus != Executing) {
if (tmpStatus != Canceled) {
cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #1" << endl;
std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #1" << std::endl;
}
MCurrentWork.lock();
safe_delete(tmpWork);
@@ -246,7 +246,7 @@ void DBAsync::Process() {
}
else {
if (tmpStatus != Canceled) {
cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #2" << endl;
std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #2" << std::endl;
}
MCurrentWork.lock();
safe_delete(CurrentWork);
@@ -274,7 +274,7 @@ void DBAsync::CheckTimeout() {
void DBAsync::CommitWrites() {
#if DEBUG_MYSQL_QUERIES >= 2
cout << "DBAsync::CommitWrites() called." << endl;
std::cout << "DBAsync::CommitWrites() called." << std::endl;
#endif
DBAsyncWork* tmpWork;
while ((tmpWork = InListPopWrite())) {
@@ -284,7 +284,7 @@ void DBAsync::CommitWrites() {
tmpStatus = tmpWork->SetStatus(DBAsync::Finished);
if (tmpStatus != Executing) {
if (tmpStatus != Canceled) {
cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #1" << endl;
std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #1" << std::endl;
}
safe_delete(tmpWork);
}
@@ -294,7 +294,7 @@ void DBAsync::CommitWrites() {
}
else {
if (tmpStatus != Canceled) {
cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #2" << endl;
std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #2" << std::endl;
}
safe_delete(tmpWork);
}
@@ -305,7 +305,7 @@ void DBAsync::ProcessWork(DBAsyncWork* iWork, bool iSleep) {
_CP(DBAsync_ProcessWork);
DBAsyncQuery* CurrentQuery;
#if DEBUG_MYSQL_QUERIES >= 2
cout << "Processing AsyncWork #" << iWork->GetWorkID() << endl;
std::cout << "Processing AsyncWork #" << iWork->GetWorkID() << std::endl;
#endif
while ((CurrentQuery = iWork->PopQuery())) {
CurrentQuery->Process(pDBC);
+11 -12
View File
@@ -5,7 +5,6 @@
#endif
#include <iostream>
using namespace std;
#include <errmsg.h>
#include <mysqld_error.h>
#include <limits.h>
@@ -72,17 +71,17 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
#if DEBUG_MYSQL_QUERIES >= 1
char tmp[120];
strn0cpy(tmp, query, sizeof(tmp));
cout << "QUERY: " << tmp << endl;
std::cout << "QUERY: " << tmp << std::endl;
#endif
if (mysql_real_query(&mysql, query, querylen)) {
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
pStatus = Error;
if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
if (retry) {
cout << "Database Error: Lost connection, attempting to recover...." << endl;
std::cout << "Database Error: Lost connection, attempting to recover...." << std::endl;
ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
if (ret)
cout << "Reconnection to database successful." << endl;
std::cout << "Reconnection to database successful." << std::endl;
}
else {
pStatus = Error;
@@ -90,7 +89,7 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
*errnum = mysql_errno(&mysql);
if (errbuf)
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << endl;
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
ret = false;
}
}
@@ -100,7 +99,7 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
if (errbuf)
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
#ifdef _EQDEBUG
cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << endl;
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
#endif
ret = false;
}
@@ -124,7 +123,7 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
}
else {
#ifdef _EQDEBUG
cout << "DB Query Error: No Result" << endl;
std::cout << "DB Query Error: No Result" << std::endl;
#endif
if (errnum)
*errnum = UINT_MAX;
@@ -139,15 +138,15 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
}
#if DEBUG_MYSQL_QUERIES >= 1
if (ret) {
cout << "query successful";
std::cout << "query successful";
if (result && (*result))
cout << ", " << (int) mysql_num_rows(*result) << " rows returned";
std::cout << ", " << (int) mysql_num_rows(*result) << " rows returned";
if (affected_rows)
cout << ", " << (*affected_rows) << " rows affected";
cout<< endl;
std::cout << ", " << (*affected_rows) << " rows affected";
std::cout<< std::endl;
}
else {
cout << "QUERY: query FAILED" << endl;
std::cout << "QUERY: query FAILED" << std::endl;
}
#endif
return ret;
+39 -28
View File
@@ -1,25 +1,27 @@
#include "debug.h"
#include <iostream>
using namespace std;
#include <string>
#include <cstdarg>
#include <time.h>
#include <string.h>
#ifdef _WINDOWS
#include <process.h>
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
#include <sys/types.h>
#include <unistd.h>
#include <stdarg.h>
#endif
#include "../common/MiscFunctions.h"
#include "../common/platform.h"
#include "debug.h"
#include "StringUtil.h"
#include "MiscFunctions.h"
#include "platform.h"
#ifndef va_copy
#define va_copy(d,s) ((d) = (s))
@@ -112,7 +114,7 @@ bool EQEMuLog::open(LogIDs id) {
#endif
fp[id] = fopen(filename, "a");
if (!fp[id]) {
cerr << "Failed to open log file: " << filename << endl;
std::cerr << "Failed to open log file: " << filename << std::endl;
pLogStatus[id] |= 4; // set file state to error
return false;
}
@@ -328,7 +330,7 @@ bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
if (!logFileValid) {
#if EQDEBUG >= 10
cerr << "Error: Dump() from null pointer"<<endl;
std::cerr << "Error: Dump() from null pointer" << std::endl;
#endif
return false;
}
@@ -350,36 +352,45 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
write(id, "Dumping Packet: %i", size);
// Output as HEX
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
uint32 i;
for(i=skip; i<size; i++) {
if ((i-skip)%cols==0) {
if (i != skip)
writeNTS(id, dofile, " | %s\n", ascii);
writeNTS(id, dofile, "%4i: ", i-skip);
memset(ascii, 0, cols+1);
j = 0;
int beginningOfLineOffset = 0;
uint32 indexInData;
std::string asciiOutput;
for(indexInData=skip; indexInData<size; indexInData++) {
if ((indexInData-skip)%cols==0) {
if (indexInData != skip)
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
writeNTS(id, dofile, "%4i: ", indexInData-skip);
asciiOutput.clear();
beginningOfLineOffset = 0;
}
else if ((i-skip)%(cols/2) == 0) {
else if ((indexInData-skip)%(cols/2) == 0) {
writeNTS(id, dofile, "- ");
}
writeNTS(id, dofile, "%02X ", (unsigned char)data[i]);
writeNTS(id, dofile, "%02X ", (unsigned char)data[indexInData]);
if (data[i] >= 32 && data[i] < 127)
ascii[j++] = data[i];
if (data[indexInData] >= 32 && data[indexInData] < 127)
{
// According to http://msdn.microsoft.com/en-us/library/vstudio/ee404875(v=vs.100).aspx
// Visual Studio 2010 doesn't have std::to_string(int) but it does have the long long
// version.
asciiOutput.append(std::to_string((long long)data[indexInData]));
}
else
ascii[j++] = '.';
{
asciiOutput.append(".");
}
}
uint32 k = ((i-skip)-1)%cols;
uint32 k = ((indexInData-skip)-1)%cols;
if (k < 8)
writeNTS(id, dofile, " ");
for (uint32 h = k+1; h < cols; h++) {
writeNTS(id, dofile, " ");
}
writeNTS(id, dofile, " | %s\n", ascii);
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
if (dofile)
fflush(fp[id]);
safe_delete_array(ascii);
return true;
}
+10 -11
View File
@@ -22,7 +22,6 @@
#include "../common/eq_packet_structs.h"
#include <memory.h>
#include <iostream>
using namespace std;
/*#ifdef _CRTDBG_MAP_ALLOC
#undef new
#endif*/
@@ -137,7 +136,7 @@ int EQTime::setEQTimeOfDay(TimeOfDay_Struct start_eq, time_t start_real)
//For some reason, ifstream/ofstream have problems with EQEmu datatypes in files.
bool EQTime::saveFile(const char *filename)
{
ofstream of;
std::ofstream of;
of.open(filename);
if(!of)
{
@@ -146,13 +145,13 @@ bool EQTime::saveFile(const char *filename)
}
//Enable for debugging
//cout << "SAVE: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << endl;
of << EQT_VERSION << endl;
of << (long)eqTime.start_eqtime.day << endl;
of << (long)eqTime.start_eqtime.hour << endl;
of << (long)eqTime.start_eqtime.minute << endl;
of << (long)eqTime.start_eqtime.month << endl;
of << eqTime.start_eqtime.year << endl;
of << eqTime.start_realtime << endl;
of << EQT_VERSION << std::endl;
of << (long)eqTime.start_eqtime.day << std::endl;
of << (long)eqTime.start_eqtime.hour << std::endl;
of << (long)eqTime.start_eqtime.minute << std::endl;
of << (long)eqTime.start_eqtime.month << std::endl;
of << eqTime.start_eqtime.year << std::endl;
of << eqTime.start_realtime << std::endl;
of.close();
return true;
}
@@ -161,7 +160,7 @@ bool EQTime::loadFile(const char *filename)
{
int version=0;
long in_data=0;
ifstream in;
std::ifstream in;
in.open(filename);
if(!in)
{
@@ -265,7 +264,7 @@ void EQTime::AddMinutes(uint32 minutes, TimeOfDay_Struct *to) {
to->year += (cur-1) / 12;
}
void EQTime::ToString(TimeOfDay_Struct *t, string &str) {
void EQTime::ToString(TimeOfDay_Struct *t, std::string &str) {
char buf[128];
snprintf(buf, 128, "%.2d/%.2d/%.4d %.2d:%.2d",
t->month, t->day, t->year, t->hour, t->minute);
+1 -3
View File
@@ -4,8 +4,6 @@
#include "../common/eq_packet_structs.h"
#include <string>
using namespace std;
//Struct
struct eqTimeOfDay
{
@@ -39,7 +37,7 @@ public:
static bool IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test); //is test before base
static void AddMinutes(uint32 minutes, TimeOfDay_Struct *to);
static void ToString(TimeOfDay_Struct *t, string &str);
static void ToString(TimeOfDay_Struct *t, std::string &str);
//Database functions
//bool loadDB(Database q);
+29 -28
View File
@@ -20,7 +20,8 @@
#include "guild_base.h"
#include "database.h"
#include "logsys.h"
#include "MiscFunctions.h"
//#include "MiscFunctions.h"
#include "StringUtil.h"
#include <cstdlib>
#include <cstring>
@@ -52,7 +53,7 @@ bool BaseGuildManager::LoadGuilds() {
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
map<uint32, GuildInfo *>::iterator res;
std::map<uint32, GuildInfo *>::iterator res;
// load up all the guilds
if (!m_db->RunQuery(query, MakeAnyLenString(&query,
@@ -116,7 +117,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
map<uint32, GuildInfo *>::iterator res;
std::map<uint32, GuildInfo *>::iterator res;
GuildInfo *info;
// load up all the guilds
@@ -173,7 +174,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
BaseGuildManager::GuildInfo *BaseGuildManager::_CreateGuild(uint32 guild_id, const char *guild_name, uint32 leader_char_id, uint8 minstatus, const char *guild_motd, const char *motd_setter, const char *Channel, const char *URL)
{
map<uint32, GuildInfo *>::iterator res;
std::map<uint32, GuildInfo *>::iterator res;
//remove any old entry.
res = m_guilds.find(guild_id);
@@ -222,7 +223,7 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
return(false);
}
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end()) {
_log(GUILDS__DB, "Requested to store non-existent guild %d", guild_id);
@@ -376,7 +377,7 @@ bool BaseGuildManager::RenameGuild(uint32 guild_id, const char* name) {
bool BaseGuildManager::SetGuildLeader(uint32 guild_id, uint32 leader_char_id) {
//get old leader first.
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return(false);
@@ -516,7 +517,7 @@ uint32 BaseGuildManager::DBCreateGuild(const char* name, uint32 leader) {
bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) {
//remove the local entry
map<uint32, GuildInfo *>::iterator res;
std::map<uint32, GuildInfo *>::iterator res;
res = m_guilds.find(guild_id);
if(res != m_guilds.end()) {
delete res->second;
@@ -557,7 +558,7 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
return(false);
}
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return(false);
@@ -597,7 +598,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
return(false);
}
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return(false);
@@ -637,7 +638,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
return(false);
}
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return(false);
@@ -682,7 +683,7 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
if(m_db == nullptr)
return(false);
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(GuildID);
@@ -723,7 +724,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
if(m_db == nullptr)
return(false);
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(GuildID);
@@ -978,7 +979,7 @@ static void ProcessGuildMember(MYSQL_ROW &row, CharGuildInfo &into) {
}
bool BaseGuildManager::GetEntireGuild(uint32 guild_id, vector<CharGuildInfo *> &members) {
bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo *> &members) {
members.clear();
if(m_db == nullptr)
@@ -1109,7 +1110,7 @@ uint8 *BaseGuildManager::MakeGuildList(const char *head_name, uint32 &length) co
strn0cpy((char *) buffer, head_name, 64);
map<uint32, GuildInfo *>::const_iterator cur, end;
std::map<uint32, GuildInfo *>::const_iterator cur, end;
cur = m_guilds.begin();
end = m_guilds.end();
for(; cur != end; cur++) {
@@ -1122,7 +1123,7 @@ uint8 *BaseGuildManager::MakeGuildList(const char *head_name, uint32 &length) co
const char *BaseGuildManager::GetRankName(uint32 guild_id, uint8 rank) const {
if(rank > GUILD_MAX_RANK)
return("Invalid Rank");
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return("Invalid Guild Rank");
@@ -1132,7 +1133,7 @@ const char *BaseGuildManager::GetRankName(uint32 guild_id, uint8 rank) const {
const char *BaseGuildManager::GetGuildName(uint32 guild_id) const {
if(guild_id == GUILD_NONE)
return("");
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return("Invalid Guild");
@@ -1140,7 +1141,7 @@ const char *BaseGuildManager::GetGuildName(uint32 guild_id) const {
}
bool BaseGuildManager::GetGuildNameByID(uint32 guild_id, std::string &into) const {
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return(false);
@@ -1150,7 +1151,7 @@ bool BaseGuildManager::GetGuildNameByID(uint32 guild_id, std::string &into) cons
uint32 BaseGuildManager::GetGuildIDByName(const char *GuildName)
{
map<uint32, GuildInfo *>::iterator Iterator;
std::map<uint32, GuildInfo *>::iterator Iterator;
for(Iterator = m_guilds.begin(); Iterator != m_guilds.end(); ++Iterator)
{
@@ -1162,7 +1163,7 @@ uint32 BaseGuildManager::GetGuildIDByName(const char *GuildName)
}
bool BaseGuildManager::GetGuildMOTD(uint32 guild_id, char *motd_buffer, char *setter_buffer) const {
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return(false);
@@ -1173,7 +1174,7 @@ bool BaseGuildManager::GetGuildMOTD(uint32 guild_id, char *motd_buffer, char *se
bool BaseGuildManager::GetGuildURL(uint32 GuildID, char *URLBuffer) const
{
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(GuildID);
if(res == m_guilds.end())
return(false);
@@ -1184,7 +1185,7 @@ bool BaseGuildManager::GetGuildURL(uint32 GuildID, char *URLBuffer) const
bool BaseGuildManager::GetGuildChannel(uint32 GuildID, char *ChannelBuffer) const
{
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(GuildID);
if(res == m_guilds.end())
return(false);
@@ -1203,7 +1204,7 @@ bool BaseGuildManager::IsGuildLeader(uint32 guild_id, uint32 char_id) const {
_log(GUILDS__PERMISSIONS, "Check leader for char %d: not a guild.", char_id);
return(false);
}
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end()) {
_log(GUILDS__PERMISSIONS, "Check leader for char %d: invalid guild.", char_id);
@@ -1214,7 +1215,7 @@ bool BaseGuildManager::IsGuildLeader(uint32 guild_id, uint32 char_id) const {
}
uint32 BaseGuildManager::FindGuildByLeader(uint32 leader) const {
map<uint32, GuildInfo *>::const_iterator cur, end;
std::map<uint32, GuildInfo *>::const_iterator cur, end;
cur = m_guilds.begin();
end = m_guilds.end();
for(; cur != end; cur++) {
@@ -1226,7 +1227,7 @@ uint32 BaseGuildManager::FindGuildByLeader(uint32 leader) const {
//returns the rank to be sent to the client for display purposes, given their eqemu rank.
uint8 BaseGuildManager::GetDisplayedRank(uint32 guild_id, uint8 rank, uint32 char_id) const {
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return(3); //invalid guild rank
@@ -1243,7 +1244,7 @@ bool BaseGuildManager::CheckGMStatus(uint32 guild_id, uint8 status) const {
return(true); //250+ as allowed anything
}
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end()) {
_log(GUILDS__PERMISSIONS, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status);
@@ -1264,7 +1265,7 @@ bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction
guild_id, rank, GuildActionNames[act], act);
return(false); //invalid rank
}
map<uint32, GuildInfo *>::const_iterator res;
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end()) {
_log(GUILDS__PERMISSIONS, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.",
@@ -1284,7 +1285,7 @@ bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction
}
bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) {
map<uint32, GuildInfo *>::iterator res;
std::map<uint32, GuildInfo *>::iterator res;
res = m_guilds.find(guild_id);
if(res == m_guilds.end())
return(false); //invalid guild
@@ -1293,7 +1294,7 @@ bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) {
}
void BaseGuildManager::ClearGuilds() {
map<uint32, GuildInfo *>::iterator cur, end;
std::map<uint32, GuildInfo *>::iterator cur, end;
cur = m_guilds.begin();
end = m_guilds.end();
for(; cur != end; cur++) {
+1 -1
View File
@@ -9,7 +9,7 @@
*/
#include <string.h> /* for memcpy() */
#include "../common/md5.h"
#include "../common/MiscFunctions.h"
#include "../common/StringUtil.h"
#include "../common/seperator.h"
MD5::MD5() {
+34 -36
View File
@@ -18,12 +18,10 @@
#include <cstdlib>
#include <cstring>
using namespace std;
#define ENC(c) (((c) & 0x3f) + ' ')
#define DEC(c) (((c) - ' ') & 0x3f)
map<int,string> DBFieldNames;
std::map<int,std::string> DBFieldNames;
#ifndef WIN32
#if defined(FREEBSD) || defined(__CYGWIN__)
@@ -44,9 +42,9 @@ int print_stacktrace()
if (names != nullptr)
{
int i;
cerr << "called from " << (char*)names[0] << endl;
std::cerr << "called from " << (char*)names[0] << std::endl;
for (i = 1; i < n; ++i)
cerr << " " << (char*)names[i] << endl;
std::cerr << " " << (char*)names[i] << std::endl;
free (names);
}
}
@@ -55,19 +53,19 @@ int print_stacktrace()
#endif //!FREEBSD
#endif //!WIN32
void Unprotect(string &s, char what)
void Unprotect(std::string &s, char what)
{
if (s.length()) {
for(string::size_type i=0;i<s.length()-1;i++) {
for(std::string::size_type i=0;i<s.length()-1;i++) {
if (s[i]=='\\' && s[i+1]==what)
s.erase(i,1);
}
}
}
void Protect(string &s, char what)
void Protect(std::string &s, char what)
{
for(string::size_type i=0;i<s.length();i++) {
for(std::string::size_type i=0;i<s.length();i++) {
if (s[i]==what)
s.insert(i++,"\\");
}
@@ -77,11 +75,11 @@ void Protect(string &s, char what)
item id -> fields_list
each fields_list is a map of field index -> value
*/
bool ItemParse(const char *data, int length, map<int,map<int,string> > &items, int id_pos, int name_pos, int max_field, int level)
bool ItemParse(const char *data, int length, std::map<int,std::map<int,std::string> > &items, int id_pos, int name_pos, int max_field, int level)
{
int i;
char *end,*ptr;
map<int,string> field;
std::map<int,std::string> field;
static char *buffer=nullptr;
static int buffsize=0;
static char *temp=nullptr;
@@ -102,7 +100,7 @@ static char *temp=nullptr;
break;
}
if (!end) {
cerr << "ItemParse: Level " << level << ": (1) Expected '|' not found near '" << ptr << "'" << endl;
std::cerr << "ItemParse: Level " << level << ": (1) Expected '|' not found near '" << ptr << "'" << std::endl;
return false;
} else {
*end=0;
@@ -114,7 +112,7 @@ static char *temp=nullptr;
}
if (*ptr!='"') {
cerr << "ItemParse: Level " << level << ": (2) Expected '\"' not found near '" << ptr << "'" << endl;
std::cerr << "ItemParse: Level " << level << ": (2) Expected '\"' not found near '" << ptr << "'" << std::endl;
return false;
}
ptr++;
@@ -126,7 +124,7 @@ static char *temp=nullptr;
break;
}
if (!end) {
cerr << "ItemParse: Level " << level << ": (1) Expected '|' not found near '" << ptr << "'" << endl;
std::cerr << "ItemParse: Level " << level << ": (1) Expected '|' not found near '" << ptr << "'" << std::endl;
return false;
} else {
*end=0;
@@ -145,12 +143,12 @@ static char *temp=nullptr;
Unprotect(field[i],'|');
ptr+=length;
} else {
cerr << "ItemParse: Level " << level << ": (4) Expected '\"' not found near '" << ptr << "'" << endl;
std::cerr << "ItemParse: Level " << level << ": (4) Expected '\"' not found near '" << ptr << "'" << std::endl;
return false;
}
if (*ptr!='|') {
cerr << "ItemParse: Level " << level << ": (5) Expected '|' not found near '" << ptr << "'" << endl;
std::cerr << "ItemParse: Level " << level << ": (5) Expected '|' not found near '" << ptr << "'" << std::endl;
return false;
}
ptr++;
@@ -162,7 +160,7 @@ static char *temp=nullptr;
end=ptr;
while((end=strchr(end+1,'"'))!=nullptr && *(end-1)=='\\');
if (end) {
string sub;
std::string sub;
sub.assign(ptr+1,end-ptr-1);
Unprotect(sub,'"');
if (!ItemParse(sub.c_str(),sub.length(),items,id_pos,name_pos,max_field,level+1)) {
@@ -170,14 +168,14 @@ static char *temp=nullptr;
}
ptr=end+1;
} else {
cerr << "ItemParse: Level " << level << ": (6) Expected closing '\"' not found near '" << (ptr+1) << "'" << endl;
std::cerr << "ItemParse: Level " << level << ": (6) Expected closing '\"' not found near '" << (ptr+1) << "'" << std::endl;
return false;
}
}
if (*ptr=='|') {
ptr++;
} else if (i<9) {
cerr << "ItemParse: Level " << level << ": (7) Expected '|' (#" << i << ") not found near '" << ptr << "'" << endl;
std::cerr << "ItemParse: Level " << level << ": (7) Expected '|' (#" << i << ") not found near '" << ptr << "'" << std::endl;
return false;
}
@@ -185,12 +183,12 @@ static char *temp=nullptr;
return true;
}
int Tokenize(string s,map<int,string> & tokens, char delim)
int Tokenize(std::string s,std::map<int,std::string> & tokens, char delim)
{
int i,len;
string::size_type end;
std::string::size_type end;
//char temp[1024];
string x;
std::string x;
tokens.clear();
i=0;
while(s.length()) {
@@ -199,10 +197,10 @@ string x;
tokens[i++]="";
} else {
end=0;
while((end=s.find(delim,end+1))!=string::npos && s[end-1]=='\\');
if (end!=string::npos) {
while((end=s.find(delim,end+1))!=std::string::npos && s[end-1]=='\\');
if (end!=std::string::npos) {
x=s;
x.erase(end,string::npos);
x.erase(end,std::string::npos);
s.erase(0,end+1);
Unprotect(x,'|');
tokens[i++]=x;
@@ -392,7 +390,7 @@ void decode_chunk(char *in, char *out)
*(out+2) = DEC(in[2]) << 6 | DEC(in[3]);
}
void dump_message_column(unsigned char *buffer, unsigned long length, string leader, FILE *to)
void dump_message_column(unsigned char *buffer, unsigned long length, std::string leader, FILE *to)
{
unsigned long i,j;
unsigned long rows,offset=0;
@@ -418,7 +416,7 @@ unsigned long rows,offset=0;
}
}
string long2ip(unsigned long ip)
std::string long2ip(unsigned long ip)
{
char temp[16];
union { unsigned long ip; struct { unsigned char a,b,c,d; } octet;} ipoctet;
@@ -426,10 +424,10 @@ union { unsigned long ip; struct { unsigned char a,b,c,d; } octet;} ipoctet;
ipoctet.ip=ip;
sprintf(temp,"%d.%d.%d.%d",ipoctet.octet.a,ipoctet.octet.b,ipoctet.octet.c,ipoctet.octet.d);
return string(temp);
return std::string(temp);
}
string string_from_time(string pattern, time_t now)
std::string string_from_time(std::string pattern, time_t now)
{
struct tm *now_tm;
char time_string[51];
@@ -440,18 +438,18 @@ char time_string[51];
strftime(time_string,51,pattern.c_str(),now_tm);
return string(time_string);
return std::string(time_string);
}
string timestamp(time_t now)
std::string timestamp(time_t now)
{
return string_from_time("[%Y%m%d.%H%M%S] ",now);
}
string pop_arg(string &s, string seps, bool obey_quotes)
std::string pop_arg(std::string &s, std::string seps, bool obey_quotes)
{
string ret;
std::string ret;
unsigned long i;
bool in_quote=false;
@@ -463,7 +461,7 @@ bool in_quote=false;
}
if (in_quote)
continue;
if (seps.find(c)!=string::npos) {
if (seps.find(c)!=std::string::npos) {
break;
}
}
@@ -523,9 +521,9 @@ char *bptr;
return (bptr-buffer);
}
string generate_key(int length)
std::string generate_key(int length)
{
string key;
std::string key;
//TODO: write this for win32...
#ifndef WIN32
int i;
+10 -12
View File
@@ -5,17 +5,15 @@
#include <string>
#include <map>
using namespace std;
#define ITEMFIELDCOUNT 116
void Unprotect(string &s, char what);
void Unprotect(std::string &s, char what);
void Protect(string &s, char what);
void Protect(std::string &s, char what);
bool ItemParse(const char *data, int length, map<int,map<int,string> > &items, int id_pos, int name_pos, int max_field, int level=0);
bool ItemParse(const char *data, int length, std::map<int,std::map<int,std::string> > &items, int id_pos, int name_pos, int max_field, int level=0);
int Tokenize(string s, map<int,string> & tokens, char delim='|');
int Tokenize(std::string s, std::map<int,std::string> & tokens, char delim='|');
void LoadItemDBFieldNames();
@@ -30,13 +28,13 @@ void decode_chunk(char *in, char *out);
int print_stacktrace();
#endif
void dump_message_column(unsigned char *buffer, unsigned long length, string leader="", FILE *to = stdout);
string string_from_time(string pattern, time_t now=0);
string timestamp(time_t now=0);
string long2ip(unsigned long ip);
string pop_arg(string &s, string seps, bool obey_quotes);
void dump_message_column(unsigned char *buffer, unsigned long length, std::string leader="", FILE *to = stdout);
std::string string_from_time(std::string pattern, time_t now=0);
std::string timestamp(time_t now=0);
std::string long2ip(unsigned long ip);
std::string pop_arg(std::string &s, std::string seps, bool obey_quotes);
int EQsprintf(char *buffer, const char *pattern, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *arg6, const char *arg7, const char *arg8, const char *arg9);
string generate_key(int length);
std::string generate_key(int length);
void build_hex_line(const char *buffer, unsigned long length, unsigned long offset, char *out_buffer, unsigned char padding=4);
void print_hex(const char *buffer, unsigned long length);
+3 -5
View File
@@ -2,13 +2,11 @@
#include <map>
#include <string>
using namespace std;
std::map<unsigned long, std::string> opcode_map;
map<unsigned long, string> opcode_map;
string get_opcode_name(unsigned long opcode)
std::string get_opcode_name(unsigned long opcode)
{
map<unsigned long, string>::iterator itr;;
std::map<unsigned long, std::string>::iterator itr;;
return (itr=opcode_map.find(opcode))!=opcode_map.end() ? itr->second : "OP_Unknown";
}
+4 -5
View File
@@ -25,7 +25,6 @@
#include <map>
#include <string>
using namespace std;
OpcodeManager::OpcodeManager() {
loaded = false;
@@ -38,7 +37,7 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
return(false);
}
map<string, uint16> eq;
std::map<std::string, uint16> eq;
//load the opcode file into eq, could swap in a nice XML parser here
char line[2048];
@@ -82,7 +81,7 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
//do the mapping and store them in the shared memory array
bool ret = true;
EmuOpcode emu_op;
map<string, uint16>::iterator res;
std::map<std::string, uint16>::iterator res;
//stupid enum wont let me ++ on it...
for(emu_op = OP_Unknown; emu_op < _maxEmuOpcode; emu_op=(EmuOpcode)(emu_op+1)) {
//get the name of this emu opcode
@@ -260,13 +259,13 @@ bool EmptyOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors)
}
uint16 EmptyOpcodeManager::EmuToEQ(const EmuOpcode emu_op) {
map<EmuOpcode, uint16>::iterator f;
std::map<EmuOpcode, uint16>::iterator f;
f = emu_to_eq.find(emu_op);
return(f == emu_to_eq.end()? 0 : f->second);
}
EmuOpcode EmptyOpcodeManager::EQToEmu(const uint16 eq_op) {
map<uint16, EmuOpcode>::iterator f;
std::map<uint16, EmuOpcode>::iterator f;
f = eq_to_emu.find(eq_op);
return(f == eq_to_emu.end()?OP_Unknown:f->second);
}
+2 -3
View File
@@ -24,7 +24,6 @@
#include "emu_opcodes.h"
#include <map>
using namespace std;
//enable the use of shared mem opcodes for world and zone only
#ifdef ZONE
@@ -156,8 +155,8 @@ public:
//fake it, just used for testing anyways
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op);
protected:
map<EmuOpcode, uint16> emu_to_eq;
map<uint16, EmuOpcode> eq_to_emu;
std::map<EmuOpcode, uint16> emu_to_eq;
std::map<uint16, EmuOpcode> eq_to_emu;
};
#endif
+46 -48
View File
@@ -20,8 +20,6 @@
#include <iomanip>
#include <stdio.h>
using namespace std;
#include "packet_dump.h"
#include "EQPacket.h"
#include "../common/servertalk.h"
@@ -32,22 +30,22 @@ void DumpPacketAscii(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
{
if ((i-skip)%cols==0)
{
cout << endl << setw(3) << setfill(' ') << i-skip << ":";
std::cout << std::endl << std::setw(3) << std::setfill(' ') << i-skip << ":";
}
else if ((i-skip)%(cols/2)==0)
{
cout << " - ";
std::cout << " - ";
}
if (buf[i] > 32 && buf[i] < 127)
{
cout << buf[i];
std::cout << buf[i];
}
else
{
cout << '.';
std::cout << '.';
}
}
cout << endl << endl;
std::cout << std::endl << std::endl;
}
void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
@@ -63,16 +61,16 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
{
if ((i-skip)%cols==0) {
if (i != skip)
cout << " | " << ascii << endl;
cout << setw(4) << setfill(' ') << i-skip << ": ";
std::cout << " | " << ascii << std::endl;
std::cout << std::setw(4) << std::setfill(' ') << i-skip << ": ";
memset(ascii, 0, cols+1);
j = 0;
}
else if ((i-skip)%(cols/2) == 0) {
cout << "- ";
std::cout << "- ";
}
sprintf(output, "%02X ", (unsigned char)buf[i]);
cout << output;
std::cout << output;
if (buf[i] >= 32 && buf[i] < 127) {
ascii[j++] = buf[i];
@@ -84,11 +82,11 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
}
uint32 k = ((i-skip)-1)%cols;
if (k < 8)
cout << " ";
std::cout << " ";
for (uint32 h = k+1; h < cols; h++) {
cout << " ";
std::cout << " ";
}
cout << " | " << ascii << endl;
std::cout << " | " << ascii << std::endl;
safe_delete_array(ascii);
}
@@ -100,8 +98,8 @@ void DumpPacket(const uchar* buf, uint32 size)
void DumpPacket(const ServerPacket* pack, bool iShowInfo) {
if (iShowInfo) {
cout << "Dumping ServerPacket: 0x" << hex << setfill('0') << setw(4) << pack->opcode << dec;
cout << " size:" << pack->size << endl;
std::cout << "Dumping ServerPacket: 0x" << std::hex << std::setfill('0') << std::setw(4) << pack->opcode << std::dec;
std::cout << " size:" << pack->size << std::endl;
}
DumpPacketHex(pack->pBuffer, pack->size);
}
@@ -131,66 +129,66 @@ void DumpPacketBin(const void* iData, uint32 len) {
for (k=0; k<len; k++) {
if (k % 4 == 0) {
if (k != 0) {
cout << " | " << hex << setw(2) << setfill('0') << (int) data[k-4] << dec;
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-3] << dec;
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-2] << dec;
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-1] << dec;
cout << endl;
std::cout << " | " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-4] << std::dec;
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-3] << std::dec;
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-2] << std::dec;
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-1] << std::dec;
std::cout << std::endl;
}
cout << setw(4) << setfill('0') << k << ":";
std::cout << std::setw(4) << std::setfill('0') << k << ":";
}
else if (k % 2 == 0)
cout << " ";
cout << " ";
std::cout << " ";
std::cout << " ";
if (data[k] & 1)
cout << "1";
std::cout << "1";
else
cout << "0";
std::cout << "0";
if (data[k] & 2)
cout << "1";
std::cout << "1";
else
cout << "0";
std::cout << "0";
if (data[k] & 4)
cout << "1";
std::cout << "1";
else
cout << "0";
std::cout << "0";
if (data[k] & 8)
cout << "1";
std::cout << "1";
else
cout << "0";
std::cout << "0";
if (data[k] & 16)
cout << "1";
std::cout << "1";
else
cout << "0";
std::cout << "0";
if (data[k] & 32)
cout << "1";
std::cout << "1";
else
cout << "0";
std::cout << "0";
if (data[k] & 64)
cout << "1";
std::cout << "1";
else
cout << "0";
std::cout << "0";
if (data[k] & 128)
cout << "1";
std::cout << "1";
else
cout << "0";
std::cout << "0";
}
uint8 tmp = (k % 4);
if (!tmp)
tmp = 4;
if (tmp <= 3)
cout << " ";
std::cout << " ";
if (tmp <= 2)
cout << " ";
std::cout << " ";
if (tmp <= 1)
cout << " ";
cout << " | " << hex << setw(2) << setfill('0') << (int) data[k-4] << dec;
std::cout << " ";
std::cout << " | " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-4] << std::dec;
if (tmp > 1)
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-3] << dec;
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-3] << std::dec;
if (tmp > 2)
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-2] << dec;
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-2] << std::dec;
if (tmp > 3)
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-1] << dec;
cout << endl;
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-1] << std::dec;
std::cout << std::endl;
}
+16 -21
View File
@@ -29,9 +29,6 @@
#ifdef _WINDOWS
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else
@@ -41,16 +38,14 @@
#include "EQStream.h"
#include "packet_dump_file.h"
using namespace std;
void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
ofstream logfile(filename, ios::app);
std::ofstream logfile(filename, std::ios::app);
// Output as ASCII
for(uint32 i=skip; i<size; i++)
{
if ((i-skip)%cols==0)
{
logfile << endl << setw(3) << setfill(' ') << i-skip << ":";
logfile << std::endl << std::setw(3) << std::setfill(' ') << i-skip << ":";
}
else if ((i-skip)%(cols/2)==0)
{
@@ -65,19 +60,19 @@ void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, ui
logfile << '.';
}
}
logfile << endl << endl;
logfile << std::endl << std::endl;
}
void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip)
{
ofstream logfile(filename, ios::app);
std::ofstream logfile(filename, std::ios::app);
// Output as HEX
char output[4];
for(uint32 i=skip; i<size; i++)
{
if ((i-skip)%cols==0)
{
logfile << endl << setw(3) << setfill(' ') << i-skip << ": ";
logfile << std::endl << std::setw(3) << std::setfill(' ') << i-skip << ": ";
}
else if ((i-skip)%(cols/2) == 0)
{
@@ -87,14 +82,14 @@ void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, u
logfile << output;
// logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " ";
}
logfile << endl << endl;
logfile << std::endl << std::endl;
}
void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip)
{
if (size == 0)
return;
ofstream logfile(filename, ios::app);
std::ofstream logfile(filename, std::ios::app);
// Output as HEX
char output[4];
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
@@ -103,8 +98,8 @@ void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint
{
if ((i-skip)%cols==0) {
if (i != skip)
logfile << " | " << ascii << endl;
logfile << setw(4) << setfill(' ') << i-skip << ": ";
logfile << " | " << ascii << std::endl;
logfile << std::setw(4) << std::setfill(' ') << i-skip << ": ";
memset(ascii, 0, cols+1);
j = 0;
}
@@ -128,7 +123,7 @@ void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint
for (uint32 h = k+1; h < cols; h++) {
logfile << " ";
}
logfile << " | " << ascii << endl;
logfile << " | " << ascii << std::endl;
delete[] ascii;
}
@@ -161,13 +156,13 @@ void FileDumpPacket(const char* filename, const EQApplicationPacket* app)
if prefix_timestamp specified, prints the current date/time to the file + ": " + text
*/
void FilePrintLine(const char* filename, bool prefix_timestamp, const char* text, ...) {
ofstream logfile(filename, ios::app);
std::ofstream logfile(filename, std::ios::app);
if (prefix_timestamp) {
time_t rawtime;
struct tm* gmt_t;
time(&rawtime);
gmt_t = gmtime(&rawtime);
logfile << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec << " GMT";
logfile << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec << " GMT";
}
if (text != 0) {
@@ -181,17 +176,17 @@ void FilePrintLine(const char* filename, bool prefix_timestamp, const char* text
logfile << ": ";
logfile << buffer;
}
logfile << endl;
logfile << std::endl;
}
void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const char* text, ...) {
ofstream logfile(filename, ios::app);
std::ofstream logfile(filename, std::ios::app);
if (prefix_timestamp) {
time_t rawtime;
struct tm* gmt_t;
time(&rawtime);
gmt_t = gmtime(&rawtime);
logfile << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec << " GMT";
logfile << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec << " GMT";
}
if (text != 0) {
@@ -207,6 +202,6 @@ void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const
}
if (newline)
logfile << endl;
logfile << std::endl;
}
-1
View File
@@ -19,7 +19,6 @@
#define PACKET_DUMP_FILE_H
#include <iostream>
using namespace std;
#include "../common/types.h"
+6 -8
View File
@@ -27,8 +27,6 @@
#include <netinet/in.h>
#endif
using namespace std;
void EncryptProfilePacket(EQApplicationPacket* app) {
//EncryptProfilePacket(app->pBuffer, app->size);
}
@@ -209,10 +207,10 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
}
else {
if (!iQuiet) {
cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
std::cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
if (zstream.msg)
cout << zstream.msg;
cout << "'" << endl;
std::cout << zstream.msg;
std::cout << "'" << std::endl;
#ifdef EQDEBUG
DumpPacket(indata-16, indatalen+16);
#endif
@@ -254,10 +252,10 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
}
else {
if (!iQuiet) {
cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
std::cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
if (zstream.msg)
cout << zstream.msg;
cout << "'" << endl;
std::cout << zstream.msg;
std::cout << "'" << std::endl;
#ifdef EQDEBUG
DumpPacket(indata-16, indatalen+16);
#endif
-3
View File
@@ -13,9 +13,6 @@
#include "../common/misc.h"
#include <map>
using namespace std;
PacketFileWriter::PacketFileWriter(bool _force_flush) {
out = NULL;
force_flush = _force_flush;
+7 -6
View File
@@ -8,6 +8,7 @@
#include "../eq_packet_structs.h"
#include "../MiscFunctions.h"
#include "../StringUtil.h"
#include "../Item.h"
#include "../clientversions.h"
#include "Client62_structs.h"
@@ -24,7 +25,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already
if(opcodes == nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
//load up the opcode manager.
@@ -39,17 +40,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register.
EQStream::Signature signature;
string pname;
std::string pname;
//register our world signature.
pname = string(name) + "_world";
pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature.
pname = string(name) + "_zone";
pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@@ -66,7 +67,7 @@ void Reload() {
if(opcodes != nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
@@ -546,7 +547,7 @@ ENCODE(OP_CharInventory) {
//do the transform...
int r;
string serial_string;
std::string serial_string;
for(r = 0; r < itemcount; r++, eq++) {
uint32 length;
char *serialized=SerializeItem((ItemInst*)eq->inst,eq->slot_id,&length,0);
+6 -5
View File
@@ -8,6 +8,7 @@
#include "../eq_packet_structs.h"
#include "../MiscFunctions.h"
#include "../StringUtil.h"
#include "../Item.h"
#include "RoF_structs.h"
#include "../rulesys.h"
@@ -27,7 +28,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already
if(opcodes == nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
//load up the opcode manager.
@@ -42,17 +43,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register.
EQStream::Signature signature;
string pname;
std::string pname;
//register our world signature.
pname = string(name) + "_world";
pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature.
pname = string(name) + "_zone";
pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@@ -71,7 +72,7 @@ void Reload() {
if(opcodes != nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
+6 -5
View File
@@ -8,6 +8,7 @@
#include "../eq_packet_structs.h"
#include "../MiscFunctions.h"
#include "../StringUtil.h"
#include "../Item.h"
#include "SoD_structs.h"
#include "../rulesys.h"
@@ -27,7 +28,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already
if(opcodes == nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
//load up the opcode manager.
@@ -42,17 +43,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register.
EQStream::Signature signature;
string pname;
std::string pname;
//register our world signature.
pname = string(name) + "_world";
pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature.
pname = string(name) + "_zone";
pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@@ -71,7 +72,7 @@ void Reload() {
if(opcodes != nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
+6 -6
View File
@@ -7,7 +7,7 @@
#include "../crc32.h"
#include "../eq_packet_structs.h"
#include "../MiscFunctions.h"
#include "../StringUtil.h"
#include "../Item.h"
#include "SoF_structs.h"
#include "../rulesys.h"
@@ -27,7 +27,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already
if(opcodes == nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
//load up the opcode manager.
@@ -42,17 +42,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register.
EQStream::Signature signature;
string pname;
std::string pname;
//register our world signature.
pname = string(name) + "_world";
pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature.
pname = string(name) + "_zone";
pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@@ -71,7 +71,7 @@ void Reload() {
if(opcodes != nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
+7 -7
View File
@@ -8,7 +8,7 @@
#include "../races.h"
#include "../eq_packet_structs.h"
#include "../MiscFunctions.h"
#include "../StringUtil.h"
#include "../Item.h"
#include "Titanium_structs.h"
#include <sstream>
@@ -25,7 +25,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already
if(opcodes == nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
//load up the opcode manager.
@@ -40,17 +40,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register.
EQStream::Signature signature;
string pname;
std::string pname;
//register our world signature.
pname = string(name) + "_world";
pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature.
pname = string(name) + "_zone";
pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@@ -69,7 +69,7 @@ void Reload() {
if(opcodes != nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
@@ -639,7 +639,7 @@ ENCODE(OP_CharInventory) {
//do the transform...
int r;
string serial_string;
std::string serial_string;
for(r = 0; r < itemcount; r++, eq++) {
uint32 length;
char *serialized=SerializeItem((const ItemInst*)eq->inst,eq->slot_id,&length,0);
+6 -5
View File
@@ -8,6 +8,7 @@
#include "../eq_packet_structs.h"
#include "../MiscFunctions.h"
#include "../StringUtil.h"
#include "../Item.h"
#include "Underfoot_structs.h"
#include "../rulesys.h"
@@ -28,7 +29,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already
if(opcodes == nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
//load up the opcode manager.
@@ -43,17 +44,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register.
EQStream::Signature signature;
string pname;
std::string pname;
//register our world signature.
pname = string(name) + "_world";
pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature.
pname = string(name) + "_zone";
pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@@ -72,7 +73,7 @@ void Reload() {
if(opcodes != nullptr) {
//TODO: get this file name from the config file
string opfile = "patch_";
std::string opfile = "patch_";
opfile += name;
opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
+4 -4
View File
@@ -139,7 +139,7 @@ XS(XS_EQDBRes_fetch_row_array)
Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_array(THIS)");
{
EQDBRes * THIS;
vector<string> RETVAL;
std::vector<std::string> RETVAL;
if (sv_derived_from(ST(0), "EQDBRes")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
@@ -160,7 +160,7 @@ XS(XS_EQDBRes_fetch_row_array)
/* grow the stack to the number of elements being returned */
EXTEND(SP, RETVAL.size());
for (ix_RETVAL = 0; ix_RETVAL < RETVAL.size(); ix_RETVAL++) {
const string &it = RETVAL[ix_RETVAL];
const std::string &it = RETVAL[ix_RETVAL];
ST(ix_RETVAL) = sv_newmortal();
sv_setpvn(ST(ix_RETVAL), it.c_str(), it.length());
}
@@ -179,7 +179,7 @@ XS(XS_EQDBRes_fetch_row_hash)
Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_hash(THIS)");
{
EQDBRes * THIS;
map<string,string> RETVAL;
std::map<std::string,std::string> RETVAL;
if (sv_derived_from(ST(0), "EQDBRes")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
@@ -199,7 +199,7 @@ XS(XS_EQDBRes_fetch_row_hash)
sv_2mortal((SV*)hv);
ST(0) = newRV((SV*)hv);
map<string,string>::const_iterator cur, end;
std::map<std::string,std::string>::const_iterator cur, end;
cur = RETVAL.begin();
end = RETVAL.end();
for(; cur != end; cur++) {
+7 -7
View File
@@ -20,7 +20,7 @@
#include "timer.h"
#include "ptimer.h"
#include "database.h"
#include "MiscFunctions.h"
#include "StringUtil.h"
#include <stdio.h>
#include <cstdlib>
#include <cstring>
@@ -289,7 +289,7 @@ PTimerList::PTimerList(uint32 char_id) {
}
PTimerList::~PTimerList() {
map<pTimerType, PersistentTimer *>::iterator s;
std::map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin();
while(s != _list.end()) {
if(s->second != nullptr)
@@ -300,7 +300,7 @@ PTimerList::~PTimerList() {
bool PTimerList::Load(Database *db) {
map<pTimerType, PersistentTimer *>::iterator s;
std::map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin();
while(s != _list.end()) {
if(s->second != nullptr)
@@ -362,7 +362,7 @@ bool PTimerList::Store(Database *db) {
printf("Storing all timers for char %lu\n", (unsigned long)_char_id);
#endif
map<pTimerType, PersistentTimer *>::iterator s;
std::map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin();
bool res = true;
while(s != _list.end()) {
@@ -462,11 +462,11 @@ PersistentTimer *PTimerList::Get(pTimerType type) {
return(_list[type]);
}
void PTimerList::ToVector(vector< pair<pTimerType, PersistentTimer *> > &out) {
void PTimerList::ToVector(std::vector< std::pair<pTimerType, PersistentTimer *> > &out) {
pair<pTimerType, PersistentTimer *> p;
std::pair<pTimerType, PersistentTimer *> p;
map<pTimerType, PersistentTimer *>::iterator s;
std::map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin();
while(s != _list.end()) {
if(s->second != nullptr) {
+3 -4
View File
@@ -21,7 +21,6 @@
#include "types.h"
#include <map>
#include <vector>
using namespace std;
enum { //values for pTimerType
pTimerStartAdventureTimer = 1,
@@ -120,13 +119,13 @@ public:
inline void SetCharID(uint32 char_id) { _char_id = char_id; }
void ToVector(vector< pair<pTimerType, PersistentTimer *> > &out);
void ToVector(std::vector< std::pair<pTimerType, PersistentTimer *> > &out);
//Clear a timer for a char not logged in
//this is not defined on a char which is logged in!
static bool ClearOffline(Database *db, uint32 char_id, pTimerType type);
typedef map<pTimerType, PersistentTimer *>::iterator iterator;
typedef std::map<pTimerType, PersistentTimer *>::iterator iterator;
iterator begin() { return(_list.begin()); }
iterator end() { return(_list.end()); }
@@ -135,7 +134,7 @@ public:
protected:
uint32 _char_id;
map<pTimerType, PersistentTimer *> _list;
std::map<pTimerType, PersistentTimer *> _list;
};
//code prettying macros
+1 -1
View File
@@ -19,7 +19,7 @@
#include "rulesys.h"
#include "logsys.h"
#include "database.h"
#include "MiscFunctions.h"
#include "StringUtil.h"
#include <cstdlib>
#include <cstring>
+17 -20
View File
@@ -6,7 +6,7 @@
#include "classes.h"
#include "rulesys.h"
#include "seperator.h"
#include "MiscFunctions.h"
#include "StringUtil.h"
#include "eq_packet_structs.h"
#include "guilds.h"
#include "extprofile.h"
@@ -17,8 +17,6 @@
#include "faction.h"
#include "features.h"
using namespace std;
SharedDatabase::SharedDatabase()
: Database(), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr), faction_mmf(nullptr), faction_hash(nullptr),
loot_table_mmf(nullptr), loot_drop_mmf(nullptr), loot_table_hash(nullptr), loot_drop_hash(nullptr)
@@ -50,7 +48,7 @@ bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET hideme = %i where id = %i", hideme, account_id), errbuf)) {
cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << endl;
std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -85,7 +83,7 @@ uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
else
{
cerr << "Error in GetGMSpeed query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetGMSpeed query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -101,7 +99,7 @@ bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET gmspeed = %i where id = %i", gmspeed, account_id), errbuf)) {
cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << endl;
std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -140,7 +138,7 @@ uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
return EntitledTime;
}
bool SharedDatabase::SaveCursor(uint32 char_id, list<ItemInst*>::const_iterator &start, list<ItemInst*>::const_iterator &end)
bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iterator &start, std::list<ItemInst*>::const_iterator &end)
{
iter_queue it;
int i;
@@ -155,7 +153,7 @@ bool ret=true;
break;
}
} else {
cout << "Clearing cursor failed: " << errbuf << endl;
std::cout << "Clearing cursor failed: " << errbuf << std::endl;
}
safe_delete_array(query);
@@ -337,8 +335,7 @@ int32 SharedDatabase::GetSharedPlatinum(uint32 account_id)
}
else
{
cerr << "Error in GetSharedPlatinum query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetSharedPlatinum query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -352,7 +349,7 @@ bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add)
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i", amount_to_add, account_id), errbuf)) {
cerr << "Error in SetSharedPlatinum query '" << query << "' " << errbuf << endl;
std::cerr << "Error in SetSharedPlatinum query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -1049,17 +1046,17 @@ const Item_Struct* SharedDatabase::IterateItems(uint32* id) {
return nullptr;
}
string SharedDatabase::GetBook(const char *txtfile)
std::string SharedDatabase::GetBook(const char *txtfile)
{
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
char txtfile2[20];
string txtout;
std::string txtout;
strcpy(txtfile2,txtfile);
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT txtfile FROM books where name='%s'", txtfile2), errbuf, &result)) {
cerr << "Error in GetBook query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetBook query '" << query << "' " << errbuf << std::endl;
if (query != 0)
safe_delete_array(query);
txtout.assign(" ",1);
@@ -1399,7 +1396,7 @@ int32 SharedDatabase::DeleteStalePlayerBackups() {
return affected_rows;
}
bool SharedDatabase::GetCommandSettings(map<string,uint8> &commands) {
bool SharedDatabase::GetCommandSettings(std::map<std::string,uint8> &commands) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
@@ -1415,7 +1412,7 @@ bool SharedDatabase::GetCommandSettings(map<string,uint8> &commands) {
mysql_free_result(result);
return true;
} else {
cerr << "Error in GetCommands query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetCommands query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return false;
}
@@ -1974,7 +1971,7 @@ void SharedDatabase::GetPlayerInspectMessage(char* playername, InspectMessage_St
mysql_free_result(result);
}
else {
cerr << "Error in GetPlayerInspectMessage query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
}
@@ -1985,7 +1982,7 @@ void SharedDatabase::SetPlayerInspectMessage(char* playername, const InspectMess
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET inspectmessage='%s' WHERE name='%s'", message->text, playername), errbuf)) {
cerr << "Error in SetPlayerInspectMessage query '" << query << "' " << errbuf << endl;
std::cerr << "Error in SetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
@@ -2009,7 +2006,7 @@ void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* m
mysql_free_result(result);
}
else {
cerr << "Error in GetBotInspectMessage query '" << query << "' " << errbuf << endl;
std::cerr << "Error in GetBotInspectMessage query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
}
}
@@ -2020,7 +2017,7 @@ void SharedDatabase::SetBotInspectMessage(uint32 botid, const InspectMessage_Str
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE bots SET BotInspectMessage='%s' WHERE BotID=%i", message->text, botid), errbuf)) {
cerr << "Error in SetBotInspectMessage query '" << query << "' " << errbuf << endl;
std::cerr << "Error in SetBotInspectMessage query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
+2 -2
View File
@@ -48,7 +48,7 @@ public:
void SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message);
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
void SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message);
bool GetCommandSettings(map<string,uint8> &commands);
bool GetCommandSettings(std::map<std::string,uint8> &commands);
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
/*
@@ -65,7 +65,7 @@ public:
bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin);
string GetBook(const char *txtfile);
std::string GetBook(const char *txtfile);
/*
* Item Methods
+2 -2
View File
@@ -36,7 +36,7 @@ TimeoutManager::TimeoutManager() {
}
void TimeoutManager::CheckTimeouts() {
vector<Timeoutable *>::iterator cur,end;
std::vector<Timeoutable *>::iterator cur,end;
cur = members.begin();
end = members.end();
for(; cur != end; cur++) {
@@ -66,7 +66,7 @@ void TimeoutManager::DeleteMember(Timeoutable *who) {
#ifdef TIMEOUT_DEBUG
LogFile->write(EQEMuLog::Debug, "Removing timeoutable 0x%x\n", who);
#endif
vector<Timeoutable *>::iterator cur,end;
std::vector<Timeoutable *>::iterator cur,end;
cur = members.begin();
end = members.end();
for(; cur != end; cur++) {
+1 -2
View File
@@ -27,7 +27,6 @@
#include "timer.h"
#include <vector>
using namespace std;
//timeoutable objects automatically register themselves
//with the global TimeoutManager object
@@ -59,7 +58,7 @@ protected:
void AddMember(Timeoutable *who);
void DeleteMember(Timeoutable *who);
vector<Timeoutable *> members;
std::vector<Timeoutable *> members;
};
extern TimeoutManager timeout_manager;
+1 -2
View File
@@ -24,7 +24,6 @@
#endif
#include <iostream>
using namespace std;
#include "timer.h"
@@ -77,7 +76,7 @@ bool Timer::Check(bool iReset)
{
_CP(Timer_Check);
if (this==0) {
cerr << "Null timer during ->Check()!?\n";
std::cerr << "Null timer during ->Check()!?\n";
return true;
}
// if (!current_time || !start_time || !timer_time) {cerr << "Timer::Check on a timer that does not have a vital member defined.";
+2 -5
View File
@@ -68,9 +68,6 @@ typedef const char Const_char; //for perl XS
#ifdef _WINDOWS
#define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
typedef void ThreadReturnType;
@@ -80,8 +77,8 @@ typedef const char Const_char; //for perl XS
#define THREAD_RETURN(x) return(x);
#endif
#define safe_delete(d) if(d) { delete d; d=0; }
#define safe_delete_array(d) if(d) { delete[] d; d=0; }
#define safe_delete(d) if(d) { delete d; d=nullptr; }
#define safe_delete_array(d) if(d) { delete[] d; d=nullptr; }
#define L32(i) ((uint32) i)
#define H32(i) ((uint32) (i >> 32))
#define L16(i) ((uint16) i)
-1
View File
@@ -21,7 +21,6 @@
#include <string.h>
#include <stdio.h>
#include <iomanip>
using namespace std;
#include <time.h>
#include <stdlib.h>
#include <stdarg.h>