From 0fdfe025cbaf885e2e9deb50ac0723343e0c6771 Mon Sep 17 00:00:00 2001 From: Michael Cook Date: Wed, 22 May 2013 16:17:19 -0400 Subject: [PATCH] Remove 'using namespaces std' fixes #61 --- common/BasePacket.cpp | 4 +- common/EQDB.h | 2 +- common/EQDBRes.cpp | 8 +- common/EQDBRes.h | 4 +- common/EQEmuConfig.cpp | 82 ++++---- common/EQEmuConfig.h | 72 +++---- common/EQNetwork.cpp | 10 +- common/EQNetwork.h | 5 +- common/EQPacket.cpp | 14 +- common/EQPacket.h | 2 - common/EQStream.cpp | 24 +-- common/EQStream.h | 10 +- common/EQStreamFactory.cpp | 14 +- common/EQStreamFactory.h | 4 +- common/EQStreamIdent.cpp | 10 +- common/EQStreamLocator.h | 5 +- common/EmuTCPConnection.cpp | 48 +++-- common/Item.cpp | 17 +- common/Item.h | 35 ++-- common/MiscFunctions.cpp | 8 +- common/Mutex.cpp | 21 +-- common/ProcLauncher.cpp | 7 +- common/StructStrategy.cpp | 4 +- common/TCPConnection.cpp | 40 ++-- common/XMLParser.cpp | 2 +- common/XMLParser.h | 6 +- common/database.cpp | 107 +++++------ common/database.h | 3 +- common/dbasync.cpp | 25 ++- common/dbcore.cpp | 23 ++- common/debug.cpp | 5 +- common/eqtime.cpp | 21 +-- common/eqtime.h | 4 +- common/guild_base.cpp | 54 +++--- common/misc.cpp | 70 ++++--- common/misc.h | 22 +-- common/opcode_map.cpp | 8 +- common/opcodemgr.cpp | 9 +- common/opcodemgr.h | 5 +- common/packet_dump.cpp | 94 +++++----- common/packet_dump_file.cpp | 34 ++-- common/packet_dump_file.h | 1 - common/packet_functions.cpp | 14 +- common/packetfile.cpp | 3 - common/patches/Client62.cpp | 12 +- common/patches/RoF.cpp | 10 +- common/patches/SoD.cpp | 10 +- common/patches/SoF.cpp | 10 +- common/patches/Titanium.cpp | 12 +- common/patches/Underfoot.cpp | 10 +- common/perl_EQDBRes.cpp | 8 +- common/ptimer.cpp | 12 +- common/ptimer.h | 7 +- common/shareddb.cpp | 35 ++-- common/shareddb.h | 4 +- common/timeoutmgr.cpp | 4 +- common/timeoutmgr.h | 3 +- common/timer.cpp | 3 +- common/worldconn.cpp | 1 - eqlaunch/eqlaunch.cpp | 12 +- eqlaunch/worldserver.cpp | 6 +- loginserver/Config.cpp | 22 +-- loginserver/Config.h | 8 +- loginserver/Database.h | 18 +- loginserver/DatabaseMySQL.h | 20 +- loginserver/Encryption.h | 4 +- loginserver/ErrorLog.h | 2 - loginserver/Main.cpp | 7 +- loginserver/Options.h | 30 +-- loginserver/ServerManager.h | 8 +- loginserver/WorldServer.h | 30 ++- queryserv/database.cpp | 1 - queryserv/database.h | 1 - queryserv/queryserv.cpp | 2 +- queryserv/queryservconfig.cpp | 2 +- queryserv/queryservconfig.h | 2 +- queryserv/worldserver.cpp | 5 +- ucs/chatchannel.cpp | 68 +++---- ucs/chatchannel.h | 56 +++--- ucs/clientlist.cpp | 340 +++++++++++++++++----------------- ucs/clientlist.h | 54 +++--- ucs/database.cpp | 33 ++-- ucs/database.h | 15 +- ucs/ucs.cpp | 4 +- ucs/ucsconfig.cpp | 2 +- ucs/ucsconfig.h | 2 +- ucs/worldserver.cpp | 15 +- world/Adventure.cpp | 24 +-- world/Adventure.h | 18 +- world/AdventureManager.cpp | 102 +++++----- world/AdventureManager.h | 40 ++-- world/EQLConfig.cpp | 16 +- world/EQLConfig.h | 10 +- world/EQW.cpp | 44 ++--- world/EQW.h | 15 +- world/EQWHTTPHandler.cpp | 38 ++-- world/EQWParser.cpp | 11 +- world/HTTPRequest.cpp | 6 +- world/HTTPRequest.h | 4 +- world/LauncherLink.cpp | 2 - world/LauncherList.cpp | 38 ++-- world/LoginServer.cpp | 2 - world/LoginServerList.cpp | 2 - world/WorldConfig.cpp | 2 +- world/WorldConfig.h | 6 +- world/client.cpp | 4 +- world/clientlist.cpp | 14 +- world/console.cpp | 1 - world/net.cpp | 43 +++-- world/perl_EQLConfig.cpp | 8 +- world/perl_EQW.cpp | 28 +-- world/perl_HTTPRequest.cpp | 4 +- world/worlddb.cpp | 7 +- world/zonelist.cpp | 2 +- zone/AA.cpp | 6 +- zone/AA.h | 7 +- zone/Map.cpp | 2 +- zone/MobAI.cpp | 32 ++-- zone/Object.cpp | 3 +- zone/PlayerCorpse.cpp | 73 ++++---- zone/ZoneConfig.h | 2 +- zone/aggro.cpp | 2 +- zone/attack.cpp | 1 - zone/bonuses.cpp | 2 +- zone/bot.h | 2 - zone/botStructs.h | 2 - zone/client.cpp | 60 +++--- zone/client.h | 26 +-- zone/client_logs.cpp | 6 +- zone/client_logs.h | 3 +- zone/client_mods.cpp | 2 +- zone/client_packet.cpp | 119 ++++++------ zone/client_process.cpp | 27 ++- zone/command.cpp | 28 +-- zone/doors.cpp | 13 +- zone/embparser.cpp | 50 ++--- zone/embparser.h | 17 +- zone/entity.cpp | 96 +++++----- zone/entity.h | 22 +-- zone/fearpath.cpp | 2 +- zone/forage.cpp | 3 +- zone/groups.cpp | 2 +- zone/groups.h | 8 +- zone/guild_mgr.cpp | 14 +- zone/horse.cpp | 2 +- zone/horse.h | 3 +- zone/inventory.cpp | 22 +-- zone/loottables.cpp | 3 +- zone/merc.cpp | 8 +- zone/merc.h | 1 - zone/mob.cpp | 12 +- zone/mob.h | 2 +- zone/mod_functions.cpp | 2 - zone/mod_functions_base.cpp | 2 - zone/net.cpp | 2 - zone/npc.cpp | 13 +- zone/npc.h | 9 +- zone/parser.cpp | 199 ++++++++++---------- zone/parser.h | 6 +- zone/pathing.cpp | 46 ++--- zone/pathing.h | 10 +- zone/perlpacket.h | 1 - zone/petitions.cpp | 2 +- zone/questmgr.cpp | 29 ++- zone/questmgr.h | 9 +- zone/raids.cpp | 2 +- zone/raids.h | 2 - zone/spawn2.cpp | 30 +-- zone/spawn2.h | 9 +- zone/spawngroup.cpp | 21 +-- zone/spawngroup.h | 5 +- zone/spell_effects.cpp | 4 +- zone/spells.cpp | 8 +- zone/tasks.cpp | 34 ++-- zone/tasks.h | 13 +- zone/titles.cpp | 20 +- zone/titles.h | 14 +- zone/tradeskills.cpp | 8 +- zone/trading.cpp | 10 +- zone/tribute.cpp | 12 +- zone/updatemgr.h | 3 +- zone/waypoints.cpp | 19 +- zone/worldserver.cpp | 35 ++-- zone/zone.cpp | 53 +++--- zone/zone.h | 28 +-- zone/zone_profile.cpp | 6 +- zone/zonedb.cpp | 74 ++++---- zone/zonedb.h | 12 +- zone/zonedbasync.cpp | 5 +- zone/zoning.cpp | 2 +- 190 files changed, 1801 insertions(+), 2004 deletions(-) diff --git a/common/BasePacket.cpp b/common/BasePacket.cpp index 12d48ee3b..613e5e25a 100644 --- a/common/BasePacket.cpp +++ b/common/BasePacket.cpp @@ -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); diff --git a/common/EQDB.h b/common/EQDB.h index 5da63fdc3..8333d6990 100644 --- a/common/EQDB.h +++ b/common/EQDB.h @@ -46,7 +46,7 @@ public: //END PERL EXPORT private: - string m_escapeBuffer; + std::string m_escapeBuffer; static EQDB s_EQDB; MYSQL *mysql_ref; }; diff --git a/common/EQDBRes.cpp b/common/EQDBRes.cpp index 57db0b381..964746c0b 100644 --- a/common/EQDBRes.cpp +++ b/common/EQDBRes.cpp @@ -19,8 +19,8 @@ #include "EQDBRes.h" #include -vector EQDBRes::fetch_row_array() { - vector array; +std::vector EQDBRes::fetch_row_array() { + std::vector array; if(res == nullptr) return(array); @@ -32,8 +32,8 @@ vector EQDBRes::fetch_row_array() { return array; } -map EQDBRes::fetch_row_hash() { - map rowhash; +std::map EQDBRes::fetch_row_hash() { + std::map rowhash; if(res == nullptr) return(rowhash); diff --git a/common/EQDBRes.h b/common/EQDBRes.h index 5af684da4..67ce5f869 100644 --- a/common/EQDBRes.h +++ b/common/EQDBRes.h @@ -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 fetch_row_array(); - map fetch_row_hash(); + std::vector fetch_row_array(); + std::map fetch_row_hash(); unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; } //END PERL EXPORT diff --git a/common/EQEmuConfig.cpp b/common/EQEmuConfig.cpp index 8bc7b0a46..d60d8df82 100644 --- a/common/EQEmuConfig.cpp +++ b/common/EQEmuConfig.cpp @@ -21,7 +21,7 @@ #include #include -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; } diff --git a/common/EQEmuConfig.h b/common/EQEmuConfig.h index b4417a2dd..a3ab021a4 100644 --- a/common/EQEmuConfig.h +++ b/common/EQEmuConfig.h @@ -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 - 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 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 - string ChatHost; + std::string ChatHost; uint16 ChatPort; // From - string MailHost; + std::string MailHost; uint16 MailPort; // From - string DatabaseHost; - string DatabaseUsername; - string DatabasePassword; - string DatabaseDB; + std::string DatabaseHost; + std::string DatabaseUsername; + std::string DatabasePassword; + std::string DatabaseDB; uint16 DatabasePort; // From // QueryServ - string QSDatabaseHost; - string QSDatabaseUsername; - string QSDatabasePassword; - string QSDatabaseDB; + std::string QSDatabaseHost; + std::string QSDatabaseUsername; + std::string QSDatabasePassword; + std::string QSDatabaseDB; uint16 QSDatabasePort; // From - string SpellsFile; - string OpCodesFile; - string EQTimeFile; - string LogSettingsFile; + std::string SpellsFile; + std::string OpCodesFile; + std::string EQTimeFile; + std::string LogSettingsFile; // From - string MapDir; - string QuestDir; - string PluginDir; + std::string MapDir; + std::string QuestDir; + std::string PluginDir; // From - 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() { diff --git a/common/EQNetwork.cpp b/common/EQNetwork.cpp index 8cdb200fe..ac18851ef 100644 --- a/common/EQNetwork.cpp +++ b/common/EQNetwork.cpp @@ -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 ::iterator connection; + std::map ::iterator connection; for (connection = connection_list.begin( ); connection != connection_list.end( );) { if(!connection->second) { - map ::iterator tmp=connection; + std::map ::iterator tmp=connection; connection++; connection_list.erase(tmp); continue; } EQStream* eqs_data = connection->second; if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) { - map ::iterator tmp=connection; + std::map ::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 ::iterator connection; + std::map ::iterator connection; if ((connection=connection_list.find(temp))!=connection_list.end()) tmp=connection->second; if(tmp != NULL && tmp->GetrPort() == irPort) diff --git a/common/EQNetwork.h b/common/EQNetwork.h index f7df21276..1ecb23d6d 100644 --- a/common/EQNetwork.h +++ b/common/EQNetwork.h @@ -30,7 +30,6 @@ #include #include #include -using namespace std; #include "../common/types.h" #include "../common/timer.h" @@ -114,8 +113,8 @@ private: Mutex MNewQueue; Mutex MOpen; - map connection_list; - queue NewQueue; + std::map connection_list; + std::queue NewQueue; }; #endif diff --git a/common/EQPacket.cpp b/common/EQPacket.cpp index 4d106f619..04ce3ce7e 100644 --- a/common/EQPacket.cpp +++ b/common/EQPacket.cpp @@ -32,8 +32,6 @@ #include #include -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); diff --git a/common/EQPacket.h b/common/EQPacket.h index 3925f5c71..8b1f7b628 100644 --- a/common/EQPacket.h +++ b/common/EQPacket.h @@ -30,8 +30,6 @@ #include "emu_opcodes.h" #endif -using namespace std; - class EQStream; class EQStreamPair; diff --git a/common/EQStream.cpp b/common/EQStream.cpp index 2b8b2488c..1aaf39527 100644 --- a/common/EQStream.cpp +++ b/common/EQStream.cpp @@ -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::iterator sitr; + std::deque::iterator sitr; sitr = SequencedQueue.begin(); sitr += index; (*sitr)->acked = true; @@ -567,7 +567,7 @@ uint32 length; while (usedpBuffer+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 ReadyToSend; +std::queue ReadyToSend; bool SeqEmpty=false,NonSeqEmpty=false; -deque::iterator sitr; +std::deque::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::iterator itr=InboundQueue.begin(); + std::vector::iterator itr=InboundQueue.begin(); p=*itr; InboundQueue.erase(itr); } @@ -979,7 +979,7 @@ EQRawApplicationPacket *p=nullptr; MInboundQueue.lock(); if (InboundQueue.size()) { - vector::iterator itr=InboundQueue.begin(); + std::vector::iterator itr=InboundQueue.begin(); p=*itr; InboundQueue.erase(itr); } @@ -1007,7 +1007,7 @@ EQRawApplicationPacket *p=nullptr; MInboundQueue.lock(); if (InboundQueue.size()) { - vector::iterator itr=InboundQueue.begin(); + std::vector::iterator itr=InboundQueue.begin(); p=*itr; } MInboundQueue.unlock(); @@ -1023,7 +1023,7 @@ EQApplicationPacket *p=nullptr; MInboundQueue.lock(); if (!InboundQueue.empty()) { - vector::iterator itr; + std::vector::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::iterator itr; + std::deque::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::iterator itr; + std::map::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::iterator itr, tmp; +std::deque::iterator itr, tmp; MOutboundQueue.lock(); //do a bit of sanity checking. @@ -1234,7 +1234,7 @@ void EQStream::ProcessQueue() EQProtocolPacket *EQStream::RemoveQueue(uint16 seq) { -map::iterator itr; +std::map::iterator itr; EQProtocolPacket *qp=nullptr; if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) { qp=itr->second; diff --git a/common/EQStream.h b/common/EQStream.h index 09bd604eb..2f10eb5a6 100644 --- a/common/EQStream.h +++ b/common/EQStream.h @@ -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 NonSequencedQueue; - deque SequencedQueue; + std::queue NonSequencedQueue; + std::deque 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 InboundQueue; - map PacketQueue; //not mutex protected, only accessed by caller of Process() + std::vector InboundQueue; + std::map PacketQueue; //not mutex protected, only accessed by caller of Process() Mutex MInboundQueue; static uint16 MaxWindowSize; diff --git a/common/EQStreamFactory.cpp b/common/EQStreamFactory.cpp index c5e37b690..bc0bad34c 100644 --- a/common/EQStreamFactory.cpp +++ b/common/EQStreamFactory.cpp @@ -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::iterator stream_itr; +std::map::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::iterator stream_itr; + std::map::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::iterator temp=stream_itr; + std::map::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::iterator stream_itr; +std::map::iterator stream_itr; bool havework=true; -vector wants_write; -vector::iterator cur,end; +std::vector wants_write; +std::vector::iterator cur,end; bool decay=false; uint32 stream_count; diff --git a/common/EQStreamFactory.h b/common/EQStreamFactory.h index 66911bc3f..866cd23d5 100644 --- a/common/EQStreamFactory.h +++ b/common/EQStreamFactory.h @@ -24,10 +24,10 @@ class EQStreamFactory : private Timeoutable { EQStreamType StreamType; - queue NewStreams; + std::queue NewStreams; Mutex MNewStreams; - map Streams; + std::map Streams; Mutex MStreams; virtual void CheckTimeout(); diff --git a/common/EQStreamIdent.cpp b/common/EQStreamIdent.cpp index 7d5fa2449..05fa1c6b5 100644 --- a/common/EQStreamIdent.cpp +++ b/common/EQStreamIdent.cpp @@ -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::iterator cur, end; + std::vector::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::iterator curp, endp; + std::vector::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::iterator cur; - vector::iterator curp, endp; + std::vector::iterator cur; + std::vector::iterator curp, endp; //foreach pending stream. cur = m_streams.begin(); diff --git a/common/EQStreamLocator.h b/common/EQStreamLocator.h index 7e41aa12b..ab93f1afb 100644 --- a/common/EQStreamLocator.h +++ b/common/EQStreamLocator.h @@ -24,7 +24,6 @@ This did not turn out nearly as nice as I hoped. #include #include -using namespace std; class EQStreamInfo { public: @@ -103,7 +102,7 @@ inline bool operator==(const EQStreamInfo &l, const EQStreamInfo &r) { template class EQStreamLocator { protected: - typedef typename map::iterator iterator; + typedef typename std::map::iterator iterator; public: void Clear() { @@ -167,7 +166,7 @@ public: // inline iterator end() const { return(streams.end()); } protected: - map streams; + std::map streams; }; #endif diff --git a/common/EmuTCPConnection.cpp b/common/EmuTCPConnection.cpp index b3f044363..872fa915b 100644 --- a/common/EmuTCPConnection.cpp +++ b/common/EmuTCPConnection.cpp @@ -26,11 +26,9 @@ tremendously. #include "../common/debug.h" #include -using namespace std; #include #include #include -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 } diff --git a/common/Item.cpp b/common/Item.cpp index 0a05d8bff..4a1b9e917 100644 --- a/common/Item.cpp +++ b/common/Item.cpp @@ -36,7 +36,6 @@ #include "races.h" #include "shareddb.h" #include "classes.h" -using namespace std; int32 NextItemInstSerialNumber = 1; @@ -102,7 +101,7 @@ ItemInstQueue::~ItemInstQueue() { } Inventory::~Inventory() { - map::iterator cur,end; + std::map::iterator cur,end; cur = m_worn.begin(); @@ -580,7 +579,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const std::string ItemInst::GetCustomDataString() const { std::string ret_val; - map::const_iterator iter = m_custom_data.begin(); + std::map::const_iterator iter = m_custom_data.begin(); while(iter != m_custom_data.end()) { if(ret_val.length() > 0) { ret_val += "^"; @@ -624,14 +623,14 @@ void ItemInst::SetCustomData(std::string identifier, bool value) { } void ItemInst::DeleteCustomData(std::string identifier) { - map::iterator iter = m_custom_data.find(identifier); + std::map::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::const_iterator iter = m_custom_data.find(identifier); + std::map::const_iterator iter = m_custom_data.find(identifier); if(iter != m_custom_data.end()) { return iter->second; } @@ -1160,7 +1159,7 @@ void Inventory::dumpInventory() { } // Internal Method: Retrieves item within an inventory bucket -ItemInst* Inventory::_GetItem(const map& bucket, int16 slot_id) const +ItemInst* Inventory::_GetItem(const std::map& bucket, int16 slot_id) const { iter_inst it = bucket.find(slot_id); if (it != bucket.end()) { @@ -1228,7 +1227,7 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst) } // Internal Method: Checks an inventory bucket for a particular item -int16 Inventory::_HasItem(map& bucket, uint32 item_id, uint8 quantity) +int16 Inventory::_HasItem(std::map& bucket, uint32 item_id, uint8 quantity) { iter_inst it; iter_contents itb; @@ -1318,7 +1317,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) } // Internal Method: Checks an inventory bucket for a particular item -int16 Inventory::_HasItemByUse(map& bucket, uint8 use, uint8 quantity) +int16 Inventory::_HasItemByUse(std::map& bucket, uint8 use, uint8 quantity) { iter_inst it; iter_contents itb; @@ -1386,7 +1385,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity) return SLOT_INVALID; } -int16 Inventory::_HasItemByLoreGroup(map& bucket, uint32 loregroup) +int16 Inventory::_HasItemByLoreGroup(std::map& bucket, uint32 loregroup) { iter_inst it; iter_contents itb; diff --git a/common/Item.h b/common/Item.h index c5d43f25e..b0f1ec449 100644 --- a/common/Item.h +++ b/common/Item.h @@ -34,15 +34,14 @@ class EvolveInfo; // Stores information about an evolving item family #include #include #include -using namespace std; #include "../common/eq_packet_structs.h" #include "../common/eq_constants.h" #include "../common/item_struct.h" // Helper typedefs -typedef list::const_iterator iter_queue; -typedef map::const_iterator iter_inst; -typedef map::const_iterator iter_contents; +typedef std::list::const_iterator iter_queue; +typedef std::map::const_iterator iter_inst; +typedef std::map::const_iterator iter_contents; namespace ItemField { enum { @@ -120,7 +119,7 @@ protected: // Protected Members ///////////////////////// - list m_list; + std::list m_list; }; @@ -209,26 +208,26 @@ protected: /////////////////////////////// // Retrieves item within an inventory bucket - ItemInst* _GetItem(const map& bucket, int16 slot_id) const; + ItemInst* _GetItem(const std::map& 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& bucket, uint32 item_id, uint8 quantity); + int16 _HasItem(std::map& bucket, uint32 item_id, uint8 quantity); int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity); - int16 _HasItemByUse(map& bucket, uint8 use, uint8 quantity); + int16 _HasItemByUse(std::map& bucket, uint8 use, uint8 quantity); int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity); - int16 _HasItemByLoreGroup(map& bucket, uint32 loregroup); + int16 _HasItemByLoreGroup(std::map& bucket, uint32 loregroup); int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup); // Player inventory - map m_worn; // Items worn by character - map m_inv; // Items in character personal inventory - map m_bank; // Items in character bank - map m_shbank; // Items in character shared bank - map m_trade; // Items in a trade session + std::map m_worn; // Items worn by character + std::map m_inv; // Items in character personal inventory + std::map m_bank; // Items in character bank + std::map m_shbank; // Items in character shared bank + std::map m_trade; // Items in a trade session ItemInstQueue m_cursor; // Items on cursor: FIFO }; @@ -300,7 +299,7 @@ public: uint8 FirstOpenSlot() const; uint8 GetTotalItemCount() const; bool IsNoneEmptyContainer(); - map* GetContents() { return &m_contents; } + std::map* GetContents() { return &m_contents; } // // Augments @@ -371,7 +370,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; } @@ -399,8 +398,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 m_contents; // Zero-based index: min=0, max=9 - map m_custom_data; + std::map m_contents; // Zero-based index: min=0, max=9 + std::map m_custom_data; }; class EvoItemInst: public ItemInst { diff --git a/common/MiscFunctions.cpp b/common/MiscFunctions.cpp index 94a03dba0..f737cdfed 100644 --- a/common/MiscFunctions.cpp +++ b/common/MiscFunctions.cpp @@ -32,8 +32,6 @@ #include "../common/timer.h" #include "../common/seperator.h" -using namespace std; - #ifdef _WINDOWS #include @@ -86,10 +84,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"; } // normal strncpy doesnt put a null term on copied strings, this one does diff --git a/common/Mutex.cpp b/common/Mutex.cpp index 0b5e156ec..2b4690167 100644 --- a/common/Mutex.cpp +++ b/common/Mutex.cpp @@ -19,7 +19,6 @@ #include "../common/Mutex.h" #include -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; } @@ -67,7 +66,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); @@ -86,7 +85,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); @@ -98,11 +97,11 @@ Mutex::~Mutex() { void Mutex::lock() { _CP(Mutex_lock); #if DEBUG_MUTEX_CLASS >= 9 - cout << "Locking Mutex" << endl; + std::cout << "Locking Mutex" << std::endl; #endif #if DEBUG_MUTEX_CLASS >= 5 if (!trylock()) { - cout << "Locking Mutex: Having to wait" << endl; + std::cout << "Locking Mutex: Having to wait" << std::endl; #ifdef _WINDOWS EnterCriticalSection(&CSMutex); #else @@ -120,7 +119,7 @@ void Mutex::lock() { bool Mutex::trylock() { #if DEBUG_MUTEX_CLASS >= 9 - cout << "TryLocking Mutex" << endl; + std::cout << "TryLocking Mutex" << std::endl; #endif #ifdef _WINDOWS #if(_WIN32_WINNT >= 0x0400) @@ -141,7 +140,7 @@ bool Mutex::trylock() { void Mutex::unlock() { #if DEBUG_MUTEX_CLASS >= 9 - cout << "Unlocking Mutex" << endl; + std::cout << "Unlocking Mutex" << std::endl; #endif #ifdef _WINDOWS LeaveCriticalSection(&CSMutex); @@ -187,7 +186,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 } diff --git a/common/ProcLauncher.cpp b/common/ProcLauncher.cpp index 18413b260..d2db2f6d4 100644 --- a/common/ProcLauncher.cpp +++ b/common/ProcLauncher.cpp @@ -32,8 +32,6 @@ #include #endif -using namespace std; - ProcLauncher ProcLauncher::s_launcher; #ifdef _WINDOWS @@ -51,10 +49,9 @@ ProcLauncher::ProcLauncher() #endif } - void ProcLauncher::Process() { #ifdef _WINDOWS - map::iterator cur, end, tmp; + std::map::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::iterator ref; + std::map::iterator ref; ref = m_running.find(died); if(ref == m_running.end()) { //unable to find this process in our list... diff --git a/common/StructStrategy.cpp b/common/StructStrategy.cpp index 61b060259..9056fad72 100644 --- a/common/StructStrategy.cpp +++ b/common/StructStrategy.cpp @@ -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 strategies; + static std::map strategies; void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) { strategies[first_opcode] = structs; } const StructStrategy *FindPatch(EmuOpcode first_opcode) { - map::const_iterator res; + std::map::const_iterator res; res = strategies.find(first_opcode); if(res == strategies.end()) return(nullptr); diff --git a/common/TCPConnection.cpp b/common/TCPConnection.cpp index 2c4867efd..3ef538d02 100644 --- a/common/TCPConnection.cpp +++ b/common/TCPConnection.cpp @@ -18,11 +18,9 @@ #include "../common/debug.h" #include -using namespace std; #include #include #include -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 diff --git a/common/XMLParser.cpp b/common/XMLParser.cpp index 44626f82f..f6f64ed13 100644 --- a/common/XMLParser.cpp +++ b/common/XMLParser.cpp @@ -23,7 +23,7 @@ XMLParser::XMLParser() { } bool XMLParser::ParseFile(const char *file, const char *root_ele) { - map::iterator handler; + std::map::iterator handler; TiXmlDocument doc( file ); if(!doc.LoadFile()) { printf("Unable to load '%s': %s\n", file, doc.ErrorDesc()); diff --git a/common/XMLParser.h b/common/XMLParser.h index 503b96e19..f96cbb044 100644 --- a/common/XMLParser.h +++ b/common/XMLParser.h @@ -24,9 +24,6 @@ #include #include -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 Handlers; + std::map Handlers; bool ParseOkay; }; - #endif diff --git a/common/database.cpp b/common/database.cpp index 4572533c4..335c68301 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -18,7 +18,6 @@ #include "../common/debug.h" #include "../common/rulesys.h" #include -using namespace std; #include #include #include @@ -193,7 +192,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, int16* oStat } else { - cerr << "Error in CheckLogin query '" << query << "' " << errbuf << endl; + std::cerr << "Error in CheckLogin query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -227,7 +226,7 @@ bool Database::CheckBannedIPs(const char* loginIP) } else { - cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << endl; + std::cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return true; } @@ -240,7 +239,7 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes) char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes), errbuf)) { - cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl; + std::cerr << "Error in ReserveName query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -290,7 +289,7 @@ void Database::LoginIP(uint32 AccountID, const char* LoginIP) char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP), errbuf)) { - cerr << "Error in Log IP query '" << query << "' " << errbuf << endl; + std::cerr << "Error in Log IP query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); } @@ -333,7 +332,7 @@ int16 Database::CheckStatus(uint32 account_id) } else { - cerr << "Error in CheckStatus query '" << query << "' " << errbuf << endl; + std::cerr << "Error in CheckStatus query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -352,16 +351,16 @@ uint32 Database::CreateAccount(const char* name, const char* password, int16 sta else querylen = MakeAnyLenString(&query, "INSERT INTO account SET name='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name, status, lsaccount_id); - cerr << "Account Attempting to be created:" << name << " " << (int16) status << endl; + std::cerr << "Account Attempting to be created:" << name << " " << (int16) status << std::endl; if (!RunQuery(query, querylen, errbuf, 0, 0, &last_insert_id)) { - cerr << "Error in CreateAccount query '" << query << "' " << errbuf << endl; + std::cerr << "Error in CreateAccount query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return 0; } safe_delete_array(query); if (last_insert_id == 0) { - cerr << "Error in CreateAccount query '" << query << "' " << errbuf << endl; + std::cerr << "Error in CreateAccount query '" << query << "' " << errbuf << std::endl; return 0; } @@ -373,7 +372,7 @@ bool Database::DeleteAccount(const char* name) { char *query = 0; uint32 affected_rows = 0; - cerr << "Account Attempting to be deleted:" << name << endl; + std::cerr << "Account Attempting to be deleted:" << name << std::endl; if (RunQuery(query, MakeAnyLenString(&query, "DELETE FROM account WHERE name='%s';",name), errbuf, 0, &affected_rows)) { safe_delete_array(query); if (affected_rows == 1) { @@ -382,7 +381,7 @@ bool Database::DeleteAccount(const char* name) { } else { - cerr << "Error in DeleteAccount query '" << query << "' " << errbuf << endl; + std::cerr << "Error in DeleteAccount query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } @@ -394,7 +393,7 @@ bool Database::SetLocalPassword(uint32 accid, const char* password) { char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET password=MD5('%s') where id=%i;", password, accid), errbuf)) { - cerr << "Error in SetLocalPassword query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetLocalPassword query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -408,7 +407,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) { char *query = 0; uint32 affected_rows = 0; - cout << "Account being GM Flagged:" << name << ", Level: " << (int16) status << endl; + std::cout << "Account being GM Flagged:" << name << ", Level: " << (int16) status << std::endl; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET status=%i WHERE name='%s';", status, name), errbuf, 0, &affected_rows)) { safe_delete_array(query); return false; @@ -416,7 +415,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) { safe_delete_array(query); if (affected_rows == 0) { - cout << "Account: " << name << " does not exist, therefore it cannot be flagged\n"; + std::cout << "Account: " << name << " does not exist, therefore it cannot be flagged\n"; return false; } @@ -429,7 +428,7 @@ bool Database::ReserveName(uint32 account_id, char* name) char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=NULL", account_id, name), errbuf)) { - cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl; + std::cerr << "Error in ReserveName query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -877,7 +876,7 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) { mysql_free_result(result); } else { - cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } @@ -940,7 +939,7 @@ uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32* mysql_free_result(result); } else { - cerr << "Error in GetAccountIDByAcc query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetAccountIDByAcc query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } @@ -968,7 +967,7 @@ void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID } else { safe_delete_array(query); - cerr << "Error in GetAccountName query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetAccountName query '" << query << "' " << errbuf << std::endl; } } @@ -990,7 +989,7 @@ void Database::GetCharName(uint32 char_id, char* name) { } else { safe_delete_array(query); - cerr << "Error in GetCharName query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetCharName query '" << query << "' " << errbuf << std::endl; } } @@ -1007,7 +1006,7 @@ bool Database::LoadVariables() { return ret; } else { - cerr << "Error in LoadVariables query '" << query << "' " << errbuf << endl; + std::cerr << "Error in LoadVariables query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } return false; @@ -1130,7 +1129,7 @@ bool Database::SetVariable(const char* varname_in, const char* varvalue_in) { } } else { - cerr << "Error in SetVariable query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetVariable query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } free(varname); @@ -1152,7 +1151,7 @@ uint32 Database::GetMiniLoginAccount(char* ip){ } else { - cerr << "Error in GetMiniLoginAccount query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetMiniLoginAccount query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } return retid; @@ -1194,11 +1193,11 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe } else { - cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << endl; - cerr << "If it errors, run the following querys:\n"; - cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n"; - cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n"; - cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n"; + std::cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << std::endl; + std::cerr << "If it errors, run the following querys:\n"; + std::cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n"; + std::cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n"; + std::cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n"; safe_delete_array(query); } @@ -1243,7 +1242,7 @@ bool Database::GetZoneLongName(const char* short_name, char** long_name, char* f } else { - cerr << "Error in GetZoneLongName query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetZoneLongName query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1269,7 +1268,7 @@ uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) { } else { - cerr << "Error in GetZoneGraveyardID query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetZoneGraveyardID query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); return GraveyardID; @@ -1303,7 +1302,7 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon } else { - cerr << "Error in GetZoneGraveyard query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetZoneGraveyard query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1342,7 +1341,7 @@ bool Database::LoadZoneNames() { mysql_free_result(result); } else { - cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << endl; + std::cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1352,7 +1351,7 @@ bool Database::LoadZoneNames() { } } else { - cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << endl; + std::cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1419,7 +1418,7 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){ } else { - cerr << "Error in GetPEQZone query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetPEQZone query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); return peqzone; @@ -1503,7 +1502,7 @@ bool Database::CheckNameFilter(const char* name, bool surname) } else { - cerr << "Error in CheckNameFilter query '" << query << "' " << errbuf << endl; + std::cerr << "Error in CheckNameFilter query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } @@ -1516,7 +1515,7 @@ bool Database::AddToNameFilter(const char* name) { uint32 affected_rows = 0; if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO name_filter (name) values ('%s')", name), errbuf, 0, &affected_rows)) { - cerr << "Error in AddToNameFilter query '" << query << "' " << errbuf << endl; + std::cerr << "Error in AddToNameFilter query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1557,7 +1556,7 @@ uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* o mysql_free_result(result); } else { - cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return 0; } @@ -1583,7 +1582,7 @@ void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) { mysql_free_result(result); } else - cerr << "Error in GetAccountFromID query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetAccountFromID query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } @@ -1592,7 +1591,7 @@ void Database::ClearMerchantTemp(){ char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "delete from merchantlist_temp"), errbuf)) { - cerr << "Error in ClearMerchantTemp query '" << query << "' " << errbuf << endl; + std::cerr << "Error in ClearMerchantTemp query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); } @@ -1602,7 +1601,7 @@ bool Database::UpdateName(const char* oldname, const char* newname) { char *query = 0; uint32 affected_rows = 0; - cout << "Renaming " << oldname << " to " << newname << "..." << endl; + std::cout << "Renaming " << oldname << " to " << newname << "..." << std::endl; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET name='%s' WHERE name='%s';", newname, oldname), errbuf, 0, &affected_rows)) { safe_delete_array(query); return false; @@ -1626,7 +1625,7 @@ bool Database::CheckUsedName(const char* name) //if (strlen(name) > 15) // return false; if (!RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM character_ where name='%s'", name), errbuf, &result)) { - cerr << "Error in CheckUsedName query '" << query << "' " << errbuf << endl; + std::cerr << "Error in CheckUsedName query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1664,15 +1663,11 @@ uint8 Database::GetServerType() mysql_free_result(result); } else - { - - - cerr << "Error in GetServerType query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetServerType query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } - return 0; } @@ -1686,7 +1681,7 @@ bool Database::MoveCharacterToZone(const char* charname, const char* zonename,ui return(false); if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s',zoneid=%i,x=-1, y=-1, z=-1 WHERE name='%s'", zonename,zoneid, charname), errbuf, 0,&affected_rows)) { - cerr << "Error in MoveCharacterToZone(name) query '" << query << "' " << errbuf << endl; + std::cerr << "Error in MoveCharacterToZone(name) query '" << query << "' " << errbuf << std::endl; return false; } safe_delete_array(query); @@ -1706,7 +1701,7 @@ bool Database::MoveCharacterToZone(uint32 iCharID, const char* iZonename) { char *query = 0; uint32 affected_rows = 0; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s', zoneid=%i, x=-1, y=-1, z=-1 WHERE id=%i", iZonename, GetZoneID(iZonename), iCharID), errbuf, 0,&affected_rows)) { - cerr << "Error in MoveCharacterToZone(id) query '" << query << "' " << errbuf << endl; + std::cerr << "Error in MoveCharacterToZone(id) query '" << query << "' " << errbuf << std::endl; return false; } safe_delete_array(query); @@ -1739,7 +1734,7 @@ uint8 Database::CopyCharacter(const char* oldname, const char* newname, uint32 a } else { - cerr << "Error in CopyCharacter read query '" << query << "' " << errbuf << endl; + std::cerr << "Error in CopyCharacter read query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return 0; } @@ -1755,7 +1750,7 @@ uint8 Database::CopyCharacter(const char* oldname, const char* newname, uint32 a end += sprintf(end, "\', account_id=%d, name='%s'", acctid, newname); if (!RunQuery(query2, (uint32) (end - query2), errbuf, 0, &affected_rows)) { - cerr << "Error in CopyCharacter query '" << query << "' " << errbuf << endl; + std::cerr << "Error in CopyCharacter query '" << query << "' " << errbuf << std::endl; return 0; } @@ -1772,7 +1767,7 @@ bool Database::SetHackerFlag(const char* accountname, const char* charactername, char *query = 0; uint32 affected_rows = 0; if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO hackers(account,name,hacked) values('%s','%s','%s')", accountname, charactername, hacked), errbuf, 0,&affected_rows)) { - cerr << "Error in SetHackerFlag query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetHackerFlag query '" << query << "' " << errbuf << std::endl; return false; } safe_delete_array(query); @@ -1792,7 +1787,7 @@ bool Database::SetMQDetectionFlag(const char* accountname, const char* character uint32 affected_rows = 0; if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO hackers(account,name,hacked,zone) values('%s','%s','%s','%s')", accountname, charactername, hacked, zone), errbuf, 0,&affected_rows)) { - cerr << "Error in SetMQDetectionFlag query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetMQDetectionFlag query '" << query << "' " << errbuf << std::endl; return false; } @@ -1911,7 +1906,7 @@ uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZo mysql_free_result(result); } else { - cerr << "Error in GetCharacterInfo query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetCharacterInfo query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } return 0; @@ -1921,7 +1916,7 @@ bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id), errbuf)) { - cerr << "Error in UpdateLiveChar query '" << query << "' " << errbuf << endl; + std::cerr << "Error in UpdateLiveChar query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1946,7 +1941,7 @@ bool Database::GetLiveChar(uint32 account_id, char* cname) { mysql_free_result(result); } else { - cerr << "Error in GetLiveChar query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetLiveChar query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } @@ -2171,7 +2166,7 @@ void Database::ClearGroupLeader(uint32 gid){ safe_delete_array(query); } -bool FetchRowMap(MYSQL_RES *result, map &rowmap) +bool FetchRowMap(MYSQL_RES *result, std::map &rowmap) { MYSQL_FIELD *fields; MYSQL_ROW row; @@ -3175,7 +3170,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; diff --git a/common/database.h b/common/database.h index 753e90d7f..22474a807 100644 --- a/common/database.h +++ b/common/database.h @@ -35,7 +35,6 @@ #include #include #include -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 &rowmap); +bool FetchRowMap(MYSQL_RES *result, std::map &rowmap); #endif diff --git a/common/dbasync.cpp b/common/dbasync.cpp index ba13ab2f6..e90637cad 100644 --- a/common/dbasync.cpp +++ b/common/dbasync.cpp @@ -5,7 +5,6 @@ #include #endif #include -using namespace std; #include "dbasync.h" #include "database.h" #include @@ -24,7 +23,7 @@ bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) { if (dbaq->GetAnswer(errbuf, &result)) iWork->GetDB()->LoadVariables_result(result); else - cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << endl; + std::cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << std::endl; return true; } @@ -115,8 +114,8 @@ uint32 DBAsync::AddWork(DBAsyncWork** iWork, uint32 iDelay) { if (iDelay) (*iWork)->pExecuteAfter = Timer::GetCurrentTime() + iDelay; #if DEBUG_MYSQL_QUERIES >= 2 - cout << "Adding AsyncWork #" << (*iWork)->GetWorkID() << endl; - cout << "ExecuteAfter = " << (*iWork)->pExecuteAfter << " (" << Timer::GetCurrentTime() << " + " << iDelay << ")" << endl; + std::cout << "Adding AsyncWork #" << (*iWork)->GetWorkID() << std::endl; + std::cout << "ExecuteAfter = " << (*iWork)->pExecuteAfter << " (" << Timer::GetCurrentTime() << " + " << iDelay << ")" << std::endl; #endif *iWork = 0; MInList.unlock(); @@ -131,7 +130,7 @@ bool DBAsync::CancelWork(uint32 iWorkID) { if (iWorkID == 0) return false; #if DEBUG_MYSQL_QUERIES >= 2 - cout << "DBAsync::CancelWork: " << iWorkID << endl; + std::cout << "DBAsync::CancelWork: " << iWorkID << std::endl; #endif MCurrentWork.lock(); if (CurrentWork && CurrentWork->GetWorkID() == iWorkID) { @@ -174,8 +173,8 @@ DBAsyncWork* DBAsync::InListPop() { if (iterator.GetData()->pExecuteAfter <= Timer::GetCurrentTime()) { ret = iterator.GetData(); #if DEBUG_MYSQL_QUERIES >= 2 - cout << "Poping AsyncWork #" << ret->GetWorkID() << endl; - cout << ret->pExecuteAfter << " <= " << Timer::GetCurrentTime() << endl; + std::cout << "Poping AsyncWork #" << ret->GetWorkID() << std::endl; + std::cout << ret->pExecuteAfter << " <= " << Timer::GetCurrentTime() << std::endl; #endif iterator.RemoveCurrent(false); break; @@ -232,7 +231,7 @@ void DBAsync::Process() { tmpStatus = tmpWork->SetStatus(DBAsync::Finished); if (tmpStatus != Executing) { if (tmpStatus != Canceled) { - cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #1" << endl; + std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #1" << std::endl; } MCurrentWork.lock(); safe_delete(tmpWork); @@ -246,7 +245,7 @@ void DBAsync::Process() { } else { if (tmpStatus != Canceled) { - cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #2" << endl; + std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #2" << std::endl; } MCurrentWork.lock(); safe_delete(CurrentWork); @@ -274,7 +273,7 @@ void DBAsync::CheckTimeout() { void DBAsync::CommitWrites() { #if DEBUG_MYSQL_QUERIES >= 2 - cout << "DBAsync::CommitWrites() called." << endl; + std::cout << "DBAsync::CommitWrites() called." << std::endl; #endif DBAsyncWork* tmpWork; while ((tmpWork = InListPopWrite())) { @@ -284,7 +283,7 @@ void DBAsync::CommitWrites() { tmpStatus = tmpWork->SetStatus(DBAsync::Finished); if (tmpStatus != Executing) { if (tmpStatus != Canceled) { - cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #1" << endl; + std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #1" << std::endl; } safe_delete(tmpWork); } @@ -294,7 +293,7 @@ void DBAsync::CommitWrites() { } else { if (tmpStatus != Canceled) { - cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #2" << endl; + std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #2" << std::endl; } safe_delete(tmpWork); } @@ -305,7 +304,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); diff --git a/common/dbcore.cpp b/common/dbcore.cpp index 7190f2224..3f215cd0f 100644 --- a/common/dbcore.cpp +++ b/common/dbcore.cpp @@ -5,7 +5,6 @@ #endif #include -using namespace std; #include #include #include @@ -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; diff --git a/common/debug.cpp b/common/debug.cpp index 947571626..2a2b082d4 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -1,7 +1,6 @@ #include "debug.h" #include -using namespace std; #include #include #ifdef _WINDOWS @@ -112,7 +111,7 @@ bool EQEMuLog::open(LogIDs id) { #endif fp[id] = fopen(filename, "a"); if (!fp[id]) { - cerr << "Failed to open log file: " << filename << endl; + std::cerr << "Failed to open log file: " << filename << std::endl; pLogStatus[id] |= 4; // set file state to error return false; } @@ -328,7 +327,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"< #include -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); diff --git a/common/eqtime.h b/common/eqtime.h index 50bb4b562..aa608f307 100644 --- a/common/eqtime.h +++ b/common/eqtime.h @@ -4,8 +4,6 @@ #include "../common/eq_packet_structs.h" #include -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); diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 83e3a3666..ab2206ecc 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -52,7 +52,7 @@ bool BaseGuildManager::LoadGuilds() { char *query = 0; MYSQL_RES *result; MYSQL_ROW row; - map::iterator res; + std::map::iterator res; // load up all the guilds if (!m_db->RunQuery(query, MakeAnyLenString(&query, @@ -116,7 +116,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) { char *query = 0; MYSQL_RES *result; MYSQL_ROW row; - map::iterator res; + std::map::iterator res; GuildInfo *info; // load up all the guilds @@ -173,7 +173,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::iterator res; + std::map::iterator res; //remove any old entry. res = m_guilds.find(guild_id); @@ -222,7 +222,7 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) { return(false); } - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) { _log(GUILDS__DB, "Requested to store non-existent guild %d", guild_id); @@ -376,7 +376,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::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return(false); @@ -516,7 +516,7 @@ uint32 BaseGuildManager::DBCreateGuild(const char* name, uint32 leader) { bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) { //remove the local entry - map::iterator res; + std::map::iterator res; res = m_guilds.find(guild_id); if(res != m_guilds.end()) { delete res->second; @@ -557,7 +557,7 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) { return(false); } - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return(false); @@ -597,7 +597,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) { return(false); } - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return(false); @@ -637,7 +637,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c return(false); } - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return(false); @@ -682,7 +682,7 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL) if(m_db == nullptr) return(false); - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(GuildID); @@ -723,7 +723,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel) if(m_db == nullptr) return(false); - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(GuildID); @@ -978,7 +978,7 @@ static void ProcessGuildMember(MYSQL_ROW &row, CharGuildInfo &into) { } -bool BaseGuildManager::GetEntireGuild(uint32 guild_id, vector &members) { +bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector &members) { members.clear(); if(m_db == nullptr) @@ -1109,7 +1109,7 @@ uint8 *BaseGuildManager::MakeGuildList(const char *head_name, uint32 &length) co strn0cpy((char *) buffer, head_name, 64); - map::const_iterator cur, end; + std::map::const_iterator cur, end; cur = m_guilds.begin(); end = m_guilds.end(); for(; cur != end; cur++) { @@ -1122,7 +1122,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::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return("Invalid Guild Rank"); @@ -1132,7 +1132,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::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return("Invalid Guild"); @@ -1140,7 +1140,7 @@ const char *BaseGuildManager::GetGuildName(uint32 guild_id) const { } bool BaseGuildManager::GetGuildNameByID(uint32 guild_id, std::string &into) const { - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return(false); @@ -1150,7 +1150,7 @@ bool BaseGuildManager::GetGuildNameByID(uint32 guild_id, std::string &into) cons uint32 BaseGuildManager::GetGuildIDByName(const char *GuildName) { - map::iterator Iterator; + std::map::iterator Iterator; for(Iterator = m_guilds.begin(); Iterator != m_guilds.end(); ++Iterator) { @@ -1162,7 +1162,7 @@ uint32 BaseGuildManager::GetGuildIDByName(const char *GuildName) } bool BaseGuildManager::GetGuildMOTD(uint32 guild_id, char *motd_buffer, char *setter_buffer) const { - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return(false); @@ -1173,7 +1173,7 @@ bool BaseGuildManager::GetGuildMOTD(uint32 guild_id, char *motd_buffer, char *se bool BaseGuildManager::GetGuildURL(uint32 GuildID, char *URLBuffer) const { - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(GuildID); if(res == m_guilds.end()) return(false); @@ -1184,7 +1184,7 @@ bool BaseGuildManager::GetGuildURL(uint32 GuildID, char *URLBuffer) const bool BaseGuildManager::GetGuildChannel(uint32 GuildID, char *ChannelBuffer) const { - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(GuildID); if(res == m_guilds.end()) return(false); @@ -1203,7 +1203,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::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) { _log(GUILDS__PERMISSIONS, "Check leader for char %d: invalid guild.", char_id); @@ -1214,7 +1214,7 @@ bool BaseGuildManager::IsGuildLeader(uint32 guild_id, uint32 char_id) const { } uint32 BaseGuildManager::FindGuildByLeader(uint32 leader) const { - map::const_iterator cur, end; + std::map::const_iterator cur, end; cur = m_guilds.begin(); end = m_guilds.end(); for(; cur != end; cur++) { @@ -1226,7 +1226,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::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return(3); //invalid guild rank @@ -1243,7 +1243,7 @@ bool BaseGuildManager::CheckGMStatus(uint32 guild_id, uint8 status) const { return(true); //250+ as allowed anything } - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) { _log(GUILDS__PERMISSIONS, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status); @@ -1264,7 +1264,7 @@ bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction guild_id, rank, GuildActionNames[act], act); return(false); //invalid rank } - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) { _log(GUILDS__PERMISSIONS, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.", @@ -1284,7 +1284,7 @@ bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction } bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) { - map::iterator res; + std::map::iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) return(false); //invalid guild @@ -1293,7 +1293,7 @@ bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) { } void BaseGuildManager::ClearGuilds() { - map::iterator cur, end; + std::map::iterator cur, end; cur = m_guilds.begin(); end = m_guilds.end(); for(; cur != end; cur++) { diff --git a/common/misc.cpp b/common/misc.cpp index 0928113e0..b2e80e3bd 100644 --- a/common/misc.cpp +++ b/common/misc.cpp @@ -18,12 +18,10 @@ #include #include -using namespace std; - #define ENC(c) (((c) & 0x3f) + ' ') #define DEC(c) (((c) - ' ') & 0x3f) -map DBFieldNames; +std::map 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 fields_list each fields_list is a map of field index -> value */ -bool ItemParse(const char *data, int length, map > &items, int id_pos, int name_pos, int max_field, int level) +bool ItemParse(const char *data, int length, std::map > &items, int id_pos, int name_pos, int max_field, int level) { int i; char *end,*ptr; -map field; +std::map 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 & tokens, char delim) +int Tokenize(std::string s,std::map & 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; diff --git a/common/misc.h b/common/misc.h index 41cfaec4c..b33f2f32d 100644 --- a/common/misc.h +++ b/common/misc.h @@ -5,17 +5,15 @@ #include #include -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 > &items, int id_pos, int name_pos, int max_field, int level=0); +bool ItemParse(const char *data, int length, std::map > &items, int id_pos, int name_pos, int max_field, int level=0); -int Tokenize(string s, map & tokens, char delim='|'); +int Tokenize(std::string s, std::map & 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); diff --git a/common/opcode_map.cpp b/common/opcode_map.cpp index 42c2d320f..10babaccb 100644 --- a/common/opcode_map.cpp +++ b/common/opcode_map.cpp @@ -2,13 +2,11 @@ #include #include -using namespace std; +std::map opcode_map; -map opcode_map; - -string get_opcode_name(unsigned long opcode) +std::string get_opcode_name(unsigned long opcode) { -map::iterator itr;; +std::map::iterator itr;; return (itr=opcode_map.find(opcode))!=opcode_map.end() ? itr->second : "OP_Unknown"; } diff --git a/common/opcodemgr.cpp b/common/opcodemgr.cpp index a7286e686..6e524bfa5 100644 --- a/common/opcodemgr.cpp +++ b/common/opcodemgr.cpp @@ -25,7 +25,6 @@ #include #include -using namespace std; OpcodeManager::OpcodeManager() { loaded = false; @@ -38,7 +37,7 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, return(false); } - map eq; + std::map 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::iterator res; + std::map::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::iterator f; + std::map::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::iterator f; + std::map::iterator f; f = eq_to_emu.find(eq_op); return(f == eq_to_emu.end()?OP_Unknown:f->second); } diff --git a/common/opcodemgr.h b/common/opcodemgr.h index 64e025c57..690f5442a 100644 --- a/common/opcodemgr.h +++ b/common/opcodemgr.h @@ -24,7 +24,6 @@ #include "emu_opcodes.h" #include -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 emu_to_eq; - map eq_to_emu; + std::map emu_to_eq; + std::map eq_to_emu; }; #endif diff --git a/common/packet_dump.cpp b/common/packet_dump.cpp index bc652f6c6..ec8d94024 100644 --- a/common/packet_dump.cpp +++ b/common/packet_dump.cpp @@ -20,8 +20,6 @@ #include #include -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 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; } diff --git a/common/packet_dump_file.cpp b/common/packet_dump_file.cpp index dc766ec9d..4453fc146 100644 --- a/common/packet_dump_file.cpp +++ b/common/packet_dump_file.cpp @@ -41,16 +41,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; itm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec << " GMT"; + logfile << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec << " GMT"; } if (text != 0) { @@ -181,17 +179,17 @@ void FilePrintLine(const char* filename, bool prefix_timestamp, const char* text logfile << ": "; logfile << buffer; } - logfile << endl; + logfile << std::endl; } void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const char* text, ...) { - ofstream logfile(filename, ios::app); + std::ofstream logfile(filename, std::ios::app); if (prefix_timestamp) { time_t rawtime; struct tm* gmt_t; time(&rawtime); gmt_t = gmtime(&rawtime); - logfile << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec << " GMT"; + logfile << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec << " GMT"; } if (text != 0) { @@ -207,6 +205,6 @@ void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const } if (newline) - logfile << endl; + logfile << std::endl; } diff --git a/common/packet_dump_file.h b/common/packet_dump_file.h index adccb40ba..aa50b0420 100644 --- a/common/packet_dump_file.h +++ b/common/packet_dump_file.h @@ -19,7 +19,6 @@ #define PACKET_DUMP_FILE_H #include -using namespace std; #include "../common/types.h" diff --git a/common/packet_functions.cpp b/common/packet_functions.cpp index a51f28f08..5860f9cc8 100644 --- a/common/packet_functions.cpp +++ b/common/packet_functions.cpp @@ -27,8 +27,6 @@ #include #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 diff --git a/common/packetfile.cpp b/common/packetfile.cpp index bbd251968..699e26357 100644 --- a/common/packetfile.cpp +++ b/common/packetfile.cpp @@ -13,9 +13,6 @@ #include "../common/misc.h" #include -using namespace std; - - PacketFileWriter::PacketFileWriter(bool _force_flush) { out = NULL; force_flush = _force_flush; diff --git a/common/patches/Client62.cpp b/common/patches/Client62.cpp index 6f5f52fbf..041a1e1b9 100644 --- a/common/patches/Client62.cpp +++ b/common/patches/Client62.cpp @@ -24,7 +24,7 @@ void Register(EQStreamIdentifier &into) { //create our opcode manager if we havent already if(opcodes == nullptr) { //TODO: get this file name from the config file - string opfile = "patch_"; + std::string opfile = "patch_"; opfile += name; opfile += ".conf"; //load up the opcode manager. @@ -39,17 +39,17 @@ void Register(EQStreamIdentifier &into) { //ok, now we have what we need to register. EQStream::Signature signature; - string pname; + std::string pname; //register our world signature. - pname = string(name) + "_world"; + pname = std::string(name) + "_world"; signature.ignore_eq_opcode = 0; signature.first_length = sizeof(structs::LoginInfo_Struct); signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo); into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); //register our zone signature. - pname = string(name) + "_zone"; + pname = std::string(name) + "_zone"; signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket); signature.first_length = sizeof(structs::ClientZoneEntry_Struct); signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry); @@ -66,7 +66,7 @@ void Reload() { if(opcodes != nullptr) { //TODO: get this file name from the config file - string opfile = "patch_"; + std::string opfile = "patch_"; opfile += name; opfile += ".conf"; if(!opcodes->ReloadOpcodes(opfile.c_str())) { @@ -546,7 +546,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); diff --git a/common/patches/RoF.cpp b/common/patches/RoF.cpp index 079887649..9496c66b0 100644 --- a/common/patches/RoF.cpp +++ b/common/patches/RoF.cpp @@ -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())) { diff --git a/common/patches/SoD.cpp b/common/patches/SoD.cpp index 04fb6729a..f0194e459 100644 --- a/common/patches/SoD.cpp +++ b/common/patches/SoD.cpp @@ -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())) { diff --git a/common/patches/SoF.cpp b/common/patches/SoF.cpp index 67610bc30..bfee3014c 100644 --- a/common/patches/SoF.cpp +++ b/common/patches/SoF.cpp @@ -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())) { diff --git a/common/patches/Titanium.cpp b/common/patches/Titanium.cpp index bf92ce3c6..0026d748b 100644 --- a/common/patches/Titanium.cpp +++ b/common/patches/Titanium.cpp @@ -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); diff --git a/common/patches/Underfoot.cpp b/common/patches/Underfoot.cpp index 20c94d253..bc3f8600b 100644 --- a/common/patches/Underfoot.cpp +++ b/common/patches/Underfoot.cpp @@ -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())) { diff --git a/common/perl_EQDBRes.cpp b/common/perl_EQDBRes.cpp index 23837321f..15979c3a7 100644 --- a/common/perl_EQDBRes.cpp +++ b/common/perl_EQDBRes.cpp @@ -139,7 +139,7 @@ XS(XS_EQDBRes_fetch_row_array) Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_array(THIS)"); { EQDBRes * THIS; - vector RETVAL; + std::vector 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 RETVAL; + std::map 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::const_iterator cur, end; + std::map::const_iterator cur, end; cur = RETVAL.begin(); end = RETVAL.end(); for(; cur != end; cur++) { diff --git a/common/ptimer.cpp b/common/ptimer.cpp index d9bfa9428..ce68ecb29 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -289,7 +289,7 @@ PTimerList::PTimerList(uint32 char_id) { } PTimerList::~PTimerList() { - map::iterator s; + std::map::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::iterator s; + std::map::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::iterator s; + std::map::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 > &out) { +void PTimerList::ToVector(std::vector< std::pair > &out) { - pair p; + std::pair p; - map::iterator s; + std::map::iterator s; s = _list.begin(); while(s != _list.end()) { if(s->second != nullptr) { diff --git a/common/ptimer.h b/common/ptimer.h index 56e2aa6a9..829a015b2 100644 --- a/common/ptimer.h +++ b/common/ptimer.h @@ -21,7 +21,6 @@ #include "types.h" #include #include -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 > &out); + void ToVector(std::vector< std::pair > &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::iterator iterator; + typedef std::map::iterator iterator; iterator begin() { return(_list.begin()); } iterator end() { return(_list.end()); } @@ -135,7 +134,7 @@ public: protected: uint32 _char_id; - map _list; + std::map _list; }; //code prettying macros diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 87420550c..887c89c9a 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -17,8 +17,6 @@ #include "faction.h" #include "features.h" -using namespace std; - SharedDatabase::SharedDatabase() : Database(), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr), faction_mmf(nullptr), faction_hash(nullptr), loot_table_mmf(nullptr), loot_drop_mmf(nullptr), loot_table_hash(nullptr), loot_drop_hash(nullptr) @@ -50,7 +48,7 @@ bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme) char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET hideme = %i where id = %i", hideme, account_id), errbuf)) { - cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -85,7 +83,7 @@ uint8 SharedDatabase::GetGMSpeed(uint32 account_id) else { - cerr << "Error in GetGMSpeed query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetGMSpeed query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -101,7 +99,7 @@ bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed) char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET gmspeed = %i where id = %i", gmspeed, account_id), errbuf)) { - cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -140,7 +138,7 @@ uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) { return EntitledTime; } -bool SharedDatabase::SaveCursor(uint32 char_id, list::const_iterator &start, list::const_iterator &end) +bool SharedDatabase::SaveCursor(uint32 char_id, std::list::const_iterator &start, std::list::const_iterator &end) { iter_queue it; int i; @@ -155,7 +153,7 @@ bool ret=true; break; } } else { - cout << "Clearing cursor failed: " << errbuf << endl; + std::cout << "Clearing cursor failed: " << errbuf << std::endl; } safe_delete_array(query); @@ -337,8 +335,7 @@ int32 SharedDatabase::GetSharedPlatinum(uint32 account_id) } else { - - cerr << "Error in GetSharedPlatinum query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetSharedPlatinum query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -352,7 +349,7 @@ bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add) char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i", amount_to_add, account_id), errbuf)) { - cerr << "Error in SetSharedPlatinum query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetSharedPlatinum query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1049,17 +1046,17 @@ const Item_Struct* SharedDatabase::IterateItems(uint32* id) { return nullptr; } -string SharedDatabase::GetBook(const char *txtfile) +std::string SharedDatabase::GetBook(const char *txtfile) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; MYSQL_RES *result; MYSQL_ROW row; char txtfile2[20]; - string txtout; + std::string txtout; strcpy(txtfile2,txtfile); if (!RunQuery(query, MakeAnyLenString(&query, "SELECT txtfile FROM books where name='%s'", txtfile2), errbuf, &result)) { - cerr << "Error in GetBook query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetBook query '" << query << "' " << errbuf << std::endl; if (query != 0) safe_delete_array(query); txtout.assign(" ",1); @@ -1399,7 +1396,7 @@ int32 SharedDatabase::DeleteStalePlayerBackups() { return affected_rows; } -bool SharedDatabase::GetCommandSettings(map &commands) { +bool SharedDatabase::GetCommandSettings(std::map &commands) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; MYSQL_RES *result; @@ -1415,7 +1412,7 @@ bool SharedDatabase::GetCommandSettings(map &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; } @@ -1973,7 +1970,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); } } @@ -1984,7 +1981,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); @@ -2008,7 +2005,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); } } @@ -2019,7 +2016,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); diff --git a/common/shareddb.h b/common/shareddb.h index 33ca3aae0..b60b31111 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -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 &commands); + bool GetCommandSettings(std::map &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 diff --git a/common/timeoutmgr.cpp b/common/timeoutmgr.cpp index cb3ee775b..5874fd3d8 100644 --- a/common/timeoutmgr.cpp +++ b/common/timeoutmgr.cpp @@ -36,7 +36,7 @@ TimeoutManager::TimeoutManager() { } void TimeoutManager::CheckTimeouts() { - vector::iterator cur,end; + std::vector::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::iterator cur,end; + std::vector::iterator cur,end; cur = members.begin(); end = members.end(); for(; cur != end; cur++) { diff --git a/common/timeoutmgr.h b/common/timeoutmgr.h index 43e85a2c2..4e5224a30 100644 --- a/common/timeoutmgr.h +++ b/common/timeoutmgr.h @@ -27,7 +27,6 @@ #include "timer.h" #include -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 members; + std::vector members; }; extern TimeoutManager timeout_manager; diff --git a/common/timer.cpp b/common/timer.cpp index 280c49545..e13fd2a9f 100644 --- a/common/timer.cpp +++ b/common/timer.cpp @@ -24,7 +24,6 @@ #endif #include -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."; diff --git a/common/worldconn.cpp b/common/worldconn.cpp index d6f6cccb3..743ac920e 100644 --- a/common/worldconn.cpp +++ b/common/worldconn.cpp @@ -21,7 +21,6 @@ #include #include #include -using namespace std; #include #include #include diff --git a/eqlaunch/eqlaunch.cpp b/eqlaunch/eqlaunch.cpp index 121fc1b55..63484d6f2 100644 --- a/eqlaunch/eqlaunch.cpp +++ b/eqlaunch/eqlaunch.cpp @@ -30,8 +30,6 @@ #include #include -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 zones; + std::map zones; WorldServer world(zones, launcher_name.c_str(), Config); if (!world.Connect()) { _log(LAUNCHER__ERROR, "worldserver.Connect() FAILED! Will retry."); } - map::iterator zone, zend; - set to_remove; + std::map::iterator zone, zend; + std::set 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()) { diff --git a/eqlaunch/worldserver.cpp b/eqlaunch/worldserver.cpp index d97b5877f..fa49715bf 100644 --- a/eqlaunch/worldserver.cpp +++ b/eqlaunch/worldserver.cpp @@ -22,7 +22,7 @@ #include "../common/EQEmuConfig.h" -WorldServer::WorldServer(map &zones, const char *name, const EQEmuConfig *config) +WorldServer::WorldServer(std::map &zones, const char *name, const EQEmuConfig *config) : WorldConnection(EmuTCPConnection::packetModeLauncher, config->SharedKey.c_str()), m_name(name), m_config(config), @@ -97,7 +97,7 @@ void WorldServer::Process() { break; } case ZR_Restart: { - map::iterator res = m_zones.find(lzr->short_name); + std::map::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 { @@ -107,7 +107,7 @@ void WorldServer::Process() { break; } case ZR_Stop: { - map::iterator res = m_zones.find(lzr->short_name); + std::map::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 { diff --git a/loginserver/Config.cpp b/loginserver/Config.cpp index 419a668d0..338378bc8 100644 --- a/loginserver/Config.cpp +++ b/loginserver/Config.cpp @@ -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 >::iterator iter = vars.find(title); + std::map >::iterator iter = vars.find(title); if(iter != vars.end()) { - map::iterator arg_iter = iter->second.find(parameter); + std::map::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 tokens; + std::list tokens; Tokenize(input, tokens); char mode = 0; - string title, param, arg; - list::iterator iter = tokens.begin(); + std::string title, param, arg; + std::list::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 >::iterator map_iter = vars.find(title); + std::map >::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 var_map; + std::map 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 &tokens) +void Config::Tokenize(FILE *input, std::list &tokens) { char c = fgetc(input); - string lexeme; + std::string lexeme; while(c != EOF) { diff --git a/loginserver/Config.h b/loginserver/Config.h index e00f8447d..36d1feebe 100644 --- a/loginserver/Config.h +++ b/loginserver/Config.h @@ -23,8 +23,6 @@ #include #include -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 > vars; + std::map > 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 &tokens); + void Tokenize(FILE* input, std::list &tokens); }; #endif diff --git a/loginserver/Database.h b/loginserver/Database.h index 318d15793..7244f2e79 100644 --- a/loginserver/Database.h +++ b/loginserver/Database.h @@ -20,8 +20,6 @@ #include -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 diff --git a/loginserver/DatabaseMySQL.h b/loginserver/DatabaseMySQL.h index 21e3f10c4..05af22315 100644 --- a/loginserver/DatabaseMySQL.h +++ b/loginserver/DatabaseMySQL.h @@ -26,8 +26,6 @@ #include #include -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; }; diff --git a/loginserver/Encryption.h b/loginserver/Encryption.h index 907b3e325..7ca2374b2 100644 --- a/loginserver/Encryption.h +++ b/loginserver/Encryption.h @@ -22,8 +22,6 @@ #include #include -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. diff --git a/loginserver/ErrorLog.h b/loginserver/ErrorLog.h index bcc8fb9c7..224eeb352 100644 --- a/loginserver/ErrorLog.h +++ b/loginserver/ErrorLog.h @@ -25,8 +25,6 @@ #include "../common/Mutex.h" -using namespace std; - /** * Dictates the log type specified in ErrorLog for Log(...) */ diff --git a/loginserver/Main.cpp b/loginserver/Main.cpp index fa127673f..54a3e9ba4 100644 --- a/loginserver/Main.cpp +++ b/loginserver/Main.cpp @@ -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_.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); diff --git a/loginserver/Options.h b/loginserver/Options.h index 38d5d109f..76fe22e1d 100644 --- a/loginserver/Options.h +++ b/loginserver/Options.h @@ -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 diff --git a/loginserver/ServerManager.h b/loginserver/ServerManager.h index aac10f09e..cf15522db 100644 --- a/loginserver/ServerManager.h +++ b/loginserver/ServerManager.h @@ -28,8 +28,6 @@ #include "Client.h" #include -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 world_servers; + std::list world_servers; }; #endif diff --git a/loginserver/WorldServer.h b/loginserver/WorldServer.h index 4ee5b19bb..2b8b6ff61 100644 --- a/loginserver/WorldServer.h +++ b/loginserver/WorldServer.h @@ -26,8 +26,6 @@ #include "../common/packet_dump.h" #include -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; diff --git a/queryserv/database.cpp b/queryserv/database.cpp index 1cfd41f44..88842384f 100644 --- a/queryserv/database.cpp +++ b/queryserv/database.cpp @@ -20,7 +20,6 @@ #include "../common/debug.h" #include -using namespace std; #include #include #include diff --git a/queryserv/database.h b/queryserv/database.h index f1f364025..61664f90d 100644 --- a/queryserv/database.h +++ b/queryserv/database.h @@ -31,7 +31,6 @@ #include #include #include -using namespace std; //atoi is not uint32 or uint32 safe!!!! #define atoul(str) strtoul(str, nullptr, 10) diff --git a/queryserv/queryserv.cpp b/queryserv/queryserv.cpp index 2154f396d..ce008a7f3 100644 --- a/queryserv/queryserv.cpp +++ b/queryserv/queryserv.cpp @@ -40,7 +40,7 @@ TimeoutManager timeout_manager; Database database; LFGuildManager lfguildmanager; -string WorldShortName; +std::string WorldShortName; const queryservconfig *Config; diff --git a/queryserv/queryservconfig.cpp b/queryserv/queryservconfig.cpp index 6088806f4..0c44a7c87 100644 --- a/queryserv/queryservconfig.cpp +++ b/queryserv/queryservconfig.cpp @@ -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)); } diff --git a/queryserv/queryservconfig.h b/queryserv/queryservconfig.h index e4bdcf5ba..e28f6b02a 100644 --- a/queryserv/queryservconfig.h +++ b/queryserv/queryservconfig.h @@ -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: diff --git a/queryserv/worldserver.cpp b/queryserv/worldserver.cpp index 4486a38fd..bb7523592 100644 --- a/queryserv/worldserver.cpp +++ b/queryserv/worldserver.cpp @@ -17,7 +17,6 @@ */ #include "../common/debug.h" #include -using namespace std; #include #include #include @@ -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; diff --git a/ucs/chatchannel.cpp b/ucs/chatchannel.cpp index 140ccdb68..494dfaef9 100644 --- a/ucs/chatchannel.cpp +++ b/ucs/chatchannel.cpp @@ -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 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::iterator Iterator; + std::list::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::iterator Iterator; + std::list::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::iterator Iterator; + std::list::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::iterator Iterator; + std::list::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::iterator Iterator; + std::list::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::iterator Iterator; + std::list::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::iterator Iterator; + std::list::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++) { diff --git a/ucs/chatchannel.h b/ucs/chatchannel.h index e18a831b8..39fb24c8b 100644 --- a/ucs/chatchannel.h +++ b/ucs/chatchannel.h @@ -7,15 +7,13 @@ #include #include -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 ClientsInChannel; - list Moderators; - list Invitees; - list Voiced; + std::list Moderators; + std::list Invitees; + std::list 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 diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index 4c57190c8..db1f8ef5d 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -33,11 +33,9 @@ #include #include -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 ParseRecipients(string RecipientString) { +std::vector 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 ParseRecipients(string RecipientString) { // // The '-' prefix indicates 'Secret To' (like BCC:) // - vector RecipientList; + std::vector 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 ParseRecipients(string RecipientString) { CurrentPos = Comma + 2; } - vector::iterator Iterator; + std::vector::iterator Iterator; Iterator = RecipientList.begin(); @@ -152,27 +150,27 @@ vector 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 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 ParseRecipients(string RecipientString) { sort(RecipientList.begin(), RecipientList.end()); - vector::iterator new_end_pos = unique(RecipientList.begin(), RecipientList.end()); + std::vector::iterator new_end_pos = unique(RecipientList.begin(), RecipientList.end()); RecipientList.erase(new_end_pos, RecipientList.end()); @@ -235,27 +233,27 @@ vector 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 Recipients; + std::vector 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.. // - 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::iterator Iterator; + std::list::iterator Iterator; for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) { @@ -596,7 +594,7 @@ void Clientlist::Process() { ClientChatConnections.push_back(c); } - list::iterator Iterator; + std::list::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.. // - 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::iterator Iterator; + std::list::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::iterator Iterator; + std::list::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 "; + if(PasswordStart == std::string::npos) { + std::string Message = "Incorrect syntax: /chat password "; 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 "; + if(Space == std::string::npos) { + std::string Message = "Incorrect syntax: /chat password "; 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 "; + if(ChannelStart == std::string::npos) { + std::string Message = "Incorrect syntax: /chat password "; 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 "; + if(PlayerStart == std::string::npos) { + std::string Message = "Incorrect syntax: /chat setowner "; 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 "; + if(Space == std::string::npos) { + std::string Message = "Incorrect syntax: /chat setowner "; 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 "; + if(ChannelStart == std::string::npos) { + std::string Message = "Incorrect syntax: /chat setowner "; 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 "; + if(ChannelStart == std::string::npos) { + std::string Message = "Incorrect syntax: /chat oplist "; 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 "; + if(PlayerStart == std::string::npos) { + std::string Message = "Incorrect syntax: /chat invite "; 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 "; + if(Space == std::string::npos) { + std::string Message = "Incorrect syntax: /chat invite "; 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 "; + if(ChannelStart == std::string::npos) { + std::string Message = "Incorrect syntax: /chat invite "; 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 "; + std::string Message = "Incorrect syntax: /chat moderate "; 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 "); 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 "); 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 "); 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 "); 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 "); 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 "); 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 "); 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 "); 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 "); 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::iterator Iterator; + std::list::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 Friends, Ignorees; + std::vector Friends, Ignorees; database.GetFriendsAndIgnore(GetCharID(), Friends, Ignorees); EQApplicationPacket *outapp; - vector::iterator Iterator; + std::vector::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))) { diff --git a/ucs/clientlist.h b/ucs/clientlist.h index 1876ec58b..b8a1609ea 100644 --- a/ucs/clientlist.h +++ b/ucs/clientlist.h @@ -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 Characters; + std::vector 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 ClientChatConnections; + std::list ClientChatConnections; OpcodeManager *ChatOpMgr; }; diff --git a/ucs/database.cpp b/ucs/database.cpp index 9f349b82a..eaac658c0 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -20,7 +20,6 @@ #include "../common/debug.h" #include -using namespace std; #include #include #include @@ -48,7 +47,7 @@ using namespace std; #include "chatchannel.h" extern Clientlist *CL; -extern string GetMailPrefix(); +extern std::string GetMailPrefix(); extern ChatChannelList *ChannelList; extern uint32 MailMessagesSent; @@ -190,7 +189,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; @@ -328,9 +327,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])); } @@ -340,7 +339,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()); @@ -357,7 +356,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()); @@ -541,17 +540,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); @@ -604,7 +603,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); } @@ -691,7 +690,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')"; @@ -709,7 +708,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'"; @@ -726,7 +725,7 @@ void Database::RemoveFriendOrIgnore(int CharID, int Type, string Name) { safe_delete_array(query); } -void Database::GetFriendsAndIgnore(int CharID, vector &Friends, vector &Ignorees) { +void Database::GetFriendsAndIgnore(int CharID, std::vector &Friends, std::vector &Ignorees) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; @@ -748,7 +747,7 @@ void Database::GetFriendsAndIgnore(int CharID, vector &Friends, vector #include #include -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 &Friends, vector &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 &Friends, std::vector &Ignorees); protected: diff --git a/ucs/ucs.cpp b/ucs/ucs.cpp index 56f274209..bb2e483bb 100644 --- a/ucs/ucs.cpp +++ b/ucs/ucs.cpp @@ -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 + "."; diff --git a/ucs/ucsconfig.cpp b/ucs/ucsconfig.cpp index 59a589a1b..4f055a6af 100644 --- a/ucs/ucsconfig.cpp +++ b/ucs/ucsconfig.cpp @@ -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)); } diff --git a/ucs/ucsconfig.h b/ucs/ucsconfig.h index 85f836464..6c4fb8579 100644 --- a/ucs/ucsconfig.h +++ b/ucs/ucsconfig.h @@ -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: diff --git a/ucs/worldserver.cpp b/ucs/worldserver.cpp index 1bd93bfc0..7e243a467 100644 --- a/ucs/worldserver.cpp +++ b/ucs/worldserver.cpp @@ -17,7 +17,6 @@ */ #include "../common/debug.h" #include -using namespace std; #include #include #include @@ -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; } } diff --git a/world/Adventure.cpp b/world/Adventure.cpp index c5542f7be..abd9800a6 100644 --- a/world/Adventure.cpp +++ b/world/Adventure.cpp @@ -49,7 +49,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)) { @@ -62,9 +62,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::iterator iter = players.begin(); + std::list::iterator iter = players.begin(); while(iter != players.end()) { if((*iter).compare(character_name) == 0) @@ -77,9 +77,9 @@ void Adventure::RemovePlayer(string character_name) } } -bool Adventure::PlayerExists(string character_name) +bool Adventure::PlayerExists(std::string character_name) { - list::iterator iter = players.begin(); + std::list::iterator iter = players.begin(); while(iter != players.end()) { if(character_name.compare((*iter)) == 0) @@ -209,7 +209,7 @@ void Adventure::SetStatus(AdventureStatus new_status) return; } - list::iterator iter = players.begin(); + std::list::iterator iter = players.begin(); while(iter != players.end()) { adventure_manager.GetAdventureData((*iter).c_str()); @@ -223,7 +223,7 @@ void Adventure::SendAdventureMessage(uint32 type, const char *msg) ServerEmoteMessage_Struct *sms = (ServerEmoteMessage_Struct*)pack->pBuffer; sms->type = type; strcpy(sms->message, msg); - list::iterator iter = players.begin(); + std::list::iterator iter = players.begin(); while(iter != players.end()) { ClientListEntry *current = client_list.FindCharacter((*iter).c_str()); @@ -277,7 +277,7 @@ void Adventure::IncrementAssassinationCount() void Adventure::Finished(AdventureWinStatus ws) { - list::iterator iter = players.begin(); + std::list::iterator iter = players.begin(); while(iter != players.end()) { ClientListEntry *current = client_list.FindCharacter((*iter).c_str()); @@ -371,8 +371,8 @@ void Adventure::MoveCorpsesToGraveyard() return; } - list dbid_list; - list charid_list; + std::list dbid_list; + std::list charid_list; char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; @@ -394,7 +394,7 @@ void Adventure::MoveCorpsesToGraveyard() safe_delete_array(query); } - list::iterator iter = dbid_list.begin(); + std::list::iterator iter = dbid_list.begin(); while(iter != dbid_list.end()) { float x = GetTemplate()->graveyard_x + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius); @@ -414,7 +414,7 @@ void Adventure::MoveCorpsesToGraveyard() } iter = dbid_list.begin(); - list::iterator c_iter = charid_list.begin(); + std::list::iterator c_iter = charid_list.begin(); while(iter != dbid_list.end()) { ServerPacket* pack = new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct)); diff --git a/world/Adventure.h b/world/Adventure.h index ebb8d2b83..cb14609ae 100644 --- a/world/Adventure.h +++ b/world/Adventure.h @@ -9,8 +9,6 @@ #include #include -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 GetPlayers() { return players; } + std::list 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 players; + std::list players; Timer *current_timer; int instance_id; }; diff --git a/world/AdventureManager.cpp b/world/AdventureManager.cpp index 4a8321a4d..115b426ba 100644 --- a/world/AdventureManager.cpp +++ b/world/AdventureManager.cpp @@ -32,7 +32,7 @@ void AdventureManager::Process() { if(process_timer->Check()) { - list::iterator iter = adventure_list.begin(); + std::list::iterator iter = adventure_list.begin(); while(iter != adventure_list.end()) { if(!(*iter)->Process()) @@ -70,7 +70,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data) /** * This block checks to see if we actually have any adventures for the requested theme. */ - map >::iterator adv_list_iter = adventure_entries.find(sar->template_id); + std::map >::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)); @@ -88,7 +88,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::iterator iter = adventure_list.begin(); + std::list::iterator iter = adventure_list.begin(); while(iter != adventure_list.end()) { Adventure* current = (*iter); @@ -102,7 +102,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()); @@ -120,8 +120,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 excluded_zones; - list excluded_zone_ins; + std::list excluded_zones; + std::list excluded_zone_ins; for(int i = 0; i < sar->member_count; ++i) { int finished_adventures_count; @@ -147,12 +147,12 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data) safe_delete_array(finished_adventures); } - list eligible_adventures = adventure_entries[sar->template_id]; + std::list 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::iterator ea_iter = eligible_adventures.begin(); + std::list::iterator ea_iter = eligible_adventures.begin(); while(ea_iter != eligible_adventures.end()) { if((*ea_iter)->is_hard != ((sar->risk == 2) ? true : false)) @@ -252,7 +252,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()); @@ -265,10 +265,10 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data) /** * Remove the zones from our eligible zones based on the exclusion above */ - list::iterator ez_iter = excluded_zones.begin(); + std::list::iterator ez_iter = excluded_zones.begin(); while(ez_iter != excluded_zones.end()) { - list::iterator ea_iter = eligible_adventures.begin(); + std::list::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) @@ -281,10 +281,10 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data) ez_iter++; } - list::iterator ezi_iter = excluded_zone_ins.begin(); + std::list::iterator ezi_iter = excluded_zone_ins.begin(); while(ezi_iter != excluded_zone_ins.end()) { - list::iterator ea_iter = eligible_adventures.begin(); + std::list::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) @@ -447,8 +447,8 @@ void AdventureManager::TryAdventureCreate(const char *data) void AdventureManager::GetAdventureData(Adventure *adv) { - list player_list = adv->GetPlayers(); - list::iterator iter = player_list.begin(); + std::list player_list = adv->GetPlayers(); + std::list::iterator iter = player_list.begin(); while(iter != player_list.end()) { GetAdventureData((*iter).c_str()); @@ -523,9 +523,9 @@ void AdventureManager::GetAdventureData(const char *name) } } -bool AdventureManager::IsInExcludedZoneList(list excluded_zones, string zone_name, int version) +bool AdventureManager::IsInExcludedZoneList(std::list excluded_zones, std::string zone_name, int version) { - list::iterator iter = excluded_zones.begin(); + std::list::iterator iter = excluded_zones.begin(); while(iter != excluded_zones.end()) { if(((*iter).zone.compare(zone_name) == 0) && ((*iter).version == version)) @@ -537,9 +537,9 @@ bool AdventureManager::IsInExcludedZoneList(list excluded_zones, return false; } -bool AdventureManager::IsInExcludedZoneInList(list excluded_zone_ins, int zone_id, int door_object) +bool AdventureManager::IsInExcludedZoneInList(std::list excluded_zone_ins, int zone_id, int door_object) { - list::iterator iter = excluded_zone_ins.begin(); + std::list::iterator iter = excluded_zone_ins.begin(); while(iter != excluded_zone_ins.end()) { if(((*iter).zone_id == zone_id) && ((*iter).door_id == door_object)) @@ -556,7 +556,7 @@ Adventure **AdventureManager::GetFinishedAdventures(const char *player, int &cou Adventure **ret = nullptr; count = 0; - list::iterator iter = adventure_list.begin(); + std::list::iterator iter = adventure_list.begin(); while(iter != adventure_list.end()) { if((*iter)->PlayerExists(player)) @@ -589,7 +589,7 @@ Adventure **AdventureManager::GetFinishedAdventures(const char *player, int &cou Adventure *AdventureManager::GetActiveAdventure(const char *player) { - list::iterator iter = adventure_list.begin(); + std::list::iterator iter = adventure_list.begin(); while(iter != adventure_list.end()) { if((*iter)->PlayerExists(player) && (*iter)->IsActive()) @@ -603,13 +603,13 @@ Adventure *AdventureManager::GetActiveAdventure(const char *player) AdventureTemplate *AdventureManager::GetAdventureTemplate(int theme, int id) { - map >::iterator iter = adventure_entries.find(theme); + std::map >::iterator iter = adventure_entries.find(theme); if(iter == adventure_entries.end()) { return nullptr; } - list::iterator l_iter = (*iter).second.begin(); + std::list::iterator l_iter = (*iter).second.begin(); while(l_iter != (*iter).second.end()) { if((*l_iter)->id == id) @@ -623,7 +623,7 @@ AdventureTemplate *AdventureManager::GetAdventureTemplate(int theme, int id) AdventureTemplate *AdventureManager::GetAdventureTemplate(int id) { - map::iterator iter = adventure_templates.find(id); + std::map::iterator iter = adventure_templates.find(id); if(iter == adventure_templates.end()) { return nullptr; @@ -712,7 +712,7 @@ bool AdventureManager::LoadAdventureEntries() int template_id = atoi(row[1]); AdventureTemplate* tid = nullptr; - map::iterator t_iter = adventure_templates.find(template_id); + std::map::iterator t_iter = adventure_templates.find(template_id); if(t_iter == adventure_templates.end()) { continue; @@ -722,8 +722,8 @@ bool AdventureManager::LoadAdventureEntries() tid = adventure_templates[template_id]; } - list temp; - map >::iterator iter = adventure_entries.find(id); + std::list temp; + std::map >::iterator iter = adventure_entries.find(id); if(iter == adventure_entries.end()) { temp.push_back(tid); @@ -751,7 +751,7 @@ bool AdventureManager::LoadAdventureEntries() void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int door_id) { - list::iterator iter = adventure_list.begin(); + std::list::iterator iter = adventure_list.begin(); while(iter != adventure_list.end()) { const AdventureTemplate *t = (*iter)->GetTemplate(); @@ -841,7 +841,7 @@ void AdventureManager::LeaveAdventure(const char *name) void AdventureManager::IncrementCount(uint16 instance_id) { - list::iterator iter = adventure_list.begin(); + std::list::iterator iter = adventure_list.begin(); Adventure *current = nullptr; while(iter != adventure_list.end()) { @@ -856,8 +856,8 @@ void AdventureManager::IncrementCount(uint16 instance_id) if(current) { current->IncrementCount(); - list slist = current->GetPlayers(); - list::iterator siter = slist.begin(); + std::list slist = current->GetPlayers(); + std::list::iterator siter = slist.begin(); ServerPacket *pack = new ServerPacket(ServerOP_AdventureCountUpdate, sizeof(ServerAdventureCountUpdate_Struct)); ServerAdventureCountUpdate_Struct *ac = (ServerAdventureCountUpdate_Struct*)pack->pBuffer; ac->count = current->GetCount(); @@ -881,7 +881,7 @@ void AdventureManager::IncrementCount(uint16 instance_id) void AdventureManager::IncrementAssassinationCount(uint16 instance_id) { - list::iterator iter = adventure_list.begin(); + std::list::iterator iter = adventure_list.begin(); Adventure *current = nullptr; while(iter != adventure_list.end()) { @@ -902,7 +902,7 @@ void AdventureManager::IncrementAssassinationCount(uint16 instance_id) void AdventureManager::GetZoneData(uint16 instance_id) { - list::iterator iter = adventure_list.begin(); + std::list::iterator iter = adventure_list.begin(); Adventure *current = nullptr; while(iter != adventure_list.end()) { @@ -1282,7 +1282,7 @@ void AdventureManager::DoLeaderboardRequestWins(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_wins.begin(); + std::list::iterator iter = leaderboard_info_wins.begin(); while(i < 100 && iter != leaderboard_info_wins.end()) { LeaderboardInfo li = (*iter); @@ -1349,7 +1349,7 @@ void AdventureManager::DoLeaderboardRequestPercentage(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_percentage.begin(); + std::list::iterator iter = leaderboard_info_percentage.begin(); while(i < 100 && iter != leaderboard_info_percentage.end()) { LeaderboardInfo li = (*iter); @@ -1416,7 +1416,7 @@ void AdventureManager::DoLeaderboardRequestWinsGuk(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_wins_guk.begin(); + std::list::iterator iter = leaderboard_info_wins_guk.begin(); while(i < 100 && iter != leaderboard_info_wins_guk.end()) { LeaderboardInfo li = (*iter); @@ -1483,7 +1483,7 @@ void AdventureManager::DoLeaderboardRequestPercentageGuk(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_percentage_guk.begin(); + std::list::iterator iter = leaderboard_info_percentage_guk.begin(); while(i < 100 && iter != leaderboard_info_percentage_guk.end()) { LeaderboardInfo li = (*iter); @@ -1550,7 +1550,7 @@ void AdventureManager::DoLeaderboardRequestWinsMir(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_wins_mir.begin(); + std::list::iterator iter = leaderboard_info_wins_mir.begin(); while(i < 100 && iter != leaderboard_info_wins_mir.end()) { LeaderboardInfo li = (*iter); @@ -1617,7 +1617,7 @@ void AdventureManager::DoLeaderboardRequestPercentageMir(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_percentage_mir.begin(); + std::list::iterator iter = leaderboard_info_percentage_mir.begin(); while(i < 100 && iter != leaderboard_info_percentage_mir.end()) { LeaderboardInfo li = (*iter); @@ -1684,7 +1684,7 @@ void AdventureManager::DoLeaderboardRequestWinsMmc(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_wins_mmc.begin(); + std::list::iterator iter = leaderboard_info_wins_mmc.begin(); while(i < 100 && iter != leaderboard_info_wins_mmc.end()) { LeaderboardInfo li = (*iter); @@ -1751,7 +1751,7 @@ void AdventureManager::DoLeaderboardRequestPercentageMmc(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_percentage_mmc.begin(); + std::list::iterator iter = leaderboard_info_percentage_mmc.begin(); while(i < 100 && iter != leaderboard_info_percentage_mmc.end()) { LeaderboardInfo li = (*iter); @@ -1818,7 +1818,7 @@ void AdventureManager::DoLeaderboardRequestWinsRuj(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_wins_ruj.begin(); + std::list::iterator iter = leaderboard_info_wins_ruj.begin(); while(i < 100 && iter != leaderboard_info_wins_ruj.end()) { LeaderboardInfo li = (*iter); @@ -1885,7 +1885,7 @@ void AdventureManager::DoLeaderboardRequestPercentageRuj(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_percentage_ruj.begin(); + std::list::iterator iter = leaderboard_info_percentage_ruj.begin(); while(i < 100 && iter != leaderboard_info_percentage_ruj.end()) { LeaderboardInfo li = (*iter); @@ -1952,7 +1952,7 @@ void AdventureManager::DoLeaderboardRequestWinsTak(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_wins_ruj.begin(); + std::list::iterator iter = leaderboard_info_wins_ruj.begin(); while(i < 100 && iter != leaderboard_info_wins_ruj.end()) { LeaderboardInfo li = (*iter); @@ -2019,7 +2019,7 @@ void AdventureManager::DoLeaderboardRequestPercentageTak(const char* player) int our_successes; int our_failures; int i = 0; - list::iterator iter = leaderboard_info_percentage_tak.begin(); + std::list::iterator iter = leaderboard_info_percentage_tak.begin(); while(i < 100 && iter != leaderboard_info_percentage_tak.end()) { LeaderboardInfo li = (*iter); @@ -2075,7 +2075,7 @@ void AdventureManager::DoLeaderboardRequestPercentageTak(const char* player) bool AdventureManager::PopFinishedEvent(const char *name, AdventureFinishEvent &fe) { - list::iterator iter = finished_list.begin(); + std::list::iterator iter = finished_list.begin(); while(iter != finished_list.end()) { if((*iter).name.compare(name) == 0) @@ -2115,13 +2115,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::iterator a_iter = adventure_list.begin(); + std::list::iterator a_iter = adventure_list.begin(); while(a_iter != adventure_list.end()) { int cur = (*a_iter)->GetCount(); @@ -2142,11 +2142,11 @@ void AdventureManager::Save() cur = (*a_iter)->GetRemainingTime(); ss.write((const char*)&cur, sizeof(int)); - list players = (*a_iter)->GetPlayers(); + std::list players = (*a_iter)->GetPlayers(); cur = players.size(); ss.write((const char*)&cur, sizeof(int)); - list::iterator s_iter = players.begin(); + std::list::iterator s_iter = players.begin(); while(s_iter != players.end()) { ss.write((const char*)(*s_iter).c_str(), (*s_iter).size()); @@ -2159,7 +2159,7 @@ void AdventureManager::Save() number_of_elements = finished_list.size(); ss.write((const char*)&number_of_elements, sizeof(int)); - list::iterator f_iter = finished_list.begin(); + std::list::iterator f_iter = finished_list.begin(); while(f_iter != finished_list.end()) { ss.write((const char*)&(*f_iter).win, sizeof(bool)); diff --git a/world/AdventureManager.h b/world/AdventureManager.h index 716458f3e..e7055ac8d 100644 --- a/world/AdventureManager.h +++ b/world/AdventureManager.h @@ -9,8 +9,6 @@ #include #include -using namespace std; - class AdventureManager { public: @@ -44,8 +42,8 @@ public: AdventureTemplate *GetAdventureTemplate(int id); void GetZoneData(uint16 instance_id); protected: - bool IsInExcludedZoneList(list excluded_zones, string zone_name, int version); - bool IsInExcludedZoneInList(list excluded_zone_ins, int zone_id, int door_object); + bool IsInExcludedZoneList(std::list excluded_zones, std::string zone_name, int version); + bool IsInExcludedZoneInList(std::list 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 adventure_templates; - map > adventure_entries; - list adventure_list; - list finished_list; - list leaderboard_info_wins; - list leaderboard_info_percentage; - list leaderboard_info_wins_guk; - list leaderboard_info_percentage_guk; - list leaderboard_info_wins_mir; - list leaderboard_info_percentage_mir; - list leaderboard_info_wins_mmc; - list leaderboard_info_percentage_mmc; - list leaderboard_info_wins_ruj; - list leaderboard_info_percentage_ruj; - list leaderboard_info_wins_tak; - list leaderboard_info_percentage_tak; + std::map adventure_templates; + std::map > adventure_entries; + std::list adventure_list; + std::list finished_list; + std::list leaderboard_info_wins; + std::list leaderboard_info_percentage; + std::list leaderboard_info_wins_guk; + std::list leaderboard_info_percentage_guk; + std::list leaderboard_info_wins_mir; + std::list leaderboard_info_percentage_mir; + std::list leaderboard_info_wins_mmc; + std::list leaderboard_info_percentage_mmc; + std::list leaderboard_info_wins_ruj; + std::list leaderboard_info_percentage_ruj; + std::list leaderboard_info_wins_tak; + std::list 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 \ No newline at end of file +#endif diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index 09ebf52b6..09c104fa9 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -96,7 +96,7 @@ EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) { } void EQLConfig::GetZones(std::vector &result) { - map::iterator cur, end; + std::map::iterator cur, end; cur = m_zones.begin(); end = m_zones.end(); for(; cur != end; cur++) { @@ -104,12 +104,12 @@ void EQLConfig::GetZones(std::vector &result) { } } -vector EQLConfig::ListZones() { +std::vector EQLConfig::ListZones() { LauncherLink *ll = launcher_list.Get(m_name.c_str()); - vector res; + std::vector res; if(ll == nullptr) { //if the launcher isnt connected, use the list from the database. - map::iterator cur, end; + std::map::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::iterator res; + std::map::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::iterator res; + std::map::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 EQLConfig::GetZoneDetails(Const_char *zone_ref) { - map res; +std::map EQLConfig::GetZoneDetails(Const_char *zone_ref) { + std::map res; LauncherLink *ll = launcher_list.Get(m_name.c_str()); if(ll == nullptr) { diff --git a/world/EQLConfig.h b/world/EQLConfig.h index f4d1a4488..2702abdbc 100644 --- a/world/EQLConfig.h +++ b/world/EQLConfig.h @@ -23,8 +23,6 @@ #include #include -using namespace std; - class LauncherLink; typedef struct { @@ -60,16 +58,16 @@ public: bool SetDynamicCount(int count); int GetDynamicCount() const; - vector ListZones(); //returns an array of zone refs - map GetZoneDetails(Const_char *zone_ref); + std::vector ListZones(); //returns an array of zone refs + std::map GetZoneDetails(Const_char *zone_ref); //END PERL EXPORT protected: - const string m_name; + const std::string m_name; uint8 m_dynamics; - map m_zones; //static zones. + std::map m_zones; //static zones. }; #endif /*EQLCONFIG_H_*/ diff --git a/world/EQW.cpp b/world/EQW.cpp index 5746f06c0..25569e3e3 100644 --- a/world/EQW.cpp +++ b/world/EQW.cpp @@ -38,16 +38,12 @@ #include "LauncherLink.h" #include "wguild_mgr.h" - #ifdef seed #undef seed #endif - #include -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 EQW::ListBootedZones() { - vector res; +std::vector EQW::ListBootedZones() { + std::vector res; - vector zones; + std::vector zones; zoneserver_list.GetZoneIDList(zones); - vector::iterator cur, end; + std::vector::iterator cur, end; cur = zones.begin(); end = zones.end(); for(; cur != end; cur++) { @@ -131,8 +127,8 @@ vector EQW::ListBootedZones() { return(res); } -map EQW::GetZoneDetails(Const_char *zone_ref) { - map res; +std::map EQW::GetZoneDetails(Const_char *zone_ref) { + std::map 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 EQW::ListPlayers(Const_char *zone_name) { - vector res; +std::vector EQW::ListPlayers(Const_char *zone_name) { + std::vector res; - vector list; + std::vector list; client_list.GetClients(zone_name, list); - vector::iterator cur, end; + std::vector::iterator cur, end; cur = list.begin(); end = list.end(); for(; cur != end; cur++) { @@ -180,8 +176,8 @@ vector EQW::ListPlayers(Const_char *zone_name) { return(res); } -map EQW::GetPlayerDetails(Const_char *char_name) { - map res; +std::map EQW::GetPlayerDetails(Const_char *char_name) { + std::map 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 it(EQW::ListLaunchers()); + std::vector it(EQW::ListLaunchers()); return(it.size()); } /* @@ -223,10 +219,10 @@ vector EQW::ListActiveLaunchers() { return(launchers); }*/ -vector EQW::ListLaunchers() { +std::vector EQW::ListLaunchers() { // vector list; // database.GetLauncherList(list); - vector launchers; + std::vector launchers; launcher_list.GetLauncherNameList(launchers); return(launchers); @@ -405,8 +401,8 @@ int EQW::CountBugs() { return 0; } -vector EQW::ListBugs(uint32 offset) { - vector res; +std::vector EQW::ListBugs(uint32 offset) { + std::vector res; char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; @@ -422,8 +418,8 @@ vector EQW::ListBugs(uint32 offset) { return res; } -map EQW::GetBugDetails(Const_char *id) { - map res; +std::map EQW::GetBugDetails(Const_char *id) { + std::map res; char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; @@ -447,7 +443,7 @@ map EQW::GetBugDetails(Const_char *id) { } void EQW::ResolveBug(const char *id) { - vector res; + std::vector 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)) { diff --git a/world/EQW.h b/world/EQW.h index d08a5bf4b..0f3cc14ab 100644 --- a/world/EQW.h +++ b/world/EQW.h @@ -22,7 +22,6 @@ #include #include #include "../common/types.h" -using namespace std; class EQLConfig; @@ -46,16 +45,16 @@ public: void LSReconnect(); int CountZones(); - vector ListBootedZones(); //returns an array of zone_refs (opaque) - map GetZoneDetails(Const_char *zone_ref); //returns a hash ref of details + std::vector ListBootedZones(); //returns an array of zone_refs (opaque) + std::map GetZoneDetails(Const_char *zone_ref); //returns a hash ref of details int CountPlayers(); - vector ListPlayers(Const_char *zone_name = ""); //returns an array of player refs (opaque) - map GetPlayerDetails(Const_char *player_ref); //returns a hash ref of details + std::vector ListPlayers(Const_char *zone_name = ""); //returns an array of player refs (opaque) + std::map GetPlayerDetails(Const_char *player_ref); //returns a hash ref of details int CountLaunchers(bool active_only); // vector ListActiveLaunchers(); //returns an array of launcher names - vector ListLaunchers(); //returns an array of launcher names + std::vector 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 ListBugs(uint32 offset); //returns an array of zone_refs (opaque) - map GetBugDetails(const char *id); + std::vector ListBugs(uint32 offset); //returns an array of zone_refs (opaque) + std::map GetBugDetails(const char *id); void ResolveBug(const char *id); void SendMessage(uint32 type, const char *msg); diff --git a/world/EQWHTTPHandler.cpp b/world/EQWHTTPHandler.cpp index 7b47ad30f..f3126e6a3 100644 --- a/world/EQWHTTPHandler.cpp +++ b/world/EQWHTTPHandler.cpp @@ -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("", 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(); diff --git a/world/EQWParser.cpp b/world/EQWParser.cpp index bdeedca2c..840c01fe3 100644 --- a/world/EQWParser.cpp +++ b/world/EQWParser.cpp @@ -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 &args, string &error, int mode) { +bool EQWParser::dosub(const char * subname, const std::vector &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 &args return(true); } -bool EQWParser::eval(const char * code, string &error) { +bool EQWParser::eval(const char * code, std::string &error) { std::vector 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()); } diff --git a/world/HTTPRequest.cpp b/world/HTTPRequest.cpp index bc0b8ab2b..b05aa5d66 100644 --- a/world/HTTPRequest.cpp +++ b/world/HTTPRequest.cpp @@ -22,12 +22,10 @@ #include "../common/SocketLib/HttpdForm.h" #include -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 HTTPRequest::get_all() const { +std::map HTTPRequest::get_all() const { return m_values; } diff --git a/world/HTTPRequest.h b/world/HTTPRequest.h index 1fd96eadf..907d75ebd 100644 --- a/world/HTTPRequest.h +++ b/world/HTTPRequest.h @@ -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 get_all() const; + std::map get_all() const; void redirect(Const_char *URL); void SetResponseCode(Const_char *code); diff --git a/world/LauncherLink.cpp b/world/LauncherLink.cpp index ad580beab..506173b9e 100644 --- a/world/LauncherLink.cpp +++ b/world/LauncherLink.cpp @@ -30,11 +30,9 @@ #include #include -using namespace std; extern LauncherList launcher_list; - LauncherLink::LauncherLink(int id, EmuTCPConnection *c) : ID(id), tcpc(c), diff --git a/world/LauncherList.cpp b/world/LauncherList.cpp index d55990e7f..b939273c7 100644 --- a/world/LauncherList.cpp +++ b/world/LauncherList.cpp @@ -23,29 +23,27 @@ #include "../common/logsys.h" #include "EQLConfig.h" -using namespace std; - LauncherList::LauncherList() : nextID(1) { } LauncherList::~LauncherList() { - vector::iterator cur, end; + std::vector::iterator cur, end; cur = m_pendingLaunchers.begin(); end = m_pendingLaunchers.end(); for(; cur != end; cur++) { delete *cur; } - map::iterator curc, endc; + std::map::iterator curc, endc; curc = m_configs.begin(); endc = m_configs.end(); for(; curc != endc; curc++) { delete curc->second; } - map::iterator curl, endl; + std::map::iterator curl, endl; curl = m_launchers.begin(); endl = m_launchers.end(); for(; curl != endl; curl++) { @@ -55,7 +53,7 @@ LauncherList::~LauncherList() { void LauncherList::Process() { //process pending launchers.. - vector::iterator cur, end; + std::vector::iterator cur, end; cur = m_pendingLaunchers.begin(); while(cur != m_pendingLaunchers.end()) { LauncherLink *l = *cur; @@ -69,9 +67,9 @@ void LauncherList::Process() { //launcher has identified itself now. //remove ourself from the pending list cur = m_pendingLaunchers.erase(cur); - string name = l->GetName(); + std::string name = l->GetName(); //kill off anybody else using our name. - map::iterator res; + std::map::iterator res; res = m_launchers.find(name); if(res != m_launchers.end()) { _log(WORLD__LAUNCH, "Ghosting launcher %s", name.c_str()); @@ -86,7 +84,7 @@ void LauncherList::Process() { } //process active launchers. - map::iterator curl, tmp; + std::map::iterator curl, tmp; curl = m_launchers.begin(); while(curl != m_launchers.end()) { LauncherLink *l = curl->second; @@ -105,14 +103,14 @@ void LauncherList::Process() { } LauncherLink *LauncherList::Get(const char *name) { - map::iterator res; + std::map::iterator res; res = m_launchers.find(name); if(res == m_launchers.end()) return(nullptr); return(res->second); -/* string goal(name); +/* std::string goal(name); - vector::iterator cur, end; + std::vector::iterator cur, end; cur = m_launchers.begin(); end = m_launchers.end(); for(; cur != end; cur++) { @@ -123,7 +121,7 @@ LauncherLink *LauncherList::Get(const char *name) { } LauncherLink *LauncherList::FindByZone(const char *short_name) { - map::iterator cur, end; + std::map::iterator cur, end; cur = m_launchers.begin(); end = m_launchers.end(); for(; cur != end; cur++) { @@ -144,8 +142,8 @@ int LauncherList::GetLauncherCount() { return(m_launchers.size()); } -void LauncherList::GetLauncherNameList(std::vector &res) { - map::iterator cur, end; +void LauncherList::GetLauncherNameList(std::vector &res) { + std::map::iterator cur, end; cur = m_configs.begin(); end = m_configs.end(); for(; cur != end; cur++) { @@ -154,11 +152,11 @@ void LauncherList::GetLauncherNameList(std::vector &res) { } void LauncherList::LoadList() { - vector launchers; + std::vector launchers; database.GetLauncherList(launchers); - vector::iterator cur, end; + std::vector::iterator cur, end; cur = launchers.begin(); end = launchers.end(); for(; cur != end; cur++) { @@ -167,7 +165,7 @@ void LauncherList::LoadList() { } EQLConfig *LauncherList::GetConfig(const char *name) { - map::iterator res; + std::map::iterator res; res = m_configs.find(name); if(res == m_configs.end()) { return(nullptr); @@ -180,14 +178,14 @@ void LauncherList::CreateLauncher(const char *name, uint8 dynamic_count) { } void LauncherList::Remove(const char *name) { - map::iterator resc; + std::map::iterator resc; resc = m_configs.find(name); if(resc != m_configs.end()) { delete resc->second; m_configs.erase(resc); } - map::iterator resl; + std::map::iterator resl; resl = m_launchers.find(name); if(resl != m_launchers.end()) { resl->second->Disconnect(); diff --git a/world/LoginServer.cpp b/world/LoginServer.cpp index 7d7bb446b..b349cc45c 100644 --- a/world/LoginServer.cpp +++ b/world/LoginServer.cpp @@ -17,11 +17,9 @@ */ #include "../common/debug.h" #include -using namespace std; #include #include #include -using namespace std; #include #include "../common/version.h" diff --git a/world/LoginServerList.cpp b/world/LoginServerList.cpp index 6af65c7b9..5316804de 100644 --- a/world/LoginServerList.cpp +++ b/world/LoginServerList.cpp @@ -17,11 +17,9 @@ */ #include "../common/debug.h" #include -using namespace std; #include #include #include -using namespace std; #include #include "../common/version.h" diff --git a/world/WorldConfig.cpp b/world/WorldConfig.cpp index 7ef819655..96313ded3 100644 --- a/world/WorldConfig.cpp +++ b/world/WorldConfig.cpp @@ -21,7 +21,7 @@ WorldConfig *WorldConfig::_world_config = nullptr; -string WorldConfig::GetByName(const string &var_name) const { +std::string WorldConfig::GetByName(const std::string &var_name) const { if(var_name == "UpdateStats") return(UpdateStats?"true":"false"); if(var_name == "LoginDisabled") diff --git a/world/WorldConfig.h b/world/WorldConfig.h index 419339732..316e6cfc4 100644 --- a/world/WorldConfig.h +++ b/world/WorldConfig.h @@ -22,7 +22,7 @@ class WorldConfig : public EQEmuConfig { public: - virtual string GetByName(const string &var_name) const; + virtual std::string GetByName(const std::string &var_name) const; bool UpdateStats; bool LoginDisabled; @@ -65,8 +65,8 @@ public: static void DisableLoginserver() { if (_world_config) _world_config->LoginDisabled=true; } static void EnableLoginserver() { if (_world_config) _world_config->LoginDisabled=false; } - static void SetWorldAddress(string addr) { if (_world_config) _world_config->WorldAddress=addr; } - static void SetLocalAddress(string addr) { if (_world_config) _world_config->LocalAddress=addr; } + static void SetWorldAddress(std::string addr) { if (_world_config) _world_config->WorldAddress=addr; } + static void SetLocalAddress(std::string addr) { if (_world_config) _world_config->LocalAddress=addr; } void Dump() const; }; diff --git a/world/client.cpp b/world/client.cpp index 12dd7180d..7eb0a5b25 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -3,9 +3,7 @@ #include "../common/EQStreamIntf.h" #include "../common/misc.h" #include -using namespace std; #include -using namespace std; #include #include #include @@ -133,7 +131,7 @@ void Client::SendLogServer() safe_delete(outapp); } -void Client::SendEnterWorld(string name) +void Client::SendEnterWorld(std::string name) { char char_name[32]= { 0 }; if (pZoning && database.GetLiveChar(GetAccountID(), char_name)) { diff --git a/world/clientlist.cpp b/world/clientlist.cpp index 82de9cebe..573e83484 100644 --- a/world/clientlist.cpp +++ b/world/clientlist.cpp @@ -29,13 +29,11 @@ #include "wguild_mgr.h" #include -using namespace std; extern ConsoleList console_list; extern ZSList zoneserver_list; uint32 numplayers = 0; //this really wants to be a member variable of ClientList... - ClientList::ClientList() : CLStale_timer(45000) { @@ -45,13 +43,11 @@ ClientList::ClientList() ClientList::~ClientList() { } - void ClientList::Process() { if (CLStale_timer.Check()) CLCheckStale(); - LinkedListIterator iterator(list); iterator.Reset(); @@ -69,7 +65,6 @@ void ClientList::Process() { } } - void ClientList::CLERemoveZSRef(ZoneServer* iZS) { LinkedListIterator iterator(clientlist); @@ -86,7 +81,6 @@ void ClientList::CLERemoveZSRef(ZoneServer* iZS) { ClientListEntry* ClientList::GetCLE(uint32 iID) { LinkedListIterator iterator(clientlist); - iterator.Reset(); while(iterator.MoreElements()) { if (iterator.GetData()->GetID() == iID) { @@ -760,7 +754,7 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S void ClientList::SendFriendsWho(ServerFriendsWho_Struct *FriendsWho, WorldTCPConnection* connection) { - vector FriendsCLEs; + std::vector FriendsCLEs; FriendsCLEs.reserve(100); char Friend_[65]; @@ -1235,7 +1229,7 @@ bool ClientList::SendPacket(const char* to, ServerPacket* pack) { } void ClientList::SendGuildPacket(uint32 guild_id, ServerPacket* pack) { - set zone_ids; + std::set zone_ids; LinkedListIterator iterator(clientlist); @@ -1249,7 +1243,7 @@ void ClientList::SendGuildPacket(uint32 guild_id, ServerPacket* pack) { //now we know all the zones, send it to each one... this is kinda a shitty way to do this //since its basically O(n^2) - set::iterator cur, end; + std::set::iterator cur, end; cur = zone_ids.begin(); end = zone_ids.end(); for(; cur != end; cur++) { @@ -1276,7 +1270,7 @@ int ClientList::GetClientCount() { return(numplayers); } -void ClientList::GetClients(const char *zone_name, vector &res) { +void ClientList::GetClients(const char *zone_name, std::vector &res) { LinkedListIterator iterator(clientlist); iterator.Reset(); diff --git a/world/console.cpp b/world/console.cpp index 93f73ed4d..d17273587 100644 --- a/world/console.cpp +++ b/world/console.cpp @@ -17,7 +17,6 @@ */ #include "../common/debug.h" #include -using namespace std; #include #include #include diff --git a/world/net.cpp b/world/net.cpp index 3545b8a31..679f64957 100644 --- a/world/net.cpp +++ b/world/net.cpp @@ -18,7 +18,6 @@ #include "../common/debug.h" #include -using namespace std; #include #include #include @@ -194,21 +193,21 @@ int main(int argc, char** argv) { if (argc >= 2) { char tmp[2]; if (strcasecmp(argv[1], "help") == 0 || strcasecmp(argv[1], "?") == 0 || strcasecmp(argv[1], "/?") == 0 || strcasecmp(argv[1], "-?") == 0 || strcasecmp(argv[1], "-h") == 0 || strcasecmp(argv[1], "-help") == 0) { - cout << "Worldserver command line commands:" << endl; - cout << "adduser username password flag - adds a user account" << endl; - cout << "flag username flag - sets GM flag on the account" << endl; - cout << "startzone zoneshortname - sets the starting zone" << endl; - cout << "-holdzones - reboots lost zones" << endl; + std::cout << "Worldserver command line commands:" << std::endl; + std::cout << "adduser username password flag - adds a user account" << std::endl; + std::cout << "flag username flag - sets GM flag on the account" << std::endl; + std::cout << "startzone zoneshortname - sets the starting zone" << std::endl; + std::cout << "-holdzones - reboots lost zones" << std::endl; return 0; } else if (strcasecmp(argv[1], "-holdzones") == 0) { - cout << "Reboot Zones mode ON" << endl; + std::cout << "Reboot Zones mode ON" << std::endl; holdzones = true; } else if (database.GetVariable("disablecommandline", tmp, 2)) { if (strlen(tmp) == 1) { if (tmp[0] == '1') { - cout << "Command line disabled in database... exiting" << endl; + std::cout << "Command line disabled in database... exiting" << std::endl; return 0; } } @@ -218,15 +217,15 @@ int main(int argc, char** argv) { if (Seperator::IsNumber(argv[4])) { if (atoi(argv[4]) >= 0 && atoi(argv[4]) <= 255) { if (database.CreateAccount(argv[2], argv[3], atoi(argv[4])) == 0) - cout << "database.CreateAccount failed." << endl; + std::cout << "database.CreateAccount failed." << std::endl; else - cout << "Account created: Username='" << argv[2] << "', Password='" << argv[3] << "', status=" << argv[4] << endl; + std::cout << "Account created: Username='" << argv[2] << "', Password='" << argv[3] << "', status=" << argv[4] << std::endl; return 0; } } } - cout << "Usage: world adduser username password flag" << endl; - cout << "flag = 0, 1 or 2" << endl; + std::cout << "Usage: world adduser username password flag" << std::endl; + std::cout << "flag = 0, 1 or 2" << std::endl; return 0; } else if (strcasecmp(argv[1], "flag") == 0) { @@ -235,38 +234,38 @@ int main(int argc, char** argv) { if (atoi(argv[3]) >= 0 && atoi(argv[3]) <= 255) { if (database.SetAccountStatus(argv[2], atoi(argv[3]))) - cout << "Account flagged: Username='" << argv[2] << "', status=" << argv[3] << endl; + std::cout << "Account flagged: Username='" << argv[2] << "', status=" << argv[3] << std::endl; else - cout << "database.SetAccountStatus failed." << endl; + std::cout << "database.SetAccountStatus failed." << std::endl; return 0; } } } - cout << "Usage: world flag username flag" << endl; - cout << "flag = 0-200" << endl; + std::cout << "Usage: world flag username flag" << std::endl; + std::cout << "flag = 0-200" << std::endl; return 0; } else if (strcasecmp(argv[1], "startzone") == 0) { if (argc == 3) { if (strlen(argv[2]) < 3) { - cout << "Error: zone name too short" << endl; + std::cout << "Error: zone name too short" << std::endl; } else if (strlen(argv[2]) > 15) { - cout << "Error: zone name too long" << endl; + std::cout << "Error: zone name too long" << std::endl; } else { if (database.SetVariable("startzone", argv[2])) - cout << "Starting zone changed: '" << argv[2] << "'" << endl; + std::cout << "Starting zone changed: '" << argv[2] << "'" << std::endl; else - cout << "database.SetVariable failed." << endl; + std::cout << "database.SetVariable failed." << std::endl; } return 0; } - cout << "Usage: world startzone zoneshortname" << endl; + std::cout << "Usage: world startzone zoneshortname" << std::endl; return 0; } else { - cout << "Error, unknown command line option" << endl; + std::cout << "Error, unknown command line option" << std::endl; return 0; } } diff --git a/world/perl_EQLConfig.cpp b/world/perl_EQLConfig.cpp index 59e86dcb9..5179839a6 100644 --- a/world/perl_EQLConfig.cpp +++ b/world/perl_EQLConfig.cpp @@ -358,7 +358,7 @@ XS(XS_EQLConfig_ListZones) Perl_croak(aTHX_ "Usage: EQLConfig::ListZones(THIS)"); { EQLConfig * THIS; - vector RETVAL; + std::vector RETVAL; if (sv_derived_from(ST(0), "EQLConfig")) { IV tmp = SvIV((SV*)SvRV(ST(0))); @@ -379,7 +379,7 @@ XS(XS_EQLConfig_ListZones) /* 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()); } @@ -398,7 +398,7 @@ XS(XS_EQLConfig_GetZoneDetails) Perl_croak(aTHX_ "Usage: EQLConfig::GetZoneDetails(THIS, zone_ref)"); { EQLConfig * THIS; - map RETVAL; + std::map RETVAL; Const_char * zone_ref = (Const_char *)SvPV_nolen(ST(1)); if (sv_derived_from(ST(0), "EQLConfig")) { @@ -419,7 +419,7 @@ XS(XS_EQLConfig_GetZoneDetails) sv_2mortal((SV*)hv); ST(0) = newRV((SV*)hv); - map::const_iterator cur, end; + std::map::const_iterator cur, end; cur = RETVAL.begin(); end = RETVAL.end(); for(; cur != end; cur++) { diff --git a/world/perl_EQW.cpp b/world/perl_EQW.cpp index fd6b62262..e6896a08c 100644 --- a/world/perl_EQW.cpp +++ b/world/perl_EQW.cpp @@ -197,7 +197,7 @@ XS(XS_EQW_ListBootedZones) Perl_croak(aTHX_ "Usage: EQW::ListBootedZones(THIS)"); { EQW * THIS; - vector RETVAL; + std::vector RETVAL; if (sv_derived_from(ST(0), "EQW")) { IV tmp = SvIV((SV*)SvRV(ST(0))); @@ -218,7 +218,7 @@ XS(XS_EQW_ListBootedZones) /* 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()); } @@ -237,7 +237,7 @@ XS(XS_EQW_GetZoneDetails) Perl_croak(aTHX_ "Usage: EQW::GetZoneDetails(THIS, zone_ref)"); { EQW * THIS; - map RETVAL; + std::map RETVAL; Const_char * zone_ref = (Const_char *)SvPV_nolen(ST(1)); if (sv_derived_from(ST(0), "EQW")) { @@ -258,7 +258,7 @@ XS(XS_EQW_GetZoneDetails) sv_2mortal((SV*)hv); ST(0) = newRV((SV*)hv); - map::const_iterator cur, end; + std::map::const_iterator cur, end; cur = RETVAL.begin(); end = RETVAL.end(); for(; cur != end; cur++) { @@ -310,7 +310,7 @@ XS(XS_EQW_ListPlayers) Perl_croak(aTHX_ "Usage: EQW::ListPlayers(THIS, zone_name= \"\")"); { EQW * THIS; - vector RETVAL; + std::vector RETVAL; Const_char * zone_name; if (sv_derived_from(ST(0), "EQW")) { @@ -338,7 +338,7 @@ XS(XS_EQW_ListPlayers) /* 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()); } @@ -357,7 +357,7 @@ XS(XS_EQW_GetPlayerDetails) Perl_croak(aTHX_ "Usage: EQW::GetPlayerDetails(THIS, player_ref)"); { EQW * THIS; - map RETVAL; + std::map RETVAL; Const_char * player_ref = (Const_char *)SvPV_nolen(ST(1)); if (sv_derived_from(ST(0), "EQW")) { @@ -378,7 +378,7 @@ XS(XS_EQW_GetPlayerDetails) sv_2mortal((SV*)hv); ST(0) = newRV((SV*)hv); - map::const_iterator cur, end; + std::map::const_iterator cur, end; cur = RETVAL.begin(); end = RETVAL.end(); for(; cur != end; cur++) { @@ -431,7 +431,7 @@ XS(XS_EQW_ListLaunchers) Perl_croak(aTHX_ "Usage: EQW::ListLaunchers(THIS)"); { EQW * THIS; - vector RETVAL; + std::vector RETVAL; if (sv_derived_from(ST(0), "EQW")) { IV tmp = SvIV((SV*)SvRV(ST(0))); @@ -452,7 +452,7 @@ XS(XS_EQW_ListLaunchers) /* 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()); } @@ -831,7 +831,7 @@ XS(XS_EQW_ListBugs) { EQW * THIS; uint32 id = (uint32)SvUV(ST(1)); - vector RETVAL; + std::vector RETVAL; if (sv_derived_from(ST(0), "EQW")) { @@ -853,7 +853,7 @@ XS(XS_EQW_ListBugs) /* 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()); } @@ -872,7 +872,7 @@ XS(XS_EQW_GetBugDetails) Perl_croak(aTHX_ "Usage: EQW::GetBugDetails(THIS, bug_ref)"); { EQW * THIS; - map RETVAL; + std::map RETVAL; Const_char * bug_ref = (Const_char *)SvPV_nolen(ST(1)); if (sv_derived_from(ST(0), "EQW")) { @@ -893,7 +893,7 @@ XS(XS_EQW_GetBugDetails) sv_2mortal((SV*)hv); ST(0) = newRV((SV*)hv); - map::const_iterator cur, end; + std::map::const_iterator cur, end; cur = RETVAL.begin(); end = RETVAL.end(); for(; cur != end; cur++) { diff --git a/world/perl_HTTPRequest.cpp b/world/perl_HTTPRequest.cpp index d9427d809..54fa48780 100644 --- a/world/perl_HTTPRequest.cpp +++ b/world/perl_HTTPRequest.cpp @@ -185,7 +185,7 @@ XS(XS_HTTPRequest_get_all) Perl_croak(aTHX_ "Usage: HTTPRequest::get_all(THIS)"); { HTTPRequest * THIS; - map RETVAL; + std::map RETVAL; if (sv_derived_from(ST(0), "HTTPRequest")) { IV tmp = SvIV((SV*)SvRV(ST(0))); @@ -205,7 +205,7 @@ XS(XS_HTTPRequest_get_all) sv_2mortal((SV*)hv); ST(0) = newRV((SV*)hv); - map::const_iterator cur, end; + std::map::const_iterator cur, end; cur = RETVAL.begin(); end = RETVAL.end(); for(; cur != end; cur++) { diff --git a/world/worlddb.cpp b/world/worlddb.cpp index e99fafcf3..7ec2ac2e2 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -28,7 +28,6 @@ #include #include "SoFCharCreateData.h" -using namespace std; WorldDatabase database; extern std::vector character_create_allocations; extern std::vector character_create_race_class_combos; @@ -220,8 +219,8 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct* } else { - cout << "Got a bogus character (" << row[0] << ") Ignoring!!!" << endl; - cout << "PP length ="< &zones) { +void ZSList::GetZoneIDList(std::vector &zones) { LinkedListIterator iterator(list); iterator.Reset(); while(iterator.MoreElements()) { diff --git a/zone/AA.cpp b/zone/AA.cpp index b8ec4ab5e..242bc286a 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -41,7 +41,7 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) //static data arrays, really not big enough to warrant shared mem. AA_DBAction AA_Actions[aaHighestID][MAX_AA_ACTION_RANKS]; //[aaid][rank] -mapaas_send; +std::mapaas_send; std::map > aa_effects; //stores the effects from the aa_effects table in memory std::map AARequiredLevelAndCost; @@ -1396,7 +1396,7 @@ void Client::SendAAList(){ } uint32 Client::GetAA(uint32 aa_id) const { - map::const_iterator res; + std::map::const_iterator res; res = aa_points.find(aa_id); if(res != aa_points.end()) { return(res->second); @@ -1500,7 +1500,7 @@ void Client::ResetAA(){ aa[i]->AA = 0; aa[i]->value = 0; } - map::iterator itr; + std::map::iterator itr; for(itr=aa_points.begin();itr!=aa_points.end();itr++) aa_points[itr->first] = 0; diff --git a/zone/AA.h b/zone/AA.h index 334dd5176..ccdddf317 100644 --- a/zone/AA.h +++ b/zone/AA.h @@ -6,10 +6,7 @@ #define MANA_BURN 664 - #include -using namespace std; - #define MAX_SWARM_PETS 12 //this can change as long as you make more coords (swarm_pet_x/swarm_pet_y) @@ -2140,11 +2137,11 @@ struct AALevelCost_Struct //assumes that no activatable AA has more than 5 ranks #define MAX_AA_ACTION_RANKS 20 extern AA_DBAction AA_Actions[aaHighestID][MAX_AA_ACTION_RANKS]; //[aaid][rank] -extern map AA_SwarmPets; //key=spell_id +extern std::map AA_SwarmPets; //key=spell_id #define AA_Choose3(val, v1, v2, v3) (val==1?v1:(val==2?v2:v3)) -extern mapaas_send; +extern std::mapaas_send; extern std::map > aa_effects; extern std::map AARequiredLevelAndCost; diff --git a/zone/Map.cpp b/zone/Map.cpp index 8e959586d..241d7bc53 100644 --- a/zone/Map.cpp +++ b/zone/Map.cpp @@ -1018,7 +1018,7 @@ float Map::FindClosestZ(VERTEX p ) const float ClosestZ = -999999; - for(list::iterator Iterator = ZSet.begin(); Iterator != ZSet.end(); ++Iterator) + for(std::list::iterator Iterator = ZSet.begin(); Iterator != ZSet.end(); ++Iterator) { if(ABS(p.z - (*Iterator)) < ABS(p.z - ClosestZ)) ClosestZ = (*Iterator); diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index e954e5dbe..b9444c4ca 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -17,9 +17,7 @@ */ #include "../common/debug.h" #include -using namespace std; #include -using namespace std; #include #include #include @@ -102,12 +100,12 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) { ) { #if MobAI_DEBUG_Spells >= 21 - cout << "Mob::AICastSpell: Casting: spellid=" << AIspells[i].spellid + std::cout << "Mob::AICastSpell: Casting: spellid=" << AIspells[i].spellid << ", tar=" << tar->GetName() << ", dist2[" << dist2 << "]<=" << spells[AIspells[i].spellid].range *spells[AIspells[i].spellid].range << ", mana_cost[" << mana_cost << "]<=" << GetMana() << ", cancast[" << AIspells[i].time_cancast << "]<=" << Timer::GetCurrentTime() - << ", type=" << AIspells[i].type << endl; + << ", type=" << AIspells[i].type << std::endl; #endif switch (AIspells[i].type) { @@ -310,14 +308,14 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) { break; } default: { - cout<<"Error: Unknown spell type in AICastSpell. caster:"<GetName()<<" type:"<GetName() << " type:" << AIspells[i].type << " slot:" << i << std::endl; break; } } } #if MobAI_DEBUG_Spells >= 21 else { - cout << "Mob::AICastSpell: NotCasting: spellid=" << AIspells[i].spellid << ", tar=" << tar->GetName() << ", dist2[" << dist2 << "]<=" << spells[AIspells[i].spellid].range*spells[AIspells[i].spellid].range << ", mana_cost[" << mana_cost << "]<=" << GetMana() << ", cancast[" << AIspells[i].time_cancast << "]<=" << Timer::GetCurrentTime() << endl; + std::cout << "Mob::AICastSpell: NotCasting: spellid=" << AIspells[i].spellid << ", tar=" << tar->GetName() << ", dist2[" << dist2 << "]<=" << spells[AIspells[i].spellid].range*spells[AIspells[i].spellid].range << ", mana_cost[" << mana_cost << "]<=" << GetMana() << ", cancast[" << AIspells[i].time_cancast << "]<=" << Timer::GetCurrentTime() << std::endl; } #endif } @@ -327,7 +325,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) { bool NPC::AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore) { #if MobAI_DEBUG_Spells >= 1 - cout << "Mob::AIDoSpellCast: spellid=" << AIspells[i].spellid << ", tar=" << tar->GetName() << ", mana=" << mana_cost << ", Name: " << spells[AIspells[i].spellid].name << endl; + std::cout << "Mob::AIDoSpellCast: spellid=" << AIspells[i].spellid << ", tar=" << tar->GetName() << ", mana=" << mana_cost << ", Name: " << spells[AIspells[i].spellid].name << std::endl; #endif casting_spell_AIindex = i; @@ -1845,7 +1843,7 @@ bool NPC::AI_IdleCastCheck() { if (AIautocastspell_timer->Check(false)) { _ZP(Mob_AI_Process_autocast); #if MobAI_DEBUG_Spells >= 25 - cout << "Non-Engaged autocast check triggered: " << this->GetName() << endl; + std::cout << "Non-Engaged autocast check triggered: " << this->GetName() << std::endl; #endif AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. if (!AICastSpell(this, 100, SpellType_Heal | SpellType_Buff | SpellType_Pet)) { @@ -2206,20 +2204,20 @@ bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) { DBnpcspells_Struct* parentlist = database.GetNPCSpells(spell_list->parent_list); uint32 i; #if MobAI_DEBUG_Spells >= 10 - cout << "Loading NPCSpells onto " << this->GetName() << ": dbspellsid=" << iDBSpellsID; + std::cout << "Loading NPCSpells onto " << this->GetName() << ": dbspellsid=" << iDBSpellsID; if (spell_list) { - cout << " (found, " << spell_list->numentries << "), parentlist=" << spell_list->parent_list; + std::cout << " (found, " << spell_list->numentries << "), parentlist=" << spell_list->parent_list; if (spell_list->parent_list) { if (parentlist) { - cout << " (found, " << parentlist->numentries << ")"; + std::cout << " (found, " << parentlist->numentries << ")"; } else - cout << " (not found)"; + std::cout << " (not found)"; } } else - cout << " (not found)"; - cout << endl; + std::cout << " (not found)"; + std::cout << std::endl; #endif int16 attack_proc_spell = -1; int8 proc_chance = 3; @@ -2379,7 +2377,7 @@ DBnpcspells_Struct* ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) { return npc_spells_cache[iDBSpellsID]; } else { - cerr << "Error in AddNPCSpells query1 '" << query << "' " << errbuf << endl; + std::cerr << "Error in AddNPCSpells query1 '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return 0; } @@ -2389,7 +2387,7 @@ DBnpcspells_Struct* ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) { } } else { - cerr << "Error in AddNPCSpells query1 '" << query << "' " << errbuf << endl; + std::cerr << "Error in AddNPCSpells query1 '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return 0; } @@ -2418,7 +2416,7 @@ uint32 ZoneDatabase::GetMaxNPCSpellsID() { mysql_free_result(result); } else { - cerr << "Error in GetMaxNPCSpellsID query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetMaxNPCSpellsID query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return 0; } diff --git a/zone/Object.cpp b/zone/Object.cpp index 25123a62b..0e9fc23c5 100644 --- a/zone/Object.cpp +++ b/zone/Object.cpp @@ -27,7 +27,6 @@ #include "../common/MiscFunctions.h" #include "../common/features.h" #include "StringIDs.h" -using namespace std; #include "QuestParserCollection.h" @@ -664,7 +663,7 @@ Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Gro mysql_free_result(result); } else { - cerr << "Error in LoadGroundSpawns query '" << query << "' " << errbuf << endl; + std::cerr << "Error in LoadGroundSpawns query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } return gs; diff --git a/zone/PlayerCorpse.cpp b/zone/PlayerCorpse.cpp index 6a2fdfe63..243a825ef 100644 --- a/zone/PlayerCorpse.cpp +++ b/zone/PlayerCorpse.cpp @@ -26,7 +26,6 @@ Child of the Mob class. #include #include #include -using namespace std; #ifdef _WINDOWS #define snprintf _snprintf #if (_MSC_VER < 1500) @@ -617,7 +616,7 @@ bool Corpse::Save() { dbid = database.UpdatePlayerCorpse(dbid, charid, orgname, zone->GetZoneID(), zone->GetInstanceID(), (uchar*) dbpc, tmpsize, x_pos, y_pos, z_pos, heading,Rezzed()); safe_delete_array(dbpc); if (dbid == 0) { - cout << "Error: Failed to save player corpse '" << this->GetName() << "'" << endl; + std::cout << "Error: Failed to save player corpse '" << this->GetName() << "'" << std::endl; return false; } return true; @@ -890,7 +889,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a if(IsPlayerCorpse() && dbid == 0) { // SendLootReqErrorPacket(client, 0); client->Message(13, "Warning: Corpse's dbid = 0! Corpse will not survive zone shutdown!"); - cout << "Error: PlayerCorpse::MakeLootRequestPackets: dbid = 0!" << endl; + std::cout << "Error: PlayerCorpse::MakeLootRequestPackets: dbid = 0!" << std::endl; // return; } @@ -1456,12 +1455,12 @@ bool ZoneDatabase::DeleteGraveyard(uint32 zone_id, uint32 graveyard_id) { if (!RunQuery(query, query_length, errbuf, 0, &affected_rows)) { safe_delete_array(query); - cerr << "Error1 in DeleteGraveyard query " << errbuf << endl; + std::cerr << "Error1 in DeleteGraveyard query " << errbuf << std::endl; return false; } if (affected_rows == 0) { - cerr << "Error2 in DeleteGraveyard query: affected_rows = 0" << endl; + std::cerr << "Error2 in DeleteGraveyard query: affected_rows = 0" << std::endl; return false; } @@ -1469,13 +1468,13 @@ bool ZoneDatabase::DeleteGraveyard(uint32 zone_id, uint32 graveyard_id) { if (!RunQuery(query, query_length, errbuf, 0, &affected_rows)) { safe_delete_array(query); - cerr << "Error3 in DeleteGraveyard query " << errbuf << endl; + std::cerr << "Error3 in DeleteGraveyard query " << errbuf << std::endl; return false; } safe_delete_array(query); if (affected_rows == 0) { - cerr << "Error4 in DeleteGraveyard query: affected_rows = 0" << endl; + std::cerr << "Error4 in DeleteGraveyard query: affected_rows = 0" << std::endl; return false; } @@ -1491,13 +1490,13 @@ uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) { if (!RunQuery(query, (uint32) (end - query), errbuf, 0, &affected_rows)) { safe_delete_array(query); - cerr << "Error1 in AddGraveyardIDToZone query " << errbuf << endl; + std::cerr << "Error1 in AddGraveyardIDToZone query " << errbuf << std::endl; return 0; } safe_delete_array(query); if (affected_rows == 0) { - cerr << "Error2 in AddGraveyardIDToZone query: affected_rows = 0" << endl; + std::cerr << "Error2 in AddGraveyardIDToZone query: affected_rows = 0" << std::endl; return 0; } @@ -1514,18 +1513,18 @@ uint32 ZoneDatabase::NewGraveyardRecord(uint32 graveyard_zoneid, float graveyard if (!RunQuery(query, (uint32) (end - query), errbuf, 0, &affected_rows, &new_graveyard_id)) { safe_delete_array(query); - cerr << "Error1 in NewGraveyardRecord query " << errbuf << endl; + std::cerr << "Error1 in NewGraveyardRecord query " << errbuf << std::endl; return 0; } safe_delete_array(query); if (affected_rows == 0) { - cerr << "Error2 in NewGraveyardRecord query: affected_rows = 0" << endl; + std::cerr << "Error2 in NewGraveyardRecord query: affected_rows = 0" << std::endl; return 0; } if(new_graveyard_id <= 0) { - cerr << "Error3 in NewGraveyardRecord query: new_graveyard_id <= 0" << endl; + std::cerr << "Error3 in NewGraveyardRecord query: new_graveyard_id <= 0" << std::endl; return 0; } @@ -1542,13 +1541,13 @@ uint32 ZoneDatabase::GraveyardPlayerCorpse(uint32 dbid, uint32 zoneid, uint16 in if (!RunQuery(query, (uint32) (end - query), errbuf, 0, &affected_rows)) { safe_delete_array(query); - cerr << "Error1 in GraveyardPlayerCorpse query " << errbuf << endl; + std::cerr << "Error1 in GraveyardPlayerCorpse query " << errbuf << std::endl; return 0; } safe_delete_array(query); if (affected_rows == 0) { - cerr << "Error2 in GraveyardPlayerCorpse query: affected_rows = 0" << endl; + std::cerr << "Error2 in GraveyardPlayerCorpse query: affected_rows = 0" << std::endl; return 0; } return dbid; @@ -1567,18 +1566,18 @@ uint32 ZoneDatabase::UpdatePlayerCorpse(uint32 dbid, uint32 charid, const char* if (!RunQuery(query, (uint32) (end - query), errbuf, 0, &affected_rows)) { safe_delete_array(query); - cerr << "Error1 in UpdatePlayerCorpse query " << errbuf << endl; + std::cerr << "Error1 in UpdatePlayerCorpse query " << errbuf << std::endl; return 0; } safe_delete_array(query); if (affected_rows == 0) { - cerr << "Error2 in UpdatePlayerCorpse query: affected_rows = 0" << endl; + std::cerr << "Error2 in UpdatePlayerCorpse query: affected_rows = 0" << std::endl; return 0; } if(rezzed){ if (!RunQuery(query, MakeAnyLenString(&query, "update player_corpses set rezzed = 1 WHERE id=%d",dbid), errbuf)) { - cerr << "Error in UpdatePlayerCorpse/Rezzed query: " << errbuf << endl; + std::cerr << "Error in UpdatePlayerCorpse/Rezzed query: " << errbuf << std::endl; } safe_delete_array(query); } @@ -1614,18 +1613,18 @@ uint32 ZoneDatabase::CreatePlayerCorpse(uint32 charid, const char* charname, uin if (!RunQuery(query, (uint32) (end - query), errbuf, 0, &affected_rows, &last_insert_id)) { safe_delete_array(query); - cerr << "Error1 in CreatePlayerCorpse query " << errbuf << endl; + std::cerr << "Error1 in CreatePlayerCorpse query " << errbuf << std::endl; return 0; } safe_delete_array(query); if (affected_rows == 0) { - cerr << "Error2 in CreatePlayerCorpse query: affected_rows = 0" << endl; + std::cerr << "Error2 in CreatePlayerCorpse query: affected_rows = 0" << std::endl; return 0; } if (last_insert_id == 0) { - cerr << "Error3 in CreatePlayerCorpse query: last_insert_id = 0" << endl; + std::cerr << "Error3 in CreatePlayerCorpse query: last_insert_id = 0" << std::endl; return 0; } @@ -1653,15 +1652,15 @@ bool ZoneDatabase::CreatePlayerCorpseBackup(uint32 dbid, uint32 charid, const ch if (affected_rows == 1) result = true; else - cerr << "Error in CreatePlayerCorpseBackup query: affected_rows != 1" << endl; + std::cerr << "Error in CreatePlayerCorpseBackup query: affected_rows != 1" << std::endl; } else - cerr << "Error in CreatePlayerCorpseBackup query " << errbuf << endl; + std::cerr << "Error in CreatePlayerCorpseBackup query " << errbuf << std::endl; } safe_delete_array(query); } else { - cerr << "Error in CreatePlayerCorpseBackup: dbid = 0" << endl; + std::cerr << "Error in CreatePlayerCorpseBackup: dbid = 0" << std::endl; } return result; } @@ -1679,7 +1678,7 @@ uint32 ZoneDatabase::GetPlayerBurriedCorpseCount(uint32 char_id) { mysql_free_result(result); } else { - cerr << "Error in GetPlayerBurriedCorpseCount query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetPlayerBurriedCorpseCount query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); @@ -1700,7 +1699,7 @@ uint32 ZoneDatabase::GetPlayerCorpseCount(uint32 char_id) { mysql_free_result(result); } else { - cerr << "Error in GetPlayerCorpseCount query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetPlayerCorpseCount query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); @@ -1723,7 +1722,7 @@ uint32 ZoneDatabase::GetPlayerCorpseID(uint32 char_id, uint8 corpse) { mysql_free_result(result); } else { - cerr << "Error in GetPlayerCorpseID query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetPlayerCorpseID query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); @@ -1769,7 +1768,7 @@ Corpse* ZoneDatabase::SummonBurriedPlayerCorpse(uint32 char_id, uint32 dest_zone mysql_free_result(result); } else { - cerr << "Error in SummonBurriedPlayerCorpse query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SummonBurriedPlayerCorpse query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); @@ -1836,10 +1835,10 @@ bool ZoneDatabase::UnburyPlayerCorpse(uint32 dbid, uint32 new_zoneid, uint16 new if (affected_rows == 1) Result = true; else - cerr << "Error2 in UnburyPlayerCorpse query: affected_rows NOT EQUAL to 1, as expected." << endl; + std::cerr << "Error2 in UnburyPlayerCorpse query: affected_rows NOT EQUAL to 1, as expected." << std::endl; } else - cerr << "Error1 in UnburyPlayerCorpse query " << errbuf << endl; + std::cerr << "Error1 in UnburyPlayerCorpse query " << errbuf << std::endl; safe_delete_array(query); @@ -1865,8 +1864,8 @@ Corpse* ZoneDatabase::LoadPlayerCorpse(uint32 player_corpse_id) { mysql_free_result(result); } else { - cerr << "Error in LoadPlayerCorpse query '" << query << "' " << errbuf << endl; - cerr << "Note that if your missing the 'rezzed' field you can add it with:\nALTER TABLE `player_corpses` ADD `rezzed` TINYINT UNSIGNED DEFAULT \"0\";\n"; + std::cerr << "Error in LoadPlayerCorpse query '" << query << "' " << errbuf << std::endl; + std::cerr << "Note that if your missing the 'rezzed' field you can add it with:\nALTER TABLE `player_corpses` ADD `rezzed` TINYINT UNSIGNED DEFAULT \"0\";\n"; } safe_delete_array(query); @@ -1897,8 +1896,8 @@ bool ZoneDatabase::LoadPlayerCorpses(uint32 iZoneID, uint16 iInstanceID) { mysql_free_result(result); } else { - cerr << "Error in LoadPlayerCorpses query '" << query << "' " << errbuf << endl; - cerr << "Note that if your missing the 'rezzed' field you can add it with:\nALTER TABLE `player_corpses` ADD `rezzed` TINYINT UNSIGNED DEFAULT \"0\";\n"; + std::cerr << "Error in LoadPlayerCorpses query '" << query << "' " << errbuf << std::endl; + std::cerr << "Note that if your missing the 'rezzed' field you can add it with:\nALTER TABLE `player_corpses` ADD `rezzed` TINYINT UNSIGNED DEFAULT \"0\";\n"; safe_delete_array(query); return false; } @@ -1922,7 +1921,7 @@ uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) { } } else { - cerr << "Error in GetFirstCorpseID query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetFirstCorpseID query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return 0; } @@ -1936,7 +1935,7 @@ bool ZoneDatabase::BuryPlayerCorpse(uint32 dbid) { char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE player_corpses SET IsBurried = 1 WHERE id=%d", dbid), errbuf)) { - cerr << "Error in BuryPlayerCorpse query '" << query << "' " << errbuf << endl; + std::cerr << "Error in BuryPlayerCorpse query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1950,7 +1949,7 @@ bool ZoneDatabase::BuryAllPlayerCorpses(uint32 charid) { char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE player_corpses SET IsBurried = 1 WHERE charid=%d", charid), errbuf)) { - cerr << "Error in BuryPlayerCorpse query '" << query << "' " << errbuf << endl; + std::cerr << "Error in BuryPlayerCorpse query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1964,7 +1963,7 @@ bool ZoneDatabase::DeletePlayerCorpse(uint32 dbid) { char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "Delete from player_corpses where id=%d", dbid), errbuf)) { - cerr << "Error in DeletePlayerCorpse query '" << query << "' " << errbuf << endl; + std::cerr << "Error in DeletePlayerCorpse query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } diff --git a/zone/ZoneConfig.h b/zone/ZoneConfig.h index 4fbbf9e59..dac5a371d 100644 --- a/zone/ZoneConfig.h +++ b/zone/ZoneConfig.h @@ -23,7 +23,7 @@ class ZoneConfig : public EQEmuConfig { public: uint16 ZonePort; - string ZoneAddress; + std::string ZoneAddress; private: diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 2d9bbeb12..52899a856 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -187,7 +187,7 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { char namebuf[256]; if(!database.GetFactionName(mob_primary, namebuf, sizeof(namebuf))) strcpy(namebuf, "(Unknown)"); - list::iterator cur,end; + std::list::iterator cur,end; cur = faction_list.begin(); end = faction_list.end(); bool res = false; diff --git a/zone/attack.cpp b/zone/attack.cpp index c08382838..af9d9543b 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -26,7 +26,6 @@ #include #include #include -using namespace std; #include #include "masterentity.h" diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index ae8bf3c53..66e841eb9 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -615,7 +615,7 @@ void Client::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) return; } - for (map::const_iterator iter = aa_effects[aaid].begin(); iter != aa_effects[aaid].end(); ++iter) { + for (std::map::const_iterator iter = aa_effects[aaid].begin(); iter != aa_effects[aaid].end(); ++iter) { effect = iter->second.skill_id; base1 = iter->second.base1; base2 = iter->second.base2; diff --git a/zone/bot.h b/zone/bot.h index 47a1516b2..b8f3c191d 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -18,8 +18,6 @@ #include -using namespace std; - extern WorldServer worldserver; const int BotAISpellRange = 100; // TODO: Write a method that calcs what the bot's spell range is based on spell, equipment, AA, whatever and replace this diff --git a/zone/botStructs.h b/zone/botStructs.h index fd7294da4..09140ae60 100644 --- a/zone/botStructs.h +++ b/zone/botStructs.h @@ -7,8 +7,6 @@ #include -using namespace std; - struct BotsAvailableList { uint32 BotID; char BotName[64]; diff --git a/zone/client.cpp b/zone/client.cpp index 8f16956aa..b372df0d8 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -17,9 +17,7 @@ */ #include "../common/debug.h" #include -using namespace std; #include -using namespace std; #include #include #include @@ -628,7 +626,7 @@ bool Client::Save(uint8 iCommitNow) { SaveBackup(); } else { - cerr << "Failed to update player profile" << endl; + std::cerr << "Failed to update player profile" << std::endl; return false; } @@ -2043,7 +2041,7 @@ void Client::ReadBook(BookRequest_Struct *book) { return; } - string booktxt2 = database.GetBook(txtfile); + std::string booktxt2 = database.GetBook(txtfile); int length = booktxt2.length(); if (booktxt2[0] != '\0') { @@ -2075,7 +2073,7 @@ void Client::ReadBook(BookRequest_Struct *book) { } void Client::QuestReadBook(const char* text, uint8 type) { - string booktxt2 = text; + std::string booktxt2 = text; int length = booktxt2.length(); if (booktxt2[0] != '\0') { EQApplicationPacket* outapp = new EQApplicationPacket(OP_ReadBook, length + sizeof(BookText_Struct)); @@ -2576,7 +2574,7 @@ void Client::LogMerchant(Client* player, Mob* merchant, uint32 quantity, uint32 if(!player || !merchant || !item) return; - string LogText = "Qty: "; + std::string LogText = "Qty: "; char Buffer[255]; memset(Buffer, 0, sizeof(Buffer)); @@ -3871,7 +3869,7 @@ void Client::KeyRingLoad() } mysql_free_result(result); }else { - cerr << "Error in Client::KeyRingLoad query '" << query << "' " << errbuf << endl; + std::cerr << "Error in Client::KeyRingLoad query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return; } @@ -3894,7 +3892,7 @@ void Client::KeyRingAdd(uint32 item_id) } else { - cerr << "Error in Doors::HandleClick query '" << query << "' " << errbuf << endl; + std::cerr << "Error in Doors::HandleClick query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return; } @@ -3947,7 +3945,7 @@ bool Client::IsDiscovered(uint32 itemid) { } else { - cerr << "Error in IsDiscovered query '" << query << "' " << errbuf << endl; + std::cerr << "Error in IsDiscovered query '" << query << "' " << errbuf << std::endl; } mysql_free_result(result); safe_delete_array(query); @@ -4736,10 +4734,10 @@ uint32 Client::GetStartZone() void Client::ShowSkillsWindow() { const char *WindowTitle = "Skills"; - string WindowText; + std::string WindowText; // using a map for easy alphabetizing of the skills list - map Skills; - map::iterator it; + std::map Skills; + std::map::iterator it; // this list of names must keep the same order as that in common/skills.h const char* SkillName[] = {"1H Blunt","1H Slashing","2H Blunt","2H Slashing","Abjuration","Alteration","Apply Poison","Archery", @@ -5141,7 +5139,7 @@ void Client::SendRewards() InternalVeteranReward *ivr = (InternalVeteranReward*)data; ivr->claim_id = rewards[i].id; ivr->number_available = rewards[i].amount; - list::iterator iter = zone->VeteranRewards.begin(); + std::list::iterator iter = zone->VeteranRewards.begin(); while(iter != zone->VeteranRewards.end()) { if((*iter).claim_id == rewards[i].id) @@ -5231,7 +5229,7 @@ bool Client::TryReward(uint32 claim_id) return false; } - list::iterator iter = zone->VeteranRewards.begin(); + std::list::iterator iter = zone->VeteranRewards.begin(); while(iter != zone->VeteranRewards.end()) { if((*iter).claim_id == claim_id) @@ -6050,7 +6048,7 @@ void Client::NPCSpawn(NPC *target_npc, const char *identifier, uint32 extra) bool Client::IsDraggingCorpse(const char *CorpseName) { - for(std::list::iterator Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator) + for(std::list::iterator Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator) { if(!strcasecmp((*Iterator).c_str(), CorpseName)) return true; @@ -6061,7 +6059,7 @@ bool Client::IsDraggingCorpse(const char *CorpseName) void Client::DragCorpses() { - for(std::list::iterator Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator) + for(std::list::iterator Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator) { Mob* corpse = entity_list.GetMob((*Iterator).c_str()); @@ -6716,7 +6714,7 @@ void Client::SendAltCurrencies() { altc->count = count; uint32 i = 0; - list::iterator iter = zone->AlternateCurrencies.begin(); + std::list::iterator iter = zone->AlternateCurrencies.begin(); while(iter != zone->AlternateCurrencies.end()) { const Item_Struct* item = database.GetItem((*iter).item_id); altc->entries[i].currency_number = (*iter).id; @@ -6771,7 +6769,7 @@ void Client::AddAlternateCurrencyValue(uint32 currency_id, int32 amount) void Client::SendAlternateCurrencyValues() { - list::iterator iter = zone->AlternateCurrencies.begin(); + std::list::iterator iter = zone->AlternateCurrencies.begin(); while(iter != zone->AlternateCurrencies.end()) { SendAlternateCurrencyValue((*iter).id, false); iter++; @@ -7138,23 +7136,23 @@ void Client::SendWebLink(const char *website) { if(website != 0) { - string str = website; - EQApplicationPacket* outapp = new EQApplicationPacket(OP_Weblink, sizeof(Weblink_Struct) + str.length() + 1); - Weblink_Struct *wl = (Weblink_Struct*)outapp->pBuffer; - memcpy(wl->weblink, str.c_str(), str.length() + 1); - wl->weblink[str.length() + 1] = '\0'; + std::string str = website; + EQApplicationPacket* outapp = new EQApplicationPacket(OP_Weblink, sizeof(Weblink_Struct) + str.length() + 1); + Weblink_Struct *wl = (Weblink_Struct*)outapp->pBuffer; + memcpy(wl->weblink, str.c_str(), str.length() + 1); + wl->weblink[str.length() + 1] = '\0'; - FastQueuePacket(&outapp); + FastQueuePacket(&outapp); } } void Client::SendMercPersonalInfo() { - uint32 mercTypeCount = 1; - uint32 mercCount = 1; //TODO: Un-hardcode this and support multiple mercs like in later clients than SoD. - //uint32 packetSize = 0; - uint32 i=0; - uint32 altCurrentType = 19; //TODO: Implement alternate currency purchases involving mercs! +uint32 mercTypeCount = 1; +uint32 mercCount = 1; //TODO: Un-hardcode this and support multiple mercs like in later clients than SoD. +//uint32 packetSize = 0; +uint32 i=0; +uint32 altCurrentType = 19; //TODO: Implement alternate currency purchases involving mercs! if (GetClientVersion() >= EQClientRoF) { @@ -7197,7 +7195,7 @@ void Client::SendMercPersonalInfo() uint32 stanceindex = 0; if (mdus->MercData[i].StanceCount != 0) { - list::iterator iter = zone->merc_stance_list[mercData->MercTemplateID].begin(); + std::list::iterator iter = zone->merc_stance_list[mercData->MercTemplateID].begin(); while(iter != zone->merc_stance_list[mercData->MercTemplateID].end()) { mdus->MercData[i].Stances[stanceindex].StanceIndex = stanceindex; @@ -7263,7 +7261,7 @@ void Client::SendMercPersonalInfo() int stanceindex = 0; if(mml->Mercs[i].StanceCount != 0) { - list::iterator iter = zone->merc_stance_list[mercData->MercTemplateID].begin(); + std::list::iterator iter = zone->merc_stance_list[mercData->MercTemplateID].begin(); while(iter != zone->merc_stance_list[mercData->MercTemplateID].end()) { mml->Mercs[i].Stances[stanceindex].StanceIndex = stanceindex; diff --git a/zone/client.h b/zone/client.h index 52d298b61..21005949c 100644 --- a/zone/client.h +++ b/zone/client.h @@ -708,7 +708,7 @@ public: void ChangeTributeSettings(TributeInfo_Struct *t); void SendTributeTimer(); void ToggleTribute(bool enabled); - void SendPathPacket(vector &path); + void SendPathPacket(std::vector &path); inline PTimerList &GetPTimers() { return(p_timers); } @@ -863,7 +863,7 @@ public: bool PendingTranslocate; time_t TranslocateTime; bool PendingSacrifice; - string SacrificeCaster; + std::string SacrificeCaster; struct Translocate_Struct PendingTranslocateData; void SendOPTranslocateConfirm(Mob *Caster, uint16 SpellID); @@ -1103,13 +1103,13 @@ public: void TickItemCheck(); void TryItemTick(int slot); - int16 GetActSTR() { return( min(GetMaxSTR(), GetSTR()) ); } - int16 GetActSTA() { return( min(GetMaxSTA(), GetSTA()) ); } - int16 GetActDEX() { return( min(GetMaxDEX(), GetDEX()) ); } - int16 GetActAGI() { return( min(GetMaxAGI(), GetAGI()) ); } - int16 GetActINT() { return( min(GetMaxINT(), GetINT()) ); } - int16 GetActWIS() { return( min(GetMaxWIS(), GetWIS()) ); } - int16 GetActCHA() { return( min(GetMaxCHA(), GetCHA()) ); } + int16 GetActSTR() { return( std::min(GetMaxSTR(), GetSTR()) ); } + int16 GetActSTA() { return( std::min(GetMaxSTA(), GetSTA()) ); } + int16 GetActDEX() { return( std::min(GetMaxDEX(), GetDEX()) ); } + int16 GetActAGI() { return( std::min(GetMaxAGI(), GetAGI()) ); } + int16 GetActINT() { return( std::min(GetMaxINT(), GetINT()) ); } + int16 GetActWIS() { return( std::min(GetMaxWIS(), GetWIS()) ); } + int16 GetActCHA() { return( std::min(GetMaxCHA(), GetCHA()) ); } void LoadAccountFlags(); void SetAccountFlag(std::string flag, std::string val); std::string GetAccountFlag(std::string flag); float GetDamageMultiplier(SkillType); @@ -1269,7 +1269,7 @@ private: uint8 mercSlot; // selected merc slot bool Trader; bool Buyer; - string BuyerWelcomeMessage; + std::string BuyerWelcomeMessage; bool AbilityTimer; int Haste; //precalced value @@ -1361,7 +1361,7 @@ private: uint32 max_AAXP; uint32 staminacount; AA_Array* aa[MAX_PP_AA_ARRAY]; //this list contains pointers into our player profile - map aa_points; + std::map aa_points; bool npcflag; uint8 npclevel; bool feigned; @@ -1377,7 +1377,7 @@ private: unsigned int RestRegenMana; unsigned int RestRegenEndurance; - set zone_flags; + std::set zone_flags; ClientTaskState *taskstate; int TotalSecondsPlayed; @@ -1426,7 +1426,7 @@ private: std::set PlayerBlockedBuffs; std::set PetBlockedBuffs; - std::list DraggedCorpses; + std::list DraggedCorpses; uint8 MaxXTargets; bool XTargetAutoAddHaters; diff --git a/zone/client_logs.cpp b/zone/client_logs.cpp index 987a2ad24..8961ac991 100644 --- a/zone/client_logs.cpp +++ b/zone/client_logs.cpp @@ -35,7 +35,7 @@ void ClientLogs::subscribe(EQEMuLog::LogIDs id, Client *c) { //make sure they arnt allready subscribed. - vector::iterator cur,end; + std::vector::iterator cur,end; cur = entries[id].begin(); end = entries[id].end(); for(; cur != end; cur++) { @@ -55,7 +55,7 @@ void ClientLogs::unsubscribe(EQEMuLog::LogIDs id, Client *c) { if(c == nullptr) return; - vector::iterator cur,end; + std::vector::iterator cur,end; cur = entries[id].begin(); end = entries[id].end(); for(; cur != end; cur++) { @@ -94,7 +94,7 @@ void ClientLogs::clear() { void ClientLogs::msg(EQEMuLog::LogIDs id, const char *buf) { if(id >= EQEMuLog::MaxLogID) return; - vector::iterator cur,end; + std::vector::iterator cur,end; cur = entries[id].begin(); end = entries[id].end(); for(; cur != end; cur++) { diff --git a/zone/client_logs.h b/zone/client_logs.h index bff215c42..9ce477f8c 100644 --- a/zone/client_logs.h +++ b/zone/client_logs.h @@ -30,7 +30,6 @@ #define MAX_CLIENT_LOG_MESSAGE_LENGTH 512 #include -using namespace std; class Client; @@ -50,7 +49,7 @@ public: protected: - vector entries[EQEMuLog::MaxLogID]; + std::vector entries[EQEMuLog::MaxLogID]; static char _buffer[MAX_CLIENT_LOG_MESSAGE_LENGTH+1]; }; diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 1e81c563e..5ed426789 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -1997,7 +1997,7 @@ int32 Client::CalcBaseEndurance() int BonusUpto800 = int( at_most_800 / 4 ) ; if(Stats > 400) { Bonus400to800 = int( (at_most_800 - 400) / 4 ); - HalfBonus400to800 = int( max( ( at_most_800 - 400 ), 0 ) / 8 ); + HalfBonus400to800 = int( std::max( ( at_most_800 - 400 ), 0 ) / 8 ); if(Stats > 800) { Bonus800plus = int( (Stats - 800) / 8 ) * 2; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 427e624cf..45a181b56 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -73,9 +73,6 @@ #include "../common/ZoneNumbers.h" #include "QuestParserCollection.h" -using namespace std; - - extern Zone* zone; extern volatile bool ZoneLoaded; extern WorldServer worldserver; @@ -87,7 +84,7 @@ extern DBAsync *dbasync; typedef void (Client::*ClientPacketProc)(const EQApplicationPacket *app); //Use a map for connecting opcodes since it dosent get used a lot and is sparse -map ConnectingOpcodes; +std::map ConnectingOpcodes; //Use a static array for connected, for speed ClientPacketProc ConnectedOpcodes[_maxEmuOpcode]; @@ -411,14 +408,14 @@ int Client::HandlePacket(const EQApplicationPacket *app) } #if EQDEBUG >= 9 - cout << "Received 0x" << hex << setw(4) << setfill('0') << opcode << ", size=" << dec << app->size << endl; + std::cout << "Received 0x" << hex << setw(4) << setfill('0') << opcode << ", size=" << dec << app->size << std::endl; #endif #ifdef SOLAR if(0 && opcode != OP_ClientUpdate) { LogFile->write(EQEMuLog::Debug,"HandlePacket() OPCODE debug enabled client %s", GetName()); - cerr << "OPCODE: " << hex << setw(4) << setfill('0') << opcode << dec << ", size: " << app->size << endl; + std::cerr << "OPCODE: " << hex << setw(4) << setfill('0') << opcode << dec << ", size: " << app->size << std::endl; DumpPacket(app); } #endif @@ -429,7 +426,7 @@ int Client::HandlePacket(const EQApplicationPacket *app) //TODO: replace this 0 with the EQ opcode LogFile->write(EQEMuLog::Error, "HandlePacket() Opcode error: Unexpected packet during CLIENT_CONNECTING: opcode: %s (#%d eq=0x%04x), size: %i", OpcodeNames[opcode], opcode, 0, app->size); #if EQDEBUG >= 9 - cout << "Unexpected packet during CLIENT_CONNECTING: OpCode: 0x" << hex << setw(4) << setfill('0') << opcode << dec << ", size: " << app->size << endl; + std::cout << "Unexpected packet during CLIENT_CONNECTING: OpCode: 0x" << hex << setw(4) << setfill('0') << opcode << dec << ", size: " << app->size << std::endl; DumpPacket(app); #endif break; @@ -458,7 +455,7 @@ int Client::HandlePacket(const EQApplicationPacket *app) if(app->size<1000) DumpPacket(app->pBuffer, app->size); else{ - cout << "Dump limited to 1000 characters:\n"; + std::cout << "Dump limited to 1000 characters:\n"; DumpPacket(app->pBuffer, 1000); } break; @@ -2993,7 +2990,7 @@ void Client::Handle_OP_RequestDuel(const EQApplicationPacket *app) void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) { if (app->size != sizeof(SpawnAppearance_Struct)) { - cout << "Wrong size on OP_SpawnAppearance. Got: " << app->size << ", Expected: " << sizeof(SpawnAppearance_Struct) << endl; + std::cout << "Wrong size on OP_SpawnAppearance. Got: " << app->size << ", Expected: " << sizeof(SpawnAppearance_Struct) << std::endl; return; } SpawnAppearance_Struct* sa = (SpawnAppearance_Struct*)app->pBuffer; @@ -3068,7 +3065,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) } */ else { - cerr << "Client " << name << " unknown apperance " << (int)sa->parameter << endl; + std::cerr << "Client " << name << " unknown apperance " << (int)sa->parameter << std::endl; return; } @@ -3086,7 +3083,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) m_pp.anon = 0; } else { - cerr << "Client " << name << " unknown Anon/Roleplay Switch " << (int)sa->parameter << endl; + std::cerr << "Client " << name << " unknown Anon/Roleplay Switch " << (int)sa->parameter << std::endl; return; } entity_list.QueueClients(this, app, true); @@ -3139,8 +3136,8 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) entity_list.QueueClients(this, app, true); } else { - cout << "Unknown SpawnAppearance type: 0x" << hex << setw(4) << setfill('0') << sa->type << dec - << " value: 0x" << hex << setw(8) << setfill('0') << sa->parameter << dec << endl; + std::cout << "Unknown SpawnAppearance type: 0x" << std::hex << std::setw(4) << std::setfill('0') << sa->type << std::dec + << " value: 0x" << std::hex << std::setw(8) << std::setfill('0') << sa->parameter << std::dec << std::endl; } return; } @@ -3220,7 +3217,7 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) if (!item) { if (ivrs->item_id > 500000) { - string response = ""; + std::string response = ""; int sayid = ivrs->item_id - 500000; bool silentsaylink = false; @@ -3584,7 +3581,7 @@ void Client::Handle_OP_ChannelMessage(const EQApplicationPacket *app) ChannelMessage_Struct* cm=(ChannelMessage_Struct*)app->pBuffer; if (app->size < sizeof(ChannelMessage_Struct)) { - cout << "Wrong size " << app->size << ", should be " << sizeof(ChannelMessage_Struct) << "+ on 0x" << hex << setfill('0') << setw(4) << app->GetOpcode() << dec << endl; + std::cout << "Wrong size " << app->size << ", should be " << sizeof(ChannelMessage_Struct) << "+ on 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec << std::endl; return; } if (IsAIControlled()) { @@ -3599,7 +3596,7 @@ void Client::Handle_OP_ChannelMessage(const EQApplicationPacket *app) void Client::Handle_OP_WearChange(const EQApplicationPacket *app) { if (app->size != sizeof(WearChange_Struct)) { - cout << "Wrong size: OP_WearChange, size=" << app->size << ", expected " << sizeof(WearChange_Struct) << endl; + std::cout << "Wrong size: OP_WearChange, size=" << app->size << ", expected " << sizeof(WearChange_Struct) << std::endl; return; } @@ -3653,7 +3650,7 @@ void Client::Handle_OP_Save(const EQApplicationPacket *app) void Client::Handle_OP_WhoAllRequest(const EQApplicationPacket *app) { if (app->size != sizeof(Who_All_Struct)) { - cout << "Wrong size on OP_WhoAll. Got: " << app->size << ", Expected: " << sizeof(Who_All_Struct) << endl; + std::cout << "Wrong size on OP_WhoAll. Got: " << app->size << ", Expected: " << sizeof(Who_All_Struct) << std::endl; return; } Who_All_Struct* whoall = (Who_All_Struct*) app->pBuffer; @@ -3675,7 +3672,7 @@ void Client::Handle_OP_FriendsWho(const EQApplicationPacket *app) void Client::Handle_OP_GMZoneRequest(const EQApplicationPacket *app) { if (app->size != sizeof(GMZoneRequest_Struct)) { - cout << "Wrong size on OP_GMZoneRequest. Got: " << app->size << ", Expected: " << sizeof(GMZoneRequest_Struct) << endl; + std::cout << "Wrong size on OP_GMZoneRequest. Got: " << app->size << ", Expected: " << sizeof(GMZoneRequest_Struct) << std::endl; return; } if (this->Admin() < minStatusToBeGM) { @@ -3715,7 +3712,7 @@ void Client::Handle_OP_GMZoneRequest(const EQApplicationPacket *app) if (tarzone[0] != 0 && admin >= minstatus && GetLevel() >= minlevel) gmzr2->success = 1; else { - cout << "GetZoneSafeCoords failed. zoneid = " << gmzr->zone_id << "; czone = " << zone->GetZoneID() << endl; + std::cout << "GetZoneSafeCoords failed. zoneid = " << gmzr->zone_id << "; czone = " << zone->GetZoneID() << std::endl; gmzr2->success = 0; } @@ -3744,7 +3741,7 @@ void Client::Handle_OP_GMZoneRequest2(const EQApplicationPacket *app) void Client::Handle_OP_EndLootRequest(const EQApplicationPacket *app) { if (app->size != sizeof(uint32)) { - cout << "Wrong size: OP_EndLootRequest, size=" << app->size << ", expected " << sizeof(uint32) << endl; + std::cout << "Wrong size: OP_EndLootRequest, size=" << app->size << ", expected " << sizeof(uint32) << std::endl; return; } @@ -3773,7 +3770,7 @@ void Client::Handle_OP_EndLootRequest(const EQApplicationPacket *app) void Client::Handle_OP_LootRequest(const EQApplicationPacket *app) { if (app->size != sizeof(uint32)) { - cout << "Wrong size: OP_LootRequest, size=" << app->size << ", expected " << sizeof(uint32) << endl; + std::cout << "Wrong size: OP_LootRequest, size=" << app->size << ", expected " << sizeof(uint32) << std::endl; return; } @@ -3824,7 +3821,7 @@ void Client::Handle_OP_LootRequest(const EQApplicationPacket *app) return; } else { - cout << "npc == 0 LOOTING FOOKED3" << endl; + std::cout << "npc == 0 LOOTING FOOKED3" << std::endl; Message(13, "Error: OP_LootRequest: Corpse not a corpse?"); Corpse::SendLootReqErrorPacket(this); } @@ -4252,7 +4249,7 @@ void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app) mpkt(GUILDS__IN_PACKET_TRACE, app); if (app->size != sizeof(GuildCommand_Struct)) { - cout << "Wrong size: OP_GuildInvite, size=" << app->size << ", expected " << sizeof(GuildCommand_Struct) << endl; + std::cout << "Wrong size: OP_GuildInvite, size=" << app->size << ", expected " << sizeof(GuildCommand_Struct) << std::endl; return; } @@ -4379,7 +4376,7 @@ void Client::Handle_OP_GuildRemove(const EQApplicationPacket *app) mpkt(GUILDS__IN_PACKET_TRACE, app); if (app->size != sizeof(GuildCommand_Struct)) { - cout << "Wrong size: OP_GuildRemove, size=" << app->size << ", expected " << sizeof(GuildCommand_Struct) << endl; + std::cout << "Wrong size: OP_GuildRemove, size=" << app->size << ", expected " << sizeof(GuildCommand_Struct) << std::endl; return; } GuildCommand_Struct* gc = (GuildCommand_Struct*) app->pBuffer; @@ -4450,7 +4447,7 @@ void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app) SetPendingGuildInvitation(false); if (app->size != sizeof(GuildInviteAccept_Struct)) { - cout << "Wrong size: OP_GuildInviteAccept, size=" << app->size << ", expected " << sizeof(GuildJoin_Struct) << endl; + std::cout << "Wrong size: OP_GuildInviteAccept, size=" << app->size << ", expected " << sizeof(GuildJoin_Struct) << std::endl; return; } @@ -4542,7 +4539,7 @@ void Client::Handle_OP_MemorizeSpell(const EQApplicationPacket *app) void Client::Handle_OP_SwapSpell(const EQApplicationPacket *app) { if (app->size != sizeof(SwapSpell_Struct)) { - cout << "Wrong size on OP_SwapSpell. Got: " << app->size << ", Expected: " << sizeof(SwapSpell_Struct) << endl; + std::cout << "Wrong size on OP_SwapSpell. Got: " << app->size << ", Expected: " << sizeof(SwapSpell_Struct) << std::endl; return; } const SwapSpell_Struct* swapspell = (const SwapSpell_Struct*) app->pBuffer; @@ -4562,7 +4559,7 @@ void Client::Handle_OP_SwapSpell(const EQApplicationPacket *app) void Client::Handle_OP_CastSpell(const EQApplicationPacket *app) { if (app->size != sizeof(CastSpell_Struct)) { - cout << "Wrong size: OP_CastSpell, size=" << app->size << ", expected " << sizeof(CastSpell_Struct) << endl; + std::cout << "Wrong size: OP_CastSpell, size=" << app->size << ", expected " << sizeof(CastSpell_Struct) << std::endl; return; } if (IsAIControlled()) { @@ -4746,7 +4743,7 @@ LogFile->write(EQEMuLog::Debug, "OP CastSpell: slot=%d, spell=%d, target=%d, inv void Client::Handle_OP_DeleteItem(const EQApplicationPacket *app) { if (app->size != sizeof(DeleteItem_Struct)) { - cout << "Wrong size on OP_DeleteItem. Got: " << app->size << ", Expected: " << sizeof(DeleteItem_Struct) << endl; + std::cout << "Wrong size on OP_DeleteItem. Got: " << app->size << ", Expected: " << sizeof(DeleteItem_Struct) << std::endl; return; } @@ -4780,7 +4777,7 @@ void Client::Handle_OP_DeleteItem(const EQApplicationPacket *app) void Client::Handle_OP_CombatAbility(const EQApplicationPacket *app) { if (app->size != sizeof(CombatAbility_Struct)) { - cout << "Wrong size on OP_CombatAbility. Got: " << app->size << ", Expected: " << sizeof(CombatAbility_Struct) << endl; + std::cout << "Wrong size on OP_CombatAbility. Got: " << app->size << ", Expected: " << sizeof(CombatAbility_Struct) << std::endl; return; } OPCombatAbility(app); @@ -4790,7 +4787,7 @@ void Client::Handle_OP_CombatAbility(const EQApplicationPacket *app) void Client::Handle_OP_Taunt(const EQApplicationPacket *app) { if (app->size != sizeof(ClientTarget_Struct)) { - cout << "Wrong size on OP_Taunt. Got: " << app->size << ", Expected: "<< sizeof(ClientTarget_Struct) << endl; + std::cout << "Wrong size on OP_Taunt. Got: " << app->size << ", Expected: "<< sizeof(ClientTarget_Struct) << std::endl; return; } @@ -4849,7 +4846,7 @@ void Client::Handle_OP_RezzAnswer(const EQApplicationPacket *app) void Client::Handle_OP_GMSummon(const EQApplicationPacket *app) { if (app->size != sizeof(GMSummon_Struct)) { - cout << "Wrong size on OP_GMSummon. Got: " << app->size << ", Expected: " << sizeof(GMSummon_Struct) << endl; + std::cout << "Wrong size on OP_GMSummon. Got: " << app->size << ", Expected: " << sizeof(GMSummon_Struct) << std::endl; return; } OPGMSummon(app); @@ -5249,7 +5246,7 @@ void Client::Handle_OP_GMKill(const EQApplicationPacket *app) void Client::Handle_OP_GMLastName(const EQApplicationPacket *app) { if (app->size != sizeof(GMLastName_Struct)) { - cout << "Wrong size on OP_GMLastName. Got: " << app->size << ", Expected: " << sizeof(GMLastName_Struct) << endl; + std::cout << "Wrong size on OP_GMLastName. Got: " << app->size << ", Expected: " << sizeof(GMLastName_Struct) << std::endl; return; } GMLastName_Struct* gmln = (GMLastName_Struct*) app->pBuffer; @@ -5283,7 +5280,7 @@ void Client::Handle_OP_GMLastName(const EQApplicationPacket *app) void Client::Handle_OP_GMToggle(const EQApplicationPacket *app) { if (app->size != sizeof(GMToggle_Struct)) { - cout << "Wrong size on OP_GMToggle. Got: " << app->size << ", Expected: " << sizeof(GMToggle_Struct) << endl; + std::cout << "Wrong size on OP_GMToggle. Got: " << app->size << ", Expected: " << sizeof(GMToggle_Struct) << std::endl; return; } if (this->Admin() < minStatusToUseGMCommands) { @@ -5312,7 +5309,7 @@ void Client::Handle_OP_GMToggle(const EQApplicationPacket *app) void Client::Handle_OP_LFGCommand(const EQApplicationPacket *app) { if (app->size != sizeof(LFG_Struct)) { - cout << "Wrong size on OP_LFGCommand. Got: " << app->size << ", Expected: " << sizeof(LFG_Struct) << endl; + std::cout << "Wrong size on OP_LFGCommand. Got: " << app->size << ", Expected: " << sizeof(LFG_Struct) << std::endl; DumpPacket(app); return; } @@ -5358,7 +5355,7 @@ void Client::Handle_OP_LFGCommand(const EQApplicationPacket *app) void Client::Handle_OP_GMGoto(const EQApplicationPacket *app) { if (app->size != sizeof(GMSummon_Struct)) { - cout << "Wrong size on OP_GMGoto. Got: " << app->size << ", Expected: " << sizeof(GMSummon_Struct) << endl; + std::cout << "Wrong size on OP_GMGoto. Got: " << app->size << ", Expected: " << sizeof(GMSummon_Struct) << std::endl; return; } if (this->Admin() < minStatusToUseGMCommands) { @@ -5728,7 +5725,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) return; } - string packet; + std::string packet; if(mp->quantity==1 && item->MaxCharges>0 && item->MaxCharges<255) mp->quantity=item->MaxCharges; @@ -5810,7 +5807,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) } t1.stop(); - cout << "At 1: " << t1.getDuration() << endl; + std::cout << "At 1: " << t1.getDuration() << std::endl; return; } @@ -5955,7 +5952,7 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) t1.start(); Save(1); t1.stop(); - cout << "Save took: " << t1.getDuration() << endl; + std::cout << "Save took: " << t1.getDuration() << std::endl; return; } @@ -7057,7 +7054,7 @@ void Client::Handle_OP_PetitionDelete(const EQApplicationPacket *app) FastQueuePacket(&outapp); if (petition_list.DeletePetition(pet->petnumber) == -1) - cout << "Something is borked with: " << pet->petnumber << endl; + std::cout << "Something is borked with: " << pet->petnumber << std::endl; petition_list.ClearPetitions(); petition_list.UpdateGMQueue(); petition_list.ReadDatabase(); @@ -7339,7 +7336,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) void Client::Handle_OP_PetitionUnCheckout(const EQApplicationPacket *app) { if (app->size != sizeof(uint32)) { - cout << "Wrong size: OP_PetitionUnCheckout, size=" << app->size << ", expected " << sizeof(uint32) << endl; + std::cout << "Wrong size: OP_PetitionUnCheckout, size=" << app->size << ", expected " << sizeof(uint32) << std::endl; return; } if (!worldserver.Connected()) @@ -7381,7 +7378,7 @@ void Client::Handle_OP_PDeletePetition(const EQApplicationPacket *app) void Client::Handle_OP_PetitionCheckout(const EQApplicationPacket *app) { if (app->size != sizeof(uint32)) { - cout << "Wrong size: OP_PetitionCheckout, size=" << app->size << ", expected " << sizeof(uint32) << endl; + std::cout << "Wrong size: OP_PetitionCheckout, size=" << app->size << ", expected " << sizeof(uint32) << std::endl; return; } if (!worldserver.Connected()) @@ -7525,7 +7522,7 @@ void Client::Handle_OP_GMDelCorpse(const EQApplicationPacket *app) return; } corpse->CastToCorpse()->Delete(); - cout << name << " deleted corpse " << dc->corpsename << endl; + std::cout << name << " deleted corpse " << dc->corpsename << std::endl; Message(13, "Corpse %s deleted.", dc->corpsename); return; } @@ -8594,7 +8591,7 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app) else { FindPersonRequest_Struct* t = (FindPersonRequest_Struct*)app->pBuffer; - vector points; + std::vector points; Message(13, "Searched for NPC ID: %d\n", t->npc_id); Mob* target = entity_list.GetMob(t->npc_id); @@ -8645,7 +8642,7 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app) } else { - list pathlist = zone->pathing->FindRoute(Start, End); + std::list pathlist = zone->pathing->FindRoute(Start, End); if(pathlist.size() == 0) { @@ -8684,7 +8681,7 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app) p.z = GetZ(); points.push_back(p); - for(list::iterator Iterator = pathlist.begin(); Iterator != pathlist.end(); ++Iterator) + for(std::list::iterator Iterator = pathlist.begin(); Iterator != pathlist.end(); ++Iterator) { if((*Iterator) == -1) // Teleporter { @@ -8735,7 +8732,7 @@ void Client::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) { } } else { - cout << "Async client save failed. '" << errbuf << "'" << endl; + std::cout << "Async client save failed. '" << errbuf << "'" << std::endl; Message(13, "Error: Asyncronous save of your character failed."); if (Admin() >= 200) Message(13, "errbuf: %s", errbuf); @@ -8744,7 +8741,7 @@ void Client::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) { break; } default: { - cout << "Error: Client::DBAWComplete(): Unknown workpt_b1" << endl; + std::cout << "Error: Client::DBAWComplete(): Unknown workpt_b1" << std::endl; break; } } @@ -8762,11 +8759,11 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { for (i=1; i<=3; i++) { dbaq = dbaw->PopAnswer(); if (!dbaq) { - cout << "Error in FinishConnState2(): dbaq==0" << endl; + std::cout << "Error in FinishConnState2(): dbaq==0" << std::endl; return false; } if (!dbaq->GetAnswer(errbuf, &result)) { - cout << "Error in FinishConnState2(): !dbaq[" << dbaq->QPT() << "]->GetAnswer(): " << errbuf << endl; + std::cout << "Error in FinishConnState2(): !dbaq[" << dbaq->QPT() << "]->GetAnswer(): " << errbuf << std::endl; return false; } if (dbaq->QPT() == 1) { @@ -8784,7 +8781,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { database.LoadFactionValues_result(result, factionvalues); } else { - cout << "Error in FinishConnState2(): dbaq->PQT() unknown" << endl; + std::cout << "Error in FinishConnState2(): dbaq->PQT() unknown" << std::endl; return false; } } @@ -9793,7 +9790,7 @@ void Client::Handle_OP_SetTitle(const EQApplicationPacket *app) SetTitle_Struct *sts = (SetTitle_Struct *)app->pBuffer; - string Title; + std::string Title; if(!sts->is_suffix) { @@ -11604,8 +11601,8 @@ void Client::Handle_OP_Report(const EQApplicationPacket *app) uint32 size = app->size; uint32 current_point = 0; - string reported, reporter; - string current_string; + std::string reported, reporter; + std::string current_string; int mode = 0; while(current_point < size) @@ -11742,7 +11739,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) char CharName[64], TimeOfDeath[20], Buffer[512]; - string PopupText = "
NameZoneXYZDate" + std::string PopupText = ""; @@ -12490,7 +12487,7 @@ void Client::Handle_OP_CorpseDrop(const EQApplicationPacket *app) return; } - for(std::list::iterator Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator) + for(std::list::iterator Iterator = DraggedCorpses.begin(); Iterator != DraggedCorpses.end(); ++Iterator) { if(!strcasecmp((*Iterator).c_str(), (const char *)app->pBuffer)) { @@ -12616,7 +12613,7 @@ void Client::Handle_OP_AltCurrencyMerchantRequest(const EQApplicationPacket *app return; } - list::iterator altc_iter = zone->AlternateCurrencies.begin(); + std::list::iterator altc_iter = zone->AlternateCurrencies.begin(); bool found = false; while(altc_iter != zone->AlternateCurrencies.end()) { if((*altc_iter).id == alt_cur_id) { @@ -12825,7 +12822,7 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) { VERIFY_PACKET_LENGTH(OP_AltCurrencyReclaim, app, AltCurrencyReclaim_Struct); AltCurrencyReclaim_Struct *reclaim = (AltCurrencyReclaim_Struct*)app->pBuffer; uint32 item_id = 0; - list::iterator iter = zone->AlternateCurrencies.begin(); + std::list::iterator iter = zone->AlternateCurrencies.begin(); while(iter != zone->AlternateCurrencies.end()) { if((*iter).id == reclaim->currency_id) { item_id = (*iter).item_id; @@ -13579,7 +13576,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) for(std::list::iterator mercListItr = mercDataList.begin(); mercListItr != mercDataList.end(); mercListItr++) { - list::iterator siter = zone->merc_stance_list[mercListItr->MercTemplateID].begin(); + std::list::iterator siter = zone->merc_stance_list[mercListItr->MercTemplateID].begin(); for(siter = zone->merc_stance_list[mercListItr->MercTemplateID].begin(); siter != zone->merc_stance_list[mercListItr->MercTemplateID].end(); siter++) { StanceCount++; @@ -13618,7 +13615,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) mml->Mercs[i].MerchantSlot = i + 1; mml->Mercs[i].MercUnk02 = 1; int mercStanceCount = 0; - list::iterator iter = zone->merc_stance_list[mercListIter->MercTemplateID].begin(); + std::list::iterator iter = zone->merc_stance_list[mercListIter->MercTemplateID].begin(); for(iter = zone->merc_stance_list[mercListIter->MercTemplateID].begin(); iter != zone->merc_stance_list[mercListIter->MercTemplateID].end(); iter++) { mercStanceCount++; @@ -13630,7 +13627,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) int stanceindex = 0; if(mercStanceCount > 0) { - list::iterator iter2 = zone->merc_stance_list[mercListIter->MercTemplateID].begin(); + std::list::iterator iter2 = zone->merc_stance_list[mercListIter->MercTemplateID].begin(); while(iter2 != zone->merc_stance_list[mercListIter->MercTemplateID].end()) { mml->Mercs[i].Stances[stanceindex].StanceIndex = stanceindex; @@ -13768,7 +13765,7 @@ void Client::Handle_OP_MercenaryCommand(const EQApplicationPacket *app) //get number of available stances for the current merc std::list mercStanceList = zone->merc_stance_list[merc->GetMercTemplateID()]; - list::iterator iter = mercStanceList.begin(); + std::list::iterator iter = mercStanceList.begin(); while(iter != mercStanceList.end()) { numStances++; iter++; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 63d2db72a..a326abf22 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -67,9 +67,6 @@ #include #include "QuestParserCollection.h" -using namespace std; - - extern Zone* zone; extern volatile bool ZoneLoaded; extern WorldServer worldserver; @@ -656,26 +653,26 @@ bool Client::Process() { if (client_state == CLIENT_KICKED) { Save(); OnDisconnect(true); - cout << "Client disconnected (cs=k): " << GetName() << endl; + std::cout << "Client disconnected (cs=k): " << GetName() << std::endl; return false; } if (client_state == DISCONNECTED) { OnDisconnect(true); - cout << "Client disconnected (cs=d): " << GetName() << endl; + std::cout << "Client disconnected (cs=d): " << GetName() << std::endl; database.SetMQDetectionFlag(this->AccountName(), GetName(), "/MQInstantCamp: Possible instant camp disconnect.", zone->GetShortName()); return false; } if (client_state == CLIENT_ERROR) { OnDisconnect(true); - cout << "Client disconnected (cs=e): " << GetName() << endl; + std::cout << "Client disconnected (cs=e): " << GetName() << std::endl; return false; } if (client_state != CLIENT_LINKDEAD && !eqs->CheckState(ESTABLISHED)) { OnDisconnect(true); - cout << "Client linkdead: " << name << endl; + std::cout << "Client linkdead: " << name << std::endl; if (GetGM()) { if (GetMerc()) @@ -879,14 +876,14 @@ void Client::BulkSendInventoryItems() { uint32 size = 0; uint16 i = 0; - map ser_items; - map::iterator itr; + std::map ser_items; + std::map::iterator itr; //Inventory items for(slot_id = 0; slot_id <= 30; slot_id++) { const ItemInst* inst = m_inv[slot_id]; if(inst) { - string packet = inst->Serialize(slot_id); + std::string packet = inst->Serialize(slot_id); ser_items[i++] = packet; size += packet.length(); } @@ -896,7 +893,7 @@ void Client::BulkSendInventoryItems() { if(GetClientVersion() >= EQClientSoF) { const ItemInst* inst = m_inv[9999]; if(inst) { - string packet = inst->Serialize(9999); + std::string packet = inst->Serialize(9999); ser_items[i++] = packet; size += packet.length(); } @@ -906,7 +903,7 @@ void Client::BulkSendInventoryItems() { for(slot_id = 2000; slot_id <= 2023; slot_id++) { const ItemInst* inst = m_inv[slot_id]; if(inst) { - string packet = inst->Serialize(slot_id); + std::string packet = inst->Serialize(slot_id); ser_items[i++] = packet; size += packet.length(); } @@ -916,7 +913,7 @@ void Client::BulkSendInventoryItems() { for(slot_id = 2500; slot_id <= 2501; slot_id++) { const ItemInst* inst = m_inv[slot_id]; if(inst) { - string packet = inst->Serialize(slot_id); + std::string packet = inst->Serialize(slot_id); ser_items[i++] = packet; size += packet.length(); } @@ -1693,7 +1690,7 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app) // languages go here if (gmskill->skill_id > 25) { - cout << "Wrong Training Skill (languages)" << endl; + std::cout << "Wrong Training Skill (languages)" << std::endl; DumpPacket(app); return; } @@ -1708,7 +1705,7 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app) // normal skills go here if (gmskill->skill_id > HIGHEST_SKILL) { - cout << "Wrong Training Skill (abilities)" << endl; + std::cout << "Wrong Training Skill (abilities)" << std::endl; DumpPacket(app); return; } diff --git a/zone/command.cpp b/zone/command.cpp index 3c04933db..4b8576fca 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -85,7 +85,7 @@ int (*command_dispatch)(Client *,char const *)=command_notavail; void command_bestz(Client *c, const Seperator *message); void command_pf(Client *c, const Seperator *message); -map commandlist; +std::map commandlist; //All allocated CommandRecords get put in here so they get deleted on shutdown LinkedList cleanup_commandlist; @@ -460,11 +460,11 @@ int command_init(void) { return -1; } - map::iterator cur,end; + std::map::iterator cur,end; cur = commandlist.begin(); end = commandlist.end(); - map command_settings; - map::iterator itr; + std::map command_settings; + std::map::iterator itr; database.GetCommandSettings(command_settings); for(; cur != end; cur++) { if ((itr=command_settings.find(cur->first))!=command_settings.end()) @@ -526,7 +526,7 @@ int command_add(const char *command_string, const char *desc, int access, CmdFun if(function == nullptr) return(-1); - string cstr(command_string); + std::string cstr(command_string); if(commandlist.count(cstr) != 0) { LogFile->write(EQEMuLog::Error, "command_add() - Command '%s' is a duplicate - check command.cpp." , command_string); @@ -534,7 +534,7 @@ int command_add(const char *command_string, const char *desc, int access, CmdFun } //look for aliases... - map::iterator cur,end,del; + std::map::iterator cur,end,del; cur = commandlist.begin(); end = commandlist.end(); for(; cur != end; cur++) { @@ -578,7 +578,7 @@ int command_add(const char *command_string, const char *desc, int access, CmdFun * */ int command_add_perl(const char *command_string, const char *desc, int access) { - string cstr(command_string); + std::string cstr(command_string); if(commandlist.count(cstr) != 0) { #ifdef COMMANDS_PERL_OVERRIDE @@ -607,7 +607,7 @@ int command_add_perl(const char *command_string, const char *desc, int access) { //clear out any perl commands. //should restore any overridden C++ commands, but thats a lot of work. void command_clear_perl() { - map::iterator cur,end,del; + std::map::iterator cur,end,del; cur = commandlist.begin(); end = commandlist.end(); for(; cur != end;) { @@ -644,7 +644,7 @@ int command_realdispatch(Client *c, const char *message) command_logcommand(c, message); - string cstr(sep.arg[0]+1); + std::string cstr(sep.arg[0]+1); if(commandlist.count(cstr) != 1) { return(-2); @@ -917,13 +917,13 @@ void command_help(Client *c, const Seperator *sep) c->Message(0, "Available EQEMu commands:"); - map::iterator cur,end; + std::map::iterator cur,end; cur = commandlist.begin(); end = commandlist.end(); for(; cur != end; cur++) { if(sep->arg[1][0]) { - if(cur->first.find(sep->arg[1]) == string::npos) { + if(cur->first.find(sep->arg[1]) == std::string::npos) { continue; } } @@ -6763,7 +6763,7 @@ void command_timers(Client *c, const Seperator *sep) { } Client *them = c->GetTarget()->CastToClient(); - vector< pair > res; + std::vector< std::pair > res; them->GetPTimers().ToVector(res); c->Message(0,"Timers for target:"); @@ -8286,8 +8286,8 @@ void command_mlog(Client *c, const Seperator *sep) { return; } bool onoff; - string on("on"); - string off("off"); + std::string on("on"); + std::string off("off"); if(!strcasecmp(sep->arg[1], "target")) { if(on == sep->arg[2]) onoff = true; diff --git a/zone/doors.cpp b/zone/doors.cpp index bdb07f062..e66e9d979 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -19,7 +19,6 @@ #include #include #include -using namespace std; #include "masterentity.h" #include "worldserver.h" #include "StringIDs.h" @@ -243,7 +242,7 @@ void Doors::HandleClick(Client* sender, uint8 trigger) { // guild doors if((guild_id > 0) && !sender->GetGM()) { - string tmp; + std::string tmp; char tmpmsg[240]; // guild doors msgs if(guild_mgr.GetGuildNameByID(guild_id, tmp)) { @@ -594,7 +593,7 @@ int32 ZoneDatabase::GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 v mysql_free_result(result); } else { - cerr << "Error in GetDoorsCount query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetDoorsCount query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return -1; } @@ -625,7 +624,7 @@ int32 ZoneDatabase::GetDoorsCountPlusOne(const char *zone_name, int16 version) { mysql_free_result(result); } else { - cerr << "Error in GetDoorsCountPlusOne query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetDoorsCountPlusOne query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return -1; } @@ -656,7 +655,7 @@ int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version) mysql_free_result(result); } else { - cerr << "Error in GetDoorsCountPlusOne query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetDoorsCountPlusOne query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return -1; } @@ -681,7 +680,7 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name int32 r; for(r = 0; (row = mysql_fetch_row(result)); r++) { if(r >= iDoorCount) { - cerr << "Error, Door Count of " << iDoorCount << " exceeded." << endl; + std::cerr << "Error, Door Count of " << iDoorCount << " exceeded." << std::endl; break; } memset(&into[r], 0, sizeof(Door)); @@ -717,7 +716,7 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name } else { - cerr << "Error in DBLoadDoors query '" << query << "' " << errbuf << endl; + std::cerr << "Error in DBLoadDoors query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } diff --git a/zone/embparser.cpp b/zone/embparser.cpp index b27293de4..8f228723d 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -131,7 +131,7 @@ void PerlembParser::ExportVar(const char * pkgprefix, const char * varname, cons } // Exports key-value pairs to a hash named pkgprefix::hashname -void PerlembParser::ExportHash(const char *pkgprefix, const char *hashname, std::map &vals) +void PerlembParser::ExportHash(const char *pkgprefix, const char *hashname, std::map &vals) { if (!perl) return; @@ -271,7 +271,7 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d } } - string packagename; + std::string packagename; if(!isPlayerQuest && !isGlobalPlayerQuest && !isItemQuest && !isSpellQuest){ if(global){ @@ -370,7 +370,7 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d //only export for npcs that are global enabled. if(npcmob && npcmob->GetQglobal()) { - map globhash; + std::map globhash; QGlobalCache *npc_c = nullptr; QGlobalCache *char_c = nullptr; QGlobalCache *zone_c = nullptr; @@ -431,7 +431,7 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d } else { - map globhash; + std::map globhash; QGlobalCache *char_c = nullptr; QGlobalCache *zone_c = nullptr; @@ -553,7 +553,7 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d if(mob && mob->IsClient()) { - string hashname = packagename + std::string("::hasitem"); + std::string hashname = packagename + std::string("::hasitem"); #if EQDEBUG >= 7 LogFile->write(EQEMuLog::Debug, "starting hasitem, on : %s",hashname.c_str() ); #endif @@ -579,7 +579,7 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d } // $oncursor if(mob && mob->IsClient()) { - string hashname = packagename + std::string("::oncursor"); + std::string hashname = packagename + std::string("::oncursor"); perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); char *hi_decl = nullptr; int itemid = mob->CastToClient()->GetItemIDAt(30); @@ -619,7 +619,7 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d ExportVar(packagename.c_str(), "silver", GetVar("silver", objid).c_str()); ExportVar(packagename.c_str(), "gold", GetVar("gold", objid).c_str()); ExportVar(packagename.c_str(), "platinum", GetVar("platinum", objid).c_str()); - string hashname = packagename + std::string("::itemcount"); + std::string hashname = packagename + std::string("::itemcount"); perl->eval(std::string("%").append(hashname).append(" = ();").c_str()); perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item1};").c_str()); perl->eval(std::string("++$").append(hashname).append("{$").append(packagename).append("::item2};").c_str()); @@ -933,7 +933,7 @@ int PerlembParser::LoadScript(int npcid, const char * zone, Mob* activater) return(1); } - string filename = "quests/", packagename = GetPkgPrefix(npcid); + std::string filename = "quests/", packagename = GetPkgPrefix(npcid); //each package name is of the form qstxxxx where xxxx = npcid (since numbers alone are not valid package names) questMode curmode = questDefault; FILE *tmpf; @@ -950,7 +950,7 @@ int PerlembParser::LoadScript(int npcid, const char * zone, Mob* activater) filename += zone; filename += "/"; #ifdef QUEST_SCRIPTS_BYNAME - string bnfilename = filename; + std::string bnfilename = filename; #endif filename += itoa(npcid); filename += ".pl"; @@ -1190,10 +1190,10 @@ int PerlembParser::LoadGlobalNPCScript() return 1; } - string filename = "quests/"; + std::string filename = "quests/"; filename += QUEST_TEMPLATES_DIRECTORY; filename += "/global_npc.pl"; - string packagename = "global_npc"; + std::string packagename = "global_npc"; try { perl->eval_file(packagename.c_str(), filename.c_str()); @@ -1222,12 +1222,12 @@ int PerlembParser::LoadPlayerScript(const char *zone_name) return 1; } - string filename= "quests/"; + std::string filename= "quests/"; filename += zone_name; filename += "/player_v"; filename += itoa(zone->GetInstanceVersion()); filename += ".pl"; - string packagename = "player"; + std::string packagename = "player"; packagename += "_"; packagename += zone_name; @@ -1294,10 +1294,10 @@ int PerlembParser::LoadGlobalPlayerScript() return 1; } - string filename = "quests/"; + std::string filename = "quests/"; filename += QUEST_TEMPLATES_DIRECTORY; filename += "/global_player.pl"; - string packagename = "global_player"; + std::string packagename = "global_player"; try { perl->eval_file(packagename.c_str(), filename.c_str()); @@ -1314,7 +1314,7 @@ int PerlembParser::LoadGlobalPlayerScript() return 1; } -int PerlembParser::LoadItemScript(ItemInst* iteminst, string packagename, itemQuestMode Qtype) { +int PerlembParser::LoadItemScript(ItemInst* iteminst, std::string packagename, itemQuestMode Qtype) { if(!perl) return 0; @@ -1327,7 +1327,7 @@ int PerlembParser::LoadItemScript(ItemInst* iteminst, string packagename, itemQu if(itemQuestLoaded.count(packagename) == 1) return 1; - string filename = "quests/items/"; + std::string filename = "quests/items/"; if(Qtype == itemQuestScale) filename += packagename; else if(Qtype == itemQuestLore) { @@ -1373,8 +1373,8 @@ int PerlembParser::LoadSpellScript(uint32 id) if(spellQuestLoaded.count(id) == 1) return 1; - string filename = "quests/spells/"; - string packagename = "spell_effect_"; + std::string filename = "quests/spells/"; + std::string packagename = "spell_effect_"; filename += itoa(id); packagename += itoa(id); filename += ".pl"; @@ -1441,7 +1441,7 @@ bool PerlembParser::HasQuestSub(uint32 npcid, const char *subname) { } } - string packagename = GetPkgPrefix(npcid); + std::string packagename = GetPkgPrefix(npcid); return(perl->SubExists(packagename.c_str(), subname)); } @@ -1451,14 +1451,14 @@ bool PerlembParser::HasGlobalQuestSub(const char *subname) { return(false); } - string packagename = "global_npc"; + std::string packagename = "global_npc"; return(perl->SubExists(packagename.c_str(), subname)); } bool PerlembParser::PlayerHasQuestSub(const char *subname) { - string packagename = "player_"; + std::string packagename = "player_"; packagename += zone->GetShortName(); if(playerQuestLoaded.count(zone->GetShortName()) == 0) @@ -1472,7 +1472,7 @@ bool PerlembParser::PlayerHasQuestSub(const char *subname) { bool PerlembParser::GlobalPlayerHasQuestSub(const char *subname) { - string packagename = "global_player"; + std::string packagename = "global_player"; if(globalPlayerQuestLoaded == pQuestReadyToLoad) LoadGlobalPlayerScript(); @@ -1485,7 +1485,7 @@ bool PerlembParser::GlobalPlayerHasQuestSub(const char *subname) { bool PerlembParser::SpellHasQuestSub(uint32 id, const char *subname) { - string packagename = "spell_effect_"; + std::string packagename = "spell_effect_"; packagename += itoa(id); if(spellQuestLoaded.count(id) == 0) @@ -1496,7 +1496,7 @@ bool PerlembParser::SpellHasQuestSub(uint32 id, const char *subname) bool PerlembParser::ItemHasQuestSub(ItemInst *itm, const char *subname) { - string packagename; + std::string packagename; const Item_Struct* item = itm->GetItem(); if(!item) return false; diff --git a/zone/embparser.h b/zone/embparser.h index 2181f6db0..7a9efe405 100644 --- a/zone/embparser.h +++ b/zone/embparser.h @@ -16,7 +16,6 @@ #include #include #include -using namespace std; class Seperator; @@ -60,7 +59,7 @@ typedef enum { struct EventRecord { QuestEventID event; uint32 objid; - string data; + std::string data; NPC* npcmob; ItemInst* iteminst; Mob* mob; @@ -75,14 +74,14 @@ protected: //could prolly get rid of this map now, since I check for the //actual subroutine in the quest package as opposed to just seeing //if they do not have a quest or the default. - map hasQuests; //npcid -> questMode - map playerQuestLoaded; //zone shortname -> playerQuestMode + std::map hasQuests; //npcid -> questMode + std::map playerQuestLoaded; //zone shortname -> playerQuestMode playerQuestMode globalPlayerQuestLoaded; GlobalNPCQuestMode globalNPCQuestLoaded; - map itemQuestLoaded; // package name - > itemQuestMode - map spellQuestLoaded; + std::map itemQuestLoaded; // package name - > itemQuestMode + std::map spellQuestLoaded; - queue eventQueue; //for events that happen when perl is in use. + std::queue eventQueue; //for events that happen when perl is in use. bool eventQueueProcessing; void HandleQueue(); @@ -122,13 +121,13 @@ public: int LoadGlobalNPCScript(); int LoadPlayerScript(const char *zone); int LoadGlobalPlayerScript(); - int LoadItemScript(ItemInst* iteminst, string packagename, itemQuestMode Qtype); + int LoadItemScript(ItemInst* iteminst, std::string packagename, itemQuestMode Qtype); int LoadSpellScript(uint32 id); //expose a var to the script (probably parallels addvar)) //i.e. exportvar("qst1234", "name", "somemob"); //would expose the variable $name='somemob' to the script that handles npc1234 - void ExportHash(const char *pkgprefix, const char *hashname, std::map &vals); + void ExportHash(const char *pkgprefix, const char *hashname, std::map &vals); void ExportVar(const char * pkgprefix, const char * varname, const char * value) const; void ExportVar(const char * pkgprefix, const char * varname, int value) const; void ExportVar(const char * pkgprefix, const char * varname, unsigned int value) const; diff --git a/zone/entity.cpp b/zone/entity.cpp index bfe12c17f..21b17308a 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -22,7 +22,6 @@ #include #include #include -using namespace std; #ifdef _WINDOWS #include @@ -83,13 +82,13 @@ void Entity::SetID(uint16 set_id) { Client* Entity::CastToClient() { if(this==0x00){ - cout << "CastToClient error (nullptr)" << endl; + std::cout << "CastToClient error (nullptr)" << std::endl; DebugBreak(); return 0; } #ifdef _EQDEBUG if(!IsClient()) { - cout << "CastToClient error (not client?)" << endl; + std::cout << "CastToClient error (not client?)" << std::endl; DebugBreak(); return 0; } @@ -100,7 +99,7 @@ Client* Entity::CastToClient() { NPC* Entity::CastToNPC() { #ifdef _EQDEBUG if(!IsNPC()) { - cout << "CastToNPC error" << endl; + std::cout << "CastToNPC error" << std::endl; DebugBreak(); return 0; } @@ -111,7 +110,7 @@ NPC* Entity::CastToNPC() { Mob* Entity::CastToMob() { #ifdef _EQDEBUG if(!IsMob()) { - cout << "CastToMob error" << endl; + std::cout << "CastToMob error" << std::endl; DebugBreak(); return 0; } @@ -122,7 +121,7 @@ Mob* Entity::CastToMob() { Merc* Entity::CastToMerc() { #ifdef _EQDEBUG if(!IsMerc()) { - cout << "CastToMerc error" << endl; + std::cout << "CastToMerc error" << std::endl; DebugBreak(); return 0; } @@ -146,7 +145,7 @@ Trap* Entity::CastToTrap() Corpse* Entity::CastToCorpse() { #ifdef _EQDEBUG if(!IsCorpse()) { - cout << "CastToCorpse error" << endl; + std::cout << "CastToCorpse error" << std::endl; DebugBreak(); return 0; } @@ -156,7 +155,7 @@ Corpse* Entity::CastToCorpse() { Object* Entity::CastToObject() { #ifdef _EQDEBUG if(!IsObject()) { - cout << "CastToObject error" << endl; + std::cout << "CastToObject error" << std::endl; DebugBreak(); return 0; } @@ -183,18 +182,15 @@ Beacon* Entity::CastToBeacon() { return static_cast(this); } - - - const Client* Entity::CastToClient() const { if(this==0x00){ - cout << "CastToClient error (nullptr)" << endl; + std::cout << "CastToClient error (nullptr)" << std::endl; DebugBreak(); return 0; } #ifdef _EQDEBUG if(!IsClient()) { - cout << "CastToClient error (not client?)" << endl; + std::cout << "CastToClient error (not client?)" << std::endl; DebugBreak(); return 0; } @@ -205,7 +201,7 @@ const Client* Entity::CastToClient() const { const NPC* Entity::CastToNPC() const { #ifdef _EQDEBUG if(!IsNPC()) { - cout << "CastToNPC error" << endl; + std::cout << "CastToNPC error" << std::endl; DebugBreak(); return 0; } @@ -216,7 +212,7 @@ const NPC* Entity::CastToNPC() const { const Mob* Entity::CastToMob() const { #ifdef _EQDEBUG if(!IsMob()) { - cout << "CastToMob error" << endl; + std::cout << "CastToMob error" << std::endl; DebugBreak(); return 0; } @@ -227,7 +223,7 @@ const Mob* Entity::CastToMob() const { const Merc* Entity::CastToMerc() const { #ifdef _EQDEBUG if(!IsMerc()) { - cout << "CastToMerc error" << endl; + std::cout << "CastToMerc error" << std::endl; DebugBreak(); return 0; } @@ -249,7 +245,7 @@ const Trap* Entity::CastToTrap() const { const Corpse* Entity::CastToCorpse() const { #ifdef _EQDEBUG if(!IsCorpse()) { - cout << "CastToCorpse error" << endl; + std::cout << "CastToCorpse error" << std::endl; DebugBreak(); return 0; } @@ -260,7 +256,7 @@ const Corpse* Entity::CastToCorpse() const { const Object* Entity::CastToObject() const { #ifdef _EQDEBUG if(!IsObject()) { - cout << "CastToObject error" << endl; + std::cout << "CastToObject error" << std::endl; DebugBreak(); return 0; } @@ -280,7 +276,7 @@ const Beacon* Entity::CastToBeacon() const { Bot* Entity::CastToBot() { #ifdef _EQDEBUG if(!IsBot()) { - cout << "CastToBot error" << endl; + std::cout << "CastToBot error" << std::endl; DebugBreak(); return 0; } @@ -355,7 +351,7 @@ void EntityList::TrapProcess() { // to track down bugs. void EntityList::CheckGroupList (const char *fname, const int fline) { - list::iterator it; + std::list::iterator it; for (it = group_list.begin(); it != group_list.end(); it++) { @@ -367,7 +363,7 @@ void EntityList::CheckGroupList (const char *fname, const int fline) } void EntityList::GroupProcess() { - list::iterator iterator; + std::list::iterator iterator; uint32 count = 0; if(numclients < 1) @@ -399,7 +395,7 @@ void EntityList::GroupProcess() { void EntityList::QueueToGroupsForNPCHealthAA(Mob* sender, const EQApplicationPacket* app) { - list::iterator iterator = group_list.begin(); + std::list::iterator iterator = group_list.begin(); _ZP(EntityList_QueueToGroupsForNPCHealthAA); @@ -411,7 +407,7 @@ void EntityList::QueueToGroupsForNPCHealthAA(Mob* sender, const EQApplicationPac } void EntityList::RaidProcess() { - list::iterator iterator; + std::list::iterator iterator; uint32 count = 0; if(numclients < 1) @@ -518,7 +514,7 @@ void EntityList::MobProcess() { #ifdef _WINDOWS struct in_addr in; in.s_addr = mob->CastToClient()->GetIP(); - cout << "Dropping client: Process=false, ip=" << inet_ntoa(in) << ", port=" << mob->CastToClient()->GetPort() << endl; + std::cout << "Dropping client: Process=false, ip=" << inet_ntoa(in) << ", port=" << mob->CastToClient()->GetPort() << std::endl; #endif zone->StartShutdownTimer(); Group *g = GetGroupByMob(mob); @@ -1952,7 +1948,7 @@ Client* EntityList::GetClientByWID(uint32 iWID) { Client* EntityList::GetRandomClient(float x, float y, float z, float Distance, Client* ExcludeClient) { - vector ClientsInRange; + std::vector ClientsInRange; LinkedListIterator iterator(client_list); @@ -2093,7 +2089,7 @@ int EntityList::RezzAllCorpsesByCharID(uint32 charid) Group* EntityList::GetGroupByMob(Mob* mob) { - list::iterator iterator; + std::list::iterator iterator; iterator = group_list.begin(); @@ -2111,7 +2107,7 @@ Group* EntityList::GetGroupByMob(Mob* mob) } Group* EntityList::GetGroupByLeaderName(char* leader){ - list::iterator iterator; + std::list::iterator iterator; iterator = group_list.begin(); @@ -2128,7 +2124,7 @@ Group* EntityList::GetGroupByLeaderName(char* leader){ return 0; } Group* EntityList::GetGroupByID(uint32 group_id){ - list::iterator iterator; + std::list::iterator iterator; iterator = group_list.begin(); @@ -2146,7 +2142,7 @@ Group* EntityList::GetGroupByID(uint32 group_id){ } Group* EntityList::GetGroupByClient(Client* client) { - list ::iterator iterator; + std::list ::iterator iterator; iterator = group_list.begin(); @@ -2164,7 +2160,7 @@ Group* EntityList::GetGroupByClient(Client* client) } Raid* EntityList::GetRaidByLeaderName(const char *leader){ - list::iterator iterator; + std::list::iterator iterator; iterator = raid_list.begin(); @@ -2180,7 +2176,7 @@ Raid* EntityList::GetRaidByLeaderName(const char *leader){ return 0; } Raid* EntityList::GetRaidByID(uint32 id){ - list::iterator iterator; + std::list::iterator iterator; iterator = raid_list.begin(); @@ -2196,7 +2192,7 @@ Raid* EntityList::GetRaidByID(uint32 id){ Raid* EntityList::GetRaidByClient(Client* client) { - list::iterator iterator; + std::list::iterator iterator; iterator = raid_list.begin(); @@ -2215,7 +2211,7 @@ Raid* EntityList::GetRaidByClient(Client* client) } Raid* EntityList::GetRaidByMob(Mob* mob) { - list::iterator iterator; + std::list::iterator iterator; iterator = raid_list.begin(); @@ -2658,7 +2654,7 @@ bool EntityList::RemoveCorpse(uint16 delete_id){ return false; } bool EntityList::RemoveGroup(uint32 delete_id){ - list::iterator iterator; + std::list::iterator iterator; iterator = group_list.begin(); @@ -2680,7 +2676,7 @@ bool EntityList::RemoveGroup(uint32 delete_id){ } bool EntityList::RemoveRaid(uint32 delete_id){ - list::iterator iterator; + std::list::iterator iterator; iterator = raid_list.begin(); @@ -3124,7 +3120,7 @@ void EntityList::FindPathsToAllNPCs() { VERTEX Node0 = zone->pathing->GetPathNodeCoordinates(0, false); VERTEX Dest(Iterator.GetData()->GetX(), Iterator.GetData()->GetY(), Iterator.GetData()->GetZ()); - list Route = zone->pathing->FindRoute(Node0, Dest); + std::list Route = zone->pathing->FindRoute(Node0, Dest); if(Route.size() == 0) printf("Unable to find a route to %s\n", Iterator.GetData()->GetName()); else @@ -3254,7 +3250,7 @@ void EntityList::WriteEntityIDs() { iterator.Reset(); while(iterator.MoreElements()) { - cout << "ID: " << iterator.GetData()->GetID() << " Name: " << iterator.GetData()->GetName() << endl; + std::cout << "ID: " << iterator.GetData()->GetID() << " Name: " << iterator.GetData()->GetName() << std::endl; iterator.Advance(); } } @@ -3892,7 +3888,7 @@ bool EntityList::LimitCheckType(uint32 npc_type, int count) { if(count < 1) return(true); - map::iterator cur,end; + std::map::iterator cur,end; cur = npc_limit_list.begin(); end = npc_limit_list.end(); @@ -3913,7 +3909,7 @@ bool EntityList::LimitCheckGroup(uint32 spawngroup_id, int count) { if(count < 1) return(true); - map::iterator cur,end; + std::map::iterator cur,end; cur = npc_limit_list.begin(); end = npc_limit_list.end(); @@ -3935,7 +3931,7 @@ bool EntityList::LimitCheckBoth(uint32 npc_type, uint32 spawngroup_id, int group if(group_count < 1 && type_count < 1) return(true); - map::iterator cur,end; + std::map::iterator cur,end; cur = npc_limit_list.begin(); end = npc_limit_list.end(); @@ -4543,7 +4539,7 @@ void EntityList::ZoneWho(Client *c, Who_All_Struct* Who) { strncasecmp(guild_mgr.GetGuildName(ClientEntry->GuildID()), Who->whom, WhomLength)) continue; - string GuildName; + std::string GuildName; if((ClientEntry->GuildID() != GUILD_NONE) && (ClientEntry->GuildID() > 0)) { @@ -4749,7 +4745,7 @@ void EntityList::SignalAllClients(uint32 data) } } -void EntityList::GetMobList(list &m_list) +void EntityList::GetMobList(std::list &m_list) { m_list.clear(); LinkedListIterator iterator(mob_list); @@ -4762,7 +4758,7 @@ void EntityList::GetMobList(list &m_list) } } -void EntityList::GetNPCList(list &n_list) +void EntityList::GetNPCList(std::list &n_list) { n_list.clear(); LinkedListIterator iterator(npc_list); @@ -4775,7 +4771,7 @@ void EntityList::GetNPCList(list &n_list) } } -void EntityList::GetClientList(list &c_list) +void EntityList::GetClientList(std::list &c_list) { c_list.clear(); LinkedListIterator iterator(client_list); @@ -4788,7 +4784,7 @@ void EntityList::GetClientList(list &c_list) } } -void EntityList::GetCorpseList(list &c_list) +void EntityList::GetCorpseList(std::list &c_list) { c_list.clear(); LinkedListIterator iterator(corpse_list); @@ -4801,7 +4797,7 @@ void EntityList::GetCorpseList(list &c_list) } } -void EntityList::GetObjectList(list &o_list) +void EntityList::GetObjectList(std::list &o_list) { o_list.clear(); LinkedListIterator iterator(object_list); @@ -4814,7 +4810,7 @@ void EntityList::GetObjectList(list &o_list) } } -void EntityList::GetDoorsList(list &o_list) +void EntityList::GetDoorsList(std::list &o_list) { o_list.clear(); LinkedListIterator iterator(door_list); @@ -5083,7 +5079,7 @@ void EntityList::AddLootToNPCS(uint32 item_id, uint32 count) while(count > 0) { - vector selection; + std::vector selection; selection.reserve(npc_count); for(int j = 0; j < npc_count; ++j) { @@ -5206,7 +5202,7 @@ Mob* EntityList::GetClosestMobByBodyType(Mob* sender, bodyType BodyType) return ClosestMob; } -void EntityList::GetTargetsForConeArea(Mob *start, uint32 radius, uint32 height, list &m_list) +void EntityList::GetTargetsForConeArea(Mob *start, uint32 radius, uint32 height, std::list &m_list) { LinkedListIterator iterator(mob_list); iterator.Reset(); @@ -5259,7 +5255,7 @@ Mob* EntityList::GetTargetForVirus(Mob* spreader) { int max_spread_range = RuleI(Spells, VirusSpreadDistance); - vector TargetsInRange; + std::vector TargetsInRange; LinkedListIterator iterator(mob_list); iterator.Reset(); diff --git a/zone/entity.h b/zone/entity.h index 4b26b45d8..812d229bb 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -387,14 +387,14 @@ public: void UpdateFindableNPCState(NPC *n, bool Remove); void HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode); - void GetMobList(list &m_list); - void GetNPCList(list &n_list); - void GetMercList(list &n_list); - void GetClientList(list &c_list); - void GetCorpseList(list &c_list); - void GetObjectList(list &o_list); - void GetDoorsList(list &d_list); - void GetTargetsForConeArea(Mob *start, uint32 radius, uint32 height, list &m_list); + void GetMobList(std::list &m_list); + void GetNPCList(std::list &n_list); + void GetMercList(std::list &n_list); + void GetClientList(std::list &c_list); + void GetCorpseList(std::list &c_list); + void GetObjectList(std::list &o_list); + void GetDoorsList(std::list &d_list); + void GetTargetsForConeArea(Mob *start, uint32 radius, uint32 height, std::list &m_list); void DepopAll(int NPCTypeID, bool StartSpawnTimer = true); @@ -412,7 +412,7 @@ private: //used for limiting spawns class SpawnLimitRecord { public: uint32 spawngroup_id; uint32 npc_type; }; - map npc_limit_list; //entity id -> npc type + std::map npc_limit_list; //entity id -> npc type uint32 tsFirstSpawnOnQueue; // timestamp that the top spawn on the spawnqueue was added, should be 0xFFFFFFFF if queue is empty uint32 NumSpawnsOnQueue; @@ -422,14 +422,14 @@ private: LinkedList mob_list; LinkedList npc_list; LinkedList merc_list; - list group_list; + std::list group_list; LinkedList corpse_list; LinkedList object_list; LinkedList door_list; LinkedList trap_list; LinkedList beacon_list; LinkedList proximity_list; - list raid_list; + std::list raid_list; uint16 last_insert_id; // Please Do Not Declare Any EntityList Class Members After This Comment diff --git a/zone/fearpath.cpp b/zone/fearpath.cpp index 82c2ff31c..f74c1fe98 100644 --- a/zone/fearpath.cpp +++ b/zone/fearpath.cpp @@ -159,7 +159,7 @@ void Mob::CalculateNewFearpoint() VERTEX CurrentPosition(GetX(), GetY(), GetZ()); - list Route = zone->pathing->FindRoute(CurrentPosition, Loc); + std::list Route = zone->pathing->FindRoute(CurrentPosition, Loc); if(Route.size() > 0) { diff --git a/zone/forage.cpp b/zone/forage.cpp index 54ac3b971..952939d90 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -17,7 +17,6 @@ */ #include "../common/debug.h" #include -using namespace std; #include #include @@ -177,7 +176,7 @@ uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, mysql_free_result(result); } else { - cerr << "Error in Fishing query '" << query << "' " << errbuf << endl; + std::cerr << "Error in Fishing query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return 0; } diff --git a/zone/groups.cpp b/zone/groups.cpp index 85d75ff0d..6f622b5ed 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -158,7 +158,7 @@ void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinu char buf[128]; buf[63] = '\0'; - string msg = "You receive"; + std::string msg = "You receive"; bool one = false; if(ppsplit > 0) { diff --git a/zone/groups.h b/zone/groups.h index ddcb3fb21..10b4fcffe 100644 --- a/zone/groups.h +++ b/zone/groups.h @@ -141,10 +141,10 @@ public: private: Mob* leader; GroupLeadershipAA_Struct LeaderAbilities; - string MainTankName; - string MainAssistName; - string PullerName; - string NPCMarkerName; + std::string MainTankName; + std::string MainAssistName; + std::string PullerName; + std::string NPCMarkerName; uint16 NPCMarkerID; uint16 AssistTargetID; uint16 TankTargetID; diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index 0e4690cee..b3013a50b 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -164,13 +164,13 @@ uint8 *ZoneGuildManager::MakeGuildMembers(uint32 guild_id, const char *prefix_na return(retbuffer); } - vector members; + std::vector members; if(!GetEntireGuild(guild_id, members)) return(nullptr); //figure out the actual packet length. uint32 fixed_length = sizeof(Internal_GuildMembers_Struct) + members.size()*sizeof(Internal_GuildMemberEntry_Struct); - vector::iterator cur, end; + std::vector::iterator cur, end; CharGuildInfo *ci; cur = members.begin(); end = members.end(); @@ -242,7 +242,7 @@ uint8 *ZoneGuildManager::MakeGuildMembers(uint32 guild_id, const char *prefix_na void ZoneGuildManager::ListGuilds(Client *c) const { c->Message(0, "Listing guilds on the server:"); char leadername[64]; - map::const_iterator cur, end; + std::map::const_iterator cur, end; cur = m_guilds.begin(); end = m_guilds.end(); int r = 0; @@ -260,7 +260,7 @@ void ZoneGuildManager::ListGuilds(Client *c) const { void ZoneGuildManager::DescribeGuild(Client *c, uint32 guild_id) const { - map::const_iterator res; + std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) { c->Message(0, "Guild %d not found.", guild_id); @@ -292,11 +292,11 @@ void ZoneGuildManager::DescribeGuild(Client *c, uint32 guild_id) const { //in theory, we could get a pile of unused entries in this array, but only if //we had a malicious client sending controlled packets, plus its like 10 bytes per entry. void ZoneGuildManager::RecordInvite(uint32 char_id, uint32 guild_id, uint8 rank) { - m_inviteQueue[char_id] = pair(guild_id, rank); + m_inviteQueue[char_id] = std::pair(guild_id, rank); } bool ZoneGuildManager::VerifyAndClearInvite(uint32 char_id, uint32 guild_id, uint8 rank) { - map >::iterator res; + std::map >::iterator res; res = m_inviteQueue.find(char_id); if(res == m_inviteQueue.end()) return(false); //no entry... @@ -308,8 +308,6 @@ bool ZoneGuildManager::VerifyAndClearInvite(uint32 char_id, uint32 guild_id, uin return(valid); } - - void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { switch(pack->opcode) { case ServerOP_RefreshGuild: { diff --git a/zone/horse.cpp b/zone/horse.cpp index ef4b23812..382b4c0f9 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -25,7 +25,7 @@ #include #include "worldserver.h" -map Horse::horse_types; +std::map Horse::horse_types; LinkedList horses_auto_delete; Horse::Horse(Client *_owner, uint16 spell_id, float x, float y, float z, float heading) diff --git a/zone/horse.h b/zone/horse.h index c9ecaaac7..dd58007eb 100644 --- a/zone/horse.h +++ b/zone/horse.h @@ -22,7 +22,6 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) #include "npc.h" #include -using namespace std; class Horse : public NPC { public: @@ -36,7 +35,7 @@ protected: Client *owner; //generate npc type records for horses - static map horse_types; + static std::map horse_types; static const NPCType *GetHorseType(uint16 spell_id); static const NPCType *BuildHorseType(uint16 spell_id); }; diff --git a/zone/inventory.cpp b/zone/inventory.cpp index b20a0f4e2..f62a1e851 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -337,7 +337,7 @@ void Client::DropItem(int16 slot_id) // Save client inventory change to database if (slot_id==SLOT_CURSOR) { - list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(CharacterID(), s, e); } else database.SaveInventory(CharacterID(), nullptr, slot_id); @@ -469,7 +469,7 @@ void Client::DeleteItemInInventory(int16 slot_id, int8 quantity, bool client_upd const ItemInst* inst=nullptr; if (slot_id==SLOT_CURSOR) { - list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); if(update_db) database.SaveCursor(character_id, s, e); } @@ -523,7 +523,7 @@ bool Client::PushItemOnCursor(const ItemInst& inst, bool client_update) SendItemPacket(SLOT_CURSOR, &inst, ItemPacketSummonItem); } - list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); return database.SaveCursor(CharacterID(), s, e); } @@ -542,7 +542,7 @@ bool Client::PutItemInInventory(int16 slot_id, const ItemInst& inst, bool client } if (slot_id==SLOT_CURSOR) { - list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); return database.SaveCursor(this->CharacterID(), s, e); } else return database.SaveInventory(this->CharacterID(), &inst, slot_id); @@ -558,7 +558,7 @@ void Client::PutLootInInventory(int16 slot_id, const ItemInst &inst, ServerLootI SendLootItemInPacket(&inst, slot_id); if (slot_id==SLOT_CURSOR) { - list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(this->CharacterID(), s, e); } else database.SaveInventory(this->CharacterID(), &inst, slot_id); @@ -712,7 +712,7 @@ void Client::MoveItemCharges(ItemInst &from, int16 to_slot, uint8 type) from.SetCharges(from.GetCharges() - charges_to_move); SendLootItemInPacket(tmp_inst, to_slot); if (to_slot==SLOT_CURSOR){ - list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(this->CharacterID(), s, e); } else database.SaveInventory(this->CharacterID(), tmp_inst, to_slot); @@ -1207,7 +1207,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { safe_delete(world_inst); if (src_slot_id==SLOT_CURSOR) { - list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(character_id, s, e); } else database.SaveInventory(character_id, m_inv[src_slot_id], src_slot_id); @@ -1332,12 +1332,12 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { // Step 7: Save change to the database if (src_slot_id==SLOT_CURSOR){ - list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(character_id, s, e); } else database.SaveInventory(character_id, m_inv.GetItem(src_slot_id), src_slot_id); if (dst_slot_id==SLOT_CURSOR) { - list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); database.SaveCursor(character_id, s, e); } else database.SaveInventory(character_id, m_inv.GetItem(dst_slot_id), dst_slot_id); @@ -1964,7 +1964,7 @@ void Client::SendItemPacket(int16 slot_id, const ItemInst* inst, ItemPacketType return; // Serialize item into |-delimited string - string packet = inst->Serialize(slot_id); + std::string packet = inst->Serialize(slot_id); EmuOpcode opcode = OP_Unknown; EQApplicationPacket* outapp = nullptr; @@ -1989,7 +1989,7 @@ EQApplicationPacket* Client::ReturnItemPacket(int16 slot_id, const ItemInst* ins return 0; // Serialize item into |-delimited string - string packet = inst->Serialize(slot_id); + std::string packet = inst->Serialize(slot_id); EmuOpcode opcode = OP_Unknown; EQApplicationPacket* outapp = nullptr; diff --git a/zone/loottables.cpp b/zone/loottables.cpp index 875d5d762..889d2727f 100644 --- a/zone/loottables.cpp +++ b/zone/loottables.cpp @@ -18,7 +18,6 @@ #include "../common/debug.h" #include #include -using namespace std; #include #include "npc.h" #include "masterentity.h" @@ -45,7 +44,7 @@ void ZoneDatabase::AddLootTableToNPC(NPC* npc,uint32 loottable_id, ItemList* ite // do coin if (lts->mincash > lts->maxcash) { - cerr << "Error in loottable #" << loottable_id << ": mincash > maxcash" << endl; + std::cerr << "Error in loottable #" << loottable_id << ": mincash > maxcash" << std::endl; } else if (lts->maxcash != 0) { uint32 cash = 0; diff --git a/zone/merc.cpp b/zone/merc.cpp index e1a4d0ec6..b1ef244d8 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1122,7 +1122,7 @@ int32 Merc::CalcBaseEndurance() int BonusUpto800 = int( at_most_800 / 4 ) ; if(Stats > 400) { Bonus400to800 = int( (at_most_800 - 400) / 4 ); - HalfBonus400to800 = int( max( ( at_most_800 - 400 ), 0 ) / 8 ); + HalfBonus400to800 = int( std::max( ( at_most_800 - 400 ), 0 ) / 8 ); if(Stats > 800) { Bonus800plus = int( (Stats - 800) / 8 ) * 2; @@ -1928,7 +1928,7 @@ bool Merc::AI_IdleCastCheck() { if (AIautocastspell_timer->Check(false)) { _ZP(Merc_AI_IdleCastCheck); #if MobAI_DEBUG_Spells >= 25 - cout << "Non-Engaged autocast check triggered: " << this->GetCleanName() << endl; + std::cout << "Non-Engaged autocast check triggered: " << this->GetCleanName() << std::endl; #endif AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. @@ -3774,7 +3774,7 @@ MercSpell Merc::GetBestMercSpellForCure(Merc* caster, Mob *tar) { //Check for group cure first if(countNeedsCured > 2) { - for(list::iterator itr = cureList.begin(); itr != cureList.end(); itr++) { + for(std::list::iterator itr = cureList.begin(); itr != cureList.end(); itr++) { MercSpell selectedMercSpell = *itr; if(IsGroupSpell(itr->spellid) && CheckSpellRecastTimers(caster, itr->spellid)) { @@ -3814,7 +3814,7 @@ MercSpell Merc::GetBestMercSpellForCure(Merc* caster, Mob *tar) { //no group cure for target- try to find single target spell if(!spellSelected) { - for(list::iterator itr = cureList.begin(); itr != cureList.end(); itr++) { + for(std::list::iterator itr = cureList.begin(); itr != cureList.end(); itr++) { MercSpell selectedMercSpell = *itr; if(CheckSpellRecastTimers(caster, itr->spellid)) { diff --git a/zone/merc.h b/zone/merc.h index 21e372f7e..0fcbb23e7 100644 --- a/zone/merc.h +++ b/zone/merc.h @@ -3,7 +3,6 @@ #include "mob.h" #include "zonedb.h" #include "npc.h" -using namespace std; #define MAXMERCS 1 #define MERC_DEBUG 0 diff --git a/zone/mob.cpp b/zone/mob.cpp index 3ec74db43..9f2c21fe1 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3782,7 +3782,7 @@ void Mob::InsertQuestGlobal(int charid, int npcid, int zoneid, const char *varna char errbuf[MYSQL_ERRMSG_SIZE]; // Make duration string either "unix_timestamp(now()) + xxx" or "NULL" - stringstream duration_ss; + std::stringstream duration_ss; if (duration == INT_MAX) { @@ -4487,7 +4487,7 @@ bool Mob::PassLimitToSkill(uint16 spell_id, uint16 skill) { // Faction Mods for Alliance type spells void Mob::AddFactionBonus(uint32 pFactionID,int32 bonus) { - map :: const_iterator faction_bonus; + std::map :: const_iterator faction_bonus; typedef std::pair NewFactionBonus; faction_bonus = faction_bonuses.find(pFactionID); @@ -4507,7 +4507,7 @@ void Mob::AddFactionBonus(uint32 pFactionID,int32 bonus) { // Faction Mods from items void Mob::AddItemFactionBonus(uint32 pFactionID,int32 bonus) { - map :: const_iterator faction_bonus; + std::map :: const_iterator faction_bonus; typedef std::pair NewFactionBonus; faction_bonus = item_faction_bonuses.find(pFactionID); @@ -4526,7 +4526,7 @@ void Mob::AddItemFactionBonus(uint32 pFactionID,int32 bonus) { } int32 Mob::GetFactionBonus(uint32 pFactionID) { - map :: const_iterator faction_bonus; + std::map :: const_iterator faction_bonus; faction_bonus = faction_bonuses.find(pFactionID); if(faction_bonus != faction_bonuses.end()) { @@ -4536,7 +4536,7 @@ int32 Mob::GetFactionBonus(uint32 pFactionID) { } int32 Mob::GetItemFactionBonus(uint32 pFactionID) { - map :: const_iterator faction_bonus; + std::map :: const_iterator faction_bonus; faction_bonus = item_faction_bonuses.find(pFactionID); if(faction_bonus != item_faction_bonuses.end()) { @@ -4546,7 +4546,7 @@ int32 Mob::GetItemFactionBonus(uint32 pFactionID) { } void Mob::ClearItemFactionBonuses() { - map :: iterator itr; + std::map :: iterator itr; for(itr = item_faction_bonuses.begin(); itr != item_faction_bonuses.end(); itr++) { item_faction_bonuses.erase(itr->first); diff --git a/zone/mob.h b/zone/mob.h index b300eb9b6..ad29d3423 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1093,7 +1093,7 @@ protected: VERTEX PathingLastPosition; int PathingLoopCount; int PathingLastNodeVisited; - list Route; + std::list Route; LOSType PathingLOSState; Timer *PathingLOSCheckTimer; Timer *PathingRouteUpdateTimerShort; diff --git a/zone/mod_functions.cpp b/zone/mod_functions.cpp index af228ed9e..c2599c547 100644 --- a/zone/mod_functions.cpp +++ b/zone/mod_functions.cpp @@ -21,8 +21,6 @@ extern Zone* zone; extern WorldServer worldserver; -using namespace std; - void Zone::mod_init() { return; } void Zone::mod_repop() { return; } diff --git a/zone/mod_functions_base.cpp b/zone/mod_functions_base.cpp index af228ed9e..c2599c547 100644 --- a/zone/mod_functions_base.cpp +++ b/zone/mod_functions_base.cpp @@ -21,8 +21,6 @@ extern Zone* zone; extern WorldServer worldserver; -using namespace std; - void Zone::mod_init() { return; } void Zone::mod_repop() { return; } diff --git a/zone/net.cpp b/zone/net.cpp index 60e891b23..b9a63b4d1 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -19,7 +19,6 @@ #include "../common/debug.h" #include "../common/features.h" #include -using namespace std; #include #include #include @@ -32,7 +31,6 @@ using namespace std; #ifdef _CRTDBG_MAP_ALLOC #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) #endif -using namespace std; #ifdef _WINDOWS #include #define snprintf _snprintf diff --git a/zone/npc.cpp b/zone/npc.cpp index bb5743956..8876cd29e 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -19,7 +19,6 @@ #include #include #include -using namespace std; #include #include "../common/moremath.h" #include @@ -383,7 +382,7 @@ NPC::~NPC() } { - list::iterator cur,end; + std::list::iterator cur,end; cur = faction_list.begin(); end = faction_list.end(); for(; cur != end; cur++) { @@ -463,7 +462,7 @@ void NPC::CheckMinMaxLevel(Mob *them) uint16 themlevel = them->GetLevel(); uint8 material; - list::iterator cur = itemlist.begin(); + std::list::iterator cur = itemlist.begin(); while(cur != itemlist.end()) { if(!(*cur)) @@ -2395,7 +2394,7 @@ FACTION_VALUE NPC::GetReverseFactionCon(Mob* iOther) { //Look through our faction list and return a faction con based //on the npc_value for the other person's primary faction in our list. FACTION_VALUE NPC::CheckNPCFactionAlly(int32 other_faction) { - list::iterator cur,end; + std::list::iterator cur,end; cur = faction_list.begin(); end = faction_list.end(); for(; cur != end; cur++) { @@ -2418,7 +2417,7 @@ bool NPC::IsFactionListAlly(uint32 other_faction) { int NPC::GetScore() { - int lv = min(70, (int)GetLevel()); + int lv = std::min(70, (int)GetLevel()); int basedmg = (lv*2)*(1+(lv / 100)) - (lv / 2); int minx = 0; int basehp = 0; @@ -2471,8 +2470,8 @@ int NPC::GetScore() } final = minx + hpcontrib + dmgcontrib + spccontrib; - final = max(1, final); - final = min(100, final); + final = std::max(1, final); + final = std::min(100, final); return(final); } diff --git a/zone/npc.h b/zone/npc.h index cd9b2baaa..f2cec36ec 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -25,7 +25,6 @@ class NPC; #include #include -using namespace std; #include "spawn2.h" #include "../common/loottable.h" @@ -256,7 +255,7 @@ public: void ResumeWandering(); void PauseWandering(int pausetime); void MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot); - void GetClosestWaypoint(list &wp_list, int count, float m_x, float m_y, float m_z); + void GetClosestWaypoint(std::list &wp_list, int count, float m_x, float m_y, float m_z); uint32 GetEquipment(uint8 material_slot) const; // returns item id int32 GetEquipmentMaterial(uint8 material_slot) const; @@ -467,7 +466,7 @@ protected: NPCType* NPCTypedata_ours; //special case for npcs with uniquely created data. friend class EntityList; - list faction_list; + std::list faction_list; uint32 copper; uint32 silver; uint32 gold; @@ -516,10 +515,10 @@ protected: bool npc_aggro; - deque signal_q; + std::deque signal_q; //waypoint crap: - vector Waypoints; + std::vector Waypoints; void _ClearWaypints(); int max_wp; int save_wp; diff --git a/zone/parser.cpp b/zone/parser.cpp index 280020533..320127f75 100644 --- a/zone/parser.cpp +++ b/zone/parser.cpp @@ -4,14 +4,11 @@ #include #include -using namespace std; #include -using namespace std; #include #include #include -using namespace std; #include "../common/debug.h" #include "entity.h" #include "masterentity.h" @@ -45,18 +42,18 @@ int mindex1 = 0; const char * charIn3 = "`~1234567890-=!@#$%^&*_+qwertyuiop[]asdfghjkl'zxcvbnm,./QWERTYUIOP|ASDFGHJKL:ZXCVBNM<>?\"\\"; // MYRA - restore missing commands for qst type files & add itemlink -string cmds("if 0|break 1|spawn 6|spawn2 7|settimer 2|stoptimer 1|rebind 4|echo 1|summonitem 1|selfcast 1|zone 1|castspell 2|say 1|emote 1|shout 1|shout2 1|depop 1|exp 1|level 1|safemove 1|rain 1|snow 1|givecash 4|pvp 1|doanim 1|addskill 2|flagcheck 1|me 1|write 2|settarget 2|follow 1|sfollow 1|save 1|setallskill 1|faction 2|settime 2|setguild 2|setsky 1|setstat 2|movepc 5|gmmove 3|movegrp 4|signal 1|attack 1|itemlink 1|setglobal 4|delglobal 1|targlobal 6|setskill 2|setlanguage 2|stop 0|resume 0|start 1|moveto 3|pause 1|addldonpoints 2|"); +std::string cmds("if 0|break 1|spawn 6|spawn2 7|settimer 2|stoptimer 1|rebind 4|echo 1|summonitem 1|selfcast 1|zone 1|castspell 2|say 1|emote 1|shout 1|shout2 1|depop 1|exp 1|level 1|safemove 1|rain 1|snow 1|givecash 4|pvp 1|doanim 1|addskill 2|flagcheck 1|me 1|write 2|settarget 2|follow 1|sfollow 1|save 1|setallskill 1|faction 2|settime 2|setguild 2|setsky 1|setstat 2|movepc 5|gmmove 3|movegrp 4|signal 1|attack 1|itemlink 1|setglobal 4|delglobal 1|targlobal 6|setskill 2|setlanguage 2|stop 0|resume 0|start 1|moveto 3|pause 1|addldonpoints 2|"); //end Myra -int GetArgs(string command) +int GetArgs(std::string command) { - string::iterator iterator = cmds.begin(); - string buffer; - string cmd; - string argnum; + std::string::iterator iterator = cmds.begin(); + std::string buffer; + std::string cmd; + std::string argnum; while (*iterator) { if (*iterator == ' ') { @@ -84,11 +81,11 @@ int GetArgs(string command) return -1; } -int calc(string calc) +int calc(std::string calc) { - string::iterator iterator = calc.begin(); - string buffer; - string integer1; + std::string::iterator iterator = calc.begin(); + std::string buffer; + std::string integer1; char op = 0; int returnvalue = 0; @@ -156,19 +153,19 @@ int Parser::numtok(const char *text, char character) { return returnvalue; } -string strlwr(string tmp) { - string res; +std::string strlwr(std::string tmp) { + std::string res; transform(tmp.begin(), tmp.end(), res.begin(), (int(*)(int))tolower); return(res); } -int strcmp(const string &com, const string &com2) { +int strcmp(const std::string &com, const std::string &com2) { return strcmp(com.c_str(),com2.c_str()); } -string gettok(const char *text, char character, int index) +std::string gettok(const char *text, char character, int index) { - string buffer; + std::string buffer; int find=0; for(; *text != '\0'; *text++) { @@ -184,20 +181,20 @@ string gettok(const char *text, char character, int index) return buffer; } -void Parser::MakeVars(string text, uint32 npcid) { - string buffer; - string temp; +void Parser::MakeVars(std::string text, uint32 npcid) { + std::string buffer; + std::string temp; int pos = numtok(text.c_str(),' ')+1; for(int i=0;i10 printf("Buffer: %s, temp: %s\n",buffer.c_str(),temp.c_str()); #endif AddVar(temp,buffer); temp=""; - temp=(string)itoa(i+1) + "-." + (string)itoa(npcid); + temp=(std::string)itoa(i+1) + "-." + (std::string)itoa(npcid); AddVar(temp,strstr(text.c_str(),buffer.c_str())); buffer=""; } @@ -273,13 +270,13 @@ void Parser::MakeParms(const char * str, uint32 npcid) { } } -int Parser::GetItemCount(string itemid, uint32 npcid) +int Parser::GetItemCount(std::string itemid, uint32 npcid) { - string temp; + std::string temp; int a=0; for (int i=1;i<5;i++) { - temp = (string)"item" + (string)itoa(i); + temp = (std::string)"item" + (std::string)itoa(i); if (!GetVar(temp,npcid).compare(itemid)) a++; temp=""; @@ -381,10 +378,10 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc fac = client->GetFactionLevel(client->GetID(), npcmob->GetID(), client->GetRace(), client->GetClass(), DEITY_AGNOSTIC, npc->GetPrimaryFaction(), npcmob); } else if (!client) { - cerr << "WARNING: cast failure on mob->CastToClient()" << endl; + std::cerr << "WARNING: cast failure on mob->CastToClient()" << std::endl; } else if (!npc) { - cerr << "WARNING: cast failure on npcmob->CastToNPC()" << endl; + std::cerr << "WARNING: cast failure on npcmob->CastToNPC()" << std::endl; } } if (mob) { @@ -410,7 +407,7 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc AddVar("zonesn.g",zone->GetShortName()); } - string temp; + std::string temp; #if Parser_DEBUG>10 printf("Data: %s,Id: %i\n",data,npcid); #endif @@ -455,13 +452,13 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc break; } case EVENT_WAYPOINT_ARRIVE: { - temp = "wp." + (string)itoa(npcid); + temp = "wp." + (std::string)itoa(npcid); AddVar(temp,data); SendCommands("event_waypoint_arrive", qstID, npcmob, mob); break; } case EVENT_WAYPOINT_DEPART: { - temp = "wp." + (string)itoa(npcid); + temp = "wp." + (std::string)itoa(npcid); AddVar(temp,data); SendCommands("event_waypoint_depart", qstID, npcmob, mob); break; @@ -559,7 +556,7 @@ int32 Parser::GetNPCqstID(uint32 iNPCID) { void Parser::ClearCache() { #if Parser_DEBUG >= 2 - cout << "Parser::ClearCache" << endl; + std::cout << "Parser::ClearCache" << std::endl; #endif //for (uint32 i=0; i::iterator iterator = MainList.begin(); + std::list::iterator iterator = MainList.begin(); Events* p; while (iterator != MainList.end()) { @@ -692,7 +689,7 @@ void Parser::ClearAliasesByNPCID(uint32 iNPCID) { }*/ } -void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npcid, Mob* other, Mob* mob ) +void Parser::ExCommands(std::string o_command, std::string parms, int argnums, uint32 npcid, Mob* other, Mob* mob ) { char arglist[10][1024]; //Work out the argument list, if there needs to be one @@ -700,8 +697,8 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci printf("Parms: %s\n", parms.c_str()); #endif if (argnums > 1) { - string buffer; - string::iterator iterator = parms.begin(); + std::string buffer; + std::string::iterator iterator = parms.begin(); int quote=0,alist=0,ignore=0; while (1) { if (*iterator == '"') { @@ -727,11 +724,11 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci } } else { - string::iterator iterator = parms.begin(); + std::string::iterator iterator = parms.begin(); if (*iterator == '"') { int quote=0,ignore=0; //once=0 - string tmp; + std::string tmp; while (iterator != parms.end()) { if (*iterator == '"') @@ -1040,14 +1037,14 @@ int Parser::LoadScript(int npcid, const char * zone, Mob* activater) ClearAliasesByNPCID(npcid); //string strnpcid = ("default"); - string strnpcid = (DEFAULT_QUEST_PREFIX); + std::string strnpcid = (DEFAULT_QUEST_PREFIX); if (npcid) strnpcid = itoa(npcid); - string filename; - filename = "./quests/" + (string)zone + "/" + (string)strnpcid + ".qst"; - string line,buffer,temp; - ifstream file( filename.c_str() ); + std::string filename; + filename = "./quests/" + (std::string)zone + "/" + (std::string)strnpcid + ".qst"; + std::string line,buffer,temp; + std::ifstream file( filename.c_str() ); if (!file) { if (npcid) { @@ -1063,8 +1060,8 @@ int Parser::LoadScript(int npcid, const char * zone, Mob* activater) Events * NewEventList = new Events; while (file && !file.eof()) { - getline(file,line); - string::iterator iterator = line.begin(); + std::getline(file,line); + std::string::iterator iterator = line.begin(); while (*iterator) { if (iterator[0] == '/' && iterator[1] == '/') break; @@ -1122,22 +1119,22 @@ int Parser::LoadScript(int npcid, const char * zone, Mob* activater) } -void Parser::Replace(string& string1, string repstr, string rep, int all) { - while (string1.find(repstr.c_str()) != string::npos) { +void Parser::Replace(std::string& string1, std::string repstr, std::string rep, int all) { + while (string1.find(repstr.c_str()) != std::string::npos) { string1.replace(string1.find(repstr.c_str()),repstr.length(),rep.c_str()); if (!all) break; } } -string Parser::GetVar(string varname, uint32 npcid) +std::string Parser::GetVar(std::string varname, uint32 npcid) { - list::iterator iterator = varlist.begin(); + std::list::iterator iterator = varlist.begin(); vars * p; - string checkfirst; - string checksecond; - checkfirst = varname + (string)"." + (string)itoa(npcid); - checksecond = varname + (string)".g"; + std::string checkfirst; + std::string checksecond; + checkfirst = varname + (std::string)"." + (std::string)itoa(npcid); + checksecond = varname + (std::string)".g"; while(iterator != varlist.end()) { @@ -1154,9 +1151,9 @@ printf("GetVar(%s) = '%s'\n", varname.c_str(), p->value.c_str()); return checkfirst; } -void Parser::DeleteVar(string name) +void Parser::DeleteVar(std::string name) { - list::iterator iterator = varlist.begin(); + std::list::iterator iterator = varlist.begin(); vars* p; while(iterator != varlist.end()) { @@ -1173,27 +1170,27 @@ void Parser::DeleteVar(string name) void Parser::DelChatAndItemVars(uint32 npcid) { // MyListItem * Ptr; - string temp; + std::string temp; int i=0; for (i=0;i<10;i++) { - temp = (string)itoa(i) + "." + (string)itoa(npcid); + temp = (std::string)itoa(i) + "." + (std::string)itoa(npcid); DeleteVar(temp); - temp = (string)itoa(i) + "-." + (string)itoa(npcid); + temp = (std::string)itoa(i) + "-." + (std::string)itoa(npcid); DeleteVar(temp); } for (i=1;i<5;i++) { - temp = "item"+(string)itoa(i) + "." + (string)itoa(npcid); + temp = "item"+(std::string)itoa(i) + "." + (std::string)itoa(npcid); DeleteVar(temp); - temp = "item"+(string)itoa(i) + ".stack." + (string)itoa(npcid); + temp = "item"+(std::string)itoa(i) + ".stack." + (std::string)itoa(npcid); DeleteVar(temp); } } -void Parser::AddVar(string varname, string varval) +void Parser::AddVar(std::string varname, std::string varval) { - list::iterator iterator = varlist.begin(); + std::list::iterator iterator = varlist.begin(); vars* p; while(iterator != varlist.end()) { @@ -1212,13 +1209,13 @@ void Parser::AddVar(string varname, string varval) varlist.push_back(newvar); } -void Parser::HandleVars(string varname, string varparms, string& origstring, string format, uint32 npcid, Mob* mob) +void Parser::HandleVars(std::string varname, std::string varparms, std::string& origstring, std::string format, uint32 npcid, Mob* mob) { - string tempvar; + std::string tempvar; tempvar = GetVar(varname,npcid); char arglist[10][1024]; - string::iterator iterator = varparms.begin(); - string buffer; + std::string::iterator iterator = varparms.begin(); + std::string buffer; int quote=0; int alist=0; while (*iterator) @@ -1243,9 +1240,9 @@ void Parser::HandleVars(string varname, string varparms, string& origstring, str int pos=0; int one = atoi(arglist[1]); int two = atoi(arglist[2]); - string buffer2; - string find = arglist[0]; - string::iterator iterator = find.begin(); + std::string buffer2; + std::string find = arglist[0]; + std::string::iterator iterator = find.begin(); while (*iterator) { pos++; @@ -1258,21 +1255,21 @@ void Parser::HandleVars(string varname, string varparms, string& origstring, str Replace(origstring,format,buffer2.c_str()); } else if (!strcmp(strlwr((const char*)varname.c_str()),"+")) { - string temp; - temp = (string)" "+format+(string)" "; + std::string temp; + temp = (std::string)" "+format+(std::string)" "; Replace(origstring, temp, " REPLACETHISSHIT ",1); } else if (!strcmp(strlwr((const char*)varname.c_str()),"replace")) { - string temp; - temp = (string)arglist[0]; + std::string temp; + temp = (std::string)arglist[0]; Replace(temp, arglist[1], arglist[2],1); Replace(origstring, format, temp); } else if (!strcmp(strlwr(varname.c_str()),"itemcount")) { - string temp; + std::string temp; int o=0; o = GetItemCount(varparms,npcid); - temp = (string)itoa(o); + temp = (std::string)itoa(o); Replace(origstring,format,temp,1); } else if (!strcmp(strlwr(varname.c_str()),"calc")) { @@ -1294,10 +1291,10 @@ void Parser::HandleVars(string varname, string varparms, string& origstring, str Replace(origstring,format,"false"); } else if (!strcmp(strlwr((const char*)varname.c_str()),"read")) { - ifstream file(arglist[0]); + std::ifstream file(arglist[0]); if (file) { - string line; + std::string line; int index=0,stop=atoi(arglist[1]); while (!file.eof()) { @@ -1344,19 +1341,19 @@ void Parser::HandleVars(string varname, string varparms, string& origstring, str gClient = 0; } -void Parser::ParseVars(string& text, uint32 npcid, Mob* mob) +void Parser::ParseVars(std::string& text, uint32 npcid, Mob* mob) { - if (text.find("$") == string::npos && text.find("%") == string::npos) + if (text.find("$") == std::string::npos && text.find("%") == std::string::npos) return; - string buffer2; - string fname; - string parms; - while (text.find("%") != string::npos) + std::string buffer2; + std::string fname; + std::string parms; + while (text.find("%") != std::string::npos) { - string temp; - temp = (string)text.substr(text.find("%")).c_str(); - string::iterator iterator = temp.begin(); - string buffer; + std::string temp; + temp = (std::string)text.substr(text.find("%")).c_str(); + std::string::iterator iterator = temp.begin(); + std::string buffer; while (*iterator) { if (!strrchr(notin,*iterator)) @@ -1370,14 +1367,14 @@ void Parser::ParseVars(string& text, uint32 npcid, Mob* mob) iterator++; } } - while (text.find("$") != string::npos) + while (text.find("$") != std::string::npos) { - string temp; - temp = (string)text.substr(text.rfind("$")).c_str(); - string::iterator iterator = temp.begin(); + std::string temp; + temp = (std::string)text.substr(text.rfind("$")).c_str(); + std::string::iterator iterator = temp.begin(); int paren=0; int fin=0; - string buffer; + std::string buffer; while (iterator != temp.end()) { if (!strrchr(notin,*iterator) || paren) @@ -1449,7 +1446,7 @@ char * fixstring(char * string) return tmp2; }*/ -int DoCompare(string compare1, string sign, string compare2) +int DoCompare(std::string compare1, std::string sign, std::string compare2) { #if Parser_DEBUG>10 printf("compare1: %s,sign: %s, compare2: %s\n",compare1.c_str(),sign.c_str(),compare2.c_str()); @@ -1489,10 +1486,10 @@ int DoCompare(string compare1, string sign, string compare2) return 1; } -int Parser::ParseIf(string text) +int Parser::ParseIf(std::string text) { - string::iterator iterator = text.begin(); - string com1,com2,sign,next,buffer; + std::string::iterator iterator = text.begin(); + std::string com1,com2,sign,next,buffer; while (*iterator) { if (!strchr(notin,*iterator)) @@ -1547,13 +1544,13 @@ int Parser::ParseIf(string text) return 1; } -int Parser::ParseCommands(string text, int line, int justcheck, uint32 npcid, Mob* other, Mob* mob, std::string filename) +int Parser::ParseCommands(std::string text, int line, int justcheck, uint32 npcid, Mob* other, Mob* mob, std::string filename) { - string buffer,command,parms,temp,temp2; + std::string buffer,command,parms,temp,temp2; temp2 = text; ParseVars(temp2,npcid,mob); int bracket=0,paren=0,lastif=0,last_finished=0,quote=0,escape=0,ignore=0,argnums=0,argit=1; - string::iterator iterator = temp2.begin(); + std::string::iterator iterator = temp2.begin(); while (iterator != temp2.end()) { if (*iterator == '\\' && !escape) { @@ -1681,8 +1678,8 @@ int Parser::ParseCommands(string text, int line, int justcheck, uint32 npcid, Mo } if (last_finished) { - if(mob && mob->IsClient()) - mob->CastToClient()->Message(10,"Line: %d,File: %s | error C0008: syntax error : missing ';' before '}'", line, filename.c_str() ); + if(mob && mob->IsClient()) + mob->CastToClient()->Message(10,"Line: %d,File: %s | error C0008: syntax error : missing ';' before '}'", line, filename.c_str() ); return 0; } return 1; diff --git a/zone/parser.h b/zone/parser.h index 7d068ff86..a874f29fe 100644 --- a/zone/parser.h +++ b/zone/parser.h @@ -45,8 +45,8 @@ public: int mindex; const std::string DEFAULT_QUEST_PREFIX; - typedef list::iterator iter_events; - typedef list::iterator iter_eventlist; + typedef std::list::iterator iter_events; + typedef std::list::iterator iter_eventlist; std::list MainList; std::list varlist; std::list AliasList; @@ -81,7 +81,7 @@ public: int numtok(const char *text, char character); - int ParseCommands(std::string text, int line, int justcheck, uint32 npcid, Mob* other, Mob* mob, std::string filename=string("none")); + int ParseCommands(std::string text, int line, int justcheck, uint32 npcid, Mob* other, Mob* mob, std::string filename=std::string("none")); int ParseIf(std::string text); int pcalc(const char * string); void ParseVars(std::string& text, uint32 npcid, Mob* mob); diff --git a/zone/pathing.cpp b/zone/pathing.cpp index c269029ec..904e50dac 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -209,7 +209,7 @@ VERTEX PathManager::GetPathNodeCoordinates(int NodeNumber, bool BestZ) } -list PathManager::FindRoute(int startID, int endID) +std::list PathManager::FindRoute(int startID, int endID) { _ZP(Pathing_FindRoute_FromNodes); @@ -217,9 +217,9 @@ list PathManager::FindRoute(int startID, int endID) memset(ClosedListFlag, 0, sizeof(int) * Head.PathNodeCount); - list OpenList, ClosedList; + std::list OpenList, ClosedList; - listRoute; + std::listRoute; AStarNode AStarEntry, CurrentNode; @@ -257,7 +257,7 @@ list PathManager::FindRoute(int startID, int endID) Route.push_back(endID); - list::iterator RouteIterator; + std::list::iterator RouteIterator; while(CurrentNode.PathNodeID != startID) { @@ -306,7 +306,7 @@ list PathManager::FindRoute(int startID, int endID) bool AlreadyInOpenList = false; - list::iterator OpenListIterator, InsertionPoint = OpenList.end(); + std::list::iterator OpenListIterator, InsertionPoint = OpenList.end(); for(OpenListIterator = OpenList.begin(); OpenListIterator != OpenList.end(); ++OpenListIterator) { @@ -356,14 +356,14 @@ bool SortPathNodesByDistance(PathNodeSortStruct n1, PathNodeSortStruct n2) return n1.Distance < n2.Distance; } -list PathManager::FindRoute(VERTEX Start, VERTEX End) +std::list PathManager::FindRoute(VERTEX Start, VERTEX End) { _ZP(Pathing_FindRoute_FromVertices); _log(PATHING__DEBUG, "FindRoute(%8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f)", Start.x, Start.y, Start.z, End.x, End.y, End.z); - list noderoute; + std::list noderoute; float CandidateNodeRangeXY = RuleR(Pathing, CandidateNodeRangeXY); @@ -374,7 +374,7 @@ list PathManager::FindRoute(VERTEX Start, VERTEX End) // int ClosestPathNodeToStart = -1; - list SortedByDistance; + std::list SortedByDistance; PathNodeSortStruct TempNode; @@ -393,7 +393,7 @@ list PathManager::FindRoute(VERTEX Start, VERTEX End) SortedByDistance.sort(SortPathNodesByDistance); - for(list::iterator Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator) + for(std::list::iterator Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator) { _log(PATHING__DEBUG, "Checking Reachability of Node %i from Start Position.", PathNodes[(*Iterator).id].id); @@ -431,7 +431,7 @@ list PathManager::FindRoute(VERTEX Start, VERTEX End) SortedByDistance.sort(SortPathNodesByDistance); - for(list::iterator Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator) + for(std::list::iterator Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator) { _log(PATHING__DEBUG, "Checking Reachability of Node %i from End Position.", PathNodes[(*Iterator).id].id); _log(PATHING__DEBUG, " (%8.3f, %8.3f, %8.3f) to (%8.3f, %8.3f, %8.3f)", @@ -465,7 +465,7 @@ list PathManager::FindRoute(VERTEX Start, VERTEX End) { int CulledNodes = 0; - list::iterator First, Second; + std::list::iterator First, Second; while((noderoute.size() >= 2) && (CulledNodes < NodesToAttemptToCull)) { @@ -496,7 +496,7 @@ list PathManager::FindRoute(VERTEX Start, VERTEX End) { int CulledNodes = 0; - list::iterator First, Second; + std::list::iterator First, Second; while((noderoute.size() >= 2) && (CulledNodes < NodesToAttemptToCull)) { @@ -620,7 +620,7 @@ void PathManager::MeshTest() if(j == i) continue; - list Route = FindRoute(PathNodes[i].id, PathNodes[j].id); + std::list Route = FindRoute(PathNodes[i].id, PathNodes[j].id); if(Route.size() == 0) { @@ -647,7 +647,7 @@ void PathManager::SimpleMeshTest() for(uint32 j = 1; j < Head.PathNodeCount; ++j) { - list Route = FindRoute(PathNodes[0].id, PathNodes[j].id); + std::list Route = FindRoute(PathNodes[0].id, PathNodes[j].id); if(Route.size() == 0) { @@ -1114,7 +1114,7 @@ int PathManager::FindNearestPathNode(VERTEX Position) int ClosestPathNodeToStart = -1; - list SortedByDistance; + std::list SortedByDistance; PathNodeSortStruct TempNode; @@ -1133,7 +1133,7 @@ int PathManager::FindNearestPathNode(VERTEX Position) SortedByDistance.sort(SortPathNodesByDistance); - for(list::iterator Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator) + for(std::list::iterator Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator) { _log(PATHING__DEBUG, "Checking Reachability of Node %i from Start Position.", PathNodes[(*Iterator).id].id); @@ -1280,7 +1280,7 @@ void Mob::PrintRoute() printf("Route is : "); - list::iterator Iterator; + std::list::iterator Iterator; for(Iterator = Route.begin(); Iterator !=Route.end(); ++Iterator) { @@ -1324,7 +1324,7 @@ void PathManager::OpenDoors(int Node1, int Node2, Mob *ForWho) //this assumes that the first point in the list is the player's //current position, I dont know how well it works if its not. -void Client::SendPathPacket(vector &points) { +void Client::SendPathPacket(std::vector &points) { if(points.size() < 2) { //empty length packet == not found. EQApplicationPacket outapp(OP_FindPersonReply, 0); @@ -1336,7 +1336,7 @@ void Client::SendPathPacket(vector &points) { EQApplicationPacket *outapp = new EQApplicationPacket(OP_FindPersonReply, len); FindPersonResult_Struct* fpr=(FindPersonResult_Struct*)outapp->pBuffer; - vector::iterator cur, end; + std::vector::iterator cur, end; cur = points.begin(); end = points.end(); unsigned int r; @@ -1473,10 +1473,10 @@ void PathManager::NodeInfo(Client *c) return; } -void PathManager::DumpPath(string filename) +void PathManager::DumpPath(std::string filename) { - ofstream o_file; - o_file.open(filename.c_str(), ios_base::binary | ios_base::trunc | ios_base::out); + std::ofstream o_file; + o_file.open(filename.c_str(), std::ios_base::binary | std::ios_base::trunc | std::ios_base::out); o_file.write("EQEMUPATH", 9); o_file.write((const char*)&Head, sizeof(Head)); o_file.write((const char*)PathNodes, (sizeof(PathNode)*Head.PathNodeCount)); @@ -2114,7 +2114,7 @@ bool PathManager::CheckLosFN(VERTEX a, VERTEX b) return true; } -void PathManager::ProcessNodesAndSave(string filename) +void PathManager::ProcessNodesAndSave(std::string filename) { if(zone->zonemap) { diff --git a/zone/pathing.h b/zone/pathing.h index 1f0e52ff7..e4daf9592 100644 --- a/zone/pathing.h +++ b/zone/pathing.h @@ -7,8 +7,6 @@ #include #include -using namespace std; - class Client; #define PATHNODENEIGHBOURS 50 @@ -63,8 +61,8 @@ public: static PathManager *LoadPathFile(const char *ZoneName); bool loadPaths(FILE *fp); void PrintPathing(); - list FindRoute(VERTEX Start, VERTEX End); - list FindRoute(int startID, int endID); + std::list FindRoute(VERTEX Start, VERTEX End); + std::list FindRoute(int startID, int endID); VERTEX GetPathNodeCoordinates(int NodeNumber, bool BestZ = true); bool CheckLosFN(VERTEX a, VERTEX b); @@ -93,8 +91,8 @@ public: void MoveNode(Client *c); void DisconnectAll(Client *c); bool NodesConnected(PathNode *a, PathNode *b); - void DumpPath(string filename); - void ProcessNodesAndSave(string filename); + void DumpPath(std::string filename); + void ProcessNodesAndSave(std::string filename); void ResortConnections(); void QuickConnect(Client *c, bool set = false); void SortNodes(); diff --git a/zone/perlpacket.h b/zone/perlpacket.h index cb50dcd93..a81e84ad0 100644 --- a/zone/perlpacket.h +++ b/zone/perlpacket.h @@ -20,7 +20,6 @@ #include #include -using namespace std; #include "../common/emu_opcodes.h" diff --git a/zone/petitions.cpp b/zone/petitions.cpp index 2591298cc..7db1f748f 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -300,7 +300,7 @@ void ZoneDatabase::RefreshPetitionsFromDB() newpet->SetUnavails(atoi(row[11])); newpet->SetSentTime2(atol(row[13])); newpet->SetGMText(row[14]); - cout << "Petition " << row[0] << " pettime = " << newpet->GetSentTime() << endl; + std::cout << "Petition " << row[0] << " pettime = " << newpet->GetSentTime() << std::endl; if (atoi(row[12]) == 1) newpet->SetCheckedOut(true); else newpet->SetCheckedOut(false); petition_list.AddPetition(newpet); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 51d8487a1..2fe726c1d 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -58,7 +58,6 @@ And then at then end of embparser.cpp, add: #include #include #include -using namespace std; #include "worldserver.h" #include "net.h" @@ -101,7 +100,7 @@ QuestManager::~QuestManager() { } void QuestManager::Process() { - list::iterator cur = QTimerList.begin(), end, tmp; + std::list::iterator cur = QTimerList.begin(), end, tmp; end = QTimerList.end(); while (cur != end) { @@ -130,7 +129,7 @@ void QuestManager::Process() { cur++; } - list::iterator curS, endS, tmpS; + std::list::iterator curS, endS, tmpS; curS = STimerList.begin(); endS = STimerList.end(); @@ -169,7 +168,7 @@ void QuestManager::EndQuest() { if(depop_npc && owner->IsNPC()) { //clear out any timers for them... - list::iterator cur = QTimerList.begin(), end, tmp; + std::list::iterator cur = QTimerList.begin(), end, tmp; end = QTimerList.end(); while (cur != end) { @@ -190,7 +189,7 @@ void QuestManager::EndQuest() { void QuestManager::ClearAllTimers() { - list::iterator cur = QTimerList.begin(), end, tmp; + std::list::iterator cur = QTimerList.begin(), end, tmp; end = QTimerList.end(); while (cur != end) @@ -453,7 +452,7 @@ void QuestManager::Zone(const char *zone_name) { void QuestManager::settimer(const char *timer_name, int seconds) { - list::iterator cur = QTimerList.begin(), end; + std::list::iterator cur = QTimerList.begin(), end; end = QTimerList.end(); while (cur != end) { @@ -472,7 +471,7 @@ void QuestManager::settimer(const char *timer_name, int seconds) { void QuestManager::settimerMS(const char *timer_name, int milliseconds) { - list::iterator cur = QTimerList.begin(), end; + std::list::iterator cur = QTimerList.begin(), end; end = QTimerList.end(); while (cur != end) { @@ -491,7 +490,7 @@ void QuestManager::settimerMS(const char *timer_name, int milliseconds) { void QuestManager::stoptimer(const char *timer_name) { - list::iterator cur = QTimerList.begin(), end; + std::list::iterator cur = QTimerList.begin(), end; end = QTimerList.end(); while (cur != end) @@ -507,7 +506,7 @@ void QuestManager::stoptimer(const char *timer_name) { void QuestManager::stopalltimers() { - list::iterator cur = QTimerList.begin(), end, tmp; + std::list::iterator cur = QTimerList.begin(), end, tmp; end = QTimerList.end(); while (cur != end) @@ -924,7 +923,7 @@ void QuestManager::givecash(int copper, int silver, int gold, int platinum) { { initiator->AddMoneyToPP(copper, silver, gold, platinum, true); - string tmp; + std::string tmp; if (platinum > 0) { tmp = "You receive "; @@ -1220,7 +1219,7 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti } if (options < 0 || options > 7) { - cerr << "Invalid options for global var " << varname << " using defaults" << endl; + std::cerr << "Invalid options for global var " << varname << " using defaults" << std::endl; } // default = 0 (only this npcid,player and zone) else { @@ -1245,7 +1244,7 @@ int QuestManager::InsertQuestGlobal( char errbuf[MYSQL_ERRMSG_SIZE]; // Make duration string either "unix_timestamp(now()) + xxx" or "NULL" - stringstream duration_ss; + std::stringstream duration_ss; if (duration == INT_MAX) { duration_ss << "NULL"; @@ -1264,7 +1263,7 @@ int QuestManager::InsertQuestGlobal( charid, npcid, zoneid, varname, varvalue, duration_ss.str().c_str() ), errbuf, nullptr, nullptr, &last_id)) { - cerr << "setglobal error inserting " << varname << " : " << errbuf << endl; + std::cerr << "setglobal error inserting " << varname << " : " << errbuf << std::endl; } safe_delete_array(query); @@ -1350,7 +1349,7 @@ void QuestManager::delglobal(const char *varname) { " && (npcid=0 || npcid=%i) && (charid=0 || charid=%i) && (zoneid=%i || zoneid=0)", varname,qgNpcid,qgCharid,qgZoneid),errbuf)) { - cerr << "delglobal error deleting " << varname << " : " << errbuf << endl; + std::cerr << "delglobal error deleting " << varname << " : " << errbuf << std::endl; } safe_delete_array(query); @@ -1569,7 +1568,7 @@ void QuestManager::showgrid(int grid) { MYSQL_ROW row; FindPerson_Point pt; - vector pts; + std::vector pts; pt.x = initiator->GetX(); pt.y = initiator->GetY(); diff --git a/zone/questmgr.h b/zone/questmgr.h index b78e01991..f2ce99973 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -24,7 +24,6 @@ #include #include -using namespace std; class NPC; class Client; @@ -274,9 +273,9 @@ protected: class QuestTimer { public: - inline QuestTimer(int duration, Mob *_mob, string _name) : mob(_mob), name(_name), Timer_(duration) { Timer_.Start(duration, false); } + inline QuestTimer(int duration, Mob *_mob, std::string _name) : mob(_mob), name(_name), Timer_(duration) { Timer_.Start(duration, false); } Mob* mob; - string name; + std::string name; Timer Timer_; }; class SignalTimer { @@ -286,8 +285,8 @@ protected: int signal_id; Timer Timer_; }; - list QTimerList; - list STimerList; + std::list QTimerList; + std::list STimerList; }; diff --git a/zone/raids.cpp b/zone/raids.cpp index 6de7cf912..8b45c3744 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -612,7 +612,7 @@ void Raid::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum char buf[128]; buf[63] = '\0'; - string msg = "You receive"; + std::string msg = "You receive"; bool one = false; if(ppsplit > 0) { diff --git a/zone/raids.h b/zone/raids.h index 89f034df0..811a233c7 100644 --- a/zone/raids.h +++ b/zone/raids.h @@ -28,8 +28,6 @@ class Client; class EQApplicationPacket; -using namespace std; - enum { //raid packet types: raidAdd = 0, raidRemove2 = 1, //parameter=0 diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 6d2b22e8a..349a90909 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -599,7 +599,7 @@ void SpawnConditionManager::Process() { return; //at least one event should get triggered, - vector::iterator cur,end; + std::vector::iterator cur,end; cur = spawn_events.begin(); end = spawn_events.end(); for(; cur != end; cur++) { @@ -614,7 +614,7 @@ void SpawnConditionManager::Process() { ExecEvent(cevent, true); //add the period of the event to the trigger time EQTime::AddMinutes(cevent.period, &cevent.next); - string t; + std::string t; EQTime::ToString(&cevent.next, t); _log(SPAWNS__CONDITIONS, "Event %d: Will trigger again in %d EQ minutes at %s.", cevent.id, cevent.period, t.c_str()); //save the next event time in the DB @@ -631,7 +631,7 @@ void SpawnConditionManager::Process() { } void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) { - map::iterator condi; + std::map::iterator condi; condi = spawn_conditions.find(event.condition_id); if(condi == spawn_conditions.end()) { _log(SPAWNS__CONDITIONS, "Event %d: Unable to find condition %d to execute on.", event.id, event.condition_id); @@ -712,7 +712,7 @@ void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 inst safe_delete_array(query); } -bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, string &zone_name) { +bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std::string &zone_name) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; @@ -742,7 +742,7 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, stri event.argument = atoi(row[10]); zone_name = row[11]; - string t; + std::string t; EQTime::ToString(&event.next, t); _log(SPAWNS__CONDITIONS, "Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d. Will trigger at %s", event.enabled?"enabled":"disabled", event.id, event.condition_id, event.period, event.action, event.argument, t.c_str()); @@ -859,7 +859,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in TimeOfDay_Struct tod; zone->zone_time.getEQTimeOfDay(&tod); - vector::iterator cur,end; + std::vector::iterator cur,end; cur = spawn_events.begin(); end = spawn_events.end(); bool ran; @@ -907,7 +907,7 @@ void SpawnConditionManager::FindNearestEvent() { //set a huge year which should never get reached normally next_event.year = 0xFFFFFF; - vector::iterator cur,end; + std::vector::iterator cur,end; cur = spawn_events.begin(); end = spawn_events.end(); int next_id = -1; @@ -935,7 +935,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance //this is an update coming from another zone, they //have allready updated the DB, just need to update our //memory, and check for condition changes - map::iterator condi; + std::map::iterator condi; condi = spawn_conditions.find(condition_id); if(condi == spawn_conditions.end()) { _log(SPAWNS__CONDITIONS, "Condition update received from world for %d, but we do not have that conditon.", condition_id); @@ -962,7 +962,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance { //this is a local spawn condition, we need to update the DB, //our memory, then notify spawn points of the change. - map::iterator condi; + std::map::iterator condi; condi = spawn_conditions.find(condition_id); if(condi == spawn_conditions.end()) { _log(SPAWNS__CONDITIONS, "Local Condition update requested for %d, but we do not have that conditon.", condition_id); @@ -1011,12 +1011,12 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance } void SpawnConditionManager::ReloadEvent(uint32 event_id) { - string zone_short_name; + std::string zone_short_name; _log(SPAWNS__CONDITIONS, "Requested to reload event %d from the database.", event_id); //first look for the event in our local event list - vector::iterator cur,end; + std::vector::iterator cur,end; cur = spawn_events.begin(); end = spawn_events.end(); for(; cur != end; cur++) { @@ -1059,7 +1059,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool rese _log(SPAWNS__CONDITIONS, "Request to %s spawn event %d %sresetting trigger time", enabled?"enable":"disable", event_id, reset_base?"":"without "); //first look for the event in our local event list - vector::iterator cur,end; + std::vector::iterator cur,end; cur = spawn_events.begin(); end = spawn_events.end(); for(; cur != end; cur++) { @@ -1102,7 +1102,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool rese //is up or not. The message to the zone will just tell it to //update its in-memory event list SpawnEvent e; - string zone_short_name; + std::string zone_short_name; if(!LoadDBEvent(event_id, e, zone_short_name)) { _log(SPAWNS__CONDITIONS, "Unable to find spawn event %d in the database.", event_id); //unable to find the event in the database... @@ -1142,7 +1142,7 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc if(!strcasecmp(zone_short, zone->GetShortName()) && instance_id == zone->GetInstanceID()) { //this is a local spawn condition - map::iterator condi; + std::map::iterator condi; condi = spawn_conditions.find(condition_id); if(condi == spawn_conditions.end()) { @@ -1185,7 +1185,7 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc } bool SpawnConditionManager::Check(uint16 condition, int16 min_value) { - map::iterator condi; + std::map::iterator condi; condi = spawn_conditions.find(condition); if(condi == spawn_conditions.end()) return(false); //unable to find the spawn condition diff --git a/zone/spawn2.h b/zone/spawn2.h index 375f624ce..f32ef35c3 100644 --- a/zone/spawn2.h +++ b/zone/spawn2.h @@ -22,7 +22,6 @@ #include "npc.h" #include -using namespace std; #define SC_AlwaysEnabled 0 @@ -129,7 +128,7 @@ public: uint32 id; uint16 condition_id; - string zone_name; + std::string zone_name; bool enabled; Action action; @@ -153,12 +152,12 @@ public: void ReloadEvent(uint32 event_id); protected: - map spawn_conditions; - vector spawn_events; + std::map spawn_conditions; + std::vector spawn_events; void ExecEvent(SpawnEvent &e, bool send_update); void UpdateDBEvent(SpawnEvent &e); - bool LoadDBEvent(uint32 event_id, SpawnEvent &e, string &zone_name); + bool LoadDBEvent(uint32 event_id, SpawnEvent &e, std::string &zone_name); void UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value); void FindNearestEvent(); diff --git a/zone/spawngroup.cpp b/zone/spawngroup.cpp index d31d53bae..9460137b5 100644 --- a/zone/spawngroup.cpp +++ b/zone/spawngroup.cpp @@ -21,7 +21,6 @@ #include #include #include -using namespace std; #include "../common/types.h" #include "zonedb.h" #include "../common/MiscFunctions.h" @@ -60,8 +59,8 @@ uint32 SpawnGroup::GetNPCType() { if(!entity_list.LimitCheckGroup(id, group_spawn_limit)) return(0); - list::iterator cur,end; - list possible; + std::list::iterator cur,end; + std::list possible; cur = list_.begin(); end = list_.end(); for(; cur != end; cur++) { @@ -101,7 +100,7 @@ void SpawnGroup::AddSpawnEntry( SpawnEntry* newEntry ) { } SpawnGroup::~SpawnGroup() { - list::iterator cur,end; + std::list::iterator cur,end; cur = list_.begin(); end = list_.end(); for(; cur != end; cur++) { @@ -112,7 +111,7 @@ SpawnGroup::~SpawnGroup() { } SpawnGroupList::~SpawnGroupList() { - map::iterator cur,end; + std::map::iterator cur,end; cur = groups.begin(); end = groups.end(); for(; cur != end; cur++) { @@ -161,7 +160,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnG } else { - cerr << "Error2 in PopulateZoneLists query '" << query << "' " << errbuf << endl; + std::cerr << "Error2 in PopulateZoneLists query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -181,13 +180,13 @@ bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnG if (sg) sg->AddSpawnEntry(newSpawnEntry); else - cout << "Error in SpawngroupID: " << row[0] << endl; + std::cout << "Error in SpawngroupID: " << row[0] << std::endl; } mysql_free_result(result); } else { - cerr << "Error3 in PopulateZoneLists query '" << query << "' " << errbuf << endl; + std::cerr << "Error3 in PopulateZoneLists query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -216,7 +215,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_g } else { - cerr << "Error2 in PopulateZoneLists query '" << query << "' " << errbuf << endl; + std::cerr << "Error2 in PopulateZoneLists query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -232,13 +231,13 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_g if (sg) sg->AddSpawnEntry(newSpawnEntry); else - cout << "Error in SpawngroupID: " << row[0] << endl; + std::cout << "Error in SpawngroupID: " << row[0] << std::endl; } mysql_free_result(result); } else { - cerr << "Error3 in PopulateZoneLists query '" << query << "' " << errbuf << endl; + std::cerr << "Error3 in PopulateZoneLists query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } diff --git a/zone/spawngroup.h b/zone/spawngroup.h index bc80b7877..ce1b150db 100644 --- a/zone/spawngroup.h +++ b/zone/spawngroup.h @@ -23,7 +23,6 @@ #include #include -using namespace std; class SpawnEntry { @@ -52,7 +51,7 @@ public: uint32 despawn_timer; private: char name_[120]; - list list_; + std::list list_; uint8 group_spawn_limit; //max # of this entry which can be spawned by this group }; @@ -67,7 +66,7 @@ public: bool RemoveSpawnGroup(uint32 in_id); private: //LinkedList list_; - map groups; + std::map groups; }; #endif diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 58954ffe7..d4ba42cc7 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -3759,7 +3759,7 @@ int16 Client::CalcAAFocus(focusType type, uint32 aa_ID, uint16 spell_id) return 0; } - for (map::const_iterator iter = aa_effects[aa_ID].begin(); iter != aa_effects[aa_ID].end(); ++iter) + for (std::map::const_iterator iter = aa_effects[aa_ID].begin(); iter != aa_effects[aa_ID].end(); ++iter) { effect = iter->second.skill_id; base1 = iter->second.base1; @@ -4642,7 +4642,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { uint8 SizeProcList = 0; uint8 MAX_SYMPATHETIC = 10; - vector SympatheticProcList; + std::vector SympatheticProcList; //item focus if (itembonuses.FocusEffects[type]){ diff --git a/zone/spells.cpp b/zone/spells.cpp index cf37971dd..493599d61 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -1955,8 +1955,8 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 while(angle_end > 360.0f) angle_end -= 360.0f; - list targets_in_range; - list::iterator iter; + std::list targets_in_range; + std::list::iterator iter; entity_list.GetTargetsForConeArea(this, spells[spell_id].aoerange, spells[spell_id].aoerange / 2, targets_in_range); iter = targets_in_range.begin(); @@ -2719,7 +2719,7 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid int buffslot, ret, caster_level, emptyslot = -1; bool will_overwrite = false; - vector overwrite_slots; + std::vector overwrite_slots; if(level_override > 0) caster_level = level_override; @@ -2829,7 +2829,7 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid // to remove some other buffs already worn if will_overwrite is true if(will_overwrite) { - vector::iterator cur, end; + std::vector::iterator cur, end; cur = overwrite_slots.begin(); end = overwrite_slots.end(); for(; cur != end; cur++) { diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 172f3d18c..1f9bda238 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -381,7 +381,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) { } int UpdatedActivityCount = 0; - string UpdateActivityQuery = ActivityQuery; + std::string UpdateActivityQuery = ActivityQuery; char *buf = 0; for(int Activity=0; ActivityActivityCount; Activity++) { @@ -812,8 +812,8 @@ void ClientTaskState::EnableTask(int CharID, int TaskCount, int *TaskList) { // Check if the Task is already enabled for this client // - vector TasksEnabled; - vector::iterator Iterator; + std::vector TasksEnabled; + std::vector::iterator Iterator; for(int i=0; i TasksDisabled; - vector::iterator Iterator; + std::vector TasksDisabled; + std::vector::iterator Iterator; for(int i=0; i::iterator Iterator; + std::vector::iterator Iterator; Iterator = EnabledTasks.begin(); @@ -1015,7 +1015,7 @@ int TaskManager::FirstTaskInSet(int TaskSetID) { if(TaskSets[TaskSetID].size() == 0) return 0; - vector::iterator Iterator = TaskSets[TaskSetID].begin(); + std::vector::iterator Iterator = TaskSets[TaskSetID].begin(); while(Iterator != TaskSets[TaskSetID].end()) { if((*Iterator) > 0) @@ -1079,7 +1079,7 @@ void TaskManager::TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, i if(TaskSets[TaskSetID][0] == 0) { _log(TASKS__UPDATE, "TaskSets[%i][0] == 0. All Tasks in Set enabled.", TaskSetID); - vector::iterator Iterator = TaskSets[TaskSetID].begin(); + std::vector::iterator Iterator = TaskSets[TaskSetID].begin(); while((Iterator != TaskSets[TaskSetID].end()) && (TaskListIndex < MAXCHOOSERENTRIES)) { if(AppropriateLevel((*Iterator), PlayerLevel) && !state->IsTaskActive((*Iterator)) && @@ -1487,7 +1487,7 @@ bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { if(AllActivitiesComplete && RuleB(TaskSystem, RecordCompletedTasks)) { if(RuleB(TasksSystem, KeepOneRecordPerCompletedTask)) { _log(TASKS__UPDATE, "KeepOneRecord enabled"); - vector::iterator Iterator = CompletedTasks.begin(); + std::vector::iterator Iterator = CompletedTasks.begin(); int ErasedElements = 0; while(Iterator != CompletedTasks.end()) { int TaskID = (*Iterator).TaskID; @@ -1560,7 +1560,7 @@ bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { // the same task again, erase the previous completed entry for this task. if(RuleB(TasksSystem, KeepOneRecordPerCompletedTask)) { _log(TASKS__UPDATE, "KeepOneRecord enabled"); - vector::iterator Iterator = CompletedTasks.begin(); + std::vector::iterator Iterator = CompletedTasks.begin(); int ErasedElements = 0; while(Iterator != CompletedTasks.end()) { int TaskID = (*Iterator).TaskID; @@ -2025,7 +2025,7 @@ void ClientTaskState::RewardTask(Client *c, TaskInformation *Task) { if(!Task || !c) return; const Item_Struct* Item; - vector RewardList; + std::vector RewardList; switch(Task->RewardMethod) { @@ -2069,7 +2069,7 @@ void ClientTaskState::RewardTask(Client *c, TaskInformation *Task) { Silver = Copper / 10; Copper = Copper - (Silver * 10); - string CashMessage; + std::string CashMessage; if (Plat>0){ CashMessage = "You receive "; @@ -2908,7 +2908,7 @@ void TaskManager::SendActiveTaskDescription(Client *c, int TaskID, int SequenceN + sizeof(TaskDescriptionData1_Struct) + strlen(Tasks[TaskID]->Description) + 1 + sizeof(TaskDescriptionData2_Struct) + 1 + sizeof(TaskDescriptionTrailer_Struct); - string RewardText; + std::string RewardText; int ItemID = 0; // If there is an item make the Reward text into a link to the item (only the first item if a list @@ -3427,9 +3427,9 @@ int TaskGoalListManager::GetFirstEntry(int ListID) { return TaskGoalLists[ListIndex].GoalItemEntries[0]; } -vector TaskGoalListManager::GetListContents(int ListID) { +std::vector TaskGoalListManager::GetListContents(int ListID) { - vector ListContents; + std::vector ListContents; int ListIndex = GetListByID(ListID); diff --git a/zone/tasks.h b/zone/tasks.h index 25d3872fa..d92d6d17f 100644 --- a/zone/tasks.h +++ b/zone/tasks.h @@ -25,9 +25,6 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) #include #include -using namespace std; - - #define MAXTASKS 10000 #define MAXTASKSETS 1000 // The Client has a hard cap of 19 active tasks @@ -68,7 +65,7 @@ public: int GetListByID(int ListID); bool IsInList(int ListID, int Entry); int GetFirstEntry(int ListID); - vector GetListContents(int ListIndex); + std::vector GetListContents(int ListIndex); private: @@ -91,7 +88,7 @@ public: int CheckProximities(float X, float Y, float Z); private: - vector TaskProximities; + std::vector TaskProximities; }; typedef enum { METHODSINGLEID = 0, METHODLIST = 1, METHODQUEST = 2 } TaskMethodType; @@ -210,8 +207,8 @@ private: void IncrementDoneCount(Client *c, TaskInformation *Task, int TaskIndex, int ActivityID, int Count=1); int ActiveTaskCount; ClientTaskInformation ActiveTasks[MAXACTIVETASKS]; - vectorEnabledTasks; - vector CompletedTasks; + std::vectorEnabledTasks; + std::vector CompletedTasks; int LastCompletedTaskLoaded; bool CheckedTouchActivities; }; @@ -254,7 +251,7 @@ private: TaskGoalListManager GoalListManager; TaskProximityManager ProximityManager; TaskInformation* Tasks[MAXTASKS]; - vector TaskSets[MAXTASKSETS]; + std::vector TaskSets[MAXTASKSETS]; void SendActiveTaskDescription(Client *c, int TaskID, int SequenceNumber, int StartTime, int Duration, bool BringUpTaskJournal=false); }; diff --git a/zone/titles.cpp b/zone/titles.cpp index 1e73da26a..607ade89e 100644 --- a/zone/titles.cpp +++ b/zone/titles.cpp @@ -73,9 +73,9 @@ bool TitleManager::LoadTitles() EQApplicationPacket *TitleManager::MakeTitlesPacket(Client *c) { - vector::iterator Iterator; + std::vector::iterator Iterator; - vector AvailableTitles; + std::vector AvailableTitles; uint32 Length = 4; @@ -122,7 +122,7 @@ int TitleManager::NumberOfAvailableTitles(Client *c) { int Count = 0; - vector::iterator Iterator; + std::vector::iterator Iterator; Iterator = Titles.begin(); @@ -137,9 +137,9 @@ int TitleManager::NumberOfAvailableTitles(Client *c) return Count; } -string TitleManager::GetPrefix(int TitleID) +std::string TitleManager::GetPrefix(int TitleID) { - vector::iterator Iterator; + std::vector::iterator Iterator; Iterator = Titles.begin(); @@ -154,9 +154,9 @@ string TitleManager::GetPrefix(int TitleID) return ""; } -string TitleManager::GetSuffix(int TitleID) +std::string TitleManager::GetSuffix(int TitleID) { - vector::iterator Iterator; + std::vector::iterator Iterator; Iterator = Titles.begin(); @@ -171,7 +171,7 @@ string TitleManager::GetSuffix(int TitleID) return ""; } -bool TitleManager::IsClientEligibleForTitle(Client *c, vector::iterator Title) +bool TitleManager::IsClientEligibleForTitle(Client *c, std::vector::iterator Title) { if((Title->CharID >= 0) && (c->CharacterID() != static_cast(Title->CharID))) return false; @@ -212,7 +212,7 @@ bool TitleManager::IsClientEligibleForTitle(Client *c, vector::itera bool TitleManager::IsNewAATitleAvailable(int AAPoints, int Class) { - vector::iterator Iterator; + std::vector::iterator Iterator; Iterator = Titles.begin(); @@ -229,7 +229,7 @@ bool TitleManager::IsNewAATitleAvailable(int AAPoints, int Class) bool TitleManager::IsNewTradeSkillTitleAvailable(int SkillID, int SkillValue) { - vector::iterator Iterator; + std::vector::iterator Iterator; Iterator = Titles.begin(); diff --git a/zone/titles.h b/zone/titles.h index 923cb6390..51d29d4d6 100644 --- a/zone/titles.h +++ b/zone/titles.h @@ -25,8 +25,6 @@ class Client; class EQApplicationPacket; -using namespace std; - struct TitleEntry { int TitleID; @@ -40,8 +38,8 @@ struct TitleEntry int CharID; int Status; int ItemID; - string Prefix; - string Suffix; + std::string Prefix; + std::string Suffix; int TitleSet; }; @@ -53,17 +51,17 @@ public: bool LoadTitles(); EQApplicationPacket *MakeTitlesPacket(Client *c); - string GetPrefix(int TitleID); - string GetSuffix(int TitleID); + std::string GetPrefix(int TitleID); + std::string GetSuffix(int TitleID); int NumberOfAvailableTitles(Client *c); - bool IsClientEligibleForTitle(Client *c, vector::iterator Title); + bool IsClientEligibleForTitle(Client *c, std::vector::iterator Title); bool IsNewAATitleAvailable(int AAPoints, int Class); bool IsNewTradeSkillTitleAvailable(int SkillID, int SkillValue); void CreateNewPlayerTitle(Client *c, const char *Title); void CreateNewPlayerSuffix(Client *c, const char *Suffix); protected: - vector Titles; + std::vector Titles; }; extern TitleManager title_manager; diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index cd7edc38b..3a16180c4 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -843,7 +843,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { int16 higher_from_int_wis = (GetINT() > GetWIS()) ? GetINT() : GetWIS(); int16 bonusstat = (higher_from_int_wis > thirdstat) ? higher_from_int_wis : thirdstat; - vector< pair >::iterator itr; + std::vector< std::pair >::iterator itr; //calculate the base success chance @@ -1401,7 +1401,7 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id row = mysql_fetch_row(result); uint32 item = (uint32)atoi(row[0]); uint8 num = (uint8) atoi(row[1]); - spec->onsuccess.push_back(pair(item, num)); + spec->onsuccess.push_back(std::pair(item, num)); } mysql_free_result(result); @@ -1418,7 +1418,7 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id row = mysql_fetch_row(result); uint32 item = (uint32)atoi(row[0]); uint8 num = (uint8) atoi(row[1]); - spec->onfail.push_back(pair(item, num)); + spec->onfail.push_back(std::pair(item, num)); } mysql_free_result(result); } @@ -1435,7 +1435,7 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id row = mysql_fetch_row(result); uint32 item = (uint32)atoi(row[0]); uint8 num = (uint8)atoi(row[1]); - spec->salvage.push_back(pair(item, num)); + spec->salvage.push_back(std::pair(item, num)); } mysql_free_result(result); } diff --git a/zone/trading.cpp b/zone/trading.cpp index aae28d0e8..3e41045f8 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -859,7 +859,7 @@ void Client::Trader_EndTrader() { void Client::SendTraderItem(uint32 ItemID, uint16 Quantity) { - string Packet; + std::string Packet; int16 FreeSlotID=0; const Item_Struct* item = database.GetItem(ItemID); @@ -1384,7 +1384,7 @@ void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint char errbuf[MYSQL_ERRMSG_SIZE]; char* Query = 0; - string Search, Values; + std::string Search, Values; MYSQL_RES *Result; MYSQL_ROW Row; char Tmp[100] = {0}; @@ -1402,7 +1402,7 @@ void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint } } - string SearchrResults; + std::string SearchrResults; if(MinPrice != 0){ sprintf(Tmp, " and trader.item_cost>=%i", MinPrice); @@ -2020,7 +2020,7 @@ void Client::SendBuyerResults(char* SearchString, uint32 SearchID) { char errbuf[MYSQL_ERRMSG_SIZE]; char* Query = 0; char ItemName[64]; - string Search, Values; + std::string Search, Values; MYSQL_RES *Result; MYSQL_ROW Row; @@ -2153,7 +2153,7 @@ void Client::ShowBuyLines(const EQApplicationPacket *app) { char errbuf[MYSQL_ERRMSG_SIZE]; char* Query = 0; char ItemName[64]; - string Search, Values; + std::string Search, Values; MYSQL_RES *Result; MYSQL_ROW Row; diff --git a/zone/tribute.cpp b/zone/tribute.cpp index 9d864a72d..bc9fbfa92 100644 --- a/zone/tribute.cpp +++ b/zone/tribute.cpp @@ -24,8 +24,6 @@ #include #include -using namespace std; - #ifdef _WINDOWS #include #include @@ -58,12 +56,12 @@ public: TributeLevel_Struct tiers[MAX_TRIBUTE_TIERS]; uint8 tier_count; uint32 unknown; - string name; - string description; + std::string name; + std::string description; bool is_guild; //is a guild tribute item }; -map tribute_list; +std::map tribute_list; void Client::ToggleTribute(bool enabled) { if(enabled) { @@ -309,7 +307,7 @@ void Client::AddTributePoints(int32 ammount) { void Client::SendTributes() { - map::iterator cur,end; + std::map::iterator cur,end; cur = tribute_list.begin(); end = tribute_list.end(); @@ -343,7 +341,7 @@ void Client::SendTributes() { void Client::SendGuildTributes() { - map::iterator cur,end; + std::map::iterator cur,end; cur = tribute_list.begin(); end = tribute_list.end(); diff --git a/zone/updatemgr.h b/zone/updatemgr.h index b024e5db6..ffc0a0c15 100644 --- a/zone/updatemgr.h +++ b/zone/updatemgr.h @@ -23,7 +23,6 @@ #include "../common/timer.h" #include -using namespace std; /*typedef enum { updateMobPOS = 1, @@ -55,7 +54,7 @@ public: bool ack; }; -typedef map UMMap; +typedef std::map UMMap; class UpdateManager { protected: diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 42dd23007..cf5d1df54 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -18,7 +18,6 @@ #include "../common/debug.h" #ifdef _EQDEBUG #include -using namespace std; #endif //#include #include @@ -71,7 +70,7 @@ void NPC::DisplayWaypointInfo(Client *c) { GetMaxWp() ); - vector::iterator cur, end; + std::vector::iterator cur, end; cur = Waypoints.begin(); end = Waypoints.end(); for(; cur != end; cur++) { @@ -217,7 +216,7 @@ void NPC::UpdateWaypoint(int wp_index) mlog(AI__WAYPOINTS, "Update to waypoint %d failed. Not found.", wp_index); return; } - vector::iterator cur; + std::vector::iterator cur; cur = Waypoints.begin(); cur += wp_index; @@ -268,9 +267,9 @@ void NPC::CalculateNewWaypoint() } case 1: //10 closest { - list closest; + std::list closest; GetClosestWaypoint(closest, 10, GetX(), GetY(), GetZ()); - list::iterator iter = closest.begin(); + std::list::iterator iter = closest.begin(); if(closest.size() != 0) { int idx = MakeRandomInt(0, closest.size() - 1); @@ -328,10 +327,10 @@ void NPC::CalculateNewWaypoint() } case 5: //pick random closest 5 and pick one that's in sight { - list closest; + std::list closest; GetClosestWaypoint(closest, 5, GetX(), GetY(), GetZ()); - list::iterator iter = closest.begin(); + std::list::iterator iter = closest.begin(); while(iter != closest.end()) { if(CheckLosFN((*iter).x, (*iter).y, (*iter).z, GetSize())) @@ -374,7 +373,7 @@ bool wp_distance_pred(const wp_distance& left, const wp_distance& right) return left.dist < right.dist; } -void NPC::GetClosestWaypoint(list &wp_list, int count, float m_x, float m_y, float m_z) +void NPC::GetClosestWaypoint(std::list &wp_list, int count, float m_x, float m_y, float m_z) { wp_list.clear(); if(Waypoints.size() <= count) @@ -386,7 +385,7 @@ void NPC::GetClosestWaypoint(list &wp_list, int count, float m_x, float return; } - list distances; + std::list distances; for(int i = 0; i < Waypoints.size(); ++i) { float cur_x = (Waypoints[i].x - m_x); @@ -403,7 +402,7 @@ void NPC::GetClosestWaypoint(list &wp_list, int count, float m_x, float } distances.sort(wp_distance_pred); - list::iterator iter = distances.begin(); + std::list::iterator iter = distances.begin(); for(int i = 0; i < count; ++i) { wp_list.push_back(Waypoints[(*iter).index]); diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index 3e77a093a..e104faac1 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -17,7 +17,6 @@ */ #include "../common/debug.h" #include -using namespace std; #include #include #include @@ -168,7 +167,7 @@ void WorldServer::Process() { break; } case ServerOP_ZAAuthFailed: { - cout << "World server responded 'Not Authorized', disabling reconnect" << endl; + std::cout << "World server responded 'Not Authorized', disabling reconnect" << std::endl; pTryReconnect = false; Disconnect(); break; @@ -454,7 +453,7 @@ void WorldServer::Process() { } case ServerOP_ZoneShutdown: { if (pack->size != sizeof(ServerZoneStateChange_struct)) { - cout << "Wrong size on ServerOP_ZoneShutdown. Got: " << pack->size << ", Expected: " << sizeof(ServerZoneStateChange_struct) << endl; + std::cout << "Wrong size on ServerOP_ZoneShutdown. Got: " << pack->size << ", Expected: " << sizeof(ServerZoneStateChange_struct) << std::endl; break; } // Annouce the change to the world @@ -465,14 +464,14 @@ void WorldServer::Process() { SendEmoteMessage(0, 0, 15, "Zone shutdown: %s", zone->GetLongName()); ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *) pack->pBuffer; - cout << "Zone shutdown by " << zst->adminname << endl; + std::cout << "Zone shutdown by " << zst->adminname << std::endl; Zone::Shutdown(); } break; } case ServerOP_ZoneBootup: { if (pack->size != sizeof(ServerZoneStateChange_struct)) { - cout << "Wrong size on ServerOP_ZoneBootup. Got: " << pack->size << ", Expected: " << sizeof(ServerZoneStateChange_struct) << endl; + std::cout << "Wrong size on ServerOP_ZoneBootup. Got: " << pack->size << ", Expected: " << sizeof(ServerZoneStateChange_struct) << std::endl; break; } ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *) pack->pBuffer; @@ -489,7 +488,7 @@ void WorldServer::Process() { } if (zst->adminname[0] != 0) - cout << "Zone bootup by " << zst->adminname << endl; + std::cout << "Zone bootup by " << zst->adminname << std::endl; if (!(Zone::Bootup(zst->zoneid, zst->instanceid, zst->makestatic))) { SendChannelMessage(0, 0, 10, 0, 0, "%s:%i Zone::Bootup failed: %s", net.GetZoneAddress(), net.GetZonePort(), database.GetZoneName(zst->zoneid)); @@ -501,7 +500,7 @@ void WorldServer::Process() { } case ServerOP_ZoneIncClient: { if (pack->size != sizeof(ServerZoneIncommingClient_Struct)) { - cout << "Wrong size on ServerOP_ZoneIncClient. Got: " << pack->size << ", Expected: " << sizeof(ServerZoneIncommingClient_Struct) << endl; + std::cout << "Wrong size on ServerOP_ZoneIncClient. Got: " << pack->size << ", Expected: " << sizeof(ServerZoneIncommingClient_Struct) << std::endl; break; } ServerZoneIncommingClient_Struct* szic = (ServerZoneIncommingClient_Struct*) pack->pBuffer; @@ -595,7 +594,7 @@ void WorldServer::Process() { } case ServerOP_GMGoto: { if (pack->size != sizeof(ServerGMGoto_Struct)) { - cout << "Wrong size on ServerOP_GMGoto. Got: " << pack->size << ", Expected: " << sizeof(ServerGMGoto_Struct) << endl; + std::cout << "Wrong size on ServerOP_GMGoto. Got: " << pack->size << ", Expected: " << sizeof(ServerGMGoto_Struct) << std::endl; break; } if (!ZoneLoaded) @@ -634,7 +633,7 @@ void WorldServer::Process() { } case ServerOP_Uptime: { if (pack->size != sizeof(ServerUptime_Struct)) { - cout << "Wrong size on ServerOP_Uptime. Got: " << pack->size << ", Expected: " << sizeof(ServerUptime_Struct) << endl; + std::cout << "Wrong size on ServerOP_Uptime. Got: " << pack->size << ", Expected: " << sizeof(ServerUptime_Struct) << std::endl; break; } ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer; @@ -654,7 +653,7 @@ void WorldServer::Process() { this->SendEmoteMessage(sus->adminname, 0, 0, "Zone #%i Uptime: %02im %02is", sus->zoneserverid, m, s); } case ServerOP_Petition: { - cout << "Got Server Requested Petition List Refresh" << endl; + std::cout << "Got Server Requested Petition List Refresh" << std::endl; ServerPetitionUpdate_Struct* sus = (ServerPetitionUpdate_Struct*) pack->pBuffer; // solar: this was typoed to = instead of ==, not that it acts any different now though.. if (sus->status == 0) petition_list.ReadDatabase(); @@ -723,7 +722,7 @@ void WorldServer::Process() { break; } case ServerOP_ZoneReboot: { - cout << "Got Server Requested Zone reboot" << endl; + std::cout << "Got Server Requested Zone reboot" << std::endl; ServerZoneReboot_Struct* zb = (ServerZoneReboot_Struct*) pack->pBuffer; // printf("%i\n",zb->zoneid); struct in_addr in; @@ -733,12 +732,12 @@ void WorldServer::Process() { snprintf(buffer,200,". %s %i %s",zb->ip2, zb->port, inet_ntoa(in)); if(zb->zoneid != 0) { snprintf(buffer,200,"%s %s %i %s",database.GetZoneName(zb->zoneid),zb->ip2, zb->port ,inet_ntoa(in)); - cout << "executing: " << buffer; + std::cout << "executing: " << buffer; ShellExecute(0,"Open",net.GetZoneFileName(), buffer, 0, SW_SHOWDEFAULT); } else { - cout << "executing: " << net.GetZoneFileName() << " " << buffer; + std::cout << "executing: " << net.GetZoneFileName() << " " << buffer; ShellExecute(0,"Open",net.GetZoneFileName(), buffer, 0, SW_SHOWDEFAULT); } #else @@ -753,7 +752,7 @@ void WorldServer::Process() { } case ServerOP_SyncWorldTime: { if(zone!=0) { - cout << "Received Message SyncWorldTime" << endl; + std::cout << "Received Message SyncWorldTime" << std::endl; eqTimeOfDay* newtime = (eqTimeOfDay*) pack->pBuffer; zone->zone_time.setEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime); EQApplicationPacket* outapp = new EQApplicationPacket(OP_TimeOfDay, sizeof(TimeOfDay_Struct)); @@ -774,7 +773,7 @@ void WorldServer::Process() { eqTime.minute, (eqTime.hour >= 13) ? "pm" : "am" ); - cout << "Time Broadcast Packet: " << timeMessage << endl; + std::cout << "Time Broadcast Packet: " << timeMessage << std::endl; zone->GotCurTime(true); //} //Test @@ -783,7 +782,7 @@ void WorldServer::Process() { } case ServerOP_ChangeWID: { if (pack->size != sizeof(ServerChangeWID_Struct)) { - cout << "Wrong size on ServerChangeWID_Struct. Got: " << pack->size << ", Expected: " << sizeof(ServerChangeWID_Struct) << endl; + std::cout << "Wrong size on ServerChangeWID_Struct. Got: " << pack->size << ", Expected: " << sizeof(ServerChangeWID_Struct) << std::endl; break; } ServerChangeWID_Struct* scw = (ServerChangeWID_Struct*) pack->pBuffer; @@ -1819,8 +1818,8 @@ void WorldServer::Process() { break; } default: { - cout << " Unknown ZSopcode:" << (int)pack->opcode; - cout << " size:" << pack->size << endl; + std::cout << " Unknown ZSopcode:" << (int)pack->opcode; + std::cout << " size:" << pack->size << std::endl; break; } } diff --git a/zone/zone.cpp b/zone/zone.cpp index 707317012..0c7cd1177 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -17,7 +17,6 @@ */ #include "../common/debug.h" #include -using namespace std; #include #include #include @@ -92,7 +91,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { if (iZoneID == 0 || zonename == 0) return false; if (zone != 0 || ZoneLoaded) { - cerr << "Error: Zone::Bootup call when zone already booted!" << endl; + std::cerr << "Error: Zone::Bootup call when zone already booted!" << std::endl; worldserver.SetZone(0); return false; } @@ -105,7 +104,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { //init the zone, loads all the data, etc if (!zone->Init(iStaticZone)) { safe_delete(zone); - cerr << "Zone->Init failed" << endl; + std::cerr << "Zone->Init failed" << std::endl; worldserver.SetZone(0); return false; } @@ -1154,7 +1153,7 @@ bool Zone::Init(bool iStaticZone) { if(RuleManager::Instance()->GetActiveRulesetID() != default_ruleset) { - string r_name = RuleManager::Instance()->GetRulesetName(&database, default_ruleset); + std::string r_name = RuleManager::Instance()->GetRulesetName(&database, default_ruleset); if(r_name.size() > 0) { RuleManager::Instance()->LoadRules(&database, r_name.c_str()); @@ -1719,7 +1718,7 @@ bool ZoneDatabase::LoadStaticZonePoints(LinkedList* zone_point_list, } else { - cerr << "Error1 in LoadStaticZonePoints query '" << query << "' " << errbuf << endl; + std::cerr << "Error1 in LoadStaticZonePoints query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1731,7 +1730,7 @@ bool ZoneDatabase::DumpZoneState() { char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "DELETE FROM zone_state_dump WHERE zonename='%s'", zone->GetShortName()), errbuf)) { - cerr << "Error in DumpZoneState query '" << query << "' " << errbuf << endl; + std::cerr << "Error in DumpZoneState query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -1745,7 +1744,7 @@ bool ZoneDatabase::DumpZoneState() { uint32 gmspawntype_count = 0; entity_list.CountNPC(&npc_count, &npcloot_count, &gmspawntype_count); - cout << "DEBUG: spawn2count=" << spawn2_count << ", npc_count=" << npc_count << ", npcloot_count=" << npcloot_count << ", gmspawntype_count=" << gmspawntype_count << endl; + std::cout << "DEBUG: spawn2count=" << spawn2_count << ", npc_count=" << npc_count << ", npcloot_count=" << npcloot_count << ", gmspawntype_count=" << gmspawntype_count << std::endl; ZSDump_Spawn2* spawn2_dump = 0; ZSDump_NPC* npc_dump = 0; @@ -1812,13 +1811,13 @@ bool ZoneDatabase::DumpZoneState() { if (!RunQuery(query, (uint32) (end - query), errbuf, 0, &affected_rows)) { // if (DoEscapeString(query, (unsigned int) (end - query))) { safe_delete_array(query); - cerr << "Error in ZoneDump query " << errbuf << endl; + std::cerr << "Error in ZoneDump query " << errbuf << std::endl; return false; } safe_delete_array(query); if (affected_rows == 0) { - cerr << "Zone dump failed. (affected rows = 0)" << endl; + std::cerr << "Zone dump failed. (affected rows = 0)" << std::endl; return false; } return true; @@ -1848,13 +1847,13 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw safe_delete_array(query); if (mysql_num_rows(result) == 1) { row = mysql_fetch_row(result); - cout << "Elapsed time: " << row[8] << endl; + std::cout << "Elapsed time: " << row[8] << std::endl; elapsedtime = atoi(row[8]) * 1000; lengths = mysql_fetch_lengths(result); spawn2_count = atoi(row[0]); - cout << "Spawn2count: " << spawn2_count << endl; + std::cout << "Spawn2count: " << spawn2_count << std::endl; if (lengths[4] != (sizeof(ZSDump_Spawn2) * spawn2_count)) { - cerr << "Error in LoadZoneState: spawn2_dump length mismatch l=" << lengths[4] << ", e=" << (sizeof(ZSDump_Spawn2) * spawn2_count) << endl; + std::cerr << "Error in LoadZoneState: spawn2_dump length mismatch l=" << lengths[4] << ", e=" << (sizeof(ZSDump_Spawn2) * spawn2_count) << std::endl; CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); return -1; } @@ -1870,7 +1869,7 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw else spawn2_loaded[i] = LoadSpawn2(spawn2_list, spawn2_dump[i].spawn2_id, spawn2_dump[i].time_left - elapsedtime); if (spawn2_loaded[i] == 0) { - cerr << "Error in LoadZoneState: spawn2_loaded[" << i << "] == 0" << endl; + std::cerr << "Error in LoadZoneState: spawn2_loaded[" << i << "] == 0" << std::endl; CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); return -1; @@ -1879,9 +1878,9 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw } gmspawntype_count = atoi(row[3]); - cout << "gmspawntype_count: " << gmspawntype_count << endl; + std::cout << "gmspawntype_count: " << gmspawntype_count << std::endl; if (lengths[7] != (sizeof(NPCType) * gmspawntype_count)) { - cerr << "Error in LoadZoneState: gmspawntype_dump length mismatch l=" << lengths[7] << ", e=" << (sizeof(NPCType) * gmspawntype_count) << endl; + std::cerr << "Error in LoadZoneState: gmspawntype_dump length mismatch l=" << lengths[7] << ", e=" << (sizeof(NPCType) * gmspawntype_count) << std::endl; CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); return -1; } @@ -1891,9 +1890,9 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw } npc_count = atoi(row[1]); - cout << "npc_count: " << npc_count << endl; + std::cout << "npc_count: " << npc_count << std::endl; if (lengths[5] != (sizeof(ZSDump_NPC) * npc_count)) { - cerr << "Error in LoadZoneState: npc_dump length mismatch l=" << lengths[5] << ", e=" << (sizeof(ZSDump_NPC) * npc_count) << endl; + std::cerr << "Error in LoadZoneState: npc_dump length mismatch l=" << lengths[5] << ", e=" << (sizeof(ZSDump_NPC) * npc_count) << std::endl; CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); return -1; } @@ -1906,14 +1905,14 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw memcpy(npc_dump, row[5], lengths[5]); for (i=0; i < npc_count; i++) { if (npc_loaded[i] != 0) { - cerr << "Error in LoadZoneState: npc_loaded[" << i << "] != 0" << endl; + std::cerr << "Error in LoadZoneState: npc_loaded[" << i << "] != 0" << std::endl; CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); return -1; } Spawn2* tmp = 0; if (!npc_dump[i].corpse && npc_dump[i].spawn2_dump_index != 0xFFFFFFFF) { if (spawn2_loaded == 0 || npc_dump[i].spawn2_dump_index >= spawn2_count) { - cerr << "Error in LoadZoneState: (spawn2_loaded == 0 || index >= count) && npc_dump[" << i << "].spawn2_dump_index != 0xFFFFFFFF" << endl; + std::cerr << "Error in LoadZoneState: (spawn2_loaded == 0 || index >= count) && npc_dump[" << i << "].spawn2_dump_index != 0xFFFFFFFF" << std::endl; CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); return -1; } @@ -1922,7 +1921,7 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw } if (npc_dump[i].npctype_id == 0) { if (npc_dump[i].gmspawntype_index == 0xFFFFFFFF) { - cerr << "Error in LoadZoneState: gmspawntype index invalid" << endl; + std::cerr << "Error in LoadZoneState: gmspawntype index invalid" << std::endl; safe_delete(tmp); CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); @@ -1930,7 +1929,7 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw } else { if (gmspawntype_dump == 0 || npc_dump[i].gmspawntype_index >= gmspawntype_count) { - cerr << "Error in LoadZoneState: (gmspawntype_dump == 0 || index >= count) && npc_dump[" << i << "].npctype_id == 0" << endl; + std::cerr << "Error in LoadZoneState: (gmspawntype_dump == 0 || index >= count) && npc_dump[" << i << "].npctype_id == 0" << std::endl; safe_delete(tmp); CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); @@ -1944,7 +1943,7 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw if (crap != 0) npc_loaded[i] = new NPC(crap, tmp, npc_dump[i].x, npc_dump[i].y, npc_dump[i].z, npc_dump[i].heading, FlyMode3, npc_dump[i].corpse); else { - cerr << "Error in LoadZoneState: Unknown npctype_id: " << npc_dump[i].npctype_id << endl; + std::cerr << "Error in LoadZoneState: Unknown npctype_id: " << npc_dump[i].npctype_id << std::endl; safe_delete(tmp); } } @@ -1962,15 +1961,15 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw } npcloot_count = atoi(row[2]); - cout << "npcloot_count: " << npcloot_count << endl; + std::cout << "npcloot_count: " << npcloot_count << std::endl; if (lengths[6] != (sizeof(ZSDump_NPC_Loot) * npcloot_count)) { - cerr << "Error in LoadZoneState: npcloot_dump length mismatch l=" << lengths[6] << ", e=" << (sizeof(ZSDump_NPC_Loot) * npcloot_count) << endl; + std::cerr << "Error in LoadZoneState: npcloot_dump length mismatch l=" << lengths[6] << ", e=" << (sizeof(ZSDump_NPC_Loot) * npcloot_count) << std::endl; CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); return -1; } else if (npcloot_count > 0) { if (npc_loaded == 0) { - cerr << "Error in LoadZoneState: npcloot_count > 0 && npc_loaded == 0" << endl; + std::cerr << "Error in LoadZoneState: npcloot_count > 0 && npc_loaded == 0" << std::endl; CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); return -1; } @@ -1978,7 +1977,7 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw memcpy(npcloot_dump, row[6], lengths[6]); for (i=0; i < npcloot_count; i++) { if (npcloot_dump[i].npc_dump_index >= npc_count) { - cerr << "Error in LoadZoneState: npcloot_dump[" << i << "].npc_dump_index >= npc_count" << endl; + std::cerr << "Error in LoadZoneState: npcloot_dump[" << i << "].npc_dump_index >= npc_count" << std::endl; CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); return -1; } @@ -1996,7 +1995,7 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList& spaw CleanupLoadZoneState(spawn2_count, &spawn2_dump, &npc_dump, &npcloot_dump, &gmspawntype_dump, &spawn2_loaded, &npc_loaded, &result); } else { - cerr << "Error in LoadZoneState query '" << query << "' " << errbuf << endl; + std::cerr << "Error in LoadZoneState query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return -1; diff --git a/zone/zone.h b/zone/zone.h index 5db6a78b5..28c133fe0 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -185,19 +185,19 @@ public: void LoadLDoNTrapEntries(); void LoadAdventureFlavor(); - map npctable; - map merctable; - map > merchanttable; - map > tmpmerchanttable; - map adventure_entry_list_flavor; - map ldon_trap_list; - map > ldon_trap_entry_list; - map > merc_stance_list; - map merc_templates; - map > merc_spells_list; - map level_exp_mod; - list VeteranRewards; - list AlternateCurrencies; + std::map npctable; + std::map merctable; + std::map > merchanttable; + std::map > tmpmerchanttable; + std::map adventure_entry_list_flavor; + std::map ldon_trap_list; + std::map > ldon_trap_entry_list; + std::map > merc_stance_list; + std::map merc_templates; + std::map > merc_spells_list; + std::map level_exp_mod; + std::list VeteranRewards; + std::list AlternateCurrencies; char *adv_data; bool did_adventure_actions; @@ -265,7 +265,7 @@ public: void LoadTickItems(); uint32 GetSpawnKillCount(uint32 in_spawnid); void UpdateHotzone(); - unordered_map tick_items; + std::unordered_map tick_items; //MODDING HOOKS void mod_init(); diff --git a/zone/zone_profile.cpp b/zone/zone_profile.cpp index 9646587a1..56b7bd9a2 100644 --- a/zone/zone_profile.cpp +++ b/zone/zone_profile.cpp @@ -42,8 +42,6 @@ #include #include -using namespace std; - #ifdef COMMON_PROFILE CommonProfiler _cp; #endif @@ -248,7 +246,7 @@ void DumpZoneProfile() { newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, __DZP_timer.getTotalDuration()); - vector<_DZP_Data> data; + std::vector<_DZP_Data> data; int r; @@ -268,7 +266,7 @@ void DumpZoneProfile() { sort(data.begin(), data.end()); - vector<_DZP_Data>::iterator cur,end; + std::vector<_DZP_Data>::iterator cur,end; cur = data.begin(); end = data.end(); diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index b93104924..82b3d7ada 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -14,8 +14,6 @@ #include #include -using namespace std; - extern Zone* zone; ZoneDatabase database; @@ -272,7 +270,7 @@ bool ZoneDatabase::logevents(const char* accountname,uint32 accountid,uint8 stat DoEscapeString(descriptiontext, description, len); DoEscapeString(targetarr, target, len2); if (!RunQuery(query, MakeAnyLenString(&query, "Insert into eventlog (accountname,accountid,status,charname,target,descriptiontype,description,event_nid) values('%s',%i,%i,'%s','%s','%s','%s','%i')", accountname,accountid,status,charname,targetarr,descriptiontype,descriptiontext,event_nid), errbuf)) { - cerr << "Error in logevents" << query << "' " << errbuf << endl; + std::cerr << "Error in logevents" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -320,7 +318,7 @@ void ZoneDatabase::UpdateBug(BugStruct* bug){ "values('%s', '%s', '%s', '%.2f', '%.2f', '%.2f', '%s', %d, '%s', '%s', CURDATE())", zone->GetShortName(), bug->name, uitext==nullptr?"":uitext, bug->y, bug->x, bug->z, bug->chartype, bug->type, targettext==nullptr?"Unknown Target":targettext, bugtext==nullptr?"":bugtext), errbuf)) { - cerr << "Error in UpdateBug" << query << "' " << errbuf << endl; + std::cerr << "Error in UpdateBug" << query << "' " << errbuf << std::endl; } safe_delete_array(query); safe_delete_array(bugtext); @@ -336,7 +334,7 @@ void ZoneDatabase::UpdateBug(PetitionBug_Struct* bug){ memset(bugtext, 0, 2*len+1); DoEscapeString(bugtext, bug->text, len); if (!RunQuery(query, MakeAnyLenString(&query, "Insert into bugs (type,name,bugtext,flag) values('%s','%s','%s',%i)","Petition",bug->name,bugtext,25), errbuf)) { - cerr << "Error in UpdateBug" << query << "' " << errbuf << endl; + std::cerr << "Error in UpdateBug" << query << "' " << errbuf << std::endl; } safe_delete_array(query); safe_delete_array(bugtext); @@ -988,7 +986,7 @@ bool ZoneDatabase::NoRentExpired(const char* name){ */ const NPCType* ZoneDatabase::GetNPCType (uint32 id) { const NPCType *npc=nullptr; - map::iterator itr; + std::map::iterator itr; // If NPC is already in tree, return it. if((itr = zone->npctable.find(id)) != zone->npctable.end()) @@ -1267,7 +1265,7 @@ const NPCType* ZoneDatabase::GetNPCType (uint32 id) { // free item we attempted to add. if (zone->npctable.find(tmpNPCType->npc_id) != zone->npctable.end()) { - cerr << "Error loading duplicate NPC " << tmpNPCType->npc_id << endl; + std::cerr << "Error loading duplicate NPC " << tmpNPCType->npc_id << std::endl; delete tmpNPCType; npc = nullptr; } else { @@ -1282,7 +1280,7 @@ const NPCType* ZoneDatabase::GetNPCType (uint32 id) { mysql_free_result(result); } } else - cerr << "Error loading NPCs from database. Bad query: " << errbuf << endl; + std::cerr << "Error loading NPCs from database. Bad query: " << errbuf << std::endl; safe_delete_array(query); return npc; @@ -1291,7 +1289,7 @@ const NPCType* ZoneDatabase::GetNPCType (uint32 id) { const NPCType* ZoneDatabase::GetMercType(uint32 id, uint16 raceid, uint32 clientlevel) { const NPCType *npc=nullptr; - map::iterator itr; + std::map::iterator itr; //need to save based on merc_npc_type & client level uint32 merc_type_id = id * 100 + clientlevel; @@ -1592,7 +1590,7 @@ const NPCType* ZoneDatabase::GetMercType(uint32 id, uint16 raceid, uint32 client mysql_free_result(result); } } else - cerr << "Error loading NPCs from database. Bad query: " << errbuf << endl; + std::cerr << "Error loading NPCs from database. Bad query: " << errbuf << std::endl; safe_delete_array(query); return npc; @@ -1985,7 +1983,7 @@ uint8 ZoneDatabase::GetGridType(uint32 grid, uint32 zoneid ) { } mysql_free_result(result); } else { - cerr << "Error in GetGridType query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetGridType query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } return type; @@ -1998,7 +1996,7 @@ void ZoneDatabase::SaveMerchantTemp(uint32 npcid, uint32 slot, uint32 item, uint char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "replace into merchantlist_temp (npcid,slot,itemid,charges) values(%d,%d,%d,%d)", npcid, slot, item, charges), errbuf)) { - cerr << "Error in SaveMerchantTemp query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SaveMerchantTemp query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); } @@ -2007,7 +2005,7 @@ void ZoneDatabase::DeleteMerchantTemp(uint32 npcid, uint32 slot){ char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "delete from merchantlist_temp where npcid=%d and slot=%d", npcid, slot), errbuf)) { - cerr << "Error in DeleteMerchantTemp query '" << query << "' " << errbuf << endl; + std::cerr << "Error in DeleteMerchantTemp query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); } @@ -2059,7 +2057,7 @@ uint8 ZoneDatabase::GetUseCFGSafeCoords() else { - cerr << "Error in GetUseCFGSafeCoords query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetUseCFGSafeCoords query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -2088,7 +2086,7 @@ uint32 ZoneDatabase::GetServerFilters(char* name, ServerSideFilters_Struct *ssfs memcpy(ssfs, row[0], sizeof(ServerSideFilters_Struct)); } else { - cerr << "Player profile length mismatch in ServerSideFilters" << endl; + std::cerr << "Player profile length mismatch in ServerSideFilters" << std::endl; mysql_free_result(result); return 0; } @@ -2103,7 +2101,7 @@ uint32 ZoneDatabase::GetServerFilters(char* name, ServerSideFilters_Struct *ssfs return len; } else { - cerr << "Error in ServerSideFilters query '" << query << "' " << errbuf << endl; + std::cerr << "Error in ServerSideFilters query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return 0; } @@ -2136,7 +2134,7 @@ bool ZoneDatabase::SetServerFilters(char* name, ServerSideFilters_Struct *ssfs) uint32 affected_rows = 0; if (!RunQuery(query, (uint32) (end - query), errbuf, 0, &affected_rows)) { - cerr << "Error in SetServerSideFilters query " << errbuf << endl; + std::cerr << "Error in SetServerSideFilters query " << errbuf << std::endl; return false; } @@ -2167,7 +2165,7 @@ uint32 ZoneDatabase::GetZoneTZ(uint32 zoneid, uint32 version) { mysql_free_result(result); } else { - cerr << "Error in GetZoneTZ query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetZoneTZ query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } return 0; @@ -2187,7 +2185,7 @@ bool ZoneDatabase::SetZoneTZ(uint32 zoneid, uint32 version, uint32 tz) { return false; } else { - cerr << "Error in SetZoneTZ query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetZoneTZ query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -2217,7 +2215,7 @@ uint8 ZoneDatabase::GetZoneWeather(uint32 zoneid, uint32 version) { } else { - cerr << "Error in GetZoneWeather query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetZoneWeather query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } return 0; @@ -2236,7 +2234,7 @@ bool ZoneDatabase::SetZoneWeather(uint32 zoneid, uint32 version, uint8 w) { return false; } else { - cerr << "Error in SetZoneWeather query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetZoneWeather query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -2262,7 +2260,7 @@ bool ZoneDatabase::GetAccountInfoForLogin(uint32 account_id, int16* admin, char* } else { - cerr << "Error in GetAccountInfoForLogin query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetAccountInfoForLogin query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -2384,7 +2382,7 @@ int32 ZoneDatabase::GetBlockedSpellsCount(uint32 zoneid) mysql_free_result(result); } else { - cerr << "Error in GetBlockedSpellsCount query '" << query << "' " << errbuf << endl; + std::cerr << "Error in GetBlockedSpellsCount query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return -1; } @@ -2408,7 +2406,7 @@ bool ZoneDatabase::LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked int32 r; for(r = 0; (row = mysql_fetch_row(result)); r++) { if(r >= blockedSpellsCount) { - cerr << "Error, Blocked Spells Count of " << blockedSpellsCount << " exceeded." << endl; + std::cerr << "Error, Blocked Spells Count of " << blockedSpellsCount << " exceeded." << std::endl; break; } memset(&into[r], 0, sizeof(ZoneSpellsBlocked)); @@ -2428,7 +2426,7 @@ bool ZoneDatabase::LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked } else { - cerr << "Error in LoadBlockedSpells query '" << query << "' " << errbuf << endl; + std::cerr << "Error in LoadBlockedSpells query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -2453,14 +2451,14 @@ int ZoneDatabase::getZoneShutDownDelay(uint32 zoneID, uint32 version) return (retVal); } else { - cerr << "Error in getZoneShutDownDelay no result '" << query << "' " << errbuf << endl; + std::cerr << "Error in getZoneShutDownDelay no result '" << query << "' " << errbuf << std::endl; mysql_free_result(result); safe_delete_array(query); return (RuleI(Zone, AutoShutdownDelay)); } } else { - cerr << "Error in getZoneShutDownDelay query '" << query << "' " << errbuf << endl; + std::cerr << "Error in getZoneShutDownDelay query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } return (RuleI(Zone, AutoShutdownDelay)); @@ -2500,7 +2498,7 @@ void ZoneDatabase::UpdateKarma(uint32 acct_id, uint32 amount) if (RunQuery(query, MakeAnyLenString(&query, "UPDATE account set karma=%i where id=%i", amount, acct_id), errbuf, 0, &affected_rows)){ safe_delete_array(query);} else { - cerr << "Error in UpdateKarma query '" << query << "' " << errbuf << endl; + std::cerr << "Error in UpdateKarma query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } } @@ -2552,7 +2550,7 @@ void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoo char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "replace into doors (id, doorid,zone,version,name,pos_x,pos_y,pos_z,heading,opentype,guild,lockpick,keyitem,door_param,invert_state,incline,size) values('%i','%i','%s','%i', '%s','%f','%f','%f','%f','%i','%i','%i', '%i','%i','%i','%i','%i')", ddoordbid ,ddoorid ,zone->GetShortName(), zone->GetInstanceVersion(), ddoor_name, dxpos, dypos, dzpos, dheading, dopentype, dguildid, dlockpick, dkeyitem, ddoor_param, dinvert, dincline, dsize), errbuf)) { - cerr << "Error in InsertDoor" << query << "' " << errbuf << endl; + std::cerr << "Error in InsertDoor" << query << "' " << errbuf << std::endl; } safe_delete_array(query); } @@ -2820,7 +2818,7 @@ void ZoneDatabase::RemoveTempFactions(Client *c){ char *query = 0; if (!RunQuery(query, MakeAnyLenString(&query, "DELETE FROM faction_values WHERE temp = 1 AND char_id=%u", c->CharacterID()), errbuf)) { - cerr << "Error in RemoveTempFactions query '" << query << "' " << errbuf << endl; + std::cerr << "Error in RemoveTempFactions query '" << query << "' " << errbuf << std::endl; } safe_delete_array(query); } @@ -3015,7 +3013,7 @@ bool ZoneDatabase::LoadFactionValues(uint32 char_id, faction_map & val_list) { return ret; } else { - cerr << "Error in LoadFactionValues query '" << query << "' " << errbuf << endl; + std::cerr << "Error in LoadFactionValues query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); } return false; @@ -3083,7 +3081,7 @@ bool ZoneDatabase::SetCharacterFactionLevel(uint32 char_id, int32 faction_id, in if (!RunQuery(query, MakeAnyLenString(&query, "DELETE FROM faction_values WHERE char_id=%i AND faction_id = %i", char_id, faction_id), errbuf)) { - cerr << "Error in SetCharacterFactionLevel query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetCharacterFactionLevel query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -3103,7 +3101,7 @@ bool ZoneDatabase::SetCharacterFactionLevel(uint32 char_id, int32 faction_id, in if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO faction_values (char_id,faction_id,current_value,temp) VALUES (%i,%i,%i,%i)", char_id, faction_id,value,temp), errbuf, 0, &affected_rows)) { - cerr << "Error in SetCharacterFactionLevel query '" << query << "' " << errbuf << endl; + std::cerr << "Error in SetCharacterFactionLevel query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -3169,7 +3167,7 @@ bool ZoneDatabase::LoadFactionData() mysql_free_result(result); } else { - cerr << "Error in LoadFactionData '" << query << "' " << errbuf << endl; + std::cerr << "Error in LoadFactionData '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } @@ -3179,16 +3177,16 @@ bool ZoneDatabase::LoadFactionData() } } else { - cerr << "Error in LoadFactionData '" << query << "' " << errbuf << endl; + std::cerr << "Error in LoadFactionData '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return false; } return true; } -bool ZoneDatabase::GetFactionIdsForNPC(uint32 nfl_id, list *faction_list, int32* primary_faction) { +bool ZoneDatabase::GetFactionIdsForNPC(uint32 nfl_id, std::list *faction_list, int32* primary_faction) { if (nfl_id <= 0) { - list::iterator cur,end; + std::list::iterator cur,end; cur = faction_list->begin(); end = faction_list->end(); for(; cur != end; cur++) { @@ -3207,7 +3205,7 @@ bool ZoneDatabase::GetFactionIdsForNPC(uint32 nfl_id, list * if (primary_faction) *primary_faction = nfl->primaryfaction; - list::iterator cur,end; + std::list::iterator cur,end; cur = faction_list->begin(); end = faction_list->end(); for(; cur != end; cur++) { diff --git a/zone/zonedb.h b/zone/zonedb.h index e15ac4268..ab5814ee1 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -44,10 +44,10 @@ struct DBTradeskillRecipe_Struct { uint16 trivial; bool nofail; bool replace_container; - vector< pair > onsuccess; - vector< pair > onfail; - vector< pair > salvage; - string name; + std::vector< std::pair > onsuccess; + std::vector< std::pair > onfail; + std::vector< std::pair > salvage; + std::string name; uint8 must_learn; bool has_learnt; uint32 madecount; @@ -172,7 +172,7 @@ struct LootTable_Struct; class ZoneDatabase : public SharedDatabase { - typedef list ItemList; + typedef std::list ItemList; public: ZoneDatabase(); ZoneDatabase(const char* host, const char* user, const char* passwd, const char* database,uint32 port); @@ -272,7 +272,7 @@ public: bool GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, int32* value, uint8* temp, int32* primary_faction = 0); bool GetFactionData(FactionMods* fd, uint32 class_mod, uint32 race_mod, uint32 deity_mod, int32 faction_id); //rembrant, needed for factions Dec, 16 2001 bool GetFactionName(int32 faction_id, char* name, uint32 buflen); // rembrant, needed for factions Dec, 16 2001 - bool GetFactionIdsForNPC(uint32 nfl_id, list *faction_list, int32* primary_faction = 0); // neotokyo: improve faction handling + bool GetFactionIdsForNPC(uint32 nfl_id, std::list *faction_list, int32* primary_faction = 0); // neotokyo: improve faction handling bool SetCharacterFactionLevel(uint32 char_id, int32 faction_id, int32 value, uint8 temp, faction_map &val_list); // rembrant, needed for factions Dec, 16 2001 bool LoadFactionData(); bool LoadFactionValues(uint32 char_id, faction_map & val_list); diff --git a/zone/zonedbasync.cpp b/zone/zonedbasync.cpp index b30c29e52..847519e48 100644 --- a/zone/zonedbasync.cpp +++ b/zone/zonedbasync.cpp @@ -1,6 +1,5 @@ #include "../common/debug.h" #include -using namespace std; #include "entity.h" #include "masterentity.h" #include "../common/MiscFunctions.h" @@ -45,7 +44,7 @@ void DispatchFinishedDBAsync(DBAsyncWork* dbaw) { break; } default: { - cout << "Error: DispatchFinishedDBAsync(): Unknown workpt.b4: " << (int) workpt.b4() << ", workpt=" << workpt << endl; + std::cout << "Error: DispatchFinishedDBAsync(): Unknown workpt.b4: " << (int) workpt.b4() << ", workpt=" << workpt << std::endl; break; } } @@ -112,7 +111,7 @@ bool DBAsyncCB_CharacterBackup(DBAsyncWork* iWork) { // return true means delete "Insert Delayed into character_backup (charid, account_id, name, profile, level, class, x, y, z, zoneid) " "select id, account_id, name, profile, level, class, x, y, z, zoneid " "from character_ where id=%u", iWork->WPT()), errbuf)) { - cout << "Error in DBAsyncCB_CharacterBackup query3 '" << query << "' " << errbuf << endl; + std::cout << "Error in DBAsyncCB_CharacterBackup query3 '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return true; } diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 86684187e..cd0f5fba1 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -787,7 +787,7 @@ void Client::SendZoneFlagInfo(Client *to) const { return; } - set::const_iterator cur, end; + std::set::const_iterator cur, end; cur = zone_flags.begin(); end = zone_flags.end(); char empty[1] = { '\0' };
NameZoneXYZDate" "RezzedBuried
 " "