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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -46,8 +46,6 @@
#include "../common/crc32.h"
#include "../common/eq_packet_structs.h"
using namespace std;
#define EQN_DEBUG 0
#define EQN_DEBUG_Error 0
#define EQN_DEBUG_Packet 0
@ -230,19 +228,19 @@ void EQStreamServer::Process() {
}
}
map <string, EQStream*>::iterator connection;
std::map <std::string, EQStream*>::iterator connection;
for (connection = connection_list.begin( ); connection != connection_list.end( );)
{
if(!connection->second)
{
map <string, EQStream*>::iterator tmp=connection;
std::map <std::string, EQStream*>::iterator tmp=connection;
connection++;
connection_list.erase(tmp);
continue;
}
EQStream* eqs_data = connection->second;
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
map <string, EQStream*>::iterator tmp=connection;
std::map <std::string, EQStream*>::iterator tmp=connection;
connection++;
safe_delete(eqs_data);
connection_list.erase(tmp);
@ -277,7 +275,7 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
sprintf(temp,"%lu:%u",(unsigned long)irIP,irPort);
cout << "Data from " << temp << endl;
EQStream* tmp = NULL;
map <string, EQStream*>::iterator connection;
std::map <std::string, EQStream*>::iterator connection;
if ((connection=connection_list.find(temp))!=connection_list.end())
tmp=connection->second;
if(tmp != NULL && tmp->GetrPort() == irPort)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,13 +15,13 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "../common/StringUtil.h"
#include <sstream>
#include <iostream>
#include <limits>
#include <limits.h>
#include "debug.h"
#include "StringUtil.h"
#include "Item.h"
#include "database.h"
#include "misc.h"
@ -29,8 +29,6 @@
#include "shareddb.h"
#include "classes.h"
using namespace std;
int32 NextItemInstSerialNumber = 1;
static inline int32 GetNextItemInstSerialNumber() {
@ -45,7 +43,7 @@ static inline int32 GetNextItemInstSerialNumber() {
// 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.
if(NextItemInstSerialNumber >= INT_MAX)
if(NextItemInstSerialNumber >= std::numeric_limits<uint32>::max())
NextItemInstSerialNumber = 1;
else
NextItemInstSerialNumber++;
@ -95,7 +93,7 @@ ItemInstQueue::~ItemInstQueue() {
}
Inventory::~Inventory() {
map<int16, ItemInst*>::iterator cur,end;
std::map<int16, ItemInst*>::iterator cur,end;
cur = m_worn.begin();
@ -573,7 +571,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
std::string ItemInst::GetCustomDataString() const {
std::string ret_val;
map<std::string, std::string>::const_iterator iter = m_custom_data.begin();
std::map<std::string, std::string>::const_iterator iter = m_custom_data.begin();
while(iter != m_custom_data.end()) {
if(ret_val.length() > 0) {
ret_val += "^";
@ -617,14 +615,14 @@ void ItemInst::SetCustomData(std::string identifier, bool value) {
}
void ItemInst::DeleteCustomData(std::string identifier) {
map<std::string, std::string>::iterator iter = m_custom_data.find(identifier);
std::map<std::string, std::string>::iterator iter = m_custom_data.find(identifier);
if(iter != m_custom_data.end()) {
m_custom_data.erase(iter);
}
}
std::string ItemInst::GetCustomData(std::string identifier) {
map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier);
std::map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier);
if(iter != m_custom_data.end()) {
return iter->second;
}
@ -1053,27 +1051,7 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
return SLOT_INVALID;
}
void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) {
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) {
void Inventory::dumpItemCollection(const std::map<int16, ItemInst*> &collection) {
iter_inst it;
iter_contents itb;
ItemInst* inst = nullptr;
@ -1084,7 +1062,7 @@ void Inventory::dumpItemCollection(const map<int16, ItemInst*> &collection) {
if(!inst || !inst->GetItem())
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());
std::cout << slot << std::endl;
@ -1125,7 +1103,7 @@ void Inventory::dumpEntireInventory() {
}
// Internal Method: Retrieves item within an inventory bucket
ItemInst* Inventory::_GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const
ItemInst* Inventory::_GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const
{
iter_inst it = bucket.find(slot_id);
if (it != bucket.end()) {
@ -1193,7 +1171,7 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
}
// Internal Method: Checks an inventory bucket for a particular item
int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
int16 Inventory::_HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
{
iter_inst it;
iter_contents itb;
@ -1283,7 +1261,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
}
// Internal Method: Checks an inventory bucket for a particular item
int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity)
int16 Inventory::_HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity)
{
iter_inst it;
iter_contents itb;
@ -1351,7 +1329,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
return SLOT_INVALID;
}
int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup)
int16 Inventory::_HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup)
{
iter_inst it;
iter_contents itb;

View File

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

View File

@ -32,8 +32,6 @@
#include "../common/timer.h"
#include "../common/seperator.h"
using namespace std;
#ifdef _WINDOWS
#include <windows.h>
@ -79,10 +77,10 @@ void CoutTimestamp(bool ms) {
struct timeval read_time;
gettimeofday(&read_time,0);
cout << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec;
std::cout << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec;
if (ms)
cout << "." << setw(3) << setfill('0') << (read_time.tv_usec / 1000);
cout << " GMT";
std::cout << "." << std::setw(3) << std::setfill('0') << (read_time.tv_usec / 1000);
std::cout << " GMT";
}

View File

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

View File

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

View File

@ -57,14 +57,14 @@ void StructStrategy::PassDecoder(EQApplicationPacket *p) {
//effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory {
static map<EmuOpcode, const StructStrategy *> strategies;
static std::map<EmuOpcode, const StructStrategy *> strategies;
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
strategies[first_opcode] = structs;
}
const StructStrategy *FindPatch(EmuOpcode first_opcode) {
map<EmuOpcode, const StructStrategy *>::const_iterator res;
std::map<EmuOpcode, const StructStrategy *>::const_iterator res;
res = strategies.find(first_opcode);
if(res == strategies.end())
return(nullptr);

View File

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

View File

@ -23,7 +23,7 @@ XMLParser::XMLParser() {
}
bool XMLParser::ParseFile(const char *file, const char *root_ele) {
map<string,ElementHandler>::iterator handler;
std::map<std::string,ElementHandler>::iterator handler;
TiXmlDocument doc( file );
if(!doc.LoadFile()) {
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());

View File

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

View File

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

View File

@ -35,7 +35,6 @@
#include <string>
#include <vector>
#include <map>
using namespace std;
//atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10)
@ -265,5 +264,5 @@ private:
uint32 varcache_lastupdate;
};
bool FetchRowMap(MYSQL_RES *result, map<string,string> &rowmap);
bool FetchRowMap(MYSQL_RES *result, std::map<std::string,std::string> &rowmap);
#endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,17 +5,15 @@
#include <string>
#include <map>
using namespace std;
#define ITEMFIELDCOUNT 116
void Unprotect(string &s, char what);
void Unprotect(std::string &s, char what);
void Protect(string &s, char what);
void Protect(std::string &s, char what);
bool ItemParse(const char *data, int length, map<int,map<int,string> > &items, int id_pos, int name_pos, int max_field, int level=0);
bool ItemParse(const char *data, int length, std::map<int,std::map<int,std::string> > &items, int id_pos, int name_pos, int max_field, int level=0);
int Tokenize(string s, map<int,string> & tokens, char delim='|');
int Tokenize(std::string s, std::map<int,std::string> & tokens, char delim='|');
void LoadItemDBFieldNames();
@ -30,13 +28,13 @@ void decode_chunk(char *in, char *out);
int print_stacktrace();
#endif
void dump_message_column(unsigned char *buffer, unsigned long length, string leader="", FILE *to = stdout);
string string_from_time(string pattern, time_t now=0);
string timestamp(time_t now=0);
string long2ip(unsigned long ip);
string pop_arg(string &s, string seps, bool obey_quotes);
void dump_message_column(unsigned char *buffer, unsigned long length, std::string leader="", FILE *to = stdout);
std::string string_from_time(std::string pattern, time_t now=0);
std::string timestamp(time_t now=0);
std::string long2ip(unsigned long ip);
std::string pop_arg(std::string &s, std::string seps, bool obey_quotes);
int EQsprintf(char *buffer, const char *pattern, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *arg6, const char *arg7, const char *arg8, const char *arg9);
string generate_key(int length);
std::string generate_key(int length);
void build_hex_line(const char *buffer, unsigned long length, unsigned long offset, char *out_buffer, unsigned char padding=4);
void print_hex(const char *buffer, unsigned long length);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,7 +48,7 @@ public:
void SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message);
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
void SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message);
bool GetCommandSettings(map<string,uint8> &commands);
bool GetCommandSettings(std::map<std::string,uint8> &commands);
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
/*
@ -65,7 +65,7 @@ public:
bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin);
string GetBook(const char *txtfile);
std::string GetBook(const char *txtfile);
/*
* Item Methods

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@
#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()),
m_name(name),
m_config(config),
@ -98,7 +98,7 @@ void WorldServer::Process() {
break;
}
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()) {
_log(LAUNCHER__ERROR, "World told us to restart zone %s, but it is not running.", lzr->short_name);
} else {
@ -108,7 +108,7 @@ void WorldServer::Process() {
break;
}
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()) {
_log(LAUNCHER__ERROR, "World told us to stop zone %s, but it is not running.", lzr->short_name);
} else {

View File

@ -25,19 +25,19 @@ extern ErrorLog *server_log;
* First gets the map from the 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())
{
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())
{
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");
if(input)
{
list<string> tokens;
std::list<std::string> tokens;
Tokenize(input, tokens);
char mode = 0;
string title, param, arg;
list<string>::iterator iter = tokens.begin();
std::string title, param, arg;
std::list<std::string>::iterator iter = tokens.begin();
while(iter != tokens.end())
{
if((*iter).compare("[") == 0)
@ -114,7 +114,7 @@ void Config::Parse(const char *file_name)
{
arg = (*iter);
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())
{
map_iter->second[param] = arg;
@ -122,7 +122,7 @@ void Config::Parse(const char *file_name)
}
else
{
map<string, string> var_map;
std::map<std::string, std::string> var_map;
var_map[param] = arg;
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.
* 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);
string lexeme;
std::string lexeme;
while(c != EOF)
{

View File

@ -23,8 +23,6 @@
#include <map>
#include <string>
using namespace std;
/**
* 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.
@ -44,10 +42,10 @@ public:
/**
* Gets a variable if it exists.
*/
string GetVariable(string title, string parameter);
std::string GetVariable(std::string title, std::string parameter);
protected:
map<string, map<string, string> > vars;
std::map<std::string, std::map<std::string, std::string> > vars;
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).
* 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

View File

@ -20,8 +20,6 @@
#include <string>
using namespace std;
#define EQEMU_MYSQL_ENABLED
//#define EQEMU_POSTGRESQL_ENABLED
@ -44,37 +42,37 @@ public:
* Needed for client login procedure.
* 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.
* Needed for world login procedure.
* 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,
unsigned int &trusted, string &list_desc, string &account, string &password) { return false; }
virtual bool GetWorldRegistration(std::string long_name, std::string short_name, unsigned int &id, std::string &desc, unsigned int &list_id,
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
*/
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
*/
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
*/
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
*/
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:
string user, pass, host, port, name;
std::string user, pass, host, port, name;
};
#endif

View File

@ -26,8 +26,6 @@
#include <stdlib.h>
#include <mysql.h>
using namespace std;
/**
* Mysql Database class
*/
@ -42,7 +40,7 @@ public:
/**
* 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.
@ -59,37 +57,37 @@ public:
* Needed for client login procedure.
* 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.
* Needed for world login procedure.
* 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,
unsigned int &trusted, string &list_desc, string &account, string &password);
virtual bool GetWorldRegistration(std::string long_name, std::string short_name, unsigned int &id, std::string &desc, unsigned int &list_id,
unsigned int &trusted, std::string &list_desc, std::string &account, std::string &password);
/**
* 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
*/
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
*/
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
*/
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:
string user, pass, host, port, name;
std::string user, pass, host, port, name;
MYSQL *db;
};

View File

@ -22,8 +22,6 @@
#include <windows.h>
#include <string>
using namespace std;
typedef char*(*DLLFUNC_DecryptUsernamePassword)(const char*, unsigned int, int);
typedef char*(*DLLFUNC_Encrypt)(const char*, unsigned int, unsigned int&);
typedef void(*DLLFUNC_HeapDelete)(char*);
@ -54,7 +52,7 @@ public:
* Loads the plugin.
* 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.

View File

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

View File

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

View File

@ -100,52 +100,52 @@ public:
/**
* 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.
*/
inline string GetLocalNetwork() const { return local_network; }
inline std::string GetLocalNetwork() const { return local_network; }
/**
* 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.
*/
inline string GetAccountTable() const { return account_table; }
inline std::string GetAccountTable() const { return 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.
*/
inline string GetWorldRegistrationTable() const { return world_registration_table; }
inline std::string GetWorldRegistrationTable() const { return world_registration_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.
*/
inline string GetWorldAdminRegistrationTable() const { return world_admin_registration_table; }
inline std::string GetWorldAdminRegistrationTable() const { return world_admin_registration_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.
*/
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.
@ -165,11 +165,11 @@ private:
bool dump_out_packets;
bool reject_duplicate_servers;
int encryption_mode;
string local_network;
string account_table;
string world_registration_table;
string world_admin_registration_table;
string world_server_type_table;
std::string local_network;
std::string account_table;
std::string world_registration_table;
std::string world_admin_registration_table;
std::string world_server_type_table;
};
#endif

View File

@ -28,8 +28,6 @@
#include "Client.h"
#include <list>
using namespace std;
/**
* 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.
*/
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.
*/
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:
/**
@ -84,7 +82,7 @@ private:
WorldServer* GetServerByAddress(unsigned int address);
EmuTCPServer* tcps;
list<WorldServer*> world_servers;
std::list<WorldServer*> world_servers;
};
#endif

View File

@ -26,8 +26,6 @@
#include "../common/packet_dump.h"
#include <string>
using namespace std;
/**
* World server class, controls the connected server processing.
*/
@ -78,12 +76,12 @@ public:
/**
* 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.
*/
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.
@ -93,12 +91,12 @@ public:
/**
* 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.
*/
string GetRemoteIP() const { return remote_ip; }
std::string GetRemoteIP() const { return remote_ip; }
/**
* 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.
*/
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:
@ -144,15 +142,15 @@ private:
unsigned int runtime_id;
unsigned int server_list_id;
unsigned int server_type;
string desc;
string long_name;
string short_name;
string account_name;
string account_password;
string remote_ip;
string local_ip;
string protocol;
string version;
std::string desc;
std::string long_name;
std::string short_name;
std::string account_name;
std::string account_password;
std::string remote_ip;
std::string local_ip;
std::string protocol;
std::string version;
bool authorized;
bool logged_in;
bool trusted;

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@
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));
}

View File

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

View File

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

View File

@ -26,7 +26,7 @@
extern Database database;
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) {
Name = inName;
@ -56,7 +56,7 @@ ChatChannel::~ChatChannel() {
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);
@ -65,9 +65,9 @@ ChatChannel* ChatChannelList::CreateChannel(string Name, string Owner, string Pa
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);
@ -103,7 +103,7 @@ void ChatChannelList::SendAllChannels(Client *c) {
iterator.Reset();
string Message;
std::string Message;
char CountString[10];
@ -200,7 +200,7 @@ int ChatChannel::MemberCount(int Status) {
return Count;
}
void ChatChannel::SetPassword(string inPassword) {
void ChatChannel::SetPassword(std::string 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;
@ -312,7 +312,7 @@ void ChatChannel::SendOPList(Client *c) {
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++)
c->GeneralChannelMessage((*Iterator));
@ -327,7 +327,7 @@ void ChatChannel::SendChannelMembers(Client *c) {
sprintf(CountString, "(%i)", MemberCount(c->GetAccountStatus()));
string Message = "Channel " + GetName();
std::string Message = "Channel " + GetName();
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;
@ -448,7 +448,7 @@ bool ChatChannel::IsClientInChannel(Client *c) {
return false;
}
ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c) {
ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client *c) {
if(!c) return nullptr;
@ -459,11 +459,11 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
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);
else {
NormalisedName = CapitaliseName(ChannelName.substr(0, Colon));
@ -487,7 +487,7 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
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);
@ -519,11 +519,11 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
return nullptr;
}
ChatChannel *ChatChannelList::RemoveClientFromChannel(string inChannelName, Client *c) {
ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName, Client *c) {
if(!c) return nullptr;
string ChannelName = inChannelName;
std::string ChannelName = inChannelName;
if((inChannelName.length() > 0) && isdigit(ChannelName[0]))
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)) {
@ -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++) {
@ -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++) {
@ -606,7 +606,7 @@ bool ChatChannel::IsInvitee(string Invitee) {
return false;
}
void ChatChannel::AddModerator(string Moderator) {
void ChatChannel::AddModerator(std::string 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++) {
@ -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++) {
@ -647,7 +647,7 @@ bool ChatChannel::IsModerator(string Moderator) {
return false;
}
void ChatChannel::AddVoice(string inVoiced) {
void ChatChannel::AddVoice(std::string 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++) {
@ -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++) {
@ -688,9 +688,9 @@ bool ChatChannel::HasVoice(string inVoiced) {
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++) {

View File

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

View File

@ -33,11 +33,9 @@
#include <cstdlib>
#include <algorithm>
using namespace std;
extern Database database;
extern string WorldShortName;
extern string GetMailPrefix();
extern std::string WorldShortName;
extern std::string GetMailPrefix();
extern ChatChannelList *ChannelList;
extern Clientlist *CL;
extern uint32 ChatMessagesSent;
@ -77,7 +75,7 @@ void Client::SendUptime() {
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:
//
@ -111,19 +109,19 @@ vector<string> ParseRecipients(string RecipientString) {
//
// 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;
while(CurrentPos != string::npos) {
while(CurrentPos != std::string::npos) {
Comma = RecipientString.find_first_of(",", CurrentPos);
if(Comma == string::npos) {
if(Comma == std::string::npos) {
RecipientList.push_back(RecipientString.substr(CurrentPos));
@ -134,7 +132,7 @@ vector<string> ParseRecipients(string RecipientString) {
CurrentPos = Comma + 2;
}
vector<string>::iterator Iterator;
std::vector<std::string>::iterator Iterator;
Iterator = RecipientList.begin();
@ -152,27 +150,27 @@ vector<string> ParseRecipients(string RecipientString) {
FirstLT = (*Iterator).find_first_of("<");
if(FirstLT != string::npos) {
if(FirstLT != std::string::npos) {
LastGT = (*Iterator).find_last_of(">");
if(LastGT != string::npos) {
if(LastGT != std::string::npos) {
(*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);
CurrentPos = 0;
while(CurrentPos != string::npos) {
while(CurrentPos != std::string::npos) {
Space = Recips.find_first_of(" ", CurrentPos);
if(Space == string::npos) {
if(Space == std::string::npos) {
RecipientList.push_back(Secret + Recips.substr(CurrentPos));
@ -207,7 +205,7 @@ vector<string> ParseRecipients(string RecipientString) {
LastPeriod = (*Iterator).find_last_of(".");
if(LastPeriod != string::npos) {
if(LastPeriod != std::string::npos) {
(*Iterator) = (*Iterator).substr(LastPeriod + 1);
@ -227,7 +225,7 @@ vector<string> ParseRecipients(string RecipientString) {
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());
@ -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());
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);
// 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) == "\"") {
@ -274,7 +272,7 @@ static void ProcessMailTo(Client *c, string MailMessage) {
SubjectEnd++;
}
string Body = MailMessage.substr(SubjectEnd);
std::string Body = MailMessage.substr(SubjectEnd);
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;
@ -376,13 +374,13 @@ static void ProcessSetMessageStatus(string SetMessageCommand) {
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());
@ -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());
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());
c->GeneralChannelMessage("Ignore list modified");
@ -442,11 +440,11 @@ static void ProcessCommandIgnore(Client *c, string Ignoree) {
// 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;
else
CharacterName = Ignoree.substr(LastPeriod + 1);
@ -554,7 +552,7 @@ void Clientlist::CheckForStaleConnections(Client *c) {
if(!c) return;
list<Client*>::iterator Iterator;
std::list<Client*>::iterator Iterator;
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
@ -596,7 +594,7 @@ void Clientlist::Process() {
ClientChatConnections.push_back(c);
}
list<Client*>::iterator Iterator;
std::list<Client*>::iterator Iterator;
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
@ -657,13 +655,13 @@ void Clientlist::Process() {
VARSTRUCT_DECODE_STRING(Key, PacketBuffer);
string MailBoxString = MailBox, CharacterName;
std::string MailBoxString = MailBox, CharacterName;
// 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;
else
CharacterName = MailBoxString.substr(LastPeriod + 1);
@ -695,7 +693,7 @@ void Clientlist::Process() {
case OP_Mail: {
string CommandString = (const char*)app->pBuffer;
std::string CommandString = (const char*)app->pBuffer;
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)
@ -756,17 +754,17 @@ void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
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);
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);
}
else
@ -867,7 +865,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
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()));
break;
}
@ -893,7 +891,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
void Clientlist::CloseAllConnections() {
list<Client*>::iterator Iterator;
std::list<Client*>::iterator Iterator;
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
@ -921,7 +919,7 @@ void Client::SendMailBoxes() {
int PacketLength = 10;
string s;
std::string s;
for(int i = 0; i < Count; i++) {
@ -951,9 +949,9 @@ void Client::SendMailBoxes() {
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++) {
@ -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)
{
@ -1019,9 +1017,9 @@ void Client::JoinChannels(string ChannelNameList) {
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) {
@ -1030,9 +1028,9 @@ void Client::JoinChannels(string ChannelNameList) {
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);
@ -1054,7 +1052,7 @@ void Client::JoinChannels(string ChannelNameList) {
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
}
string JoinedChannelsList, ChannelMessage;
std::string JoinedChannelsList, ChannelMessage;
ChannelMessage = "Channels: ";
@ -1115,17 +1113,17 @@ void Client::JoinChannels(string ChannelNameList) {
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());
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);
@ -1143,7 +1141,7 @@ void Client::LeaveChannels(string ChannelNameList) {
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
}
string JoinedChannelsList, ChannelMessage;
std::string JoinedChannelsList, ChannelMessage;
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) {
@ -1229,7 +1227,7 @@ void Client::ProcessChannelList(string Input) {
return;
}
string ChannelName = Input;
std::string ChannelName = Input;
if(isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1246,7 +1244,7 @@ void Client::ProcessChannelList(string Input) {
void Client::SendChannelList() {
string ChannelMessage;
std::string ChannelMessage;
ChannelMessage = "Channels: ";
@ -1287,15 +1285,15 @@ void Client::SendChannelList() {
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;
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());
@ -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;
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;
string FQSenderName = WorldShortName + "." + Sender->GetName();
std::string FQSenderName = WorldShortName + "." + Sender->GetName();
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);
}
void Client::ToggleAnnounce(string State)
void Client::ToggleAnnounce(std::string State)
{
if(State == "")
Announce = !Announce;
@ -1540,7 +1538,7 @@ void Client::ToggleAnnounce(string State)
else
Announce = false;
string Message = "Announcing now ";
std::string Message = "Announcing now ";
if(Announce)
Message += "on";
@ -1594,13 +1592,13 @@ void Client::GeneralChannelMessage(const char *Characters) {
if(!Characters) return;
string Message = Characters;
std::string Message = Characters;
GeneralChannelMessage(Message);
}
void Client::GeneralChannelMessage(string Message) {
void Client::GeneralChannelMessage(std::string Message) {
EQApplicationPacket *outapp = new EQApplicationPacket(OP_ChannelMessage, Message.length() + 3);
char *PacketBuffer = (char *)outapp->pBuffer;
@ -1614,40 +1612,40 @@ void Client::GeneralChannelMessage(string Message) {
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) {
string Message = "Incorrect syntax: /chat password <new password> <channel name>";
if(PasswordStart == std::string::npos) {
std::string Message = "Incorrect syntax: /chat password <new password> <channel name>";
GeneralChannelMessage(Message);
return;
}
string::size_type Space = ChannelPassword.find_first_of(" ", PasswordStart);
std::string::size_type Space = ChannelPassword.find_first_of(" ", PasswordStart);
if(Space == string::npos) {
string Message = "Incorrect syntax: /chat password <new password> <channel name>";
if(Space == std::string::npos) {
std::string Message = "Incorrect syntax: /chat password <new password> <channel name>";
GeneralChannelMessage(Message);
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) {
string Message = "Incorrect syntax: /chat password <new password> <channel name>";
if(ChannelStart == std::string::npos) {
std::string Message = "Incorrect syntax: /chat password <new password> <channel name>";
GeneralChannelMessage(Message);
return;
}
string ChannelName = ChannelPassword.substr(ChannelStart);
std::string ChannelName = ChannelPassword.substr(ChannelStart);
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
string Message;
std::string Message;
if(!strcasecmp(Password.c_str(), "remove")) {
Password.clear();
@ -1661,13 +1659,13 @@ void Client::SetChannelPassword(string ChannelPassword) {
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
if(!RequiredChannel) {
string Message = "Channel not found.";
std::string Message = "Channel not found.";
GeneralChannelMessage(Message);
return;
}
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);
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) {
string Message = "Incorrect syntax: /chat setowner <player> <channel>";
if(PlayerStart == std::string::npos) {
std::string Message = "Incorrect syntax: /chat setowner <player> <channel>";
GeneralChannelMessage(Message);
return;
}
string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
if(Space == string::npos) {
string Message = "Incorrect syntax: /chat setowner <player> <channel>";
if(Space == std::string::npos) {
std::string Message = "Incorrect syntax: /chat setowner <player> <channel>";
GeneralChannelMessage(Message);
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) {
string Message = "Incorrect syntax: /chat setowner <player> <channel>";
if(ChannelStart == std::string::npos) {
std::string Message = "Incorrect syntax: /chat setowner <player> <channel>";
GeneralChannelMessage(Message);
return;
}
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1721,7 +1719,7 @@ void Client::SetChannelOwner(string CommandString) {
}
if(!RequiredChannel->IsOwner(GetName()) && !IsChannelAdmin()) {
string Message = "You do not own channel " + ChannelName;
std::string Message = "You do not own channel " + ChannelName;
GeneralChannelMessage(Message);
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) {
string Message = "Incorrect syntax: /chat oplist <channel>";
if(ChannelStart == std::string::npos) {
std::string Message = "Incorrect syntax: /chat oplist <channel>";
GeneralChannelMessage(Message);
return;
}
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1766,35 +1764,35 @@ void Client::OPList(string CommandString) {
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) {
string Message = "Incorrect syntax: /chat invite <player> <channel>";
if(PlayerStart == std::string::npos) {
std::string Message = "Incorrect syntax: /chat invite <player> <channel>";
GeneralChannelMessage(Message);
return;
}
string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
if(Space == string::npos) {
string Message = "Incorrect syntax: /chat invite <player> <channel>";
if(Space == std::string::npos) {
std::string Message = "Incorrect syntax: /chat invite <player> <channel>";
GeneralChannelMessage(Message);
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) {
string Message = "Incorrect syntax: /chat invite <player> <channel>";
if(ChannelStart == std::string::npos) {
std::string Message = "Incorrect syntax: /chat invite <player> <channel>";
GeneralChannelMessage(Message);
return;
}
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
@ -1831,7 +1829,7 @@ void Client::ChannelInvite(string CommandString) {
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);
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);
return;
}
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
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>");
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>");
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>");
return;
}
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
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>");
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>");
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>");
return;
}
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
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>");
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>");
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>");
return;
}
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
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))
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,
// 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
// mail window.
//
list<Client*>::iterator Iterator;
std::list<Client*>::iterator Iterator;
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
@ -2262,7 +2260,7 @@ Client *Clientlist::IsCharacterOnline(string CharacterName) {
return nullptr;
}
int Client::GetMailBoxNumber(string CharacterName) {
int Client::GetMailBoxNumber(std::string CharacterName) {
for(unsigned int i = 0; i < Characters.size(); i++)
if(Characters[i].Name == CharacterName)
@ -2271,7 +2269,7 @@ int Client::GetMailBoxNumber(string CharacterName) {
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];
@ -2328,13 +2326,13 @@ void Client::ChangeMailBox(int NewMailBox) {
void Client::SendFriends() {
vector<string> Friends, Ignorees;
std::vector<std::string> Friends, Ignorees;
database.GetFriendsAndIgnore(GetCharID(), Friends, Ignorees);
EQApplicationPacket *outapp;
vector<string>::iterator Iterator;
std::vector<std::string>::iterator Iterator;
Iterator = Friends.begin();
@ -2361,7 +2359,7 @@ void Client::SendFriends() {
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);
@ -2381,7 +2379,7 @@ void Client::SendFriends() {
}
}
string Client::MailBoxName() {
std::string Client::MailBoxName() {
if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1)))
{

View File

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

View File

@ -20,7 +20,6 @@
#include "../common/debug.h"
#include <iostream>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -49,7 +48,7 @@ using namespace std;
#include "chatchannel.h"
extern Clientlist *CL;
extern string GetMailPrefix();
extern std::string GetMailPrefix();
extern ChatChannelList *ChannelList;
extern uint32 MailMessagesSent;
@ -191,7 +190,7 @@ int Database::FindAccount(const char *CharacterName, Client *c) {
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* query = 0;
@ -329,9 +328,9 @@ bool Database::LoadChatChannels() {
while((row = mysql_fetch_row(result))) {
string ChannelName = row[0];
string ChannelOwner = row[1];
string ChannelPassword = row[2];
std::string ChannelName = row[0];
std::string ChannelOwner = row[1];
std::string ChannelPassword = row[2];
ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, atoi(row[3]));
}
@ -341,7 +340,7 @@ bool Database::LoadChatChannels() {
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());
@ -358,7 +357,7 @@ void Database::SetChannelPassword(string ChannelName, string Password) {
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());
@ -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;
string CharacterName;
std::string CharacterName;
//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;
else
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);
if(c) {
string FQN = GetMailPrefix() + From;
std::string FQN = GetMailPrefix() + From;
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')";
@ -710,7 +709,7 @@ void Database::AddFriendOrIgnore(int CharID, int Type, string Name) {
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'";
@ -727,7 +726,7 @@ void Database::RemoveFriendOrIgnore(int CharID, int Type, string Name) {
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* query = 0;
@ -749,7 +748,7 @@ void Database::GetFriendsAndIgnore(int CharID, vector<string> &Friends, vector<s
while((row = mysql_fetch_row(result))) {
string Name = row[1];
std::string Name = row[1];
if(atoi(row[0]) == 0)
{

View File

@ -31,7 +31,6 @@
#include <string>
#include <vector>
#include <map>
using namespace std;
//atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10)
@ -45,20 +44,20 @@ public:
int FindAccount(const char *CharacterName, Client *c);
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 LoadChatChannels();
void GetAccountStatus(Client *c);
void SetChannelPassword(string ChannelName, string Password);
void SetChannelOwner(string ChannelName, string Owner);
void SetChannelPassword(std::string ChannelName, std::string Password);
void SetChannelOwner(std::string ChannelName, std::string Owner);
void SendHeaders(Client *c);
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 ExpireMail();
void AddFriendOrIgnore(int CharID, int Type, string Name);
void RemoveFriendOrIgnore(int CharID, int Type, string Name);
void GetFriendsAndIgnore(int CharID, vector<string> &Friends, vector<string> &Ignorees);
void AddFriendOrIgnore(int CharID, int Type, std::string Name);
void RemoveFriendOrIgnore(int CharID, int Type, std::string Name);
void GetFriendsAndIgnore(int CharID, std::vector<std::string> &Friends, std::vector<std::string> &Ignorees);
protected:

View File

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

View File

@ -22,7 +22,7 @@
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));
}

View File

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

View File

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

View File

@ -50,7 +50,7 @@ Adventure::~Adventure()
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))
{
@ -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())
{
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())
{
if(character_name.compare((*iter)) == 0)
@ -210,7 +210,7 @@ void Adventure::SetStatus(AdventureStatus new_status)
return;
}
list<string>::iterator iter = players.begin();
std::list<std::string>::iterator iter = players.begin();
while(iter != players.end())
{
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;
sms->type = type;
strcpy(sms->message, msg);
list<string>::iterator iter = players.begin();
std::list<std::string>::iterator iter = players.begin();
while(iter != players.end())
{
ClientListEntry *current = client_list.FindCharacter((*iter).c_str());
@ -278,7 +278,7 @@ void Adventure::IncrementAssassinationCount()
void Adventure::Finished(AdventureWinStatus ws)
{
list<string>::iterator iter = players.begin();
std::list<std::string>::iterator iter = players.begin();
while(iter != players.end())
{
ClientListEntry *current = client_list.FindCharacter((*iter).c_str());
@ -372,8 +372,8 @@ void Adventure::MoveCorpsesToGraveyard()
return;
}
list<uint32> dbid_list;
list<uint32> charid_list;
std::list<uint32> dbid_list;
std::list<uint32> charid_list;
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
MYSQL_RES *result;
@ -395,7 +395,7 @@ void Adventure::MoveCorpsesToGraveyard()
safe_delete_array(query);
}
list<uint32>::iterator iter = dbid_list.begin();
std::list<uint32>::iterator iter = dbid_list.begin();
while(iter != dbid_list.end())
{
float x = GetTemplate()->graveyard_x + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
@ -415,7 +415,7 @@ void Adventure::MoveCorpsesToGraveyard()
}
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())
{
ServerPacket* pack = new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct));

View File

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

View File

@ -33,7 +33,7 @@ void AdventureManager::Process()
{
if(process_timer->Check())
{
list<Adventure*>::iterator iter = adventure_list.begin();
std::list<Adventure*>::iterator iter = adventure_list.begin();
while(iter != adventure_list.end())
{
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.
*/
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())
{
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
* 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())
{
Adventure* current = (*iter);
@ -103,7 +103,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
ServerAdventureRequestDeny_Struct *deny = (ServerAdventureRequestDeny_Struct*)pack->pBuffer;
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.";
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.
* ie. the ones that would cause overlap issues for new adventures with the old unexpired adventures.
*/
list<AdventureZones> excluded_zones;
list<AdventureZoneIn> excluded_zone_ins;
std::list<AdventureZones> excluded_zones;
std::list<AdventureZoneIn> excluded_zone_ins;
for(int i = 0; i < sar->member_count; ++i)
{
int finished_adventures_count;
@ -148,12 +148,12 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
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.
* 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())
{
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;
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 << " but the level range calculated was " << (max_level - min_level) << ".";
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
*/
list<AdventureZones>::iterator ez_iter = excluded_zones.begin();
std::list<AdventureZones>::iterator ez_iter = excluded_zones.begin();
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())
{
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++;
}
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())
{
list<AdventureTemplate*>::iterator ea_iter = eligible_adventures.begin();
std::list<AdventureTemplate*>::iterator ea_iter = eligible_adventures.begin();
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)
@ -448,8 +448,8 @@ void AdventureManager::TryAdventureCreate(const char *data)
void AdventureManager::GetAdventureData(Adventure *adv)
{
list<string> player_list = adv->GetPlayers();
list<string>::iterator iter = player_list.begin();
std::list<std::string> player_list = adv->GetPlayers();
std::list<std::string>::iterator iter = player_list.begin();
while(iter != player_list.end())
{
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())
{
if(((*iter).zone.compare(zone_name) == 0) && ((*iter).version == version))
@ -538,9 +538,9 @@ bool AdventureManager::IsInExcludedZoneList(list<AdventureZones> excluded_zones,
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())
{
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;
count = 0;
list<Adventure*>::iterator iter = adventure_list.begin();
std::list<Adventure*>::iterator iter = adventure_list.begin();
while(iter != adventure_list.end())
{
if((*iter)->PlayerExists(player))
@ -590,7 +590,7 @@ Adventure **AdventureManager::GetFinishedAdventures(const char *player, int &cou
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())
{
if((*iter)->PlayerExists(player) && (*iter)->IsActive())
@ -604,13 +604,13 @@ Adventure *AdventureManager::GetActiveAdventure(const char *player)
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())
{
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())
{
if((*l_iter)->id == id)
@ -624,7 +624,7 @@ AdventureTemplate *AdventureManager::GetAdventureTemplate(int theme, 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())
{
return nullptr;
@ -713,7 +713,7 @@ bool AdventureManager::LoadAdventureEntries()
int template_id = atoi(row[1]);
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())
{
continue;
@ -723,8 +723,8 @@ bool AdventureManager::LoadAdventureEntries()
tid = adventure_templates[template_id];
}
list<AdventureTemplate*> temp;
map<uint32, list<AdventureTemplate*> >::iterator iter = adventure_entries.find(id);
std::list<AdventureTemplate*> temp;
std::map<uint32, std::list<AdventureTemplate*> >::iterator iter = adventure_entries.find(id);
if(iter == adventure_entries.end())
{
temp.push_back(tid);
@ -752,7 +752,7 @@ bool AdventureManager::LoadAdventureEntries()
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())
{
const AdventureTemplate *t = (*iter)->GetTemplate();
@ -842,7 +842,7 @@ void AdventureManager::LeaveAdventure(const char *name)
void AdventureManager::IncrementCount(uint16 instance_id)
{
list<Adventure*>::iterator iter = adventure_list.begin();
std::list<Adventure*>::iterator iter = adventure_list.begin();
Adventure *current = nullptr;
while(iter != adventure_list.end())
{
@ -857,8 +857,8 @@ void AdventureManager::IncrementCount(uint16 instance_id)
if(current)
{
current->IncrementCount();
list<string> slist = current->GetPlayers();
list<string>::iterator siter = slist.begin();
std::list<std::string> slist = current->GetPlayers();
std::list<std::string>::iterator siter = slist.begin();
ServerPacket *pack = new ServerPacket(ServerOP_AdventureCountUpdate, sizeof(ServerAdventureCountUpdate_Struct));
ServerAdventureCountUpdate_Struct *ac = (ServerAdventureCountUpdate_Struct*)pack->pBuffer;
ac->count = current->GetCount();
@ -882,7 +882,7 @@ void AdventureManager::IncrementCount(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;
while(iter != adventure_list.end())
{
@ -903,7 +903,7 @@ void AdventureManager::IncrementAssassinationCount(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;
while(iter != adventure_list.end())
{
@ -1283,7 +1283,7 @@ void AdventureManager::DoLeaderboardRequestWins(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1350,7 +1350,7 @@ void AdventureManager::DoLeaderboardRequestPercentage(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1417,7 +1417,7 @@ void AdventureManager::DoLeaderboardRequestWinsGuk(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1484,7 +1484,7 @@ void AdventureManager::DoLeaderboardRequestPercentageGuk(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1551,7 +1551,7 @@ void AdventureManager::DoLeaderboardRequestWinsMir(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1618,7 +1618,7 @@ void AdventureManager::DoLeaderboardRequestPercentageMir(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1685,7 +1685,7 @@ void AdventureManager::DoLeaderboardRequestWinsMmc(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1752,7 +1752,7 @@ void AdventureManager::DoLeaderboardRequestPercentageMmc(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1819,7 +1819,7 @@ void AdventureManager::DoLeaderboardRequestWinsRuj(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1886,7 +1886,7 @@ void AdventureManager::DoLeaderboardRequestPercentageRuj(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -1953,7 +1953,7 @@ void AdventureManager::DoLeaderboardRequestWinsTak(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -2020,7 +2020,7 @@ void AdventureManager::DoLeaderboardRequestPercentageTak(const char* player)
int our_successes;
int our_failures;
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())
{
LeaderboardInfo li = (*iter);
@ -2076,7 +2076,7 @@ void AdventureManager::DoLeaderboardRequestPercentageTak(const char* player)
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())
{
if((*iter).name.compare(name) == 0)
@ -2116,13 +2116,13 @@ void AdventureManager::Save()
//disabled for now
return;
stringstream ss(stringstream::in | stringstream::out);
std::stringstream ss(std::stringstream::in | std::stringstream::out);
int number_of_elements = adventure_list.size();
ss.write((const char*)&number_of_elements, sizeof(int));
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())
{
int cur = (*a_iter)->GetCount();
@ -2143,11 +2143,11 @@ void AdventureManager::Save()
cur = (*a_iter)->GetRemainingTime();
ss.write((const char*)&cur, sizeof(int));
list<string> players = (*a_iter)->GetPlayers();
std::list<std::string> players = (*a_iter)->GetPlayers();
cur = players.size();
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())
{
ss.write((const char*)(*s_iter).c_str(), (*s_iter).size());
@ -2160,7 +2160,7 @@ void AdventureManager::Save()
number_of_elements = finished_list.size();
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())
{
ss.write((const char*)&(*f_iter).win, sizeof(bool));

View File

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

View File

@ -96,7 +96,7 @@ EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) {
}
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();
end = m_zones.end();
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());
vector<string> res;
std::vector<std::string> res;
if(ll == nullptr) {
//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();
end = m_zones.end();
for(; cur != end; cur++) {
@ -224,7 +224,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
return(false);
//check internal state
map<string, LauncherZone>::iterator res;
std::map<std::string, LauncherZone>::iterator res;
res = m_zones.find(short_name);
if(res == m_zones.end()) {
//not found.
@ -268,7 +268,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
//check internal state
map<string, LauncherZone>::iterator res;
std::map<std::string, LauncherZone>::iterator res;
res = m_zones.find(short_name);
if(res == m_zones.end()) {
//not found.
@ -341,8 +341,8 @@ int EQLConfig::GetDynamicCount() const {
return(m_dynamics);
}
map<string,string> EQLConfig::GetZoneDetails(Const_char *zone_ref) {
map<string,string> res;
std::map<std::string,std::string> EQLConfig::GetZoneDetails(Const_char *zone_ref) {
std::map<std::string,std::string> res;
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll == nullptr) {

View File

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

View File

@ -38,16 +38,12 @@
#include "LauncherLink.h"
#include "wguild_mgr.h"
#ifdef seed
#undef seed
#endif
#include <algorithm>
using namespace std;
extern ZSList zoneserver_list;
extern ClientList client_list;
extern uint32 numzones;
@ -115,13 +111,13 @@ int EQW::CountZones() {
}
//returns an array of zone_refs (opaque)
vector<string> EQW::ListBootedZones() {
vector<string> res;
std::vector<std::string> EQW::ListBootedZones() {
std::vector<std::string> res;
vector<uint32> zones;
std::vector<uint32> zones;
zoneserver_list.GetZoneIDList(zones);
vector<uint32>::iterator cur, end;
std::vector<uint32>::iterator cur, end;
cur = zones.begin();
end = zones.end();
for(; cur != end; cur++) {
@ -131,8 +127,8 @@ vector<string> EQW::ListBootedZones() {
return(res);
}
map<string,string> EQW::GetZoneDetails(Const_char *zone_ref) {
map<string,string> res;
std::map<std::string,std::string> EQW::GetZoneDetails(Const_char *zone_ref) {
std::map<std::string,std::string> res;
ZoneServer *zs = zoneserver_list.FindByID(atoi(zone_ref));
if(zs == nullptr) {
@ -165,13 +161,13 @@ int EQW::CountPlayers() {
}
//returns an array of character names in the zone (empty=all zones)
vector<string> EQW::ListPlayers(Const_char *zone_name) {
vector<string> res;
std::vector<std::string> EQW::ListPlayers(Const_char *zone_name) {
std::vector<std::string> res;
vector<ClientListEntry *> list;
std::vector<ClientListEntry *> list;
client_list.GetClients(zone_name, list);
vector<ClientListEntry *>::iterator cur, end;
std::vector<ClientListEntry *>::iterator cur, end;
cur = list.begin();
end = list.end();
for(; cur != end; cur++) {
@ -180,8 +176,8 @@ vector<string> EQW::ListPlayers(Const_char *zone_name) {
return(res);
}
map<string,string> EQW::GetPlayerDetails(Const_char *char_name) {
map<string,string> res;
std::map<std::string,std::string> EQW::GetPlayerDetails(Const_char *char_name) {
std::map<std::string,std::string> res;
ClientListEntry *cle = client_list.FindCharacter(char_name);
if(cle == nullptr) {
@ -213,7 +209,7 @@ int EQW::CountLaunchers(bool active_only) {
if(active_only)
return(launcher_list.GetLauncherCount());
vector<string> it(EQW::ListLaunchers());
std::vector<std::string> it(EQW::ListLaunchers());
return(it.size());
}
/*
@ -223,10 +219,10 @@ vector<string> EQW::ListActiveLaunchers() {
return(launchers);
}*/
vector<string> EQW::ListLaunchers() {
std::vector<std::string> EQW::ListLaunchers() {
// vector<string> list;
// database.GetLauncherList(list);
vector<string> launchers;
std::vector<std::string> launchers;
launcher_list.GetLauncherNameList(launchers);
return(launchers);
@ -405,8 +401,8 @@ int EQW::CountBugs() {
return 0;
}
vector<string> EQW::ListBugs(uint32 offset) {
vector<string> res;
std::vector<std::string> EQW::ListBugs(uint32 offset) {
std::vector<std::string> res;
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
MYSQL_RES *result;
@ -422,8 +418,8 @@ vector<string> EQW::ListBugs(uint32 offset) {
return res;
}
map<string,string> EQW::GetBugDetails(Const_char *id) {
map<string,string> res;
std::map<std::string,std::string> EQW::GetBugDetails(Const_char *id) {
std::map<std::string,std::string> res;
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
MYSQL_RES *result;
@ -447,7 +443,7 @@ map<string,string> EQW::GetBugDetails(Const_char *id) {
}
void EQW::ResolveBug(const char *id) {
vector<string> res;
std::vector<std::string> res;
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
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 <map>
#include "../common/types.h"
using namespace std;
class EQLConfig;
@ -46,16 +45,16 @@ public:
void LSReconnect();
int CountZones();
vector<string> ListBootedZones(); //returns an array of zone_refs (opaque)
map<string,string> GetZoneDetails(Const_char *zone_ref); //returns a hash ref of details
std::vector<std::string> ListBootedZones(); //returns an array of zone_refs (opaque)
std::map<std::string,std::string> GetZoneDetails(Const_char *zone_ref); //returns a hash ref of details
int CountPlayers();
vector<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::vector<std::string> ListPlayers(Const_char *zone_name = ""); //returns an array of player refs (opaque)
std::map<std::string,std::string> GetPlayerDetails(Const_char *player_ref); //returns a hash ref of details
int CountLaunchers(bool active_only);
// 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.
void CreateLauncher(Const_char *launcher_name, int dynamic_count);
// EQLConfig * FindLauncher(Const_char *zone_ref);
@ -74,8 +73,8 @@ public:
//bugs
int CountBugs();
vector<string> ListBugs(uint32 offset); //returns an array of zone_refs (opaque)
map<string,string> GetBugDetails(const char *id);
std::vector<std::string> ListBugs(uint32 offset); //returns an array of zone_refs (opaque)
std::map<std::string,std::string> GetBugDetails(const char *id);
void ResolveBug(const char *id);
void SendMessage(uint32 type, const char *msg);

View File

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

View File

@ -27,13 +27,10 @@
#include "../common/logsys.h"
#include "worlddb.h"
using namespace std;
#ifndef GvCV_set
#define GvCV_set(gv,cv) (GvCV(gv) = (cv))
#endif
XS(XS_EQWIO_PRINT);
//so embedded scripts can use xs extensions (ala 'use socket;')
@ -186,7 +183,7 @@ void EQWParser::DoInit() {
#ifdef EMBPERL_PLUGIN
_log(WORLD__PERL, "Loading worldui perl plugins.");
string err;
std::string err;
if(!eval_file("world", "worldui.pl", err)) {
_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));
}
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;
dSP; // initialize stack pointer
ENTER; // everything created after here
@ -254,7 +251,7 @@ bool EQWParser::dosub(const char * subname, const std::vector<std::string> &args
return(true);
}
bool EQWParser::eval(const char * code, string &error) {
bool EQWParser::eval(const char * code, std::string &error) {
std::vector<std::string> arg;
arg.push_back(code);
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);
}
string err;
std::string err;
if(!eval(code, err)) {
EQW::Singleton()->AppendOutput(err.c_str());
}

View File

@ -22,12 +22,10 @@
#include "../common/SocketLib/HttpdForm.h"
#include <cstdlib>
using namespace std;
HTTPRequest::HTTPRequest(EQWHTTPHandler *h, HttpdForm *form)
: m_handler(h)
{
string name, value;
std::string name, value;
if(form->getfirst(name, value)) {
m_values[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());
}
map<string,string> HTTPRequest::get_all() const {
std::map<std::string,std::string> HTTPRequest::get_all() const {
return m_values;
}

View File

@ -29,8 +29,6 @@
class HttpdForm;
class EQWHTTPHandler;
using namespace std;
class HTTPRequest {
public:
HTTPRequest(EQWHTTPHandler *h, HttpdForm *form);
@ -44,7 +42,7 @@ public:
//returns a database-safe string
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 SetResponseCode(Const_char *code);

View File

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

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