Merge branch 'StringFormatting' into small_stage_cleanup

Conflicts:
	common/Item.cpp
	world/client.cpp
	zone/net.cpp
This commit is contained in:
Arthur Ice 2013-05-22 18:36:07 -07:00
commit 54914a970e
190 changed files with 1859 additions and 2097 deletions

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); buffer += sprintf(buffer, "%s.%06lu ",temp,timestamp.tv_usec);
} }
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
buffer += sprintf(buffer, "[%s:%d->%s:%d]\n",sIP.c_str(),src_port,dIP.c_str(),dst_port); 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 void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);

View File

@ -46,7 +46,7 @@ public:
//END PERL EXPORT //END PERL EXPORT
private: private:
string m_escapeBuffer; std::string m_escapeBuffer;
static EQDB s_EQDB; static EQDB s_EQDB;
MYSQL *mysql_ref; MYSQL *mysql_ref;
}; };

View File

@ -19,8 +19,8 @@
#include "EQDBRes.h" #include "EQDBRes.h"
#include <mysql.h> #include <mysql.h>
vector<string> EQDBRes::fetch_row_array() { std::vector<std::string> EQDBRes::fetch_row_array() {
vector<string> array; std::vector<std::string> array;
if(res == nullptr) if(res == nullptr)
return(array); return(array);
@ -32,8 +32,8 @@ vector<string> EQDBRes::fetch_row_array() {
return array; return array;
} }
map<string,string> EQDBRes::fetch_row_hash() { std::map<std::string,std::string> EQDBRes::fetch_row_hash() {
map<string,string> rowhash; std::map<std::string,std::string> rowhash;
if(res == nullptr) if(res == nullptr)
return(rowhash); return(rowhash);

View File

@ -36,8 +36,8 @@ public:
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; } unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
void DESTROY() { } void DESTROY() { }
void finish() { if (res) mysql_free_result(res); res=nullptr; }; void finish() { if (res) mysql_free_result(res); res=nullptr; };
vector<string> fetch_row_array(); std::vector<std::string> fetch_row_array();
map<string,string> fetch_row_hash(); std::map<std::string,std::string> fetch_row_hash();
unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; } unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; }
//END PERL EXPORT //END PERL EXPORT

View File

@ -21,7 +21,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
string EQEmuConfig::ConfigFile = "eqemu_config.xml"; std::string EQEmuConfig::ConfigFile = "eqemu_config.xml";
EQEmuConfig *EQEmuConfig::_config = nullptr; EQEmuConfig *EQEmuConfig::_config = nullptr;
void EQEmuConfig::do_world(TiXmlElement *ele) { 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") if(var_name == "ShortName")
return(ShortName); return(ShortName);
if(var_name == "LongName") if(var_name == "LongName")
@ -405,44 +405,44 @@ string EQEmuConfig::GetByName(const string &var_name) const {
void EQEmuConfig::Dump() const void EQEmuConfig::Dump() const
{ {
cout << "ShortName = " << ShortName << endl; std::cout << "ShortName = " << ShortName << std::endl;
cout << "LongName = " << LongName << endl; std::cout << "LongName = " << LongName << std::endl;
cout << "WorldAddress = " << WorldAddress << endl; std::cout << "WorldAddress = " << WorldAddress << std::endl;
cout << "LoginHost = " << LoginHost << endl; std::cout << "LoginHost = " << LoginHost << std::endl;
cout << "LoginAccount = " << LoginAccount << endl; std::cout << "LoginAccount = " << LoginAccount << std::endl;
cout << "LoginPassword = " << LoginPassword << endl; std::cout << "LoginPassword = " << LoginPassword << std::endl;
cout << "LoginPort = " << LoginPort << endl; std::cout << "LoginPort = " << LoginPort << std::endl;
cout << "Locked = " << Locked << endl; std::cout << "Locked = " << Locked << std::endl;
cout << "WorldTCPPort = " << WorldTCPPort << endl; std::cout << "WorldTCPPort = " << WorldTCPPort << std::endl;
cout << "WorldIP = " << WorldIP << endl; std::cout << "WorldIP = " << WorldIP << std::endl;
cout << "TelnetEnabled = " << TelnetEnabled << endl; std::cout << "TelnetEnabled = " << TelnetEnabled << std::endl;
cout << "WorldHTTPPort = " << WorldHTTPPort << endl; std::cout << "WorldHTTPPort = " << WorldHTTPPort << std::endl;
cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << endl; std::cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << std::endl;
cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << endl; std::cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << std::endl;
cout << "ChatHost = " << ChatHost << endl; std::cout << "ChatHost = " << ChatHost << std::endl;
cout << "ChatPort = " << ChatPort << endl; std::cout << "ChatPort = " << ChatPort << std::endl;
cout << "MailHost = " << MailHost << endl; std::cout << "MailHost = " << MailHost << std::endl;
cout << "MailPort = " << MailPort << endl; std::cout << "MailPort = " << MailPort << std::endl;
cout << "DatabaseHost = " << DatabaseHost << endl; std::cout << "DatabaseHost = " << DatabaseHost << std::endl;
cout << "DatabaseUsername = " << DatabaseUsername << endl; std::cout << "DatabaseUsername = " << DatabaseUsername << std::endl;
cout << "DatabasePassword = " << DatabasePassword << endl; std::cout << "DatabasePassword = " << DatabasePassword << std::endl;
cout << "DatabaseDB = " << DatabaseDB << endl; std::cout << "DatabaseDB = " << DatabaseDB << std::endl;
cout << "DatabasePort = " << DatabasePort << endl; std::cout << "DatabasePort = " << DatabasePort << std::endl;
cout << "QSDatabaseHost = " << QSDatabaseHost << endl; std::cout << "QSDatabaseHost = " << QSDatabaseHost << std::endl;
cout << "QSDatabaseUsername = " << QSDatabaseUsername << endl; std::cout << "QSDatabaseUsername = " << QSDatabaseUsername << std::endl;
cout << "QSDatabasePassword = " << QSDatabasePassword << endl; std::cout << "QSDatabasePassword = " << QSDatabasePassword << std::endl;
cout << "QSDatabaseDB = " << QSDatabaseDB << endl; std::cout << "QSDatabaseDB = " << QSDatabaseDB << std::endl;
cout << "QSDatabasePort = " << QSDatabasePort << endl; std::cout << "QSDatabasePort = " << QSDatabasePort << std::endl;
cout << "SpellsFile = " << SpellsFile << endl; std::cout << "SpellsFile = " << SpellsFile << std::endl;
cout << "OpCodesFile = " << OpCodesFile << endl; std::cout << "OpCodesFile = " << OpCodesFile << std::endl;
cout << "EQTimeFile = " << EQTimeFile << endl; std::cout << "EQTimeFile = " << EQTimeFile << std::endl;
cout << "LogSettingsFile = " << LogSettingsFile << endl; std::cout << "LogSettingsFile = " << LogSettingsFile << std::endl;
cout << "MapDir = " << MapDir << endl; std::cout << "MapDir = " << MapDir << std::endl;
cout << "QuestDir = " << QuestDir << endl; std::cout << "QuestDir = " << QuestDir << std::endl;
cout << "PluginDir = " << PluginDir << endl; std::cout << "PluginDir = " << PluginDir << std::endl;
cout << "ZonePortLow = " << ZonePortLow << endl; std::cout << "ZonePortLow = " << ZonePortLow << std::endl;
cout << "ZonePortHigh = " << ZonePortHigh << endl; std::cout << "ZonePortHigh = " << ZonePortHigh << std::endl;
cout << "DefaultStatus = " << (int)DefaultStatus << endl; std::cout << "DefaultStatus = " << (int)DefaultStatus << std::endl;
// cout << "DynamicCount = " << DynamicCount << endl; // std::cout << "DynamicCount = " << DynamicCount << std::endl;
} }

View File

@ -22,74 +22,74 @@
#include "linked_list.h" #include "linked_list.h"
struct LoginConfig { struct LoginConfig {
string LoginHost; std::string LoginHost;
string LoginAccount; std::string LoginAccount;
string LoginPassword; std::string LoginPassword;
uint16 LoginPort; uint16 LoginPort;
}; };
class EQEmuConfig : public XMLParser { class EQEmuConfig : public XMLParser {
public: public:
virtual string GetByName(const string &var_name) const; virtual std::string GetByName(const std::string &var_name) const;
// From <world/> // From <world/>
string ShortName; std::string ShortName;
string LongName; std::string LongName;
string WorldAddress; std::string WorldAddress;
string LocalAddress; std::string LocalAddress;
string LoginHost; std::string LoginHost;
string LoginAccount; std::string LoginAccount;
string LoginPassword; std::string LoginPassword;
uint16 LoginPort; uint16 LoginPort;
uint32 LoginCount; uint32 LoginCount;
LinkedList<LoginConfig*> loginlist; LinkedList<LoginConfig*> loginlist;
bool Locked; bool Locked;
uint16 WorldTCPPort; uint16 WorldTCPPort;
string WorldIP; std::string WorldIP;
bool TelnetEnabled; bool TelnetEnabled;
int32 MaxClients; int32 MaxClients;
bool WorldHTTPEnabled; bool WorldHTTPEnabled;
uint16 WorldHTTPPort; uint16 WorldHTTPPort;
string WorldHTTPMimeFile; std::string WorldHTTPMimeFile;
string SharedKey; std::string SharedKey;
// From <chatserver/> // From <chatserver/>
string ChatHost; std::string ChatHost;
uint16 ChatPort; uint16 ChatPort;
// From <mailserver/> // From <mailserver/>
string MailHost; std::string MailHost;
uint16 MailPort; uint16 MailPort;
// From <database/> // From <database/>
string DatabaseHost; std::string DatabaseHost;
string DatabaseUsername; std::string DatabaseUsername;
string DatabasePassword; std::string DatabasePassword;
string DatabaseDB; std::string DatabaseDB;
uint16 DatabasePort; uint16 DatabasePort;
// From <qsdatabase> // QueryServ // From <qsdatabase> // QueryServ
string QSDatabaseHost; std::string QSDatabaseHost;
string QSDatabaseUsername; std::string QSDatabaseUsername;
string QSDatabasePassword; std::string QSDatabasePassword;
string QSDatabaseDB; std::string QSDatabaseDB;
uint16 QSDatabasePort; uint16 QSDatabasePort;
// From <files/> // From <files/>
string SpellsFile; std::string SpellsFile;
string OpCodesFile; std::string OpCodesFile;
string EQTimeFile; std::string EQTimeFile;
string LogSettingsFile; std::string LogSettingsFile;
// From <directories/> // From <directories/>
string MapDir; std::string MapDir;
string QuestDir; std::string QuestDir;
string PluginDir; std::string PluginDir;
// From <launcher/> // From <launcher/>
string LogPrefix; std::string LogPrefix;
string LogSuffix; std::string LogSuffix;
string ZoneExe; std::string ZoneExe;
uint32 RestartWait; uint32 RestartWait;
uint32 TerminateWait; uint32 TerminateWait;
uint32 InitialBootWait; uint32 InitialBootWait;
@ -108,7 +108,7 @@ protected:
static EQEmuConfig *_config; static EQEmuConfig *_config;
static string ConfigFile; static std::string ConfigFile;
#define ELEMENT(name) \ #define ELEMENT(name) \
void do_##name(TiXmlElement *ele); void do_##name(TiXmlElement *ele);
@ -210,7 +210,7 @@ public:
} }
// Allow the use to set the conf file to be used. // 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 // Load the config
static bool LoadConfig() { static bool LoadConfig() {

View File

@ -46,8 +46,6 @@
#include "../common/crc32.h" #include "../common/crc32.h"
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
using namespace std;
#define EQN_DEBUG 0 #define EQN_DEBUG 0
#define EQN_DEBUG_Error 0 #define EQN_DEBUG_Error 0
#define EQN_DEBUG_Packet 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( );) for (connection = connection_list.begin( ); connection != connection_list.end( );)
{ {
if(!connection->second) if(!connection->second)
{ {
map <string, EQStream*>::iterator tmp=connection; std::map <std::string, EQStream*>::iterator tmp=connection;
connection++; connection++;
connection_list.erase(tmp); connection_list.erase(tmp);
continue; continue;
} }
EQStream* eqs_data = connection->second; EQStream* eqs_data = connection->second;
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) { if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
map <string, EQStream*>::iterator tmp=connection; std::map <std::string, EQStream*>::iterator tmp=connection;
connection++; connection++;
safe_delete(eqs_data); safe_delete(eqs_data);
connection_list.erase(tmp); 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); sprintf(temp,"%lu:%u",(unsigned long)irIP,irPort);
cout << "Data from " << temp << endl; cout << "Data from " << temp << endl;
EQStream* tmp = NULL; EQStream* tmp = NULL;
map <string, EQStream*>::iterator connection; std::map <std::string, EQStream*>::iterator connection;
if ((connection=connection_list.find(temp))!=connection_list.end()) if ((connection=connection_list.find(temp))!=connection_list.end())
tmp=connection->second; tmp=connection->second;
if(tmp != NULL && tmp->GetrPort() == irPort) if(tmp != NULL && tmp->GetrPort() == irPort)

View File

@ -30,7 +30,6 @@
#include <map> #include <map>
#include <list> #include <list>
#include <queue> #include <queue>
using namespace std;
#include "../common/types.h" #include "../common/types.h"
#include "../common/timer.h" #include "../common/timer.h"
@ -114,8 +113,8 @@ private:
Mutex MNewQueue; Mutex MNewQueue;
Mutex MOpen; Mutex MOpen;
map<string,EQStream*> connection_list; std::map<std::string,EQStream*> connection_list;
queue<EQStream *> NewQueue; std::queue<EQStream *> NewQueue;
}; };
#endif #endif

View File

@ -32,8 +32,6 @@
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
using namespace std;
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len) EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len), : BasePacket(buf, len),
emu_opcode(op) emu_opcode(op)
@ -61,7 +59,7 @@ void EQPacket::build_header_dump(char *buffer) const {
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); 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 void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); 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 void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); 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 void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
{ {
if (src_ip) { if (src_ip) {
string sIP,dIP;; std::string sIP,dIP;;
sIP=long2ip(src_ip); sIP=long2ip(src_ip);
dIP=long2ip(dst_ip); dIP=long2ip(dst_ip);
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port); 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) { void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
if (iShowInfo) { if (iShowInfo) {
cout << "Dumping Applayer: 0x" << hex << setfill('0') << setw(4) << app->GetOpcode() << dec; std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
cout << " size:" << app->size << endl; std::cout << " size:" << app->size << std::endl;
} }
DumpPacketHex(app->pBuffer, app->size); DumpPacketHex(app->pBuffer, app->size);
// DumpPacketAscii(app->pBuffer, app->size); // DumpPacketAscii(app->pBuffer, app->size);

View File

@ -30,8 +30,6 @@
#include "emu_opcodes.h" #include "emu_opcodes.h"
#endif #endif
using namespace std;
class EQStream; class EQStream;
class EQStreamPair; class EQStreamPair;

View File

@ -424,7 +424,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
uint16 index = seq - SequencedBase; 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); _log(NET__NET_TRACE, _L " OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
if (index < sqsize) { if (index < sqsize) {
deque<EQProtocolPacket *>::iterator sitr; std::deque<EQProtocolPacket *>::iterator sitr;
sitr = SequencedQueue.begin(); sitr = SequencedQueue.begin();
sitr += index; sitr += index;
(*sitr)->acked = true; (*sitr)->acked = true;
@ -567,7 +567,7 @@ uint32 length;
while (used<length) { while (used<length) {
out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4); 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); memcpy(out->pBuffer+2,tmpbuff+used,chunksize);
out->size=chunksize+2; out->size=chunksize+2;
SequencedPush(out); SequencedPush(out);
@ -646,9 +646,9 @@ uint16 Seq=htons(seq);
void EQStream::Write(int eq_fd) void EQStream::Write(int eq_fd)
{ {
queue<EQProtocolPacket *> ReadyToSend; std::queue<EQProtocolPacket *> ReadyToSend;
bool SeqEmpty=false,NonSeqEmpty=false; bool SeqEmpty=false,NonSeqEmpty=false;
deque<EQProtocolPacket *>::iterator sitr; std::deque<EQProtocolPacket *>::iterator sitr;
// Check our rate to make sure we can send more // Check our rate to make sure we can send more
MRate.lock(); MRate.lock();
@ -951,7 +951,7 @@ EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin(); std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
p=*itr; p=*itr;
InboundQueue.erase(itr); InboundQueue.erase(itr);
} }
@ -979,7 +979,7 @@ EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin(); std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
p=*itr; p=*itr;
InboundQueue.erase(itr); InboundQueue.erase(itr);
} }
@ -1007,7 +1007,7 @@ EQRawApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (InboundQueue.size()) { if (InboundQueue.size()) {
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin(); std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
p=*itr; p=*itr;
} }
MInboundQueue.unlock(); MInboundQueue.unlock();
@ -1023,7 +1023,7 @@ EQApplicationPacket *p=nullptr;
MInboundQueue.lock(); MInboundQueue.lock();
if (!InboundQueue.empty()) { if (!InboundQueue.empty()) {
vector<EQRawApplicationPacket *>::iterator itr; std::vector<EQRawApplicationPacket *>::iterator itr;
for(itr=InboundQueue.begin();itr!=InboundQueue.end();itr++) { for(itr=InboundQueue.begin();itr!=InboundQueue.end();itr++) {
p=*itr; p=*itr;
delete p; delete p;
@ -1070,7 +1070,7 @@ EQProtocolPacket *p=nullptr;
NonSequencedQueue.pop(); NonSequencedQueue.pop();
} }
if(!SequencedQueue.empty()) { if(!SequencedQueue.empty()) {
deque<EQProtocolPacket *>::iterator itr; std::deque<EQProtocolPacket *>::iterator itr;
for(itr=SequencedQueue.begin();itr!=SequencedQueue.end();itr++) { for(itr=SequencedQueue.begin();itr!=SequencedQueue.end();itr++) {
p=*itr; p=*itr;
delete p; delete p;
@ -1095,7 +1095,7 @@ EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L); _log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
if(!PacketQueue.empty()) { if(!PacketQueue.empty()) {
map<unsigned short,EQProtocolPacket *>::iterator itr; std::map<unsigned short,EQProtocolPacket *>::iterator itr;
for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) { for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) {
p=itr->second; p=itr->second;
delete p; delete p;
@ -1149,7 +1149,7 @@ long EQStream::GetLastAckSent()
void EQStream::AckPackets(uint16 seq) void EQStream::AckPackets(uint16 seq)
{ {
deque<EQProtocolPacket *>::iterator itr, tmp; std::deque<EQProtocolPacket *>::iterator itr, tmp;
MOutboundQueue.lock(); MOutboundQueue.lock();
//do a bit of sanity checking. //do a bit of sanity checking.
@ -1234,7 +1234,7 @@ void EQStream::ProcessQueue()
EQProtocolPacket *EQStream::RemoveQueue(uint16 seq) EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
{ {
map<unsigned short,EQProtocolPacket *>::iterator itr; std::map<unsigned short,EQProtocolPacket *>::iterator itr;
EQProtocolPacket *qp=nullptr; EQProtocolPacket *qp=nullptr;
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) { if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
qp=itr->second; qp=itr->second;

View File

@ -18,8 +18,6 @@
#include "../common/Condition.h" #include "../common/Condition.h"
#include "../common/timer.h" #include "../common/timer.h"
using namespace std;
#define FLAG_COMPRESSED 0x01 #define FLAG_COMPRESSED 0x01
#define FLAG_ENCODED 0x04 #define FLAG_ENCODED 0x04
@ -113,8 +111,8 @@ class EQStream : public EQStreamInterface {
Mutex MAcks; Mutex MAcks;
// Packets waiting to be sent (all protected by MOutboundQueue) // Packets waiting to be sent (all protected by MOutboundQueue)
queue<EQProtocolPacket *> NonSequencedQueue; std::queue<EQProtocolPacket *> NonSequencedQueue;
deque<EQProtocolPacket *> SequencedQueue; std::deque<EQProtocolPacket *> SequencedQueue;
uint16 NextOutSeq; uint16 NextOutSeq;
uint16 SequencedBase; //the sequence number of SequencedQueue[0] uint16 SequencedBase; //the sequence number of SequencedQueue[0]
long NextSequencedSend; //index into SequencedQueue long NextSequencedSend; //index into SequencedQueue
@ -124,8 +122,8 @@ class EQStream : public EQStreamInterface {
unsigned char _tempBuffer[2048]; unsigned char _tempBuffer[2048];
// Packets waiting to be processed // Packets waiting to be processed
vector<EQRawApplicationPacket *> InboundQueue; std::vector<EQRawApplicationPacket *> InboundQueue;
map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process() std::map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
Mutex MInboundQueue; Mutex MInboundQueue;
static uint16 MaxWindowSize; static uint16 MaxWindowSize;

View File

@ -19,8 +19,6 @@
#include "EQStream.h" #include "EQStream.h"
#include "logsys.h" #include "logsys.h"
using namespace std;
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs) ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
{ {
EQStreamFactory *fs=(EQStreamFactory *)eqfs; EQStreamFactory *fs=(EQStreamFactory *)eqfs;
@ -146,7 +144,7 @@ void EQStreamFactory::Push(EQStream *s)
void EQStreamFactory::ReaderLoop() void EQStreamFactory::ReaderLoop()
{ {
fd_set readset; fd_set readset;
map<string,EQStream *>::iterator stream_itr; std::map<std::string,EQStream *>::iterator stream_itr;
int num; int num;
int length; int length;
unsigned char buffer[2048]; unsigned char buffer[2048];
@ -227,7 +225,7 @@ void EQStreamFactory::CheckTimeout()
MStreams.lock(); MStreams.lock();
unsigned long now=Timer::GetCurrentTime(); 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();) { for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
EQStream *s = stream_itr->second; EQStream *s = stream_itr->second;
@ -243,7 +241,7 @@ void EQStreamFactory::CheckTimeout()
} else { } else {
//everybody is done, we can delete it now //everybody is done, we can delete it now
//cout << "Removing connection" << endl; //cout << "Removing connection" << endl;
map<string,EQStream *>::iterator temp=stream_itr; std::map<std::string,EQStream *>::iterator temp=stream_itr;
stream_itr++; stream_itr++;
//let whoever has the stream outside delete it //let whoever has the stream outside delete it
delete temp->second; delete temp->second;
@ -259,10 +257,10 @@ void EQStreamFactory::CheckTimeout()
void EQStreamFactory::WriterLoop() void EQStreamFactory::WriterLoop()
{ {
map<string,EQStream *>::iterator stream_itr; std::map<std::string,EQStream *>::iterator stream_itr;
bool havework=true; bool havework=true;
vector<EQStream *> wants_write; std::vector<EQStream *> wants_write;
vector<EQStream *>::iterator cur,end; std::vector<EQStream *>::iterator cur,end;
bool decay=false; bool decay=false;
uint32 stream_count; uint32 stream_count;

View File

@ -24,10 +24,10 @@ class EQStreamFactory : private Timeoutable {
EQStreamType StreamType; EQStreamType StreamType;
queue<EQStream *> NewStreams; std::queue<EQStream *> NewStreams;
Mutex MNewStreams; Mutex MNewStreams;
map<string,EQStream *> Streams; std::map<std::string,EQStream *> Streams;
Mutex MStreams; Mutex MStreams;
virtual void CheckTimeout(); virtual void CheckTimeout();

View File

@ -3,14 +3,12 @@
#include "EQStreamProxy.h" #include "EQStreamProxy.h"
#include "logsys.h" #include "logsys.h"
using namespace std;
EQStreamIdentifier::~EQStreamIdentifier() { EQStreamIdentifier::~EQStreamIdentifier() {
while(!m_identified.empty()) { while(!m_identified.empty()) {
m_identified.front()->ReleaseFromUse(); m_identified.front()->ReleaseFromUse();
m_identified.pop(); m_identified.pop();
} }
vector<Record *>::iterator cur, end; std::vector<Record *>::iterator cur, end;
cur = m_streams.begin(); cur = m_streams.begin();
end = m_streams.end(); end = m_streams.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@ -18,7 +16,7 @@ EQStreamIdentifier::~EQStreamIdentifier() {
r->stream->ReleaseFromUse(); r->stream->ReleaseFromUse();
delete r; delete r;
} }
vector<Patch *>::iterator curp, endp; std::vector<Patch *>::iterator curp, endp;
curp = m_patches.begin(); curp = m_patches.begin();
endp = m_patches.end(); endp = m_patches.end();
for(; curp != endp; curp++) { for(; curp != endp; curp++) {
@ -36,8 +34,8 @@ void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const cha
} }
void EQStreamIdentifier::Process() { void EQStreamIdentifier::Process() {
vector<Record *>::iterator cur; std::vector<Record *>::iterator cur;
vector<Patch *>::iterator curp, endp; std::vector<Patch *>::iterator curp, endp;
//foreach pending stream. //foreach pending stream.
cur = m_streams.begin(); cur = m_streams.begin();

View File

@ -24,7 +24,6 @@ This did not turn out nearly as nice as I hoped.
#include <map> #include <map>
#include <string> #include <string>
using namespace std;
class EQStreamInfo { class EQStreamInfo {
public: public:
@ -103,7 +102,7 @@ inline bool operator==(const EQStreamInfo &l, const EQStreamInfo &r) {
template <class T> template <class T>
class EQStreamLocator { class EQStreamLocator {
protected: protected:
typedef typename map<const EQStreamInfo, T *>::iterator iterator; typedef typename std::map<const EQStreamInfo, T *>::iterator iterator;
public: public:
void Clear() { void Clear() {
@ -167,7 +166,7 @@ public:
// inline iterator end() const { return(streams.end()); } // inline iterator end() const { return(streams.end()); }
protected: protected:
map<const EQStreamInfo, T *> streams; std::map<const EQStreamInfo, T *> streams;
}; };
#endif #endif

View File

@ -26,11 +26,9 @@ tremendously.
#include "../common/debug.h" #include "../common/debug.h"
#include <iostream> #include <iostream>
using namespace std;
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>
using namespace std;
#include "EmuTCPConnection.h" #include "EmuTCPConnection.h"
#include "EmuTCPServer.h" #include "EmuTCPServer.h"
@ -93,7 +91,7 @@ EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer,
TCPMode = iMode; TCPMode = iMode;
PacketMode = packetModeZone; PacketMode = packetModeZone;
#if TCPN_DEBUG_Memory >= 7 #if TCPN_DEBUG_Memory >= 7
cout << "Constructor #1 on outgoing TCP# " << GetID() << endl; std::cout << "Constructor #1 on outgoing TCP# " << GetID() << std::endl;
#endif #endif
} }
@ -113,7 +111,7 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConne
TCPMode = modePacket; TCPMode = modePacket;
PacketMode = packetModeZone; PacketMode = packetModeZone;
#if TCPN_DEBUG_Memory >= 7 #if TCPN_DEBUG_Memory >= 7
cout << "Constructor #3 on outgoing TCP# " << GetID() << endl; std::cout << "Constructor #3 on outgoing TCP# " << GetID() << std::endl;
#endif #endif
} }
@ -173,7 +171,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); 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 TCPN_LOG_PACKETS == 2
if (pack->size >= 32) if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32); DumpPacket(pack->pBuffer, 32);
@ -200,7 +198,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); 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 TCPN_LOG_PACKETS == 2
if (pack->size >= 32) if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32); DumpPacket(pack->pBuffer, 32);
@ -239,10 +237,10 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); 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) if (pOldFormat)
cout << " (OldFormat)"; std::cout << " (OldFormat)";
cout << endl; std::cout << std::endl;
#if TCPN_LOG_PACKETS == 2 #if TCPN_LOG_PACKETS == 2
if (tnps->size >= 32) if (tnps->size >= 32)
DumpPacket((uchar*) tnps, 32); DumpPacket((uchar*) tnps, 32);
@ -284,7 +282,7 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
#if defined(GOTFRAGS) && 0 #if defined(GOTFRAGS) && 0
if (strcmp(line, "**CRASHME**") == 0) { if (strcmp(line, "**CRASHME**") == 0) {
int i = 0; int i = 0;
cout << (5 / i) << endl; std::cout << (5 / i) << std::endl;
} }
#endif #endif
if(line[0] == '*') { if(line[0] == '*') {
@ -456,10 +454,10 @@ void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
#if TCPC_DEBUG >= 1 #if TCPC_DEBUG >= 1
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
cout "NetError: '"; std::cout "NetError: '";
if (reason) if (reason)
cout << reason; std::cout << reason;
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl; std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif #endif
ServerPacket* pack = new ServerPacket(0); ServerPacket* pack = new ServerPacket(0);
pack->size = 1; pack->size = 1;
@ -522,7 +520,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
size = tnps->size; size = tnps->size;
if (size >= MaxTCPReceiveBuffferSize) { if (size >= MaxTCPReceiveBuffferSize) {
#if TCPN_DEBUG_Memory >= 1 #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); DumpPacket(&recvbuf[base], 16);
#endif #endif
if (errbuf) if (errbuf)
@ -562,13 +560,13 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
if (pack->opcode == 0) { if (pack->opcode == 0) {
if (pack->size) { if (pack->size) {
#if TCPN_DEBUG >= 2 #if TCPN_DEBUG >= 2
cout << "Received TCP Network layer packet" << endl; std::cout << "Received TCP Network layer packet" << std::endl;
#endif #endif
ProcessNetworkLayerPacket(pack); ProcessNetworkLayerPacket(pack);
} }
#if TCPN_DEBUG >= 5 #if TCPN_DEBUG >= 5
else { else {
cout << "Received TCP keepalive packet. (opcode=0)" << endl; std::cout << "Received TCP keepalive packet. (opcode=0)" << std::endl;
} }
#endif #endif
// keepalive, no need to process // keepalive, no need to process
@ -580,7 +578,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); 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 TCPN_LOG_PACKETS == 2
if (pack->size >= 32) if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32); DumpPacket(pack->pBuffer, 32);
@ -596,7 +594,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
EmuTCPConnection* con = Server->FindConnection(pack->destination); EmuTCPConnection* con = Server->FindConnection(pack->destination);
if (!con) { if (!con) {
#if TCPN_DEBUG >= 1 #if TCPN_DEBUG >= 1
cout << "Error relaying packet: con = 0" << endl; std::cout << "Error relaying packet: con = 0" << std::endl;
#endif #endif
safe_delete(pack); safe_delete(pack);
} }
@ -635,7 +633,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
memcpy(&size, &buffer[2], 2); memcpy(&size, &buffer[2], 2);
if (size >= MaxTCPReceiveBuffferSize) { if (size >= MaxTCPReceiveBuffferSize) {
#if TCPN_DEBUG_Memory >= 1 #if TCPN_DEBUG_Memory >= 1
cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << endl; std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
#endif #endif
if (errbuf) if (errbuf)
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize"); snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
@ -665,7 +663,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); 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 TCPN_LOG_PACKETS == 2
if (pack->size >= 32) if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32); DumpPacket(pack->pBuffer, 32);
@ -726,7 +724,7 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
#if TCPC_DEBUG >= 3 #if TCPC_DEBUG >= 3
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); 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 #endif
RelayServer = true; RelayServer = true;
break; break;
@ -774,10 +772,10 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
#if TCPC_DEBUG >= 1 #if TCPC_DEBUG >= 1
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
cout "Received NetError: '"; std::cout "Received NetError: '";
if (pack->size > 1) if (pack->size > 1)
cout << (char*) data; std::cout << (char*) data;
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl; std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
#endif #endif
break; break;
} }
@ -796,7 +794,7 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
SendPacket(pack); SendPacket(pack);
safe_delete(pack); safe_delete(pack);
#if TCPN_DEBUG >= 5 #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 #endif
} }

View File

@ -15,13 +15,13 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "../common/debug.h"
#include "../common/StringUtil.h"
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include <limits>
#include <limits.h> #include "debug.h"
#include "StringUtil.h"
#include "Item.h" #include "Item.h"
#include "database.h" #include "database.h"
#include "misc.h" #include "misc.h"
@ -29,8 +29,6 @@
#include "shareddb.h" #include "shareddb.h"
#include "classes.h" #include "classes.h"
using namespace std;
int32 NextItemInstSerialNumber = 1; int32 NextItemInstSerialNumber = 1;
static inline int32 GetNextItemInstSerialNumber() { static inline int32 GetNextItemInstSerialNumber() {
@ -45,7 +43,7 @@ static inline int32 GetNextItemInstSerialNumber() {
// NextItemInstSerialNumber is the next one to hand out. // NextItemInstSerialNumber is the next one to hand out.
// //
// It is very unlikely to reach 2,147,483,647. Maybe we should call abort(), rather than wrapping back to 1. // It is very unlikely to reach 2,147,483,647. Maybe we should call abort(), rather than wrapping back to 1.
if(NextItemInstSerialNumber >= INT_MAX) if(NextItemInstSerialNumber >= std::numeric_limits<uint32>::max())
NextItemInstSerialNumber = 1; NextItemInstSerialNumber = 1;
else else
NextItemInstSerialNumber++; NextItemInstSerialNumber++;
@ -95,7 +93,7 @@ ItemInstQueue::~ItemInstQueue() {
} }
Inventory::~Inventory() { Inventory::~Inventory() {
map<int16, ItemInst*>::iterator cur,end; std::map<int16, ItemInst*>::iterator cur,end;
cur = m_worn.begin(); cur = m_worn.begin();
@ -573,7 +571,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
std::string ItemInst::GetCustomDataString() const { std::string ItemInst::GetCustomDataString() const {
std::string ret_val; 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()) { while(iter != m_custom_data.end()) {
if(ret_val.length() > 0) { if(ret_val.length() > 0) {
ret_val += "^"; ret_val += "^";
@ -617,14 +615,14 @@ void ItemInst::SetCustomData(std::string identifier, bool value) {
} }
void ItemInst::DeleteCustomData(std::string identifier) { 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()) { if(iter != m_custom_data.end()) {
m_custom_data.erase(iter); m_custom_data.erase(iter);
} }
} }
std::string ItemInst::GetCustomData(std::string identifier) { 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()) { if(iter != m_custom_data.end()) {
return iter->second; return iter->second;
} }
@ -1053,27 +1051,7 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
return SLOT_INVALID; return SLOT_INVALID;
} }
void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) { void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection) {
iter_contents itb;
if (!inst || !inst->IsType(ItemClassContainer))
return;
// Go through bag, if bag
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem())
continue;
std::string subSlot;
StringFormat(subSlot," Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
std::cout << subSlot << std::endl;
}
}
void Inventory::dumpItemCollection(const map<int16, ItemInst*> &collection) {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = nullptr; ItemInst* inst = nullptr;
@ -1084,7 +1062,7 @@ void Inventory::dumpItemCollection(const map<int16, ItemInst*> &collection) {
if(!inst || !inst->GetItem()) if(!inst || !inst->GetItem())
continue; continue;
std:string slot; std::string slot;
StringFormat(slot, "Slot %d: %s (%d)",it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); StringFormat(slot, "Slot %d: %s (%d)",it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
std::cout << slot << std::endl; std::cout << slot << std::endl;
@ -1125,7 +1103,7 @@ void Inventory::dumpEntireInventory() {
} }
// Internal Method: Retrieves item within an inventory bucket // 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); iter_inst it = bucket.find(slot_id);
if (it != bucket.end()) { if (it != bucket.end()) {
@ -1193,7 +1171,7 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
} }
// Internal Method: Checks an inventory bucket for a particular item // 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_inst it;
iter_contents itb; iter_contents itb;
@ -1283,7 +1261,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
} }
// Internal Method: Checks an inventory bucket for a particular item // 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_inst it;
iter_contents itb; iter_contents itb;
@ -1351,7 +1329,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
return SLOT_INVALID; 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_inst it;
iter_contents itb; iter_contents itb;

View File

@ -34,15 +34,14 @@ class EvolveInfo; // Stores information about an evolving item family
#include <vector> #include <vector>
#include <map> #include <map>
#include <list> #include <list>
using namespace std;
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
#include "../common/eq_constants.h" #include "../common/eq_constants.h"
#include "../common/item_struct.h" #include "../common/item_struct.h"
// Helper typedefs // Helper typedefs
typedef list<ItemInst*>::const_iterator iter_queue; typedef std::list<ItemInst*>::const_iterator iter_queue;
typedef map<int16, ItemInst*>::const_iterator iter_inst; typedef std::map<int16, ItemInst*>::const_iterator iter_inst;
typedef map<uint8, ItemInst*>::const_iterator iter_contents; typedef std::map<uint8, ItemInst*>::const_iterator iter_contents;
namespace ItemField { namespace ItemField {
enum { enum {
@ -120,7 +119,7 @@ protected:
// Protected Members // Protected Members
///////////////////////// /////////////////////////
list<ItemInst*> m_list; std::list<ItemInst*> m_list;
}; };
@ -212,30 +211,30 @@ protected:
// Protected Methods // Protected Methods
/////////////////////////////// ///////////////////////////////
void dumpItemCollection(const map<int16, ItemInst*> &collection); void dumpItemCollection(const std::map<int16, ItemInst*> &collection);
void dumpBagContents(ItemInst *inst, iter_inst *it); void dumpBagContents(ItemInst *inst, iter_inst *it);
// Retrieves item within an inventory bucket // 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 // Private "put" item into bucket, without regard for what is currently in bucket
int16 _PutItem(int16 slot_id, ItemInst* inst); int16 _PutItem(int16 slot_id, ItemInst* inst);
// Checks an inventory bucket for a particular item // 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 _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 _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); int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
// Player inventory // Player inventory
map<int16, ItemInst*> m_worn; // Items worn by character std::map<int16, ItemInst*> m_worn; // Items worn by character
map<int16, ItemInst*> m_inv; // Items in character personal inventory std::map<int16, ItemInst*> m_inv; // Items in character personal inventory
map<int16, ItemInst*> m_bank; // Items in character bank std::map<int16, ItemInst*> m_bank; // Items in character bank
map<int16, ItemInst*> m_shbank; // Items in character shared bank std::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_trade; // Items in a trade session
ItemInstQueue m_cursor; // Items on cursor: FIFO ItemInstQueue m_cursor; // Items on cursor: FIFO
}; };
@ -307,7 +306,7 @@ public:
uint8 FirstOpenSlot() const; uint8 FirstOpenSlot() const;
uint8 GetTotalItemCount() const; uint8 GetTotalItemCount() const;
bool IsNoneEmptyContainer(); bool IsNoneEmptyContainer();
map<uint8, ItemInst*>* GetContents() { return &m_contents; } std::map<uint8, ItemInst*>* GetContents() { return &m_contents; }
// //
// Augments // Augments
@ -378,7 +377,7 @@ public:
virtual bool IsScaling() const { return false; } virtual bool IsScaling() const { return false; }
virtual bool IsEvolving() 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 int32 GetSerialNumber() const { return m_SerialNumber; }
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; } inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
@ -406,8 +405,8 @@ protected:
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar. int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
// //
// Items inside of this item (augs or contents); // Items inside of this item (augs or contents);
map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9 std::map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
map<std::string, std::string> m_custom_data; std::map<std::string, std::string> m_custom_data;
}; };
class EvoItemInst: public ItemInst { class EvoItemInst: public ItemInst {

View File

@ -32,8 +32,6 @@
#include "../common/timer.h" #include "../common/timer.h"
#include "../common/seperator.h" #include "../common/seperator.h"
using namespace std;
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
@ -79,10 +77,10 @@ void CoutTimestamp(bool ms) {
struct timeval read_time; struct timeval read_time;
gettimeofday(&read_time,0); 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) if (ms)
cout << "." << setw(3) << setfill('0') << (read_time.tv_usec / 1000); std::cout << "." << std::setw(3) << std::setfill('0') << (read_time.tv_usec / 1000);
cout << " GMT"; std::cout << " GMT";
} }

View File

@ -19,7 +19,6 @@
#include "../common/Mutex.h" #include "../common/Mutex.h"
#include <iostream> #include <iostream>
using namespace std;
#define DEBUG_MUTEX_CLASS 0 #define DEBUG_MUTEX_CLASS 0
#if DEBUG_MUTEX_CLASS >= 1 #if DEBUG_MUTEX_CLASS >= 1
@ -43,7 +42,7 @@ bool IsTryLockSupported() {
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) { if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) {
#if DEBUG_MUTEX_CLASS >= 1 #if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() NOT supported" << endl; std::cout << "Mutex::trylock() NOT supported" << std::endl;
#endif #endif
return false; return false;
} }
@ -52,13 +51,13 @@ bool IsTryLockSupported() {
// Tests for Windows NT product family. // Tests for Windows NT product family.
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 4) { if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 4) {
#if DEBUG_MUTEX_CLASS >= 1 #if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() SUPPORTED" << endl; std::cout << "Mutex::trylock() SUPPORTED" << std::endl;
#endif #endif
return true; return true;
} }
else { else {
#if DEBUG_MUTEX_CLASS >= 1 #if DEBUG_MUTEX_CLASS >= 1
cout << "Mutex::trylock() NOT supported" << endl; std::cout << "Mutex::trylock() NOT supported" << std::endl;
#endif #endif
return false; return false;
} }
@ -68,7 +67,7 @@ bool IsTryLockSupported() {
Mutex::Mutex() { Mutex::Mutex() {
#if DEBUG_MUTEX_CLASS >= 7 #if DEBUG_MUTEX_CLASS >= 7
cout << "Constructing Mutex" << endl; std::cout << "Constructing Mutex" << std::endl;
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
InitializeCriticalSection(&CSMutex); InitializeCriticalSection(&CSMutex);
@ -87,7 +86,7 @@ Mutex::Mutex() {
Mutex::~Mutex() { Mutex::~Mutex() {
#if DEBUG_MUTEX_CLASS >= 7 #if DEBUG_MUTEX_CLASS >= 7
cout << "Deconstructing Mutex" << endl; std::cout << "Deconstructing Mutex" << std::endl;
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
DeleteCriticalSection(&CSMutex); DeleteCriticalSection(&CSMutex);
@ -99,11 +98,11 @@ Mutex::~Mutex() {
void Mutex::lock() { void Mutex::lock() {
_CP(Mutex_lock); _CP(Mutex_lock);
#if DEBUG_MUTEX_CLASS >= 9 #if DEBUG_MUTEX_CLASS >= 9
cout << "Locking Mutex" << endl; std::cout << "Locking Mutex" << std::endl;
#endif #endif
#if DEBUG_MUTEX_CLASS >= 5 #if DEBUG_MUTEX_CLASS >= 5
if (!trylock()) { if (!trylock()) {
cout << "Locking Mutex: Having to wait" << endl; std::cout << "Locking Mutex: Having to wait" << std::endl;
#ifdef _WINDOWS #ifdef _WINDOWS
EnterCriticalSection(&CSMutex); EnterCriticalSection(&CSMutex);
#else #else
@ -121,7 +120,7 @@ void Mutex::lock() {
bool Mutex::trylock() { bool Mutex::trylock() {
#if DEBUG_MUTEX_CLASS >= 9 #if DEBUG_MUTEX_CLASS >= 9
cout << "TryLocking Mutex" << endl; std::cout << "TryLocking Mutex" << std::endl;
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
#if(_WIN32_WINNT >= 0x0400) #if(_WIN32_WINNT >= 0x0400)
@ -142,7 +141,7 @@ bool Mutex::trylock() {
void Mutex::unlock() { void Mutex::unlock() {
#if DEBUG_MUTEX_CLASS >= 9 #if DEBUG_MUTEX_CLASS >= 9
cout << "Unlocking Mutex" << endl; std::cout << "Unlocking Mutex" << std::endl;
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
LeaveCriticalSection(&CSMutex); LeaveCriticalSection(&CSMutex);
@ -188,7 +187,7 @@ MRMutex::MRMutex() {
MRMutex::~MRMutex() { MRMutex::~MRMutex() {
#ifdef _EQDEBUG #ifdef _EQDEBUG
if (wl || rl) { 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 #endif
} }

View File

@ -32,8 +32,6 @@
#include <string.h> #include <string.h>
#endif #endif
using namespace std;
ProcLauncher ProcLauncher::s_launcher; ProcLauncher ProcLauncher::s_launcher;
#ifdef _WINDOWS #ifdef _WINDOWS
@ -51,10 +49,9 @@ ProcLauncher::ProcLauncher()
#endif #endif
} }
void ProcLauncher::Process() { void ProcLauncher::Process() {
#ifdef _WINDOWS #ifdef _WINDOWS
map<ProcRef, Spec *>::iterator cur, end, tmp; std::map<ProcRef, Spec *>::iterator cur, end, tmp;
cur = m_running.begin(); cur = m_running.begin();
end = m_running.end(); end = m_running.end();
while(cur != end) { while(cur != end) {
@ -91,7 +88,7 @@ void ProcLauncher::Process() {
break; break;
} else { } else {
//one died... //one died...
map<ProcRef, Spec *>::iterator ref; std::map<ProcRef, Spec *>::iterator ref;
ref = m_running.find(died); ref = m_running.find(died);
if(ref == m_running.end()) { if(ref == m_running.end()) {
//unable to find this process in our list... //unable to find this process in our list...

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. //effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory { namespace StructStrategyFactory {
static map<EmuOpcode, const StructStrategy *> strategies; static std::map<EmuOpcode, const StructStrategy *> strategies;
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) { void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
strategies[first_opcode] = structs; strategies[first_opcode] = structs;
} }
const StructStrategy *FindPatch(EmuOpcode first_opcode) { 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); res = strategies.find(first_opcode);
if(res == strategies.end()) if(res == strategies.end())
return(nullptr); return(nullptr);

View File

@ -18,11 +18,9 @@
#include "../common/debug.h" #include "../common/debug.h"
#include <iostream> #include <iostream>
using namespace std;
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>
using namespace std;
#include "TCPConnection.h" #include "TCPConnection.h"
#include "../common/servertalk.h" #include "../common/servertalk.h"
@ -63,7 +61,7 @@ TCPConnection::TCPConnection()
pAsyncConnect = false; pAsyncConnect = false;
m_previousLineEnd = false; m_previousLineEnd = false;
#if TCPN_DEBUG_Memory >= 7 #if TCPN_DEBUG_Memory >= 7
cout << "Constructor #2 on outgoing TCP# " << GetID() << endl; std::cout << "Constructor #2 on outgoing TCP# " << GetID() << std::endl;
#endif #endif
} }
@ -85,7 +83,7 @@ TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 ir
pAsyncConnect = false; pAsyncConnect = false;
m_previousLineEnd = false; m_previousLineEnd = false;
#if TCPN_DEBUG_Memory >= 7 #if TCPN_DEBUG_Memory >= 7
cout << "Constructor #2 on incoming TCP# " << GetID() << endl; std::cout << "Constructor #2 on incoming TCP# " << GetID() << std::endl;
#endif #endif
} }
@ -99,12 +97,12 @@ TCPConnection::~TCPConnection() {
MLoopRunning.lock(); MLoopRunning.lock();
MLoopRunning.unlock(); MLoopRunning.unlock();
#if TCPN_DEBUG_Memory >= 6 #if TCPN_DEBUG_Memory >= 6
cout << "Deconstructor on outgoing TCP# " << GetID() << endl; std::cout << "Deconstructor on outgoing TCP# " << GetID() << std::endl;
#endif #endif
} }
#if TCPN_DEBUG_Memory >= 5 #if TCPN_DEBUG_Memory >= 5
else { else {
cout << "Deconstructor on incomming TCP# " << GetID() << endl; std::cout << "Deconstructor on incomming TCP# " << GetID() << std::endl;
} }
#endif #endif
safe_delete_array(recvbuf); safe_delete_array(recvbuf);
@ -587,7 +585,7 @@ bool TCPConnection::Process() {
if (!SendData(sent_something, errbuf)) { if (!SendData(sent_something, errbuf)) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl; std::cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << std::endl;
return false; return false;
} }
@ -628,8 +626,8 @@ bool TCPConnection::RecvData(char* errbuf) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort(); std::cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort();
cout << endl; std::cout << std::endl;
#if TCPN_LOG_RAW_DATA_IN == 2 #if TCPN_LOG_RAW_DATA_IN == 2
int32 tmp = status; int32 tmp = status;
if (tmp > 32) if (tmp > 32)
@ -683,7 +681,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
return true; return true;
#if TCPN_DEBUG_Console >= 4 #if TCPN_DEBUG_Console >= 4
if (recvbuf_used) { if (recvbuf_used) {
cout << "Starting Processing: recvbuf=" << recvbuf_used << endl; std::cout << "Starting Processing: recvbuf=" << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used); DumpPacket(recvbuf, recvbuf_used);
} }
#endif #endif
@ -715,13 +713,13 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
} }
} }
#if TCPN_DEBUG_Console >= 5 #if TCPN_DEBUG_Console >= 5
cout << "Removed 0x00" << endl; std::cout << "Removed 0x00" << std::endl;
if (recvbuf_used) { if (recvbuf_used) {
cout << "recvbuf left: " << recvbuf_used << endl; std::cout << "recvbuf left: " << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used); DumpPacket(recvbuf, recvbuf_used);
} }
else else
cout << "recbuf left: None" << endl; std::cout << "recbuf left: None" << std::endl;
#endif #endif
m_previousLineEnd = false; m_previousLineEnd = false;
break; break;
@ -748,7 +746,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
memset(line, 0, i+1); memset(line, 0, i+1);
memcpy(line, recvbuf, i); memcpy(line, recvbuf, i);
#if TCPN_DEBUG_Console >= 3 #if TCPN_DEBUG_Console >= 3
cout << "Line Out: " << endl; std::cout << "Line Out: " << std::endl;
DumpPacket((uchar*) line, i); DumpPacket((uchar*) line, i);
#endif #endif
//line[i] = 0; //line[i] = 0;
@ -758,13 +756,13 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
recvbuf_echo -= i+1; recvbuf_echo -= i+1;
memcpy(recvbuf, &tmpdel[i+1], recvbuf_used); memcpy(recvbuf, &tmpdel[i+1], recvbuf_used);
#if TCPN_DEBUG_Console >= 5 #if TCPN_DEBUG_Console >= 5
cout << "i+1=" << i+1 << endl; std::cout << "i+1=" << i+1 << std::endl;
if (recvbuf_used) { if (recvbuf_used) {
cout << "recvbuf left: " << recvbuf_used << endl; std::cout << "recvbuf left: " << recvbuf_used << std::endl;
DumpPacket(recvbuf, recvbuf_used); DumpPacket(recvbuf, recvbuf_used);
} }
else else
cout << "recbuf left: None" << endl; std::cout << "recbuf left: None" << std::endl;
#endif #endif
safe_delete_array(tmpdel); safe_delete_array(tmpdel);
i = -1; i = -1;
@ -829,8 +827,8 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort(); std::cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort();
cout << endl; std::cout << std::endl;
#if TCPN_LOG_RAW_DATA_OUT == 2 #if TCPN_LOG_RAW_DATA_OUT == 2
int32 tmp = status; int32 tmp = status;
if (tmp > 32) if (tmp > 32)
@ -846,8 +844,8 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
CoutTimestamp(true); CoutTimestamp(true);
cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort(); std::cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort();
cout << endl; std::cout << std::endl;
#endif #endif
// If there's network congestion, the number of bytes sent can be less than // 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 // what we tried to give it... Push the extra back on the queue for later

View File

@ -23,7 +23,7 @@ XMLParser::XMLParser() {
} }
bool XMLParser::ParseFile(const char *file, const char *root_ele) { 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 ); TiXmlDocument doc( file );
if(!doc.LoadFile()) { if(!doc.LoadFile()) {
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc()); printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());

View File

@ -24,9 +24,6 @@
#include <string> #include <string>
#include <map> #include <map>
using namespace std;
/* /*
* See note in XMLParser::ParseFile() before inheriting this class. * 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 *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false);
const char *GetText(TiXmlNode *within, bool optional = false); const char *GetText(TiXmlNode *within, bool optional = false);
map<string,ElementHandler> Handlers; std::map<std::string,ElementHandler> Handlers;
bool ParseOkay; bool ParseOkay;
}; };
#endif #endif

View File

@ -18,7 +18,6 @@
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/rulesys.h" #include "../common/rulesys.h"
#include <iostream> #include <iostream>
using namespace std;
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -194,7 +193,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, int16* oStat
} }
else else
{ {
cerr << "Error in CheckLogin query '" << query << "' " << errbuf << endl; std::cerr << "Error in CheckLogin query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
@ -228,7 +227,7 @@ bool Database::CheckBannedIPs(const char* loginIP)
} }
else else
{ {
cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << endl; std::cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return true; return true;
} }
@ -241,7 +240,7 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes)
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes), errbuf)) { 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); safe_delete_array(query);
return false; return false;
} }
@ -291,7 +290,7 @@ void Database::LoginIP(uint32 AccountID, const char* LoginIP)
char *query = 0; 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)) { 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); safe_delete_array(query);
} }
@ -334,7 +333,7 @@ int16 Database::CheckStatus(uint32 account_id)
} }
else else
{ {
cerr << "Error in CheckStatus query '" << query << "' " << errbuf << endl; std::cerr << "Error in CheckStatus query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
@ -353,16 +352,16 @@ uint32 Database::CreateAccount(const char* name, const char* password, int16 sta
else else
querylen = MakeAnyLenString(&query, "INSERT INTO account SET name='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name, status, lsaccount_id); 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)) { 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); safe_delete_array(query);
return 0; return 0;
} }
safe_delete_array(query); safe_delete_array(query);
if (last_insert_id == 0) { 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; return 0;
} }
@ -374,7 +373,7 @@ bool Database::DeleteAccount(const char* name) {
char *query = 0; char *query = 0;
uint32 affected_rows = 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)) { if (RunQuery(query, MakeAnyLenString(&query, "DELETE FROM account WHERE name='%s';",name), errbuf, 0, &affected_rows)) {
safe_delete_array(query); safe_delete_array(query);
if (affected_rows == 1) { if (affected_rows == 1) {
@ -383,7 +382,7 @@ bool Database::DeleteAccount(const char* name) {
} }
else { else {
cerr << "Error in DeleteAccount query '" << query << "' " << errbuf << endl; std::cerr << "Error in DeleteAccount query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
@ -395,7 +394,7 @@ bool Database::SetLocalPassword(uint32 accid, const char* password) {
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET password=MD5('%s') where id=%i;", password, accid), errbuf)) { 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); safe_delete_array(query);
return false; return false;
} }
@ -409,7 +408,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
char *query = 0; char *query = 0;
uint32 affected_rows = 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)) { if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET status=%i WHERE name='%s';", status, name), errbuf, 0, &affected_rows)) {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
@ -417,7 +416,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
safe_delete_array(query); safe_delete_array(query);
if (affected_rows == 0) { 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; return false;
} }
@ -430,7 +429,7 @@ bool Database::ReserveName(uint32 account_id, char* name)
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=NULL", account_id, name), errbuf)) { if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=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); safe_delete_array(query);
return false; return false;
} }
@ -878,7 +877,7 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
@ -941,7 +940,7 @@ uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32*
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in GetAccountIDByAcc query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetAccountIDByAcc query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
@ -969,7 +968,7 @@ void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID
} }
else { else {
safe_delete_array(query); safe_delete_array(query);
cerr << "Error in GetAccountName query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetAccountName query '" << query << "' " << errbuf << std::endl;
} }
} }
@ -991,7 +990,7 @@ void Database::GetCharName(uint32 char_id, char* name) {
} }
else { else {
safe_delete_array(query); safe_delete_array(query);
cerr << "Error in GetCharName query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetCharName query '" << query << "' " << errbuf << std::endl;
} }
} }
@ -1008,7 +1007,7 @@ bool Database::LoadVariables() {
return ret; return ret;
} }
else { else {
cerr << "Error in LoadVariables query '" << query << "' " << errbuf << endl; std::cerr << "Error in LoadVariables query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
return false; return false;
@ -1131,7 +1130,7 @@ bool Database::SetVariable(const char* varname_in, const char* varvalue_in) {
} }
} }
else { else {
cerr << "Error in SetVariable query '" << query << "' " << errbuf << endl; std::cerr << "Error in SetVariable query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
free(varname); free(varname);
@ -1153,7 +1152,7 @@ uint32 Database::GetMiniLoginAccount(char* ip){
} }
else else
{ {
cerr << "Error in GetMiniLoginAccount query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetMiniLoginAccount query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
return retid; return retid;
@ -1195,11 +1194,11 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe
} }
else else
{ {
cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << std::endl;
cerr << "If it errors, run the following querys:\n"; std::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"; std::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"; std::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 << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n";
safe_delete_array(query); safe_delete_array(query);
} }
@ -1244,7 +1243,7 @@ bool Database::GetZoneLongName(const char* short_name, char** long_name, char* f
} }
else else
{ {
cerr << "Error in GetZoneLongName query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetZoneLongName query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
@ -1270,7 +1269,7 @@ uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) {
} }
else else
{ {
cerr << "Error in GetZoneGraveyardID query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetZoneGraveyardID query '" << query << "' " << errbuf << std::endl;
} }
safe_delete_array(query); safe_delete_array(query);
return GraveyardID; return GraveyardID;
@ -1304,7 +1303,7 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon
} }
else else
{ {
cerr << "Error in GetZoneGraveyard query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetZoneGraveyard query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
@ -1343,7 +1342,7 @@ bool Database::LoadZoneNames() {
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << endl; std::cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
@ -1353,7 +1352,7 @@ bool Database::LoadZoneNames() {
} }
} }
else { else {
cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << endl; std::cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
@ -1420,7 +1419,7 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
} }
else else
{ {
cerr << "Error in GetPEQZone query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetPEQZone query '" << query << "' " << errbuf << std::endl;
} }
safe_delete_array(query); safe_delete_array(query);
return peqzone; return peqzone;
@ -1504,7 +1503,7 @@ bool Database::CheckNameFilter(const char* name, bool surname)
} }
else else
{ {
cerr << "Error in CheckNameFilter query '" << query << "' " << errbuf << endl; std::cerr << "Error in CheckNameFilter query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
@ -1517,7 +1516,7 @@ bool Database::AddToNameFilter(const char* name) {
uint32 affected_rows = 0; uint32 affected_rows = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO name_filter (name) values ('%s')", name), errbuf, 0, &affected_rows)) { 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); safe_delete_array(query);
return false; return false;
} }
@ -1558,7 +1557,7 @@ uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* o
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return 0; return 0;
} }
@ -1584,7 +1583,7 @@ void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
mysql_free_result(result); mysql_free_result(result);
} }
else else
cerr << "Error in GetAccountFromID query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetAccountFromID query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
@ -1593,7 +1592,7 @@ void Database::ClearMerchantTemp(){
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "delete from merchantlist_temp"), errbuf)) { 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); safe_delete_array(query);
} }
@ -1603,7 +1602,7 @@ bool Database::UpdateName(const char* oldname, const char* newname) {
char *query = 0; char *query = 0;
uint32 affected_rows = 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)) { if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET name='%s' WHERE name='%s';", newname, oldname), errbuf, 0, &affected_rows)) {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
@ -1627,7 +1626,7 @@ bool Database::CheckUsedName(const char* name)
//if (strlen(name) > 15) //if (strlen(name) > 15)
// return false; // return false;
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM character_ where name='%s'", name), errbuf, &result)) { 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); safe_delete_array(query);
return false; return false;
} }
@ -1665,15 +1664,11 @@ uint8 Database::GetServerType()
mysql_free_result(result); mysql_free_result(result);
} }
else else
{ {
std::cerr << "Error in GetServerType query '" << query << "' " << errbuf << std::endl;
cerr << "Error in GetServerType query '" << query << "' " << errbuf << endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return 0; return 0;
} }
@ -1687,7 +1682,7 @@ bool Database::MoveCharacterToZone(const char* charname, const char* zonename,ui
return(false); return(false);
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s',zoneid=%i,x=-1, y=-1, z=-1 WHERE name='%s'", zonename,zoneid, charname), errbuf, 0,&affected_rows)) { if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s',zoneid=%i,x=-1, y=-1, z=-1 WHERE name='%s'", zonename,zoneid, charname), errbuf, 0,&affected_rows)) {
cerr << "Error in MoveCharacterToZone(name) query '" << query << "' " << errbuf << endl; std::cerr << "Error in MoveCharacterToZone(name) query '" << query << "' " << errbuf << std::endl;
return false; return false;
} }
safe_delete_array(query); safe_delete_array(query);
@ -1707,7 +1702,7 @@ bool Database::MoveCharacterToZone(uint32 iCharID, const char* iZonename) {
char *query = 0; char *query = 0;
uint32 affected_rows = 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)) { 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; return false;
} }
safe_delete_array(query); safe_delete_array(query);
@ -1740,7 +1735,7 @@ uint8 Database::CopyCharacter(const char* oldname, const char* newname, uint32 a
} }
else { 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); safe_delete_array(query);
return 0; return 0;
} }
@ -1756,7 +1751,7 @@ uint8 Database::CopyCharacter(const char* oldname, const char* newname, uint32 a
end += sprintf(end, "\', account_id=%d, name='%s'", acctid, newname); end += sprintf(end, "\', account_id=%d, name='%s'", acctid, newname);
if (!RunQuery(query2, (uint32) (end - query2), errbuf, 0, &affected_rows)) { 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; return 0;
} }
@ -1773,7 +1768,7 @@ bool Database::SetHackerFlag(const char* accountname, const char* charactername,
char *query = 0; char *query = 0;
uint32 affected_rows = 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)) { 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; return false;
} }
safe_delete_array(query); safe_delete_array(query);
@ -1793,7 +1788,7 @@ bool Database::SetMQDetectionFlag(const char* accountname, const char* character
uint32 affected_rows = 0; 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)) { 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; return false;
} }
@ -1912,7 +1907,7 @@ uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZo
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in GetCharacterInfo query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetCharacterInfo query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
return 0; return 0;
@ -1922,7 +1917,7 @@ bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id), errbuf)) { 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); safe_delete_array(query);
return false; return false;
} }
@ -1947,7 +1942,7 @@ bool Database::GetLiveChar(uint32 account_id, char* cname) {
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in GetLiveChar query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetLiveChar query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
@ -2172,7 +2167,7 @@ void Database::ClearGroupLeader(uint32 gid){
safe_delete_array(query); 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_FIELD *fields;
MYSQL_ROW row; MYSQL_ROW row;
@ -3176,7 +3171,7 @@ uint32 Database::GetGuildDBIDByCharID(uint32 char_id) {
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << std::endl;
} }
safe_delete_array(query); safe_delete_array(query);
return retVal; return retVal;

View File

@ -35,7 +35,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
using namespace std;
//atoi is not uint32 or uint32 safe!!!! //atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10) #define atoul(str) strtoul(str, nullptr, 10)
@ -265,5 +264,5 @@ private:
uint32 varcache_lastupdate; 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 #endif

View File

@ -5,7 +5,6 @@
#include <winsock2.h> #include <winsock2.h>
#endif #endif
#include <iostream> #include <iostream>
using namespace std;
#include "dbasync.h" #include "dbasync.h"
#include "database.h" #include "database.h"
#include <errmsg.h> #include <errmsg.h>
@ -25,7 +24,7 @@ bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) {
if (dbaq->GetAnswer(errbuf, &result)) if (dbaq->GetAnswer(errbuf, &result))
iWork->GetDB()->LoadVariables_result(result); iWork->GetDB()->LoadVariables_result(result);
else else
cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << endl; std::cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << std::endl;
return true; return true;
} }
@ -116,8 +115,8 @@ uint32 DBAsync::AddWork(DBAsyncWork** iWork, uint32 iDelay) {
if (iDelay) if (iDelay)
(*iWork)->pExecuteAfter = Timer::GetCurrentTime() + iDelay; (*iWork)->pExecuteAfter = Timer::GetCurrentTime() + iDelay;
#if DEBUG_MYSQL_QUERIES >= 2 #if DEBUG_MYSQL_QUERIES >= 2
cout << "Adding AsyncWork #" << (*iWork)->GetWorkID() << endl; std::cout << "Adding AsyncWork #" << (*iWork)->GetWorkID() << std::endl;
cout << "ExecuteAfter = " << (*iWork)->pExecuteAfter << " (" << Timer::GetCurrentTime() << " + " << iDelay << ")" << endl; std::cout << "ExecuteAfter = " << (*iWork)->pExecuteAfter << " (" << Timer::GetCurrentTime() << " + " << iDelay << ")" << std::endl;
#endif #endif
*iWork = 0; *iWork = 0;
MInList.unlock(); MInList.unlock();
@ -132,7 +131,7 @@ bool DBAsync::CancelWork(uint32 iWorkID) {
if (iWorkID == 0) if (iWorkID == 0)
return false; return false;
#if DEBUG_MYSQL_QUERIES >= 2 #if DEBUG_MYSQL_QUERIES >= 2
cout << "DBAsync::CancelWork: " << iWorkID << endl; std::cout << "DBAsync::CancelWork: " << iWorkID << std::endl;
#endif #endif
MCurrentWork.lock(); MCurrentWork.lock();
if (CurrentWork && CurrentWork->GetWorkID() == iWorkID) { if (CurrentWork && CurrentWork->GetWorkID() == iWorkID) {
@ -175,8 +174,8 @@ DBAsyncWork* DBAsync::InListPop() {
if (iterator.GetData()->pExecuteAfter <= Timer::GetCurrentTime()) { if (iterator.GetData()->pExecuteAfter <= Timer::GetCurrentTime()) {
ret = iterator.GetData(); ret = iterator.GetData();
#if DEBUG_MYSQL_QUERIES >= 2 #if DEBUG_MYSQL_QUERIES >= 2
cout << "Poping AsyncWork #" << ret->GetWorkID() << endl; std::cout << "Poping AsyncWork #" << ret->GetWorkID() << std::endl;
cout << ret->pExecuteAfter << " <= " << Timer::GetCurrentTime() << endl; std::cout << ret->pExecuteAfter << " <= " << Timer::GetCurrentTime() << std::endl;
#endif #endif
iterator.RemoveCurrent(false); iterator.RemoveCurrent(false);
break; break;
@ -233,7 +232,7 @@ void DBAsync::Process() {
tmpStatus = tmpWork->SetStatus(DBAsync::Finished); tmpStatus = tmpWork->SetStatus(DBAsync::Finished);
if (tmpStatus != Executing) { if (tmpStatus != Executing) {
if (tmpStatus != Canceled) { 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(); MCurrentWork.lock();
safe_delete(tmpWork); safe_delete(tmpWork);
@ -247,7 +246,7 @@ void DBAsync::Process() {
} }
else { else {
if (tmpStatus != Canceled) { 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(); MCurrentWork.lock();
safe_delete(CurrentWork); safe_delete(CurrentWork);
@ -275,7 +274,7 @@ void DBAsync::CheckTimeout() {
void DBAsync::CommitWrites() { void DBAsync::CommitWrites() {
#if DEBUG_MYSQL_QUERIES >= 2 #if DEBUG_MYSQL_QUERIES >= 2
cout << "DBAsync::CommitWrites() called." << endl; std::cout << "DBAsync::CommitWrites() called." << std::endl;
#endif #endif
DBAsyncWork* tmpWork; DBAsyncWork* tmpWork;
while ((tmpWork = InListPopWrite())) { while ((tmpWork = InListPopWrite())) {
@ -285,7 +284,7 @@ void DBAsync::CommitWrites() {
tmpStatus = tmpWork->SetStatus(DBAsync::Finished); tmpStatus = tmpWork->SetStatus(DBAsync::Finished);
if (tmpStatus != Executing) { if (tmpStatus != Executing) {
if (tmpStatus != Canceled) { 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); safe_delete(tmpWork);
} }
@ -295,7 +294,7 @@ void DBAsync::CommitWrites() {
} }
else { else {
if (tmpStatus != Canceled) { 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); safe_delete(tmpWork);
} }
@ -306,7 +305,7 @@ void DBAsync::ProcessWork(DBAsyncWork* iWork, bool iSleep) {
_CP(DBAsync_ProcessWork); _CP(DBAsync_ProcessWork);
DBAsyncQuery* CurrentQuery; DBAsyncQuery* CurrentQuery;
#if DEBUG_MYSQL_QUERIES >= 2 #if DEBUG_MYSQL_QUERIES >= 2
cout << "Processing AsyncWork #" << iWork->GetWorkID() << endl; std::cout << "Processing AsyncWork #" << iWork->GetWorkID() << std::endl;
#endif #endif
while ((CurrentQuery = iWork->PopQuery())) { while ((CurrentQuery = iWork->PopQuery())) {
CurrentQuery->Process(pDBC); CurrentQuery->Process(pDBC);

View File

@ -5,7 +5,6 @@
#endif #endif
#include <iostream> #include <iostream>
using namespace std;
#include <errmsg.h> #include <errmsg.h>
#include <mysqld_error.h> #include <mysqld_error.h>
#include <limits.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 #if DEBUG_MYSQL_QUERIES >= 1
char tmp[120]; char tmp[120];
strn0cpy(tmp, query, sizeof(tmp)); strn0cpy(tmp, query, sizeof(tmp));
cout << "QUERY: " << tmp << endl; std::cout << "QUERY: " << tmp << std::endl;
#endif #endif
if (mysql_real_query(&mysql, query, querylen)) { if (mysql_real_query(&mysql, query, querylen)) {
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
pStatus = Error; pStatus = Error;
if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) { if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
if (retry) { 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); ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
if (ret) if (ret)
cout << "Reconnection to database successful." << endl; std::cout << "Reconnection to database successful." << std::endl;
} }
else { else {
pStatus = Error; pStatus = Error;
@ -90,7 +89,7 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
*errnum = mysql_errno(&mysql); *errnum = mysql_errno(&mysql);
if (errbuf) if (errbuf)
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql)); 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; ret = false;
} }
} }
@ -100,7 +99,7 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
if (errbuf) if (errbuf)
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql)); snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
#ifdef _EQDEBUG #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 #endif
ret = false; ret = false;
} }
@ -124,7 +123,7 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
} }
else { else {
#ifdef _EQDEBUG #ifdef _EQDEBUG
cout << "DB Query Error: No Result" << endl; std::cout << "DB Query Error: No Result" << std::endl;
#endif #endif
if (errnum) if (errnum)
*errnum = UINT_MAX; *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 DEBUG_MYSQL_QUERIES >= 1
if (ret) { if (ret) {
cout << "query successful"; std::cout << "query successful";
if (result && (*result)) if (result && (*result))
cout << ", " << (int) mysql_num_rows(*result) << " rows returned"; std::cout << ", " << (int) mysql_num_rows(*result) << " rows returned";
if (affected_rows) if (affected_rows)
cout << ", " << (*affected_rows) << " rows affected"; std::cout << ", " << (*affected_rows) << " rows affected";
cout<< endl; std::cout<< std::endl;
} }
else { else {
cout << "QUERY: query FAILED" << endl; std::cout << "QUERY: query FAILED" << std::endl;
} }
#endif #endif
return ret; return ret;

View File

@ -1,5 +1,3 @@
#include "debug.h"
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <cstdarg> #include <cstdarg>
@ -18,11 +16,13 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "../common/StringUtil.h" #include "debug.h"
#include "../common/MiscFunctions.h" #include "StringUtil.h"
#include "../common/platform.h" #include "MiscFunctions.h"
#include "platform.h"
#ifndef va_copy #ifndef va_copy
#define va_copy(d,s) ((d) = (s)) #define va_copy(d,s) ((d) = (s))
@ -76,7 +76,6 @@ EQEMuLog::~EQEMuLog() {
} }
bool EQEMuLog::open(LogIDs id) { bool EQEMuLog::open(LogIDs id) {
if (!logFileValid) { if (!logFileValid) {
return false; return false;
} }
@ -92,40 +91,36 @@ bool EQEMuLog::open(LogIDs id) {
return true; return true;
} }
std::string filename = FileNames[id]; char exename[200] = "";
const EQEmuExePlatform &platform = GetExecutablePlatform(); const EQEmuExePlatform &platform = GetExecutablePlatform();
if(platform == ExePlatformWorld) { if(platform == ExePlatformWorld) {
filename.append("_world"); snprintf(exename, sizeof(exename), "_world");
} else if(platform == ExePlatformZone) { } else if(platform == ExePlatformZone) {
filename.append("_zone"); snprintf(exename, sizeof(exename), "_zone");
} else if(platform == ExePlatformLaunch) { } else if(platform == ExePlatformLaunch) {
filename.append("_launch"); snprintf(exename, sizeof(exename), "_launch");
} else if(platform == ExePlatformUCS) { } else if(platform == ExePlatformUCS) {
filename.append("_ucs"); snprintf(exename, sizeof(exename), "_ucs");
} else if(platform == ExePlatformQueryServ) { } else if(platform == ExePlatformQueryServ) {
filename.append("_queryserv"); snprintf(exename, sizeof(exename), "_queryserv");
} else if(platform == ExePlatformSharedMemory) { } else if(platform == ExePlatformSharedMemory) {
filename.append("_shared_memory"); snprintf(exename, sizeof(exename), "_shared_memory");
} }
char filename[200];
#ifndef NO_PIDLOG #ifndef NO_PIDLOG
// According to http://msdn.microsoft.com/en-us/library/vstudio/ee404875(v=vs.100).aspx snprintf(filename, sizeof(filename), "%s%s_%04i.log", FileNames[id], exename, getpid());
// Visual Studio 2010 doesn't have std::to_string(int) but it does have one for #else
// long long. Oh well, it works fine and formats perfectly acceptably. snprintf(filename, sizeof(filename), "%s%s.log", FileNames[id], exename);
filename.append(std::to_string((long long)getpid()));
#endif #endif
filename.append(".log"); fp[id] = fopen(filename, "a");
fp[id] = fopen(filename.c_str(), "a");
if (!fp[id]) { if (!fp[id]) {
std::cerr << "Failed to open log file: " << filename << std::endl; std::cerr << "Failed to open log file: " << filename << std::endl;
pLogStatus[id] |= 4; // set file state to error pLogStatus[id] |= 4; // set file state to error
return false; return false;
} }
fputs("---------------------------------------------\n",fp[id]); fputs("---------------------------------------------\n",fp[id]);
write(id, "Starting Log: %s", filename.c_str()); write(id, "Starting Log: %s", filename);
return true; return true;
} }
@ -152,54 +147,44 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
time( &aclock ); /* Get time in seconds */ time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */ newtime = localtime( &aclock ); /* Convert time to struct */
if (dofile) { if (dofile)
#ifndef NO_PIDLOG #ifndef NO_PIDLOG
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec); fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
#else #else
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec); fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
#endif #endif
}
va_list argptr, tmpargptr; va_list argptr, tmpargptr;
if (dofile) {
va_start(argptr, fmt); va_start(argptr, fmt);
if (dofile) {
va_copy(tmpargptr, argptr); va_copy(tmpargptr, argptr);
vfprintf( fp[id], fmt, tmpargptr ); vfprintf( fp[id], fmt, tmpargptr );
va_end(tmpargptr);
} }
if(logCallbackFmt[id]) { if(logCallbackFmt[id]) {
msgCallbackFmt p = logCallbackFmt[id]; msgCallbackFmt p = logCallbackFmt[id];
va_start(argptr, fmt);
va_copy(tmpargptr, argptr); va_copy(tmpargptr, argptr);
p(id, fmt, tmpargptr ); p(id, fmt, tmpargptr );
va_end(tmpargptr);
} }
std::string outputMessage;
va_start(argptr, fmt);
va_copy(tmpargptr,argptr);
vStringFormat(outputMessage, fmt, tmpargptr);
va_end(tmpargptr);
if (pLogStatus[id] & 2) { if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) { if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] ", LogNames[id]);
std::cerr << "[" << LogNames[id] << "] "; vfprintf( stderr, fmt, argptr );
std::cerr << outputMessage;
} }
else { else {
std::cout << "[" << LogNames[id] << "] "; fprintf(stdout, "[%s] ", LogNames[id]);
std::cout << outputMessage; vfprintf( stdout, fmt, argptr );
} }
} }
va_end(argptr);
if (dofile) if (dofile)
fprintf(fp[id], "\n"); fprintf(fp[id], "\n");
if (pLogStatus[id] & 2) { if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) { if (pLogStatus[id] & 8) {
std::cerr << std::endl; fprintf(stderr, "\n");
fflush(stderr);
} else { } else {
std::cout << std::endl; fprintf(stdout, "\n");
fflush(stdout);
} }
} }
if(dofile) if(dofile)
@ -346,7 +331,7 @@ bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) { bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
if (!logFileValid) { if (!logFileValid) {
#if EQDEBUG >= 10 #if EQDEBUG >= 10
cerr << "Error: Dump() from null pointer"<<endl; std::cerr << "Error: Dump() from null pointer" << std::endl;
#endif #endif
return false; return false;
} }
@ -463,3 +448,4 @@ void EQEMuLog::SetAllCallbacks(msgCallbackPva proc) {
SetCallback((LogIDs)r, proc); SetCallback((LogIDs)r, proc);
} }
} }

View File

@ -22,7 +22,6 @@
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
#include <memory.h> #include <memory.h>
#include <iostream> #include <iostream>
using namespace std;
/*#ifdef _CRTDBG_MAP_ALLOC /*#ifdef _CRTDBG_MAP_ALLOC
#undef new #undef new
#endif*/ #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. //For some reason, ifstream/ofstream have problems with EQEmu datatypes in files.
bool EQTime::saveFile(const char *filename) bool EQTime::saveFile(const char *filename)
{ {
ofstream of; std::ofstream of;
of.open(filename); of.open(filename);
if(!of) if(!of)
{ {
@ -146,13 +145,13 @@ bool EQTime::saveFile(const char *filename)
} }
//Enable for debugging //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; //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 << EQT_VERSION << std::endl;
of << (long)eqTime.start_eqtime.day << endl; of << (long)eqTime.start_eqtime.day << std::endl;
of << (long)eqTime.start_eqtime.hour << endl; of << (long)eqTime.start_eqtime.hour << std::endl;
of << (long)eqTime.start_eqtime.minute << endl; of << (long)eqTime.start_eqtime.minute << std::endl;
of << (long)eqTime.start_eqtime.month << endl; of << (long)eqTime.start_eqtime.month << std::endl;
of << eqTime.start_eqtime.year << endl; of << eqTime.start_eqtime.year << std::endl;
of << eqTime.start_realtime << endl; of << eqTime.start_realtime << std::endl;
of.close(); of.close();
return true; return true;
} }
@ -161,7 +160,7 @@ bool EQTime::loadFile(const char *filename)
{ {
int version=0; int version=0;
long in_data=0; long in_data=0;
ifstream in; std::ifstream in;
in.open(filename); in.open(filename);
if(!in) if(!in)
{ {
@ -265,7 +264,7 @@ void EQTime::AddMinutes(uint32 minutes, TimeOfDay_Struct *to) {
to->year += (cur-1) / 12; 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]; char buf[128];
snprintf(buf, 128, "%.2d/%.2d/%.4d %.2d:%.2d", snprintf(buf, 128, "%.2d/%.2d/%.4d %.2d:%.2d",
t->month, t->day, t->year, t->hour, t->minute); t->month, t->day, t->year, t->hour, t->minute);

View File

@ -4,8 +4,6 @@
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
#include <string> #include <string>
using namespace std;
//Struct //Struct
struct eqTimeOfDay struct eqTimeOfDay
{ {
@ -39,7 +37,7 @@ public:
static bool IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test); //is test before base static bool IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test); //is test before base
static void AddMinutes(uint32 minutes, TimeOfDay_Struct *to); 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 //Database functions
//bool loadDB(Database q); //bool loadDB(Database q);

View File

@ -53,7 +53,7 @@ bool BaseGuildManager::LoadGuilds() {
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
map<uint32, GuildInfo *>::iterator res; std::map<uint32, GuildInfo *>::iterator res;
// load up all the guilds // load up all the guilds
if (!m_db->RunQuery(query, MakeAnyLenString(&query, if (!m_db->RunQuery(query, MakeAnyLenString(&query,
@ -117,7 +117,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
map<uint32, GuildInfo *>::iterator res; std::map<uint32, GuildInfo *>::iterator res;
GuildInfo *info; GuildInfo *info;
// load up all the guilds // load up all the guilds
@ -174,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) 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. //remove any old entry.
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
@ -223,7 +223,7 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
return(false); return(false);
} }
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) { if(res == m_guilds.end()) {
_log(GUILDS__DB, "Requested to store non-existent guild %d", guild_id); _log(GUILDS__DB, "Requested to store non-existent guild %d", guild_id);
@ -377,7 +377,7 @@ bool BaseGuildManager::RenameGuild(uint32 guild_id, const char* name) {
bool BaseGuildManager::SetGuildLeader(uint32 guild_id, uint32 leader_char_id) { bool BaseGuildManager::SetGuildLeader(uint32 guild_id, uint32 leader_char_id) {
//get old leader first. //get old leader first.
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(false); return(false);
@ -517,7 +517,7 @@ uint32 BaseGuildManager::DBCreateGuild(const char* name, uint32 leader) {
bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) { bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) {
//remove the local entry //remove the local entry
map<uint32, GuildInfo *>::iterator res; std::map<uint32, GuildInfo *>::iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res != m_guilds.end()) { if(res != m_guilds.end()) {
delete res->second; delete res->second;
@ -558,7 +558,7 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
return(false); return(false);
} }
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(false); return(false);
@ -598,7 +598,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
return(false); return(false);
} }
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(false); return(false);
@ -638,7 +638,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
return(false); return(false);
} }
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(false); return(false);
@ -683,7 +683,7 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
if(m_db == nullptr) if(m_db == nullptr)
return(false); return(false);
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(GuildID); res = m_guilds.find(GuildID);
@ -724,7 +724,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
if(m_db == nullptr) if(m_db == nullptr)
return(false); return(false);
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(GuildID); res = m_guilds.find(GuildID);
@ -979,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(); members.clear();
if(m_db == nullptr) if(m_db == nullptr)
@ -1110,7 +1110,7 @@ uint8 *BaseGuildManager::MakeGuildList(const char *head_name, uint32 &length) co
strn0cpy((char *) buffer, head_name, 64); 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(); cur = m_guilds.begin();
end = m_guilds.end(); end = m_guilds.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@ -1123,7 +1123,7 @@ uint8 *BaseGuildManager::MakeGuildList(const char *head_name, uint32 &length) co
const char *BaseGuildManager::GetRankName(uint32 guild_id, uint8 rank) const { const char *BaseGuildManager::GetRankName(uint32 guild_id, uint8 rank) const {
if(rank > GUILD_MAX_RANK) if(rank > GUILD_MAX_RANK)
return("Invalid Rank"); return("Invalid Rank");
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return("Invalid Guild Rank"); return("Invalid Guild Rank");
@ -1133,7 +1133,7 @@ const char *BaseGuildManager::GetRankName(uint32 guild_id, uint8 rank) const {
const char *BaseGuildManager::GetGuildName(uint32 guild_id) const { const char *BaseGuildManager::GetGuildName(uint32 guild_id) const {
if(guild_id == GUILD_NONE) if(guild_id == GUILD_NONE)
return(""); return("");
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return("Invalid Guild"); return("Invalid Guild");
@ -1141,7 +1141,7 @@ const char *BaseGuildManager::GetGuildName(uint32 guild_id) const {
} }
bool BaseGuildManager::GetGuildNameByID(uint32 guild_id, std::string &into) 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); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(false); return(false);
@ -1151,7 +1151,7 @@ bool BaseGuildManager::GetGuildNameByID(uint32 guild_id, std::string &into) cons
uint32 BaseGuildManager::GetGuildIDByName(const char *GuildName) 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) for(Iterator = m_guilds.begin(); Iterator != m_guilds.end(); ++Iterator)
{ {
@ -1163,7 +1163,7 @@ uint32 BaseGuildManager::GetGuildIDByName(const char *GuildName)
} }
bool BaseGuildManager::GetGuildMOTD(uint32 guild_id, char *motd_buffer, char *setter_buffer) const { 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); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(false); return(false);
@ -1174,7 +1174,7 @@ bool BaseGuildManager::GetGuildMOTD(uint32 guild_id, char *motd_buffer, char *se
bool BaseGuildManager::GetGuildURL(uint32 GuildID, char *URLBuffer) const 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); res = m_guilds.find(GuildID);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(false); return(false);
@ -1185,7 +1185,7 @@ bool BaseGuildManager::GetGuildURL(uint32 GuildID, char *URLBuffer) const
bool BaseGuildManager::GetGuildChannel(uint32 GuildID, char *ChannelBuffer) 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); res = m_guilds.find(GuildID);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(false); return(false);
@ -1204,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); _log(GUILDS__PERMISSIONS, "Check leader for char %d: not a guild.", char_id);
return(false); return(false);
} }
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) { if(res == m_guilds.end()) {
_log(GUILDS__PERMISSIONS, "Check leader for char %d: invalid guild.", char_id); _log(GUILDS__PERMISSIONS, "Check leader for char %d: invalid guild.", char_id);
@ -1215,7 +1215,7 @@ bool BaseGuildManager::IsGuildLeader(uint32 guild_id, uint32 char_id) const {
} }
uint32 BaseGuildManager::FindGuildByLeader(uint32 leader) 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(); cur = m_guilds.begin();
end = m_guilds.end(); end = m_guilds.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@ -1227,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. //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 { 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); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(3); //invalid guild rank return(3); //invalid guild rank
@ -1244,7 +1244,7 @@ bool BaseGuildManager::CheckGMStatus(uint32 guild_id, uint8 status) const {
return(true); //250+ as allowed anything 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); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) { if(res == m_guilds.end()) {
_log(GUILDS__PERMISSIONS, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status); _log(GUILDS__PERMISSIONS, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status);
@ -1265,7 +1265,7 @@ bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction
guild_id, rank, GuildActionNames[act], act); guild_id, rank, GuildActionNames[act], act);
return(false); //invalid rank return(false); //invalid rank
} }
map<uint32, GuildInfo *>::const_iterator res; std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) { if(res == m_guilds.end()) {
_log(GUILDS__PERMISSIONS, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.", _log(GUILDS__PERMISSIONS, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.",
@ -1285,7 +1285,7 @@ bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction
} }
bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) { bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) {
map<uint32, GuildInfo *>::iterator res; std::map<uint32, GuildInfo *>::iterator res;
res = m_guilds.find(guild_id); res = m_guilds.find(guild_id);
if(res == m_guilds.end()) if(res == m_guilds.end())
return(false); //invalid guild return(false); //invalid guild
@ -1294,7 +1294,7 @@ bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) {
} }
void BaseGuildManager::ClearGuilds() { void BaseGuildManager::ClearGuilds() {
map<uint32, GuildInfo *>::iterator cur, end; std::map<uint32, GuildInfo *>::iterator cur, end;
cur = m_guilds.begin(); cur = m_guilds.begin();
end = m_guilds.end(); end = m_guilds.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {

View File

@ -18,12 +18,10 @@
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
using namespace std;
#define ENC(c) (((c) & 0x3f) + ' ') #define ENC(c) (((c) & 0x3f) + ' ')
#define DEC(c) (((c) - ' ') & 0x3f) #define DEC(c) (((c) - ' ') & 0x3f)
map<int,string> DBFieldNames; std::map<int,std::string> DBFieldNames;
#ifndef WIN32 #ifndef WIN32
#if defined(FREEBSD) || defined(__CYGWIN__) #if defined(FREEBSD) || defined(__CYGWIN__)
@ -44,9 +42,9 @@ int print_stacktrace()
if (names != nullptr) if (names != nullptr)
{ {
int i; int i;
cerr << "called from " << (char*)names[0] << endl; std::cerr << "called from " << (char*)names[0] << std::endl;
for (i = 1; i < n; ++i) for (i = 1; i < n; ++i)
cerr << " " << (char*)names[i] << endl; std::cerr << " " << (char*)names[i] << std::endl;
free (names); free (names);
} }
} }
@ -55,19 +53,19 @@ int print_stacktrace()
#endif //!FREEBSD #endif //!FREEBSD
#endif //!WIN32 #endif //!WIN32
void Unprotect(string &s, char what) void Unprotect(std::string &s, char what)
{ {
if (s.length()) { 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) if (s[i]=='\\' && s[i+1]==what)
s.erase(i,1); 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) if (s[i]==what)
s.insert(i++,"\\"); s.insert(i++,"\\");
} }
@ -77,11 +75,11 @@ void Protect(string &s, char what)
item id -> fields_list item id -> fields_list
each fields_list is a map of field index -> value 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; int i;
char *end,*ptr; char *end,*ptr;
map<int,string> field; std::map<int,std::string> field;
static char *buffer=nullptr; static char *buffer=nullptr;
static int buffsize=0; static int buffsize=0;
static char *temp=nullptr; static char *temp=nullptr;
@ -102,7 +100,7 @@ static char *temp=nullptr;
break; break;
} }
if (!end) { 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; return false;
} else { } else {
*end=0; *end=0;
@ -114,7 +112,7 @@ static char *temp=nullptr;
} }
if (*ptr!='"') { 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; return false;
} }
ptr++; ptr++;
@ -126,7 +124,7 @@ static char *temp=nullptr;
break; break;
} }
if (!end) { 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; return false;
} else { } else {
*end=0; *end=0;
@ -145,12 +143,12 @@ static char *temp=nullptr;
Unprotect(field[i],'|'); Unprotect(field[i],'|');
ptr+=length; ptr+=length;
} else { } 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; return false;
} }
if (*ptr!='|') { 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; return false;
} }
ptr++; ptr++;
@ -162,7 +160,7 @@ static char *temp=nullptr;
end=ptr; end=ptr;
while((end=strchr(end+1,'"'))!=nullptr && *(end-1)=='\\'); while((end=strchr(end+1,'"'))!=nullptr && *(end-1)=='\\');
if (end) { if (end) {
string sub; std::string sub;
sub.assign(ptr+1,end-ptr-1); sub.assign(ptr+1,end-ptr-1);
Unprotect(sub,'"'); Unprotect(sub,'"');
if (!ItemParse(sub.c_str(),sub.length(),items,id_pos,name_pos,max_field,level+1)) { 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; ptr=end+1;
} else { } 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; return false;
} }
} }
if (*ptr=='|') { if (*ptr=='|') {
ptr++; ptr++;
} else if (i<9) { } 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; return false;
} }
@ -185,12 +183,12 @@ static char *temp=nullptr;
return true; 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; int i,len;
string::size_type end; std::string::size_type end;
//char temp[1024]; //char temp[1024];
string x; std::string x;
tokens.clear(); tokens.clear();
i=0; i=0;
while(s.length()) { while(s.length()) {
@ -199,10 +197,10 @@ string x;
tokens[i++]=""; tokens[i++]="";
} else { } else {
end=0; end=0;
while((end=s.find(delim,end+1))!=string::npos && s[end-1]=='\\'); while((end=s.find(delim,end+1))!=std::string::npos && s[end-1]=='\\');
if (end!=string::npos) { if (end!=std::string::npos) {
x=s; x=s;
x.erase(end,string::npos); x.erase(end,std::string::npos);
s.erase(0,end+1); s.erase(0,end+1);
Unprotect(x,'|'); Unprotect(x,'|');
tokens[i++]=x; tokens[i++]=x;
@ -392,7 +390,7 @@ void decode_chunk(char *in, char *out)
*(out+2) = DEC(in[2]) << 6 | DEC(in[3]); *(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 i,j;
unsigned long rows,offset=0; 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]; char temp[16];
union { unsigned long ip; struct { unsigned char a,b,c,d; } octet;} ipoctet; 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; ipoctet.ip=ip;
sprintf(temp,"%d.%d.%d.%d",ipoctet.octet.a,ipoctet.octet.b,ipoctet.octet.c,ipoctet.octet.d); 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; struct tm *now_tm;
char time_string[51]; char time_string[51];
@ -440,18 +438,18 @@ char time_string[51];
strftime(time_string,51,pattern.c_str(),now_tm); 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); 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; unsigned long i;
bool in_quote=false; bool in_quote=false;
@ -463,7 +461,7 @@ bool in_quote=false;
} }
if (in_quote) if (in_quote)
continue; continue;
if (seps.find(c)!=string::npos) { if (seps.find(c)!=std::string::npos) {
break; break;
} }
} }
@ -523,9 +521,9 @@ char *bptr;
return (bptr-buffer); return (bptr-buffer);
} }
string generate_key(int length) std::string generate_key(int length)
{ {
string key; std::string key;
//TODO: write this for win32... //TODO: write this for win32...
#ifndef WIN32 #ifndef WIN32
int i; int i;

View File

@ -5,17 +5,15 @@
#include <string> #include <string>
#include <map> #include <map>
using namespace std;
#define ITEMFIELDCOUNT 116 #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(); void LoadItemDBFieldNames();
@ -30,13 +28,13 @@ void decode_chunk(char *in, char *out);
int print_stacktrace(); int print_stacktrace();
#endif #endif
void dump_message_column(unsigned char *buffer, unsigned long length, string leader="", FILE *to = stdout); void dump_message_column(unsigned char *buffer, unsigned long length, std::string leader="", FILE *to = stdout);
string string_from_time(string pattern, time_t now=0); std::string string_from_time(std::string pattern, time_t now=0);
string timestamp(time_t now=0); std::string timestamp(time_t now=0);
string long2ip(unsigned long ip); std::string long2ip(unsigned long ip);
string pop_arg(string &s, string seps, bool obey_quotes); 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); 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 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); void print_hex(const char *buffer, unsigned long length);

View File

@ -2,13 +2,11 @@
#include <map> #include <map>
#include <string> #include <string>
using namespace std; std::map<unsigned long, std::string> opcode_map;
map<unsigned long, string> opcode_map; std::string get_opcode_name(unsigned long opcode)
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"; return (itr=opcode_map.find(opcode))!=opcode_map.end() ? itr->second : "OP_Unknown";
} }

View File

@ -25,7 +25,6 @@
#include <map> #include <map>
#include <string> #include <string>
using namespace std;
OpcodeManager::OpcodeManager() { OpcodeManager::OpcodeManager() {
loaded = false; loaded = false;
@ -38,7 +37,7 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
return(false); 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 //load the opcode file into eq, could swap in a nice XML parser here
char line[2048]; 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 //do the mapping and store them in the shared memory array
bool ret = true; bool ret = true;
EmuOpcode emu_op; EmuOpcode emu_op;
map<string, uint16>::iterator res; std::map<std::string, uint16>::iterator res;
//stupid enum wont let me ++ on it... //stupid enum wont let me ++ on it...
for(emu_op = OP_Unknown; emu_op < _maxEmuOpcode; emu_op=(EmuOpcode)(emu_op+1)) { for(emu_op = OP_Unknown; emu_op < _maxEmuOpcode; emu_op=(EmuOpcode)(emu_op+1)) {
//get the name of this emu opcode //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) { 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); f = emu_to_eq.find(emu_op);
return(f == emu_to_eq.end()? 0 : f->second); return(f == emu_to_eq.end()? 0 : f->second);
} }
EmuOpcode EmptyOpcodeManager::EQToEmu(const uint16 eq_op) { 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); f = eq_to_emu.find(eq_op);
return(f == eq_to_emu.end()?OP_Unknown:f->second); return(f == eq_to_emu.end()?OP_Unknown:f->second);
} }

View File

@ -24,7 +24,6 @@
#include "emu_opcodes.h" #include "emu_opcodes.h"
#include <map> #include <map>
using namespace std;
//enable the use of shared mem opcodes for world and zone only //enable the use of shared mem opcodes for world and zone only
#ifdef ZONE #ifdef ZONE
@ -156,8 +155,8 @@ public:
//fake it, just used for testing anyways //fake it, just used for testing anyways
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op); virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op);
protected: protected:
map<EmuOpcode, uint16> emu_to_eq; std::map<EmuOpcode, uint16> emu_to_eq;
map<uint16, EmuOpcode> eq_to_emu; std::map<uint16, EmuOpcode> eq_to_emu;
}; };
#endif #endif

View File

@ -20,8 +20,6 @@
#include <iomanip> #include <iomanip>
#include <stdio.h> #include <stdio.h>
using namespace std;
#include "packet_dump.h" #include "packet_dump.h"
#include "EQPacket.h" #include "EQPacket.h"
#include "../common/servertalk.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) 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) else if ((i-skip)%(cols/2)==0)
{ {
cout << " - "; std::cout << " - ";
} }
if (buf[i] > 32 && buf[i] < 127) if (buf[i] > 32 && buf[i] < 127)
{ {
cout << buf[i]; std::cout << buf[i];
} }
else else
{ {
cout << '.'; std::cout << '.';
} }
} }
cout << endl << endl; std::cout << std::endl << std::endl;
} }
void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) { 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)%cols==0) {
if (i != skip) if (i != skip)
cout << " | " << ascii << endl; std::cout << " | " << ascii << std::endl;
cout << setw(4) << setfill(' ') << i-skip << ": "; std::cout << std::setw(4) << std::setfill(' ') << i-skip << ": ";
memset(ascii, 0, cols+1); memset(ascii, 0, cols+1);
j = 0; j = 0;
} }
else if ((i-skip)%(cols/2) == 0) { else if ((i-skip)%(cols/2) == 0) {
cout << "- "; std::cout << "- ";
} }
sprintf(output, "%02X ", (unsigned char)buf[i]); sprintf(output, "%02X ", (unsigned char)buf[i]);
cout << output; std::cout << output;
if (buf[i] >= 32 && buf[i] < 127) { if (buf[i] >= 32 && buf[i] < 127) {
ascii[j++] = buf[i]; 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; uint32 k = ((i-skip)-1)%cols;
if (k < 8) if (k < 8)
cout << " "; std::cout << " ";
for (uint32 h = k+1; h < cols; h++) { for (uint32 h = k+1; h < cols; h++) {
cout << " "; std::cout << " ";
} }
cout << " | " << ascii << endl; std::cout << " | " << ascii << std::endl;
safe_delete_array(ascii); safe_delete_array(ascii);
} }
@ -100,8 +98,8 @@ void DumpPacket(const uchar* buf, uint32 size)
void DumpPacket(const ServerPacket* pack, bool iShowInfo) { void DumpPacket(const ServerPacket* pack, bool iShowInfo) {
if (iShowInfo) { if (iShowInfo) {
cout << "Dumping ServerPacket: 0x" << hex << setfill('0') << setw(4) << pack->opcode << dec; std::cout << "Dumping ServerPacket: 0x" << std::hex << std::setfill('0') << std::setw(4) << pack->opcode << std::dec;
cout << " size:" << pack->size << endl; std::cout << " size:" << pack->size << std::endl;
} }
DumpPacketHex(pack->pBuffer, pack->size); DumpPacketHex(pack->pBuffer, pack->size);
} }
@ -131,66 +129,66 @@ void DumpPacketBin(const void* iData, uint32 len) {
for (k=0; k<len; k++) { for (k=0; k<len; k++) {
if (k % 4 == 0) { if (k % 4 == 0) {
if (k != 0) { if (k != 0) {
cout << " | " << hex << setw(2) << setfill('0') << (int) data[k-4] << dec; std::cout << " | " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-4] << std::dec;
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;
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;
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-1] << dec; std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-1] << std::dec;
cout << endl; std::cout << std::endl;
} }
cout << setw(4) << setfill('0') << k << ":"; std::cout << std::setw(4) << std::setfill('0') << k << ":";
} }
else if (k % 2 == 0) else if (k % 2 == 0)
cout << " "; std::cout << " ";
cout << " "; std::cout << " ";
if (data[k] & 1) if (data[k] & 1)
cout << "1"; std::cout << "1";
else else
cout << "0"; std::cout << "0";
if (data[k] & 2) if (data[k] & 2)
cout << "1"; std::cout << "1";
else else
cout << "0"; std::cout << "0";
if (data[k] & 4) if (data[k] & 4)
cout << "1"; std::cout << "1";
else else
cout << "0"; std::cout << "0";
if (data[k] & 8) if (data[k] & 8)
cout << "1"; std::cout << "1";
else else
cout << "0"; std::cout << "0";
if (data[k] & 16) if (data[k] & 16)
cout << "1"; std::cout << "1";
else else
cout << "0"; std::cout << "0";
if (data[k] & 32) if (data[k] & 32)
cout << "1"; std::cout << "1";
else else
cout << "0"; std::cout << "0";
if (data[k] & 64) if (data[k] & 64)
cout << "1"; std::cout << "1";
else else
cout << "0"; std::cout << "0";
if (data[k] & 128) if (data[k] & 128)
cout << "1"; std::cout << "1";
else else
cout << "0"; std::cout << "0";
} }
uint8 tmp = (k % 4); uint8 tmp = (k % 4);
if (!tmp) if (!tmp)
tmp = 4; tmp = 4;
if (tmp <= 3) if (tmp <= 3)
cout << " "; std::cout << " ";
if (tmp <= 2) if (tmp <= 2)
cout << " "; std::cout << " ";
if (tmp <= 1) if (tmp <= 1)
cout << " "; std::cout << " ";
cout << " | " << hex << setw(2) << setfill('0') << (int) data[k-4] << dec; std::cout << " | " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-4] << std::dec;
if (tmp > 1) 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) 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) if (tmp > 3)
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-1] << dec; std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-1] << std::dec;
cout << endl; std::cout << std::endl;
} }

View File

@ -38,16 +38,14 @@
#include "EQStream.h" #include "EQStream.h"
#include "packet_dump_file.h" #include "packet_dump_file.h"
using namespace std;
void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) { 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 // Output as ASCII
for(uint32 i=skip; i<size; i++) for(uint32 i=skip; i<size; i++)
{ {
if ((i-skip)%cols==0) 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) else if ((i-skip)%(cols/2)==0)
{ {
@ -62,19 +60,19 @@ void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, ui
logfile << '.'; logfile << '.';
} }
} }
logfile << endl << endl; logfile << std::endl << std::endl;
} }
void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) 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 // Output as HEX
char output[4]; char output[4];
for(uint32 i=skip; i<size; i++) for(uint32 i=skip; i<size; i++)
{ {
if ((i-skip)%cols==0) 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) else if ((i-skip)%(cols/2) == 0)
{ {
@ -84,14 +82,14 @@ void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, u
logfile << output; logfile << output;
// logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " "; // 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) void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip)
{ {
if (size == 0) if (size == 0)
return; return;
ofstream logfile(filename, ios::app); std::ofstream logfile(filename, std::ios::app);
// Output as HEX // Output as HEX
char output[4]; char output[4];
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1); int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
@ -100,8 +98,8 @@ void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint
{ {
if ((i-skip)%cols==0) { if ((i-skip)%cols==0) {
if (i != skip) if (i != skip)
logfile << " | " << ascii << endl; logfile << " | " << ascii << std::endl;
logfile << setw(4) << setfill(' ') << i-skip << ": "; logfile << std::setw(4) << std::setfill(' ') << i-skip << ": ";
memset(ascii, 0, cols+1); memset(ascii, 0, cols+1);
j = 0; j = 0;
} }
@ -125,7 +123,7 @@ void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint
for (uint32 h = k+1; h < cols; h++) { for (uint32 h = k+1; h < cols; h++) {
logfile << " "; logfile << " ";
} }
logfile << " | " << ascii << endl; logfile << " | " << ascii << std::endl;
delete[] ascii; delete[] ascii;
} }
@ -158,13 +156,13 @@ void FileDumpPacket(const char* filename, const EQApplicationPacket* app)
if prefix_timestamp specified, prints the current date/time to the file + ": " + text if prefix_timestamp specified, prints the current date/time to the file + ": " + text
*/ */
void FilePrintLine(const char* filename, bool prefix_timestamp, const char* 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) { if (prefix_timestamp) {
time_t rawtime; time_t rawtime;
struct tm* gmt_t; struct tm* gmt_t;
time(&rawtime); time(&rawtime);
gmt_t = gmtime(&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) { if (text != 0) {
@ -178,17 +176,17 @@ void FilePrintLine(const char* filename, bool prefix_timestamp, const char* text
logfile << ": "; logfile << ": ";
logfile << buffer; logfile << buffer;
} }
logfile << endl; logfile << std::endl;
} }
void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const char* text, ...) { 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) { if (prefix_timestamp) {
time_t rawtime; time_t rawtime;
struct tm* gmt_t; struct tm* gmt_t;
time(&rawtime); time(&rawtime);
gmt_t = gmtime(&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) { if (text != 0) {
@ -204,6 +202,6 @@ void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const
} }
if (newline) if (newline)
logfile << endl; logfile << std::endl;
} }

View File

@ -19,7 +19,6 @@
#define PACKET_DUMP_FILE_H #define PACKET_DUMP_FILE_H
#include <iostream> #include <iostream>
using namespace std;
#include "../common/types.h" #include "../common/types.h"

View File

@ -27,8 +27,6 @@
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
using namespace std;
void EncryptProfilePacket(EQApplicationPacket* app) { void EncryptProfilePacket(EQApplicationPacket* app) {
//EncryptProfilePacket(app->pBuffer, app->size); //EncryptProfilePacket(app->pBuffer, app->size);
} }
@ -209,10 +207,10 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
} }
else { else {
if (!iQuiet) { if (!iQuiet) {
cout << "Error: InflatePacket: inflate() returned " << zerror << " '"; std::cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
if (zstream.msg) if (zstream.msg)
cout << zstream.msg; std::cout << zstream.msg;
cout << "'" << endl; std::cout << "'" << std::endl;
#ifdef EQDEBUG #ifdef EQDEBUG
DumpPacket(indata-16, indatalen+16); DumpPacket(indata-16, indatalen+16);
#endif #endif
@ -254,10 +252,10 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
} }
else { else {
if (!iQuiet) { if (!iQuiet) {
cout << "Error: InflatePacket: inflate() returned " << zerror << " '"; std::cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
if (zstream.msg) if (zstream.msg)
cout << zstream.msg; std::cout << zstream.msg;
cout << "'" << endl; std::cout << "'" << std::endl;
#ifdef EQDEBUG #ifdef EQDEBUG
DumpPacket(indata-16, indatalen+16); DumpPacket(indata-16, indatalen+16);
#endif #endif

View File

@ -13,9 +13,6 @@
#include "../common/misc.h" #include "../common/misc.h"
#include <map> #include <map>
using namespace std;
PacketFileWriter::PacketFileWriter(bool _force_flush) { PacketFileWriter::PacketFileWriter(bool _force_flush) {
out = NULL; out = NULL;
force_flush = _force_flush; force_flush = _force_flush;

View File

@ -25,7 +25,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == nullptr) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
//load up the opcode manager. //load up the opcode manager.
@ -40,17 +40,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register. //ok, now we have what we need to register.
EQStream::Signature signature; EQStream::Signature signature;
string pname; std::string pname;
//register our world signature. //register our world signature.
pname = string(name) + "_world"; pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0; signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct); signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo); signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature. //register our zone signature.
pname = string(name) + "_zone"; pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket); signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct); signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry); signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@ -67,7 +67,7 @@ void Reload() {
if(opcodes != nullptr) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) { if(!opcodes->ReloadOpcodes(opfile.c_str())) {
@ -547,7 +547,7 @@ ENCODE(OP_CharInventory) {
//do the transform... //do the transform...
int r; int r;
string serial_string; std::string serial_string;
for(r = 0; r < itemcount; r++, eq++) { for(r = 0; r < itemcount; r++, eq++) {
uint32 length; uint32 length;
char *serialized=SerializeItem((ItemInst*)eq->inst,eq->slot_id,&length,0); char *serialized=SerializeItem((ItemInst*)eq->inst,eq->slot_id,&length,0);

View File

@ -28,7 +28,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == nullptr) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
//load up the opcode manager. //load up the opcode manager.
@ -43,17 +43,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register. //ok, now we have what we need to register.
EQStream::Signature signature; EQStream::Signature signature;
string pname; std::string pname;
//register our world signature. //register our world signature.
pname = string(name) + "_world"; pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0; signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct); signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo); signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature. //register our zone signature.
pname = string(name) + "_zone"; pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket); signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct); signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry); signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@ -72,7 +72,7 @@ void Reload() {
if(opcodes != nullptr) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) { if(!opcodes->ReloadOpcodes(opfile.c_str())) {

View File

@ -28,7 +28,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == nullptr) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
//load up the opcode manager. //load up the opcode manager.
@ -43,17 +43,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register. //ok, now we have what we need to register.
EQStream::Signature signature; EQStream::Signature signature;
string pname; std::string pname;
//register our world signature. //register our world signature.
pname = string(name) + "_world"; pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0; signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct); signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo); signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature. //register our zone signature.
pname = string(name) + "_zone"; pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket); signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct); signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry); signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@ -72,7 +72,7 @@ void Reload() {
if(opcodes != nullptr) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) { if(!opcodes->ReloadOpcodes(opfile.c_str())) {

View File

@ -27,7 +27,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == nullptr) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
//load up the opcode manager. //load up the opcode manager.
@ -42,17 +42,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register. //ok, now we have what we need to register.
EQStream::Signature signature; EQStream::Signature signature;
string pname; std::string pname;
//register our world signature. //register our world signature.
pname = string(name) + "_world"; pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0; signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct); signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo); signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature. //register our zone signature.
pname = string(name) + "_zone"; pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket); signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct); signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry); signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@ -71,7 +71,7 @@ void Reload() {
if(opcodes != nullptr) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) { if(!opcodes->ReloadOpcodes(opfile.c_str())) {

View File

@ -25,7 +25,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == nullptr) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
//load up the opcode manager. //load up the opcode manager.
@ -40,17 +40,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register. //ok, now we have what we need to register.
EQStream::Signature signature; EQStream::Signature signature;
string pname; std::string pname;
//register our world signature. //register our world signature.
pname = string(name) + "_world"; pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0; signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct); signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo); signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature. //register our zone signature.
pname = string(name) + "_zone"; pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket); signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct); signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry); signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@ -69,7 +69,7 @@ void Reload() {
if(opcodes != nullptr) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) { if(!opcodes->ReloadOpcodes(opfile.c_str())) {
@ -639,7 +639,7 @@ ENCODE(OP_CharInventory) {
//do the transform... //do the transform...
int r; int r;
string serial_string; std::string serial_string;
for(r = 0; r < itemcount; r++, eq++) { for(r = 0; r < itemcount; r++, eq++) {
uint32 length; uint32 length;
char *serialized=SerializeItem((const ItemInst*)eq->inst,eq->slot_id,&length,0); char *serialized=SerializeItem((const ItemInst*)eq->inst,eq->slot_id,&length,0);

View File

@ -29,7 +29,7 @@ void Register(EQStreamIdentifier &into) {
//create our opcode manager if we havent already //create our opcode manager if we havent already
if(opcodes == nullptr) { if(opcodes == nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
//load up the opcode manager. //load up the opcode manager.
@ -44,17 +44,17 @@ void Register(EQStreamIdentifier &into) {
//ok, now we have what we need to register. //ok, now we have what we need to register.
EQStream::Signature signature; EQStream::Signature signature;
string pname; std::string pname;
//register our world signature. //register our world signature.
pname = string(name) + "_world"; pname = std::string(name) + "_world";
signature.ignore_eq_opcode = 0; signature.ignore_eq_opcode = 0;
signature.first_length = sizeof(structs::LoginInfo_Struct); signature.first_length = sizeof(structs::LoginInfo_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo); signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
//register our zone signature. //register our zone signature.
pname = string(name) + "_zone"; pname = std::string(name) + "_zone";
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket); signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
signature.first_length = sizeof(structs::ClientZoneEntry_Struct); signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry); signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
@ -73,7 +73,7 @@ void Reload() {
if(opcodes != nullptr) { if(opcodes != nullptr) {
//TODO: get this file name from the config file //TODO: get this file name from the config file
string opfile = "patch_"; std::string opfile = "patch_";
opfile += name; opfile += name;
opfile += ".conf"; opfile += ".conf";
if(!opcodes->ReloadOpcodes(opfile.c_str())) { if(!opcodes->ReloadOpcodes(opfile.c_str())) {

View File

@ -139,7 +139,7 @@ XS(XS_EQDBRes_fetch_row_array)
Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_array(THIS)"); Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_array(THIS)");
{ {
EQDBRes * THIS; EQDBRes * THIS;
vector<string> RETVAL; std::vector<std::string> RETVAL;
if (sv_derived_from(ST(0), "EQDBRes")) { if (sv_derived_from(ST(0), "EQDBRes")) {
IV tmp = SvIV((SV*)SvRV(ST(0))); 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 */ /* grow the stack to the number of elements being returned */
EXTEND(SP, RETVAL.size()); EXTEND(SP, RETVAL.size());
for (ix_RETVAL = 0; ix_RETVAL < RETVAL.size(); ix_RETVAL++) { 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(); ST(ix_RETVAL) = sv_newmortal();
sv_setpvn(ST(ix_RETVAL), it.c_str(), it.length()); 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)"); Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_hash(THIS)");
{ {
EQDBRes * THIS; EQDBRes * THIS;
map<string,string> RETVAL; std::map<std::string,std::string> RETVAL;
if (sv_derived_from(ST(0), "EQDBRes")) { if (sv_derived_from(ST(0), "EQDBRes")) {
IV tmp = SvIV((SV*)SvRV(ST(0))); IV tmp = SvIV((SV*)SvRV(ST(0)));
@ -199,7 +199,7 @@ XS(XS_EQDBRes_fetch_row_hash)
sv_2mortal((SV*)hv); sv_2mortal((SV*)hv);
ST(0) = newRV((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(); cur = RETVAL.begin();
end = RETVAL.end(); end = RETVAL.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {

View File

@ -289,7 +289,7 @@ PTimerList::PTimerList(uint32 char_id) {
} }
PTimerList::~PTimerList() { PTimerList::~PTimerList() {
map<pTimerType, PersistentTimer *>::iterator s; std::map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin(); s = _list.begin();
while(s != _list.end()) { while(s != _list.end()) {
if(s->second != nullptr) if(s->second != nullptr)
@ -300,7 +300,7 @@ PTimerList::~PTimerList() {
bool PTimerList::Load(Database *db) { bool PTimerList::Load(Database *db) {
map<pTimerType, PersistentTimer *>::iterator s; std::map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin(); s = _list.begin();
while(s != _list.end()) { while(s != _list.end()) {
if(s->second != nullptr) 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); printf("Storing all timers for char %lu\n", (unsigned long)_char_id);
#endif #endif
map<pTimerType, PersistentTimer *>::iterator s; std::map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin(); s = _list.begin();
bool res = true; bool res = true;
while(s != _list.end()) { while(s != _list.end()) {
@ -462,11 +462,11 @@ PersistentTimer *PTimerList::Get(pTimerType type) {
return(_list[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(); s = _list.begin();
while(s != _list.end()) { while(s != _list.end()) {
if(s->second != nullptr) { if(s->second != nullptr) {

View File

@ -21,7 +21,6 @@
#include "types.h" #include "types.h"
#include <map> #include <map>
#include <vector> #include <vector>
using namespace std;
enum { //values for pTimerType enum { //values for pTimerType
pTimerStartAdventureTimer = 1, pTimerStartAdventureTimer = 1,
@ -120,13 +119,13 @@ public:
inline void SetCharID(uint32 char_id) { _char_id = char_id; } 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 //Clear a timer for a char not logged in
//this is not defined on a char which is logged in! //this is not defined on a char which is logged in!
static bool ClearOffline(Database *db, uint32 char_id, pTimerType type); 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 begin() { return(_list.begin()); }
iterator end() { return(_list.end()); } iterator end() { return(_list.end()); }
@ -135,7 +134,7 @@ public:
protected: protected:
uint32 _char_id; uint32 _char_id;
map<pTimerType, PersistentTimer *> _list; std::map<pTimerType, PersistentTimer *> _list;
}; };
//code prettying macros //code prettying macros

View File

@ -19,8 +19,6 @@
#include "faction.h" #include "faction.h"
#include "features.h" #include "features.h"
using namespace std;
SharedDatabase::SharedDatabase() SharedDatabase::SharedDatabase()
: Database(), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr), faction_mmf(nullptr), faction_hash(nullptr), : 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) loot_table_mmf(nullptr), loot_drop_mmf(nullptr), loot_table_hash(nullptr), loot_drop_hash(nullptr)
@ -52,7 +50,7 @@ bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET hideme = %i where id = %i", hideme, account_id), errbuf)) { 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); safe_delete_array(query);
return false; return false;
} }
@ -87,7 +85,7 @@ uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
else else
{ {
cerr << "Error in GetGMSpeed query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetGMSpeed query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
@ -103,7 +101,7 @@ bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET gmspeed = %i where id = %i", gmspeed, account_id), errbuf)) { 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); safe_delete_array(query);
return false; return false;
} }
@ -142,7 +140,7 @@ uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
return EntitledTime; 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; iter_queue it;
int i; int i;
@ -157,7 +155,7 @@ bool ret=true;
break; break;
} }
} else { } else {
cout << "Clearing cursor failed: " << errbuf << endl; std::cout << "Clearing cursor failed: " << errbuf << std::endl;
} }
safe_delete_array(query); safe_delete_array(query);
@ -339,8 +337,7 @@ int32 SharedDatabase::GetSharedPlatinum(uint32 account_id)
} }
else else
{ {
std::cerr << "Error in GetSharedPlatinum query '" << query << "' " << errbuf << std::endl;
cerr << "Error in GetSharedPlatinum query '" << query << "' " << errbuf << endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
@ -354,7 +351,7 @@ bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add)
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i", amount_to_add, account_id), errbuf)) { 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); safe_delete_array(query);
return false; return false;
} }
@ -1051,17 +1048,17 @@ const Item_Struct* SharedDatabase::IterateItems(uint32* id) {
return nullptr; return nullptr;
} }
string SharedDatabase::GetBook(const char *txtfile) std::string SharedDatabase::GetBook(const char *txtfile)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
char txtfile2[20]; char txtfile2[20];
string txtout; std::string txtout;
strcpy(txtfile2,txtfile); strcpy(txtfile2,txtfile);
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT txtfile FROM books where name='%s'", txtfile2), errbuf, &result)) { 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) if (query != 0)
safe_delete_array(query); safe_delete_array(query);
txtout.assign(" ",1); txtout.assign(" ",1);
@ -1401,7 +1398,7 @@ int32 SharedDatabase::DeleteStalePlayerBackups() {
return affected_rows; 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 errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
@ -1417,7 +1414,7 @@ bool SharedDatabase::GetCommandSettings(map<string,uint8> &commands) {
mysql_free_result(result); mysql_free_result(result);
return true; return true;
} else { } else {
cerr << "Error in GetCommands query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetCommands query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
@ -1975,7 +1972,7 @@ void SharedDatabase::GetPlayerInspectMessage(char* playername, InspectMessage_St
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in GetPlayerInspectMessage query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
} }
@ -1986,7 +1983,7 @@ void SharedDatabase::SetPlayerInspectMessage(char* playername, const InspectMess
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET inspectmessage='%s' WHERE name='%s'", message->text, playername), errbuf)) { 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); safe_delete_array(query);
@ -2010,7 +2007,7 @@ void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* m
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in GetBotInspectMessage query '" << query << "' " << errbuf << endl; std::cerr << "Error in GetBotInspectMessage query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); safe_delete_array(query);
} }
} }
@ -2021,7 +2018,7 @@ void SharedDatabase::SetBotInspectMessage(uint32 botid, const InspectMessage_Str
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE bots SET BotInspectMessage='%s' WHERE BotID=%i", message->text, botid), errbuf)) { 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); safe_delete_array(query);

View File

@ -48,7 +48,7 @@ public:
void SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message); void SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message);
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message); void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
void SetBotInspectMessage(uint32 botid, const 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); 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); 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 * Item Methods

View File

@ -36,7 +36,7 @@ TimeoutManager::TimeoutManager() {
} }
void TimeoutManager::CheckTimeouts() { void TimeoutManager::CheckTimeouts() {
vector<Timeoutable *>::iterator cur,end; std::vector<Timeoutable *>::iterator cur,end;
cur = members.begin(); cur = members.begin();
end = members.end(); end = members.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@ -66,7 +66,7 @@ void TimeoutManager::DeleteMember(Timeoutable *who) {
#ifdef TIMEOUT_DEBUG #ifdef TIMEOUT_DEBUG
LogFile->write(EQEMuLog::Debug, "Removing timeoutable 0x%x\n", who); LogFile->write(EQEMuLog::Debug, "Removing timeoutable 0x%x\n", who);
#endif #endif
vector<Timeoutable *>::iterator cur,end; std::vector<Timeoutable *>::iterator cur,end;
cur = members.begin(); cur = members.begin();
end = members.end(); end = members.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {

View File

@ -27,7 +27,6 @@
#include "timer.h" #include "timer.h"
#include <vector> #include <vector>
using namespace std;
//timeoutable objects automatically register themselves //timeoutable objects automatically register themselves
//with the global TimeoutManager object //with the global TimeoutManager object
@ -59,7 +58,7 @@ protected:
void AddMember(Timeoutable *who); void AddMember(Timeoutable *who);
void DeleteMember(Timeoutable *who); void DeleteMember(Timeoutable *who);
vector<Timeoutable *> members; std::vector<Timeoutable *> members;
}; };
extern TimeoutManager timeout_manager; extern TimeoutManager timeout_manager;

View File

@ -24,7 +24,6 @@
#endif #endif
#include <iostream> #include <iostream>
using namespace std;
#include "timer.h" #include "timer.h"
@ -77,7 +76,7 @@ bool Timer::Check(bool iReset)
{ {
_CP(Timer_Check); _CP(Timer_Check);
if (this==0) { if (this==0) {
cerr << "Null timer during ->Check()!?\n"; std::cerr << "Null timer during ->Check()!?\n";
return true; return true;
} }
// if (!current_time || !start_time || !timer_time) {cerr << "Timer::Check on a timer that does not have a vital member defined."; // if (!current_time || !start_time || !timer_time) {cerr << "Timer::Check on a timer that does not have a vital member defined.";

View File

@ -21,7 +21,6 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>
using namespace std;
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -30,8 +30,6 @@
#include <signal.h> #include <signal.h>
#include <time.h> #include <time.h>
using namespace std;
bool RunLoops = false; bool RunLoops = false;
void CatchSignal(int sig_num); void CatchSignal(int sig_num);
@ -40,7 +38,7 @@ int main(int argc, char *argv[]) {
RegisterExecutablePlatform(ExePlatformLaunch); RegisterExecutablePlatform(ExePlatformLaunch);
set_exception_handler(); set_exception_handler();
string launcher_name; std::string launcher_name;
if(argc == 2) { if(argc == 2) {
launcher_name = argv[1]; launcher_name = argv[1];
} }
@ -87,14 +85,14 @@ int main(int argc, char *argv[]) {
} }
#endif #endif
map<string, ZoneLaunch *> zones; std::map<std::string, ZoneLaunch *> zones;
WorldServer world(zones, launcher_name.c_str(), Config); WorldServer world(zones, launcher_name.c_str(), Config);
if (!world.Connect()) { if (!world.Connect()) {
_log(LAUNCHER__ERROR, "worldserver.Connect() FAILED! Will retry."); _log(LAUNCHER__ERROR, "worldserver.Connect() FAILED! Will retry.");
} }
map<string, ZoneLaunch *>::iterator zone, zend; std::map<std::string, ZoneLaunch *>::iterator zone, zend;
set<string> to_remove; std::set<std::string> to_remove;
Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect
@ -132,7 +130,7 @@ int main(int argc, char *argv[]) {
* Kill off any zones which have stopped * Kill off any zones which have stopped
*/ */
while(!to_remove.empty()) { while(!to_remove.empty()) {
string rem = *to_remove.begin(); std::string rem = *to_remove.begin();
to_remove.erase(rem); to_remove.erase(rem);
zone = zones.find(rem); zone = zones.find(rem);
if(zone == zones.end()) { if(zone == zones.end()) {

View File

@ -23,7 +23,7 @@
#include "../common/StringUtil.h" #include "../common/StringUtil.h"
WorldServer::WorldServer(map<string, ZoneLaunch *> &zones, const char *name, const EQEmuConfig *config) WorldServer::WorldServer(std::map<std::string, ZoneLaunch *> &zones, const char *name, const EQEmuConfig *config)
: WorldConnection(EmuTCPConnection::packetModeLauncher, config->SharedKey.c_str()), : WorldConnection(EmuTCPConnection::packetModeLauncher, config->SharedKey.c_str()),
m_name(name), m_name(name),
m_config(config), m_config(config),
@ -98,7 +98,7 @@ void WorldServer::Process() {
break; break;
} }
case ZR_Restart: { case ZR_Restart: {
map<string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name); std::map<std::string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
if(res == m_zones.end()) { if(res == m_zones.end()) {
_log(LAUNCHER__ERROR, "World told us to restart zone %s, but it is not running.", lzr->short_name); _log(LAUNCHER__ERROR, "World told us to restart zone %s, but it is not running.", lzr->short_name);
} else { } else {
@ -108,7 +108,7 @@ void WorldServer::Process() {
break; break;
} }
case ZR_Stop: { case ZR_Stop: {
map<string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name); std::map<std::string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
if(res == m_zones.end()) { if(res == m_zones.end()) {
_log(LAUNCHER__ERROR, "World told us to stop zone %s, but it is not running.", lzr->short_name); _log(LAUNCHER__ERROR, "World told us to stop zone %s, but it is not running.", lzr->short_name);
} else { } else {

View File

@ -25,19 +25,19 @@ extern ErrorLog *server_log;
* First gets the map from the title * First gets the map from the title
* Then gets the argument from the map we got from title * Then gets the argument from the map we got from title
*/ */
string Config::GetVariable(string title, string parameter) std::string Config::GetVariable(std::string title, std::string parameter)
{ {
map<string, map<string, string> >::iterator iter = vars.find(title); std::map<std::string, std::map<std::string, std::string> >::iterator iter = vars.find(title);
if(iter != vars.end()) if(iter != vars.end())
{ {
map<string, string>::iterator arg_iter = iter->second.find(parameter); std::map<std::string, std::string>::iterator arg_iter = iter->second.find(parameter);
if(arg_iter != iter->second.end()) if(arg_iter != iter->second.end())
{ {
return arg_iter->second; return arg_iter->second;
} }
} }
return string(""); return std::string("");
} }
/** /**
@ -56,12 +56,12 @@ void Config::Parse(const char *file_name)
FILE *input = fopen(file_name, "r"); FILE *input = fopen(file_name, "r");
if(input) if(input)
{ {
list<string> tokens; std::list<std::string> tokens;
Tokenize(input, tokens); Tokenize(input, tokens);
char mode = 0; char mode = 0;
string title, param, arg; std::string title, param, arg;
list<string>::iterator iter = tokens.begin(); std::list<std::string>::iterator iter = tokens.begin();
while(iter != tokens.end()) while(iter != tokens.end())
{ {
if((*iter).compare("[") == 0) if((*iter).compare("[") == 0)
@ -114,7 +114,7 @@ void Config::Parse(const char *file_name)
{ {
arg = (*iter); arg = (*iter);
mode = 0; mode = 0;
map<string, map<string, string> >::iterator map_iter = vars.find(title); std::map<std::string, std::map<std::string, std::string> >::iterator map_iter = vars.find(title);
if(map_iter != vars.end()) if(map_iter != vars.end())
{ {
map_iter->second[param] = arg; map_iter->second[param] = arg;
@ -122,7 +122,7 @@ void Config::Parse(const char *file_name)
} }
else else
{ {
map<string, string> var_map; std::map<std::string, std::string> var_map;
var_map[param] = arg; var_map[param] = arg;
vars[title] = var_map; vars[title] = var_map;
} }
@ -142,10 +142,10 @@ void Config::Parse(const char *file_name)
* Breaks up the input character stream into tokens and puts them into the list provided. * Breaks up the input character stream into tokens and puts them into the list provided.
* Ignores # as a line comment * Ignores # as a line comment
*/ */
void Config::Tokenize(FILE *input, list<string> &tokens) void Config::Tokenize(FILE *input, std::list<std::string> &tokens)
{ {
char c = fgetc(input); char c = fgetc(input);
string lexeme; std::string lexeme;
while(c != EOF) while(c != EOF)
{ {

View File

@ -23,8 +23,6 @@
#include <map> #include <map>
#include <string> #include <string>
using namespace std;
/** /**
* Keeps track of all the configuration for the application with a small parser. * Keeps track of all the configuration for the application with a small parser.
* Note: This is not a thread safe class, but only parse writes to variables in the class. * Note: This is not a thread safe class, but only parse writes to variables in the class.
@ -44,10 +42,10 @@ public:
/** /**
* Gets a variable if it exists. * Gets a variable if it exists.
*/ */
string GetVariable(string title, string parameter); std::string GetVariable(std::string title, std::string parameter);
protected: protected:
map<string, map<string, string> > vars; std::map<std::string, std::map<std::string, std::string> > vars;
private: private:
/** /**
@ -56,7 +54,7 @@ private:
* may get it's input from other places than a C file pointer. (a http get request for example). * may get it's input from other places than a C file pointer. (a http get request for example).
* The programmer of a derived class would be expected to make their own Tokenize function for their own Parse(). * The programmer of a derived class would be expected to make their own Tokenize function for their own Parse().
*/ */
void Tokenize(FILE* input, list<string> &tokens); void Tokenize(FILE* input, std::list<std::string> &tokens);
}; };
#endif #endif

View File

@ -20,8 +20,6 @@
#include <string> #include <string>
using namespace std;
#define EQEMU_MYSQL_ENABLED #define EQEMU_MYSQL_ENABLED
//#define EQEMU_POSTGRESQL_ENABLED //#define EQEMU_POSTGRESQL_ENABLED
@ -44,37 +42,37 @@ public:
* Needed for client login procedure. * Needed for client login procedure.
* Returns true if the record was found, false otherwise. * Returns true if the record was found, false otherwise.
*/ */
virtual bool GetLoginDataFromAccountName(string name, string &password, unsigned int &id) { return false; } virtual bool GetLoginDataFromAccountName(std::string name, std::string &password, unsigned int &id) { return false; }
/** /**
* Retrieves the world registration from the long and short names provided. * Retrieves the world registration from the long and short names provided.
* Needed for world login procedure. * Needed for world login procedure.
* Returns true if the record was found, false otherwise. * Returns true if the record was found, false otherwise.
*/ */
virtual bool GetWorldRegistration(string long_name, string short_name, unsigned int &id, string &desc, unsigned int &list_id, virtual bool GetWorldRegistration(std::string long_name, std::string short_name, unsigned int &id, std::string &desc, unsigned int &list_id,
unsigned int &trusted, string &list_desc, string &account, string &password) { return false; } unsigned int &trusted, std::string &list_desc, std::string &account, std::string &password) { return false; }
/** /**
* Updates the ip address of the client with account id = id * Updates the ip address of the client with account id = id
*/ */
virtual void UpdateLSAccountData(unsigned int id, string ip_address) { } virtual void UpdateLSAccountData(unsigned int id, std::string ip_address) { }
/** /**
* Updates or creates the login server account with info from world server * Updates or creates the login server account with info from world server
*/ */
virtual void UpdateLSAccountInfo(unsigned int id, string name, string password, string email) { } virtual void UpdateLSAccountInfo(unsigned int id, std::string name, std::string password, std::string email) { }
/** /**
* Updates the ip address of the world with account id = id * Updates the ip address of the world with account id = id
*/ */
virtual void UpdateWorldRegistration(unsigned int id, string long_name, string ip_address) { } virtual void UpdateWorldRegistration(unsigned int id, std::string long_name, std::string ip_address) { }
/** /**
* Creates new world registration for unregistered servers and returns new id * Creates new world registration for unregistered servers and returns new id
*/ */
virtual bool CreateWorldRegistration(string long_name, string short_name, unsigned int &id) { return false; } virtual bool CreateWorldRegistration(std::string long_name, std::string short_name, unsigned int &id) { return false; }
protected: protected:
string user, pass, host, port, name; std::string user, pass, host, port, name;
}; };
#endif #endif

View File

@ -26,8 +26,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <mysql.h> #include <mysql.h>
using namespace std;
/** /**
* Mysql Database class * Mysql Database class
*/ */
@ -42,7 +40,7 @@ public:
/** /**
* Constructor, tries to set our database to connect to the supplied options. * Constructor, tries to set our database to connect to the supplied options.
*/ */
DatabaseMySQL(string user, string pass, string host, string port, string name); DatabaseMySQL(std::string user, std::string pass, std::string host, std::string port, std::string name);
/** /**
* Destructor, frees our database if needed. * Destructor, frees our database if needed.
@ -59,37 +57,37 @@ public:
* Needed for client login procedure. * Needed for client login procedure.
* Returns true if the record was found, false otherwise. * Returns true if the record was found, false otherwise.
*/ */
virtual bool GetLoginDataFromAccountName(string name, string &password, unsigned int &id); virtual bool GetLoginDataFromAccountName(std::string name, std::string &password, unsigned int &id);
/** /**
* Retrieves the world registration from the long and short names provided. * Retrieves the world registration from the long and short names provided.
* Needed for world login procedure. * Needed for world login procedure.
* Returns true if the record was found, false otherwise. * Returns true if the record was found, false otherwise.
*/ */
virtual bool GetWorldRegistration(string long_name, string short_name, unsigned int &id, string &desc, unsigned int &list_id, virtual bool GetWorldRegistration(std::string long_name, std::string short_name, unsigned int &id, std::string &desc, unsigned int &list_id,
unsigned int &trusted, string &list_desc, string &account, string &password); unsigned int &trusted, std::string &list_desc, std::string &account, std::string &password);
/** /**
* Updates the ip address of the client with account id = id * Updates the ip address of the client with account id = id
*/ */
virtual void UpdateLSAccountData(unsigned int id, string ip_address); virtual void UpdateLSAccountData(unsigned int id, std::string ip_address);
/** /**
* Updates or creates the login server account with info from world server * Updates or creates the login server account with info from world server
*/ */
virtual void UpdateLSAccountInfo(unsigned int id, string name, string password, string email); virtual void UpdateLSAccountInfo(unsigned int id, std::string name, std::string password, std::string email);
/** /**
* Updates the ip address of the world with account id = id * Updates the ip address of the world with account id = id
*/ */
virtual void UpdateWorldRegistration(unsigned int id, string long_name, string ip_address); virtual void UpdateWorldRegistration(unsigned int id, std::string long_name, std::string ip_address);
/** /**
* Creates new world registration for unregistered servers and returns new id * Creates new world registration for unregistered servers and returns new id
*/ */
virtual bool CreateWorldRegistration(string long_name, string short_name, unsigned int &id); virtual bool CreateWorldRegistration(std::string long_name, std::string short_name, unsigned int &id);
protected: protected:
string user, pass, host, port, name; std::string user, pass, host, port, name;
MYSQL *db; MYSQL *db;
}; };

View File

@ -22,8 +22,6 @@
#include <windows.h> #include <windows.h>
#include <string> #include <string>
using namespace std;
typedef char*(*DLLFUNC_DecryptUsernamePassword)(const char*, unsigned int, int); typedef char*(*DLLFUNC_DecryptUsernamePassword)(const char*, unsigned int, int);
typedef char*(*DLLFUNC_Encrypt)(const char*, unsigned int, unsigned int&); typedef char*(*DLLFUNC_Encrypt)(const char*, unsigned int, unsigned int&);
typedef void(*DLLFUNC_HeapDelete)(char*); typedef void(*DLLFUNC_HeapDelete)(char*);
@ -54,7 +52,7 @@ public:
* Loads the plugin. * Loads the plugin.
* True if there are no errors, false if there was an error. * True if there are no errors, false if there was an error.
*/ */
bool LoadCrypto(string name); bool LoadCrypto(std::string name);
/** /**
* Wrapper around the plugin's decrypt function. * Wrapper around the plugin's decrypt function.

View File

@ -25,8 +25,6 @@
#include "../common/Mutex.h" #include "../common/Mutex.h"
using namespace std;
/** /**
* Dictates the log type specified in ErrorLog for Log(...) * Dictates the log type specified in ErrorLog for Log(...)
*/ */

View File

@ -32,7 +32,6 @@ TimeoutManager timeout_manager;
LoginServer server; LoginServer server;
ErrorLog *server_log; ErrorLog *server_log;
bool run_server = true; bool run_server = true;
using namespace std;
void CatchSignal(int sig_num) void CatchSignal(int sig_num)
{ {
@ -45,7 +44,7 @@ int main()
//Create our error log, is of format login_<number>.log //Create our error log, is of format login_<number>.log
time_t current_time = time(nullptr); time_t current_time = time(nullptr);
stringstream log_name(stringstream::in | stringstream::out); std::stringstream log_name(std::stringstream::in | std::stringstream::out);
#ifdef WIN32 #ifdef WIN32
log_name << ".\\logs\\login_" << (unsigned int)current_time << ".log"; log_name << ".\\logs\\login_" << (unsigned int)current_time << ".log";
#else #else
@ -90,14 +89,14 @@ int main()
} }
//Parse encryption mode option. //Parse encryption mode option.
string mode = server.config->GetVariable("security", "mode"); std::string mode = server.config->GetVariable("security", "mode");
if(mode.size() > 0) if(mode.size() > 0)
{ {
server.options.EncryptionMode(atoi(mode.c_str())); server.options.EncryptionMode(atoi(mode.c_str()));
} }
//Parse local network option. //Parse local network option.
string ln = server.config->GetVariable("options", "local_network"); std::string ln = server.config->GetVariable("options", "local_network");
if(ln.size() > 0) if(ln.size() > 0)
{ {
server.options.LocalNetwork(ln); server.options.LocalNetwork(ln);

View File

@ -100,52 +100,52 @@ public:
/** /**
* Sets local_network. * Sets local_network.
*/ */
inline void LocalNetwork(string n) { local_network = n; } inline void LocalNetwork(std::string n) { local_network = n; }
/** /**
* Return the value of local_network. * Return the value of local_network.
*/ */
inline string GetLocalNetwork() const { return local_network; } inline std::string GetLocalNetwork() const { return local_network; }
/** /**
* Sets account table. * Sets account table.
*/ */
inline void AccountTable(string t) { account_table = t; } inline void AccountTable(std::string t) { account_table = t; }
/** /**
* Return the value of local_network. * Return the value of local_network.
*/ */
inline string GetAccountTable() const { return account_table; } inline std::string GetAccountTable() const { return account_table; }
/** /**
* Sets world account table. * Sets world account table.
*/ */
inline void WorldRegistrationTable(string t) { world_registration_table = t; } inline void WorldRegistrationTable(std::string t) { world_registration_table = t; }
/** /**
* Return the value of world account table. * Return the value of world account table.
*/ */
inline string GetWorldRegistrationTable() const { return world_registration_table; } inline std::string GetWorldRegistrationTable() const { return world_registration_table; }
/** /**
* Sets world admin account table. * Sets world admin account table.
*/ */
inline void WorldAdminRegistrationTable(string t) { world_admin_registration_table = t; } inline void WorldAdminRegistrationTable(std::string t) { world_admin_registration_table = t; }
/** /**
* Return the value of world admin account table. * Return the value of world admin account table.
*/ */
inline string GetWorldAdminRegistrationTable() const { return world_admin_registration_table; } inline std::string GetWorldAdminRegistrationTable() const { return world_admin_registration_table; }
/** /**
* Sets world server type table. * Sets world server type table.
*/ */
inline void WorldServerTypeTable(string t) { world_server_type_table = t; } inline void WorldServerTypeTable(std::string t) { world_server_type_table = t; }
/** /**
* Return the value of world admin account table. * Return the value of world admin account table.
*/ */
inline string GetWorldServerTypeTable() const { return world_server_type_table; } inline std::string GetWorldServerTypeTable() const { return world_server_type_table; }
/** /**
* Sets whether we are rejecting duplicate servers or not. * Sets whether we are rejecting duplicate servers or not.
@ -165,11 +165,11 @@ private:
bool dump_out_packets; bool dump_out_packets;
bool reject_duplicate_servers; bool reject_duplicate_servers;
int encryption_mode; int encryption_mode;
string local_network; std::string local_network;
string account_table; std::string account_table;
string world_registration_table; std::string world_registration_table;
string world_admin_registration_table; std::string world_admin_registration_table;
string world_server_type_table; std::string world_server_type_table;
}; };
#endif #endif

View File

@ -28,8 +28,6 @@
#include "Client.h" #include "Client.h"
#include <list> #include <list>
using namespace std;
/** /**
* Server manager class, deals with management of the world servers. * Server manager class, deals with management of the world servers.
*/ */
@ -64,12 +62,12 @@ public:
/** /**
* Checks to see if there is a server exists with this name, ignoring option. * Checks to see if there is a server exists with this name, ignoring option.
*/ */
bool ServerExists(string l_name, string s_name, WorldServer *ignore = nullptr); bool ServerExists(std::string l_name, std::string s_name, WorldServer *ignore = nullptr);
/** /**
* Destroys a server with this name, ignoring option. * Destroys a server with this name, ignoring option.
*/ */
void DestroyServerByName(string l_name, string s_name, WorldServer *ignore = nullptr); void DestroyServerByName(std::string l_name, std::string s_name, WorldServer *ignore = nullptr);
private: private:
/** /**
@ -84,7 +82,7 @@ private:
WorldServer* GetServerByAddress(unsigned int address); WorldServer* GetServerByAddress(unsigned int address);
EmuTCPServer* tcps; EmuTCPServer* tcps;
list<WorldServer*> world_servers; std::list<WorldServer*> world_servers;
}; };
#endif #endif

View File

@ -26,8 +26,6 @@
#include "../common/packet_dump.h" #include "../common/packet_dump.h"
#include <string> #include <string>
using namespace std;
/** /**
* World server class, controls the connected server processing. * World server class, controls the connected server processing.
*/ */
@ -78,12 +76,12 @@ public:
/** /**
* Gets the long name of the server. * Gets the long name of the server.
*/ */
string GetLongName() const { return long_name; } std::string GetLongName() const { return long_name; }
/** /**
* Gets the short name of the server. * Gets the short name of the server.
*/ */
string GetShortName() const { return short_name; } std::string GetShortName() const { return short_name; }
/** /**
* Gets whether the server is authorized to show up on the server list or not. * Gets whether the server is authorized to show up on the server list or not.
@ -93,12 +91,12 @@ public:
/** /**
* Gets the local ip of the server. * Gets the local ip of the server.
*/ */
string GetLocalIP() const { return local_ip; } std::string GetLocalIP() const { return local_ip; }
/** /**
* Gets the remote ip of the server. * Gets the remote ip of the server.
*/ */
string GetRemoteIP() const { return remote_ip; } std::string GetRemoteIP() const { return remote_ip; }
/** /**
* Gets what kind of server this server is (legends, preferred, normal) * Gets what kind of server this server is (legends, preferred, normal)
@ -133,7 +131,7 @@ public:
/** /**
* Informs world that there is a client incoming with the following data. * Informs world that there is a client incoming with the following data.
*/ */
void SendClientAuth(unsigned int ip, string account, string key, unsigned int account_id); void SendClientAuth(unsigned int ip, std::string account, std::string key, unsigned int account_id);
private: private:
@ -144,15 +142,15 @@ private:
unsigned int runtime_id; unsigned int runtime_id;
unsigned int server_list_id; unsigned int server_list_id;
unsigned int server_type; unsigned int server_type;
string desc; std::string desc;
string long_name; std::string long_name;
string short_name; std::string short_name;
string account_name; std::string account_name;
string account_password; std::string account_password;
string remote_ip; std::string remote_ip;
string local_ip; std::string local_ip;
string protocol; std::string protocol;
string version; std::string version;
bool authorized; bool authorized;
bool logged_in; bool logged_in;
bool trusted; bool trusted;

View File

@ -20,7 +20,6 @@
#include "../common/debug.h" #include "../common/debug.h"
#include <iostream> #include <iostream>
using namespace std;
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -31,7 +31,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
using namespace std;
//atoi is not uint32 or uint32 safe!!!! //atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10) #define atoul(str) strtoul(str, nullptr, 10)

View File

@ -40,7 +40,7 @@ TimeoutManager timeout_manager;
Database database; Database database;
LFGuildManager lfguildmanager; LFGuildManager lfguildmanager;
string WorldShortName; std::string WorldShortName;
const queryservconfig *Config; const queryservconfig *Config;

View File

@ -22,7 +22,7 @@
queryservconfig *queryservconfig::_chat_config = nullptr; queryservconfig *queryservconfig::_chat_config = nullptr;
string queryservconfig::GetByName(const string &var_name) const { std::string queryservconfig::GetByName(const std::string &var_name) const {
return(EQEmuConfig::GetByName(var_name)); return(EQEmuConfig::GetByName(var_name));
} }

View File

@ -24,7 +24,7 @@
class queryservconfig : public EQEmuConfig { class queryservconfig : public EQEmuConfig {
public: public:
virtual string GetByName(const string &var_name) const; virtual std::string GetByName(const std::string &var_name) const;
private: private:

View File

@ -17,7 +17,6 @@
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include <iostream> #include <iostream>
using namespace std;
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>
@ -81,8 +80,8 @@ void WorldServer::Process()
{ {
Server_Speech_Struct *SSS = (Server_Speech_Struct*)pack->pBuffer; Server_Speech_Struct *SSS = (Server_Speech_Struct*)pack->pBuffer;
string tmp1 = SSS->from; std::string tmp1 = SSS->from;
string tmp2 = SSS->to; std::string tmp2 = SSS->to;
database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type); database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type);
break; break;

View File

@ -26,7 +26,7 @@
extern Database database; extern Database database;
extern uint32 ChatMessagesSent; extern uint32 ChatMessagesSent;
ChatChannel::ChatChannel(string inName, string inOwner, string inPassword, bool inPermanent, int inMinimumStatus) : ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus) :
DeleteTimer(0) { DeleteTimer(0) {
Name = inName; Name = inName;
@ -56,7 +56,7 @@ ChatChannel::~ChatChannel() {
iterator.RemoveCurrent(false); iterator.RemoveCurrent(false);
} }
ChatChannel* ChatChannelList::CreateChannel(string Name, string Owner, string Password, bool Permanent, int MinimumStatus) { ChatChannel* ChatChannelList::CreateChannel(std::string Name, std::string Owner, std::string Password, bool Permanent, int MinimumStatus) {
ChatChannel *NewChannel = new ChatChannel(CapitaliseName(Name), Owner, Password, Permanent, MinimumStatus); ChatChannel *NewChannel = new ChatChannel(CapitaliseName(Name), Owner, Password, Permanent, MinimumStatus);
@ -65,9 +65,9 @@ ChatChannel* ChatChannelList::CreateChannel(string Name, string Owner, string Pa
return NewChannel; return NewChannel;
} }
ChatChannel* ChatChannelList::FindChannel(string Name) { ChatChannel* ChatChannelList::FindChannel(std::string Name) {
string NormalisedName = CapitaliseName(Name); std::string NormalisedName = CapitaliseName(Name);
LinkedListIterator<ChatChannel*> iterator(ChatChannels); LinkedListIterator<ChatChannel*> iterator(ChatChannels);
@ -103,7 +103,7 @@ void ChatChannelList::SendAllChannels(Client *c) {
iterator.Reset(); iterator.Reset();
string Message; std::string Message;
char CountString[10]; char CountString[10];
@ -200,7 +200,7 @@ int ChatChannel::MemberCount(int Status) {
return Count; return Count;
} }
void ChatChannel::SetPassword(string inPassword) { void ChatChannel::SetPassword(std::string inPassword) {
Password = inPassword; Password = inPassword;
@ -211,7 +211,7 @@ void ChatChannel::SetPassword(string inPassword) {
} }
} }
void ChatChannel::SetOwner(string inOwner) { void ChatChannel::SetOwner(std::string inOwner) {
Owner = inOwner; Owner = inOwner;
@ -312,7 +312,7 @@ void ChatChannel::SendOPList(Client *c) {
c->GeneralChannelMessage("Channel " + Name + " op-list: (Owner=" + Owner + ")"); c->GeneralChannelMessage("Channel " + Name + " op-list: (Owner=" + Owner + ")");
list<string>::iterator Iterator; std::list<std::string>::iterator Iterator;
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++) for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++)
c->GeneralChannelMessage((*Iterator)); c->GeneralChannelMessage((*Iterator));
@ -327,7 +327,7 @@ void ChatChannel::SendChannelMembers(Client *c) {
sprintf(CountString, "(%i)", MemberCount(c->GetAccountStatus())); sprintf(CountString, "(%i)", MemberCount(c->GetAccountStatus()));
string Message = "Channel " + GetName(); std::string Message = "Channel " + GetName();
Message += CountString; Message += CountString;
@ -380,7 +380,7 @@ void ChatChannel::SendChannelMembers(Client *c) {
} }
void ChatChannel::SendMessageToChannel(string Message, Client* Sender) { void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
if(!Sender) return; if(!Sender) return;
@ -448,7 +448,7 @@ bool ChatChannel::IsClientInChannel(Client *c) {
return false; return false;
} }
ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c) { ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client *c) {
if(!c) return nullptr; if(!c) return nullptr;
@ -459,11 +459,11 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
return nullptr; return nullptr;
} }
string NormalisedName, Password; std::string NormalisedName, Password;
string::size_type Colon = ChannelName.find_first_of(":"); std::string::size_type Colon = ChannelName.find_first_of(":");
if(Colon == string::npos) if(Colon == std::string::npos)
NormalisedName = CapitaliseName(ChannelName); NormalisedName = CapitaliseName(ChannelName);
else { else {
NormalisedName = CapitaliseName(ChannelName.substr(0, Colon)); NormalisedName = CapitaliseName(ChannelName.substr(0, Colon));
@ -487,7 +487,7 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
if(RequiredChannel->GetMinStatus() > c->GetAccountStatus()) { if(RequiredChannel->GetMinStatus() > c->GetAccountStatus()) {
string Message = "You do not have the required account status to join channel " + NormalisedName; std::string Message = "You do not have the required account status to join channel " + NormalisedName;
c->GeneralChannelMessage(Message); c->GeneralChannelMessage(Message);
@ -519,11 +519,11 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
return nullptr; return nullptr;
} }
ChatChannel *ChatChannelList::RemoveClientFromChannel(string inChannelName, Client *c) { ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName, Client *c) {
if(!c) return nullptr; if(!c) return nullptr;
string ChannelName = inChannelName; std::string ChannelName = inChannelName;
if((inChannelName.length() > 0) && isdigit(ChannelName[0])) if((inChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = c->ChannelSlotName(atoi(inChannelName.c_str())); ChannelName = c->ChannelSlotName(atoi(inChannelName.c_str()));
@ -565,7 +565,7 @@ void ChatChannelList::Process() {
} }
} }
void ChatChannel::AddInvitee(string Invitee) { void ChatChannel::AddInvitee(std::string Invitee) {
if(!IsInvitee(Invitee)) { if(!IsInvitee(Invitee)) {
@ -576,9 +576,9 @@ void ChatChannel::AddInvitee(string Invitee) {
} }
void ChatChannel::RemoveInvitee(string Invitee) { void ChatChannel::RemoveInvitee(std::string Invitee) {
list<string>::iterator Iterator; std::list<std::string>::iterator Iterator;
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); Iterator++) { for(Iterator = Invitees.begin(); Iterator != Invitees.end(); Iterator++) {
@ -593,9 +593,9 @@ void ChatChannel::RemoveInvitee(string Invitee) {
} }
} }
bool ChatChannel::IsInvitee(string Invitee) { bool ChatChannel::IsInvitee(std::string Invitee) {
list<string>::iterator Iterator; std::list<std::string>::iterator Iterator;
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); Iterator++) { for(Iterator = Invitees.begin(); Iterator != Invitees.end(); Iterator++) {
@ -606,7 +606,7 @@ bool ChatChannel::IsInvitee(string Invitee) {
return false; return false;
} }
void ChatChannel::AddModerator(string Moderator) { void ChatChannel::AddModerator(std::string Moderator) {
if(!IsModerator(Moderator)) { if(!IsModerator(Moderator)) {
@ -617,9 +617,9 @@ void ChatChannel::AddModerator(string Moderator) {
} }
void ChatChannel::RemoveModerator(string Moderator) { void ChatChannel::RemoveModerator(std::string Moderator) {
list<string>::iterator Iterator; std::list<std::string>::iterator Iterator;
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++) { for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++) {
@ -634,9 +634,9 @@ void ChatChannel::RemoveModerator(string Moderator) {
} }
} }
bool ChatChannel::IsModerator(string Moderator) { bool ChatChannel::IsModerator(std::string Moderator) {
list<string>::iterator Iterator; std::list<std::string>::iterator Iterator;
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++) { for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++) {
@ -647,7 +647,7 @@ bool ChatChannel::IsModerator(string Moderator) {
return false; return false;
} }
void ChatChannel::AddVoice(string inVoiced) { void ChatChannel::AddVoice(std::string inVoiced) {
if(!HasVoice(inVoiced)) { if(!HasVoice(inVoiced)) {
@ -658,9 +658,9 @@ void ChatChannel::AddVoice(string inVoiced) {
} }
void ChatChannel::RemoveVoice(string inVoiced) { void ChatChannel::RemoveVoice(std::string inVoiced) {
list<string>::iterator Iterator; std::list<std::string>::iterator Iterator;
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); Iterator++) { for(Iterator = Voiced.begin(); Iterator != Voiced.end(); Iterator++) {
@ -675,9 +675,9 @@ void ChatChannel::RemoveVoice(string inVoiced) {
} }
} }
bool ChatChannel::HasVoice(string inVoiced) { bool ChatChannel::HasVoice(std::string inVoiced) {
list<string>::iterator Iterator; std::list<std::string>::iterator Iterator;
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); Iterator++) { for(Iterator = Voiced.begin(); Iterator != Voiced.end(); Iterator++) {
@ -688,9 +688,9 @@ bool ChatChannel::HasVoice(string inVoiced) {
return false; return false;
} }
string CapitaliseName(string inString) { std::string CapitaliseName(std::string inString) {
string NormalisedName = inString; std::string NormalisedName = inString;
for(unsigned int i = 0; i < NormalisedName.length(); i++) { for(unsigned int i = 0; i < NormalisedName.length(); i++) {

View File

@ -7,15 +7,13 @@
#include <string> #include <string>
#include <list> #include <list>
using namespace std;
class Client; class Client;
class ChatChannel { class ChatChannel {
public: public:
ChatChannel(string inName, string inOwner, string inPassword, bool inPermanent, int inMinimumStatus = 0); ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus = 0);
~ChatChannel(); ~ChatChannel();
void AddClient(Client *c); void AddClient(Client *c);
@ -23,25 +21,25 @@ public:
bool IsClientInChannel(Client *c); bool IsClientInChannel(Client *c);
int MemberCount(int Status); int MemberCount(int Status);
string GetName() { return Name; } std::string GetName() { return Name; }
void SendMessageToChannel(string Message, Client* Sender); void SendMessageToChannel(std::string Message, Client* Sender);
bool CheckPassword(string inPassword) { return ((Password.length() == 0) || (Password == inPassword)); } bool CheckPassword(std::string inPassword) { return ((Password.length() == 0) || (Password == inPassword)); }
void SetPassword(string inPassword); void SetPassword(std::string inPassword);
bool IsOwner(string Name) { return (Owner == Name); } bool IsOwner(std::string Name) { return (Owner == Name); }
void SetOwner(string inOwner); void SetOwner(std::string inOwner);
void SendChannelMembers(Client *c); void SendChannelMembers(Client *c);
int GetMinStatus() { return MinimumStatus; } int GetMinStatus() { return MinimumStatus; }
bool ReadyToDelete() { return DeleteTimer.Check(); } bool ReadyToDelete() { return DeleteTimer.Check(); }
void SendOPList(Client *c); void SendOPList(Client *c);
void AddInvitee(string Invitee); void AddInvitee(std::string Invitee);
void RemoveInvitee(string Invitee); void RemoveInvitee(std::string Invitee);
bool IsInvitee(string Invitee); bool IsInvitee(std::string Invitee);
void AddModerator(string Moderator); void AddModerator(std::string Moderator);
void RemoveModerator(string Modeerator); void RemoveModerator(std::string Modeerator);
bool IsModerator(string Moderator); bool IsModerator(std::string Moderator);
void AddVoice(string Voiced); void AddVoice(std::string Voiced);
void RemoveVoice(string Voiced); void RemoveVoice(std::string Voiced);
bool HasVoice(string Voiced); bool HasVoice(std::string Voiced);
inline bool IsModerated() { return Moderated; } inline bool IsModerated() { return Moderated; }
void SetModerated(bool inModerated); void SetModerated(bool inModerated);
@ -49,9 +47,9 @@ public:
private: private:
string Name; std::string Name;
string Owner; std::string Owner;
string Password; std::string Password;
bool Permanent; bool Permanent;
bool Moderated; bool Moderated;
@ -62,19 +60,19 @@ private:
LinkedList<Client*> ClientsInChannel; LinkedList<Client*> ClientsInChannel;
list<string> Moderators; std::list<std::string> Moderators;
list<string> Invitees; std::list<std::string> Invitees;
list<string> Voiced; std::list<std::string> Voiced;
}; };
class ChatChannelList { class ChatChannelList {
public: public:
ChatChannel* CreateChannel(string Name, string Owner, string Passwordi, bool Permanent, int MinimumStatus = 0); ChatChannel* CreateChannel(std::string Name, std::string Owner, std::string Passwordi, bool Permanent, int MinimumStatus = 0);
ChatChannel* FindChannel(string Name); ChatChannel* FindChannel(std::string Name);
ChatChannel* AddClientToChannel(string Channel, Client *c); ChatChannel* AddClientToChannel(std::string Channel, Client *c);
ChatChannel* RemoveClientFromChannel(string Channel, Client *c); ChatChannel* RemoveClientFromChannel(std::string Channel, Client *c);
void RemoveClientFromAllChannels(Client *c); void RemoveClientFromAllChannels(Client *c);
void RemoveChannel(ChatChannel *Channel); void RemoveChannel(ChatChannel *Channel);
void RemoveAllChannels(); void RemoveAllChannels();
@ -87,6 +85,6 @@ private:
}; };
string CapitaliseName(string inString); std::string CapitaliseName(std::string inString);
#endif #endif

View File

@ -33,11 +33,9 @@
#include <cstdlib> #include <cstdlib>
#include <algorithm> #include <algorithm>
using namespace std;
extern Database database; extern Database database;
extern string WorldShortName; extern std::string WorldShortName;
extern string GetMailPrefix(); extern std::string GetMailPrefix();
extern ChatChannelList *ChannelList; extern ChatChannelList *ChannelList;
extern Clientlist *CL; extern Clientlist *CL;
extern uint32 ChatMessagesSent; extern uint32 ChatMessagesSent;
@ -77,7 +75,7 @@ void Client::SendUptime() {
safe_delete_array(Buffer); safe_delete_array(Buffer);
} }
vector<string> ParseRecipients(string RecipientString) { std::vector<std::string> ParseRecipients(std::string RecipientString) {
// This method parses the Recipient List in the mailto command, which can look like this example: // This method parses the Recipient List in the mailto command, which can look like this example:
// //
@ -111,19 +109,19 @@ vector<string> ParseRecipients(string RecipientString) {
// //
// The '-' prefix indicates 'Secret To' (like BCC:) // The '-' prefix indicates 'Secret To' (like BCC:)
// //
vector<string> RecipientList; std::vector<std::string> RecipientList;
string Secret; std::string Secret;
string::size_type CurrentPos, Comma, FirstLT, LastGT, Space, LastPeriod; std::string::size_type CurrentPos, Comma, FirstLT, LastGT, Space, LastPeriod;
CurrentPos = 0; CurrentPos = 0;
while(CurrentPos != string::npos) { while(CurrentPos != std::string::npos) {
Comma = RecipientString.find_first_of(",", CurrentPos); Comma = RecipientString.find_first_of(",", CurrentPos);
if(Comma == string::npos) { if(Comma == std::string::npos) {
RecipientList.push_back(RecipientString.substr(CurrentPos)); RecipientList.push_back(RecipientString.substr(CurrentPos));
@ -134,7 +132,7 @@ vector<string> ParseRecipients(string RecipientString) {
CurrentPos = Comma + 2; CurrentPos = Comma + 2;
} }
vector<string>::iterator Iterator; std::vector<std::string>::iterator Iterator;
Iterator = RecipientList.begin(); Iterator = RecipientList.begin();
@ -152,27 +150,27 @@ vector<string> ParseRecipients(string RecipientString) {
FirstLT = (*Iterator).find_first_of("<"); FirstLT = (*Iterator).find_first_of("<");
if(FirstLT != string::npos) { if(FirstLT != std::string::npos) {
LastGT = (*Iterator).find_last_of(">"); LastGT = (*Iterator).find_last_of(">");
if(LastGT != string::npos) { if(LastGT != std::string::npos) {
(*Iterator) = (*Iterator).substr(FirstLT + 1, LastGT - FirstLT - 1); (*Iterator) = (*Iterator).substr(FirstLT + 1, LastGT - FirstLT - 1);
if((*Iterator).find_first_of(" ") != string::npos) { if((*Iterator).find_first_of(" ") != std::string::npos) {
string Recips = (*Iterator); std::string Recips = (*Iterator);
RecipientList.erase(Iterator); RecipientList.erase(Iterator);
CurrentPos = 0; CurrentPos = 0;
while(CurrentPos != string::npos) { while(CurrentPos != std::string::npos) {
Space = Recips.find_first_of(" ", CurrentPos); Space = Recips.find_first_of(" ", CurrentPos);
if(Space == string::npos) { if(Space == std::string::npos) {
RecipientList.push_back(Secret + Recips.substr(CurrentPos)); RecipientList.push_back(Secret + Recips.substr(CurrentPos));
@ -207,7 +205,7 @@ vector<string> ParseRecipients(string RecipientString) {
LastPeriod = (*Iterator).find_last_of("."); LastPeriod = (*Iterator).find_last_of(".");
if(LastPeriod != string::npos) { if(LastPeriod != std::string::npos) {
(*Iterator) = (*Iterator).substr(LastPeriod + 1); (*Iterator) = (*Iterator).substr(LastPeriod + 1);
@ -227,7 +225,7 @@ vector<string> ParseRecipients(string RecipientString) {
sort(RecipientList.begin(), RecipientList.end()); sort(RecipientList.begin(), RecipientList.end());
vector<string>::iterator new_end_pos = unique(RecipientList.begin(), RecipientList.end()); std::vector<std::string>::iterator new_end_pos = unique(RecipientList.begin(), RecipientList.end());
RecipientList.erase(new_end_pos, RecipientList.end()); RecipientList.erase(new_end_pos, RecipientList.end());
@ -235,27 +233,27 @@ vector<string> ParseRecipients(string RecipientString) {
} }
static void ProcessMailTo(Client *c, string MailMessage) { static void ProcessMailTo(Client *c, std::string MailMessage) {
_log(UCS__TRACE, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str()); _log(UCS__TRACE, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str());
vector<string> Recipients; std::vector<std::string> Recipients;
string::size_type FirstQuote = MailMessage.find_first_of("\"", 0); std::string::size_type FirstQuote = MailMessage.find_first_of("\"", 0);
string::size_type NextQuote = MailMessage.find_first_of("\"", FirstQuote + 1); std::string::size_type NextQuote = MailMessage.find_first_of("\"", FirstQuote + 1);
string RecipientsString = MailMessage.substr(FirstQuote+1, NextQuote-FirstQuote - 1); std::string RecipientsString = MailMessage.substr(FirstQuote+1, NextQuote-FirstQuote - 1);
Recipients = ParseRecipients(RecipientsString); Recipients = ParseRecipients(RecipientsString);
// Now extract the subject field. This is in quotes if it is more than one word // Now extract the subject field. This is in quotes if it is more than one word
// //
string Subject; std::string Subject;
string::size_type SubjectStart = NextQuote + 2; std::string::size_type SubjectStart = NextQuote + 2;
string::size_type SubjectEnd; std::string::size_type SubjectEnd;
if(MailMessage.substr(SubjectStart, 1) == "\"") { if(MailMessage.substr(SubjectStart, 1) == "\"") {
@ -274,7 +272,7 @@ static void ProcessMailTo(Client *c, string MailMessage) {
SubjectEnd++; SubjectEnd++;
} }
string Body = MailMessage.substr(SubjectEnd); std::string Body = MailMessage.substr(SubjectEnd);
bool Success = true; bool Success = true;
@ -353,10 +351,10 @@ static void ProcessMailTo(Client *c, string MailMessage) {
} }
} }
static void ProcessMailTo(Client *c, string from, string subject, string message) { static void ProcessMailTo(Client *c, std::string from, std::string subject, std::string message) {
} }
static void ProcessSetMessageStatus(string SetMessageCommand) { static void ProcessSetMessageStatus(std::string SetMessageCommand) {
int MessageNumber; int MessageNumber;
@ -376,13 +374,13 @@ static void ProcessSetMessageStatus(string SetMessageCommand) {
Status = 0; Status = 0;
} }
string::size_type NumStart = SetMessageCommand.find_first_of("123456789"); std::string::size_type NumStart = SetMessageCommand.find_first_of("123456789");
while(NumStart != string::npos) { while(NumStart != std::string::npos) {
string::size_type NumEnd = SetMessageCommand.find_first_of(" ", NumStart); std::string::size_type NumEnd = SetMessageCommand.find_first_of(" ", NumStart);
if(NumEnd == string::npos) { if(NumEnd == std::string::npos) {
MessageNumber = atoi(SetMessageCommand.substr(NumStart).c_str()); MessageNumber = atoi(SetMessageCommand.substr(NumStart).c_str());
@ -399,7 +397,7 @@ static void ProcessSetMessageStatus(string SetMessageCommand) {
} }
} }
static void ProcessCommandBuddy(Client *c, string Buddy) { static void ProcessCommandBuddy(Client *c, std::string Buddy) {
_log(UCS__TRACE, "Received buddy command with parameters %s", Buddy.c_str()); _log(UCS__TRACE, "Received buddy command with parameters %s", Buddy.c_str());
c->GeneralChannelMessage("Buddy list modified"); c->GeneralChannelMessage("Buddy list modified");
@ -429,7 +427,7 @@ static void ProcessCommandBuddy(Client *c, string Buddy) {
} }
static void ProcessCommandIgnore(Client *c, string Ignoree) { static void ProcessCommandIgnore(Client *c, std::string Ignoree) {
_log(UCS__TRACE, "Received ignore command with parameters %s", Ignoree.c_str()); _log(UCS__TRACE, "Received ignore command with parameters %s", Ignoree.c_str());
c->GeneralChannelMessage("Ignore list modified"); c->GeneralChannelMessage("Ignore list modified");
@ -442,11 +440,11 @@ static void ProcessCommandIgnore(Client *c, string Ignoree) {
// Strip off the SOE.EQ.<shortname>. // Strip off the SOE.EQ.<shortname>.
// //
string CharacterName; std::string CharacterName;
string::size_type LastPeriod = Ignoree.find_last_of("."); std::string::size_type LastPeriod = Ignoree.find_last_of(".");
if(LastPeriod == string::npos) if(LastPeriod == std::string::npos)
CharacterName = Ignoree; CharacterName = Ignoree;
else else
CharacterName = Ignoree.substr(LastPeriod + 1); CharacterName = Ignoree.substr(LastPeriod + 1);
@ -554,7 +552,7 @@ void Clientlist::CheckForStaleConnections(Client *c) {
if(!c) return; if(!c) return;
list<Client*>::iterator Iterator; std::list<Client*>::iterator Iterator;
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) { for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
@ -596,7 +594,7 @@ void Clientlist::Process() {
ClientChatConnections.push_back(c); ClientChatConnections.push_back(c);
} }
list<Client*>::iterator Iterator; std::list<Client*>::iterator Iterator;
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) { for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
@ -657,13 +655,13 @@ void Clientlist::Process() {
VARSTRUCT_DECODE_STRING(Key, PacketBuffer); VARSTRUCT_DECODE_STRING(Key, PacketBuffer);
string MailBoxString = MailBox, CharacterName; std::string MailBoxString = MailBox, CharacterName;
// Strip off the SOE.EQ.<shortname>. // Strip off the SOE.EQ.<shortname>.
// //
string::size_type LastPeriod = MailBoxString.find_last_of("."); std::string::size_type LastPeriod = MailBoxString.find_last_of(".");
if(LastPeriod == string::npos) if(LastPeriod == std::string::npos)
CharacterName = MailBoxString; CharacterName = MailBoxString;
else else
CharacterName = MailBoxString.substr(LastPeriod + 1); CharacterName = MailBoxString.substr(LastPeriod + 1);
@ -695,7 +693,7 @@ void Clientlist::Process() {
case OP_Mail: { case OP_Mail: {
string CommandString = (const char*)app->pBuffer; std::string CommandString = (const char*)app->pBuffer;
ProcessOPMailCommand((*Iterator), CommandString); ProcessOPMailCommand((*Iterator), CommandString);
@ -735,7 +733,7 @@ void Clientlist::Process() {
} }
void Clientlist::ProcessOPMailCommand(Client *c, string CommandString) void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
{ {
if(CommandString.length() == 0) if(CommandString.length() == 0)
@ -756,17 +754,17 @@ void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
return; return;
} }
string Command, Parameters; std::string Command, Parameters;
string::size_type Space = CommandString.find_first_of(" "); std::string::size_type Space = CommandString.find_first_of(" ");
if(Space != string::npos) { if(Space != std::string::npos) {
Command = CommandString.substr(0, Space); Command = CommandString.substr(0, Space);
string::size_type ParametersStart = CommandString.find_first_not_of(" ", Space); std::string::size_type ParametersStart = CommandString.find_first_not_of(" ", Space);
if(ParametersStart != string::npos) if(ParametersStart != std::string::npos)
Parameters = CommandString.substr(ParametersStart); Parameters = CommandString.substr(ParametersStart);
} }
else else
@ -867,7 +865,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
case CommandSelectMailBox: case CommandSelectMailBox:
{ {
string::size_type NumStart = Parameters.find_first_of("0123456789"); std::string::size_type NumStart = Parameters.find_first_of("0123456789");
c->ChangeMailBox(atoi(Parameters.substr(NumStart).c_str())); c->ChangeMailBox(atoi(Parameters.substr(NumStart).c_str()));
break; break;
} }
@ -893,7 +891,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
void Clientlist::CloseAllConnections() { void Clientlist::CloseAllConnections() {
list<Client*>::iterator Iterator; std::list<Client*>::iterator Iterator;
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) { for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
@ -921,7 +919,7 @@ void Client::SendMailBoxes() {
int PacketLength = 10; int PacketLength = 10;
string s; std::string s;
for(int i = 0; i < Count; i++) { for(int i = 0; i < Count; i++) {
@ -951,9 +949,9 @@ void Client::SendMailBoxes() {
safe_delete(outapp); safe_delete(outapp);
} }
Client *Clientlist::FindCharacter(string CharacterName) { Client *Clientlist::FindCharacter(std::string CharacterName) {
list<Client*>::iterator Iterator; std::list<Client*>::iterator Iterator;
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) { for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
@ -1005,7 +1003,7 @@ int Client::ChannelCount() {
} }
void Client::JoinChannels(string ChannelNameList) { void Client::JoinChannels(std::string ChannelNameList) {
for(int x = 0; x < ChannelNameList.size(); ++x) for(int x = 0; x < ChannelNameList.size(); ++x)
{ {
@ -1019,9 +1017,9 @@ void Client::JoinChannels(string ChannelNameList) {
int NumberOfChannels = ChannelCount(); int NumberOfChannels = ChannelCount();
string::size_type CurrentPos = ChannelNameList.find_first_not_of(" "); std::string::size_type CurrentPos = ChannelNameList.find_first_not_of(" ");
while(CurrentPos != string::npos) { while(CurrentPos != std::string::npos) {
if(NumberOfChannels == MAX_JOINED_CHANNELS) { if(NumberOfChannels == MAX_JOINED_CHANNELS) {
@ -1030,9 +1028,9 @@ void Client::JoinChannels(string ChannelNameList) {
break; break;
} }
string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos); std::string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos);
if(Comma == string::npos) { if(Comma == std::string::npos) {
ChatChannel* JoinedChannel = ChannelList->AddClientToChannel(ChannelNameList.substr(CurrentPos), this); ChatChannel* JoinedChannel = ChannelList->AddClientToChannel(ChannelNameList.substr(CurrentPos), this);
@ -1054,7 +1052,7 @@ void Client::JoinChannels(string ChannelNameList) {
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma); CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
} }
string JoinedChannelsList, ChannelMessage; std::string JoinedChannelsList, ChannelMessage;
ChannelMessage = "Channels: "; ChannelMessage = "Channels: ";
@ -1115,17 +1113,17 @@ void Client::JoinChannels(string ChannelNameList) {
safe_delete(outapp); safe_delete(outapp);
} }
void Client::LeaveChannels(string ChannelNameList) { void Client::LeaveChannels(std::string ChannelNameList) {
_log(UCS__TRACE, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str()); _log(UCS__TRACE, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str());
string::size_type CurrentPos = 0; std::string::size_type CurrentPos = 0;
while(CurrentPos != string::npos) { while(CurrentPos != std::string::npos) {
string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos); std::string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos);
if(Comma == string::npos) { if(Comma == std::string::npos) {
ChatChannel* JoinedChannel = ChannelList->RemoveClientFromChannel(ChannelNameList.substr(CurrentPos), this); ChatChannel* JoinedChannel = ChannelList->RemoveClientFromChannel(ChannelNameList.substr(CurrentPos), this);
@ -1143,7 +1141,7 @@ void Client::LeaveChannels(string ChannelNameList) {
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma); CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
} }
string JoinedChannelsList, ChannelMessage; std::string JoinedChannelsList, ChannelMessage;
ChannelMessage = "Channels: "; ChannelMessage = "Channels: ";
@ -1220,7 +1218,7 @@ void Client::LeaveAllChannels(bool SendUpdatedChannelList) {
} }
void Client::ProcessChannelList(string Input) { void Client::ProcessChannelList(std::string Input) {
if(Input.length() == 0) { if(Input.length() == 0) {
@ -1229,7 +1227,7 @@ void Client::ProcessChannelList(string Input) {
return; return;
} }
string ChannelName = Input; std::string ChannelName = Input;
if(isdigit(ChannelName[0])) if(isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1246,7 +1244,7 @@ void Client::ProcessChannelList(string Input) {
void Client::SendChannelList() { void Client::SendChannelList() {
string ChannelMessage; std::string ChannelMessage;
ChannelMessage = "Channels: "; ChannelMessage = "Channels: ";
@ -1287,15 +1285,15 @@ void Client::SendChannelList() {
safe_delete(outapp); safe_delete(outapp);
} }
void Client::SendChannelMessage(string Message) void Client::SendChannelMessage(std::string Message)
{ {
string::size_type MessageStart = Message.find_first_of(" "); std::string::size_type MessageStart = Message.find_first_of(" ");
if(MessageStart == string::npos) if(MessageStart == std::string::npos)
return; return;
string ChannelName = Message.substr(1, MessageStart-1); std::string ChannelName = Message.substr(1, MessageStart-1);
_log(UCS__TRACE, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str()); _log(UCS__TRACE, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str());
@ -1389,11 +1387,11 @@ void Client::SendChannelMessage(string Message)
} }
void Client::SendChannelMessageByNumber(string Message) { void Client::SendChannelMessageByNumber(std::string Message) {
string::size_type MessageStart = Message.find_first_of(" "); std::string::size_type MessageStart = Message.find_first_of(" ");
if(MessageStart == string::npos) if(MessageStart == std::string::npos)
return; return;
int ChannelNumber = atoi(Message.substr(0, MessageStart).c_str()); int ChannelNumber = atoi(Message.substr(0, MessageStart).c_str());
@ -1503,11 +1501,11 @@ void Client::SendChannelMessageByNumber(string Message) {
} }
void Client::SendChannelMessage(string ChannelName, string Message, Client *Sender) { void Client::SendChannelMessage(std::string ChannelName, std::string Message, Client *Sender) {
if(!Sender) return; if(!Sender) return;
string FQSenderName = WorldShortName + "." + Sender->GetName(); std::string FQSenderName = WorldShortName + "." + Sender->GetName();
int PacketLength = ChannelName.length() + Message.length() + FQSenderName.length() + 3; int PacketLength = ChannelName.length() + Message.length() + FQSenderName.length() + 3;
@ -1531,7 +1529,7 @@ void Client::SendChannelMessage(string ChannelName, string Message, Client *Send
safe_delete(outapp); safe_delete(outapp);
} }
void Client::ToggleAnnounce(string State) void Client::ToggleAnnounce(std::string State)
{ {
if(State == "") if(State == "")
Announce = !Announce; Announce = !Announce;
@ -1540,7 +1538,7 @@ void Client::ToggleAnnounce(string State)
else else
Announce = false; Announce = false;
string Message = "Announcing now "; std::string Message = "Announcing now ";
if(Announce) if(Announce)
Message += "on"; Message += "on";
@ -1594,13 +1592,13 @@ void Client::GeneralChannelMessage(const char *Characters) {
if(!Characters) return; if(!Characters) return;
string Message = Characters; std::string Message = Characters;
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
} }
void Client::GeneralChannelMessage(string Message) { void Client::GeneralChannelMessage(std::string Message) {
EQApplicationPacket *outapp = new EQApplicationPacket(OP_ChannelMessage, Message.length() + 3); EQApplicationPacket *outapp = new EQApplicationPacket(OP_ChannelMessage, Message.length() + 3);
char *PacketBuffer = (char *)outapp->pBuffer; char *PacketBuffer = (char *)outapp->pBuffer;
@ -1614,40 +1612,40 @@ void Client::GeneralChannelMessage(string Message) {
safe_delete(outapp); safe_delete(outapp);
} }
void Client::SetChannelPassword(string ChannelPassword) { void Client::SetChannelPassword(std::string ChannelPassword) {
string::size_type PasswordStart = ChannelPassword.find_first_not_of(" "); std::string::size_type PasswordStart = ChannelPassword.find_first_not_of(" ");
if(PasswordStart == string::npos) { if(PasswordStart == std::string::npos) {
string Message = "Incorrect syntax: /chat password <new password> <channel name>"; std::string Message = "Incorrect syntax: /chat password <new password> <channel name>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string::size_type Space = ChannelPassword.find_first_of(" ", PasswordStart); std::string::size_type Space = ChannelPassword.find_first_of(" ", PasswordStart);
if(Space == string::npos) { if(Space == std::string::npos) {
string Message = "Incorrect syntax: /chat password <new password> <channel name>"; std::string Message = "Incorrect syntax: /chat password <new password> <channel name>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string Password = ChannelPassword.substr(PasswordStart, Space - PasswordStart); std::string Password = ChannelPassword.substr(PasswordStart, Space - PasswordStart);
string::size_type ChannelStart = ChannelPassword.find_first_not_of(" ", Space); std::string::size_type ChannelStart = ChannelPassword.find_first_not_of(" ", Space);
if(ChannelStart == string::npos) { if(ChannelStart == std::string::npos) {
string Message = "Incorrect syntax: /chat password <new password> <channel name>"; std::string Message = "Incorrect syntax: /chat password <new password> <channel name>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string ChannelName = ChannelPassword.substr(ChannelStart); std::string ChannelName = ChannelPassword.substr(ChannelStart);
if((ChannelName.length() > 0) && isdigit(ChannelName[0])) if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
string Message; std::string Message;
if(!strcasecmp(Password.c_str(), "remove")) { if(!strcasecmp(Password.c_str(), "remove")) {
Password.clear(); Password.clear();
@ -1661,13 +1659,13 @@ void Client::SetChannelPassword(string ChannelPassword) {
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
if(!RequiredChannel) { if(!RequiredChannel) {
string Message = "Channel not found."; std::string Message = "Channel not found.";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) { if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) {
string Message = "You do not own or have moderator rights on channel " + ChannelName; std::string Message = "You do not own or have moderator rights on channel " + ChannelName;
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
@ -1678,35 +1676,35 @@ void Client::SetChannelPassword(string ChannelPassword) {
} }
void Client::SetChannelOwner(string CommandString) { void Client::SetChannelOwner(std::string CommandString) {
string::size_type PlayerStart = CommandString.find_first_not_of(" "); std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
if(PlayerStart == string::npos) { if(PlayerStart == std::string::npos) {
string Message = "Incorrect syntax: /chat setowner <player> <channel>"; std::string Message = "Incorrect syntax: /chat setowner <player> <channel>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string::size_type Space = CommandString.find_first_of(" ", PlayerStart); std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
if(Space == string::npos) { if(Space == std::string::npos) {
string Message = "Incorrect syntax: /chat setowner <player> <channel>"; std::string Message = "Incorrect syntax: /chat setowner <player> <channel>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string NewOwner = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart)); std::string NewOwner = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
if(ChannelStart == string::npos) { if(ChannelStart == std::string::npos) {
string Message = "Incorrect syntax: /chat setowner <player> <channel>"; std::string Message = "Incorrect syntax: /chat setowner <player> <channel>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0])) if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1721,7 +1719,7 @@ void Client::SetChannelOwner(string CommandString) {
} }
if(!RequiredChannel->IsOwner(GetName()) && !IsChannelAdmin()) { if(!RequiredChannel->IsOwner(GetName()) && !IsChannelAdmin()) {
string Message = "You do not own channel " + ChannelName; std::string Message = "You do not own channel " + ChannelName;
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
@ -1741,17 +1739,17 @@ void Client::SetChannelOwner(string CommandString) {
} }
void Client::OPList(string CommandString) { void Client::OPList(std::string CommandString) {
string::size_type ChannelStart = CommandString.find_first_not_of(" "); std::string::size_type ChannelStart = CommandString.find_first_not_of(" ");
if(ChannelStart == string::npos) { if(ChannelStart == std::string::npos) {
string Message = "Incorrect syntax: /chat oplist <channel>"; std::string Message = "Incorrect syntax: /chat oplist <channel>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0])) if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1766,35 +1764,35 @@ void Client::OPList(string CommandString) {
RequiredChannel->SendOPList(this); RequiredChannel->SendOPList(this);
} }
void Client::ChannelInvite(string CommandString) { void Client::ChannelInvite(std::string CommandString) {
string::size_type PlayerStart = CommandString.find_first_not_of(" "); std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
if(PlayerStart == string::npos) { if(PlayerStart == std::string::npos) {
string Message = "Incorrect syntax: /chat invite <player> <channel>"; std::string Message = "Incorrect syntax: /chat invite <player> <channel>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string::size_type Space = CommandString.find_first_of(" ", PlayerStart); std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
if(Space == string::npos) { if(Space == std::string::npos) {
string Message = "Incorrect syntax: /chat invite <player> <channel>"; std::string Message = "Incorrect syntax: /chat invite <player> <channel>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string Invitee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart)); std::string Invitee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
if(ChannelStart == string::npos) { if(ChannelStart == std::string::npos) {
string Message = "Incorrect syntax: /chat invite <player> <channel>"; std::string Message = "Incorrect syntax: /chat invite <player> <channel>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0])) if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1831,7 +1829,7 @@ void Client::ChannelInvite(string CommandString) {
if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName())) { if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName())) {
string Message = "You do not own or have moderator rights to channel " + ChannelName; std::string Message = "You do not own or have moderator rights to channel " + ChannelName;
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
@ -1852,19 +1850,19 @@ void Client::ChannelInvite(string CommandString) {
} }
void Client::ChannelModerate(string CommandString) { void Client::ChannelModerate(std::string CommandString) {
string::size_type ChannelStart = CommandString.find_first_not_of(" "); std::string::size_type ChannelStart = CommandString.find_first_not_of(" ");
if(ChannelStart == string::npos) { if(ChannelStart == std::string::npos) {
string Message = "Incorrect syntax: /chat moderate <channel>"; std::string Message = "Incorrect syntax: /chat moderate <channel>";
GeneralChannelMessage(Message); GeneralChannelMessage(Message);
return; return;
} }
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0])) if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1893,35 +1891,35 @@ void Client::ChannelModerate(string CommandString) {
} }
void Client::ChannelGrantModerator(string CommandString) { void Client::ChannelGrantModerator(std::string CommandString) {
string::size_type PlayerStart = CommandString.find_first_not_of(" "); std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
if(PlayerStart == string::npos) { if(PlayerStart == std::string::npos) {
GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>"); GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>");
return; return;
} }
string::size_type Space = CommandString.find_first_of(" ", PlayerStart); std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
if(Space == string::npos) { if(Space == std::string::npos) {
GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>"); GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>");
return; return;
} }
string Moderator = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart)); std::string Moderator = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
if(ChannelStart == string::npos) { if(ChannelStart == std::string::npos) {
GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>"); GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>");
return; return;
} }
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0])) if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1976,33 +1974,33 @@ void Client::ChannelGrantModerator(string CommandString) {
} }
void Client::ChannelGrantVoice(string CommandString) { void Client::ChannelGrantVoice(std::string CommandString) {
string::size_type PlayerStart = CommandString.find_first_not_of(" "); std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
if(PlayerStart == string::npos) { if(PlayerStart == std::string::npos) {
GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>"); GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>");
return; return;
} }
string::size_type Space = CommandString.find_first_of(" ", PlayerStart); std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
if(Space == string::npos) { if(Space == std::string::npos) {
GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>"); GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>");
return; return;
} }
string Voicee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart)); std::string Voicee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
if(ChannelStart == string::npos) { if(ChannelStart == std::string::npos) {
GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>"); GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>");
return; return;
} }
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0])) if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -2063,34 +2061,34 @@ void Client::ChannelGrantVoice(string CommandString) {
} }
void Client::ChannelKick(string CommandString) { void Client::ChannelKick(std::string CommandString) {
string::size_type PlayerStart = CommandString.find_first_not_of(" "); std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
if(PlayerStart == string::npos) { if(PlayerStart == std::string::npos) {
GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>"); GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>");
return; return;
} }
string::size_type Space = CommandString.find_first_of(" ", PlayerStart); std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
if(Space == string::npos) { if(Space == std::string::npos) {
GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>"); GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>");
return; return;
} }
string Kickee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart)); std::string Kickee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
if(ChannelStart == string::npos) { if(ChannelStart == std::string::npos) {
GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>"); GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>");
return; return;
} }
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0])) if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -2164,7 +2162,7 @@ void Client::ToggleInvites() {
} }
string Client::ChannelSlotName(int SlotNumber) { std::string Client::ChannelSlotName(int SlotNumber) {
if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS)) if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS))
return ""; return "";
@ -2234,7 +2232,7 @@ void Client::SetConnectionType(char c) {
} }
} }
Client *Clientlist::IsCharacterOnline(string CharacterName) { Client *Clientlist::IsCharacterOnline(std::string CharacterName) {
// This method is used to determine if the character we are a sending an email to is connected to the mailserver, // This method is used to determine if the character we are a sending an email to is connected to the mailserver,
// so we can send them a new email notification. // so we can send them a new email notification.
@ -2243,7 +2241,7 @@ Client *Clientlist::IsCharacterOnline(string CharacterName) {
// i.e. for the character they are logged in as, or for the character whose mailbox they have selected in the // i.e. for the character they are logged in as, or for the character whose mailbox they have selected in the
// mail window. // mail window.
// //
list<Client*>::iterator Iterator; std::list<Client*>::iterator Iterator;
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) { for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
@ -2262,7 +2260,7 @@ Client *Clientlist::IsCharacterOnline(string CharacterName) {
return nullptr; return nullptr;
} }
int Client::GetMailBoxNumber(string CharacterName) { int Client::GetMailBoxNumber(std::string CharacterName) {
for(unsigned int i = 0; i < Characters.size(); i++) for(unsigned int i = 0; i < Characters.size(); i++)
if(Characters[i].Name == CharacterName) if(Characters[i].Name == CharacterName)
@ -2271,7 +2269,7 @@ int Client::GetMailBoxNumber(string CharacterName) {
return -1; return -1;
} }
void Client::SendNotification(int MailBoxNumber, string Subject, string From, int MessageID) { void Client::SendNotification(int MailBoxNumber, std::string Subject, std::string From, int MessageID) {
char TimeStamp[100]; char TimeStamp[100];
@ -2328,13 +2326,13 @@ void Client::ChangeMailBox(int NewMailBox) {
void Client::SendFriends() { void Client::SendFriends() {
vector<string> Friends, Ignorees; std::vector<std::string> Friends, Ignorees;
database.GetFriendsAndIgnore(GetCharID(), Friends, Ignorees); database.GetFriendsAndIgnore(GetCharID(), Friends, Ignorees);
EQApplicationPacket *outapp; EQApplicationPacket *outapp;
vector<string>::iterator Iterator; std::vector<std::string>::iterator Iterator;
Iterator = Friends.begin(); Iterator = Friends.begin();
@ -2361,7 +2359,7 @@ void Client::SendFriends() {
while(Iterator != Ignorees.end()) { while(Iterator != Ignorees.end()) {
string Ignoree = "SOE.EQ." + WorldShortName + "." + (*Iterator); std::string Ignoree = "SOE.EQ." + WorldShortName + "." + (*Iterator);
outapp = new EQApplicationPacket(OP_Ignore, Ignoree.length() + 2); outapp = new EQApplicationPacket(OP_Ignore, Ignoree.length() + 2);
@ -2381,7 +2379,7 @@ void Client::SendFriends() {
} }
} }
string Client::MailBoxName() { std::string Client::MailBoxName() {
if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1))) if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1)))
{ {

View File

@ -78,7 +78,7 @@ static const CommandEntry Commands[] = {
struct CharacterEntry { struct CharacterEntry {
int CharID; int CharID;
int Level; int Level;
string Name; std::string Name;
}; };
class Client { class Client {
@ -92,25 +92,25 @@ public:
void ClearCharacters() { Characters.clear(); } void ClearCharacters() { Characters.clear(); }
void SendMailBoxes(); void SendMailBoxes();
inline void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) { ClientStream->QueuePacket(p, ack_req); } inline void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) { ClientStream->QueuePacket(p, ack_req); }
string GetName() { if(Characters.size()) return Characters[0].Name; else return ""; } std::string GetName() { if(Characters.size()) return Characters[0].Name; else return ""; }
void JoinChannels(string ChannelList); void JoinChannels(std::string ChannelList);
void LeaveChannels(string ChannelList); void LeaveChannels(std::string ChannelList);
void LeaveAllChannels(bool SendUpdatedChannelList = true); void LeaveAllChannels(bool SendUpdatedChannelList = true);
void AddToChannelList(ChatChannel *JoinedChannel); void AddToChannelList(ChatChannel *JoinedChannel);
void RemoveFromChannelList(ChatChannel *JoinedChannel); void RemoveFromChannelList(ChatChannel *JoinedChannel);
void SendChannelMessage(string Message); void SendChannelMessage(std::string Message);
void SendChannelMessage(string ChannelName, string Message, Client *Sender); void SendChannelMessage(std::string ChannelName, std::string Message, Client *Sender);
void SendChannelMessageByNumber(string Message); void SendChannelMessageByNumber(std::string Message);
void SendChannelList(); void SendChannelList();
void CloseConnection(); void CloseConnection();
void ToggleAnnounce(string State); void ToggleAnnounce(std::string State);
bool IsAnnounceOn() { return (Announce == true); } bool IsAnnounceOn() { return (Announce == true); }
void AnnounceJoin(ChatChannel *Channel, Client *c); void AnnounceJoin(ChatChannel *Channel, Client *c);
void AnnounceLeave(ChatChannel *Channel, Client *c); void AnnounceLeave(ChatChannel *Channel, Client *c);
void GeneralChannelMessage(string Message); void GeneralChannelMessage(std::string Message);
void GeneralChannelMessage(const char *Characters); void GeneralChannelMessage(const char *Characters);
void SetChannelPassword(string ChannelPassword); void SetChannelPassword(std::string ChannelPassword);
void ProcessChannelList(string CommandString); void ProcessChannelList(std::string CommandString);
void AccountUpdate(); void AccountUpdate();
int ChannelCount(); int ChannelCount();
inline void SetAccountID(int inAccountID) { AccountID = inAccountID; } inline void SetAccountID(int inAccountID) { AccountID = inAccountID; }
@ -121,14 +121,14 @@ public:
inline int GetAccountStatus() { return Status; } inline int GetAccountStatus() { return Status; }
inline bool GetHideMe() { return HideMe; } inline bool GetHideMe() { return HideMe; }
inline uint32 GetKarma() { return TotalKarma; } inline uint32 GetKarma() { return TotalKarma; }
void SetChannelOwner(string CommandString); void SetChannelOwner(std::string CommandString);
void OPList(string CommandString); void OPList(std::string CommandString);
void ChannelInvite(string CommandString); void ChannelInvite(std::string CommandString);
void ChannelGrantModerator(string CommandString); void ChannelGrantModerator(std::string CommandString);
void ChannelGrantVoice(string CommandString); void ChannelGrantVoice(std::string CommandString);
void ChannelKick(string CommandString); void ChannelKick(std::string CommandString);
void ChannelModerate(string CommandString); void ChannelModerate(std::string CommandString);
string ChannelSlotName(int ChannelNumber); std::string ChannelSlotName(int ChannelNumber);
void ToggleInvites(); void ToggleInvites();
bool InvitesAllowed() { return AllowInvites; } bool InvitesAllowed() { return AllowInvites; }
bool IsRevoked() { return Revoked; } bool IsRevoked() { return Revoked; }
@ -137,13 +137,13 @@ public:
inline bool CanListAllChannels() { return (Status >= RuleI(Channels, RequiredStatusListAll)); } inline bool CanListAllChannels() { return (Status >= RuleI(Channels, RequiredStatusListAll)); }
void SendHelp(); void SendHelp();
inline bool GetForceDisconnect() { return ForceDisconnect; } inline bool GetForceDisconnect() { return ForceDisconnect; }
string MailBoxName(); std::string MailBoxName();
int GetMailBoxNumber() { return CurrentMailBox; } int GetMailBoxNumber() { return CurrentMailBox; }
int GetMailBoxNumber(string CharacterName); int GetMailBoxNumber(std::string CharacterName);
void SetConnectionType(char c); void SetConnectionType(char c);
ConnectionType GetConnectionType() { return TypeOfConnection; } ConnectionType GetConnectionType() { return TypeOfConnection; }
inline bool IsMailConnection() { return (TypeOfConnection == ConnectionTypeMail) || (TypeOfConnection == ConnectionTypeCombined); } inline bool IsMailConnection() { return (TypeOfConnection == ConnectionTypeMail) || (TypeOfConnection == ConnectionTypeCombined); }
void SendNotification(int MailBoxNumber, string From, string Subject, int MessageID); void SendNotification(int MailBoxNumber, std::string From, std::string Subject, int MessageID);
void ChangeMailBox(int NewMailBox); void ChangeMailBox(int NewMailBox);
inline void SetMailBox(int NewMailBox) { CurrentMailBox = NewMailBox; } inline void SetMailBox(int NewMailBox) { CurrentMailBox = NewMailBox; }
void SendFriends(); void SendFriends();
@ -152,7 +152,7 @@ public:
private: private:
unsigned int CurrentMailBox; unsigned int CurrentMailBox;
vector<CharacterEntry> Characters; std::vector<CharacterEntry> Characters;
ChatChannel *JoinedChannels[MAX_JOINED_CHANNELS]; ChatChannel *JoinedChannels[MAX_JOINED_CHANNELS];
bool Announce; bool Announce;
int AccountID; int AccountID;
@ -178,16 +178,16 @@ public:
Clientlist(int MailPort); Clientlist(int MailPort);
void Process(); void Process();
void CloseAllConnections(); void CloseAllConnections();
Client *FindCharacter(string CharacterName); Client *FindCharacter(std::string CharacterName);
void CheckForStaleConnections(Client *c); void CheckForStaleConnections(Client *c);
Client *IsCharacterOnline(string CharacterName); Client *IsCharacterOnline(std::string CharacterName);
void ProcessOPMailCommand(Client *c, string CommandString); void ProcessOPMailCommand(Client *c, std::string CommandString);
private: private:
EQStreamFactory *chatsf; EQStreamFactory *chatsf;
list<Client*> ClientChatConnections; std::list<Client*> ClientChatConnections;
OpcodeManager *ChatOpMgr; OpcodeManager *ChatOpMgr;
}; };

View File

@ -20,7 +20,6 @@
#include "../common/debug.h" #include "../common/debug.h"
#include <iostream> #include <iostream>
using namespace std;
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -49,7 +48,7 @@ using namespace std;
#include "chatchannel.h" #include "chatchannel.h"
extern Clientlist *CL; extern Clientlist *CL;
extern string GetMailPrefix(); extern std::string GetMailPrefix();
extern ChatChannelList *ChannelList; extern ChatChannelList *ChannelList;
extern uint32 MailMessagesSent; extern uint32 MailMessagesSent;
@ -191,7 +190,7 @@ int Database::FindAccount(const char *CharacterName, Client *c) {
return AccountID; return AccountID;
} }
bool Database::VerifyMailKey(string CharacterName, int IPAddress, string MailKey) { bool Database::VerifyMailKey(std::string CharacterName, int IPAddress, std::string MailKey) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0; char* query = 0;
@ -329,9 +328,9 @@ bool Database::LoadChatChannels() {
while((row = mysql_fetch_row(result))) { while((row = mysql_fetch_row(result))) {
string ChannelName = row[0]; std::string ChannelName = row[0];
string ChannelOwner = row[1]; std::string ChannelOwner = row[1];
string ChannelPassword = row[2]; std::string ChannelPassword = row[2];
ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, atoi(row[3])); ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, atoi(row[3]));
} }
@ -341,7 +340,7 @@ bool Database::LoadChatChannels() {
return true; return true;
} }
void Database::SetChannelPassword(string ChannelName, string Password) { void Database::SetChannelPassword(std::string ChannelName, std::string Password) {
_log(UCS__TRACE, "Database::SetChannelPassword(%s, %s)", ChannelName.c_str(), Password.c_str()); _log(UCS__TRACE, "Database::SetChannelPassword(%s, %s)", ChannelName.c_str(), Password.c_str());
@ -358,7 +357,7 @@ void Database::SetChannelPassword(string ChannelName, string Password) {
safe_delete_array(query); safe_delete_array(query);
} }
void Database::SetChannelOwner(string ChannelName, string Owner) { void Database::SetChannelOwner(std::string ChannelName, std::string Owner) {
_log(UCS__TRACE, "Database::SetChannelOwner(%s, %s)", ChannelName.c_str(), Owner.c_str()); _log(UCS__TRACE, "Database::SetChannelOwner(%s, %s)", ChannelName.c_str(), Owner.c_str());
@ -542,17 +541,17 @@ void Database::SendBody(Client *c, int MessageNumber) {
} }
bool Database::SendMail(string Recipient, string From, string Subject, string Body, string RecipientsString) { bool Database::SendMail(std::string Recipient, std::string From, std::string Subject, std::string Body, std::string RecipientsString) {
int CharacterID; int CharacterID;
string CharacterName; std::string CharacterName;
//printf("Database::SendMail(%s, %s, %s)\n", Recipient.c_str(), From.c_str(), Subject.c_str()); //printf("Database::SendMail(%s, %s, %s)\n", Recipient.c_str(), From.c_str(), Subject.c_str());
string::size_type LastPeriod = Recipient.find_last_of("."); std::string::size_type LastPeriod = Recipient.find_last_of(".");
if(LastPeriod == string::npos) if(LastPeriod == std::string::npos)
CharacterName = Recipient; CharacterName = Recipient;
else else
CharacterName = Recipient.substr(LastPeriod+1); CharacterName = Recipient.substr(LastPeriod+1);
@ -605,7 +604,7 @@ bool Database::SendMail(string Recipient, string From, string Subject, string Bo
Client *c = CL->IsCharacterOnline(CharacterName); Client *c = CL->IsCharacterOnline(CharacterName);
if(c) { if(c) {
string FQN = GetMailPrefix() + From; std::string FQN = GetMailPrefix() + From;
c->SendNotification(c->GetMailBoxNumber(CharacterName), Subject, FQN, LastMsgID); c->SendNotification(c->GetMailBoxNumber(CharacterName), Subject, FQN, LastMsgID);
} }
@ -692,7 +691,7 @@ void Database::ExpireMail() {
} }
} }
void Database::AddFriendOrIgnore(int CharID, int Type, string Name) { void Database::AddFriendOrIgnore(int CharID, int Type, std::string Name) {
const char *FriendsQuery="INSERT INTO `friends` (`charid`, `type`, `name`) VALUES ('%i', %i, '%s')"; const char *FriendsQuery="INSERT INTO `friends` (`charid`, `type`, `name`) VALUES ('%i', %i, '%s')";
@ -710,7 +709,7 @@ void Database::AddFriendOrIgnore(int CharID, int Type, string Name) {
safe_delete_array(query); safe_delete_array(query);
} }
void Database::RemoveFriendOrIgnore(int CharID, int Type, string Name) { void Database::RemoveFriendOrIgnore(int CharID, int Type, std::string Name) {
const char *FriendsQuery="DELETE FROM `friends` WHERE `charid`=%i AND `type`=%i and `name`='%s'"; const char *FriendsQuery="DELETE FROM `friends` WHERE `charid`=%i AND `type`=%i and `name`='%s'";
@ -727,7 +726,7 @@ void Database::RemoveFriendOrIgnore(int CharID, int Type, string Name) {
safe_delete_array(query); safe_delete_array(query);
} }
void Database::GetFriendsAndIgnore(int CharID, vector<string> &Friends, vector<string> &Ignorees) { void Database::GetFriendsAndIgnore(int CharID, std::vector<std::string> &Friends, std::vector<std::string> &Ignorees) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0; char* query = 0;
@ -749,7 +748,7 @@ void Database::GetFriendsAndIgnore(int CharID, vector<string> &Friends, vector<s
while((row = mysql_fetch_row(result))) { while((row = mysql_fetch_row(result))) {
string Name = row[1]; std::string Name = row[1];
if(atoi(row[0]) == 0) if(atoi(row[0]) == 0)
{ {

View File

@ -31,7 +31,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
using namespace std;
//atoi is not uint32 or uint32 safe!!!! //atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10) #define atoul(str) strtoul(str, nullptr, 10)
@ -45,20 +44,20 @@ public:
int FindAccount(const char *CharacterName, Client *c); int FindAccount(const char *CharacterName, Client *c);
int FindCharacter(const char *CharacterName); int FindCharacter(const char *CharacterName);
bool VerifyMailKey(string CharacterName, int IPAddress, string MailKey); bool VerifyMailKey(std::string CharacterName, int IPAddress, std::string MailKey);
bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len); bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len);
bool LoadChatChannels(); bool LoadChatChannels();
void GetAccountStatus(Client *c); void GetAccountStatus(Client *c);
void SetChannelPassword(string ChannelName, string Password); void SetChannelPassword(std::string ChannelName, std::string Password);
void SetChannelOwner(string ChannelName, string Owner); void SetChannelOwner(std::string ChannelName, std::string Owner);
void SendHeaders(Client *c); void SendHeaders(Client *c);
void SendBody(Client *c, int MessageNumber); void SendBody(Client *c, int MessageNumber);
bool SendMail(string Recipient, string From, string Subject, string Body, string RecipientsString); bool SendMail(std::string Recipient, std::string From, std::string Subject, std::string Body, std::string RecipientsString);
void SetMessageStatus(int MessageNumber, int Status); void SetMessageStatus(int MessageNumber, int Status);
void ExpireMail(); void ExpireMail();
void AddFriendOrIgnore(int CharID, int Type, string Name); void AddFriendOrIgnore(int CharID, int Type, std::string Name);
void RemoveFriendOrIgnore(int CharID, int Type, string Name); void RemoveFriendOrIgnore(int CharID, int Type, std::string Name);
void GetFriendsAndIgnore(int CharID, vector<string> &Friends, vector<string> &Ignorees); void GetFriendsAndIgnore(int CharID, std::vector<std::string> &Friends, std::vector<std::string> &Ignorees);
protected: protected:

View File

@ -45,7 +45,7 @@ ChatChannelList *ChannelList;
Database database; Database database;
string WorldShortName; std::string WorldShortName;
const ucsconfig *Config; const ucsconfig *Config;
@ -60,7 +60,7 @@ void CatchSignal(int sig_num) {
worldserver->Disconnect(); worldserver->Disconnect();
} }
string GetMailPrefix() { std::string GetMailPrefix() {
return "SOE.EQ." + WorldShortName + "."; return "SOE.EQ." + WorldShortName + ".";

View File

@ -22,7 +22,7 @@
ucsconfig *ucsconfig::_chat_config = nullptr; ucsconfig *ucsconfig::_chat_config = nullptr;
string ucsconfig::GetByName(const string &var_name) const { std::string ucsconfig::GetByName(const std::string &var_name) const {
return(EQEmuConfig::GetByName(var_name)); return(EQEmuConfig::GetByName(var_name));
} }

View File

@ -24,7 +24,7 @@
class ucsconfig : public EQEmuConfig { class ucsconfig : public EQEmuConfig {
public: public:
virtual string GetByName(const string &var_name) const; virtual std::string GetByName(const std::string &var_name) const;
private: private:

View File

@ -17,7 +17,6 @@
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include <iostream> #include <iostream>
using namespace std;
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>
@ -38,7 +37,7 @@ extern Clientlist *CL;
extern const ucsconfig *Config; extern const ucsconfig *Config;
extern Database database; extern Database database;
void ProcessMailTo(Client *c, string from, string subject, string message); void ProcessMailTo(Client *c, std::string from, std::string subject, std::string message);
WorldServer::WorldServer() WorldServer::WorldServer()
: WorldConnection(EmuTCPConnection::packetModeUCS, Config->SharedKey.c_str()) : WorldConnection(EmuTCPConnection::packetModeUCS, Config->SharedKey.c_str())
@ -86,7 +85,7 @@ void WorldServer::Process()
VARSTRUCT_DECODE_STRING(From, Buffer); VARSTRUCT_DECODE_STRING(From, Buffer);
string Message = Buffer; std::string Message = Buffer;
_log(UCS__TRACE, "Player: %s, Sent Message: %s", From, Message.c_str()); _log(UCS__TRACE, "Player: %s, Sent Message: %s", From, Message.c_str());
@ -105,11 +104,11 @@ void WorldServer::Process()
if(Message[0] == ';') if(Message[0] == ';')
{ {
c->SendChannelMessageByNumber(Message.substr(1, string::npos)); c->SendChannelMessageByNumber(Message.substr(1, std::string::npos));
} }
else if(Message[0] == '[') else if(Message[0] == '[')
{ {
CL->ProcessOPMailCommand(c, Message.substr(1, string::npos)); CL->ProcessOPMailCommand(c, Message.substr(1, std::string::npos));
} }
break; break;
@ -118,11 +117,11 @@ void WorldServer::Process()
case ServerOP_UCSMailMessage: case ServerOP_UCSMailMessage:
{ {
ServerMailMessageHeader_Struct *mail = (ServerMailMessageHeader_Struct*)pack->pBuffer; ServerMailMessageHeader_Struct *mail = (ServerMailMessageHeader_Struct*)pack->pBuffer;
database.SendMail(string("SOE.EQ.") + Config->ShortName + string(".") + string(mail->to), database.SendMail(std::string("SOE.EQ.") + Config->ShortName + std::string(".") + std::string(mail->to),
string(mail->from), std::string(mail->from),
mail->subject, mail->subject,
mail->message, mail->message,
string()); std::string());
break; break;
} }
} }

View File

@ -50,7 +50,7 @@ Adventure::~Adventure()
safe_delete(current_timer); safe_delete(current_timer);
} }
void Adventure::AddPlayer(string character_name, bool add_client_to_instance) void Adventure::AddPlayer(std::string character_name, bool add_client_to_instance)
{ {
if(!PlayerExists(character_name)) if(!PlayerExists(character_name))
{ {
@ -63,9 +63,9 @@ void Adventure::AddPlayer(string character_name, bool add_client_to_instance)
} }
} }
void Adventure::RemovePlayer(string character_name) void Adventure::RemovePlayer(std::string character_name)
{ {
list<string>::iterator iter = players.begin(); std::list<std::string>::iterator iter = players.begin();
while(iter != players.end()) while(iter != players.end())
{ {
if((*iter).compare(character_name) == 0) if((*iter).compare(character_name) == 0)
@ -78,9 +78,9 @@ void Adventure::RemovePlayer(string character_name)
} }
} }
bool Adventure::PlayerExists(string character_name) bool Adventure::PlayerExists(std::string character_name)
{ {
list<string>::iterator iter = players.begin(); std::list<std::string>::iterator iter = players.begin();
while(iter != players.end()) while(iter != players.end())
{ {
if(character_name.compare((*iter)) == 0) if(character_name.compare((*iter)) == 0)
@ -210,7 +210,7 @@ void Adventure::SetStatus(AdventureStatus new_status)
return; return;
} }
list<string>::iterator iter = players.begin(); std::list<std::string>::iterator iter = players.begin();
while(iter != players.end()) while(iter != players.end())
{ {
adventure_manager.GetAdventureData((*iter).c_str()); adventure_manager.GetAdventureData((*iter).c_str());
@ -224,7 +224,7 @@ void Adventure::SendAdventureMessage(uint32 type, const char *msg)
ServerEmoteMessage_Struct *sms = (ServerEmoteMessage_Struct*)pack->pBuffer; ServerEmoteMessage_Struct *sms = (ServerEmoteMessage_Struct*)pack->pBuffer;
sms->type = type; sms->type = type;
strcpy(sms->message, msg); strcpy(sms->message, msg);
list<string>::iterator iter = players.begin(); std::list<std::string>::iterator iter = players.begin();
while(iter != players.end()) while(iter != players.end())
{ {
ClientListEntry *current = client_list.FindCharacter((*iter).c_str()); ClientListEntry *current = client_list.FindCharacter((*iter).c_str());
@ -278,7 +278,7 @@ void Adventure::IncrementAssassinationCount()
void Adventure::Finished(AdventureWinStatus ws) void Adventure::Finished(AdventureWinStatus ws)
{ {
list<string>::iterator iter = players.begin(); std::list<std::string>::iterator iter = players.begin();
while(iter != players.end()) while(iter != players.end())
{ {
ClientListEntry *current = client_list.FindCharacter((*iter).c_str()); ClientListEntry *current = client_list.FindCharacter((*iter).c_str());
@ -372,8 +372,8 @@ void Adventure::MoveCorpsesToGraveyard()
return; return;
} }
list<uint32> dbid_list; std::list<uint32> dbid_list;
list<uint32> charid_list; std::list<uint32> charid_list;
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0; char* query = 0;
MYSQL_RES *result; MYSQL_RES *result;
@ -395,7 +395,7 @@ void Adventure::MoveCorpsesToGraveyard()
safe_delete_array(query); safe_delete_array(query);
} }
list<uint32>::iterator iter = dbid_list.begin(); std::list<uint32>::iterator iter = dbid_list.begin();
while(iter != dbid_list.end()) while(iter != dbid_list.end())
{ {
float x = GetTemplate()->graveyard_x + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius); float x = GetTemplate()->graveyard_x + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
@ -415,7 +415,7 @@ void Adventure::MoveCorpsesToGraveyard()
} }
iter = dbid_list.begin(); iter = dbid_list.begin();
list<uint32>::iterator c_iter = charid_list.begin(); std::list<uint32>::iterator c_iter = charid_list.begin();
while(iter != dbid_list.end()) while(iter != dbid_list.end())
{ {
ServerPacket* pack = new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct)); ServerPacket* pack = new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct));

View File

@ -9,8 +9,6 @@
#include <string> #include <string>
#include <stdlib.h> #include <stdlib.h>
using namespace std;
enum AdventureStatus enum AdventureStatus
{ {
AS_WaitingForZoneIn, AS_WaitingForZoneIn,
@ -28,7 +26,7 @@ enum AdventureWinStatus
struct AdventureZones struct AdventureZones
{ {
string zone; std::string zone;
int version; int version;
}; };
@ -40,7 +38,7 @@ struct AdventureZoneIn
struct AdventureFinishEvent struct AdventureFinishEvent
{ {
string name; std::string name;
bool win; bool win;
int points; int points;
int theme; int theme;
@ -48,7 +46,7 @@ struct AdventureFinishEvent
struct LeaderboardInfo struct LeaderboardInfo
{ {
string name; std::string name;
uint32 wins; uint32 wins;
uint32 guk_wins; uint32 guk_wins;
uint32 mir_wins; uint32 mir_wins;
@ -71,9 +69,9 @@ public:
~Adventure(); ~Adventure();
bool Process(); bool Process();
bool IsActive(); bool IsActive();
void AddPlayer(string character_name, bool add_client_to_instance = true); void AddPlayer(std::string character_name, bool add_client_to_instance = true);
void RemovePlayer(string character_name); void RemovePlayer(std::string character_name);
bool PlayerExists(string character_name); bool PlayerExists(std::string character_name);
bool CreateInstance(); bool CreateInstance();
void IncrementCount(); void IncrementCount();
void IncrementAssassinationCount(); void IncrementAssassinationCount();
@ -85,7 +83,7 @@ public:
uint16 GetInstanceID() const { return instance_id; } uint16 GetInstanceID() const { return instance_id; }
const AdventureTemplate *GetTemplate() const { return adventure_template; } const AdventureTemplate *GetTemplate() const { return adventure_template; }
AdventureStatus GetStatus() const { return status; } AdventureStatus GetStatus() const { return status; }
list<string> GetPlayers() { return players; } std::list<std::string> GetPlayers() { return players; }
int GetCount() const { return count; } int GetCount() const { return count; }
int GetAssassinationCount() const { return assassination_count; } int GetAssassinationCount() const { return assassination_count; }
uint32 GetRemainingTime() const { if(current_timer) { return (current_timer->GetRemainingTime() / 1000); } else { return 0; } } uint32 GetRemainingTime() const { if(current_timer) { return (current_timer->GetRemainingTime() / 1000); } else { return 0; } }
@ -95,7 +93,7 @@ protected:
int assassination_count; int assassination_count;
AdventureTemplate *adventure_template; AdventureTemplate *adventure_template;
AdventureStatus status; AdventureStatus status;
list<string> players; std::list<std::string> players;
Timer *current_timer; Timer *current_timer;
int instance_id; int instance_id;
}; };

View File

@ -33,7 +33,7 @@ void AdventureManager::Process()
{ {
if(process_timer->Check()) if(process_timer->Check())
{ {
list<Adventure*>::iterator iter = adventure_list.begin(); std::list<Adventure*>::iterator iter = adventure_list.begin();
while(iter != adventure_list.end()) while(iter != adventure_list.end())
{ {
if(!(*iter)->Process()) if(!(*iter)->Process())
@ -71,7 +71,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
/** /**
* This block checks to see if we actually have any adventures for the requested theme. * This block checks to see if we actually have any adventures for the requested theme.
*/ */
map<uint32, list<AdventureTemplate*> >::iterator adv_list_iter = adventure_entries.find(sar->template_id); std::map<uint32, std::list<AdventureTemplate*> >::iterator adv_list_iter = adventure_entries.find(sar->template_id);
if(adv_list_iter == adventure_entries.end()) if(adv_list_iter == adventure_entries.end())
{ {
ServerPacket *pack = new ServerPacket(ServerOP_AdventureRequestDeny, sizeof(ServerAdventureRequestDeny_Struct)); ServerPacket *pack = new ServerPacket(ServerOP_AdventureRequestDeny, sizeof(ServerAdventureRequestDeny_Struct));
@ -89,7 +89,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
* Active being in progress, finished adventures that are still waiting to expire do not count * Active being in progress, finished adventures that are still waiting to expire do not count
* Though they will count against you for which new adventure you can get. * Though they will count against you for which new adventure you can get.
*/ */
list<Adventure*>::iterator iter = adventure_list.begin(); std::list<Adventure*>::iterator iter = adventure_list.begin();
while(iter != adventure_list.end()) while(iter != adventure_list.end())
{ {
Adventure* current = (*iter); Adventure* current = (*iter);
@ -103,7 +103,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
ServerAdventureRequestDeny_Struct *deny = (ServerAdventureRequestDeny_Struct*)pack->pBuffer; ServerAdventureRequestDeny_Struct *deny = (ServerAdventureRequestDeny_Struct*)pack->pBuffer;
strcpy(deny->leader, sar->leader); strcpy(deny->leader, sar->leader);
stringstream ss(stringstream::out | stringstream::in); std::stringstream ss(std::stringstream::out | std::stringstream::in);
ss << (data + sizeof(ServerAdventureRequest_Struct) + (64 * i)) << " is already apart of an active adventure."; ss << (data + sizeof(ServerAdventureRequest_Struct) + (64 * i)) << " is already apart of an active adventure.";
strcpy(deny->reason, ss.str().c_str()); strcpy(deny->reason, ss.str().c_str());
@ -121,8 +121,8 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
* Now we need to get every available adventure for our selected theme and exclude ones we can't use. * Now we need to get every available adventure for our selected theme and exclude ones we can't use.
* ie. the ones that would cause overlap issues for new adventures with the old unexpired adventures. * ie. the ones that would cause overlap issues for new adventures with the old unexpired adventures.
*/ */
list<AdventureZones> excluded_zones; std::list<AdventureZones> excluded_zones;
list<AdventureZoneIn> excluded_zone_ins; std::list<AdventureZoneIn> excluded_zone_ins;
for(int i = 0; i < sar->member_count; ++i) for(int i = 0; i < sar->member_count; ++i)
{ {
int finished_adventures_count; int finished_adventures_count;
@ -148,12 +148,12 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
safe_delete_array(finished_adventures); safe_delete_array(finished_adventures);
} }
list<AdventureTemplate*> eligible_adventures = adventure_entries[sar->template_id]; std::list<AdventureTemplate*> eligible_adventures = adventure_entries[sar->template_id];
/** /**
* Remove zones from eligible zones based on their difficulty and type. * Remove zones from eligible zones based on their difficulty and type.
* ie only use difficult zones for difficult, collect for collect, etc. * ie only use difficult zones for difficult, collect for collect, etc.
*/ */
list<AdventureTemplate*>::iterator ea_iter = eligible_adventures.begin(); std::list<AdventureTemplate*>::iterator ea_iter = eligible_adventures.begin();
while(ea_iter != eligible_adventures.end()) while(ea_iter != eligible_adventures.end())
{ {
if((*ea_iter)->is_hard != ((sar->risk == 2) ? true : false)) if((*ea_iter)->is_hard != ((sar->risk == 2) ? true : false))
@ -253,7 +253,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
ServerAdventureRequestDeny_Struct *deny = (ServerAdventureRequestDeny_Struct*)pack->pBuffer; ServerAdventureRequestDeny_Struct *deny = (ServerAdventureRequestDeny_Struct*)pack->pBuffer;
strcpy(deny->leader, sar->leader); strcpy(deny->leader, sar->leader);
stringstream ss(stringstream::out | stringstream::in); std::stringstream ss(std::stringstream::out | std::stringstream::in);
ss << "The maximum level range for this adventure is " << RuleI(Adventure, MaxLevelRange); ss << "The maximum level range for this adventure is " << RuleI(Adventure, MaxLevelRange);
ss << " but the level range calculated was " << (max_level - min_level) << "."; ss << " but the level range calculated was " << (max_level - min_level) << ".";
strcpy(deny->reason, ss.str().c_str()); strcpy(deny->reason, ss.str().c_str());
@ -266,10 +266,10 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
/** /**
* Remove the zones from our eligible zones based on the exclusion above * Remove the zones from our eligible zones based on the exclusion above
*/ */
list<AdventureZones>::iterator ez_iter = excluded_zones.begin(); std::list<AdventureZones>::iterator ez_iter = excluded_zones.begin();
while(ez_iter != excluded_zones.end()) while(ez_iter != excluded_zones.end())
{ {
list<AdventureTemplate*>::iterator ea_iter = eligible_adventures.begin(); std::list<AdventureTemplate*>::iterator ea_iter = eligible_adventures.begin();
while(ea_iter != eligible_adventures.end()) while(ea_iter != eligible_adventures.end())
{ {
if((*ez_iter).zone.compare((*ea_iter)->zone) == 0 && (*ez_iter).version == (*ea_iter)->zone_version) if((*ez_iter).zone.compare((*ea_iter)->zone) == 0 && (*ez_iter).version == (*ea_iter)->zone_version)
@ -282,10 +282,10 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
ez_iter++; ez_iter++;
} }
list<AdventureZoneIn>::iterator ezi_iter = excluded_zone_ins.begin(); std::list<AdventureZoneIn>::iterator ezi_iter = excluded_zone_ins.begin();
while(ezi_iter != excluded_zone_ins.end()) while(ezi_iter != excluded_zone_ins.end())
{ {
list<AdventureTemplate*>::iterator ea_iter = eligible_adventures.begin(); std::list<AdventureTemplate*>::iterator ea_iter = eligible_adventures.begin();
while(ea_iter != eligible_adventures.end()) while(ea_iter != eligible_adventures.end())
{ {
if((*ezi_iter).zone_id == (*ea_iter)->zone_in_zone_id && (*ezi_iter).door_id == (*ea_iter)->zone_in_object_id) if((*ezi_iter).zone_id == (*ea_iter)->zone_in_zone_id && (*ezi_iter).door_id == (*ea_iter)->zone_in_object_id)
@ -448,8 +448,8 @@ void AdventureManager::TryAdventureCreate(const char *data)
void AdventureManager::GetAdventureData(Adventure *adv) void AdventureManager::GetAdventureData(Adventure *adv)
{ {
list<string> player_list = adv->GetPlayers(); std::list<std::string> player_list = adv->GetPlayers();
list<string>::iterator iter = player_list.begin(); std::list<std::string>::iterator iter = player_list.begin();
while(iter != player_list.end()) while(iter != player_list.end())
{ {
GetAdventureData((*iter).c_str()); GetAdventureData((*iter).c_str());
@ -524,9 +524,9 @@ void AdventureManager::GetAdventureData(const char *name)
} }
} }
bool AdventureManager::IsInExcludedZoneList(list<AdventureZones> excluded_zones, string zone_name, int version) bool AdventureManager::IsInExcludedZoneList(std::list<AdventureZones> excluded_zones, std::string zone_name, int version)
{ {
list<AdventureZones>::iterator iter = excluded_zones.begin(); std::list<AdventureZones>::iterator iter = excluded_zones.begin();
while(iter != excluded_zones.end()) while(iter != excluded_zones.end())
{ {
if(((*iter).zone.compare(zone_name) == 0) && ((*iter).version == version)) if(((*iter).zone.compare(zone_name) == 0) && ((*iter).version == version))
@ -538,9 +538,9 @@ bool AdventureManager::IsInExcludedZoneList(list<AdventureZones> excluded_zones,
return false; return false;
} }
bool AdventureManager::IsInExcludedZoneInList(list<AdventureZoneIn> excluded_zone_ins, int zone_id, int door_object) bool AdventureManager::IsInExcludedZoneInList(std::list<AdventureZoneIn> excluded_zone_ins, int zone_id, int door_object)
{ {
list<AdventureZoneIn>::iterator iter = excluded_zone_ins.begin(); std::list<AdventureZoneIn>::iterator iter = excluded_zone_ins.begin();
while(iter != excluded_zone_ins.end()) while(iter != excluded_zone_ins.end())
{ {
if(((*iter).zone_id == zone_id) && ((*iter).door_id == door_object)) if(((*iter).zone_id == zone_id) && ((*iter).door_id == door_object))
@ -557,7 +557,7 @@ Adventure **AdventureManager::GetFinishedAdventures(const char *player, int &cou
Adventure **ret = nullptr; Adventure **ret = nullptr;
count = 0; count = 0;
list<Adventure*>::iterator iter = adventure_list.begin(); std::list<Adventure*>::iterator iter = adventure_list.begin();
while(iter != adventure_list.end()) while(iter != adventure_list.end())
{ {
if((*iter)->PlayerExists(player)) if((*iter)->PlayerExists(player))
@ -590,7 +590,7 @@ Adventure **AdventureManager::GetFinishedAdventures(const char *player, int &cou
Adventure *AdventureManager::GetActiveAdventure(const char *player) Adventure *AdventureManager::GetActiveAdventure(const char *player)
{ {
list<Adventure*>::iterator iter = adventure_list.begin(); std::list<Adventure*>::iterator iter = adventure_list.begin();
while(iter != adventure_list.end()) while(iter != adventure_list.end())
{ {
if((*iter)->PlayerExists(player) && (*iter)->IsActive()) if((*iter)->PlayerExists(player) && (*iter)->IsActive())
@ -604,13 +604,13 @@ Adventure *AdventureManager::GetActiveAdventure(const char *player)
AdventureTemplate *AdventureManager::GetAdventureTemplate(int theme, int id) AdventureTemplate *AdventureManager::GetAdventureTemplate(int theme, int id)
{ {
map<uint32, list<AdventureTemplate*> >::iterator iter = adventure_entries.find(theme); std::map<uint32, std::list<AdventureTemplate*> >::iterator iter = adventure_entries.find(theme);
if(iter == adventure_entries.end()) if(iter == adventure_entries.end())
{ {
return nullptr; return nullptr;
} }
list<AdventureTemplate*>::iterator l_iter = (*iter).second.begin(); std::list<AdventureTemplate*>::iterator l_iter = (*iter).second.begin();
while(l_iter != (*iter).second.end()) while(l_iter != (*iter).second.end())
{ {
if((*l_iter)->id == id) if((*l_iter)->id == id)
@ -624,7 +624,7 @@ AdventureTemplate *AdventureManager::GetAdventureTemplate(int theme, int id)
AdventureTemplate *AdventureManager::GetAdventureTemplate(int id) AdventureTemplate *AdventureManager::GetAdventureTemplate(int id)
{ {
map<uint32, AdventureTemplate*>::iterator iter = adventure_templates.find(id); std::map<uint32, AdventureTemplate*>::iterator iter = adventure_templates.find(id);
if(iter == adventure_templates.end()) if(iter == adventure_templates.end())
{ {
return nullptr; return nullptr;
@ -713,7 +713,7 @@ bool AdventureManager::LoadAdventureEntries()
int template_id = atoi(row[1]); int template_id = atoi(row[1]);
AdventureTemplate* tid = nullptr; AdventureTemplate* tid = nullptr;
map<uint32, AdventureTemplate*>::iterator t_iter = adventure_templates.find(template_id); std::map<uint32, AdventureTemplate*>::iterator t_iter = adventure_templates.find(template_id);
if(t_iter == adventure_templates.end()) if(t_iter == adventure_templates.end())
{ {
continue; continue;
@ -723,8 +723,8 @@ bool AdventureManager::LoadAdventureEntries()
tid = adventure_templates[template_id]; tid = adventure_templates[template_id];
} }
list<AdventureTemplate*> temp; std::list<AdventureTemplate*> temp;
map<uint32, list<AdventureTemplate*> >::iterator iter = adventure_entries.find(id); std::map<uint32, std::list<AdventureTemplate*> >::iterator iter = adventure_entries.find(id);
if(iter == adventure_entries.end()) if(iter == adventure_entries.end())
{ {
temp.push_back(tid); temp.push_back(tid);
@ -752,7 +752,7 @@ bool AdventureManager::LoadAdventureEntries()
void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int door_id) void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int door_id)
{ {
list<Adventure*>::iterator iter = adventure_list.begin(); std::list<Adventure*>::iterator iter = adventure_list.begin();
while(iter != adventure_list.end()) while(iter != adventure_list.end())
{ {
const AdventureTemplate *t = (*iter)->GetTemplate(); const AdventureTemplate *t = (*iter)->GetTemplate();
@ -842,7 +842,7 @@ void AdventureManager::LeaveAdventure(const char *name)
void AdventureManager::IncrementCount(uint16 instance_id) void AdventureManager::IncrementCount(uint16 instance_id)
{ {
list<Adventure*>::iterator iter = adventure_list.begin(); std::list<Adventure*>::iterator iter = adventure_list.begin();
Adventure *current = nullptr; Adventure *current = nullptr;
while(iter != adventure_list.end()) while(iter != adventure_list.end())
{ {
@ -857,8 +857,8 @@ void AdventureManager::IncrementCount(uint16 instance_id)
if(current) if(current)
{ {
current->IncrementCount(); current->IncrementCount();
list<string> slist = current->GetPlayers(); std::list<std::string> slist = current->GetPlayers();
list<string>::iterator siter = slist.begin(); std::list<std::string>::iterator siter = slist.begin();
ServerPacket *pack = new ServerPacket(ServerOP_AdventureCountUpdate, sizeof(ServerAdventureCountUpdate_Struct)); ServerPacket *pack = new ServerPacket(ServerOP_AdventureCountUpdate, sizeof(ServerAdventureCountUpdate_Struct));
ServerAdventureCountUpdate_Struct *ac = (ServerAdventureCountUpdate_Struct*)pack->pBuffer; ServerAdventureCountUpdate_Struct *ac = (ServerAdventureCountUpdate_Struct*)pack->pBuffer;
ac->count = current->GetCount(); ac->count = current->GetCount();
@ -882,7 +882,7 @@ void AdventureManager::IncrementCount(uint16 instance_id)
void AdventureManager::IncrementAssassinationCount(uint16 instance_id) void AdventureManager::IncrementAssassinationCount(uint16 instance_id)
{ {
list<Adventure*>::iterator iter = adventure_list.begin(); std::list<Adventure*>::iterator iter = adventure_list.begin();
Adventure *current = nullptr; Adventure *current = nullptr;
while(iter != adventure_list.end()) while(iter != adventure_list.end())
{ {
@ -903,7 +903,7 @@ void AdventureManager::IncrementAssassinationCount(uint16 instance_id)
void AdventureManager::GetZoneData(uint16 instance_id) void AdventureManager::GetZoneData(uint16 instance_id)
{ {
list<Adventure*>::iterator iter = adventure_list.begin(); std::list<Adventure*>::iterator iter = adventure_list.begin();
Adventure *current = nullptr; Adventure *current = nullptr;
while(iter != adventure_list.end()) while(iter != adventure_list.end())
{ {
@ -1283,7 +1283,7 @@ void AdventureManager::DoLeaderboardRequestWins(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_wins.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_wins.begin();
while(i < 100 && iter != leaderboard_info_wins.end()) while(i < 100 && iter != leaderboard_info_wins.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1350,7 +1350,7 @@ void AdventureManager::DoLeaderboardRequestPercentage(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage.begin();
while(i < 100 && iter != leaderboard_info_percentage.end()) while(i < 100 && iter != leaderboard_info_percentage.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1417,7 +1417,7 @@ void AdventureManager::DoLeaderboardRequestWinsGuk(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_guk.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_guk.begin();
while(i < 100 && iter != leaderboard_info_wins_guk.end()) while(i < 100 && iter != leaderboard_info_wins_guk.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1484,7 +1484,7 @@ void AdventureManager::DoLeaderboardRequestPercentageGuk(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_guk.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_guk.begin();
while(i < 100 && iter != leaderboard_info_percentage_guk.end()) while(i < 100 && iter != leaderboard_info_percentage_guk.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1551,7 +1551,7 @@ void AdventureManager::DoLeaderboardRequestWinsMir(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_mir.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_mir.begin();
while(i < 100 && iter != leaderboard_info_wins_mir.end()) while(i < 100 && iter != leaderboard_info_wins_mir.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1618,7 +1618,7 @@ void AdventureManager::DoLeaderboardRequestPercentageMir(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_mir.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_mir.begin();
while(i < 100 && iter != leaderboard_info_percentage_mir.end()) while(i < 100 && iter != leaderboard_info_percentage_mir.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1685,7 +1685,7 @@ void AdventureManager::DoLeaderboardRequestWinsMmc(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_mmc.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_mmc.begin();
while(i < 100 && iter != leaderboard_info_wins_mmc.end()) while(i < 100 && iter != leaderboard_info_wins_mmc.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1752,7 +1752,7 @@ void AdventureManager::DoLeaderboardRequestPercentageMmc(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_mmc.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_mmc.begin();
while(i < 100 && iter != leaderboard_info_percentage_mmc.end()) while(i < 100 && iter != leaderboard_info_percentage_mmc.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1819,7 +1819,7 @@ void AdventureManager::DoLeaderboardRequestWinsRuj(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_ruj.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_ruj.begin();
while(i < 100 && iter != leaderboard_info_wins_ruj.end()) while(i < 100 && iter != leaderboard_info_wins_ruj.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1886,7 +1886,7 @@ void AdventureManager::DoLeaderboardRequestPercentageRuj(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_ruj.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_ruj.begin();
while(i < 100 && iter != leaderboard_info_percentage_ruj.end()) while(i < 100 && iter != leaderboard_info_percentage_ruj.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -1953,7 +1953,7 @@ void AdventureManager::DoLeaderboardRequestWinsTak(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_ruj.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_wins_ruj.begin();
while(i < 100 && iter != leaderboard_info_wins_ruj.end()) while(i < 100 && iter != leaderboard_info_wins_ruj.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -2020,7 +2020,7 @@ void AdventureManager::DoLeaderboardRequestPercentageTak(const char* player)
int our_successes; int our_successes;
int our_failures; int our_failures;
int i = 0; int i = 0;
list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_tak.begin(); std::list<LeaderboardInfo>::iterator iter = leaderboard_info_percentage_tak.begin();
while(i < 100 && iter != leaderboard_info_percentage_tak.end()) while(i < 100 && iter != leaderboard_info_percentage_tak.end())
{ {
LeaderboardInfo li = (*iter); LeaderboardInfo li = (*iter);
@ -2076,7 +2076,7 @@ void AdventureManager::DoLeaderboardRequestPercentageTak(const char* player)
bool AdventureManager::PopFinishedEvent(const char *name, AdventureFinishEvent &fe) bool AdventureManager::PopFinishedEvent(const char *name, AdventureFinishEvent &fe)
{ {
list<AdventureFinishEvent>::iterator iter = finished_list.begin(); std::list<AdventureFinishEvent>::iterator iter = finished_list.begin();
while(iter != finished_list.end()) while(iter != finished_list.end())
{ {
if((*iter).name.compare(name) == 0) if((*iter).name.compare(name) == 0)
@ -2116,13 +2116,13 @@ void AdventureManager::Save()
//disabled for now //disabled for now
return; return;
stringstream ss(stringstream::in | stringstream::out); std::stringstream ss(std::stringstream::in | std::stringstream::out);
int number_of_elements = adventure_list.size(); int number_of_elements = adventure_list.size();
ss.write((const char*)&number_of_elements, sizeof(int)); ss.write((const char*)&number_of_elements, sizeof(int));
char null_term = 0; char null_term = 0;
list<Adventure*>::iterator a_iter = adventure_list.begin(); std::list<Adventure*>::iterator a_iter = adventure_list.begin();
while(a_iter != adventure_list.end()) while(a_iter != adventure_list.end())
{ {
int cur = (*a_iter)->GetCount(); int cur = (*a_iter)->GetCount();
@ -2143,11 +2143,11 @@ void AdventureManager::Save()
cur = (*a_iter)->GetRemainingTime(); cur = (*a_iter)->GetRemainingTime();
ss.write((const char*)&cur, sizeof(int)); ss.write((const char*)&cur, sizeof(int));
list<string> players = (*a_iter)->GetPlayers(); std::list<std::string> players = (*a_iter)->GetPlayers();
cur = players.size(); cur = players.size();
ss.write((const char*)&cur, sizeof(int)); ss.write((const char*)&cur, sizeof(int));
list<string>::iterator s_iter = players.begin(); std::list<std::string>::iterator s_iter = players.begin();
while(s_iter != players.end()) while(s_iter != players.end())
{ {
ss.write((const char*)(*s_iter).c_str(), (*s_iter).size()); ss.write((const char*)(*s_iter).c_str(), (*s_iter).size());
@ -2160,7 +2160,7 @@ void AdventureManager::Save()
number_of_elements = finished_list.size(); number_of_elements = finished_list.size();
ss.write((const char*)&number_of_elements, sizeof(int)); ss.write((const char*)&number_of_elements, sizeof(int));
list<AdventureFinishEvent>::iterator f_iter = finished_list.begin(); std::list<AdventureFinishEvent>::iterator f_iter = finished_list.begin();
while(f_iter != finished_list.end()) while(f_iter != finished_list.end())
{ {
ss.write((const char*)&(*f_iter).win, sizeof(bool)); ss.write((const char*)&(*f_iter).win, sizeof(bool));

View File

@ -9,8 +9,6 @@
#include <map> #include <map>
#include <list> #include <list>
using namespace std;
class AdventureManager class AdventureManager
{ {
public: public:
@ -44,8 +42,8 @@ public:
AdventureTemplate *GetAdventureTemplate(int id); AdventureTemplate *GetAdventureTemplate(int id);
void GetZoneData(uint16 instance_id); void GetZoneData(uint16 instance_id);
protected: protected:
bool IsInExcludedZoneList(list<AdventureZones> excluded_zones, string zone_name, int version); bool IsInExcludedZoneList(std::list<AdventureZones> excluded_zones, std::string zone_name, int version);
bool IsInExcludedZoneInList(list<AdventureZoneIn> excluded_zone_ins, int zone_id, int door_object); bool IsInExcludedZoneInList(std::list<AdventureZoneIn> excluded_zone_ins, int zone_id, int door_object);
void DoLeaderboardRequestWins(const char* player); void DoLeaderboardRequestWins(const char* player);
void DoLeaderboardRequestPercentage(const char* player); void DoLeaderboardRequestPercentage(const char* player);
void DoLeaderboardRequestWinsGuk(const char* player); void DoLeaderboardRequestWinsGuk(const char* player);
@ -59,22 +57,22 @@ protected:
void DoLeaderboardRequestWinsTak(const char* player); void DoLeaderboardRequestWinsTak(const char* player);
void DoLeaderboardRequestPercentageTak(const char* player); void DoLeaderboardRequestPercentageTak(const char* player);
map<uint32, AdventureTemplate*> adventure_templates; std::map<uint32, AdventureTemplate*> adventure_templates;
map<uint32, list<AdventureTemplate*> > adventure_entries; std::map<uint32, std::list<AdventureTemplate*> > adventure_entries;
list<Adventure*> adventure_list; std::list<Adventure*> adventure_list;
list<AdventureFinishEvent> finished_list; std::list<AdventureFinishEvent> finished_list;
list<LeaderboardInfo> leaderboard_info_wins; std::list<LeaderboardInfo> leaderboard_info_wins;
list<LeaderboardInfo> leaderboard_info_percentage; std::list<LeaderboardInfo> leaderboard_info_percentage;
list<LeaderboardInfo> leaderboard_info_wins_guk; std::list<LeaderboardInfo> leaderboard_info_wins_guk;
list<LeaderboardInfo> leaderboard_info_percentage_guk; std::list<LeaderboardInfo> leaderboard_info_percentage_guk;
list<LeaderboardInfo> leaderboard_info_wins_mir; std::list<LeaderboardInfo> leaderboard_info_wins_mir;
list<LeaderboardInfo> leaderboard_info_percentage_mir; std::list<LeaderboardInfo> leaderboard_info_percentage_mir;
list<LeaderboardInfo> leaderboard_info_wins_mmc; std::list<LeaderboardInfo> leaderboard_info_wins_mmc;
list<LeaderboardInfo> leaderboard_info_percentage_mmc; std::list<LeaderboardInfo> leaderboard_info_percentage_mmc;
list<LeaderboardInfo> leaderboard_info_wins_ruj; std::list<LeaderboardInfo> leaderboard_info_wins_ruj;
list<LeaderboardInfo> leaderboard_info_percentage_ruj; std::list<LeaderboardInfo> leaderboard_info_percentage_ruj;
list<LeaderboardInfo> leaderboard_info_wins_tak; std::list<LeaderboardInfo> leaderboard_info_wins_tak;
list<LeaderboardInfo> leaderboard_info_percentage_tak; std::list<LeaderboardInfo> leaderboard_info_percentage_tak;
bool leaderboard_sorted_wins; bool leaderboard_sorted_wins;
bool leaderboard_sorted_percentage; bool leaderboard_sorted_percentage;
bool leaderboard_sorted_wins_guk; bool leaderboard_sorted_wins_guk;

View File

@ -96,7 +96,7 @@ EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) {
} }
void EQLConfig::GetZones(std::vector<LauncherZone> &result) { void EQLConfig::GetZones(std::vector<LauncherZone> &result) {
map<string, LauncherZone>::iterator cur, end; std::map<std::string, LauncherZone>::iterator cur, end;
cur = m_zones.begin(); cur = m_zones.begin();
end = m_zones.end(); end = m_zones.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@ -104,12 +104,12 @@ void EQLConfig::GetZones(std::vector<LauncherZone> &result) {
} }
} }
vector<string> EQLConfig::ListZones() { std::vector<std::string> EQLConfig::ListZones() {
LauncherLink *ll = launcher_list.Get(m_name.c_str()); LauncherLink *ll = launcher_list.Get(m_name.c_str());
vector<string> res; std::vector<std::string> res;
if(ll == nullptr) { if(ll == nullptr) {
//if the launcher isnt connected, use the list from the database. //if the launcher isnt connected, use the list from the database.
map<string, LauncherZone>::iterator cur, end; std::map<std::string, LauncherZone>::iterator cur, end;
cur = m_zones.begin(); cur = m_zones.begin();
end = m_zones.end(); end = m_zones.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@ -224,7 +224,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
return(false); return(false);
//check internal state //check internal state
map<string, LauncherZone>::iterator res; std::map<std::string, LauncherZone>::iterator res;
res = m_zones.find(short_name); res = m_zones.find(short_name);
if(res == m_zones.end()) { if(res == m_zones.end()) {
//not found. //not found.
@ -268,7 +268,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
bool EQLConfig::DeleteStaticZone(Const_char *short_name) { bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
//check internal state //check internal state
map<string, LauncherZone>::iterator res; std::map<std::string, LauncherZone>::iterator res;
res = m_zones.find(short_name); res = m_zones.find(short_name);
if(res == m_zones.end()) { if(res == m_zones.end()) {
//not found. //not found.
@ -341,8 +341,8 @@ int EQLConfig::GetDynamicCount() const {
return(m_dynamics); return(m_dynamics);
} }
map<string,string> EQLConfig::GetZoneDetails(Const_char *zone_ref) { std::map<std::string,std::string> EQLConfig::GetZoneDetails(Const_char *zone_ref) {
map<string,string> res; std::map<std::string,std::string> res;
LauncherLink *ll = launcher_list.Get(m_name.c_str()); LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll == nullptr) { if(ll == nullptr) {

View File

@ -23,8 +23,6 @@
#include <map> #include <map>
#include <string> #include <string>
using namespace std;
class LauncherLink; class LauncherLink;
typedef struct { typedef struct {
@ -60,16 +58,16 @@ public:
bool SetDynamicCount(int count); bool SetDynamicCount(int count);
int GetDynamicCount() const; int GetDynamicCount() const;
vector<string> ListZones(); //returns an array of zone refs std::vector<std::string> ListZones(); //returns an array of zone refs
map<string,string> GetZoneDetails(Const_char *zone_ref); std::map<std::string,std::string> GetZoneDetails(Const_char *zone_ref);
//END PERL EXPORT //END PERL EXPORT
protected: protected:
const string m_name; const std::string m_name;
uint8 m_dynamics; uint8 m_dynamics;
map<string, LauncherZone> m_zones; //static zones. std::map<std::string, LauncherZone> m_zones; //static zones.
}; };
#endif /*EQLCONFIG_H_*/ #endif /*EQLCONFIG_H_*/

View File

@ -38,16 +38,12 @@
#include "LauncherLink.h" #include "LauncherLink.h"
#include "wguild_mgr.h" #include "wguild_mgr.h"
#ifdef seed #ifdef seed
#undef seed #undef seed
#endif #endif
#include <algorithm> #include <algorithm>
using namespace std;
extern ZSList zoneserver_list; extern ZSList zoneserver_list;
extern ClientList client_list; extern ClientList client_list;
extern uint32 numzones; extern uint32 numzones;
@ -115,13 +111,13 @@ int EQW::CountZones() {
} }
//returns an array of zone_refs (opaque) //returns an array of zone_refs (opaque)
vector<string> EQW::ListBootedZones() { std::vector<std::string> EQW::ListBootedZones() {
vector<string> res; std::vector<std::string> res;
vector<uint32> zones; std::vector<uint32> zones;
zoneserver_list.GetZoneIDList(zones); zoneserver_list.GetZoneIDList(zones);
vector<uint32>::iterator cur, end; std::vector<uint32>::iterator cur, end;
cur = zones.begin(); cur = zones.begin();
end = zones.end(); end = zones.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@ -131,8 +127,8 @@ vector<string> EQW::ListBootedZones() {
return(res); return(res);
} }
map<string,string> EQW::GetZoneDetails(Const_char *zone_ref) { std::map<std::string,std::string> EQW::GetZoneDetails(Const_char *zone_ref) {
map<string,string> res; std::map<std::string,std::string> res;
ZoneServer *zs = zoneserver_list.FindByID(atoi(zone_ref)); ZoneServer *zs = zoneserver_list.FindByID(atoi(zone_ref));
if(zs == nullptr) { if(zs == nullptr) {
@ -165,13 +161,13 @@ int EQW::CountPlayers() {
} }
//returns an array of character names in the zone (empty=all zones) //returns an array of character names in the zone (empty=all zones)
vector<string> EQW::ListPlayers(Const_char *zone_name) { std::vector<std::string> EQW::ListPlayers(Const_char *zone_name) {
vector<string> res; std::vector<std::string> res;
vector<ClientListEntry *> list; std::vector<ClientListEntry *> list;
client_list.GetClients(zone_name, list); client_list.GetClients(zone_name, list);
vector<ClientListEntry *>::iterator cur, end; std::vector<ClientListEntry *>::iterator cur, end;
cur = list.begin(); cur = list.begin();
end = list.end(); end = list.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@ -180,8 +176,8 @@ vector<string> EQW::ListPlayers(Const_char *zone_name) {
return(res); return(res);
} }
map<string,string> EQW::GetPlayerDetails(Const_char *char_name) { std::map<std::string,std::string> EQW::GetPlayerDetails(Const_char *char_name) {
map<string,string> res; std::map<std::string,std::string> res;
ClientListEntry *cle = client_list.FindCharacter(char_name); ClientListEntry *cle = client_list.FindCharacter(char_name);
if(cle == nullptr) { if(cle == nullptr) {
@ -213,7 +209,7 @@ int EQW::CountLaunchers(bool active_only) {
if(active_only) if(active_only)
return(launcher_list.GetLauncherCount()); return(launcher_list.GetLauncherCount());
vector<string> it(EQW::ListLaunchers()); std::vector<std::string> it(EQW::ListLaunchers());
return(it.size()); return(it.size());
} }
/* /*
@ -223,10 +219,10 @@ vector<string> EQW::ListActiveLaunchers() {
return(launchers); return(launchers);
}*/ }*/
vector<string> EQW::ListLaunchers() { std::vector<std::string> EQW::ListLaunchers() {
// vector<string> list; // vector<string> list;
// database.GetLauncherList(list); // database.GetLauncherList(list);
vector<string> launchers; std::vector<std::string> launchers;
launcher_list.GetLauncherNameList(launchers); launcher_list.GetLauncherNameList(launchers);
return(launchers); return(launchers);
@ -405,8 +401,8 @@ int EQW::CountBugs() {
return 0; return 0;
} }
vector<string> EQW::ListBugs(uint32 offset) { std::vector<std::string> EQW::ListBugs(uint32 offset) {
vector<string> res; std::vector<std::string> res;
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0; char* query = 0;
MYSQL_RES *result; MYSQL_RES *result;
@ -422,8 +418,8 @@ vector<string> EQW::ListBugs(uint32 offset) {
return res; return res;
} }
map<string,string> EQW::GetBugDetails(Const_char *id) { std::map<std::string,std::string> EQW::GetBugDetails(Const_char *id) {
map<string,string> res; std::map<std::string,std::string> res;
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0; char* query = 0;
MYSQL_RES *result; MYSQL_RES *result;
@ -447,7 +443,7 @@ map<string,string> EQW::GetBugDetails(Const_char *id) {
} }
void EQW::ResolveBug(const char *id) { void EQW::ResolveBug(const char *id) {
vector<string> res; std::vector<std::string> res;
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0; char* query = 0;
if(database.RunQuery(query, MakeAnyLenString(&query, "UPDATE bugs SET status=1 WHERE id=%s", id), errbuf)) { if(database.RunQuery(query, MakeAnyLenString(&query, "UPDATE bugs SET status=1 WHERE id=%s", id), errbuf)) {

View File

@ -22,7 +22,6 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include "../common/types.h" #include "../common/types.h"
using namespace std;
class EQLConfig; class EQLConfig;
@ -46,16 +45,16 @@ public:
void LSReconnect(); void LSReconnect();
int CountZones(); int CountZones();
vector<string> ListBootedZones(); //returns an array of zone_refs (opaque) std::vector<std::string> ListBootedZones(); //returns an array of zone_refs (opaque)
map<string,string> GetZoneDetails(Const_char *zone_ref); //returns a hash ref of details std::map<std::string,std::string> GetZoneDetails(Const_char *zone_ref); //returns a hash ref of details
int CountPlayers(); int CountPlayers();
vector<string> ListPlayers(Const_char *zone_name = ""); //returns an array of player refs (opaque) std::vector<std::string> ListPlayers(Const_char *zone_name = ""); //returns an array of player refs (opaque)
map<string,string> GetPlayerDetails(Const_char *player_ref); //returns a hash ref of details std::map<std::string,std::string> GetPlayerDetails(Const_char *player_ref); //returns a hash ref of details
int CountLaunchers(bool active_only); int CountLaunchers(bool active_only);
// vector<string> ListActiveLaunchers(); //returns an array of launcher names // vector<string> ListActiveLaunchers(); //returns an array of launcher names
vector<string> ListLaunchers(); //returns an array of launcher names std::vector<std::string> ListLaunchers(); //returns an array of launcher names
EQLConfig * GetLauncher(Const_char *launcher_name); //returns the EQLConfig object for the specified launcher. EQLConfig * GetLauncher(Const_char *launcher_name); //returns the EQLConfig object for the specified launcher.
void CreateLauncher(Const_char *launcher_name, int dynamic_count); void CreateLauncher(Const_char *launcher_name, int dynamic_count);
// EQLConfig * FindLauncher(Const_char *zone_ref); // EQLConfig * FindLauncher(Const_char *zone_ref);
@ -74,8 +73,8 @@ public:
//bugs //bugs
int CountBugs(); int CountBugs();
vector<string> ListBugs(uint32 offset); //returns an array of zone_refs (opaque) std::vector<std::string> ListBugs(uint32 offset); //returns an array of zone_refs (opaque)
map<string,string> GetBugDetails(const char *id); std::map<std::string,std::string> GetBugDetails(const char *id);
void ResolveBug(const char *id); void ResolveBug(const char *id);
void SendMessage(uint32 type, const char *msg); void SendMessage(uint32 type, const char *msg);

View File

@ -25,8 +25,6 @@
#include "worlddb.h" #include "worlddb.h"
#include "console.h" #include "console.h"
using namespace std;
Mime EQWHTTPHandler::s_mime; Mime EQWHTTPHandler::s_mime;
#ifdef EMBPERL #ifdef EMBPERL
EQWParser *EQWHTTPHandler::s_parser = nullptr; EQWParser *EQWHTTPHandler::s_parser = nullptr;
@ -48,7 +46,7 @@ EQWParser *EQWHTTPHandler::GetParser() {
if(s_parser == nullptr) { if(s_parser == nullptr) {
EQW::Singleton()->ClearOutput(); EQW::Singleton()->ClearOutput();
s_parser = new EQWParser(); s_parser = new EQWParser();
const string &res = EQW::Singleton()->GetOutput(); const std::string &res = EQW::Singleton()->GetOutput();
if(!res.empty()) { if(!res.empty()) {
printf("EQWParser Init output:\n%s\n\n", res.c_str()); printf("EQWParser Init output:\n%s\n\n", res.c_str());
EQW::Singleton()->ClearOutput(); EQW::Singleton()->ClearOutput();
@ -75,7 +73,7 @@ void EQWHTTPHandler::Exec() {
SetHttpVersion("HTTP/1.0"); SetHttpVersion("HTTP/1.0");
AddResponseHeader("Connection", "close"); AddResponseHeader("Connection", "close");
if(GetUri().find("..") != string::npos) { if(GetUri().find("..") != std::string::npos) {
SendResponse("403", "Forbidden"); SendResponse("403", "Forbidden");
printf("%s is forbidden.\n", GetUri().c_str()); printf("%s is forbidden.\n", GetUri().c_str());
return; return;
@ -87,9 +85,9 @@ void EQWHTTPHandler::Exec() {
SendResponse("401", "Authorization Required"); SendResponse("401", "Authorization Required");
SendString("Gotta Authenticate."); SendString("Gotta Authenticate.");
} else { } else {
string::size_type start = GetUri().find_first_not_of('/'); std::string::size_type start = GetUri().find_first_not_of('/');
string page; std::string page;
if(start != string::npos) if(start != std::string::npos)
page = GetUri().substr(start); page = GetUri().substr(start);
else else
page = "index.html"; page = "index.html";
@ -122,7 +120,7 @@ void EQWHTTPHandler::OnHeader(const std::string& key,const std::string& value) {
std::string::size_type cpos; std::string::size_type cpos;
cpos = dec.find_first_of(':'); cpos = dec.find_first_of(':');
if(cpos == string::npos) { if(cpos == std::string::npos) {
printf("Invalid auth string: %s\n", dec.c_str()); printf("Invalid auth string: %s\n", dec.c_str());
return; return;
} }
@ -154,7 +152,7 @@ bool EQWHTTPHandler::CheckAuth() const {
void EQWHTTPHandler::SendPage(const std::string &file) { void EQWHTTPHandler::SendPage(const std::string &file) {
string path = "templates/"; std::string path = "templates/";
path += file; path += file;
FILE *f = fopen(path.c_str(), "rb"); FILE *f = fopen(path.c_str(), "rb");
@ -165,7 +163,7 @@ void EQWHTTPHandler::SendPage(const std::string &file) {
return; return;
} }
string type = s_mime.GetMimeFromFilename(file); std::string type = s_mime.GetMimeFromFilename(file);
AddResponseHeader("Content-type", type); AddResponseHeader("Content-type", type);
bool process = false; bool process = false;
@ -183,7 +181,7 @@ void EQWHTTPHandler::SendPage(const std::string &file) {
char *buffer = new char[READ_BUFFER_LEN+1]; char *buffer = new char[READ_BUFFER_LEN+1];
size_t len; size_t len;
string to_process; std::string to_process;
while((len = fread(buffer, 1, READ_BUFFER_LEN, f)) > 0) { while((len = fread(buffer, 1, READ_BUFFER_LEN, f)) > 0) {
buffer[len] = '\0'; buffer[len] = '\0';
if(process) if(process)
@ -213,12 +211,12 @@ bool EQWHTTPHandler::LoadMimeTypes(const char *filename) {
} }
#ifdef EMBPERL #ifdef EMBPERL
void EQWHTTPHandler::ProcessAndSend(const string &str) { void EQWHTTPHandler::ProcessAndSend(const std::string &str) {
string::size_type len = str.length(); std::string::size_type len = str.length();
string::size_type start = 0; std::string::size_type start = 0;
string::size_type pos, end; std::string::size_type pos, end;
while((pos = str.find("<?", start)) != string::npos) { while((pos = str.find("<?", start)) != std::string::npos) {
//send all the crap leading up to the script block //send all the crap leading up to the script block
if(pos != start) { if(pos != start) {
ProcessText(str.c_str() + start, pos-start); ProcessText(str.c_str() + start, pos-start);
@ -226,15 +224,15 @@ void EQWHTTPHandler::ProcessAndSend(const string &str) {
//look for the end of this script block... //look for the end of this script block...
end = str.find("?>", pos+2); end = str.find("?>", pos+2);
if(end == string::npos) { if(end == std::string::npos) {
//terminal ?> not found... should issue a warning or something... //terminal ?> not found... should issue a warning or something...
string scriptBody = str.substr(pos+2); std::string scriptBody = str.substr(pos+2);
ProcessScript(scriptBody); ProcessScript(scriptBody);
start = len; start = len;
break; break;
} else { } else {
//script only consumes some of this buffer... //script only consumes some of this buffer...
string scriptBody = str.substr(pos+2, end-pos-2); std::string scriptBody = str.substr(pos+2, end-pos-2);
ProcessScript(scriptBody); ProcessScript(scriptBody);
start = end + 2; start = end + 2;
} }
@ -253,7 +251,7 @@ void EQWHTTPHandler::ProcessScript(const std::string &script_body) {
// printf("Script: ''''%s''''\n\n", script_body.c_str()); // printf("Script: ''''%s''''\n\n", script_body.c_str());
GetParser()->EQW_eval("testing", script_body.c_str()); GetParser()->EQW_eval("testing", script_body.c_str());
const string &res = EQW::Singleton()->GetOutput(); const std::string &res = EQW::Singleton()->GetOutput();
if(!res.empty()) { if(!res.empty()) {
ProcessText(res.c_str(), res.length()); ProcessText(res.c_str(), res.length());
EQW::Singleton()->ClearOutput(); EQW::Singleton()->ClearOutput();

View File

@ -27,13 +27,10 @@
#include "../common/logsys.h" #include "../common/logsys.h"
#include "worlddb.h" #include "worlddb.h"
using namespace std;
#ifndef GvCV_set #ifndef GvCV_set
#define GvCV_set(gv,cv) (GvCV(gv) = (cv)) #define GvCV_set(gv,cv) (GvCV(gv) = (cv))
#endif #endif
XS(XS_EQWIO_PRINT); XS(XS_EQWIO_PRINT);
//so embedded scripts can use xs extensions (ala 'use socket;') //so embedded scripts can use xs extensions (ala 'use socket;')
@ -186,7 +183,7 @@ void EQWParser::DoInit() {
#ifdef EMBPERL_PLUGIN #ifdef EMBPERL_PLUGIN
_log(WORLD__PERL, "Loading worldui perl plugins."); _log(WORLD__PERL, "Loading worldui perl plugins.");
string err; std::string err;
if(!eval_file("world", "worldui.pl", err)) { if(!eval_file("world", "worldui.pl", err)) {
_log(WORLD__PERL_ERR, "Warning - world.pl: %s", err.c_str()); _log(WORLD__PERL_ERR, "Warning - world.pl: %s", err.c_str());
} }
@ -224,7 +221,7 @@ bool EQWParser::eval_file(const char * packagename, const char * filename, std::
return(dosub("eval_file", args, error)); return(dosub("eval_file", args, error));
} }
bool EQWParser::dosub(const char * subname, const std::vector<std::string> &args, string &error, int mode) { bool EQWParser::dosub(const char * subname, const std::vector<std::string> &args, std::string &error, int mode) {
bool err = false; bool err = false;
dSP; // initialize stack pointer dSP; // initialize stack pointer
ENTER; // everything created after here ENTER; // everything created after here
@ -254,7 +251,7 @@ bool EQWParser::dosub(const char * subname, const std::vector<std::string> &args
return(true); return(true);
} }
bool EQWParser::eval(const char * code, string &error) { bool EQWParser::eval(const char * code, std::string &error) {
std::vector<std::string> arg; std::vector<std::string> arg;
arg.push_back(code); arg.push_back(code);
return(dosub("my_eval", arg, error, G_SCALAR|G_DISCARD|G_EVAL|G_KEEPERR)); return(dosub("my_eval", arg, error, G_SCALAR|G_DISCARD|G_EVAL|G_KEEPERR));
@ -289,7 +286,7 @@ void EQWParser::EQW_eval(const char *pkg, const char *code) {
sv_setsv(l_db, _empty_sv); sv_setsv(l_db, _empty_sv);
} }
string err; std::string err;
if(!eval(code, err)) { if(!eval(code, err)) {
EQW::Singleton()->AppendOutput(err.c_str()); EQW::Singleton()->AppendOutput(err.c_str());
} }

View File

@ -22,12 +22,10 @@
#include "../common/SocketLib/HttpdForm.h" #include "../common/SocketLib/HttpdForm.h"
#include <cstdlib> #include <cstdlib>
using namespace std;
HTTPRequest::HTTPRequest(EQWHTTPHandler *h, HttpdForm *form) HTTPRequest::HTTPRequest(EQWHTTPHandler *h, HttpdForm *form)
: m_handler(h) : m_handler(h)
{ {
string name, value; std::string name, value;
if(form->getfirst(name, value)) { if(form->getfirst(name, value)) {
m_values[name] = value; m_values[name] = value;
while(form->getnext(name, value)) while(form->getnext(name, value))
@ -47,7 +45,7 @@ const char *HTTPRequest::get(const char *name, const char *default_value) const
return(res->second.c_str()); return(res->second.c_str());
} }
map<string,string> HTTPRequest::get_all() const { std::map<std::string,std::string> HTTPRequest::get_all() const {
return m_values; return m_values;
} }

View File

@ -29,8 +29,6 @@
class HttpdForm; class HttpdForm;
class EQWHTTPHandler; class EQWHTTPHandler;
using namespace std;
class HTTPRequest { class HTTPRequest {
public: public:
HTTPRequest(EQWHTTPHandler *h, HttpdForm *form); HTTPRequest(EQWHTTPHandler *h, HttpdForm *form);
@ -44,7 +42,7 @@ public:
//returns a database-safe string //returns a database-safe string
Const_char * getEscaped(Const_char *name, Const_char *default_value = "") const; Const_char * getEscaped(Const_char *name, Const_char *default_value = "") const;
map<string,string> get_all() const; std::map<std::string,std::string> get_all() const;
void redirect(Const_char *URL); void redirect(Const_char *URL);
void SetResponseCode(Const_char *code); void SetResponseCode(Const_char *code);

View File

@ -31,11 +31,9 @@
#include <vector> #include <vector>
#include <string> #include <string>
using namespace std;
extern LauncherList launcher_list; extern LauncherList launcher_list;
LauncherLink::LauncherLink(int id, EmuTCPConnection *c) LauncherLink::LauncherLink(int id, EmuTCPConnection *c)
: ID(id), : ID(id),
tcpc(c), tcpc(c),

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