mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 06:21:28 +00:00
Merge branch 'master' of git://github.com/EQEmu/Server into gcc-changes
This commit is contained in:
commit
b47597b813
@ -79,6 +79,8 @@ IF(MSVC)
|
|||||||
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||||
ENDIF(${flag_var} MATCHES "/MD")
|
ENDIF(${flag_var} MATCHES "/MD")
|
||||||
ENDFOREACH(flag_var)
|
ENDFOREACH(flag_var)
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DNOMINMAX)
|
||||||
ELSE(MSVC)
|
ELSE(MSVC)
|
||||||
#Normally set by perl but we don't use the perl flags anymore so we set it.
|
#Normally set by perl but we don't use the perl flags anymore so we set it.
|
||||||
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
|
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
|
||||||
@ -125,17 +127,8 @@ OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
|||||||
#C++11 stuff
|
#C++11 stuff
|
||||||
IF(NOT MSVC)
|
IF(NOT MSVC)
|
||||||
ADD_DEFINITIONS(-std=c++0x)
|
ADD_DEFINITIONS(-std=c++0x)
|
||||||
#Rvalue-Move - todo: auto set this based on gcc version
|
|
||||||
OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if GCC 4.3 or higher)" OFF)
|
|
||||||
ELSE(NOT MSVC)
|
|
||||||
#Rvalue-Move - todo: auto set this based on msvc version
|
|
||||||
OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if Visual Studio 2010 or higher)" OFF)
|
|
||||||
ENDIF(NOT MSVC)
|
ENDIF(NOT MSVC)
|
||||||
|
|
||||||
IF(EQEMU_ENABLE_RVALUE_MOVE)
|
|
||||||
ADD_DEFINITIONS(-DEQEMU_RVALUE_MOVE)
|
|
||||||
ENDIF(EQEMU_ENABLE_RVALUE_MOVE)
|
|
||||||
|
|
||||||
#Various definitions
|
#Various definitions
|
||||||
IF(EQEMU_BUILD_PERL)
|
IF(EQEMU_BUILD_PERL)
|
||||||
ADD_DEFINITIONS(-DEMBPERL)
|
ADD_DEFINITIONS(-DEMBPERL)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
The server code and utilities are released under GPL.
|
The server code and utilities are released under GPLv3.
|
||||||
|
|
||||||
We also include some small libraries for convienence that may be under different licensing:
|
We also include some small libraries for convienence that may be under different licensing:
|
||||||
|
|
||||||
@ -9,3 +9,4 @@ ZLib - ZLib License
|
|||||||
MySQL - GPL
|
MySQL - GPL
|
||||||
Perl - GPL / ActiveState (under the assumption that this is a free project).
|
Perl - GPL / ActiveState (under the assumption that this is a free project).
|
||||||
CPPUnit - GLP
|
CPPUnit - GLP
|
||||||
|
StringUtilities - Apache
|
||||||
@ -56,7 +56,7 @@ void BasePacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
|||||||
buffer += sprintf(buffer, "%s.%06lu ",temp,timestamp.tv_usec);
|
buffer += sprintf(buffer, "%s.%06lu ",temp,timestamp.tv_usec);
|
||||||
}
|
}
|
||||||
if (src_ip) {
|
if (src_ip) {
|
||||||
string sIP,dIP;;
|
std::string sIP,dIP;;
|
||||||
sIP=long2ip(src_ip);
|
sIP=long2ip(src_ip);
|
||||||
dIP=long2ip(dst_ip);
|
dIP=long2ip(dst_ip);
|
||||||
buffer += sprintf(buffer, "[%s:%d->%s:%d]\n",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
buffer += sprintf(buffer, "[%s:%d->%s:%d]\n",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||||
@ -80,7 +80,7 @@ void BasePacket::build_header_dump(char *buffer) const
|
|||||||
void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||||
{
|
{
|
||||||
if (src_ip) {
|
if (src_ip) {
|
||||||
string sIP,dIP;;
|
std::string sIP,dIP;;
|
||||||
sIP=long2ip(src_ip);
|
sIP=long2ip(src_ip);
|
||||||
dIP=long2ip(dst_ip);
|
dIP=long2ip(dst_ip);
|
||||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||||
|
|||||||
@ -55,6 +55,7 @@ SET(common_sources
|
|||||||
serverinfo.cpp
|
serverinfo.cpp
|
||||||
shareddb.cpp
|
shareddb.cpp
|
||||||
spdat.cpp
|
spdat.cpp
|
||||||
|
StringUtil.cpp
|
||||||
StructStrategy.cpp
|
StructStrategy.cpp
|
||||||
TCPConnection.cpp
|
TCPConnection.cpp
|
||||||
TCPServer.cpp
|
TCPServer.cpp
|
||||||
@ -170,6 +171,7 @@ SET(common_headers
|
|||||||
shareddb.h
|
shareddb.h
|
||||||
skills.h
|
skills.h
|
||||||
spdat.h
|
spdat.h
|
||||||
|
StringUtil.h
|
||||||
StructStrategy.h
|
StructStrategy.h
|
||||||
TCPBasicServer.h
|
TCPBasicServer.h
|
||||||
TCPConnection.h
|
TCPConnection.h
|
||||||
@ -313,7 +315,6 @@ INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML)
|
|||||||
|
|
||||||
ADD_LIBRARY(Common ${common_sources} ${common_headers})
|
ADD_LIBRARY(Common ${common_sources} ${common_headers})
|
||||||
|
|
||||||
|
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
ADD_DEFINITIONS(-fPIC)
|
ADD_DEFINITIONS(-fPIC)
|
||||||
SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0)
|
SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0)
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public:
|
|||||||
//END PERL EXPORT
|
//END PERL EXPORT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_escapeBuffer;
|
std::string m_escapeBuffer;
|
||||||
static EQDB s_EQDB;
|
static EQDB s_EQDB;
|
||||||
MYSQL *mysql_ref;
|
MYSQL *mysql_ref;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -19,8 +19,8 @@
|
|||||||
#include "EQDBRes.h"
|
#include "EQDBRes.h"
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
|
||||||
vector<string> EQDBRes::fetch_row_array() {
|
std::vector<std::string> EQDBRes::fetch_row_array() {
|
||||||
vector<string> array;
|
std::vector<std::string> array;
|
||||||
if(res == nullptr)
|
if(res == nullptr)
|
||||||
return(array);
|
return(array);
|
||||||
|
|
||||||
@ -32,8 +32,8 @@ vector<string> EQDBRes::fetch_row_array() {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
map<string,string> EQDBRes::fetch_row_hash() {
|
std::map<std::string,std::string> EQDBRes::fetch_row_hash() {
|
||||||
map<string,string> rowhash;
|
std::map<std::string,std::string> rowhash;
|
||||||
if(res == nullptr)
|
if(res == nullptr)
|
||||||
return(rowhash);
|
return(rowhash);
|
||||||
|
|
||||||
|
|||||||
@ -36,8 +36,8 @@ public:
|
|||||||
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
|
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
|
||||||
void DESTROY() { }
|
void DESTROY() { }
|
||||||
void finish() { if (res) mysql_free_result(res); res=nullptr; };
|
void finish() { if (res) mysql_free_result(res); res=nullptr; };
|
||||||
vector<string> fetch_row_array();
|
std::vector<std::string> fetch_row_array();
|
||||||
map<string,string> fetch_row_hash();
|
std::map<std::string,std::string> fetch_row_hash();
|
||||||
unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; }
|
unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; }
|
||||||
//END PERL EXPORT
|
//END PERL EXPORT
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
string EQEmuConfig::ConfigFile = "eqemu_config.xml";
|
std::string EQEmuConfig::ConfigFile = "eqemu_config.xml";
|
||||||
EQEmuConfig *EQEmuConfig::_config = nullptr;
|
EQEmuConfig *EQEmuConfig::_config = nullptr;
|
||||||
|
|
||||||
void EQEmuConfig::do_world(TiXmlElement *ele) {
|
void EQEmuConfig::do_world(TiXmlElement *ele) {
|
||||||
@ -315,7 +315,7 @@ void EQEmuConfig::do_launcher(TiXmlElement *ele) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string EQEmuConfig::GetByName(const string &var_name) const {
|
std::string EQEmuConfig::GetByName(const std::string &var_name) const {
|
||||||
if(var_name == "ShortName")
|
if(var_name == "ShortName")
|
||||||
return(ShortName);
|
return(ShortName);
|
||||||
if(var_name == "LongName")
|
if(var_name == "LongName")
|
||||||
@ -405,44 +405,44 @@ string EQEmuConfig::GetByName(const string &var_name) const {
|
|||||||
|
|
||||||
void EQEmuConfig::Dump() const
|
void EQEmuConfig::Dump() const
|
||||||
{
|
{
|
||||||
cout << "ShortName = " << ShortName << endl;
|
std::cout << "ShortName = " << ShortName << std::endl;
|
||||||
cout << "LongName = " << LongName << endl;
|
std::cout << "LongName = " << LongName << std::endl;
|
||||||
cout << "WorldAddress = " << WorldAddress << endl;
|
std::cout << "WorldAddress = " << WorldAddress << std::endl;
|
||||||
cout << "LoginHost = " << LoginHost << endl;
|
std::cout << "LoginHost = " << LoginHost << std::endl;
|
||||||
cout << "LoginAccount = " << LoginAccount << endl;
|
std::cout << "LoginAccount = " << LoginAccount << std::endl;
|
||||||
cout << "LoginPassword = " << LoginPassword << endl;
|
std::cout << "LoginPassword = " << LoginPassword << std::endl;
|
||||||
cout << "LoginPort = " << LoginPort << endl;
|
std::cout << "LoginPort = " << LoginPort << std::endl;
|
||||||
cout << "Locked = " << Locked << endl;
|
std::cout << "Locked = " << Locked << std::endl;
|
||||||
cout << "WorldTCPPort = " << WorldTCPPort << endl;
|
std::cout << "WorldTCPPort = " << WorldTCPPort << std::endl;
|
||||||
cout << "WorldIP = " << WorldIP << endl;
|
std::cout << "WorldIP = " << WorldIP << std::endl;
|
||||||
cout << "TelnetEnabled = " << TelnetEnabled << endl;
|
std::cout << "TelnetEnabled = " << TelnetEnabled << std::endl;
|
||||||
cout << "WorldHTTPPort = " << WorldHTTPPort << endl;
|
std::cout << "WorldHTTPPort = " << WorldHTTPPort << std::endl;
|
||||||
cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << endl;
|
std::cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << std::endl;
|
||||||
cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << endl;
|
std::cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << std::endl;
|
||||||
cout << "ChatHost = " << ChatHost << endl;
|
std::cout << "ChatHost = " << ChatHost << std::endl;
|
||||||
cout << "ChatPort = " << ChatPort << endl;
|
std::cout << "ChatPort = " << ChatPort << std::endl;
|
||||||
cout << "MailHost = " << MailHost << endl;
|
std::cout << "MailHost = " << MailHost << std::endl;
|
||||||
cout << "MailPort = " << MailPort << endl;
|
std::cout << "MailPort = " << MailPort << std::endl;
|
||||||
cout << "DatabaseHost = " << DatabaseHost << endl;
|
std::cout << "DatabaseHost = " << DatabaseHost << std::endl;
|
||||||
cout << "DatabaseUsername = " << DatabaseUsername << endl;
|
std::cout << "DatabaseUsername = " << DatabaseUsername << std::endl;
|
||||||
cout << "DatabasePassword = " << DatabasePassword << endl;
|
std::cout << "DatabasePassword = " << DatabasePassword << std::endl;
|
||||||
cout << "DatabaseDB = " << DatabaseDB << endl;
|
std::cout << "DatabaseDB = " << DatabaseDB << std::endl;
|
||||||
cout << "DatabasePort = " << DatabasePort << endl;
|
std::cout << "DatabasePort = " << DatabasePort << std::endl;
|
||||||
cout << "QSDatabaseHost = " << QSDatabaseHost << endl;
|
std::cout << "QSDatabaseHost = " << QSDatabaseHost << std::endl;
|
||||||
cout << "QSDatabaseUsername = " << QSDatabaseUsername << endl;
|
std::cout << "QSDatabaseUsername = " << QSDatabaseUsername << std::endl;
|
||||||
cout << "QSDatabasePassword = " << QSDatabasePassword << endl;
|
std::cout << "QSDatabasePassword = " << QSDatabasePassword << std::endl;
|
||||||
cout << "QSDatabaseDB = " << QSDatabaseDB << endl;
|
std::cout << "QSDatabaseDB = " << QSDatabaseDB << std::endl;
|
||||||
cout << "QSDatabasePort = " << QSDatabasePort << endl;
|
std::cout << "QSDatabasePort = " << QSDatabasePort << std::endl;
|
||||||
cout << "SpellsFile = " << SpellsFile << endl;
|
std::cout << "SpellsFile = " << SpellsFile << std::endl;
|
||||||
cout << "OpCodesFile = " << OpCodesFile << endl;
|
std::cout << "OpCodesFile = " << OpCodesFile << std::endl;
|
||||||
cout << "EQTimeFile = " << EQTimeFile << endl;
|
std::cout << "EQTimeFile = " << EQTimeFile << std::endl;
|
||||||
cout << "LogSettingsFile = " << LogSettingsFile << endl;
|
std::cout << "LogSettingsFile = " << LogSettingsFile << std::endl;
|
||||||
cout << "MapDir = " << MapDir << endl;
|
std::cout << "MapDir = " << MapDir << std::endl;
|
||||||
cout << "QuestDir = " << QuestDir << endl;
|
std::cout << "QuestDir = " << QuestDir << std::endl;
|
||||||
cout << "PluginDir = " << PluginDir << endl;
|
std::cout << "PluginDir = " << PluginDir << std::endl;
|
||||||
cout << "ZonePortLow = " << ZonePortLow << endl;
|
std::cout << "ZonePortLow = " << ZonePortLow << std::endl;
|
||||||
cout << "ZonePortHigh = " << ZonePortHigh << endl;
|
std::cout << "ZonePortHigh = " << ZonePortHigh << std::endl;
|
||||||
cout << "DefaultStatus = " << (int)DefaultStatus << endl;
|
std::cout << "DefaultStatus = " << (int)DefaultStatus << std::endl;
|
||||||
// cout << "DynamicCount = " << DynamicCount << endl;
|
// std::cout << "DynamicCount = " << DynamicCount << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,74 +22,74 @@
|
|||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
|
|
||||||
struct LoginConfig {
|
struct LoginConfig {
|
||||||
string LoginHost;
|
std::string LoginHost;
|
||||||
string LoginAccount;
|
std::string LoginAccount;
|
||||||
string LoginPassword;
|
std::string LoginPassword;
|
||||||
uint16 LoginPort;
|
uint16 LoginPort;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EQEmuConfig : public XMLParser {
|
class EQEmuConfig : public XMLParser {
|
||||||
public:
|
public:
|
||||||
virtual string GetByName(const string &var_name) const;
|
virtual std::string GetByName(const std::string &var_name) const;
|
||||||
|
|
||||||
// From <world/>
|
// From <world/>
|
||||||
string ShortName;
|
std::string ShortName;
|
||||||
string LongName;
|
std::string LongName;
|
||||||
string WorldAddress;
|
std::string WorldAddress;
|
||||||
string LocalAddress;
|
std::string LocalAddress;
|
||||||
string LoginHost;
|
std::string LoginHost;
|
||||||
string LoginAccount;
|
std::string LoginAccount;
|
||||||
string LoginPassword;
|
std::string LoginPassword;
|
||||||
uint16 LoginPort;
|
uint16 LoginPort;
|
||||||
uint32 LoginCount;
|
uint32 LoginCount;
|
||||||
LinkedList<LoginConfig*> loginlist;
|
LinkedList<LoginConfig*> loginlist;
|
||||||
bool Locked;
|
bool Locked;
|
||||||
uint16 WorldTCPPort;
|
uint16 WorldTCPPort;
|
||||||
string WorldIP;
|
std::string WorldIP;
|
||||||
bool TelnetEnabled;
|
bool TelnetEnabled;
|
||||||
int32 MaxClients;
|
int32 MaxClients;
|
||||||
bool WorldHTTPEnabled;
|
bool WorldHTTPEnabled;
|
||||||
uint16 WorldHTTPPort;
|
uint16 WorldHTTPPort;
|
||||||
string WorldHTTPMimeFile;
|
std::string WorldHTTPMimeFile;
|
||||||
string SharedKey;
|
std::string SharedKey;
|
||||||
|
|
||||||
// From <chatserver/>
|
// From <chatserver/>
|
||||||
string ChatHost;
|
std::string ChatHost;
|
||||||
uint16 ChatPort;
|
uint16 ChatPort;
|
||||||
|
|
||||||
// From <mailserver/>
|
// From <mailserver/>
|
||||||
string MailHost;
|
std::string MailHost;
|
||||||
uint16 MailPort;
|
uint16 MailPort;
|
||||||
|
|
||||||
// From <database/>
|
// From <database/>
|
||||||
string DatabaseHost;
|
std::string DatabaseHost;
|
||||||
string DatabaseUsername;
|
std::string DatabaseUsername;
|
||||||
string DatabasePassword;
|
std::string DatabasePassword;
|
||||||
string DatabaseDB;
|
std::string DatabaseDB;
|
||||||
uint16 DatabasePort;
|
uint16 DatabasePort;
|
||||||
|
|
||||||
// From <qsdatabase> // QueryServ
|
// From <qsdatabase> // QueryServ
|
||||||
string QSDatabaseHost;
|
std::string QSDatabaseHost;
|
||||||
string QSDatabaseUsername;
|
std::string QSDatabaseUsername;
|
||||||
string QSDatabasePassword;
|
std::string QSDatabasePassword;
|
||||||
string QSDatabaseDB;
|
std::string QSDatabaseDB;
|
||||||
uint16 QSDatabasePort;
|
uint16 QSDatabasePort;
|
||||||
|
|
||||||
// From <files/>
|
// From <files/>
|
||||||
string SpellsFile;
|
std::string SpellsFile;
|
||||||
string OpCodesFile;
|
std::string OpCodesFile;
|
||||||
string EQTimeFile;
|
std::string EQTimeFile;
|
||||||
string LogSettingsFile;
|
std::string LogSettingsFile;
|
||||||
|
|
||||||
// From <directories/>
|
// From <directories/>
|
||||||
string MapDir;
|
std::string MapDir;
|
||||||
string QuestDir;
|
std::string QuestDir;
|
||||||
string PluginDir;
|
std::string PluginDir;
|
||||||
|
|
||||||
// From <launcher/>
|
// From <launcher/>
|
||||||
string LogPrefix;
|
std::string LogPrefix;
|
||||||
string LogSuffix;
|
std::string LogSuffix;
|
||||||
string ZoneExe;
|
std::string ZoneExe;
|
||||||
uint32 RestartWait;
|
uint32 RestartWait;
|
||||||
uint32 TerminateWait;
|
uint32 TerminateWait;
|
||||||
uint32 InitialBootWait;
|
uint32 InitialBootWait;
|
||||||
@ -108,7 +108,7 @@ protected:
|
|||||||
|
|
||||||
static EQEmuConfig *_config;
|
static EQEmuConfig *_config;
|
||||||
|
|
||||||
static string ConfigFile;
|
static std::string ConfigFile;
|
||||||
|
|
||||||
#define ELEMENT(name) \
|
#define ELEMENT(name) \
|
||||||
void do_##name(TiXmlElement *ele);
|
void do_##name(TiXmlElement *ele);
|
||||||
@ -210,7 +210,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allow the use to set the conf file to be used.
|
// Allow the use to set the conf file to be used.
|
||||||
static void SetConfigFile(string file) { EQEmuConfig::ConfigFile = file; }
|
static void SetConfigFile(std::string file) { EQEmuConfig::ConfigFile = file; }
|
||||||
|
|
||||||
// Load the config
|
// Load the config
|
||||||
static bool LoadConfig() {
|
static bool LoadConfig() {
|
||||||
|
|||||||
@ -46,8 +46,6 @@
|
|||||||
#include "../common/crc32.h"
|
#include "../common/crc32.h"
|
||||||
#include "../common/eq_packet_structs.h"
|
#include "../common/eq_packet_structs.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define EQN_DEBUG 0
|
#define EQN_DEBUG 0
|
||||||
#define EQN_DEBUG_Error 0
|
#define EQN_DEBUG_Error 0
|
||||||
#define EQN_DEBUG_Packet 0
|
#define EQN_DEBUG_Packet 0
|
||||||
@ -230,19 +228,19 @@ void EQStreamServer::Process() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
map <string, EQStream*>::iterator connection;
|
std::map <std::string, EQStream*>::iterator connection;
|
||||||
for (connection = connection_list.begin( ); connection != connection_list.end( );)
|
for (connection = connection_list.begin( ); connection != connection_list.end( );)
|
||||||
{
|
{
|
||||||
if(!connection->second)
|
if(!connection->second)
|
||||||
{
|
{
|
||||||
map <string, EQStream*>::iterator tmp=connection;
|
std::map <std::string, EQStream*>::iterator tmp=connection;
|
||||||
connection++;
|
connection++;
|
||||||
connection_list.erase(tmp);
|
connection_list.erase(tmp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
EQStream* eqs_data = connection->second;
|
EQStream* eqs_data = connection->second;
|
||||||
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
|
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
|
||||||
map <string, EQStream*>::iterator tmp=connection;
|
std::map <std::string, EQStream*>::iterator tmp=connection;
|
||||||
connection++;
|
connection++;
|
||||||
safe_delete(eqs_data);
|
safe_delete(eqs_data);
|
||||||
connection_list.erase(tmp);
|
connection_list.erase(tmp);
|
||||||
@ -277,7 +275,7 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
|
|||||||
sprintf(temp,"%lu:%u",(unsigned long)irIP,irPort);
|
sprintf(temp,"%lu:%u",(unsigned long)irIP,irPort);
|
||||||
cout << "Data from " << temp << endl;
|
cout << "Data from " << temp << endl;
|
||||||
EQStream* tmp = NULL;
|
EQStream* tmp = NULL;
|
||||||
map <string, EQStream*>::iterator connection;
|
std::map <std::string, EQStream*>::iterator connection;
|
||||||
if ((connection=connection_list.find(temp))!=connection_list.end())
|
if ((connection=connection_list.find(temp))!=connection_list.end())
|
||||||
tmp=connection->second;
|
tmp=connection->second;
|
||||||
if(tmp != NULL && tmp->GetrPort() == irPort)
|
if(tmp != NULL && tmp->GetrPort() == irPort)
|
||||||
|
|||||||
@ -30,7 +30,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "../common/types.h"
|
#include "../common/types.h"
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
@ -114,8 +113,8 @@ private:
|
|||||||
Mutex MNewQueue;
|
Mutex MNewQueue;
|
||||||
Mutex MOpen;
|
Mutex MOpen;
|
||||||
|
|
||||||
map<string,EQStream*> connection_list;
|
std::map<std::string,EQStream*> connection_list;
|
||||||
queue<EQStream *> NewQueue;
|
std::queue<EQStream *> NewQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -32,8 +32,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
|
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
|
||||||
: BasePacket(buf, len),
|
: BasePacket(buf, len),
|
||||||
emu_opcode(op)
|
emu_opcode(op)
|
||||||
@ -61,7 +59,7 @@ void EQPacket::build_header_dump(char *buffer) const {
|
|||||||
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||||
{
|
{
|
||||||
if (src_ip) {
|
if (src_ip) {
|
||||||
string sIP,dIP;;
|
std::string sIP,dIP;;
|
||||||
sIP=long2ip(src_ip);
|
sIP=long2ip(src_ip);
|
||||||
dIP=long2ip(dst_ip);
|
dIP=long2ip(dst_ip);
|
||||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||||
@ -95,7 +93,7 @@ void EQProtocolPacket::build_header_dump(char *buffer) const
|
|||||||
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||||
{
|
{
|
||||||
if (src_ip) {
|
if (src_ip) {
|
||||||
string sIP,dIP;;
|
std::string sIP,dIP;;
|
||||||
sIP=long2ip(src_ip);
|
sIP=long2ip(src_ip);
|
||||||
dIP=long2ip(dst_ip);
|
dIP=long2ip(dst_ip);
|
||||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||||
@ -137,7 +135,7 @@ void EQApplicationPacket::build_header_dump(char *buffer) const
|
|||||||
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||||
{
|
{
|
||||||
if (src_ip) {
|
if (src_ip) {
|
||||||
string sIP,dIP;;
|
std::string sIP,dIP;;
|
||||||
sIP=long2ip(src_ip);
|
sIP=long2ip(src_ip);
|
||||||
dIP=long2ip(dst_ip);
|
dIP=long2ip(dst_ip);
|
||||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||||
@ -183,7 +181,7 @@ void EQRawApplicationPacket::build_header_dump(char *buffer) const
|
|||||||
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||||
{
|
{
|
||||||
if (src_ip) {
|
if (src_ip) {
|
||||||
string sIP,dIP;;
|
std::string sIP,dIP;;
|
||||||
sIP=long2ip(src_ip);
|
sIP=long2ip(src_ip);
|
||||||
dIP=long2ip(dst_ip);
|
dIP=long2ip(dst_ip);
|
||||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||||
@ -502,8 +500,8 @@ EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const u
|
|||||||
|
|
||||||
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
|
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
|
||||||
if (iShowInfo) {
|
if (iShowInfo) {
|
||||||
cout << "Dumping Applayer: 0x" << hex << setfill('0') << setw(4) << app->GetOpcode() << dec;
|
std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
|
||||||
cout << " size:" << app->size << endl;
|
std::cout << " size:" << app->size << std::endl;
|
||||||
}
|
}
|
||||||
DumpPacketHex(app->pBuffer, app->size);
|
DumpPacketHex(app->pBuffer, app->size);
|
||||||
// DumpPacketAscii(app->pBuffer, app->size);
|
// DumpPacketAscii(app->pBuffer, app->size);
|
||||||
|
|||||||
@ -30,8 +30,6 @@
|
|||||||
#include "emu_opcodes.h"
|
#include "emu_opcodes.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class EQStream;
|
class EQStream;
|
||||||
class EQStreamPair;
|
class EQStreamPair;
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <time.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -424,7 +423,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
|
|||||||
uint16 index = seq - SequencedBase;
|
uint16 index = seq - SequencedBase;
|
||||||
_log(NET__NET_TRACE, _L " OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
|
_log(NET__NET_TRACE, _L " OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
|
||||||
if (index < sqsize) {
|
if (index < sqsize) {
|
||||||
deque<EQProtocolPacket *>::iterator sitr;
|
std::deque<EQProtocolPacket *>::iterator sitr;
|
||||||
sitr = SequencedQueue.begin();
|
sitr = SequencedQueue.begin();
|
||||||
sitr += index;
|
sitr += index;
|
||||||
(*sitr)->acked = true;
|
(*sitr)->acked = true;
|
||||||
@ -567,7 +566,7 @@ uint32 length;
|
|||||||
|
|
||||||
while (used<length) {
|
while (used<length) {
|
||||||
out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
|
out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
|
||||||
chunksize=min(length-used,MaxLen-6);
|
chunksize=std::min(length-used,MaxLen-6);
|
||||||
memcpy(out->pBuffer+2,tmpbuff+used,chunksize);
|
memcpy(out->pBuffer+2,tmpbuff+used,chunksize);
|
||||||
out->size=chunksize+2;
|
out->size=chunksize+2;
|
||||||
SequencedPush(out);
|
SequencedPush(out);
|
||||||
@ -646,9 +645,9 @@ uint16 Seq=htons(seq);
|
|||||||
|
|
||||||
void EQStream::Write(int eq_fd)
|
void EQStream::Write(int eq_fd)
|
||||||
{
|
{
|
||||||
queue<EQProtocolPacket *> ReadyToSend;
|
std::queue<EQProtocolPacket *> ReadyToSend;
|
||||||
bool SeqEmpty=false,NonSeqEmpty=false;
|
bool SeqEmpty=false,NonSeqEmpty=false;
|
||||||
deque<EQProtocolPacket *>::iterator sitr;
|
std::deque<EQProtocolPacket *>::iterator sitr;
|
||||||
|
|
||||||
// Check our rate to make sure we can send more
|
// Check our rate to make sure we can send more
|
||||||
MRate.lock();
|
MRate.lock();
|
||||||
@ -951,7 +950,7 @@ EQRawApplicationPacket *p=nullptr;
|
|||||||
|
|
||||||
MInboundQueue.lock();
|
MInboundQueue.lock();
|
||||||
if (InboundQueue.size()) {
|
if (InboundQueue.size()) {
|
||||||
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
|
std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
|
||||||
p=*itr;
|
p=*itr;
|
||||||
InboundQueue.erase(itr);
|
InboundQueue.erase(itr);
|
||||||
}
|
}
|
||||||
@ -979,7 +978,7 @@ EQRawApplicationPacket *p=nullptr;
|
|||||||
|
|
||||||
MInboundQueue.lock();
|
MInboundQueue.lock();
|
||||||
if (InboundQueue.size()) {
|
if (InboundQueue.size()) {
|
||||||
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
|
std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
|
||||||
p=*itr;
|
p=*itr;
|
||||||
InboundQueue.erase(itr);
|
InboundQueue.erase(itr);
|
||||||
}
|
}
|
||||||
@ -1007,7 +1006,7 @@ EQRawApplicationPacket *p=nullptr;
|
|||||||
|
|
||||||
MInboundQueue.lock();
|
MInboundQueue.lock();
|
||||||
if (InboundQueue.size()) {
|
if (InboundQueue.size()) {
|
||||||
vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
|
std::vector<EQRawApplicationPacket *>::iterator itr=InboundQueue.begin();
|
||||||
p=*itr;
|
p=*itr;
|
||||||
}
|
}
|
||||||
MInboundQueue.unlock();
|
MInboundQueue.unlock();
|
||||||
@ -1023,7 +1022,7 @@ EQApplicationPacket *p=nullptr;
|
|||||||
|
|
||||||
MInboundQueue.lock();
|
MInboundQueue.lock();
|
||||||
if (!InboundQueue.empty()) {
|
if (!InboundQueue.empty()) {
|
||||||
vector<EQRawApplicationPacket *>::iterator itr;
|
std::vector<EQRawApplicationPacket *>::iterator itr;
|
||||||
for(itr=InboundQueue.begin();itr!=InboundQueue.end();itr++) {
|
for(itr=InboundQueue.begin();itr!=InboundQueue.end();itr++) {
|
||||||
p=*itr;
|
p=*itr;
|
||||||
delete p;
|
delete p;
|
||||||
@ -1070,7 +1069,7 @@ EQProtocolPacket *p=nullptr;
|
|||||||
NonSequencedQueue.pop();
|
NonSequencedQueue.pop();
|
||||||
}
|
}
|
||||||
if(!SequencedQueue.empty()) {
|
if(!SequencedQueue.empty()) {
|
||||||
deque<EQProtocolPacket *>::iterator itr;
|
std::deque<EQProtocolPacket *>::iterator itr;
|
||||||
for(itr=SequencedQueue.begin();itr!=SequencedQueue.end();itr++) {
|
for(itr=SequencedQueue.begin();itr!=SequencedQueue.end();itr++) {
|
||||||
p=*itr;
|
p=*itr;
|
||||||
delete p;
|
delete p;
|
||||||
@ -1095,7 +1094,7 @@ EQProtocolPacket *p=nullptr;
|
|||||||
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
|
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
|
||||||
|
|
||||||
if(!PacketQueue.empty()) {
|
if(!PacketQueue.empty()) {
|
||||||
map<unsigned short,EQProtocolPacket *>::iterator itr;
|
std::map<unsigned short,EQProtocolPacket *>::iterator itr;
|
||||||
for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) {
|
for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) {
|
||||||
p=itr->second;
|
p=itr->second;
|
||||||
delete p;
|
delete p;
|
||||||
@ -1149,7 +1148,7 @@ long EQStream::GetLastAckSent()
|
|||||||
|
|
||||||
void EQStream::AckPackets(uint16 seq)
|
void EQStream::AckPackets(uint16 seq)
|
||||||
{
|
{
|
||||||
deque<EQProtocolPacket *>::iterator itr, tmp;
|
std::deque<EQProtocolPacket *>::iterator itr, tmp;
|
||||||
|
|
||||||
MOutboundQueue.lock();
|
MOutboundQueue.lock();
|
||||||
//do a bit of sanity checking.
|
//do a bit of sanity checking.
|
||||||
@ -1234,7 +1233,7 @@ void EQStream::ProcessQueue()
|
|||||||
|
|
||||||
EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
|
EQProtocolPacket *EQStream::RemoveQueue(uint16 seq)
|
||||||
{
|
{
|
||||||
map<unsigned short,EQProtocolPacket *>::iterator itr;
|
std::map<unsigned short,EQProtocolPacket *>::iterator itr;
|
||||||
EQProtocolPacket *qp=nullptr;
|
EQProtocolPacket *qp=nullptr;
|
||||||
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
|
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
|
||||||
qp=itr->second;
|
qp=itr->second;
|
||||||
|
|||||||
@ -18,8 +18,6 @@
|
|||||||
#include "../common/Condition.h"
|
#include "../common/Condition.h"
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define FLAG_COMPRESSED 0x01
|
#define FLAG_COMPRESSED 0x01
|
||||||
#define FLAG_ENCODED 0x04
|
#define FLAG_ENCODED 0x04
|
||||||
|
|
||||||
@ -113,8 +111,8 @@ class EQStream : public EQStreamInterface {
|
|||||||
Mutex MAcks;
|
Mutex MAcks;
|
||||||
|
|
||||||
// Packets waiting to be sent (all protected by MOutboundQueue)
|
// Packets waiting to be sent (all protected by MOutboundQueue)
|
||||||
queue<EQProtocolPacket *> NonSequencedQueue;
|
std::queue<EQProtocolPacket *> NonSequencedQueue;
|
||||||
deque<EQProtocolPacket *> SequencedQueue;
|
std::deque<EQProtocolPacket *> SequencedQueue;
|
||||||
uint16 NextOutSeq;
|
uint16 NextOutSeq;
|
||||||
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
|
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
|
||||||
long NextSequencedSend; //index into SequencedQueue
|
long NextSequencedSend; //index into SequencedQueue
|
||||||
@ -124,8 +122,8 @@ class EQStream : public EQStreamInterface {
|
|||||||
unsigned char _tempBuffer[2048];
|
unsigned char _tempBuffer[2048];
|
||||||
|
|
||||||
// Packets waiting to be processed
|
// Packets waiting to be processed
|
||||||
vector<EQRawApplicationPacket *> InboundQueue;
|
std::vector<EQRawApplicationPacket *> InboundQueue;
|
||||||
map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
|
std::map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
|
||||||
Mutex MInboundQueue;
|
Mutex MInboundQueue;
|
||||||
|
|
||||||
static uint16 MaxWindowSize;
|
static uint16 MaxWindowSize;
|
||||||
|
|||||||
@ -19,8 +19,6 @@
|
|||||||
#include "EQStream.h"
|
#include "EQStream.h"
|
||||||
#include "logsys.h"
|
#include "logsys.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
|
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
|
||||||
{
|
{
|
||||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||||
@ -146,7 +144,7 @@ void EQStreamFactory::Push(EQStream *s)
|
|||||||
void EQStreamFactory::ReaderLoop()
|
void EQStreamFactory::ReaderLoop()
|
||||||
{
|
{
|
||||||
fd_set readset;
|
fd_set readset;
|
||||||
map<string,EQStream *>::iterator stream_itr;
|
std::map<std::string,EQStream *>::iterator stream_itr;
|
||||||
int num;
|
int num;
|
||||||
int length;
|
int length;
|
||||||
unsigned char buffer[2048];
|
unsigned char buffer[2048];
|
||||||
@ -227,7 +225,7 @@ void EQStreamFactory::CheckTimeout()
|
|||||||
MStreams.lock();
|
MStreams.lock();
|
||||||
|
|
||||||
unsigned long now=Timer::GetCurrentTime();
|
unsigned long now=Timer::GetCurrentTime();
|
||||||
map<string,EQStream *>::iterator stream_itr;
|
std::map<std::string,EQStream *>::iterator stream_itr;
|
||||||
|
|
||||||
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
|
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
|
||||||
EQStream *s = stream_itr->second;
|
EQStream *s = stream_itr->second;
|
||||||
@ -243,7 +241,7 @@ void EQStreamFactory::CheckTimeout()
|
|||||||
} else {
|
} else {
|
||||||
//everybody is done, we can delete it now
|
//everybody is done, we can delete it now
|
||||||
//cout << "Removing connection" << endl;
|
//cout << "Removing connection" << endl;
|
||||||
map<string,EQStream *>::iterator temp=stream_itr;
|
std::map<std::string,EQStream *>::iterator temp=stream_itr;
|
||||||
stream_itr++;
|
stream_itr++;
|
||||||
//let whoever has the stream outside delete it
|
//let whoever has the stream outside delete it
|
||||||
delete temp->second;
|
delete temp->second;
|
||||||
@ -259,10 +257,10 @@ void EQStreamFactory::CheckTimeout()
|
|||||||
|
|
||||||
void EQStreamFactory::WriterLoop()
|
void EQStreamFactory::WriterLoop()
|
||||||
{
|
{
|
||||||
map<string,EQStream *>::iterator stream_itr;
|
std::map<std::string,EQStream *>::iterator stream_itr;
|
||||||
bool havework=true;
|
bool havework=true;
|
||||||
vector<EQStream *> wants_write;
|
std::vector<EQStream *> wants_write;
|
||||||
vector<EQStream *>::iterator cur,end;
|
std::vector<EQStream *>::iterator cur,end;
|
||||||
bool decay=false;
|
bool decay=false;
|
||||||
uint32 stream_count;
|
uint32 stream_count;
|
||||||
|
|
||||||
|
|||||||
@ -24,10 +24,10 @@ class EQStreamFactory : private Timeoutable {
|
|||||||
|
|
||||||
EQStreamType StreamType;
|
EQStreamType StreamType;
|
||||||
|
|
||||||
queue<EQStream *> NewStreams;
|
std::queue<EQStream *> NewStreams;
|
||||||
Mutex MNewStreams;
|
Mutex MNewStreams;
|
||||||
|
|
||||||
map<string,EQStream *> Streams;
|
std::map<std::string,EQStream *> Streams;
|
||||||
Mutex MStreams;
|
Mutex MStreams;
|
||||||
|
|
||||||
virtual void CheckTimeout();
|
virtual void CheckTimeout();
|
||||||
|
|||||||
@ -3,14 +3,12 @@
|
|||||||
#include "EQStreamProxy.h"
|
#include "EQStreamProxy.h"
|
||||||
#include "logsys.h"
|
#include "logsys.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
EQStreamIdentifier::~EQStreamIdentifier() {
|
EQStreamIdentifier::~EQStreamIdentifier() {
|
||||||
while(!m_identified.empty()) {
|
while(!m_identified.empty()) {
|
||||||
m_identified.front()->ReleaseFromUse();
|
m_identified.front()->ReleaseFromUse();
|
||||||
m_identified.pop();
|
m_identified.pop();
|
||||||
}
|
}
|
||||||
vector<Record *>::iterator cur, end;
|
std::vector<Record *>::iterator cur, end;
|
||||||
cur = m_streams.begin();
|
cur = m_streams.begin();
|
||||||
end = m_streams.end();
|
end = m_streams.end();
|
||||||
for(; cur != end; cur++) {
|
for(; cur != end; cur++) {
|
||||||
@ -18,7 +16,7 @@ EQStreamIdentifier::~EQStreamIdentifier() {
|
|||||||
r->stream->ReleaseFromUse();
|
r->stream->ReleaseFromUse();
|
||||||
delete r;
|
delete r;
|
||||||
}
|
}
|
||||||
vector<Patch *>::iterator curp, endp;
|
std::vector<Patch *>::iterator curp, endp;
|
||||||
curp = m_patches.begin();
|
curp = m_patches.begin();
|
||||||
endp = m_patches.end();
|
endp = m_patches.end();
|
||||||
for(; curp != endp; curp++) {
|
for(; curp != endp; curp++) {
|
||||||
@ -36,8 +34,8 @@ void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EQStreamIdentifier::Process() {
|
void EQStreamIdentifier::Process() {
|
||||||
vector<Record *>::iterator cur;
|
std::vector<Record *>::iterator cur;
|
||||||
vector<Patch *>::iterator curp, endp;
|
std::vector<Patch *>::iterator curp, endp;
|
||||||
|
|
||||||
//foreach pending stream.
|
//foreach pending stream.
|
||||||
cur = m_streams.begin();
|
cur = m_streams.begin();
|
||||||
|
|||||||
@ -24,7 +24,6 @@ This did not turn out nearly as nice as I hoped.
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class EQStreamInfo {
|
class EQStreamInfo {
|
||||||
public:
|
public:
|
||||||
@ -103,7 +102,7 @@ inline bool operator==(const EQStreamInfo &l, const EQStreamInfo &r) {
|
|||||||
template <class T>
|
template <class T>
|
||||||
class EQStreamLocator {
|
class EQStreamLocator {
|
||||||
protected:
|
protected:
|
||||||
typedef typename map<const EQStreamInfo, T *>::iterator iterator;
|
typedef typename std::map<const EQStreamInfo, T *>::iterator iterator;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Clear() {
|
void Clear() {
|
||||||
@ -167,7 +166,7 @@ public:
|
|||||||
// inline iterator end() const { return(streams.end()); }
|
// inline iterator end() const { return(streams.end()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
map<const EQStreamInfo, T *> streams;
|
std::map<const EQStreamInfo, T *> streams;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -26,11 +26,9 @@ tremendously.
|
|||||||
#include "../common/debug.h"
|
#include "../common/debug.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "EmuTCPConnection.h"
|
#include "EmuTCPConnection.h"
|
||||||
#include "EmuTCPServer.h"
|
#include "EmuTCPServer.h"
|
||||||
@ -93,7 +91,7 @@ EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer,
|
|||||||
TCPMode = iMode;
|
TCPMode = iMode;
|
||||||
PacketMode = packetModeZone;
|
PacketMode = packetModeZone;
|
||||||
#if TCPN_DEBUG_Memory >= 7
|
#if TCPN_DEBUG_Memory >= 7
|
||||||
cout << "Constructor #1 on outgoing TCP# " << GetID() << endl;
|
std::cout << "Constructor #1 on outgoing TCP# " << GetID() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +111,7 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConne
|
|||||||
TCPMode = modePacket;
|
TCPMode = modePacket;
|
||||||
PacketMode = packetModeZone;
|
PacketMode = packetModeZone;
|
||||||
#if TCPN_DEBUG_Memory >= 7
|
#if TCPN_DEBUG_Memory >= 7
|
||||||
cout << "Constructor #3 on outgoing TCP# " << GetID() << endl;
|
std::cout << "Constructor #3 on outgoing TCP# " << GetID() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +171,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
CoutTimestamp(true);
|
CoutTimestamp(true);
|
||||||
cout << ": Logging outgoing TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl;
|
std::cout << ": Logging outgoing TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||||
#if TCPN_LOG_PACKETS == 2
|
#if TCPN_LOG_PACKETS == 2
|
||||||
if (pack->size >= 32)
|
if (pack->size >= 32)
|
||||||
DumpPacket(pack->pBuffer, 32);
|
DumpPacket(pack->pBuffer, 32);
|
||||||
@ -200,7 +198,7 @@ bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
CoutTimestamp(true);
|
CoutTimestamp(true);
|
||||||
cout << ": Logging outgoing TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl;
|
std::cout << ": Logging outgoing TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||||
#if TCPN_LOG_PACKETS == 2
|
#if TCPN_LOG_PACKETS == 2
|
||||||
if (pack->size >= 32)
|
if (pack->size >= 32)
|
||||||
DumpPacket(pack->pBuffer, 32);
|
DumpPacket(pack->pBuffer, 32);
|
||||||
@ -239,10 +237,10 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
CoutTimestamp(true);
|
CoutTimestamp(true);
|
||||||
cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << tnps->opcode << dec << ", size: " << setw(5) << setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
|
std::cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << tnps->opcode << dec << ", size: " << setw(5) << setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
|
||||||
if (pOldFormat)
|
if (pOldFormat)
|
||||||
cout << " (OldFormat)";
|
std::cout << " (OldFormat)";
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
#if TCPN_LOG_PACKETS == 2
|
#if TCPN_LOG_PACKETS == 2
|
||||||
if (tnps->size >= 32)
|
if (tnps->size >= 32)
|
||||||
DumpPacket((uchar*) tnps, 32);
|
DumpPacket((uchar*) tnps, 32);
|
||||||
@ -284,7 +282,7 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
|
|||||||
#if defined(GOTFRAGS) && 0
|
#if defined(GOTFRAGS) && 0
|
||||||
if (strcmp(line, "**CRASHME**") == 0) {
|
if (strcmp(line, "**CRASHME**") == 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
cout << (5 / i) << endl;
|
std::cout << (5 / i) << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(line[0] == '*') {
|
if(line[0] == '*') {
|
||||||
@ -456,10 +454,10 @@ void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
|
|||||||
#if TCPC_DEBUG >= 1
|
#if TCPC_DEBUG >= 1
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
cout "NetError: '";
|
std::cout "NetError: '";
|
||||||
if (reason)
|
if (reason)
|
||||||
cout << reason;
|
std::cout << reason;
|
||||||
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl;
|
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
ServerPacket* pack = new ServerPacket(0);
|
ServerPacket* pack = new ServerPacket(0);
|
||||||
pack->size = 1;
|
pack->size = 1;
|
||||||
@ -522,7 +520,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
|
|||||||
size = tnps->size;
|
size = tnps->size;
|
||||||
if (size >= MaxTCPReceiveBuffferSize) {
|
if (size >= MaxTCPReceiveBuffferSize) {
|
||||||
#if TCPN_DEBUG_Memory >= 1
|
#if TCPN_DEBUG_Memory >= 1
|
||||||
cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << endl;
|
std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
|
||||||
DumpPacket(&recvbuf[base], 16);
|
DumpPacket(&recvbuf[base], 16);
|
||||||
#endif
|
#endif
|
||||||
if (errbuf)
|
if (errbuf)
|
||||||
@ -562,13 +560,13 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
|
|||||||
if (pack->opcode == 0) {
|
if (pack->opcode == 0) {
|
||||||
if (pack->size) {
|
if (pack->size) {
|
||||||
#if TCPN_DEBUG >= 2
|
#if TCPN_DEBUG >= 2
|
||||||
cout << "Received TCP Network layer packet" << endl;
|
std::cout << "Received TCP Network layer packet" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
ProcessNetworkLayerPacket(pack);
|
ProcessNetworkLayerPacket(pack);
|
||||||
}
|
}
|
||||||
#if TCPN_DEBUG >= 5
|
#if TCPN_DEBUG >= 5
|
||||||
else {
|
else {
|
||||||
cout << "Received TCP keepalive packet. (opcode=0)" << endl;
|
std::cout << "Received TCP keepalive packet. (opcode=0)" << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// keepalive, no need to process
|
// keepalive, no need to process
|
||||||
@ -580,7 +578,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
CoutTimestamp(true);
|
CoutTimestamp(true);
|
||||||
cout << ": Logging incoming TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl;
|
std::cout << ": Logging incoming TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||||
#if TCPN_LOG_PACKETS == 2
|
#if TCPN_LOG_PACKETS == 2
|
||||||
if (pack->size >= 32)
|
if (pack->size >= 32)
|
||||||
DumpPacket(pack->pBuffer, 32);
|
DumpPacket(pack->pBuffer, 32);
|
||||||
@ -596,7 +594,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
|
|||||||
EmuTCPConnection* con = Server->FindConnection(pack->destination);
|
EmuTCPConnection* con = Server->FindConnection(pack->destination);
|
||||||
if (!con) {
|
if (!con) {
|
||||||
#if TCPN_DEBUG >= 1
|
#if TCPN_DEBUG >= 1
|
||||||
cout << "Error relaying packet: con = 0" << endl;
|
std::cout << "Error relaying packet: con = 0" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
safe_delete(pack);
|
safe_delete(pack);
|
||||||
}
|
}
|
||||||
@ -635,7 +633,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
|
|||||||
memcpy(&size, &buffer[2], 2);
|
memcpy(&size, &buffer[2], 2);
|
||||||
if (size >= MaxTCPReceiveBuffferSize) {
|
if (size >= MaxTCPReceiveBuffferSize) {
|
||||||
#if TCPN_DEBUG_Memory >= 1
|
#if TCPN_DEBUG_Memory >= 1
|
||||||
cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << endl;
|
std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (errbuf)
|
if (errbuf)
|
||||||
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
|
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
|
||||||
@ -665,7 +663,7 @@ bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
CoutTimestamp(true);
|
CoutTimestamp(true);
|
||||||
cout << ": Logging incoming TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << endl;
|
std::cout << ": Logging incoming TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||||
#if TCPN_LOG_PACKETS == 2
|
#if TCPN_LOG_PACKETS == 2
|
||||||
if (pack->size >= 32)
|
if (pack->size >= 32)
|
||||||
DumpPacket(pack->pBuffer, 32);
|
DumpPacket(pack->pBuffer, 32);
|
||||||
@ -726,7 +724,7 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
|
|||||||
#if TCPC_DEBUG >= 3
|
#if TCPC_DEBUG >= 3
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
cout << "Switching to RelayServer mode: " << inet_ntoa(in) << ":" << GetPort() << endl;
|
std::cout << "Switching to RelayServer mode: " << inet_ntoa(in) << ":" << GetPort() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
RelayServer = true;
|
RelayServer = true;
|
||||||
break;
|
break;
|
||||||
@ -774,10 +772,10 @@ void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
|
|||||||
#if TCPC_DEBUG >= 1
|
#if TCPC_DEBUG >= 1
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
cout "Received NetError: '";
|
std::cout "Received NetError: '";
|
||||||
if (pack->size > 1)
|
if (pack->size > 1)
|
||||||
cout << (char*) data;
|
std::cout << (char*) data;
|
||||||
cout << "': " << inet_ntoa(in) << ":" << GetPort() << endl;
|
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -796,7 +794,7 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
|
|||||||
SendPacket(pack);
|
SendPacket(pack);
|
||||||
safe_delete(pack);
|
safe_delete(pack);
|
||||||
#if TCPN_DEBUG >= 5
|
#if TCPN_DEBUG >= 5
|
||||||
cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << endl;
|
std::cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,6 @@
|
|||||||
#include "races.h"
|
#include "races.h"
|
||||||
#include "shareddb.h"
|
#include "shareddb.h"
|
||||||
#include "classes.h"
|
#include "classes.h"
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int32 NextItemInstSerialNumber = 1;
|
int32 NextItemInstSerialNumber = 1;
|
||||||
|
|
||||||
@ -102,7 +101,7 @@ ItemInstQueue::~ItemInstQueue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Inventory::~Inventory() {
|
Inventory::~Inventory() {
|
||||||
map<int16, ItemInst*>::iterator cur,end;
|
std::map<int16, ItemInst*>::iterator cur,end;
|
||||||
|
|
||||||
|
|
||||||
cur = m_worn.begin();
|
cur = m_worn.begin();
|
||||||
@ -580,7 +579,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
|
|||||||
|
|
||||||
std::string ItemInst::GetCustomDataString() const {
|
std::string ItemInst::GetCustomDataString() const {
|
||||||
std::string ret_val;
|
std::string ret_val;
|
||||||
map<std::string, std::string>::const_iterator iter = m_custom_data.begin();
|
std::map<std::string, std::string>::const_iterator iter = m_custom_data.begin();
|
||||||
while(iter != m_custom_data.end()) {
|
while(iter != m_custom_data.end()) {
|
||||||
if(ret_val.length() > 0) {
|
if(ret_val.length() > 0) {
|
||||||
ret_val += "^";
|
ret_val += "^";
|
||||||
@ -624,14 +623,14 @@ void ItemInst::SetCustomData(std::string identifier, bool value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ItemInst::DeleteCustomData(std::string identifier) {
|
void ItemInst::DeleteCustomData(std::string identifier) {
|
||||||
map<std::string, std::string>::iterator iter = m_custom_data.find(identifier);
|
std::map<std::string, std::string>::iterator iter = m_custom_data.find(identifier);
|
||||||
if(iter != m_custom_data.end()) {
|
if(iter != m_custom_data.end()) {
|
||||||
m_custom_data.erase(iter);
|
m_custom_data.erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ItemInst::GetCustomData(std::string identifier) {
|
std::string ItemInst::GetCustomData(std::string identifier) {
|
||||||
map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier);
|
std::map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier);
|
||||||
if(iter != m_custom_data.end()) {
|
if(iter != m_custom_data.end()) {
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
@ -1160,7 +1159,7 @@ void Inventory::dumpInventory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Internal Method: Retrieves item within an inventory bucket
|
// Internal Method: Retrieves item within an inventory bucket
|
||||||
ItemInst* Inventory::_GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const
|
ItemInst* Inventory::_GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const
|
||||||
{
|
{
|
||||||
iter_inst it = bucket.find(slot_id);
|
iter_inst it = bucket.find(slot_id);
|
||||||
if (it != bucket.end()) {
|
if (it != bucket.end()) {
|
||||||
@ -1228,7 +1227,7 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Internal Method: Checks an inventory bucket for a particular item
|
// Internal Method: Checks an inventory bucket for a particular item
|
||||||
int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
|
int16 Inventory::_HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity)
|
||||||
{
|
{
|
||||||
iter_inst it;
|
iter_inst it;
|
||||||
iter_contents itb;
|
iter_contents itb;
|
||||||
@ -1318,7 +1317,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Internal Method: Checks an inventory bucket for a particular item
|
// Internal Method: Checks an inventory bucket for a particular item
|
||||||
int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity)
|
int16 Inventory::_HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity)
|
||||||
{
|
{
|
||||||
iter_inst it;
|
iter_inst it;
|
||||||
iter_contents itb;
|
iter_contents itb;
|
||||||
@ -1386,7 +1385,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
|
|||||||
return SLOT_INVALID;
|
return SLOT_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup)
|
int16 Inventory::_HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup)
|
||||||
{
|
{
|
||||||
iter_inst it;
|
iter_inst it;
|
||||||
iter_contents itb;
|
iter_contents itb;
|
||||||
|
|||||||
@ -34,15 +34,14 @@ class EvolveInfo; // Stores information about an evolving item family
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
using namespace std;
|
|
||||||
#include "../common/eq_packet_structs.h"
|
#include "../common/eq_packet_structs.h"
|
||||||
#include "../common/eq_constants.h"
|
#include "../common/eq_constants.h"
|
||||||
#include "../common/item_struct.h"
|
#include "../common/item_struct.h"
|
||||||
|
|
||||||
// Helper typedefs
|
// Helper typedefs
|
||||||
typedef list<ItemInst*>::const_iterator iter_queue;
|
typedef std::list<ItemInst*>::const_iterator iter_queue;
|
||||||
typedef map<int16, ItemInst*>::const_iterator iter_inst;
|
typedef std::map<int16, ItemInst*>::const_iterator iter_inst;
|
||||||
typedef map<uint8, ItemInst*>::const_iterator iter_contents;
|
typedef std::map<uint8, ItemInst*>::const_iterator iter_contents;
|
||||||
|
|
||||||
namespace ItemField {
|
namespace ItemField {
|
||||||
enum {
|
enum {
|
||||||
@ -120,7 +119,7 @@ protected:
|
|||||||
// Protected Members
|
// Protected Members
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
|
||||||
list<ItemInst*> m_list;
|
std::list<ItemInst*> m_list;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -209,26 +208,26 @@ protected:
|
|||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
// Retrieves item within an inventory bucket
|
// Retrieves item within an inventory bucket
|
||||||
ItemInst* _GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const;
|
ItemInst* _GetItem(const std::map<int16, ItemInst*>& bucket, int16 slot_id) const;
|
||||||
|
|
||||||
// Private "put" item into bucket, without regard for what is currently in bucket
|
// Private "put" item into bucket, without regard for what is currently in bucket
|
||||||
int16 _PutItem(int16 slot_id, ItemInst* inst);
|
int16 _PutItem(int16 slot_id, ItemInst* inst);
|
||||||
|
|
||||||
// Checks an inventory bucket for a particular item
|
// Checks an inventory bucket for a particular item
|
||||||
int16 _HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity);
|
int16 _HasItem(std::map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity);
|
||||||
int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity);
|
int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity);
|
||||||
int16 _HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity);
|
int16 _HasItemByUse(std::map<int16, ItemInst*>& bucket, uint8 use, uint8 quantity);
|
||||||
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
|
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
|
||||||
int16 _HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup);
|
int16 _HasItemByLoreGroup(std::map<int16, ItemInst*>& bucket, uint32 loregroup);
|
||||||
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
|
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
|
||||||
|
|
||||||
|
|
||||||
// Player inventory
|
// Player inventory
|
||||||
map<int16, ItemInst*> m_worn; // Items worn by character
|
std::map<int16, ItemInst*> m_worn; // Items worn by character
|
||||||
map<int16, ItemInst*> m_inv; // Items in character personal inventory
|
std::map<int16, ItemInst*> m_inv; // Items in character personal inventory
|
||||||
map<int16, ItemInst*> m_bank; // Items in character bank
|
std::map<int16, ItemInst*> m_bank; // Items in character bank
|
||||||
map<int16, ItemInst*> m_shbank; // Items in character shared bank
|
std::map<int16, ItemInst*> m_shbank; // Items in character shared bank
|
||||||
map<int16, ItemInst*> m_trade; // Items in a trade session
|
std::map<int16, ItemInst*> m_trade; // Items in a trade session
|
||||||
ItemInstQueue m_cursor; // Items on cursor: FIFO
|
ItemInstQueue m_cursor; // Items on cursor: FIFO
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -300,7 +299,7 @@ public:
|
|||||||
uint8 FirstOpenSlot() const;
|
uint8 FirstOpenSlot() const;
|
||||||
uint8 GetTotalItemCount() const;
|
uint8 GetTotalItemCount() const;
|
||||||
bool IsNoneEmptyContainer();
|
bool IsNoneEmptyContainer();
|
||||||
map<uint8, ItemInst*>* GetContents() { return &m_contents; }
|
std::map<uint8, ItemInst*>* GetContents() { return &m_contents; }
|
||||||
|
|
||||||
//
|
//
|
||||||
// Augments
|
// Augments
|
||||||
@ -371,7 +370,7 @@ public:
|
|||||||
virtual bool IsScaling() const { return false; }
|
virtual bool IsScaling() const { return false; }
|
||||||
virtual bool IsEvolving() const { return false; }
|
virtual bool IsEvolving() const { return false; }
|
||||||
|
|
||||||
string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id=slot_id; s.inst=(const void *)this; string ser; ser.assign((char *)&s,sizeof(InternalSerializedItem_Struct)); return ser; }
|
std::string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id=slot_id; s.inst=(const void *)this; std::string ser; ser.assign((char *)&s,sizeof(InternalSerializedItem_Struct)); return ser; }
|
||||||
inline int32 GetSerialNumber() const { return m_SerialNumber; }
|
inline int32 GetSerialNumber() const { return m_SerialNumber; }
|
||||||
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
|
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
|
||||||
|
|
||||||
@ -399,8 +398,8 @@ protected:
|
|||||||
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
|
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
|
||||||
//
|
//
|
||||||
// Items inside of this item (augs or contents);
|
// Items inside of this item (augs or contents);
|
||||||
map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
|
std::map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
|
||||||
map<std::string, std::string> m_custom_data;
|
std::map<std::string, std::string> m_custom_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EvoItemInst: public ItemInst {
|
class EvoItemInst: public ItemInst {
|
||||||
|
|||||||
@ -32,15 +32,10 @@
|
|||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
#include "../common/seperator.h"
|
#include "../common/seperator.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#if (_MSC_VER < 1500)
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
#endif
|
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#else
|
#else
|
||||||
@ -59,10 +54,6 @@ using namespace std;
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef va_copy
|
|
||||||
#define va_copy(d,s) ((d) = (s))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool WELLRNG_init = false;
|
static bool WELLRNG_init = false;
|
||||||
static int state_i = 0;
|
static int state_i = 0;
|
||||||
static unsigned int STATE[R];
|
static unsigned int STATE[R];
|
||||||
@ -86,207 +77,12 @@ void CoutTimestamp(bool ms) {
|
|||||||
struct timeval read_time;
|
struct timeval read_time;
|
||||||
gettimeofday(&read_time,0);
|
gettimeofday(&read_time,0);
|
||||||
|
|
||||||
cout << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec;
|
std::cout << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec;
|
||||||
if (ms)
|
if (ms)
|
||||||
cout << "." << setw(3) << setfill('0') << (read_time.tv_usec / 1000);
|
std::cout << "." << std::setw(3) << std::setfill('0') << (read_time.tv_usec / 1000);
|
||||||
cout << " GMT";
|
std::cout << " GMT";
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal strncpy doesnt put a null term on copied strings, this one does
|
|
||||||
// ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecrt/htm/_wcecrt_strncpy_wcsncpy.asp
|
|
||||||
char* strn0cpy(char* dest, const char* source, uint32 size) {
|
|
||||||
if (!dest)
|
|
||||||
return 0;
|
|
||||||
if (size == 0 || source == 0) {
|
|
||||||
dest[0] = 0;
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
strncpy(dest, source, size);
|
|
||||||
dest[size - 1] = 0;
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
// String N w/null Copy Truncated?
|
|
||||||
// return value =true if entire string(source) fit, false if it was truncated
|
|
||||||
bool strn0cpyt(char* dest, const char* source, uint32 size) {
|
|
||||||
if (!dest)
|
|
||||||
return 0;
|
|
||||||
if (size == 0 || source == 0) {
|
|
||||||
dest[0] = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
strncpy(dest, source, size);
|
|
||||||
dest[size - 1] = 0;
|
|
||||||
return (bool) (source[strlen(dest)] == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *MakeUpperString(const char *source) {
|
|
||||||
static char str[128];
|
|
||||||
if (!source)
|
|
||||||
return nullptr;
|
|
||||||
MakeUpperString(source, str);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MakeUpperString(const char *source, char *target) {
|
|
||||||
if (!source || !target) {
|
|
||||||
*target=0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (*source)
|
|
||||||
{
|
|
||||||
*target = toupper(*source);
|
|
||||||
target++;source++;
|
|
||||||
}
|
|
||||||
*target = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *MakeLowerString(const char *source) {
|
|
||||||
static char str[128];
|
|
||||||
if (!source)
|
|
||||||
return nullptr;
|
|
||||||
MakeLowerString(source, str);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MakeLowerString(const char *source, char *target) {
|
|
||||||
if (!source || !target) {
|
|
||||||
*target=0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (*source)
|
|
||||||
{
|
|
||||||
*target = tolower(*source);
|
|
||||||
target++;source++;
|
|
||||||
}
|
|
||||||
*target = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MakeAnyLenString(char** ret, const char* format, ...) {
|
|
||||||
int buf_len = 128;
|
|
||||||
int chars = -1;
|
|
||||||
va_list argptr, tmpargptr;
|
|
||||||
va_start(argptr, format);
|
|
||||||
while (chars == -1 || chars >= buf_len) {
|
|
||||||
safe_delete_array(*ret);
|
|
||||||
if (chars == -1)
|
|
||||||
buf_len *= 2;
|
|
||||||
else
|
|
||||||
buf_len = chars + 1;
|
|
||||||
*ret = new char[buf_len];
|
|
||||||
va_copy(tmpargptr, argptr);
|
|
||||||
chars = vsnprintf(*ret, buf_len, format, tmpargptr);
|
|
||||||
}
|
|
||||||
va_end(argptr);
|
|
||||||
return chars;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...) {
|
|
||||||
if (*bufsize == 0)
|
|
||||||
*bufsize = 256;
|
|
||||||
if (*ret == 0)
|
|
||||||
*strlen = 0;
|
|
||||||
int chars = -1;
|
|
||||||
char* oldret = 0;
|
|
||||||
va_list argptr, tmpargptr;
|
|
||||||
va_start(argptr, format);
|
|
||||||
while (chars == -1 || chars >= (int32)(*bufsize-*strlen)) {
|
|
||||||
if (chars == -1)
|
|
||||||
*bufsize += 256;
|
|
||||||
else
|
|
||||||
*bufsize += chars + 25;
|
|
||||||
oldret = *ret;
|
|
||||||
*ret = new char[*bufsize];
|
|
||||||
if (oldret) {
|
|
||||||
if (*strlen)
|
|
||||||
memcpy(*ret, oldret, *strlen);
|
|
||||||
safe_delete_array(oldret);
|
|
||||||
}
|
|
||||||
va_copy(tmpargptr, argptr);
|
|
||||||
chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
|
|
||||||
}
|
|
||||||
va_end(argptr);
|
|
||||||
*strlen += chars;
|
|
||||||
return *strlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 hextoi(char* num) {
|
|
||||||
int len = strlen(num);
|
|
||||||
if (len < 3)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
uint32 ret = 0;
|
|
||||||
int mul = 1;
|
|
||||||
for (int i=len-1; i>=2; i--) {
|
|
||||||
if (num[i] >= 'A' && num[i] <= 'F')
|
|
||||||
ret += ((num[i] - 'A') + 10) * mul;
|
|
||||||
else if (num[i] >= 'a' && num[i] <= 'f')
|
|
||||||
ret += ((num[i] - 'a') + 10) * mul;
|
|
||||||
else if (num[i] >= '0' && num[i] <= '9')
|
|
||||||
ret += (num[i] - '0') * mul;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
mul *= 16;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64 hextoi64(char* num) {
|
|
||||||
int len = strlen(num);
|
|
||||||
if (len < 3)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
uint64 ret = 0;
|
|
||||||
int mul = 1;
|
|
||||||
for (int i=len-1; i>=2; i--) {
|
|
||||||
if (num[i] >= 'A' && num[i] <= 'F')
|
|
||||||
ret += ((num[i] - 'A') + 10) * mul;
|
|
||||||
else if (num[i] >= 'a' && num[i] <= 'f')
|
|
||||||
ret += ((num[i] - 'a') + 10) * mul;
|
|
||||||
else if (num[i] >= '0' && num[i] <= '9')
|
|
||||||
ret += (num[i] - '0') * mul;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
mul *= 16;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool atobool(char* iBool) {
|
|
||||||
if (!strcasecmp(iBool, "true"))
|
|
||||||
return true;
|
|
||||||
if (!strcasecmp(iBool, "false"))
|
|
||||||
return false;
|
|
||||||
if (!strcasecmp(iBool, "yes"))
|
|
||||||
return true;
|
|
||||||
if (!strcasecmp(iBool, "no"))
|
|
||||||
return false;
|
|
||||||
if (!strcasecmp(iBool, "on"))
|
|
||||||
return true;
|
|
||||||
if (!strcasecmp(iBool, "off"))
|
|
||||||
return false;
|
|
||||||
if (!strcasecmp(iBool, "enable"))
|
|
||||||
return true;
|
|
||||||
if (!strcasecmp(iBool, "disable"))
|
|
||||||
return false;
|
|
||||||
if (!strcasecmp(iBool, "enabled"))
|
|
||||||
return true;
|
|
||||||
if (!strcasecmp(iBool, "disabled"))
|
|
||||||
return false;
|
|
||||||
if (!strcasecmp(iBool, "y"))
|
|
||||||
return true;
|
|
||||||
if (!strcasecmp(iBool, "n"))
|
|
||||||
return false;
|
|
||||||
if (atoi(iBool))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 filesize(FILE* fp) {
|
int32 filesize(FILE* fp) {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
@ -549,40 +345,6 @@ static unsigned int case_6 (void){
|
|||||||
|
|
||||||
// end WELL RNG code
|
// end WELL RNG code
|
||||||
|
|
||||||
// solar: removes the crap and turns the underscores into spaces.
|
|
||||||
char *CleanMobName(const char *in, char *out)
|
|
||||||
{
|
|
||||||
unsigned i, j;
|
|
||||||
|
|
||||||
for(i = j = 0; i < strlen(in); i++)
|
|
||||||
{
|
|
||||||
// convert _ to space.. any other conversions like this? I *think* this
|
|
||||||
// is the only non alpha char that's not stripped but converted.
|
|
||||||
if(in[i] == '_')
|
|
||||||
{
|
|
||||||
out[j++] = ' ';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(isalpha(in[i]) || (in[i] == '`')) // numbers, #, or any other crap just gets skipped
|
|
||||||
out[j++] = in[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out[j] = 0; // terimnate the string before returning it
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ConvertArray(int input, char *returnchar)
|
|
||||||
{
|
|
||||||
sprintf(returnchar, "%i" ,input);
|
|
||||||
return returnchar;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ConvertArrayF(float input, char *returnchar)
|
|
||||||
{
|
|
||||||
sprintf(returnchar, "%0.2f", input);
|
|
||||||
return returnchar;
|
|
||||||
}
|
|
||||||
|
|
||||||
float EQ13toFloat(int d)
|
float EQ13toFloat(int d)
|
||||||
{
|
{
|
||||||
@ -627,24 +389,3 @@ float EQHtoFloat(int d)
|
|||||||
{
|
{
|
||||||
return(360.0f - float((d * 360) >> 11));
|
return(360.0f - float((d * 360) >> 11));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveApostrophes(std::string &s)
|
|
||||||
{
|
|
||||||
for(unsigned int i = 0; i < s.length(); ++i)
|
|
||||||
if(s[i] == '\'')
|
|
||||||
s[i] = '_';
|
|
||||||
}
|
|
||||||
|
|
||||||
char *RemoveApostrophes(const char *s)
|
|
||||||
{
|
|
||||||
char *NewString = new char[strlen(s) + 1];
|
|
||||||
|
|
||||||
strcpy(NewString, s);
|
|
||||||
|
|
||||||
for(unsigned int i = 0 ; i < strlen(NewString); ++i)
|
|
||||||
if(NewString[i] == '\'')
|
|
||||||
NewString[i] = '_';
|
|
||||||
|
|
||||||
return NewString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -86,39 +86,14 @@
|
|||||||
|
|
||||||
#define BITMASK 0x41180000
|
#define BITMASK 0x41180000
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// MakeUpperString
|
|
||||||
// i: source - allocated null-terminated string
|
|
||||||
// return: pointer to static buffer with the target string
|
|
||||||
const char *MakeUpperString(const char *source);
|
|
||||||
const char *MakeLowerString(const char *source);
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// MakeUpperString
|
|
||||||
// i : source - allocated null-terminated string
|
|
||||||
// io: target - allocated buffer, at least of size strlen(source)+1
|
|
||||||
void MakeUpperString(const char *source, char *target);
|
|
||||||
void MakeLowerString(const char *source, char *target);
|
|
||||||
|
|
||||||
|
|
||||||
int MakeAnyLenString(char** ret, const char* format, ...);
|
|
||||||
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...);
|
|
||||||
uint32 hextoi(char* num);
|
|
||||||
uint64 hextoi64(char* num);
|
|
||||||
bool atobool(char* iBool);
|
|
||||||
int32 filesize(FILE* fp);
|
int32 filesize(FILE* fp);
|
||||||
uint32 ResolveIP(const char* hostname, char* errbuf = 0);
|
uint32 ResolveIP(const char* hostname, char* errbuf = 0);
|
||||||
bool ParseAddress(const char* iAddress, uint32* oIP, uint16* oPort, char* errbuf = 0);
|
bool ParseAddress(const char* iAddress, uint32* oIP, uint16* oPort, char* errbuf = 0);
|
||||||
void CoutTimestamp(bool ms = true);
|
void CoutTimestamp(bool ms = true);
|
||||||
char* strn0cpy(char* dest, const char* source, uint32 size);
|
|
||||||
// return value =true if entire string(source) fit, false if it was truncated
|
|
||||||
bool strn0cpyt(char* dest, const char* source, uint32 size);
|
|
||||||
int MakeRandomInt(int low, int high);
|
int MakeRandomInt(int low, int high);
|
||||||
double MakeRandomFloat(double low, double high);
|
double MakeRandomFloat(double low, double high);
|
||||||
char *CleanMobName(const char *in, char *out);
|
|
||||||
const char *ConvertArray(int input, char *returnchar);
|
|
||||||
const char *ConvertArrayF(float input, char *returnchar);
|
|
||||||
float EQ13toFloat(int d);
|
float EQ13toFloat(int d);
|
||||||
float NewEQ13toFloat(int d);
|
float NewEQ13toFloat(int d);
|
||||||
float EQ19toFloat(int d);
|
float EQ19toFloat(int d);
|
||||||
@ -127,8 +102,6 @@ int FloatToEQ13(float d);
|
|||||||
int NewFloatToEQ13(float d);
|
int NewFloatToEQ13(float d);
|
||||||
int FloatToEQ19(float d);
|
int FloatToEQ19(float d);
|
||||||
int FloatToEQH(float d);
|
int FloatToEQH(float d);
|
||||||
void RemoveApostrophes(std::string &s);
|
|
||||||
char *RemoveApostrophes(const char *s);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,6 @@
|
|||||||
#include "../common/Mutex.h"
|
#include "../common/Mutex.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define DEBUG_MUTEX_CLASS 0
|
#define DEBUG_MUTEX_CLASS 0
|
||||||
#if DEBUG_MUTEX_CLASS >= 1
|
#if DEBUG_MUTEX_CLASS >= 1
|
||||||
@ -43,7 +42,7 @@ bool IsTryLockSupported() {
|
|||||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
||||||
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) {
|
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) {
|
||||||
#if DEBUG_MUTEX_CLASS >= 1
|
#if DEBUG_MUTEX_CLASS >= 1
|
||||||
cout << "Mutex::trylock() NOT supported" << endl;
|
std::cout << "Mutex::trylock() NOT supported" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -52,13 +51,13 @@ bool IsTryLockSupported() {
|
|||||||
// Tests for Windows NT product family.
|
// Tests for Windows NT product family.
|
||||||
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 4) {
|
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 4) {
|
||||||
#if DEBUG_MUTEX_CLASS >= 1
|
#if DEBUG_MUTEX_CLASS >= 1
|
||||||
cout << "Mutex::trylock() SUPPORTED" << endl;
|
std::cout << "Mutex::trylock() SUPPORTED" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if DEBUG_MUTEX_CLASS >= 1
|
#if DEBUG_MUTEX_CLASS >= 1
|
||||||
cout << "Mutex::trylock() NOT supported" << endl;
|
std::cout << "Mutex::trylock() NOT supported" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -66,27 +65,28 @@ bool IsTryLockSupported() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Mutex::Mutex() {
|
Mutex::Mutex() {
|
||||||
|
|
||||||
#if DEBUG_MUTEX_CLASS >= 7
|
#if DEBUG_MUTEX_CLASS >= 7
|
||||||
cout << "Constructing Mutex" << endl;
|
std::cout << "Constructing Mutex" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
InitializeCriticalSection(&CSMutex);
|
InitializeCriticalSection(&CSMutex);
|
||||||
#else
|
#else
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
pthread_mutexattr_init(&attr);
|
pthread_mutexattr_init(&attr);
|
||||||
#if defined(__CYGWIN__) || defined(__APPLE__) || defined(FREEBSD)
|
#if defined(__CYGWIN__) || defined(__APPLE__) || defined(FREEBSD)
|
||||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
#else
|
#else
|
||||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_init(&CSMutex, &attr);
|
pthread_mutex_init(&CSMutex, &attr);
|
||||||
pthread_mutexattr_destroy(&attr);
|
pthread_mutexattr_destroy(&attr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Mutex::~Mutex() {
|
Mutex::~Mutex() {
|
||||||
#if DEBUG_MUTEX_CLASS >= 7
|
#if DEBUG_MUTEX_CLASS >= 7
|
||||||
cout << "Deconstructing Mutex" << endl;
|
std::cout << "Deconstructing Mutex" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
DeleteCriticalSection(&CSMutex);
|
DeleteCriticalSection(&CSMutex);
|
||||||
@ -98,11 +98,11 @@ Mutex::~Mutex() {
|
|||||||
void Mutex::lock() {
|
void Mutex::lock() {
|
||||||
_CP(Mutex_lock);
|
_CP(Mutex_lock);
|
||||||
#if DEBUG_MUTEX_CLASS >= 9
|
#if DEBUG_MUTEX_CLASS >= 9
|
||||||
cout << "Locking Mutex" << endl;
|
std::cout << "Locking Mutex" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
#if DEBUG_MUTEX_CLASS >= 5
|
#if DEBUG_MUTEX_CLASS >= 5
|
||||||
if (!trylock()) {
|
if (!trylock()) {
|
||||||
cout << "Locking Mutex: Having to wait" << endl;
|
std::cout << "Locking Mutex: Having to wait" << std::endl;
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
EnterCriticalSection(&CSMutex);
|
EnterCriticalSection(&CSMutex);
|
||||||
#else
|
#else
|
||||||
@ -120,7 +120,7 @@ void Mutex::lock() {
|
|||||||
|
|
||||||
bool Mutex::trylock() {
|
bool Mutex::trylock() {
|
||||||
#if DEBUG_MUTEX_CLASS >= 9
|
#if DEBUG_MUTEX_CLASS >= 9
|
||||||
cout << "TryLocking Mutex" << endl;
|
std::cout << "TryLocking Mutex" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#if(_WIN32_WINNT >= 0x0400)
|
#if(_WIN32_WINNT >= 0x0400)
|
||||||
@ -141,7 +141,7 @@ bool Mutex::trylock() {
|
|||||||
|
|
||||||
void Mutex::unlock() {
|
void Mutex::unlock() {
|
||||||
#if DEBUG_MUTEX_CLASS >= 9
|
#if DEBUG_MUTEX_CLASS >= 9
|
||||||
cout << "Unlocking Mutex" << endl;
|
std::cout << "Unlocking Mutex" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
LeaveCriticalSection(&CSMutex);
|
LeaveCriticalSection(&CSMutex);
|
||||||
@ -187,7 +187,7 @@ MRMutex::MRMutex() {
|
|||||||
MRMutex::~MRMutex() {
|
MRMutex::~MRMutex() {
|
||||||
#ifdef _EQDEBUG
|
#ifdef _EQDEBUG
|
||||||
if (wl || rl) {
|
if (wl || rl) {
|
||||||
cout << "MRMutex::~MRMutex: poor cleanup detected: rl=" << rl << ", wl=" << wl << endl;
|
std::cout << "MRMutex::~MRMutex: poor cleanup detected: rl=" << rl << ", wl=" << wl << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
ProcLauncher ProcLauncher::s_launcher;
|
ProcLauncher ProcLauncher::s_launcher;
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
@ -51,10 +49,9 @@ ProcLauncher::ProcLauncher()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ProcLauncher::Process() {
|
void ProcLauncher::Process() {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
map<ProcRef, Spec *>::iterator cur, end, tmp;
|
std::map<ProcRef, Spec *>::iterator cur, end, tmp;
|
||||||
cur = m_running.begin();
|
cur = m_running.begin();
|
||||||
end = m_running.end();
|
end = m_running.end();
|
||||||
while(cur != end) {
|
while(cur != end) {
|
||||||
@ -91,7 +88,7 @@ void ProcLauncher::Process() {
|
|||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
//one died...
|
//one died...
|
||||||
map<ProcRef, Spec *>::iterator ref;
|
std::map<ProcRef, Spec *>::iterator ref;
|
||||||
ref = m_running.find(died);
|
ref = m_running.find(died);
|
||||||
if(ref == m_running.end()) {
|
if(ref == m_running.end()) {
|
||||||
//unable to find this process in our list...
|
//unable to find this process in our list...
|
||||||
@ -168,8 +165,8 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
|
|||||||
// Create the child process.
|
// Create the child process.
|
||||||
|
|
||||||
//glue together all the nice command line arguments
|
//glue together all the nice command line arguments
|
||||||
string args(it->program);
|
std::string args(it->program);
|
||||||
vector<string>::iterator cur, end;
|
std::vector<std::string>::iterator cur, end;
|
||||||
cur = it->args.begin();
|
cur = it->args.begin();
|
||||||
end = it->args.end();
|
end = it->args.end();
|
||||||
for(; cur != end; cur++) {
|
for(; cur != end; cur++) {
|
||||||
|
|||||||
351
common/StringUtil.cpp
Normal file
351
common/StringUtil.cpp
Normal file
@ -0,0 +1,351 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "StringUtil.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstring> // for strncpy
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#define strncasecmp _strnicmp
|
||||||
|
#define strcasecmp _stricmp
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef va_copy
|
||||||
|
#define va_copy(d,s) ((d) = (s))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// original source:
|
||||||
|
// https://github.com/facebook/folly/blob/master/folly/String.cpp
|
||||||
|
//
|
||||||
|
void vStringFormat(std::string& output, const char* format, va_list args)
|
||||||
|
{
|
||||||
|
va_list tmpargs;
|
||||||
|
|
||||||
|
va_copy(tmpargs,args);
|
||||||
|
int characters_used = vsnprintf(nullptr, 0, format, tmpargs);
|
||||||
|
va_end(tmpargs);
|
||||||
|
|
||||||
|
if (characters_used < 0) {
|
||||||
|
// Looks like we have an invalid format string.
|
||||||
|
// error out.
|
||||||
|
std::string errorMessage("Invalid format string; snprintf returned negative with format string: ");
|
||||||
|
errorMessage.append(format);
|
||||||
|
|
||||||
|
throw std::runtime_error(errorMessage);
|
||||||
|
}
|
||||||
|
else if ((unsigned int)characters_used > output.capacity()) {
|
||||||
|
output.resize(characters_used+1);
|
||||||
|
va_copy(tmpargs,args);
|
||||||
|
characters_used = vsnprintf(&output[0], output.capacity(), format, tmpargs);
|
||||||
|
va_end(tmpargs);
|
||||||
|
|
||||||
|
if (characters_used < 0) {
|
||||||
|
// We shouldn't have a format error by this point, but I can't imagine what error we
|
||||||
|
// could have by this point. Still, error out and report it.
|
||||||
|
std::string errorMessage("Invalid format string or unknown vsnprintf error; vsnprintf returned negative with format string: ");
|
||||||
|
errorMessage.append(format);
|
||||||
|
|
||||||
|
throw std::runtime_error(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
output.resize(characters_used + 1);
|
||||||
|
|
||||||
|
va_copy(tmpargs,args);
|
||||||
|
characters_used = vsnprintf(&output[0], output.capacity(), format, tmpargs);
|
||||||
|
va_end(tmpargs);
|
||||||
|
|
||||||
|
if (characters_used < 0) {
|
||||||
|
// We shouldn't have a format error by this point, but I can't imagine what error we
|
||||||
|
// could have by this point. still error out and report it.
|
||||||
|
std::string errorMessage("Invalid format string or unknown vsnprintf error; vsnprintf returned negative with format string: ");
|
||||||
|
errorMessage.append(format);
|
||||||
|
|
||||||
|
throw std::runtime_error(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StringFormat(std::string& output, const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
vStringFormat(output,format,args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// normal strncpy doesnt put a null term on copied strings, this one does
|
||||||
|
// ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecrt/htm/_wcecrt_strncpy_wcsncpy.asp
|
||||||
|
char* strn0cpy(char* dest, const char* source, uint32 size) {
|
||||||
|
if (!dest)
|
||||||
|
return 0;
|
||||||
|
if (size == 0 || source == 0) {
|
||||||
|
dest[0] = 0;
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
strncpy(dest, source, size);
|
||||||
|
dest[size - 1] = 0;
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
// String N w/null Copy Truncated?
|
||||||
|
// return value =true if entire string(source) fit, false if it was truncated
|
||||||
|
bool strn0cpyt(char* dest, const char* source, uint32 size) {
|
||||||
|
if (!dest)
|
||||||
|
return 0;
|
||||||
|
if (size == 0 || source == 0) {
|
||||||
|
dest[0] = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
strncpy(dest, source, size);
|
||||||
|
dest[size - 1] = 0;
|
||||||
|
return (bool) (source[strlen(dest)] == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *MakeUpperString(const char *source) {
|
||||||
|
static char str[128];
|
||||||
|
if (!source)
|
||||||
|
return nullptr;
|
||||||
|
MakeUpperString(source, str);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MakeUpperString(const char *source, char *target) {
|
||||||
|
if (!source || !target) {
|
||||||
|
*target=0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (*source)
|
||||||
|
{
|
||||||
|
*target = toupper(*source);
|
||||||
|
target++;source++;
|
||||||
|
}
|
||||||
|
*target = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *MakeLowerString(const char *source) {
|
||||||
|
static char str[128];
|
||||||
|
if (!source)
|
||||||
|
return nullptr;
|
||||||
|
MakeLowerString(source, str);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MakeLowerString(const char *source, char *target) {
|
||||||
|
if (!source || !target) {
|
||||||
|
*target=0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (*source)
|
||||||
|
{
|
||||||
|
*target = tolower(*source);
|
||||||
|
target++;source++;
|
||||||
|
}
|
||||||
|
*target = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MakeAnyLenString(char** ret, const char* format, ...) {
|
||||||
|
int buf_len = 128;
|
||||||
|
int chars = -1;
|
||||||
|
va_list argptr, tmpargptr;
|
||||||
|
va_start(argptr, format);
|
||||||
|
while (chars == -1 || chars >= buf_len) {
|
||||||
|
safe_delete_array(*ret);
|
||||||
|
if (chars == -1)
|
||||||
|
buf_len *= 2;
|
||||||
|
else
|
||||||
|
buf_len = chars + 1;
|
||||||
|
*ret = new char[buf_len];
|
||||||
|
va_copy(tmpargptr, argptr);
|
||||||
|
chars = vsnprintf(*ret, buf_len, format, tmpargptr);
|
||||||
|
}
|
||||||
|
va_end(argptr);
|
||||||
|
return chars;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...) {
|
||||||
|
if (*bufsize == 0)
|
||||||
|
*bufsize = 256;
|
||||||
|
if (*ret == 0)
|
||||||
|
*strlen = 0;
|
||||||
|
int chars = -1;
|
||||||
|
char* oldret = 0;
|
||||||
|
va_list argptr, tmpargptr;
|
||||||
|
va_start(argptr, format);
|
||||||
|
while (chars == -1 || chars >= (int32)(*bufsize-*strlen)) {
|
||||||
|
if (chars == -1)
|
||||||
|
*bufsize += 256;
|
||||||
|
else
|
||||||
|
*bufsize += chars + 25;
|
||||||
|
oldret = *ret;
|
||||||
|
*ret = new char[*bufsize];
|
||||||
|
if (oldret) {
|
||||||
|
if (*strlen)
|
||||||
|
memcpy(*ret, oldret, *strlen);
|
||||||
|
safe_delete_array(oldret);
|
||||||
|
}
|
||||||
|
va_copy(tmpargptr, argptr);
|
||||||
|
chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
|
||||||
|
}
|
||||||
|
va_end(argptr);
|
||||||
|
*strlen += chars;
|
||||||
|
return *strlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 hextoi(char* num) {
|
||||||
|
int len = strlen(num);
|
||||||
|
if (len < 3)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint32 ret = 0;
|
||||||
|
int mul = 1;
|
||||||
|
for (int i=len-1; i>=2; i--) {
|
||||||
|
if (num[i] >= 'A' && num[i] <= 'F')
|
||||||
|
ret += ((num[i] - 'A') + 10) * mul;
|
||||||
|
else if (num[i] >= 'a' && num[i] <= 'f')
|
||||||
|
ret += ((num[i] - 'a') + 10) * mul;
|
||||||
|
else if (num[i] >= '0' && num[i] <= '9')
|
||||||
|
ret += (num[i] - '0') * mul;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
mul *= 16;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64 hextoi64(char* num) {
|
||||||
|
int len = strlen(num);
|
||||||
|
if (len < 3)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (num[0] != '0' || (num[1] != 'x' && num[1] != 'X'))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint64 ret = 0;
|
||||||
|
int mul = 1;
|
||||||
|
for (int i=len-1; i>=2; i--) {
|
||||||
|
if (num[i] >= 'A' && num[i] <= 'F')
|
||||||
|
ret += ((num[i] - 'A') + 10) * mul;
|
||||||
|
else if (num[i] >= 'a' && num[i] <= 'f')
|
||||||
|
ret += ((num[i] - 'a') + 10) * mul;
|
||||||
|
else if (num[i] >= '0' && num[i] <= '9')
|
||||||
|
ret += (num[i] - '0') * mul;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
mul *= 16;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool atobool(char* iBool) {
|
||||||
|
if (!strcasecmp(iBool, "true"))
|
||||||
|
return true;
|
||||||
|
if (!strcasecmp(iBool, "false"))
|
||||||
|
return false;
|
||||||
|
if (!strcasecmp(iBool, "yes"))
|
||||||
|
return true;
|
||||||
|
if (!strcasecmp(iBool, "no"))
|
||||||
|
return false;
|
||||||
|
if (!strcasecmp(iBool, "on"))
|
||||||
|
return true;
|
||||||
|
if (!strcasecmp(iBool, "off"))
|
||||||
|
return false;
|
||||||
|
if (!strcasecmp(iBool, "enable"))
|
||||||
|
return true;
|
||||||
|
if (!strcasecmp(iBool, "disable"))
|
||||||
|
return false;
|
||||||
|
if (!strcasecmp(iBool, "enabled"))
|
||||||
|
return true;
|
||||||
|
if (!strcasecmp(iBool, "disabled"))
|
||||||
|
return false;
|
||||||
|
if (!strcasecmp(iBool, "y"))
|
||||||
|
return true;
|
||||||
|
if (!strcasecmp(iBool, "n"))
|
||||||
|
return false;
|
||||||
|
if (atoi(iBool))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// solar: removes the crap and turns the underscores into spaces.
|
||||||
|
char *CleanMobName(const char *in, char *out)
|
||||||
|
{
|
||||||
|
unsigned i, j;
|
||||||
|
|
||||||
|
for(i = j = 0; i < strlen(in); i++)
|
||||||
|
{
|
||||||
|
// convert _ to space.. any other conversions like this? I *think* this
|
||||||
|
// is the only non alpha char that's not stripped but converted.
|
||||||
|
if(in[i] == '_')
|
||||||
|
{
|
||||||
|
out[j++] = ' ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(isalpha(in[i]) || (in[i] == '`')) // numbers, #, or any other crap just gets skipped
|
||||||
|
out[j++] = in[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out[j] = 0; // terimnate the string before returning it
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RemoveApostrophes(std::string &s)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 0; i < s.length(); ++i)
|
||||||
|
if(s[i] == '\'')
|
||||||
|
s[i] = '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
char *RemoveApostrophes(const char *s)
|
||||||
|
{
|
||||||
|
char *NewString = new char[strlen(s) + 1];
|
||||||
|
|
||||||
|
strcpy(NewString, s);
|
||||||
|
|
||||||
|
for(unsigned int i = 0 ; i < strlen(NewString); ++i)
|
||||||
|
if(NewString[i] == '\'')
|
||||||
|
NewString[i] = '_';
|
||||||
|
|
||||||
|
return NewString;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *ConvertArray(int input, char *returnchar)
|
||||||
|
{
|
||||||
|
sprintf(returnchar, "%i" ,input);
|
||||||
|
return returnchar;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *ConvertArrayF(float input, char *returnchar)
|
||||||
|
{
|
||||||
|
sprintf(returnchar, "%0.2f", input);
|
||||||
|
return returnchar;
|
||||||
|
}
|
||||||
61
common/StringUtil.h
Normal file
61
common/StringUtil.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _STRINGUTIL_H_
|
||||||
|
#define _STRINGUTIL_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
|
||||||
|
void vStringFormat(std::string& output, const char* format, va_list args);
|
||||||
|
void StringFormat(std::string& output, const char* format, ...);
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// MakeUpperString
|
||||||
|
// i : source - allocated null-terminated string
|
||||||
|
// return: pointer to static buffer with the target string
|
||||||
|
const char *MakeUpperString(const char *source);
|
||||||
|
const char *MakeLowerString(const char *source);
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// MakeUpperString
|
||||||
|
// i : source - allocated null-terminated string
|
||||||
|
// io: target - allocated buffer, at least of size strlen(source)+1
|
||||||
|
void MakeUpperString(const char *source, char *target);
|
||||||
|
void MakeLowerString(const char *source, char *target);
|
||||||
|
|
||||||
|
|
||||||
|
int MakeAnyLenString(char** ret, const char* format, ...);
|
||||||
|
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...);
|
||||||
|
|
||||||
|
uint32 hextoi(char* num);
|
||||||
|
uint64 hextoi64(char* num);
|
||||||
|
bool atobool(char* iBool);
|
||||||
|
|
||||||
|
char* strn0cpy(char* dest, const char* source, uint32 size);
|
||||||
|
// return value =true if entire string(source) fit, false if it was truncated
|
||||||
|
bool strn0cpyt(char* dest, const char* source, uint32 size);
|
||||||
|
|
||||||
|
char *CleanMobName(const char *in, char *out);
|
||||||
|
|
||||||
|
const char *ConvertArray(int input, char *returnchar);
|
||||||
|
const char *ConvertArrayF(float input, char *returnchar);
|
||||||
|
|
||||||
|
void RemoveApostrophes(std::string &s);
|
||||||
|
char *RemoveApostrophes(const char *s);
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -57,14 +57,14 @@ void StructStrategy::PassDecoder(EQApplicationPacket *p) {
|
|||||||
//effectively a singleton, but I decided to do it this way for no apparent reason.
|
//effectively a singleton, but I decided to do it this way for no apparent reason.
|
||||||
namespace StructStrategyFactory {
|
namespace StructStrategyFactory {
|
||||||
|
|
||||||
static map<EmuOpcode, const StructStrategy *> strategies;
|
static std::map<EmuOpcode, const StructStrategy *> strategies;
|
||||||
|
|
||||||
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
|
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
|
||||||
strategies[first_opcode] = structs;
|
strategies[first_opcode] = structs;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StructStrategy *FindPatch(EmuOpcode first_opcode) {
|
const StructStrategy *FindPatch(EmuOpcode first_opcode) {
|
||||||
map<EmuOpcode, const StructStrategy *>::const_iterator res;
|
std::map<EmuOpcode, const StructStrategy *>::const_iterator res;
|
||||||
res = strategies.find(first_opcode);
|
res = strategies.find(first_opcode);
|
||||||
if(res == strategies.end())
|
if(res == strategies.end())
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|||||||
@ -18,11 +18,9 @@
|
|||||||
#include "../common/debug.h"
|
#include "../common/debug.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "TCPConnection.h"
|
#include "TCPConnection.h"
|
||||||
#include "../common/servertalk.h"
|
#include "../common/servertalk.h"
|
||||||
@ -63,7 +61,7 @@ TCPConnection::TCPConnection()
|
|||||||
pAsyncConnect = false;
|
pAsyncConnect = false;
|
||||||
m_previousLineEnd = false;
|
m_previousLineEnd = false;
|
||||||
#if TCPN_DEBUG_Memory >= 7
|
#if TCPN_DEBUG_Memory >= 7
|
||||||
cout << "Constructor #2 on outgoing TCP# " << GetID() << endl;
|
std::cout << "Constructor #2 on outgoing TCP# " << GetID() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +83,7 @@ TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 ir
|
|||||||
pAsyncConnect = false;
|
pAsyncConnect = false;
|
||||||
m_previousLineEnd = false;
|
m_previousLineEnd = false;
|
||||||
#if TCPN_DEBUG_Memory >= 7
|
#if TCPN_DEBUG_Memory >= 7
|
||||||
cout << "Constructor #2 on incoming TCP# " << GetID() << endl;
|
std::cout << "Constructor #2 on incoming TCP# " << GetID() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,12 +97,12 @@ TCPConnection::~TCPConnection() {
|
|||||||
MLoopRunning.lock();
|
MLoopRunning.lock();
|
||||||
MLoopRunning.unlock();
|
MLoopRunning.unlock();
|
||||||
#if TCPN_DEBUG_Memory >= 6
|
#if TCPN_DEBUG_Memory >= 6
|
||||||
cout << "Deconstructor on outgoing TCP# " << GetID() << endl;
|
std::cout << "Deconstructor on outgoing TCP# " << GetID() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if TCPN_DEBUG_Memory >= 5
|
#if TCPN_DEBUG_Memory >= 5
|
||||||
else {
|
else {
|
||||||
cout << "Deconstructor on incomming TCP# " << GetID() << endl;
|
std::cout << "Deconstructor on incomming TCP# " << GetID() << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
safe_delete_array(recvbuf);
|
safe_delete_array(recvbuf);
|
||||||
@ -587,7 +585,7 @@ bool TCPConnection::Process() {
|
|||||||
if (!SendData(sent_something, errbuf)) {
|
if (!SendData(sent_something, errbuf)) {
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
|
std::cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,8 +626,8 @@ bool TCPConnection::RecvData(char* errbuf) {
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
CoutTimestamp(true);
|
CoutTimestamp(true);
|
||||||
cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort();
|
std::cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort();
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
#if TCPN_LOG_RAW_DATA_IN == 2
|
#if TCPN_LOG_RAW_DATA_IN == 2
|
||||||
int32 tmp = status;
|
int32 tmp = status;
|
||||||
if (tmp > 32)
|
if (tmp > 32)
|
||||||
@ -683,7 +681,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
|
|||||||
return true;
|
return true;
|
||||||
#if TCPN_DEBUG_Console >= 4
|
#if TCPN_DEBUG_Console >= 4
|
||||||
if (recvbuf_used) {
|
if (recvbuf_used) {
|
||||||
cout << "Starting Processing: recvbuf=" << recvbuf_used << endl;
|
std::cout << "Starting Processing: recvbuf=" << recvbuf_used << std::endl;
|
||||||
DumpPacket(recvbuf, recvbuf_used);
|
DumpPacket(recvbuf, recvbuf_used);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -715,13 +713,13 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if TCPN_DEBUG_Console >= 5
|
#if TCPN_DEBUG_Console >= 5
|
||||||
cout << "Removed 0x00" << endl;
|
std::cout << "Removed 0x00" << std::endl;
|
||||||
if (recvbuf_used) {
|
if (recvbuf_used) {
|
||||||
cout << "recvbuf left: " << recvbuf_used << endl;
|
std::cout << "recvbuf left: " << recvbuf_used << std::endl;
|
||||||
DumpPacket(recvbuf, recvbuf_used);
|
DumpPacket(recvbuf, recvbuf_used);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cout << "recbuf left: None" << endl;
|
std::cout << "recbuf left: None" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
m_previousLineEnd = false;
|
m_previousLineEnd = false;
|
||||||
break;
|
break;
|
||||||
@ -748,7 +746,7 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
|
|||||||
memset(line, 0, i+1);
|
memset(line, 0, i+1);
|
||||||
memcpy(line, recvbuf, i);
|
memcpy(line, recvbuf, i);
|
||||||
#if TCPN_DEBUG_Console >= 3
|
#if TCPN_DEBUG_Console >= 3
|
||||||
cout << "Line Out: " << endl;
|
std::cout << "Line Out: " << std::endl;
|
||||||
DumpPacket((uchar*) line, i);
|
DumpPacket((uchar*) line, i);
|
||||||
#endif
|
#endif
|
||||||
//line[i] = 0;
|
//line[i] = 0;
|
||||||
@ -758,13 +756,13 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
|
|||||||
recvbuf_echo -= i+1;
|
recvbuf_echo -= i+1;
|
||||||
memcpy(recvbuf, &tmpdel[i+1], recvbuf_used);
|
memcpy(recvbuf, &tmpdel[i+1], recvbuf_used);
|
||||||
#if TCPN_DEBUG_Console >= 5
|
#if TCPN_DEBUG_Console >= 5
|
||||||
cout << "i+1=" << i+1 << endl;
|
std::cout << "i+1=" << i+1 << std::endl;
|
||||||
if (recvbuf_used) {
|
if (recvbuf_used) {
|
||||||
cout << "recvbuf left: " << recvbuf_used << endl;
|
std::cout << "recvbuf left: " << recvbuf_used << std::endl;
|
||||||
DumpPacket(recvbuf, recvbuf_used);
|
DumpPacket(recvbuf, recvbuf_used);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cout << "recbuf left: None" << endl;
|
std::cout << "recbuf left: None" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
safe_delete_array(tmpdel);
|
safe_delete_array(tmpdel);
|
||||||
i = -1;
|
i = -1;
|
||||||
@ -829,8 +827,8 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
CoutTimestamp(true);
|
CoutTimestamp(true);
|
||||||
cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort();
|
std::cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort();
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
#if TCPN_LOG_RAW_DATA_OUT == 2
|
#if TCPN_LOG_RAW_DATA_OUT == 2
|
||||||
int32 tmp = status;
|
int32 tmp = status;
|
||||||
if (tmp > 32)
|
if (tmp > 32)
|
||||||
@ -846,8 +844,8 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
|
|||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
in.s_addr = GetrIP();
|
in.s_addr = GetrIP();
|
||||||
CoutTimestamp(true);
|
CoutTimestamp(true);
|
||||||
cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort();
|
std::cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort();
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
#endif
|
#endif
|
||||||
// If there's network congestion, the number of bytes sent can be less than
|
// If there's network congestion, the number of bytes sent can be less than
|
||||||
// what we tried to give it... Push the extra back on the queue for later
|
// what we tried to give it... Push the extra back on the queue for later
|
||||||
|
|||||||
@ -24,9 +24,6 @@
|
|||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#if (_MSC_VER < 1500)
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
#endif
|
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ XMLParser::XMLParser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool XMLParser::ParseFile(const char *file, const char *root_ele) {
|
bool XMLParser::ParseFile(const char *file, const char *root_ele) {
|
||||||
map<string,ElementHandler>::iterator handler;
|
std::map<std::string,ElementHandler>::iterator handler;
|
||||||
TiXmlDocument doc( file );
|
TiXmlDocument doc( file );
|
||||||
if(!doc.LoadFile()) {
|
if(!doc.LoadFile()) {
|
||||||
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());
|
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());
|
||||||
|
|||||||
@ -24,9 +24,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See note in XMLParser::ParseFile() before inheriting this class.
|
* See note in XMLParser::ParseFile() before inheriting this class.
|
||||||
@ -45,12 +42,11 @@ protected:
|
|||||||
const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false);
|
const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false);
|
||||||
const char *GetText(TiXmlNode *within, bool optional = false);
|
const char *GetText(TiXmlNode *within, bool optional = false);
|
||||||
|
|
||||||
map<string,ElementHandler> Handlers;
|
std::map<std::string,ElementHandler> Handlers;
|
||||||
|
|
||||||
bool ParseOkay;
|
bool ParseOkay;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
#include "../common/debug.h"
|
#include "../common/debug.h"
|
||||||
#include "../common/rulesys.h"
|
#include "../common/rulesys.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -44,7 +43,8 @@ using namespace std;
|
|||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "eq_packet_structs.h"
|
#include "eq_packet_structs.h"
|
||||||
#include "guilds.h"
|
#include "guilds.h"
|
||||||
#include "MiscFunctions.h"
|
//#include "MiscFunctions.h"
|
||||||
|
#include "StringUtil.h"
|
||||||
#include "extprofile.h"
|
#include "extprofile.h"
|
||||||
extern Client client;
|
extern Client client;
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, int16* oStat
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in CheckLogin query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in CheckLogin query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ bool Database::CheckBannedIPs(const char* loginIP)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes)
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes), errbuf)) {
|
||||||
cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in ReserveName query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ void Database::LoginIP(uint32 AccountID, const char* LoginIP)
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP), errbuf)) {
|
||||||
cerr << "Error in Log IP query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in Log IP query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
@ -333,7 +333,7 @@ int16 Database::CheckStatus(uint32 account_id)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in CheckStatus query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in CheckStatus query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -352,16 +352,16 @@ uint32 Database::CreateAccount(const char* name, const char* password, int16 sta
|
|||||||
else
|
else
|
||||||
querylen = MakeAnyLenString(&query, "INSERT INTO account SET name='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name, status, lsaccount_id);
|
querylen = MakeAnyLenString(&query, "INSERT INTO account SET name='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name, status, lsaccount_id);
|
||||||
|
|
||||||
cerr << "Account Attempting to be created:" << name << " " << (int16) status << endl;
|
std::cerr << "Account Attempting to be created:" << name << " " << (int16) status << std::endl;
|
||||||
if (!RunQuery(query, querylen, errbuf, 0, 0, &last_insert_id)) {
|
if (!RunQuery(query, querylen, errbuf, 0, 0, &last_insert_id)) {
|
||||||
cerr << "Error in CreateAccount query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in CreateAccount query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
|
|
||||||
if (last_insert_id == 0) {
|
if (last_insert_id == 0) {
|
||||||
cerr << "Error in CreateAccount query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in CreateAccount query '" << query << "' " << errbuf << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ bool Database::DeleteAccount(const char* name) {
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
cerr << "Account Attempting to be deleted:" << name << endl;
|
std::cerr << "Account Attempting to be deleted:" << name << std::endl;
|
||||||
if (RunQuery(query, MakeAnyLenString(&query, "DELETE FROM account WHERE name='%s';",name), errbuf, 0, &affected_rows)) {
|
if (RunQuery(query, MakeAnyLenString(&query, "DELETE FROM account WHERE name='%s';",name), errbuf, 0, &affected_rows)) {
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
if (affected_rows == 1) {
|
if (affected_rows == 1) {
|
||||||
@ -382,7 +382,7 @@ bool Database::DeleteAccount(const char* name) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
cerr << "Error in DeleteAccount query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in DeleteAccount query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,7 +394,7 @@ bool Database::SetLocalPassword(uint32 accid, const char* password) {
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET password=MD5('%s') where id=%i;", password, accid), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET password=MD5('%s') where id=%i;", password, accid), errbuf)) {
|
||||||
cerr << "Error in SetLocalPassword query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in SetLocalPassword query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
cout << "Account being GM Flagged:" << name << ", Level: " << (int16) status << endl;
|
std::cout << "Account being GM Flagged:" << name << ", Level: " << (int16) status << std::endl;
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET status=%i WHERE name='%s';", status, name), errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET status=%i WHERE name='%s';", status, name), errbuf, 0, &affected_rows)) {
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
@ -416,7 +416,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
|
|||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
|
|
||||||
if (affected_rows == 0) {
|
if (affected_rows == 0) {
|
||||||
cout << "Account: " << name << " does not exist, therefore it cannot be flagged\n";
|
std::cout << "Account: " << name << " does not exist, therefore it cannot be flagged\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ bool Database::ReserveName(uint32 account_id, char* name)
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=NULL", account_id, name), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=NULL", account_id, name), errbuf)) {
|
||||||
cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in ReserveName query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -877,7 +877,7 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,7 +940,7 @@ uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32*
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in GetAccountIDByAcc query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetAccountIDByAcc query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -968,7 +968,7 @@ void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
cerr << "Error in GetAccountName query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetAccountName query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,7 +990,7 @@ void Database::GetCharName(uint32 char_id, char* name) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
cerr << "Error in GetCharName query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetCharName query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1007,7 +1007,7 @@ bool Database::LoadVariables() {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in LoadVariables query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in LoadVariables query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1130,7 +1130,7 @@ bool Database::SetVariable(const char* varname_in, const char* varvalue_in) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in SetVariable query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in SetVariable query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
free(varname);
|
free(varname);
|
||||||
@ -1152,7 +1152,7 @@ uint32 Database::GetMiniLoginAccount(char* ip){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in GetMiniLoginAccount query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetMiniLoginAccount query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
return retid;
|
return retid;
|
||||||
@ -1194,11 +1194,11 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetSafePoint query '" << query << "' " << errbuf << std::endl;
|
||||||
cerr << "If it errors, run the following querys:\n";
|
std::cerr << "If it errors, run the following querys:\n";
|
||||||
cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n";
|
std::cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n";
|
||||||
cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n";
|
std::cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n";
|
||||||
cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n";
|
std::cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n";
|
||||||
|
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
@ -1243,7 +1243,7 @@ bool Database::GetZoneLongName(const char* short_name, char** long_name, char* f
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in GetZoneLongName query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetZoneLongName query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1269,7 +1269,7 @@ uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in GetZoneGraveyardID query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetZoneGraveyardID query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return GraveyardID;
|
return GraveyardID;
|
||||||
@ -1303,7 +1303,7 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in GetZoneGraveyard query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetZoneGraveyard query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1342,7 +1342,7 @@ bool Database::LoadZoneNames() {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1352,7 +1352,7 @@ bool Database::LoadZoneNames() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in LoadZoneNames query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1419,7 +1419,7 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in GetPEQZone query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetPEQZone query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return peqzone;
|
return peqzone;
|
||||||
@ -1503,7 +1503,7 @@ bool Database::CheckNameFilter(const char* name, bool surname)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "Error in CheckNameFilter query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in CheckNameFilter query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1516,7 +1516,7 @@ bool Database::AddToNameFilter(const char* name) {
|
|||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO name_filter (name) values ('%s')", name), errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO name_filter (name) values ('%s')", name), errbuf, 0, &affected_rows)) {
|
||||||
cerr << "Error in AddToNameFilter query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in AddToNameFilter query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1557,7 +1557,7 @@ uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* o
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1583,7 +1583,7 @@ void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cerr << "Error in GetAccountFromID query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetAccountFromID query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1592,7 +1592,7 @@ void Database::ClearMerchantTemp(){
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "delete from merchantlist_temp"), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "delete from merchantlist_temp"), errbuf)) {
|
||||||
cerr << "Error in ClearMerchantTemp query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in ClearMerchantTemp query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
@ -1602,7 +1602,7 @@ bool Database::UpdateName(const char* oldname, const char* newname) {
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
cout << "Renaming " << oldname << " to " << newname << "..." << endl;
|
std::cout << "Renaming " << oldname << " to " << newname << "..." << std::endl;
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET name='%s' WHERE name='%s';", newname, oldname), errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET name='%s' WHERE name='%s';", newname, oldname), errbuf, 0, &affected_rows)) {
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
@ -1626,7 +1626,7 @@ bool Database::CheckUsedName(const char* name)
|
|||||||
//if (strlen(name) > 15)
|
//if (strlen(name) > 15)
|
||||||
// return false;
|
// return false;
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM character_ where name='%s'", name), errbuf, &result)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM character_ where name='%s'", name), errbuf, &result)) {
|
||||||
cerr << "Error in CheckUsedName query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in CheckUsedName query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1664,15 +1664,11 @@ uint8 Database::GetServerType()
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
||||||
{
|
{
|
||||||
|
std::cerr << "Error in GetServerType query '" << query << "' " << errbuf << std::endl;
|
||||||
|
|
||||||
cerr << "Error in GetServerType query '" << query << "' " << errbuf << endl;
|
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1686,7 +1682,7 @@ bool Database::MoveCharacterToZone(const char* charname, const char* zonename,ui
|
|||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s',zoneid=%i,x=-1, y=-1, z=-1 WHERE name='%s'", zonename,zoneid, charname), errbuf, 0,&affected_rows)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s',zoneid=%i,x=-1, y=-1, z=-1 WHERE name='%s'", zonename,zoneid, charname), errbuf, 0,&affected_rows)) {
|
||||||
cerr << "Error in MoveCharacterToZone(name) query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in MoveCharacterToZone(name) query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
@ -1706,7 +1702,7 @@ bool Database::MoveCharacterToZone(uint32 iCharID, const char* iZonename) {
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s', zoneid=%i, x=-1, y=-1, z=-1 WHERE id=%i", iZonename, GetZoneID(iZonename), iCharID), errbuf, 0,&affected_rows)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s', zoneid=%i, x=-1, y=-1, z=-1 WHERE id=%i", iZonename, GetZoneID(iZonename), iCharID), errbuf, 0,&affected_rows)) {
|
||||||
cerr << "Error in MoveCharacterToZone(id) query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in MoveCharacterToZone(id) query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
@ -1739,7 +1735,7 @@ uint8 Database::CopyCharacter(const char* oldname, const char* newname, uint32 a
|
|||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
cerr << "Error in CopyCharacter read query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in CopyCharacter read query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1755,7 +1751,7 @@ uint8 Database::CopyCharacter(const char* oldname, const char* newname, uint32 a
|
|||||||
end += sprintf(end, "\', account_id=%d, name='%s'", acctid, newname);
|
end += sprintf(end, "\', account_id=%d, name='%s'", acctid, newname);
|
||||||
|
|
||||||
if (!RunQuery(query2, (uint32) (end - query2), errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query2, (uint32) (end - query2), errbuf, 0, &affected_rows)) {
|
||||||
cerr << "Error in CopyCharacter query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in CopyCharacter query '" << query << "' " << errbuf << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1772,7 +1768,7 @@ bool Database::SetHackerFlag(const char* accountname, const char* charactername,
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO hackers(account,name,hacked) values('%s','%s','%s')", accountname, charactername, hacked), errbuf, 0,&affected_rows)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO hackers(account,name,hacked) values('%s','%s','%s')", accountname, charactername, hacked), errbuf, 0,&affected_rows)) {
|
||||||
cerr << "Error in SetHackerFlag query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in SetHackerFlag query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
@ -1792,7 +1788,7 @@ bool Database::SetMQDetectionFlag(const char* accountname, const char* character
|
|||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO hackers(account,name,hacked,zone) values('%s','%s','%s','%s')", accountname, charactername, hacked, zone), errbuf, 0,&affected_rows)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO hackers(account,name,hacked,zone) values('%s','%s','%s','%s')", accountname, charactername, hacked, zone), errbuf, 0,&affected_rows)) {
|
||||||
cerr << "Error in SetMQDetectionFlag query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in SetMQDetectionFlag query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1911,7 +1907,7 @@ uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZo
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in GetCharacterInfo query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetCharacterInfo query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1921,7 +1917,7 @@ bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) {
|
|||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id), errbuf)) {
|
||||||
cerr << "Error in UpdateLiveChar query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in UpdateLiveChar query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1946,7 +1942,7 @@ bool Database::GetLiveChar(uint32 account_id, char* cname) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in GetLiveChar query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetLiveChar query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2171,7 +2167,7 @@ void Database::ClearGroupLeader(uint32 gid){
|
|||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FetchRowMap(MYSQL_RES *result, map<string,string> &rowmap)
|
bool FetchRowMap(MYSQL_RES *result, std::map<std::string,std::string> &rowmap)
|
||||||
{
|
{
|
||||||
MYSQL_FIELD *fields;
|
MYSQL_FIELD *fields;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -3175,7 +3171,7 @@ uint32 Database::GetGuildDBIDByCharID(uint32 char_id) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|||||||
@ -35,7 +35,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//atoi is not uint32 or uint32 safe!!!!
|
//atoi is not uint32 or uint32 safe!!!!
|
||||||
#define atoul(str) strtoul(str, nullptr, 10)
|
#define atoul(str) strtoul(str, nullptr, 10)
|
||||||
@ -265,5 +264,5 @@ private:
|
|||||||
uint32 varcache_lastupdate;
|
uint32 varcache_lastupdate;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool FetchRowMap(MYSQL_RES *result, map<string,string> &rowmap);
|
bool FetchRowMap(MYSQL_RES *result, std::map<std::string,std::string> &rowmap);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include "dbasync.h"
|
#include "dbasync.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include <errmsg.h>
|
#include <errmsg.h>
|
||||||
@ -14,7 +13,8 @@ using namespace std;
|
|||||||
#include "dbcore.h"
|
#include "dbcore.h"
|
||||||
#include "common_profile.h"
|
#include "common_profile.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../common/MiscFunctions.h"
|
//#include "../common/MiscFunctions.h"
|
||||||
|
#include "StringUtil.h"
|
||||||
#define ASYNC_LOOP_GRANULARITY 4 //# of ms between checking our work
|
#define ASYNC_LOOP_GRANULARITY 4 //# of ms between checking our work
|
||||||
|
|
||||||
bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) {
|
bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) {
|
||||||
@ -24,7 +24,7 @@ bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) {
|
|||||||
if (dbaq->GetAnswer(errbuf, &result))
|
if (dbaq->GetAnswer(errbuf, &result))
|
||||||
iWork->GetDB()->LoadVariables_result(result);
|
iWork->GetDB()->LoadVariables_result(result);
|
||||||
else
|
else
|
||||||
cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << endl;
|
std::cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +115,8 @@ uint32 DBAsync::AddWork(DBAsyncWork** iWork, uint32 iDelay) {
|
|||||||
if (iDelay)
|
if (iDelay)
|
||||||
(*iWork)->pExecuteAfter = Timer::GetCurrentTime() + iDelay;
|
(*iWork)->pExecuteAfter = Timer::GetCurrentTime() + iDelay;
|
||||||
#if DEBUG_MYSQL_QUERIES >= 2
|
#if DEBUG_MYSQL_QUERIES >= 2
|
||||||
cout << "Adding AsyncWork #" << (*iWork)->GetWorkID() << endl;
|
std::cout << "Adding AsyncWork #" << (*iWork)->GetWorkID() << std::endl;
|
||||||
cout << "ExecuteAfter = " << (*iWork)->pExecuteAfter << " (" << Timer::GetCurrentTime() << " + " << iDelay << ")" << endl;
|
std::cout << "ExecuteAfter = " << (*iWork)->pExecuteAfter << " (" << Timer::GetCurrentTime() << " + " << iDelay << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
*iWork = 0;
|
*iWork = 0;
|
||||||
MInList.unlock();
|
MInList.unlock();
|
||||||
@ -131,7 +131,7 @@ bool DBAsync::CancelWork(uint32 iWorkID) {
|
|||||||
if (iWorkID == 0)
|
if (iWorkID == 0)
|
||||||
return false;
|
return false;
|
||||||
#if DEBUG_MYSQL_QUERIES >= 2
|
#if DEBUG_MYSQL_QUERIES >= 2
|
||||||
cout << "DBAsync::CancelWork: " << iWorkID << endl;
|
std::cout << "DBAsync::CancelWork: " << iWorkID << std::endl;
|
||||||
#endif
|
#endif
|
||||||
MCurrentWork.lock();
|
MCurrentWork.lock();
|
||||||
if (CurrentWork && CurrentWork->GetWorkID() == iWorkID) {
|
if (CurrentWork && CurrentWork->GetWorkID() == iWorkID) {
|
||||||
@ -174,8 +174,8 @@ DBAsyncWork* DBAsync::InListPop() {
|
|||||||
if (iterator.GetData()->pExecuteAfter <= Timer::GetCurrentTime()) {
|
if (iterator.GetData()->pExecuteAfter <= Timer::GetCurrentTime()) {
|
||||||
ret = iterator.GetData();
|
ret = iterator.GetData();
|
||||||
#if DEBUG_MYSQL_QUERIES >= 2
|
#if DEBUG_MYSQL_QUERIES >= 2
|
||||||
cout << "Poping AsyncWork #" << ret->GetWorkID() << endl;
|
std::cout << "Poping AsyncWork #" << ret->GetWorkID() << std::endl;
|
||||||
cout << ret->pExecuteAfter << " <= " << Timer::GetCurrentTime() << endl;
|
std::cout << ret->pExecuteAfter << " <= " << Timer::GetCurrentTime() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
iterator.RemoveCurrent(false);
|
iterator.RemoveCurrent(false);
|
||||||
break;
|
break;
|
||||||
@ -232,7 +232,7 @@ void DBAsync::Process() {
|
|||||||
tmpStatus = tmpWork->SetStatus(DBAsync::Finished);
|
tmpStatus = tmpWork->SetStatus(DBAsync::Finished);
|
||||||
if (tmpStatus != Executing) {
|
if (tmpStatus != Executing) {
|
||||||
if (tmpStatus != Canceled) {
|
if (tmpStatus != Canceled) {
|
||||||
cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #1" << endl;
|
std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #1" << std::endl;
|
||||||
}
|
}
|
||||||
MCurrentWork.lock();
|
MCurrentWork.lock();
|
||||||
safe_delete(tmpWork);
|
safe_delete(tmpWork);
|
||||||
@ -246,7 +246,7 @@ void DBAsync::Process() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (tmpStatus != Canceled) {
|
if (tmpStatus != Canceled) {
|
||||||
cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #2" << endl;
|
std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::Process #2" << std::endl;
|
||||||
}
|
}
|
||||||
MCurrentWork.lock();
|
MCurrentWork.lock();
|
||||||
safe_delete(CurrentWork);
|
safe_delete(CurrentWork);
|
||||||
@ -274,7 +274,7 @@ void DBAsync::CheckTimeout() {
|
|||||||
|
|
||||||
void DBAsync::CommitWrites() {
|
void DBAsync::CommitWrites() {
|
||||||
#if DEBUG_MYSQL_QUERIES >= 2
|
#if DEBUG_MYSQL_QUERIES >= 2
|
||||||
cout << "DBAsync::CommitWrites() called." << endl;
|
std::cout << "DBAsync::CommitWrites() called." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
DBAsyncWork* tmpWork;
|
DBAsyncWork* tmpWork;
|
||||||
while ((tmpWork = InListPopWrite())) {
|
while ((tmpWork = InListPopWrite())) {
|
||||||
@ -284,7 +284,7 @@ void DBAsync::CommitWrites() {
|
|||||||
tmpStatus = tmpWork->SetStatus(DBAsync::Finished);
|
tmpStatus = tmpWork->SetStatus(DBAsync::Finished);
|
||||||
if (tmpStatus != Executing) {
|
if (tmpStatus != Executing) {
|
||||||
if (tmpStatus != Canceled) {
|
if (tmpStatus != Canceled) {
|
||||||
cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #1" << endl;
|
std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #1" << std::endl;
|
||||||
}
|
}
|
||||||
safe_delete(tmpWork);
|
safe_delete(tmpWork);
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ void DBAsync::CommitWrites() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (tmpStatus != Canceled) {
|
if (tmpStatus != Canceled) {
|
||||||
cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #2" << endl;
|
std::cout << "Error: Unexpected DBAsyncWork->Status in DBAsync::CommitWrites #2" << std::endl;
|
||||||
}
|
}
|
||||||
safe_delete(tmpWork);
|
safe_delete(tmpWork);
|
||||||
}
|
}
|
||||||
@ -305,7 +305,7 @@ void DBAsync::ProcessWork(DBAsyncWork* iWork, bool iSleep) {
|
|||||||
_CP(DBAsync_ProcessWork);
|
_CP(DBAsync_ProcessWork);
|
||||||
DBAsyncQuery* CurrentQuery;
|
DBAsyncQuery* CurrentQuery;
|
||||||
#if DEBUG_MYSQL_QUERIES >= 2
|
#if DEBUG_MYSQL_QUERIES >= 2
|
||||||
cout << "Processing AsyncWork #" << iWork->GetWorkID() << endl;
|
std::cout << "Processing AsyncWork #" << iWork->GetWorkID() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
while ((CurrentQuery = iWork->PopQuery())) {
|
while ((CurrentQuery = iWork->PopQuery())) {
|
||||||
CurrentQuery->Process(pDBC);
|
CurrentQuery->Process(pDBC);
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include <errmsg.h>
|
#include <errmsg.h>
|
||||||
#include <mysqld_error.h>
|
#include <mysqld_error.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@ -72,17 +71,17 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
|
|||||||
#if DEBUG_MYSQL_QUERIES >= 1
|
#if DEBUG_MYSQL_QUERIES >= 1
|
||||||
char tmp[120];
|
char tmp[120];
|
||||||
strn0cpy(tmp, query, sizeof(tmp));
|
strn0cpy(tmp, query, sizeof(tmp));
|
||||||
cout << "QUERY: " << tmp << endl;
|
std::cout << "QUERY: " << tmp << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (mysql_real_query(&mysql, query, querylen)) {
|
if (mysql_real_query(&mysql, query, querylen)) {
|
||||||
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
|
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
|
||||||
pStatus = Error;
|
pStatus = Error;
|
||||||
if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
|
if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
|
||||||
if (retry) {
|
if (retry) {
|
||||||
cout << "Database Error: Lost connection, attempting to recover...." << endl;
|
std::cout << "Database Error: Lost connection, attempting to recover...." << std::endl;
|
||||||
ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
|
ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
|
||||||
if (ret)
|
if (ret)
|
||||||
cout << "Reconnection to database successful." << endl;
|
std::cout << "Reconnection to database successful." << std::endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pStatus = Error;
|
pStatus = Error;
|
||||||
@ -90,7 +89,7 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
|
|||||||
*errnum = mysql_errno(&mysql);
|
*errnum = mysql_errno(&mysql);
|
||||||
if (errbuf)
|
if (errbuf)
|
||||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||||
cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << endl;
|
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,7 +99,7 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
|
|||||||
if (errbuf)
|
if (errbuf)
|
||||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||||
#ifdef _EQDEBUG
|
#ifdef _EQDEBUG
|
||||||
cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << endl;
|
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
@ -124,7 +123,7 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef _EQDEBUG
|
#ifdef _EQDEBUG
|
||||||
cout << "DB Query Error: No Result" << endl;
|
std::cout << "DB Query Error: No Result" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (errnum)
|
if (errnum)
|
||||||
*errnum = UINT_MAX;
|
*errnum = UINT_MAX;
|
||||||
@ -139,15 +138,15 @@ bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RE
|
|||||||
}
|
}
|
||||||
#if DEBUG_MYSQL_QUERIES >= 1
|
#if DEBUG_MYSQL_QUERIES >= 1
|
||||||
if (ret) {
|
if (ret) {
|
||||||
cout << "query successful";
|
std::cout << "query successful";
|
||||||
if (result && (*result))
|
if (result && (*result))
|
||||||
cout << ", " << (int) mysql_num_rows(*result) << " rows returned";
|
std::cout << ", " << (int) mysql_num_rows(*result) << " rows returned";
|
||||||
if (affected_rows)
|
if (affected_rows)
|
||||||
cout << ", " << (*affected_rows) << " rows affected";
|
std::cout << ", " << (*affected_rows) << " rows affected";
|
||||||
cout<< endl;
|
std::cout<< std::endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cout << "QUERY: query FAILED" << endl;
|
std::cout << "QUERY: query FAILED" << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@ -1,25 +1,27 @@
|
|||||||
#include "debug.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
#include <string>
|
||||||
|
#include <cstdarg>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#if (_MSC_VER < 1500)
|
|
||||||
#define vsnprintf _vsnprintf
|
#define vsnprintf _vsnprintf
|
||||||
#endif
|
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#endif
|
#endif
|
||||||
#include "../common/MiscFunctions.h"
|
|
||||||
#include "../common/platform.h"
|
#include "debug.h"
|
||||||
|
#include "StringUtil.h"
|
||||||
|
#include "MiscFunctions.h"
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
#ifndef va_copy
|
#ifndef va_copy
|
||||||
#define va_copy(d,s) ((d) = (s))
|
#define va_copy(d,s) ((d) = (s))
|
||||||
@ -112,7 +114,7 @@ bool EQEMuLog::open(LogIDs id) {
|
|||||||
#endif
|
#endif
|
||||||
fp[id] = fopen(filename, "a");
|
fp[id] = fopen(filename, "a");
|
||||||
if (!fp[id]) {
|
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
|
pLogStatus[id] |= 4; // set file state to error
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -328,7 +330,7 @@ bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
|
|||||||
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
|
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
|
||||||
if (!logFileValid) {
|
if (!logFileValid) {
|
||||||
#if EQDEBUG >= 10
|
#if EQDEBUG >= 10
|
||||||
cerr << "Error: Dump() from null pointer"<<endl;
|
std::cerr << "Error: Dump() from null pointer" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -350,36 +352,45 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
|
|||||||
|
|
||||||
write(id, "Dumping Packet: %i", size);
|
write(id, "Dumping Packet: %i", size);
|
||||||
// Output as HEX
|
// Output as HEX
|
||||||
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
|
|
||||||
uint32 i;
|
int beginningOfLineOffset = 0;
|
||||||
for(i=skip; i<size; i++) {
|
uint32 indexInData;
|
||||||
if ((i-skip)%cols==0) {
|
std::string asciiOutput;
|
||||||
if (i != skip)
|
|
||||||
writeNTS(id, dofile, " | %s\n", ascii);
|
for(indexInData=skip; indexInData<size; indexInData++) {
|
||||||
writeNTS(id, dofile, "%4i: ", i-skip);
|
if ((indexInData-skip)%cols==0) {
|
||||||
memset(ascii, 0, cols+1);
|
if (indexInData != skip)
|
||||||
j = 0;
|
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
|
||||||
|
writeNTS(id, dofile, "%4i: ", indexInData-skip);
|
||||||
|
asciiOutput.clear();
|
||||||
|
beginningOfLineOffset = 0;
|
||||||
}
|
}
|
||||||
else if ((i-skip)%(cols/2) == 0) {
|
else if ((indexInData-skip)%(cols/2) == 0) {
|
||||||
writeNTS(id, dofile, "- ");
|
writeNTS(id, dofile, "- ");
|
||||||
}
|
}
|
||||||
writeNTS(id, dofile, "%02X ", (unsigned char)data[i]);
|
writeNTS(id, dofile, "%02X ", (unsigned char)data[indexInData]);
|
||||||
|
|
||||||
if (data[i] >= 32 && data[i] < 127)
|
if (data[indexInData] >= 32 && data[indexInData] < 127)
|
||||||
ascii[j++] = data[i];
|
{
|
||||||
|
// According to http://msdn.microsoft.com/en-us/library/vstudio/ee404875(v=vs.100).aspx
|
||||||
|
// Visual Studio 2010 doesn't have std::to_string(int) but it does have the long long
|
||||||
|
// version.
|
||||||
|
asciiOutput.append(std::to_string((long long)data[indexInData]));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ascii[j++] = '.';
|
{
|
||||||
|
asciiOutput.append(".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
uint32 k = ((i-skip)-1)%cols;
|
uint32 k = ((indexInData-skip)-1)%cols;
|
||||||
if (k < 8)
|
if (k < 8)
|
||||||
writeNTS(id, dofile, " ");
|
writeNTS(id, dofile, " ");
|
||||||
for (uint32 h = k+1; h < cols; h++) {
|
for (uint32 h = k+1; h < cols; h++) {
|
||||||
writeNTS(id, dofile, " ");
|
writeNTS(id, dofile, " ");
|
||||||
}
|
}
|
||||||
writeNTS(id, dofile, " | %s\n", ascii);
|
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
|
||||||
if (dofile)
|
if (dofile)
|
||||||
fflush(fp[id]);
|
fflush(fp[id]);
|
||||||
safe_delete_array(ascii);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,6 @@
|
|||||||
#include "../common/eq_packet_structs.h"
|
#include "../common/eq_packet_structs.h"
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
/*#ifdef _CRTDBG_MAP_ALLOC
|
/*#ifdef _CRTDBG_MAP_ALLOC
|
||||||
#undef new
|
#undef new
|
||||||
#endif*/
|
#endif*/
|
||||||
@ -137,7 +136,7 @@ int EQTime::setEQTimeOfDay(TimeOfDay_Struct start_eq, time_t start_real)
|
|||||||
//For some reason, ifstream/ofstream have problems with EQEmu datatypes in files.
|
//For some reason, ifstream/ofstream have problems with EQEmu datatypes in files.
|
||||||
bool EQTime::saveFile(const char *filename)
|
bool EQTime::saveFile(const char *filename)
|
||||||
{
|
{
|
||||||
ofstream of;
|
std::ofstream of;
|
||||||
of.open(filename);
|
of.open(filename);
|
||||||
if(!of)
|
if(!of)
|
||||||
{
|
{
|
||||||
@ -146,13 +145,13 @@ bool EQTime::saveFile(const char *filename)
|
|||||||
}
|
}
|
||||||
//Enable for debugging
|
//Enable for debugging
|
||||||
//cout << "SAVE: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << endl;
|
//cout << "SAVE: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << endl;
|
||||||
of << EQT_VERSION << endl;
|
of << EQT_VERSION << std::endl;
|
||||||
of << (long)eqTime.start_eqtime.day << endl;
|
of << (long)eqTime.start_eqtime.day << std::endl;
|
||||||
of << (long)eqTime.start_eqtime.hour << endl;
|
of << (long)eqTime.start_eqtime.hour << std::endl;
|
||||||
of << (long)eqTime.start_eqtime.minute << endl;
|
of << (long)eqTime.start_eqtime.minute << std::endl;
|
||||||
of << (long)eqTime.start_eqtime.month << endl;
|
of << (long)eqTime.start_eqtime.month << std::endl;
|
||||||
of << eqTime.start_eqtime.year << endl;
|
of << eqTime.start_eqtime.year << std::endl;
|
||||||
of << eqTime.start_realtime << endl;
|
of << eqTime.start_realtime << std::endl;
|
||||||
of.close();
|
of.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -161,7 +160,7 @@ bool EQTime::loadFile(const char *filename)
|
|||||||
{
|
{
|
||||||
int version=0;
|
int version=0;
|
||||||
long in_data=0;
|
long in_data=0;
|
||||||
ifstream in;
|
std::ifstream in;
|
||||||
in.open(filename);
|
in.open(filename);
|
||||||
if(!in)
|
if(!in)
|
||||||
{
|
{
|
||||||
@ -265,7 +264,7 @@ void EQTime::AddMinutes(uint32 minutes, TimeOfDay_Struct *to) {
|
|||||||
to->year += (cur-1) / 12;
|
to->year += (cur-1) / 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQTime::ToString(TimeOfDay_Struct *t, string &str) {
|
void EQTime::ToString(TimeOfDay_Struct *t, std::string &str) {
|
||||||
char buf[128];
|
char buf[128];
|
||||||
snprintf(buf, 128, "%.2d/%.2d/%.4d %.2d:%.2d",
|
snprintf(buf, 128, "%.2d/%.2d/%.4d %.2d:%.2d",
|
||||||
t->month, t->day, t->year, t->hour, t->minute);
|
t->month, t->day, t->year, t->hour, t->minute);
|
||||||
|
|||||||
@ -4,8 +4,6 @@
|
|||||||
#include "../common/eq_packet_structs.h"
|
#include "../common/eq_packet_structs.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//Struct
|
//Struct
|
||||||
struct eqTimeOfDay
|
struct eqTimeOfDay
|
||||||
{
|
{
|
||||||
@ -39,7 +37,7 @@ public:
|
|||||||
static bool IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test); //is test before base
|
static bool IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test); //is test before base
|
||||||
static void AddMinutes(uint32 minutes, TimeOfDay_Struct *to);
|
static void AddMinutes(uint32 minutes, TimeOfDay_Struct *to);
|
||||||
|
|
||||||
static void ToString(TimeOfDay_Struct *t, string &str);
|
static void ToString(TimeOfDay_Struct *t, std::string &str);
|
||||||
|
|
||||||
//Database functions
|
//Database functions
|
||||||
//bool loadDB(Database q);
|
//bool loadDB(Database q);
|
||||||
|
|||||||
@ -20,7 +20,8 @@
|
|||||||
#include "guild_base.h"
|
#include "guild_base.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "logsys.h"
|
#include "logsys.h"
|
||||||
#include "MiscFunctions.h"
|
//#include "MiscFunctions.h"
|
||||||
|
#include "StringUtil.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ bool BaseGuildManager::LoadGuilds() {
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
map<uint32, GuildInfo *>::iterator res;
|
std::map<uint32, GuildInfo *>::iterator res;
|
||||||
|
|
||||||
// load up all the guilds
|
// load up all the guilds
|
||||||
if (!m_db->RunQuery(query, MakeAnyLenString(&query,
|
if (!m_db->RunQuery(query, MakeAnyLenString(&query,
|
||||||
@ -116,7 +117,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
map<uint32, GuildInfo *>::iterator res;
|
std::map<uint32, GuildInfo *>::iterator res;
|
||||||
GuildInfo *info;
|
GuildInfo *info;
|
||||||
|
|
||||||
// load up all the guilds
|
// load up all the guilds
|
||||||
@ -173,7 +174,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
|||||||
|
|
||||||
BaseGuildManager::GuildInfo *BaseGuildManager::_CreateGuild(uint32 guild_id, const char *guild_name, uint32 leader_char_id, uint8 minstatus, const char *guild_motd, const char *motd_setter, const char *Channel, const char *URL)
|
BaseGuildManager::GuildInfo *BaseGuildManager::_CreateGuild(uint32 guild_id, const char *guild_name, uint32 leader_char_id, uint8 minstatus, const char *guild_motd, const char *motd_setter, const char *Channel, const char *URL)
|
||||||
{
|
{
|
||||||
map<uint32, GuildInfo *>::iterator res;
|
std::map<uint32, GuildInfo *>::iterator res;
|
||||||
|
|
||||||
//remove any old entry.
|
//remove any old entry.
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
@ -222,7 +223,7 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end()) {
|
if(res == m_guilds.end()) {
|
||||||
_log(GUILDS__DB, "Requested to store non-existent guild %d", guild_id);
|
_log(GUILDS__DB, "Requested to store non-existent guild %d", guild_id);
|
||||||
@ -376,7 +377,7 @@ bool BaseGuildManager::RenameGuild(uint32 guild_id, const char* name) {
|
|||||||
|
|
||||||
bool BaseGuildManager::SetGuildLeader(uint32 guild_id, uint32 leader_char_id) {
|
bool BaseGuildManager::SetGuildLeader(uint32 guild_id, uint32 leader_char_id) {
|
||||||
//get old leader first.
|
//get old leader first.
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(false);
|
return(false);
|
||||||
@ -516,7 +517,7 @@ uint32 BaseGuildManager::DBCreateGuild(const char* name, uint32 leader) {
|
|||||||
bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) {
|
bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) {
|
||||||
|
|
||||||
//remove the local entry
|
//remove the local entry
|
||||||
map<uint32, GuildInfo *>::iterator res;
|
std::map<uint32, GuildInfo *>::iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res != m_guilds.end()) {
|
if(res != m_guilds.end()) {
|
||||||
delete res->second;
|
delete res->second;
|
||||||
@ -557,7 +558,7 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(false);
|
return(false);
|
||||||
@ -597,7 +598,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(false);
|
return(false);
|
||||||
@ -637,7 +638,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(false);
|
return(false);
|
||||||
@ -682,7 +683,7 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
|
|||||||
if(m_db == nullptr)
|
if(m_db == nullptr)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
|
|
||||||
res = m_guilds.find(GuildID);
|
res = m_guilds.find(GuildID);
|
||||||
|
|
||||||
@ -723,7 +724,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
|
|||||||
if(m_db == nullptr)
|
if(m_db == nullptr)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
|
|
||||||
res = m_guilds.find(GuildID);
|
res = m_guilds.find(GuildID);
|
||||||
|
|
||||||
@ -978,7 +979,7 @@ static void ProcessGuildMember(MYSQL_ROW &row, CharGuildInfo &into) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BaseGuildManager::GetEntireGuild(uint32 guild_id, vector<CharGuildInfo *> &members) {
|
bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo *> &members) {
|
||||||
members.clear();
|
members.clear();
|
||||||
|
|
||||||
if(m_db == nullptr)
|
if(m_db == nullptr)
|
||||||
@ -1109,7 +1110,7 @@ uint8 *BaseGuildManager::MakeGuildList(const char *head_name, uint32 &length) co
|
|||||||
|
|
||||||
strn0cpy((char *) buffer, head_name, 64);
|
strn0cpy((char *) buffer, head_name, 64);
|
||||||
|
|
||||||
map<uint32, GuildInfo *>::const_iterator cur, end;
|
std::map<uint32, GuildInfo *>::const_iterator cur, end;
|
||||||
cur = m_guilds.begin();
|
cur = m_guilds.begin();
|
||||||
end = m_guilds.end();
|
end = m_guilds.end();
|
||||||
for(; cur != end; cur++) {
|
for(; cur != end; cur++) {
|
||||||
@ -1122,7 +1123,7 @@ uint8 *BaseGuildManager::MakeGuildList(const char *head_name, uint32 &length) co
|
|||||||
const char *BaseGuildManager::GetRankName(uint32 guild_id, uint8 rank) const {
|
const char *BaseGuildManager::GetRankName(uint32 guild_id, uint8 rank) const {
|
||||||
if(rank > GUILD_MAX_RANK)
|
if(rank > GUILD_MAX_RANK)
|
||||||
return("Invalid Rank");
|
return("Invalid Rank");
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return("Invalid Guild Rank");
|
return("Invalid Guild Rank");
|
||||||
@ -1132,7 +1133,7 @@ const char *BaseGuildManager::GetRankName(uint32 guild_id, uint8 rank) const {
|
|||||||
const char *BaseGuildManager::GetGuildName(uint32 guild_id) const {
|
const char *BaseGuildManager::GetGuildName(uint32 guild_id) const {
|
||||||
if(guild_id == GUILD_NONE)
|
if(guild_id == GUILD_NONE)
|
||||||
return("");
|
return("");
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return("Invalid Guild");
|
return("Invalid Guild");
|
||||||
@ -1140,7 +1141,7 @@ const char *BaseGuildManager::GetGuildName(uint32 guild_id) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BaseGuildManager::GetGuildNameByID(uint32 guild_id, std::string &into) const {
|
bool BaseGuildManager::GetGuildNameByID(uint32 guild_id, std::string &into) const {
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(false);
|
return(false);
|
||||||
@ -1150,7 +1151,7 @@ bool BaseGuildManager::GetGuildNameByID(uint32 guild_id, std::string &into) cons
|
|||||||
|
|
||||||
uint32 BaseGuildManager::GetGuildIDByName(const char *GuildName)
|
uint32 BaseGuildManager::GetGuildIDByName(const char *GuildName)
|
||||||
{
|
{
|
||||||
map<uint32, GuildInfo *>::iterator Iterator;
|
std::map<uint32, GuildInfo *>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = m_guilds.begin(); Iterator != m_guilds.end(); ++Iterator)
|
for(Iterator = m_guilds.begin(); Iterator != m_guilds.end(); ++Iterator)
|
||||||
{
|
{
|
||||||
@ -1162,7 +1163,7 @@ uint32 BaseGuildManager::GetGuildIDByName(const char *GuildName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BaseGuildManager::GetGuildMOTD(uint32 guild_id, char *motd_buffer, char *setter_buffer) const {
|
bool BaseGuildManager::GetGuildMOTD(uint32 guild_id, char *motd_buffer, char *setter_buffer) const {
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(false);
|
return(false);
|
||||||
@ -1173,7 +1174,7 @@ bool BaseGuildManager::GetGuildMOTD(uint32 guild_id, char *motd_buffer, char *se
|
|||||||
|
|
||||||
bool BaseGuildManager::GetGuildURL(uint32 GuildID, char *URLBuffer) const
|
bool BaseGuildManager::GetGuildURL(uint32 GuildID, char *URLBuffer) const
|
||||||
{
|
{
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(GuildID);
|
res = m_guilds.find(GuildID);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(false);
|
return(false);
|
||||||
@ -1184,7 +1185,7 @@ bool BaseGuildManager::GetGuildURL(uint32 GuildID, char *URLBuffer) const
|
|||||||
|
|
||||||
bool BaseGuildManager::GetGuildChannel(uint32 GuildID, char *ChannelBuffer) const
|
bool BaseGuildManager::GetGuildChannel(uint32 GuildID, char *ChannelBuffer) const
|
||||||
{
|
{
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(GuildID);
|
res = m_guilds.find(GuildID);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(false);
|
return(false);
|
||||||
@ -1203,7 +1204,7 @@ bool BaseGuildManager::IsGuildLeader(uint32 guild_id, uint32 char_id) const {
|
|||||||
_log(GUILDS__PERMISSIONS, "Check leader for char %d: not a guild.", char_id);
|
_log(GUILDS__PERMISSIONS, "Check leader for char %d: not a guild.", char_id);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end()) {
|
if(res == m_guilds.end()) {
|
||||||
_log(GUILDS__PERMISSIONS, "Check leader for char %d: invalid guild.", char_id);
|
_log(GUILDS__PERMISSIONS, "Check leader for char %d: invalid guild.", char_id);
|
||||||
@ -1214,7 +1215,7 @@ bool BaseGuildManager::IsGuildLeader(uint32 guild_id, uint32 char_id) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 BaseGuildManager::FindGuildByLeader(uint32 leader) const {
|
uint32 BaseGuildManager::FindGuildByLeader(uint32 leader) const {
|
||||||
map<uint32, GuildInfo *>::const_iterator cur, end;
|
std::map<uint32, GuildInfo *>::const_iterator cur, end;
|
||||||
cur = m_guilds.begin();
|
cur = m_guilds.begin();
|
||||||
end = m_guilds.end();
|
end = m_guilds.end();
|
||||||
for(; cur != end; cur++) {
|
for(; cur != end; cur++) {
|
||||||
@ -1226,7 +1227,7 @@ uint32 BaseGuildManager::FindGuildByLeader(uint32 leader) const {
|
|||||||
|
|
||||||
//returns the rank to be sent to the client for display purposes, given their eqemu rank.
|
//returns the rank to be sent to the client for display purposes, given their eqemu rank.
|
||||||
uint8 BaseGuildManager::GetDisplayedRank(uint32 guild_id, uint8 rank, uint32 char_id) const {
|
uint8 BaseGuildManager::GetDisplayedRank(uint32 guild_id, uint8 rank, uint32 char_id) const {
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(3); //invalid guild rank
|
return(3); //invalid guild rank
|
||||||
@ -1243,7 +1244,7 @@ bool BaseGuildManager::CheckGMStatus(uint32 guild_id, uint8 status) const {
|
|||||||
return(true); //250+ as allowed anything
|
return(true); //250+ as allowed anything
|
||||||
}
|
}
|
||||||
|
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end()) {
|
if(res == m_guilds.end()) {
|
||||||
_log(GUILDS__PERMISSIONS, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status);
|
_log(GUILDS__PERMISSIONS, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status);
|
||||||
@ -1264,7 +1265,7 @@ bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction
|
|||||||
guild_id, rank, GuildActionNames[act], act);
|
guild_id, rank, GuildActionNames[act], act);
|
||||||
return(false); //invalid rank
|
return(false); //invalid rank
|
||||||
}
|
}
|
||||||
map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end()) {
|
if(res == m_guilds.end()) {
|
||||||
_log(GUILDS__PERMISSIONS, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.",
|
_log(GUILDS__PERMISSIONS, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.",
|
||||||
@ -1284,7 +1285,7 @@ bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) {
|
bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) {
|
||||||
map<uint32, GuildInfo *>::iterator res;
|
std::map<uint32, GuildInfo *>::iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end())
|
if(res == m_guilds.end())
|
||||||
return(false); //invalid guild
|
return(false); //invalid guild
|
||||||
@ -1293,7 +1294,7 @@ bool BaseGuildManager::LocalDeleteGuild(uint32 guild_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BaseGuildManager::ClearGuilds() {
|
void BaseGuildManager::ClearGuilds() {
|
||||||
map<uint32, GuildInfo *>::iterator cur, end;
|
std::map<uint32, GuildInfo *>::iterator cur, end;
|
||||||
cur = m_guilds.begin();
|
cur = m_guilds.begin();
|
||||||
end = m_guilds.end();
|
end = m_guilds.end();
|
||||||
for(; cur != end; cur++) {
|
for(; cur != end; cur++) {
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <string.h> /* for memcpy() */
|
#include <string.h> /* for memcpy() */
|
||||||
#include "../common/md5.h"
|
#include "../common/md5.h"
|
||||||
#include "../common/MiscFunctions.h"
|
#include "../common/StringUtil.h"
|
||||||
#include "../common/seperator.h"
|
#include "../common/seperator.h"
|
||||||
|
|
||||||
MD5::MD5() {
|
MD5::MD5() {
|
||||||
|
|||||||
@ -18,12 +18,10 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define ENC(c) (((c) & 0x3f) + ' ')
|
#define ENC(c) (((c) & 0x3f) + ' ')
|
||||||
#define DEC(c) (((c) - ' ') & 0x3f)
|
#define DEC(c) (((c) - ' ') & 0x3f)
|
||||||
|
|
||||||
map<int,string> DBFieldNames;
|
std::map<int,std::string> DBFieldNames;
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#if defined(FREEBSD) || defined(__CYGWIN__)
|
#if defined(FREEBSD) || defined(__CYGWIN__)
|
||||||
@ -44,9 +42,9 @@ int print_stacktrace()
|
|||||||
if (names != nullptr)
|
if (names != nullptr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
cerr << "called from " << (char*)names[0] << endl;
|
std::cerr << "called from " << (char*)names[0] << std::endl;
|
||||||
for (i = 1; i < n; ++i)
|
for (i = 1; i < n; ++i)
|
||||||
cerr << " " << (char*)names[i] << endl;
|
std::cerr << " " << (char*)names[i] << std::endl;
|
||||||
free (names);
|
free (names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,19 +53,19 @@ int print_stacktrace()
|
|||||||
#endif //!FREEBSD
|
#endif //!FREEBSD
|
||||||
#endif //!WIN32
|
#endif //!WIN32
|
||||||
|
|
||||||
void Unprotect(string &s, char what)
|
void Unprotect(std::string &s, char what)
|
||||||
{
|
{
|
||||||
if (s.length()) {
|
if (s.length()) {
|
||||||
for(string::size_type i=0;i<s.length()-1;i++) {
|
for(std::string::size_type i=0;i<s.length()-1;i++) {
|
||||||
if (s[i]=='\\' && s[i+1]==what)
|
if (s[i]=='\\' && s[i+1]==what)
|
||||||
s.erase(i,1);
|
s.erase(i,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Protect(string &s, char what)
|
void Protect(std::string &s, char what)
|
||||||
{
|
{
|
||||||
for(string::size_type i=0;i<s.length();i++) {
|
for(std::string::size_type i=0;i<s.length();i++) {
|
||||||
if (s[i]==what)
|
if (s[i]==what)
|
||||||
s.insert(i++,"\\");
|
s.insert(i++,"\\");
|
||||||
}
|
}
|
||||||
@ -77,11 +75,11 @@ void Protect(string &s, char what)
|
|||||||
item id -> fields_list
|
item id -> fields_list
|
||||||
each fields_list is a map of field index -> value
|
each fields_list is a map of field index -> value
|
||||||
*/
|
*/
|
||||||
bool ItemParse(const char *data, int length, map<int,map<int,string> > &items, int id_pos, int name_pos, int max_field, int level)
|
bool ItemParse(const char *data, int length, std::map<int,std::map<int,std::string> > &items, int id_pos, int name_pos, int max_field, int level)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *end,*ptr;
|
char *end,*ptr;
|
||||||
map<int,string> field;
|
std::map<int,std::string> field;
|
||||||
static char *buffer=nullptr;
|
static char *buffer=nullptr;
|
||||||
static int buffsize=0;
|
static int buffsize=0;
|
||||||
static char *temp=nullptr;
|
static char *temp=nullptr;
|
||||||
@ -102,7 +100,7 @@ static char *temp=nullptr;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!end) {
|
if (!end) {
|
||||||
cerr << "ItemParse: Level " << level << ": (1) Expected '|' not found near '" << ptr << "'" << endl;
|
std::cerr << "ItemParse: Level " << level << ": (1) Expected '|' not found near '" << ptr << "'" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
*end=0;
|
*end=0;
|
||||||
@ -114,7 +112,7 @@ static char *temp=nullptr;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*ptr!='"') {
|
if (*ptr!='"') {
|
||||||
cerr << "ItemParse: Level " << level << ": (2) Expected '\"' not found near '" << ptr << "'" << endl;
|
std::cerr << "ItemParse: Level " << level << ": (2) Expected '\"' not found near '" << ptr << "'" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
@ -126,7 +124,7 @@ static char *temp=nullptr;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!end) {
|
if (!end) {
|
||||||
cerr << "ItemParse: Level " << level << ": (1) Expected '|' not found near '" << ptr << "'" << endl;
|
std::cerr << "ItemParse: Level " << level << ": (1) Expected '|' not found near '" << ptr << "'" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
*end=0;
|
*end=0;
|
||||||
@ -145,12 +143,12 @@ static char *temp=nullptr;
|
|||||||
Unprotect(field[i],'|');
|
Unprotect(field[i],'|');
|
||||||
ptr+=length;
|
ptr+=length;
|
||||||
} else {
|
} else {
|
||||||
cerr << "ItemParse: Level " << level << ": (4) Expected '\"' not found near '" << ptr << "'" << endl;
|
std::cerr << "ItemParse: Level " << level << ": (4) Expected '\"' not found near '" << ptr << "'" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*ptr!='|') {
|
if (*ptr!='|') {
|
||||||
cerr << "ItemParse: Level " << level << ": (5) Expected '|' not found near '" << ptr << "'" << endl;
|
std::cerr << "ItemParse: Level " << level << ": (5) Expected '|' not found near '" << ptr << "'" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
@ -162,7 +160,7 @@ static char *temp=nullptr;
|
|||||||
end=ptr;
|
end=ptr;
|
||||||
while((end=strchr(end+1,'"'))!=nullptr && *(end-1)=='\\');
|
while((end=strchr(end+1,'"'))!=nullptr && *(end-1)=='\\');
|
||||||
if (end) {
|
if (end) {
|
||||||
string sub;
|
std::string sub;
|
||||||
sub.assign(ptr+1,end-ptr-1);
|
sub.assign(ptr+1,end-ptr-1);
|
||||||
Unprotect(sub,'"');
|
Unprotect(sub,'"');
|
||||||
if (!ItemParse(sub.c_str(),sub.length(),items,id_pos,name_pos,max_field,level+1)) {
|
if (!ItemParse(sub.c_str(),sub.length(),items,id_pos,name_pos,max_field,level+1)) {
|
||||||
@ -170,14 +168,14 @@ static char *temp=nullptr;
|
|||||||
}
|
}
|
||||||
ptr=end+1;
|
ptr=end+1;
|
||||||
} else {
|
} else {
|
||||||
cerr << "ItemParse: Level " << level << ": (6) Expected closing '\"' not found near '" << (ptr+1) << "'" << endl;
|
std::cerr << "ItemParse: Level " << level << ": (6) Expected closing '\"' not found near '" << (ptr+1) << "'" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*ptr=='|') {
|
if (*ptr=='|') {
|
||||||
ptr++;
|
ptr++;
|
||||||
} else if (i<9) {
|
} else if (i<9) {
|
||||||
cerr << "ItemParse: Level " << level << ": (7) Expected '|' (#" << i << ") not found near '" << ptr << "'" << endl;
|
std::cerr << "ItemParse: Level " << level << ": (7) Expected '|' (#" << i << ") not found near '" << ptr << "'" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,12 +183,12 @@ static char *temp=nullptr;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Tokenize(string s,map<int,string> & tokens, char delim)
|
int Tokenize(std::string s,std::map<int,std::string> & tokens, char delim)
|
||||||
{
|
{
|
||||||
int i,len;
|
int i,len;
|
||||||
string::size_type end;
|
std::string::size_type end;
|
||||||
//char temp[1024];
|
//char temp[1024];
|
||||||
string x;
|
std::string x;
|
||||||
tokens.clear();
|
tokens.clear();
|
||||||
i=0;
|
i=0;
|
||||||
while(s.length()) {
|
while(s.length()) {
|
||||||
@ -199,10 +197,10 @@ string x;
|
|||||||
tokens[i++]="";
|
tokens[i++]="";
|
||||||
} else {
|
} else {
|
||||||
end=0;
|
end=0;
|
||||||
while((end=s.find(delim,end+1))!=string::npos && s[end-1]=='\\');
|
while((end=s.find(delim,end+1))!=std::string::npos && s[end-1]=='\\');
|
||||||
if (end!=string::npos) {
|
if (end!=std::string::npos) {
|
||||||
x=s;
|
x=s;
|
||||||
x.erase(end,string::npos);
|
x.erase(end,std::string::npos);
|
||||||
s.erase(0,end+1);
|
s.erase(0,end+1);
|
||||||
Unprotect(x,'|');
|
Unprotect(x,'|');
|
||||||
tokens[i++]=x;
|
tokens[i++]=x;
|
||||||
@ -392,7 +390,7 @@ void decode_chunk(char *in, char *out)
|
|||||||
*(out+2) = DEC(in[2]) << 6 | DEC(in[3]);
|
*(out+2) = DEC(in[2]) << 6 | DEC(in[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_message_column(unsigned char *buffer, unsigned long length, string leader, FILE *to)
|
void dump_message_column(unsigned char *buffer, unsigned long length, std::string leader, FILE *to)
|
||||||
{
|
{
|
||||||
unsigned long i,j;
|
unsigned long i,j;
|
||||||
unsigned long rows,offset=0;
|
unsigned long rows,offset=0;
|
||||||
@ -418,7 +416,7 @@ unsigned long rows,offset=0;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string long2ip(unsigned long ip)
|
std::string long2ip(unsigned long ip)
|
||||||
{
|
{
|
||||||
char temp[16];
|
char temp[16];
|
||||||
union { unsigned long ip; struct { unsigned char a,b,c,d; } octet;} ipoctet;
|
union { unsigned long ip; struct { unsigned char a,b,c,d; } octet;} ipoctet;
|
||||||
@ -426,10 +424,10 @@ union { unsigned long ip; struct { unsigned char a,b,c,d; } octet;} ipoctet;
|
|||||||
ipoctet.ip=ip;
|
ipoctet.ip=ip;
|
||||||
sprintf(temp,"%d.%d.%d.%d",ipoctet.octet.a,ipoctet.octet.b,ipoctet.octet.c,ipoctet.octet.d);
|
sprintf(temp,"%d.%d.%d.%d",ipoctet.octet.a,ipoctet.octet.b,ipoctet.octet.c,ipoctet.octet.d);
|
||||||
|
|
||||||
return string(temp);
|
return std::string(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
string string_from_time(string pattern, time_t now)
|
std::string string_from_time(std::string pattern, time_t now)
|
||||||
{
|
{
|
||||||
struct tm *now_tm;
|
struct tm *now_tm;
|
||||||
char time_string[51];
|
char time_string[51];
|
||||||
@ -440,18 +438,18 @@ char time_string[51];
|
|||||||
|
|
||||||
strftime(time_string,51,pattern.c_str(),now_tm);
|
strftime(time_string,51,pattern.c_str(),now_tm);
|
||||||
|
|
||||||
return string(time_string);
|
return std::string(time_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
string timestamp(time_t now)
|
std::string timestamp(time_t now)
|
||||||
{
|
{
|
||||||
return string_from_time("[%Y%m%d.%H%M%S] ",now);
|
return string_from_time("[%Y%m%d.%H%M%S] ",now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string pop_arg(string &s, string seps, bool obey_quotes)
|
std::string pop_arg(std::string &s, std::string seps, bool obey_quotes)
|
||||||
{
|
{
|
||||||
string ret;
|
std::string ret;
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
bool in_quote=false;
|
bool in_quote=false;
|
||||||
|
|
||||||
@ -463,7 +461,7 @@ bool in_quote=false;
|
|||||||
}
|
}
|
||||||
if (in_quote)
|
if (in_quote)
|
||||||
continue;
|
continue;
|
||||||
if (seps.find(c)!=string::npos) {
|
if (seps.find(c)!=std::string::npos) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,9 +521,9 @@ char *bptr;
|
|||||||
return (bptr-buffer);
|
return (bptr-buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
string generate_key(int length)
|
std::string generate_key(int length)
|
||||||
{
|
{
|
||||||
string key;
|
std::string key;
|
||||||
//TODO: write this for win32...
|
//TODO: write this for win32...
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@ -5,17 +5,15 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define ITEMFIELDCOUNT 116
|
#define ITEMFIELDCOUNT 116
|
||||||
|
|
||||||
void Unprotect(string &s, char what);
|
void Unprotect(std::string &s, char what);
|
||||||
|
|
||||||
void Protect(string &s, char what);
|
void Protect(std::string &s, char what);
|
||||||
|
|
||||||
bool ItemParse(const char *data, int length, map<int,map<int,string> > &items, int id_pos, int name_pos, int max_field, int level=0);
|
bool ItemParse(const char *data, int length, std::map<int,std::map<int,std::string> > &items, int id_pos, int name_pos, int max_field, int level=0);
|
||||||
|
|
||||||
int Tokenize(string s, map<int,string> & tokens, char delim='|');
|
int Tokenize(std::string s, std::map<int,std::string> & tokens, char delim='|');
|
||||||
|
|
||||||
void LoadItemDBFieldNames();
|
void LoadItemDBFieldNames();
|
||||||
|
|
||||||
@ -30,13 +28,13 @@ void decode_chunk(char *in, char *out);
|
|||||||
int print_stacktrace();
|
int print_stacktrace();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dump_message_column(unsigned char *buffer, unsigned long length, string leader="", FILE *to = stdout);
|
void dump_message_column(unsigned char *buffer, unsigned long length, std::string leader="", FILE *to = stdout);
|
||||||
string string_from_time(string pattern, time_t now=0);
|
std::string string_from_time(std::string pattern, time_t now=0);
|
||||||
string timestamp(time_t now=0);
|
std::string timestamp(time_t now=0);
|
||||||
string long2ip(unsigned long ip);
|
std::string long2ip(unsigned long ip);
|
||||||
string pop_arg(string &s, string seps, bool obey_quotes);
|
std::string pop_arg(std::string &s, std::string seps, bool obey_quotes);
|
||||||
int EQsprintf(char *buffer, const char *pattern, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *arg6, const char *arg7, const char *arg8, const char *arg9);
|
int EQsprintf(char *buffer, const char *pattern, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *arg6, const char *arg7, const char *arg8, const char *arg9);
|
||||||
string generate_key(int length);
|
std::string generate_key(int length);
|
||||||
void build_hex_line(const char *buffer, unsigned long length, unsigned long offset, char *out_buffer, unsigned char padding=4);
|
void build_hex_line(const char *buffer, unsigned long length, unsigned long offset, char *out_buffer, unsigned char padding=4);
|
||||||
void print_hex(const char *buffer, unsigned long length);
|
void print_hex(const char *buffer, unsigned long length);
|
||||||
|
|
||||||
|
|||||||
@ -2,13 +2,11 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
std::map<unsigned long, std::string> opcode_map;
|
||||||
|
|
||||||
map<unsigned long, string> opcode_map;
|
std::string get_opcode_name(unsigned long opcode)
|
||||||
|
|
||||||
string get_opcode_name(unsigned long opcode)
|
|
||||||
{
|
{
|
||||||
map<unsigned long, string>::iterator itr;;
|
std::map<unsigned long, std::string>::iterator itr;;
|
||||||
|
|
||||||
return (itr=opcode_map.find(opcode))!=opcode_map.end() ? itr->second : "OP_Unknown";
|
return (itr=opcode_map.find(opcode))!=opcode_map.end() ? itr->second : "OP_Unknown";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
OpcodeManager::OpcodeManager() {
|
OpcodeManager::OpcodeManager() {
|
||||||
loaded = false;
|
loaded = false;
|
||||||
@ -38,7 +37,7 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
map<string, uint16> eq;
|
std::map<std::string, uint16> eq;
|
||||||
|
|
||||||
//load the opcode file into eq, could swap in a nice XML parser here
|
//load the opcode file into eq, could swap in a nice XML parser here
|
||||||
char line[2048];
|
char line[2048];
|
||||||
@ -82,7 +81,7 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
|
|||||||
//do the mapping and store them in the shared memory array
|
//do the mapping and store them in the shared memory array
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
EmuOpcode emu_op;
|
EmuOpcode emu_op;
|
||||||
map<string, uint16>::iterator res;
|
std::map<std::string, uint16>::iterator res;
|
||||||
//stupid enum wont let me ++ on it...
|
//stupid enum wont let me ++ on it...
|
||||||
for(emu_op = OP_Unknown; emu_op < _maxEmuOpcode; emu_op=(EmuOpcode)(emu_op+1)) {
|
for(emu_op = OP_Unknown; emu_op < _maxEmuOpcode; emu_op=(EmuOpcode)(emu_op+1)) {
|
||||||
//get the name of this emu opcode
|
//get the name of this emu opcode
|
||||||
@ -260,13 +259,13 @@ bool EmptyOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16 EmptyOpcodeManager::EmuToEQ(const EmuOpcode emu_op) {
|
uint16 EmptyOpcodeManager::EmuToEQ(const EmuOpcode emu_op) {
|
||||||
map<EmuOpcode, uint16>::iterator f;
|
std::map<EmuOpcode, uint16>::iterator f;
|
||||||
f = emu_to_eq.find(emu_op);
|
f = emu_to_eq.find(emu_op);
|
||||||
return(f == emu_to_eq.end()? 0 : f->second);
|
return(f == emu_to_eq.end()? 0 : f->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
EmuOpcode EmptyOpcodeManager::EQToEmu(const uint16 eq_op) {
|
EmuOpcode EmptyOpcodeManager::EQToEmu(const uint16 eq_op) {
|
||||||
map<uint16, EmuOpcode>::iterator f;
|
std::map<uint16, EmuOpcode>::iterator f;
|
||||||
f = eq_to_emu.find(eq_op);
|
f = eq_to_emu.find(eq_op);
|
||||||
return(f == eq_to_emu.end()?OP_Unknown:f->second);
|
return(f == eq_to_emu.end()?OP_Unknown:f->second);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,6 @@
|
|||||||
#include "emu_opcodes.h"
|
#include "emu_opcodes.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//enable the use of shared mem opcodes for world and zone only
|
//enable the use of shared mem opcodes for world and zone only
|
||||||
#ifdef ZONE
|
#ifdef ZONE
|
||||||
@ -156,8 +155,8 @@ public:
|
|||||||
//fake it, just used for testing anyways
|
//fake it, just used for testing anyways
|
||||||
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op);
|
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op);
|
||||||
protected:
|
protected:
|
||||||
map<EmuOpcode, uint16> emu_to_eq;
|
std::map<EmuOpcode, uint16> emu_to_eq;
|
||||||
map<uint16, EmuOpcode> eq_to_emu;
|
std::map<uint16, EmuOpcode> eq_to_emu;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -20,8 +20,6 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "packet_dump.h"
|
#include "packet_dump.h"
|
||||||
#include "EQPacket.h"
|
#include "EQPacket.h"
|
||||||
#include "../common/servertalk.h"
|
#include "../common/servertalk.h"
|
||||||
@ -32,22 +30,22 @@ void DumpPacketAscii(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
|||||||
{
|
{
|
||||||
if ((i-skip)%cols==0)
|
if ((i-skip)%cols==0)
|
||||||
{
|
{
|
||||||
cout << endl << setw(3) << setfill(' ') << i-skip << ":";
|
std::cout << std::endl << std::setw(3) << std::setfill(' ') << i-skip << ":";
|
||||||
}
|
}
|
||||||
else if ((i-skip)%(cols/2)==0)
|
else if ((i-skip)%(cols/2)==0)
|
||||||
{
|
{
|
||||||
cout << " - ";
|
std::cout << " - ";
|
||||||
}
|
}
|
||||||
if (buf[i] > 32 && buf[i] < 127)
|
if (buf[i] > 32 && buf[i] < 127)
|
||||||
{
|
{
|
||||||
cout << buf[i];
|
std::cout << buf[i];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cout << '.';
|
std::cout << '.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << endl << endl;
|
std::cout << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
||||||
@ -63,16 +61,16 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
|||||||
{
|
{
|
||||||
if ((i-skip)%cols==0) {
|
if ((i-skip)%cols==0) {
|
||||||
if (i != skip)
|
if (i != skip)
|
||||||
cout << " | " << ascii << endl;
|
std::cout << " | " << ascii << std::endl;
|
||||||
cout << setw(4) << setfill(' ') << i-skip << ": ";
|
std::cout << std::setw(4) << std::setfill(' ') << i-skip << ": ";
|
||||||
memset(ascii, 0, cols+1);
|
memset(ascii, 0, cols+1);
|
||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
else if ((i-skip)%(cols/2) == 0) {
|
else if ((i-skip)%(cols/2) == 0) {
|
||||||
cout << "- ";
|
std::cout << "- ";
|
||||||
}
|
}
|
||||||
sprintf(output, "%02X ", (unsigned char)buf[i]);
|
sprintf(output, "%02X ", (unsigned char)buf[i]);
|
||||||
cout << output;
|
std::cout << output;
|
||||||
|
|
||||||
if (buf[i] >= 32 && buf[i] < 127) {
|
if (buf[i] >= 32 && buf[i] < 127) {
|
||||||
ascii[j++] = buf[i];
|
ascii[j++] = buf[i];
|
||||||
@ -84,11 +82,11 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
|||||||
}
|
}
|
||||||
uint32 k = ((i-skip)-1)%cols;
|
uint32 k = ((i-skip)-1)%cols;
|
||||||
if (k < 8)
|
if (k < 8)
|
||||||
cout << " ";
|
std::cout << " ";
|
||||||
for (uint32 h = k+1; h < cols; h++) {
|
for (uint32 h = k+1; h < cols; h++) {
|
||||||
cout << " ";
|
std::cout << " ";
|
||||||
}
|
}
|
||||||
cout << " | " << ascii << endl;
|
std::cout << " | " << ascii << std::endl;
|
||||||
safe_delete_array(ascii);
|
safe_delete_array(ascii);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +98,8 @@ void DumpPacket(const uchar* buf, uint32 size)
|
|||||||
|
|
||||||
void DumpPacket(const ServerPacket* pack, bool iShowInfo) {
|
void DumpPacket(const ServerPacket* pack, bool iShowInfo) {
|
||||||
if (iShowInfo) {
|
if (iShowInfo) {
|
||||||
cout << "Dumping ServerPacket: 0x" << hex << setfill('0') << setw(4) << pack->opcode << dec;
|
std::cout << "Dumping ServerPacket: 0x" << std::hex << std::setfill('0') << std::setw(4) << pack->opcode << std::dec;
|
||||||
cout << " size:" << pack->size << endl;
|
std::cout << " size:" << pack->size << std::endl;
|
||||||
}
|
}
|
||||||
DumpPacketHex(pack->pBuffer, pack->size);
|
DumpPacketHex(pack->pBuffer, pack->size);
|
||||||
}
|
}
|
||||||
@ -131,66 +129,66 @@ void DumpPacketBin(const void* iData, uint32 len) {
|
|||||||
for (k=0; k<len; k++) {
|
for (k=0; k<len; k++) {
|
||||||
if (k % 4 == 0) {
|
if (k % 4 == 0) {
|
||||||
if (k != 0) {
|
if (k != 0) {
|
||||||
cout << " | " << hex << setw(2) << setfill('0') << (int) data[k-4] << dec;
|
std::cout << " | " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-4] << std::dec;
|
||||||
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-3] << dec;
|
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-3] << std::dec;
|
||||||
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-2] << dec;
|
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-2] << std::dec;
|
||||||
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-1] << dec;
|
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-1] << std::dec;
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
cout << setw(4) << setfill('0') << k << ":";
|
std::cout << std::setw(4) << std::setfill('0') << k << ":";
|
||||||
}
|
}
|
||||||
else if (k % 2 == 0)
|
else if (k % 2 == 0)
|
||||||
cout << " ";
|
std::cout << " ";
|
||||||
cout << " ";
|
std::cout << " ";
|
||||||
if (data[k] & 1)
|
if (data[k] & 1)
|
||||||
cout << "1";
|
std::cout << "1";
|
||||||
else
|
else
|
||||||
cout << "0";
|
std::cout << "0";
|
||||||
if (data[k] & 2)
|
if (data[k] & 2)
|
||||||
cout << "1";
|
std::cout << "1";
|
||||||
else
|
else
|
||||||
cout << "0";
|
std::cout << "0";
|
||||||
if (data[k] & 4)
|
if (data[k] & 4)
|
||||||
cout << "1";
|
std::cout << "1";
|
||||||
else
|
else
|
||||||
cout << "0";
|
std::cout << "0";
|
||||||
if (data[k] & 8)
|
if (data[k] & 8)
|
||||||
cout << "1";
|
std::cout << "1";
|
||||||
else
|
else
|
||||||
cout << "0";
|
std::cout << "0";
|
||||||
if (data[k] & 16)
|
if (data[k] & 16)
|
||||||
cout << "1";
|
std::cout << "1";
|
||||||
else
|
else
|
||||||
cout << "0";
|
std::cout << "0";
|
||||||
if (data[k] & 32)
|
if (data[k] & 32)
|
||||||
cout << "1";
|
std::cout << "1";
|
||||||
else
|
else
|
||||||
cout << "0";
|
std::cout << "0";
|
||||||
if (data[k] & 64)
|
if (data[k] & 64)
|
||||||
cout << "1";
|
std::cout << "1";
|
||||||
else
|
else
|
||||||
cout << "0";
|
std::cout << "0";
|
||||||
if (data[k] & 128)
|
if (data[k] & 128)
|
||||||
cout << "1";
|
std::cout << "1";
|
||||||
else
|
else
|
||||||
cout << "0";
|
std::cout << "0";
|
||||||
}
|
}
|
||||||
uint8 tmp = (k % 4);
|
uint8 tmp = (k % 4);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
tmp = 4;
|
tmp = 4;
|
||||||
if (tmp <= 3)
|
if (tmp <= 3)
|
||||||
cout << " ";
|
std::cout << " ";
|
||||||
if (tmp <= 2)
|
if (tmp <= 2)
|
||||||
cout << " ";
|
std::cout << " ";
|
||||||
if (tmp <= 1)
|
if (tmp <= 1)
|
||||||
cout << " ";
|
std::cout << " ";
|
||||||
cout << " | " << hex << setw(2) << setfill('0') << (int) data[k-4] << dec;
|
std::cout << " | " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-4] << std::dec;
|
||||||
if (tmp > 1)
|
if (tmp > 1)
|
||||||
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-3] << dec;
|
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-3] << std::dec;
|
||||||
if (tmp > 2)
|
if (tmp > 2)
|
||||||
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-2] << dec;
|
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-2] << std::dec;
|
||||||
if (tmp > 3)
|
if (tmp > 3)
|
||||||
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-1] << dec;
|
std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << (int) data[k-1] << std::dec;
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,9 +29,6 @@
|
|||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#if (_MSC_VER < 1500)
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
#endif
|
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#else
|
#else
|
||||||
@ -41,16 +38,14 @@
|
|||||||
#include "EQStream.h"
|
#include "EQStream.h"
|
||||||
#include "packet_dump_file.h"
|
#include "packet_dump_file.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
||||||
ofstream logfile(filename, ios::app);
|
std::ofstream logfile(filename, std::ios::app);
|
||||||
// Output as ASCII
|
// Output as ASCII
|
||||||
for(uint32 i=skip; i<size; i++)
|
for(uint32 i=skip; i<size; i++)
|
||||||
{
|
{
|
||||||
if ((i-skip)%cols==0)
|
if ((i-skip)%cols==0)
|
||||||
{
|
{
|
||||||
logfile << endl << setw(3) << setfill(' ') << i-skip << ":";
|
logfile << std::endl << std::setw(3) << std::setfill(' ') << i-skip << ":";
|
||||||
}
|
}
|
||||||
else if ((i-skip)%(cols/2)==0)
|
else if ((i-skip)%(cols/2)==0)
|
||||||
{
|
{
|
||||||
@ -65,19 +60,19 @@ void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, ui
|
|||||||
logfile << '.';
|
logfile << '.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logfile << endl << endl;
|
logfile << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip)
|
void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip)
|
||||||
{
|
{
|
||||||
ofstream logfile(filename, ios::app);
|
std::ofstream logfile(filename, std::ios::app);
|
||||||
// Output as HEX
|
// Output as HEX
|
||||||
char output[4];
|
char output[4];
|
||||||
for(uint32 i=skip; i<size; i++)
|
for(uint32 i=skip; i<size; i++)
|
||||||
{
|
{
|
||||||
if ((i-skip)%cols==0)
|
if ((i-skip)%cols==0)
|
||||||
{
|
{
|
||||||
logfile << endl << setw(3) << setfill(' ') << i-skip << ": ";
|
logfile << std::endl << std::setw(3) << std::setfill(' ') << i-skip << ": ";
|
||||||
}
|
}
|
||||||
else if ((i-skip)%(cols/2) == 0)
|
else if ((i-skip)%(cols/2) == 0)
|
||||||
{
|
{
|
||||||
@ -87,14 +82,14 @@ void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, u
|
|||||||
logfile << output;
|
logfile << output;
|
||||||
// logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " ";
|
// logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " ";
|
||||||
}
|
}
|
||||||
logfile << endl << endl;
|
logfile << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip)
|
void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip)
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return;
|
return;
|
||||||
ofstream logfile(filename, ios::app);
|
std::ofstream logfile(filename, std::ios::app);
|
||||||
// Output as HEX
|
// Output as HEX
|
||||||
char output[4];
|
char output[4];
|
||||||
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
|
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
|
||||||
@ -103,8 +98,8 @@ void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint
|
|||||||
{
|
{
|
||||||
if ((i-skip)%cols==0) {
|
if ((i-skip)%cols==0) {
|
||||||
if (i != skip)
|
if (i != skip)
|
||||||
logfile << " | " << ascii << endl;
|
logfile << " | " << ascii << std::endl;
|
||||||
logfile << setw(4) << setfill(' ') << i-skip << ": ";
|
logfile << std::setw(4) << std::setfill(' ') << i-skip << ": ";
|
||||||
memset(ascii, 0, cols+1);
|
memset(ascii, 0, cols+1);
|
||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
@ -128,7 +123,7 @@ void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint
|
|||||||
for (uint32 h = k+1; h < cols; h++) {
|
for (uint32 h = k+1; h < cols; h++) {
|
||||||
logfile << " ";
|
logfile << " ";
|
||||||
}
|
}
|
||||||
logfile << " | " << ascii << endl;
|
logfile << " | " << ascii << std::endl;
|
||||||
delete[] ascii;
|
delete[] ascii;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,13 +156,13 @@ void FileDumpPacket(const char* filename, const EQApplicationPacket* app)
|
|||||||
if prefix_timestamp specified, prints the current date/time to the file + ": " + text
|
if prefix_timestamp specified, prints the current date/time to the file + ": " + text
|
||||||
*/
|
*/
|
||||||
void FilePrintLine(const char* filename, bool prefix_timestamp, const char* text, ...) {
|
void FilePrintLine(const char* filename, bool prefix_timestamp, const char* text, ...) {
|
||||||
ofstream logfile(filename, ios::app);
|
std::ofstream logfile(filename, std::ios::app);
|
||||||
if (prefix_timestamp) {
|
if (prefix_timestamp) {
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm* gmt_t;
|
struct tm* gmt_t;
|
||||||
time(&rawtime);
|
time(&rawtime);
|
||||||
gmt_t = gmtime(&rawtime);
|
gmt_t = gmtime(&rawtime);
|
||||||
logfile << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec << " GMT";
|
logfile << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec << " GMT";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text != 0) {
|
if (text != 0) {
|
||||||
@ -181,17 +176,17 @@ void FilePrintLine(const char* filename, bool prefix_timestamp, const char* text
|
|||||||
logfile << ": ";
|
logfile << ": ";
|
||||||
logfile << buffer;
|
logfile << buffer;
|
||||||
}
|
}
|
||||||
logfile << endl;
|
logfile << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const char* text, ...) {
|
void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const char* text, ...) {
|
||||||
ofstream logfile(filename, ios::app);
|
std::ofstream logfile(filename, std::ios::app);
|
||||||
if (prefix_timestamp) {
|
if (prefix_timestamp) {
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm* gmt_t;
|
struct tm* gmt_t;
|
||||||
time(&rawtime);
|
time(&rawtime);
|
||||||
gmt_t = gmtime(&rawtime);
|
gmt_t = gmtime(&rawtime);
|
||||||
logfile << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec << " GMT";
|
logfile << (gmt_t->tm_year + 1900) << "/" << std::setw(2) << std::setfill('0') << (gmt_t->tm_mon + 1) << "/" << std::setw(2) << std::setfill('0') << gmt_t->tm_mday << " " << std::setw(2) << std::setfill('0') << gmt_t->tm_hour << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_min << ":" << std::setw(2) << std::setfill('0') << gmt_t->tm_sec << " GMT";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text != 0) {
|
if (text != 0) {
|
||||||
@ -207,6 +202,6 @@ void FilePrint(const char* filename, bool newline, bool prefix_timestamp, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newline)
|
if (newline)
|
||||||
logfile << endl;
|
logfile << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,6 @@
|
|||||||
#define PACKET_DUMP_FILE_H
|
#define PACKET_DUMP_FILE_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "../common/types.h"
|
#include "../common/types.h"
|
||||||
|
|
||||||
|
|||||||
@ -27,8 +27,6 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
void EncryptProfilePacket(EQApplicationPacket* app) {
|
void EncryptProfilePacket(EQApplicationPacket* app) {
|
||||||
//EncryptProfilePacket(app->pBuffer, app->size);
|
//EncryptProfilePacket(app->pBuffer, app->size);
|
||||||
}
|
}
|
||||||
@ -209,10 +207,10 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!iQuiet) {
|
if (!iQuiet) {
|
||||||
cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
|
std::cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
|
||||||
if (zstream.msg)
|
if (zstream.msg)
|
||||||
cout << zstream.msg;
|
std::cout << zstream.msg;
|
||||||
cout << "'" << endl;
|
std::cout << "'" << std::endl;
|
||||||
#ifdef EQDEBUG
|
#ifdef EQDEBUG
|
||||||
DumpPacket(indata-16, indatalen+16);
|
DumpPacket(indata-16, indatalen+16);
|
||||||
#endif
|
#endif
|
||||||
@ -254,10 +252,10 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!iQuiet) {
|
if (!iQuiet) {
|
||||||
cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
|
std::cout << "Error: InflatePacket: inflate() returned " << zerror << " '";
|
||||||
if (zstream.msg)
|
if (zstream.msg)
|
||||||
cout << zstream.msg;
|
std::cout << zstream.msg;
|
||||||
cout << "'" << endl;
|
std::cout << "'" << std::endl;
|
||||||
#ifdef EQDEBUG
|
#ifdef EQDEBUG
|
||||||
DumpPacket(indata-16, indatalen+16);
|
DumpPacket(indata-16, indatalen+16);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -13,9 +13,6 @@
|
|||||||
#include "../common/misc.h"
|
#include "../common/misc.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
PacketFileWriter::PacketFileWriter(bool _force_flush) {
|
PacketFileWriter::PacketFileWriter(bool _force_flush) {
|
||||||
out = NULL;
|
out = NULL;
|
||||||
force_flush = _force_flush;
|
force_flush = _force_flush;
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "../eq_packet_structs.h"
|
#include "../eq_packet_structs.h"
|
||||||
#include "../MiscFunctions.h"
|
#include "../MiscFunctions.h"
|
||||||
|
#include "../StringUtil.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../clientversions.h"
|
#include "../clientversions.h"
|
||||||
#include "Client62_structs.h"
|
#include "Client62_structs.h"
|
||||||
@ -24,7 +25,7 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if(opcodes == nullptr) {
|
if(opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
@ -39,17 +40,17 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//ok, now we have what we need to register.
|
//ok, now we have what we need to register.
|
||||||
|
|
||||||
EQStream::Signature signature;
|
EQStream::Signature signature;
|
||||||
string pname;
|
std::string pname;
|
||||||
|
|
||||||
//register our world signature.
|
//register our world signature.
|
||||||
pname = string(name) + "_world";
|
pname = std::string(name) + "_world";
|
||||||
signature.ignore_eq_opcode = 0;
|
signature.ignore_eq_opcode = 0;
|
||||||
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
||||||
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
||||||
|
|
||||||
//register our zone signature.
|
//register our zone signature.
|
||||||
pname = string(name) + "_zone";
|
pname = std::string(name) + "_zone";
|
||||||
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
||||||
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
||||||
@ -66,7 +67,7 @@ void Reload() {
|
|||||||
|
|
||||||
if(opcodes != nullptr) {
|
if(opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
@ -546,7 +547,7 @@ ENCODE(OP_CharInventory) {
|
|||||||
|
|
||||||
//do the transform...
|
//do the transform...
|
||||||
int r;
|
int r;
|
||||||
string serial_string;
|
std::string serial_string;
|
||||||
for(r = 0; r < itemcount; r++, eq++) {
|
for(r = 0; r < itemcount; r++, eq++) {
|
||||||
uint32 length;
|
uint32 length;
|
||||||
char *serialized=SerializeItem((ItemInst*)eq->inst,eq->slot_id,&length,0);
|
char *serialized=SerializeItem((ItemInst*)eq->inst,eq->slot_id,&length,0);
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "../eq_packet_structs.h"
|
#include "../eq_packet_structs.h"
|
||||||
#include "../MiscFunctions.h"
|
#include "../MiscFunctions.h"
|
||||||
|
#include "../StringUtil.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "RoF_structs.h"
|
#include "RoF_structs.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
@ -27,7 +28,7 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if(opcodes == nullptr) {
|
if(opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
@ -42,17 +43,17 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//ok, now we have what we need to register.
|
//ok, now we have what we need to register.
|
||||||
|
|
||||||
EQStream::Signature signature;
|
EQStream::Signature signature;
|
||||||
string pname;
|
std::string pname;
|
||||||
|
|
||||||
//register our world signature.
|
//register our world signature.
|
||||||
pname = string(name) + "_world";
|
pname = std::string(name) + "_world";
|
||||||
signature.ignore_eq_opcode = 0;
|
signature.ignore_eq_opcode = 0;
|
||||||
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
||||||
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
||||||
|
|
||||||
//register our zone signature.
|
//register our zone signature.
|
||||||
pname = string(name) + "_zone";
|
pname = std::string(name) + "_zone";
|
||||||
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
||||||
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
||||||
@ -71,7 +72,7 @@ void Reload() {
|
|||||||
|
|
||||||
if(opcodes != nullptr) {
|
if(opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "../eq_packet_structs.h"
|
#include "../eq_packet_structs.h"
|
||||||
#include "../MiscFunctions.h"
|
#include "../MiscFunctions.h"
|
||||||
|
#include "../StringUtil.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "SoD_structs.h"
|
#include "SoD_structs.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
@ -27,7 +28,7 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if(opcodes == nullptr) {
|
if(opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
@ -42,17 +43,17 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//ok, now we have what we need to register.
|
//ok, now we have what we need to register.
|
||||||
|
|
||||||
EQStream::Signature signature;
|
EQStream::Signature signature;
|
||||||
string pname;
|
std::string pname;
|
||||||
|
|
||||||
//register our world signature.
|
//register our world signature.
|
||||||
pname = string(name) + "_world";
|
pname = std::string(name) + "_world";
|
||||||
signature.ignore_eq_opcode = 0;
|
signature.ignore_eq_opcode = 0;
|
||||||
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
||||||
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
||||||
|
|
||||||
//register our zone signature.
|
//register our zone signature.
|
||||||
pname = string(name) + "_zone";
|
pname = std::string(name) + "_zone";
|
||||||
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
||||||
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
||||||
@ -71,7 +72,7 @@ void Reload() {
|
|||||||
|
|
||||||
if(opcodes != nullptr) {
|
if(opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#include "../crc32.h"
|
#include "../crc32.h"
|
||||||
|
|
||||||
#include "../eq_packet_structs.h"
|
#include "../eq_packet_structs.h"
|
||||||
#include "../MiscFunctions.h"
|
#include "../StringUtil.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "SoF_structs.h"
|
#include "SoF_structs.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
@ -27,7 +27,7 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if(opcodes == nullptr) {
|
if(opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
@ -42,17 +42,17 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//ok, now we have what we need to register.
|
//ok, now we have what we need to register.
|
||||||
|
|
||||||
EQStream::Signature signature;
|
EQStream::Signature signature;
|
||||||
string pname;
|
std::string pname;
|
||||||
|
|
||||||
//register our world signature.
|
//register our world signature.
|
||||||
pname = string(name) + "_world";
|
pname = std::string(name) + "_world";
|
||||||
signature.ignore_eq_opcode = 0;
|
signature.ignore_eq_opcode = 0;
|
||||||
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
||||||
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
||||||
|
|
||||||
//register our zone signature.
|
//register our zone signature.
|
||||||
pname = string(name) + "_zone";
|
pname = std::string(name) + "_zone";
|
||||||
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
||||||
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
||||||
@ -71,7 +71,7 @@ void Reload() {
|
|||||||
|
|
||||||
if(opcodes != nullptr) {
|
if(opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
#include "../races.h"
|
#include "../races.h"
|
||||||
|
|
||||||
#include "../eq_packet_structs.h"
|
#include "../eq_packet_structs.h"
|
||||||
#include "../MiscFunctions.h"
|
#include "../StringUtil.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "Titanium_structs.h"
|
#include "Titanium_structs.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -25,7 +25,7 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if(opcodes == nullptr) {
|
if(opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
@ -40,17 +40,17 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//ok, now we have what we need to register.
|
//ok, now we have what we need to register.
|
||||||
|
|
||||||
EQStream::Signature signature;
|
EQStream::Signature signature;
|
||||||
string pname;
|
std::string pname;
|
||||||
|
|
||||||
//register our world signature.
|
//register our world signature.
|
||||||
pname = string(name) + "_world";
|
pname = std::string(name) + "_world";
|
||||||
signature.ignore_eq_opcode = 0;
|
signature.ignore_eq_opcode = 0;
|
||||||
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
||||||
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
||||||
|
|
||||||
//register our zone signature.
|
//register our zone signature.
|
||||||
pname = string(name) + "_zone";
|
pname = std::string(name) + "_zone";
|
||||||
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
||||||
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
||||||
@ -69,7 +69,7 @@ void Reload() {
|
|||||||
|
|
||||||
if(opcodes != nullptr) {
|
if(opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
@ -639,7 +639,7 @@ ENCODE(OP_CharInventory) {
|
|||||||
|
|
||||||
//do the transform...
|
//do the transform...
|
||||||
int r;
|
int r;
|
||||||
string serial_string;
|
std::string serial_string;
|
||||||
for(r = 0; r < itemcount; r++, eq++) {
|
for(r = 0; r < itemcount; r++, eq++) {
|
||||||
uint32 length;
|
uint32 length;
|
||||||
char *serialized=SerializeItem((const ItemInst*)eq->inst,eq->slot_id,&length,0);
|
char *serialized=SerializeItem((const ItemInst*)eq->inst,eq->slot_id,&length,0);
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "../eq_packet_structs.h"
|
#include "../eq_packet_structs.h"
|
||||||
#include "../MiscFunctions.h"
|
#include "../MiscFunctions.h"
|
||||||
|
#include "../StringUtil.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "Underfoot_structs.h"
|
#include "Underfoot_structs.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
@ -28,7 +29,7 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if(opcodes == nullptr) {
|
if(opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
@ -43,17 +44,17 @@ void Register(EQStreamIdentifier &into) {
|
|||||||
//ok, now we have what we need to register.
|
//ok, now we have what we need to register.
|
||||||
|
|
||||||
EQStream::Signature signature;
|
EQStream::Signature signature;
|
||||||
string pname;
|
std::string pname;
|
||||||
|
|
||||||
//register our world signature.
|
//register our world signature.
|
||||||
pname = string(name) + "_world";
|
pname = std::string(name) + "_world";
|
||||||
signature.ignore_eq_opcode = 0;
|
signature.ignore_eq_opcode = 0;
|
||||||
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
signature.first_length = sizeof(structs::LoginInfo_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_SendLoginInfo);
|
||||||
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
||||||
|
|
||||||
//register our zone signature.
|
//register our zone signature.
|
||||||
pname = string(name) + "_zone";
|
pname = std::string(name) + "_zone";
|
||||||
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
signature.ignore_eq_opcode = opcodes->EmuToEQ(OP_AckPacket);
|
||||||
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
||||||
@ -72,7 +73,7 @@ void Reload() {
|
|||||||
|
|
||||||
if(opcodes != nullptr) {
|
if(opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
//TODO: get this file name from the config file
|
||||||
string opfile = "patch_";
|
std::string opfile = "patch_";
|
||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
|
|||||||
@ -139,7 +139,7 @@ XS(XS_EQDBRes_fetch_row_array)
|
|||||||
Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_array(THIS)");
|
Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_array(THIS)");
|
||||||
{
|
{
|
||||||
EQDBRes * THIS;
|
EQDBRes * THIS;
|
||||||
vector<string> RETVAL;
|
std::vector<std::string> RETVAL;
|
||||||
|
|
||||||
if (sv_derived_from(ST(0), "EQDBRes")) {
|
if (sv_derived_from(ST(0), "EQDBRes")) {
|
||||||
IV tmp = SvIV((SV*)SvRV(ST(0)));
|
IV tmp = SvIV((SV*)SvRV(ST(0)));
|
||||||
@ -160,7 +160,7 @@ XS(XS_EQDBRes_fetch_row_array)
|
|||||||
/* grow the stack to the number of elements being returned */
|
/* grow the stack to the number of elements being returned */
|
||||||
EXTEND(SP, RETVAL.size());
|
EXTEND(SP, RETVAL.size());
|
||||||
for (ix_RETVAL = 0; ix_RETVAL < RETVAL.size(); ix_RETVAL++) {
|
for (ix_RETVAL = 0; ix_RETVAL < RETVAL.size(); ix_RETVAL++) {
|
||||||
const string &it = RETVAL[ix_RETVAL];
|
const std::string &it = RETVAL[ix_RETVAL];
|
||||||
ST(ix_RETVAL) = sv_newmortal();
|
ST(ix_RETVAL) = sv_newmortal();
|
||||||
sv_setpvn(ST(ix_RETVAL), it.c_str(), it.length());
|
sv_setpvn(ST(ix_RETVAL), it.c_str(), it.length());
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ XS(XS_EQDBRes_fetch_row_hash)
|
|||||||
Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_hash(THIS)");
|
Perl_croak(aTHX_ "Usage: EQDBRes::fetch_row_hash(THIS)");
|
||||||
{
|
{
|
||||||
EQDBRes * THIS;
|
EQDBRes * THIS;
|
||||||
map<string,string> RETVAL;
|
std::map<std::string,std::string> RETVAL;
|
||||||
|
|
||||||
if (sv_derived_from(ST(0), "EQDBRes")) {
|
if (sv_derived_from(ST(0), "EQDBRes")) {
|
||||||
IV tmp = SvIV((SV*)SvRV(ST(0)));
|
IV tmp = SvIV((SV*)SvRV(ST(0)));
|
||||||
@ -199,7 +199,7 @@ XS(XS_EQDBRes_fetch_row_hash)
|
|||||||
sv_2mortal((SV*)hv);
|
sv_2mortal((SV*)hv);
|
||||||
ST(0) = newRV((SV*)hv);
|
ST(0) = newRV((SV*)hv);
|
||||||
|
|
||||||
map<string,string>::const_iterator cur, end;
|
std::map<std::string,std::string>::const_iterator cur, end;
|
||||||
cur = RETVAL.begin();
|
cur = RETVAL.begin();
|
||||||
end = RETVAL.end();
|
end = RETVAL.end();
|
||||||
for(; cur != end; cur++) {
|
for(; cur != end; cur++) {
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "ptimer.h"
|
#include "ptimer.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "MiscFunctions.h"
|
#include "StringUtil.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -289,7 +289,7 @@ PTimerList::PTimerList(uint32 char_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PTimerList::~PTimerList() {
|
PTimerList::~PTimerList() {
|
||||||
map<pTimerType, PersistentTimer *>::iterator s;
|
std::map<pTimerType, PersistentTimer *>::iterator s;
|
||||||
s = _list.begin();
|
s = _list.begin();
|
||||||
while(s != _list.end()) {
|
while(s != _list.end()) {
|
||||||
if(s->second != nullptr)
|
if(s->second != nullptr)
|
||||||
@ -300,7 +300,7 @@ PTimerList::~PTimerList() {
|
|||||||
|
|
||||||
|
|
||||||
bool PTimerList::Load(Database *db) {
|
bool PTimerList::Load(Database *db) {
|
||||||
map<pTimerType, PersistentTimer *>::iterator s;
|
std::map<pTimerType, PersistentTimer *>::iterator s;
|
||||||
s = _list.begin();
|
s = _list.begin();
|
||||||
while(s != _list.end()) {
|
while(s != _list.end()) {
|
||||||
if(s->second != nullptr)
|
if(s->second != nullptr)
|
||||||
@ -362,7 +362,7 @@ bool PTimerList::Store(Database *db) {
|
|||||||
printf("Storing all timers for char %lu\n", (unsigned long)_char_id);
|
printf("Storing all timers for char %lu\n", (unsigned long)_char_id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
map<pTimerType, PersistentTimer *>::iterator s;
|
std::map<pTimerType, PersistentTimer *>::iterator s;
|
||||||
s = _list.begin();
|
s = _list.begin();
|
||||||
bool res = true;
|
bool res = true;
|
||||||
while(s != _list.end()) {
|
while(s != _list.end()) {
|
||||||
@ -462,11 +462,11 @@ PersistentTimer *PTimerList::Get(pTimerType type) {
|
|||||||
return(_list[type]);
|
return(_list[type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PTimerList::ToVector(vector< pair<pTimerType, PersistentTimer *> > &out) {
|
void PTimerList::ToVector(std::vector< std::pair<pTimerType, PersistentTimer *> > &out) {
|
||||||
|
|
||||||
pair<pTimerType, PersistentTimer *> p;
|
std::pair<pTimerType, PersistentTimer *> p;
|
||||||
|
|
||||||
map<pTimerType, PersistentTimer *>::iterator s;
|
std::map<pTimerType, PersistentTimer *>::iterator s;
|
||||||
s = _list.begin();
|
s = _list.begin();
|
||||||
while(s != _list.end()) {
|
while(s != _list.end()) {
|
||||||
if(s->second != nullptr) {
|
if(s->second != nullptr) {
|
||||||
|
|||||||
@ -21,7 +21,6 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
enum { //values for pTimerType
|
enum { //values for pTimerType
|
||||||
pTimerStartAdventureTimer = 1,
|
pTimerStartAdventureTimer = 1,
|
||||||
@ -120,13 +119,13 @@ public:
|
|||||||
|
|
||||||
inline void SetCharID(uint32 char_id) { _char_id = char_id; }
|
inline void SetCharID(uint32 char_id) { _char_id = char_id; }
|
||||||
|
|
||||||
void ToVector(vector< pair<pTimerType, PersistentTimer *> > &out);
|
void ToVector(std::vector< std::pair<pTimerType, PersistentTimer *> > &out);
|
||||||
|
|
||||||
//Clear a timer for a char not logged in
|
//Clear a timer for a char not logged in
|
||||||
//this is not defined on a char which is logged in!
|
//this is not defined on a char which is logged in!
|
||||||
static bool ClearOffline(Database *db, uint32 char_id, pTimerType type);
|
static bool ClearOffline(Database *db, uint32 char_id, pTimerType type);
|
||||||
|
|
||||||
typedef map<pTimerType, PersistentTimer *>::iterator iterator;
|
typedef std::map<pTimerType, PersistentTimer *>::iterator iterator;
|
||||||
iterator begin() { return(_list.begin()); }
|
iterator begin() { return(_list.begin()); }
|
||||||
iterator end() { return(_list.end()); }
|
iterator end() { return(_list.end()); }
|
||||||
|
|
||||||
@ -135,7 +134,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
uint32 _char_id;
|
uint32 _char_id;
|
||||||
|
|
||||||
map<pTimerType, PersistentTimer *> _list;
|
std::map<pTimerType, PersistentTimer *> _list;
|
||||||
};
|
};
|
||||||
|
|
||||||
//code prettying macros
|
//code prettying macros
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#include "rulesys.h"
|
#include "rulesys.h"
|
||||||
#include "logsys.h"
|
#include "logsys.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "MiscFunctions.h"
|
#include "StringUtil.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "classes.h"
|
#include "classes.h"
|
||||||
#include "rulesys.h"
|
#include "rulesys.h"
|
||||||
#include "seperator.h"
|
#include "seperator.h"
|
||||||
#include "MiscFunctions.h"
|
#include "StringUtil.h"
|
||||||
#include "eq_packet_structs.h"
|
#include "eq_packet_structs.h"
|
||||||
#include "guilds.h"
|
#include "guilds.h"
|
||||||
#include "extprofile.h"
|
#include "extprofile.h"
|
||||||
@ -17,8 +17,6 @@
|
|||||||
#include "faction.h"
|
#include "faction.h"
|
||||||
#include "features.h"
|
#include "features.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
SharedDatabase::SharedDatabase()
|
SharedDatabase::SharedDatabase()
|
||||||
: Database(), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr), faction_mmf(nullptr), faction_hash(nullptr),
|
: Database(), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr), faction_mmf(nullptr), faction_hash(nullptr),
|
||||||
loot_table_mmf(nullptr), loot_table_hash(nullptr), loot_drop_mmf(nullptr), loot_drop_hash(nullptr)
|
loot_table_mmf(nullptr), loot_table_hash(nullptr), loot_drop_mmf(nullptr), loot_drop_hash(nullptr)
|
||||||
@ -50,7 +48,7 @@ bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET hideme = %i where id = %i", hideme, account_id), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET hideme = %i where id = %i", hideme, account_id), errbuf)) {
|
||||||
cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -85,7 +83,7 @@ uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
cerr << "Error in GetGMSpeed query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetGMSpeed query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -101,7 +99,7 @@ bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET gmspeed = %i where id = %i", gmspeed, account_id), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET gmspeed = %i where id = %i", gmspeed, account_id), errbuf)) {
|
||||||
cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -140,7 +138,7 @@ uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
|
|||||||
return EntitledTime;
|
return EntitledTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedDatabase::SaveCursor(uint32 char_id, list<ItemInst*>::const_iterator &start, list<ItemInst*>::const_iterator &end)
|
bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iterator &start, std::list<ItemInst*>::const_iterator &end)
|
||||||
{
|
{
|
||||||
iter_queue it;
|
iter_queue it;
|
||||||
int i;
|
int i;
|
||||||
@ -155,7 +153,7 @@ bool ret=true;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cout << "Clearing cursor failed: " << errbuf << endl;
|
std::cout << "Clearing cursor failed: " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
|
|
||||||
@ -337,8 +335,7 @@ int32 SharedDatabase::GetSharedPlatinum(uint32 account_id)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
std::cerr << "Error in GetSharedPlatinum query '" << query << "' " << errbuf << std::endl;
|
||||||
cerr << "Error in GetSharedPlatinum query '" << query << "' " << errbuf << endl;
|
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -352,7 +349,7 @@ bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add)
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i", amount_to_add, account_id), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i", amount_to_add, account_id), errbuf)) {
|
||||||
cerr << "Error in SetSharedPlatinum query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in SetSharedPlatinum query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1049,17 +1046,17 @@ const Item_Struct* SharedDatabase::IterateItems(uint32* id) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
string SharedDatabase::GetBook(const char *txtfile)
|
std::string SharedDatabase::GetBook(const char *txtfile)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
char txtfile2[20];
|
char txtfile2[20];
|
||||||
string txtout;
|
std::string txtout;
|
||||||
strcpy(txtfile2,txtfile);
|
strcpy(txtfile2,txtfile);
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT txtfile FROM books where name='%s'", txtfile2), errbuf, &result)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT txtfile FROM books where name='%s'", txtfile2), errbuf, &result)) {
|
||||||
cerr << "Error in GetBook query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetBook query '" << query << "' " << errbuf << std::endl;
|
||||||
if (query != 0)
|
if (query != 0)
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
txtout.assign(" ",1);
|
txtout.assign(" ",1);
|
||||||
@ -1399,7 +1396,7 @@ int32 SharedDatabase::DeleteStalePlayerBackups() {
|
|||||||
return affected_rows;
|
return affected_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedDatabase::GetCommandSettings(map<string,uint8> &commands) {
|
bool SharedDatabase::GetCommandSettings(std::map<std::string,uint8> &commands) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
@ -1415,7 +1412,7 @@ bool SharedDatabase::GetCommandSettings(map<string,uint8> &commands) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
cerr << "Error in GetCommands query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetCommands query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1973,7 +1970,7 @@ void SharedDatabase::GetPlayerInspectMessage(char* playername, InspectMessage_St
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in GetPlayerInspectMessage query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1984,7 +1981,7 @@ void SharedDatabase::SetPlayerInspectMessage(char* playername, const InspectMess
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET inspectmessage='%s' WHERE name='%s'", message->text, playername), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET inspectmessage='%s' WHERE name='%s'", message->text, playername), errbuf)) {
|
||||||
cerr << "Error in SetPlayerInspectMessage query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in SetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
@ -2008,7 +2005,7 @@ void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* m
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cerr << "Error in GetBotInspectMessage query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in GetBotInspectMessage query '" << query << "' " << errbuf << std::endl;
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2019,7 +2016,7 @@ void SharedDatabase::SetBotInspectMessage(uint32 botid, const InspectMessage_Str
|
|||||||
char *query = 0;
|
char *query = 0;
|
||||||
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE bots SET BotInspectMessage='%s' WHERE BotID=%i", message->text, botid), errbuf)) {
|
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE bots SET BotInspectMessage='%s' WHERE BotID=%i", message->text, botid), errbuf)) {
|
||||||
cerr << "Error in SetBotInspectMessage query '" << query << "' " << errbuf << endl;
|
std::cerr << "Error in SetBotInspectMessage query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public:
|
|||||||
void SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message);
|
void SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message);
|
||||||
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
|
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
|
||||||
void SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message);
|
void SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message);
|
||||||
bool GetCommandSettings(map<string,uint8> &commands);
|
bool GetCommandSettings(std::map<std::string,uint8> &commands);
|
||||||
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
|
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -65,7 +65,7 @@ public:
|
|||||||
bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin);
|
bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin);
|
||||||
|
|
||||||
|
|
||||||
string GetBook(const char *txtfile);
|
std::string GetBook(const char *txtfile);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Item Methods
|
* Item Methods
|
||||||
|
|||||||
@ -36,7 +36,7 @@ TimeoutManager::TimeoutManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TimeoutManager::CheckTimeouts() {
|
void TimeoutManager::CheckTimeouts() {
|
||||||
vector<Timeoutable *>::iterator cur,end;
|
std::vector<Timeoutable *>::iterator cur,end;
|
||||||
cur = members.begin();
|
cur = members.begin();
|
||||||
end = members.end();
|
end = members.end();
|
||||||
for(; cur != end; cur++) {
|
for(; cur != end; cur++) {
|
||||||
@ -66,7 +66,7 @@ void TimeoutManager::DeleteMember(Timeoutable *who) {
|
|||||||
#ifdef TIMEOUT_DEBUG
|
#ifdef TIMEOUT_DEBUG
|
||||||
LogFile->write(EQEMuLog::Debug, "Removing timeoutable 0x%x\n", who);
|
LogFile->write(EQEMuLog::Debug, "Removing timeoutable 0x%x\n", who);
|
||||||
#endif
|
#endif
|
||||||
vector<Timeoutable *>::iterator cur,end;
|
std::vector<Timeoutable *>::iterator cur,end;
|
||||||
cur = members.begin();
|
cur = members.begin();
|
||||||
end = members.end();
|
end = members.end();
|
||||||
for(; cur != end; cur++) {
|
for(; cur != end; cur++) {
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//timeoutable objects automatically register themselves
|
//timeoutable objects automatically register themselves
|
||||||
//with the global TimeoutManager object
|
//with the global TimeoutManager object
|
||||||
@ -59,7 +58,7 @@ protected:
|
|||||||
void AddMember(Timeoutable *who);
|
void AddMember(Timeoutable *who);
|
||||||
void DeleteMember(Timeoutable *who);
|
void DeleteMember(Timeoutable *who);
|
||||||
|
|
||||||
vector<Timeoutable *> members;
|
std::vector<Timeoutable *> members;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TimeoutManager timeout_manager;
|
extern TimeoutManager timeout_manager;
|
||||||
|
|||||||
@ -24,7 +24,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
@ -77,7 +76,7 @@ bool Timer::Check(bool iReset)
|
|||||||
{
|
{
|
||||||
_CP(Timer_Check);
|
_CP(Timer_Check);
|
||||||
if (this==0) {
|
if (this==0) {
|
||||||
cerr << "Null timer during ->Check()!?\n";
|
std::cerr << "Null timer during ->Check()!?\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// if (!current_time || !start_time || !timer_time) {cerr << "Timer::Check on a timer that does not have a vital member defined.";
|
// if (!current_time || !start_time || !timer_time) {cerr << "Timer::Check on a timer that does not have a vital member defined.";
|
||||||
|
|||||||
@ -68,9 +68,6 @@ typedef const char Const_char; //for perl XS
|
|||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#if (_MSC_VER < 1500)
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
#endif
|
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
typedef void ThreadReturnType;
|
typedef void ThreadReturnType;
|
||||||
@ -80,8 +77,8 @@ typedef const char Const_char; //for perl XS
|
|||||||
#define THREAD_RETURN(x) return(x);
|
#define THREAD_RETURN(x) return(x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define safe_delete(d) if(d) { delete d; d=0; }
|
#define safe_delete(d) if(d) { delete d; d=nullptr; }
|
||||||
#define safe_delete_array(d) if(d) { delete[] d; d=0; }
|
#define safe_delete_array(d) if(d) { delete[] d; d=nullptr; }
|
||||||
#define L32(i) ((uint32) i)
|
#define L32(i) ((uint32) i)
|
||||||
#define H32(i) ((uint32) (i >> 32))
|
#define H32(i) ((uint32) (i >> 32))
|
||||||
#define L16(i) ((uint16) i)
|
#define L16(i) ((uint16) i)
|
||||||
|
|||||||
@ -21,7 +21,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
using namespace std;
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|||||||
@ -18,7 +18,6 @@ INSTALL(TARGETS eqlaunch RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
|||||||
TARGET_LINK_LIBRARIES(eqlaunch Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
TARGET_LINK_LIBRARIES(eqlaunch Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||||
|
|
||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(eqlaunch PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
SET_TARGET_PROPERTIES(eqlaunch PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||||
TARGET_LINK_LIBRARIES(eqlaunch "Ws2_32.lib")
|
TARGET_LINK_LIBRARIES(eqlaunch "Ws2_32.lib")
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|||||||
@ -30,8 +30,6 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
bool RunLoops = false;
|
bool RunLoops = false;
|
||||||
|
|
||||||
void CatchSignal(int sig_num);
|
void CatchSignal(int sig_num);
|
||||||
@ -40,7 +38,7 @@ int main(int argc, char *argv[]) {
|
|||||||
RegisterExecutablePlatform(ExePlatformLaunch);
|
RegisterExecutablePlatform(ExePlatformLaunch);
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
string launcher_name;
|
std::string launcher_name;
|
||||||
if(argc == 2) {
|
if(argc == 2) {
|
||||||
launcher_name = argv[1];
|
launcher_name = argv[1];
|
||||||
}
|
}
|
||||||
@ -87,14 +85,14 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
map<string, ZoneLaunch *> zones;
|
std::map<std::string, ZoneLaunch *> zones;
|
||||||
WorldServer world(zones, launcher_name.c_str(), Config);
|
WorldServer world(zones, launcher_name.c_str(), Config);
|
||||||
if (!world.Connect()) {
|
if (!world.Connect()) {
|
||||||
_log(LAUNCHER__ERROR, "worldserver.Connect() FAILED! Will retry.");
|
_log(LAUNCHER__ERROR, "worldserver.Connect() FAILED! Will retry.");
|
||||||
}
|
}
|
||||||
|
|
||||||
map<string, ZoneLaunch *>::iterator zone, zend;
|
std::map<std::string, ZoneLaunch *>::iterator zone, zend;
|
||||||
set<string> to_remove;
|
std::set<std::string> to_remove;
|
||||||
|
|
||||||
Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect
|
Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect
|
||||||
|
|
||||||
@ -132,7 +130,7 @@ int main(int argc, char *argv[]) {
|
|||||||
* Kill off any zones which have stopped
|
* Kill off any zones which have stopped
|
||||||
*/
|
*/
|
||||||
while(!to_remove.empty()) {
|
while(!to_remove.empty()) {
|
||||||
string rem = *to_remove.begin();
|
std::string rem = *to_remove.begin();
|
||||||
to_remove.erase(rem);
|
to_remove.erase(rem);
|
||||||
zone = zones.find(rem);
|
zone = zones.find(rem);
|
||||||
if(zone == zones.end()) {
|
if(zone == zones.end()) {
|
||||||
|
|||||||
@ -20,9 +20,10 @@
|
|||||||
#include "../common/servertalk.h"
|
#include "../common/servertalk.h"
|
||||||
#include "ZoneLaunch.h"
|
#include "ZoneLaunch.h"
|
||||||
#include "../common/EQEmuConfig.h"
|
#include "../common/EQEmuConfig.h"
|
||||||
|
#include "../common/StringUtil.h"
|
||||||
|
|
||||||
|
|
||||||
WorldServer::WorldServer(map<string, ZoneLaunch *> &zones, const char *name, const EQEmuConfig *config)
|
WorldServer::WorldServer(std::map<std::string, ZoneLaunch *> &zones, const char *name, const EQEmuConfig *config)
|
||||||
: WorldConnection(EmuTCPConnection::packetModeLauncher, config->SharedKey.c_str()),
|
: WorldConnection(EmuTCPConnection::packetModeLauncher, config->SharedKey.c_str()),
|
||||||
m_name(name),
|
m_name(name),
|
||||||
m_config(config),
|
m_config(config),
|
||||||
@ -97,7 +98,7 @@ void WorldServer::Process() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ZR_Restart: {
|
case ZR_Restart: {
|
||||||
map<string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
|
std::map<std::string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
|
||||||
if(res == m_zones.end()) {
|
if(res == m_zones.end()) {
|
||||||
_log(LAUNCHER__ERROR, "World told us to restart zone %s, but it is not running.", lzr->short_name);
|
_log(LAUNCHER__ERROR, "World told us to restart zone %s, but it is not running.", lzr->short_name);
|
||||||
} else {
|
} else {
|
||||||
@ -107,7 +108,7 @@ void WorldServer::Process() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ZR_Stop: {
|
case ZR_Stop: {
|
||||||
map<string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
|
std::map<std::string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
|
||||||
if(res == m_zones.end()) {
|
if(res == m_zones.end()) {
|
||||||
_log(LAUNCHER__ERROR, "World told us to stop zone %s, but it is not running.", lzr->short_name);
|
_log(LAUNCHER__ERROR, "World told us to stop zone %s, but it is not running.", lzr->short_name);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -13,6 +13,7 @@ SET(eqlogin_sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
IF(MSVC OR MINGW)
|
IF(MSVC OR MINGW)
|
||||||
|
ADD_DEFINITIONS(-DNOMINMAX)
|
||||||
SET(eqlogin_sources ${eqlogin_sources} Encryption.cpp)
|
SET(eqlogin_sources ${eqlogin_sources} Encryption.cpp)
|
||||||
ENDIF(MSVC OR MINGW)
|
ENDIF(MSVC OR MINGW)
|
||||||
|
|
||||||
@ -45,7 +46,6 @@ INSTALL(TARGETS loginserver RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
|||||||
TARGET_LINK_LIBRARIES(loginserver Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE})
|
TARGET_LINK_LIBRARIES(loginserver Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE})
|
||||||
|
|
||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(loginserver PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
SET_TARGET_PROPERTIES(loginserver PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||||
TARGET_LINK_LIBRARIES(loginserver "Ws2_32.lib")
|
TARGET_LINK_LIBRARIES(loginserver "Ws2_32.lib")
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|||||||
@ -25,19 +25,19 @@ extern ErrorLog *server_log;
|
|||||||
* First gets the map from the title
|
* First gets the map from the title
|
||||||
* Then gets the argument from the map we got from title
|
* Then gets the argument from the map we got from title
|
||||||
*/
|
*/
|
||||||
string Config::GetVariable(string title, string parameter)
|
std::string Config::GetVariable(std::string title, std::string parameter)
|
||||||
{
|
{
|
||||||
map<string, map<string, string> >::iterator iter = vars.find(title);
|
std::map<std::string, std::map<std::string, std::string> >::iterator iter = vars.find(title);
|
||||||
if(iter != vars.end())
|
if(iter != vars.end())
|
||||||
{
|
{
|
||||||
map<string, string>::iterator arg_iter = iter->second.find(parameter);
|
std::map<std::string, std::string>::iterator arg_iter = iter->second.find(parameter);
|
||||||
if(arg_iter != iter->second.end())
|
if(arg_iter != iter->second.end())
|
||||||
{
|
{
|
||||||
return arg_iter->second;
|
return arg_iter->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string("");
|
return std::string("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,12 +56,12 @@ void Config::Parse(const char *file_name)
|
|||||||
FILE *input = fopen(file_name, "r");
|
FILE *input = fopen(file_name, "r");
|
||||||
if(input)
|
if(input)
|
||||||
{
|
{
|
||||||
list<string> tokens;
|
std::list<std::string> tokens;
|
||||||
Tokenize(input, tokens);
|
Tokenize(input, tokens);
|
||||||
|
|
||||||
char mode = 0;
|
char mode = 0;
|
||||||
string title, param, arg;
|
std::string title, param, arg;
|
||||||
list<string>::iterator iter = tokens.begin();
|
std::list<std::string>::iterator iter = tokens.begin();
|
||||||
while(iter != tokens.end())
|
while(iter != tokens.end())
|
||||||
{
|
{
|
||||||
if((*iter).compare("[") == 0)
|
if((*iter).compare("[") == 0)
|
||||||
@ -114,7 +114,7 @@ void Config::Parse(const char *file_name)
|
|||||||
{
|
{
|
||||||
arg = (*iter);
|
arg = (*iter);
|
||||||
mode = 0;
|
mode = 0;
|
||||||
map<string, map<string, string> >::iterator map_iter = vars.find(title);
|
std::map<std::string, std::map<std::string, std::string> >::iterator map_iter = vars.find(title);
|
||||||
if(map_iter != vars.end())
|
if(map_iter != vars.end())
|
||||||
{
|
{
|
||||||
map_iter->second[param] = arg;
|
map_iter->second[param] = arg;
|
||||||
@ -122,7 +122,7 @@ void Config::Parse(const char *file_name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
map<string, string> var_map;
|
std::map<std::string, std::string> var_map;
|
||||||
var_map[param] = arg;
|
var_map[param] = arg;
|
||||||
vars[title] = var_map;
|
vars[title] = var_map;
|
||||||
}
|
}
|
||||||
@ -142,10 +142,10 @@ void Config::Parse(const char *file_name)
|
|||||||
* Breaks up the input character stream into tokens and puts them into the list provided.
|
* Breaks up the input character stream into tokens and puts them into the list provided.
|
||||||
* Ignores # as a line comment
|
* Ignores # as a line comment
|
||||||
*/
|
*/
|
||||||
void Config::Tokenize(FILE *input, list<string> &tokens)
|
void Config::Tokenize(FILE *input, std::list<std::string> &tokens)
|
||||||
{
|
{
|
||||||
char c = fgetc(input);
|
char c = fgetc(input);
|
||||||
string lexeme;
|
std::string lexeme;
|
||||||
|
|
||||||
while(c != EOF)
|
while(c != EOF)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -23,8 +23,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps track of all the configuration for the application with a small parser.
|
* Keeps track of all the configuration for the application with a small parser.
|
||||||
* Note: This is not a thread safe class, but only parse writes to variables in the class.
|
* Note: This is not a thread safe class, but only parse writes to variables in the class.
|
||||||
@ -44,10 +42,10 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Gets a variable if it exists.
|
* Gets a variable if it exists.
|
||||||
*/
|
*/
|
||||||
string GetVariable(string title, string parameter);
|
std::string GetVariable(std::string title, std::string parameter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
map<string, map<string, string> > vars;
|
std::map<std::string, std::map<std::string, std::string> > vars;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -56,7 +54,7 @@ private:
|
|||||||
* may get it's input from other places than a C file pointer. (a http get request for example).
|
* may get it's input from other places than a C file pointer. (a http get request for example).
|
||||||
* The programmer of a derived class would be expected to make their own Tokenize function for their own Parse().
|
* The programmer of a derived class would be expected to make their own Tokenize function for their own Parse().
|
||||||
*/
|
*/
|
||||||
void Tokenize(FILE* input, list<string> &tokens);
|
void Tokenize(FILE* input, std::list<std::string> &tokens);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define EQEMU_MYSQL_ENABLED
|
#define EQEMU_MYSQL_ENABLED
|
||||||
//#define EQEMU_POSTGRESQL_ENABLED
|
//#define EQEMU_POSTGRESQL_ENABLED
|
||||||
|
|
||||||
@ -44,37 +42,37 @@ public:
|
|||||||
* Needed for client login procedure.
|
* Needed for client login procedure.
|
||||||
* Returns true if the record was found, false otherwise.
|
* Returns true if the record was found, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool GetLoginDataFromAccountName(string name, string &password, unsigned int &id) { return false; }
|
virtual bool GetLoginDataFromAccountName(std::string name, std::string &password, unsigned int &id) { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the world registration from the long and short names provided.
|
* Retrieves the world registration from the long and short names provided.
|
||||||
* Needed for world login procedure.
|
* Needed for world login procedure.
|
||||||
* Returns true if the record was found, false otherwise.
|
* Returns true if the record was found, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool GetWorldRegistration(string long_name, string short_name, unsigned int &id, string &desc, unsigned int &list_id,
|
virtual bool GetWorldRegistration(std::string long_name, std::string short_name, unsigned int &id, std::string &desc, unsigned int &list_id,
|
||||||
unsigned int &trusted, string &list_desc, string &account, string &password) { return false; }
|
unsigned int &trusted, std::string &list_desc, std::string &account, std::string &password) { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the ip address of the client with account id = id
|
* Updates the ip address of the client with account id = id
|
||||||
*/
|
*/
|
||||||
virtual void UpdateLSAccountData(unsigned int id, string ip_address) { }
|
virtual void UpdateLSAccountData(unsigned int id, std::string ip_address) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates or creates the login server account with info from world server
|
* Updates or creates the login server account with info from world server
|
||||||
*/
|
*/
|
||||||
virtual void UpdateLSAccountInfo(unsigned int id, string name, string password, string email) { }
|
virtual void UpdateLSAccountInfo(unsigned int id, std::string name, std::string password, std::string email) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the ip address of the world with account id = id
|
* Updates the ip address of the world with account id = id
|
||||||
*/
|
*/
|
||||||
virtual void UpdateWorldRegistration(unsigned int id, string long_name, string ip_address) { }
|
virtual void UpdateWorldRegistration(unsigned int id, std::string long_name, std::string ip_address) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new world registration for unregistered servers and returns new id
|
* Creates new world registration for unregistered servers and returns new id
|
||||||
*/
|
*/
|
||||||
virtual bool CreateWorldRegistration(string long_name, string short_name, unsigned int &id) { return false; }
|
virtual bool CreateWorldRegistration(std::string long_name, std::string short_name, unsigned int &id) { return false; }
|
||||||
protected:
|
protected:
|
||||||
string user, pass, host, port, name;
|
std::string user, pass, host, port, name;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -26,8 +26,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mysql Database class
|
* Mysql Database class
|
||||||
*/
|
*/
|
||||||
@ -42,7 +40,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Constructor, tries to set our database to connect to the supplied options.
|
* Constructor, tries to set our database to connect to the supplied options.
|
||||||
*/
|
*/
|
||||||
DatabaseMySQL(string user, string pass, string host, string port, string name);
|
DatabaseMySQL(std::string user, std::string pass, std::string host, std::string port, std::string name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor, frees our database if needed.
|
* Destructor, frees our database if needed.
|
||||||
@ -59,37 +57,37 @@ public:
|
|||||||
* Needed for client login procedure.
|
* Needed for client login procedure.
|
||||||
* Returns true if the record was found, false otherwise.
|
* Returns true if the record was found, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool GetLoginDataFromAccountName(string name, string &password, unsigned int &id);
|
virtual bool GetLoginDataFromAccountName(std::string name, std::string &password, unsigned int &id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the world registration from the long and short names provided.
|
* Retrieves the world registration from the long and short names provided.
|
||||||
* Needed for world login procedure.
|
* Needed for world login procedure.
|
||||||
* Returns true if the record was found, false otherwise.
|
* Returns true if the record was found, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool GetWorldRegistration(string long_name, string short_name, unsigned int &id, string &desc, unsigned int &list_id,
|
virtual bool GetWorldRegistration(std::string long_name, std::string short_name, unsigned int &id, std::string &desc, unsigned int &list_id,
|
||||||
unsigned int &trusted, string &list_desc, string &account, string &password);
|
unsigned int &trusted, std::string &list_desc, std::string &account, std::string &password);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the ip address of the client with account id = id
|
* Updates the ip address of the client with account id = id
|
||||||
*/
|
*/
|
||||||
virtual void UpdateLSAccountData(unsigned int id, string ip_address);
|
virtual void UpdateLSAccountData(unsigned int id, std::string ip_address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates or creates the login server account with info from world server
|
* Updates or creates the login server account with info from world server
|
||||||
*/
|
*/
|
||||||
virtual void UpdateLSAccountInfo(unsigned int id, string name, string password, string email);
|
virtual void UpdateLSAccountInfo(unsigned int id, std::string name, std::string password, std::string email);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the ip address of the world with account id = id
|
* Updates the ip address of the world with account id = id
|
||||||
*/
|
*/
|
||||||
virtual void UpdateWorldRegistration(unsigned int id, string long_name, string ip_address);
|
virtual void UpdateWorldRegistration(unsigned int id, std::string long_name, std::string ip_address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new world registration for unregistered servers and returns new id
|
* Creates new world registration for unregistered servers and returns new id
|
||||||
*/
|
*/
|
||||||
virtual bool CreateWorldRegistration(string long_name, string short_name, unsigned int &id);
|
virtual bool CreateWorldRegistration(std::string long_name, std::string short_name, unsigned int &id);
|
||||||
protected:
|
protected:
|
||||||
string user, pass, host, port, name;
|
std::string user, pass, host, port, name;
|
||||||
MYSQL *db;
|
MYSQL *db;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -18,10 +18,11 @@
|
|||||||
#include "../common/debug.h"
|
#include "../common/debug.h"
|
||||||
#include "Encryption.h"
|
#include "Encryption.h"
|
||||||
#include "ErrorLog.h"
|
#include "ErrorLog.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
extern ErrorLog *server_log;
|
extern ErrorLog *server_log;
|
||||||
|
|
||||||
bool Encryption::LoadCrypto(string name)
|
bool Encryption::LoadCrypto(std::string name)
|
||||||
{
|
{
|
||||||
if(!Load(name.c_str()))
|
if(!Load(name.c_str()))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,8 +22,6 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
typedef char*(*DLLFUNC_DecryptUsernamePassword)(const char*, unsigned int, int);
|
typedef char*(*DLLFUNC_DecryptUsernamePassword)(const char*, unsigned int, int);
|
||||||
typedef char*(*DLLFUNC_Encrypt)(const char*, unsigned int, unsigned int&);
|
typedef char*(*DLLFUNC_Encrypt)(const char*, unsigned int, unsigned int&);
|
||||||
typedef void(*DLLFUNC_HeapDelete)(char*);
|
typedef void(*DLLFUNC_HeapDelete)(char*);
|
||||||
@ -54,7 +52,7 @@ public:
|
|||||||
* Loads the plugin.
|
* Loads the plugin.
|
||||||
* True if there are no errors, false if there was an error.
|
* True if there are no errors, false if there was an error.
|
||||||
*/
|
*/
|
||||||
bool LoadCrypto(string name);
|
bool LoadCrypto(std::string name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around the plugin's decrypt function.
|
* Wrapper around the plugin's decrypt function.
|
||||||
|
|||||||
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#include "../common/Mutex.h"
|
#include "../common/Mutex.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dictates the log type specified in ErrorLog for Log(...)
|
* Dictates the log type specified in ErrorLog for Log(...)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -32,7 +32,6 @@ TimeoutManager timeout_manager;
|
|||||||
LoginServer server;
|
LoginServer server;
|
||||||
ErrorLog *server_log;
|
ErrorLog *server_log;
|
||||||
bool run_server = true;
|
bool run_server = true;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
void CatchSignal(int sig_num)
|
void CatchSignal(int sig_num)
|
||||||
{
|
{
|
||||||
@ -45,7 +44,7 @@ int main()
|
|||||||
|
|
||||||
//Create our error log, is of format login_<number>.log
|
//Create our error log, is of format login_<number>.log
|
||||||
time_t current_time = time(nullptr);
|
time_t current_time = time(nullptr);
|
||||||
stringstream log_name(stringstream::in | stringstream::out);
|
std::stringstream log_name(std::stringstream::in | std::stringstream::out);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
log_name << ".\\logs\\login_" << (unsigned int)current_time << ".log";
|
log_name << ".\\logs\\login_" << (unsigned int)current_time << ".log";
|
||||||
#else
|
#else
|
||||||
@ -90,14 +89,14 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Parse encryption mode option.
|
//Parse encryption mode option.
|
||||||
string mode = server.config->GetVariable("security", "mode");
|
std::string mode = server.config->GetVariable("security", "mode");
|
||||||
if(mode.size() > 0)
|
if(mode.size() > 0)
|
||||||
{
|
{
|
||||||
server.options.EncryptionMode(atoi(mode.c_str()));
|
server.options.EncryptionMode(atoi(mode.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Parse local network option.
|
//Parse local network option.
|
||||||
string ln = server.config->GetVariable("options", "local_network");
|
std::string ln = server.config->GetVariable("options", "local_network");
|
||||||
if(ln.size() > 0)
|
if(ln.size() > 0)
|
||||||
{
|
{
|
||||||
server.options.LocalNetwork(ln);
|
server.options.LocalNetwork(ln);
|
||||||
|
|||||||
@ -100,52 +100,52 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Sets local_network.
|
* Sets local_network.
|
||||||
*/
|
*/
|
||||||
inline void LocalNetwork(string n) { local_network = n; }
|
inline void LocalNetwork(std::string n) { local_network = n; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the value of local_network.
|
* Return the value of local_network.
|
||||||
*/
|
*/
|
||||||
inline string GetLocalNetwork() const { return local_network; }
|
inline std::string GetLocalNetwork() const { return local_network; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets account table.
|
* Sets account table.
|
||||||
*/
|
*/
|
||||||
inline void AccountTable(string t) { account_table = t; }
|
inline void AccountTable(std::string t) { account_table = t; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the value of local_network.
|
* Return the value of local_network.
|
||||||
*/
|
*/
|
||||||
inline string GetAccountTable() const { return account_table; }
|
inline std::string GetAccountTable() const { return account_table; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets world account table.
|
* Sets world account table.
|
||||||
*/
|
*/
|
||||||
inline void WorldRegistrationTable(string t) { world_registration_table = t; }
|
inline void WorldRegistrationTable(std::string t) { world_registration_table = t; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the value of world account table.
|
* Return the value of world account table.
|
||||||
*/
|
*/
|
||||||
inline string GetWorldRegistrationTable() const { return world_registration_table; }
|
inline std::string GetWorldRegistrationTable() const { return world_registration_table; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets world admin account table.
|
* Sets world admin account table.
|
||||||
*/
|
*/
|
||||||
inline void WorldAdminRegistrationTable(string t) { world_admin_registration_table = t; }
|
inline void WorldAdminRegistrationTable(std::string t) { world_admin_registration_table = t; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the value of world admin account table.
|
* Return the value of world admin account table.
|
||||||
*/
|
*/
|
||||||
inline string GetWorldAdminRegistrationTable() const { return world_admin_registration_table; }
|
inline std::string GetWorldAdminRegistrationTable() const { return world_admin_registration_table; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets world server type table.
|
* Sets world server type table.
|
||||||
*/
|
*/
|
||||||
inline void WorldServerTypeTable(string t) { world_server_type_table = t; }
|
inline void WorldServerTypeTable(std::string t) { world_server_type_table = t; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the value of world admin account table.
|
* Return the value of world admin account table.
|
||||||
*/
|
*/
|
||||||
inline string GetWorldServerTypeTable() const { return world_server_type_table; }
|
inline std::string GetWorldServerTypeTable() const { return world_server_type_table; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether we are rejecting duplicate servers or not.
|
* Sets whether we are rejecting duplicate servers or not.
|
||||||
@ -165,11 +165,11 @@ private:
|
|||||||
bool dump_out_packets;
|
bool dump_out_packets;
|
||||||
bool reject_duplicate_servers;
|
bool reject_duplicate_servers;
|
||||||
int encryption_mode;
|
int encryption_mode;
|
||||||
string local_network;
|
std::string local_network;
|
||||||
string account_table;
|
std::string account_table;
|
||||||
string world_registration_table;
|
std::string world_registration_table;
|
||||||
string world_admin_registration_table;
|
std::string world_admin_registration_table;
|
||||||
string world_server_type_table;
|
std::string world_server_type_table;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -28,8 +28,6 @@
|
|||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server manager class, deals with management of the world servers.
|
* Server manager class, deals with management of the world servers.
|
||||||
*/
|
*/
|
||||||
@ -64,12 +62,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Checks to see if there is a server exists with this name, ignoring option.
|
* Checks to see if there is a server exists with this name, ignoring option.
|
||||||
*/
|
*/
|
||||||
bool ServerExists(string l_name, string s_name, WorldServer *ignore = nullptr);
|
bool ServerExists(std::string l_name, std::string s_name, WorldServer *ignore = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys a server with this name, ignoring option.
|
* Destroys a server with this name, ignoring option.
|
||||||
*/
|
*/
|
||||||
void DestroyServerByName(string l_name, string s_name, WorldServer *ignore = nullptr);
|
void DestroyServerByName(std::string l_name, std::string s_name, WorldServer *ignore = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -84,7 +82,7 @@ private:
|
|||||||
WorldServer* GetServerByAddress(unsigned int address);
|
WorldServer* GetServerByAddress(unsigned int address);
|
||||||
|
|
||||||
EmuTCPServer* tcps;
|
EmuTCPServer* tcps;
|
||||||
list<WorldServer*> world_servers;
|
std::list<WorldServer*> world_servers;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -26,8 +26,6 @@
|
|||||||
#include "../common/packet_dump.h"
|
#include "../common/packet_dump.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* World server class, controls the connected server processing.
|
* World server class, controls the connected server processing.
|
||||||
*/
|
*/
|
||||||
@ -78,12 +76,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Gets the long name of the server.
|
* Gets the long name of the server.
|
||||||
*/
|
*/
|
||||||
string GetLongName() const { return long_name; }
|
std::string GetLongName() const { return long_name; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the short name of the server.
|
* Gets the short name of the server.
|
||||||
*/
|
*/
|
||||||
string GetShortName() const { return short_name; }
|
std::string GetShortName() const { return short_name; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether the server is authorized to show up on the server list or not.
|
* Gets whether the server is authorized to show up on the server list or not.
|
||||||
@ -93,12 +91,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Gets the local ip of the server.
|
* Gets the local ip of the server.
|
||||||
*/
|
*/
|
||||||
string GetLocalIP() const { return local_ip; }
|
std::string GetLocalIP() const { return local_ip; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the remote ip of the server.
|
* Gets the remote ip of the server.
|
||||||
*/
|
*/
|
||||||
string GetRemoteIP() const { return remote_ip; }
|
std::string GetRemoteIP() const { return remote_ip; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets what kind of server this server is (legends, preferred, normal)
|
* Gets what kind of server this server is (legends, preferred, normal)
|
||||||
@ -133,7 +131,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Informs world that there is a client incoming with the following data.
|
* Informs world that there is a client incoming with the following data.
|
||||||
*/
|
*/
|
||||||
void SendClientAuth(unsigned int ip, string account, string key, unsigned int account_id);
|
void SendClientAuth(unsigned int ip, std::string account, std::string key, unsigned int account_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -144,15 +142,15 @@ private:
|
|||||||
unsigned int runtime_id;
|
unsigned int runtime_id;
|
||||||
unsigned int server_list_id;
|
unsigned int server_list_id;
|
||||||
unsigned int server_type;
|
unsigned int server_type;
|
||||||
string desc;
|
std::string desc;
|
||||||
string long_name;
|
std::string long_name;
|
||||||
string short_name;
|
std::string short_name;
|
||||||
string account_name;
|
std::string account_name;
|
||||||
string account_password;
|
std::string account_password;
|
||||||
string remote_ip;
|
std::string remote_ip;
|
||||||
string local_ip;
|
std::string local_ip;
|
||||||
string protocol;
|
std::string protocol;
|
||||||
string version;
|
std::string version;
|
||||||
bool authorized;
|
bool authorized;
|
||||||
bool logged_in;
|
bool logged_in;
|
||||||
bool trusted;
|
bool trusted;
|
||||||
|
|||||||
@ -24,7 +24,6 @@ ADD_DEFINITIONS(-DQSERV)
|
|||||||
TARGET_LINK_LIBRARIES(queryserv Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
TARGET_LINK_LIBRARIES(queryserv Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||||
|
|
||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(queryserv PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
SET_TARGET_PROPERTIES(queryserv PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||||
TARGET_LINK_LIBRARIES(queryserv "Ws2_32.lib")
|
TARGET_LINK_LIBRARIES(queryserv "Ws2_32.lib")
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "../common/debug.h"
|
#include "../common/debug.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -44,7 +43,7 @@ using namespace std;
|
|||||||
|
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "../common/eq_packet_structs.h"
|
#include "../common/eq_packet_structs.h"
|
||||||
#include "../common/MiscFunctions.h"
|
#include "../common/StringUtil.h"
|
||||||
#include "../common/servertalk.h"
|
#include "../common/servertalk.h"
|
||||||
|
|
||||||
Database::Database ()
|
Database::Database ()
|
||||||
|
|||||||
@ -31,7 +31,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//atoi is not uint32 or uint32 safe!!!!
|
//atoi is not uint32 or uint32 safe!!!!
|
||||||
#define atoul(str) strtoul(str, nullptr, 10)
|
#define atoul(str) strtoul(str, nullptr, 10)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
#include "lfguild.h"
|
#include "lfguild.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "worldserver.h"
|
#include "worldserver.h"
|
||||||
#include "../common/MiscFunctions.h"
|
#include "../common/StringUtil.h"
|
||||||
#include "../common/packet_dump.h"
|
#include "../common/packet_dump.h"
|
||||||
#include "../common/rulesys.h"
|
#include "../common/rulesys.h"
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ TimeoutManager timeout_manager;
|
|||||||
|
|
||||||
Database database;
|
Database database;
|
||||||
LFGuildManager lfguildmanager;
|
LFGuildManager lfguildmanager;
|
||||||
string WorldShortName;
|
std::string WorldShortName;
|
||||||
|
|
||||||
const queryservconfig *Config;
|
const queryservconfig *Config;
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
queryservconfig *queryservconfig::_chat_config = nullptr;
|
queryservconfig *queryservconfig::_chat_config = nullptr;
|
||||||
|
|
||||||
string queryservconfig::GetByName(const string &var_name) const {
|
std::string queryservconfig::GetByName(const std::string &var_name) const {
|
||||||
return(EQEmuConfig::GetByName(var_name));
|
return(EQEmuConfig::GetByName(var_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
class queryservconfig : public EQEmuConfig {
|
class queryservconfig : public EQEmuConfig {
|
||||||
public:
|
public:
|
||||||
virtual string GetByName(const string &var_name) const;
|
virtual std::string GetByName(const std::string &var_name) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "../common/debug.h"
|
#include "../common/debug.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -81,8 +80,8 @@ void WorldServer::Process()
|
|||||||
{
|
{
|
||||||
Server_Speech_Struct *SSS = (Server_Speech_Struct*)pack->pBuffer;
|
Server_Speech_Struct *SSS = (Server_Speech_Struct*)pack->pBuffer;
|
||||||
|
|
||||||
string tmp1 = SSS->from;
|
std::string tmp1 = SSS->from;
|
||||||
string tmp2 = SSS->to;
|
std::string tmp2 = SSS->to;
|
||||||
|
|
||||||
database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type);
|
database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -26,7 +26,6 @@ ADD_DEFINITIONS(-DUCS)
|
|||||||
TARGET_LINK_LIBRARIES(ucs Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
TARGET_LINK_LIBRARIES(ucs Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||||
|
|
||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(ucs PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
SET_TARGET_PROPERTIES(ucs PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||||
TARGET_LINK_LIBRARIES(ucs "Ws2_32.lib")
|
TARGET_LINK_LIBRARIES(ucs "Ws2_32.lib")
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|||||||
@ -20,13 +20,13 @@
|
|||||||
#include "chatchannel.h"
|
#include "chatchannel.h"
|
||||||
#include "clientlist.h"
|
#include "clientlist.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "../common/MiscFunctions.h"
|
#include "../common/StringUtil.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
extern Database database;
|
extern Database database;
|
||||||
extern uint32 ChatMessagesSent;
|
extern uint32 ChatMessagesSent;
|
||||||
|
|
||||||
ChatChannel::ChatChannel(string inName, string inOwner, string inPassword, bool inPermanent, int inMinimumStatus) :
|
ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus) :
|
||||||
DeleteTimer(0) {
|
DeleteTimer(0) {
|
||||||
|
|
||||||
Name = inName;
|
Name = inName;
|
||||||
@ -56,7 +56,7 @@ ChatChannel::~ChatChannel() {
|
|||||||
iterator.RemoveCurrent(false);
|
iterator.RemoveCurrent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatChannel* ChatChannelList::CreateChannel(string Name, string Owner, string Password, bool Permanent, int MinimumStatus) {
|
ChatChannel* ChatChannelList::CreateChannel(std::string Name, std::string Owner, std::string Password, bool Permanent, int MinimumStatus) {
|
||||||
|
|
||||||
ChatChannel *NewChannel = new ChatChannel(CapitaliseName(Name), Owner, Password, Permanent, MinimumStatus);
|
ChatChannel *NewChannel = new ChatChannel(CapitaliseName(Name), Owner, Password, Permanent, MinimumStatus);
|
||||||
|
|
||||||
@ -65,9 +65,9 @@ ChatChannel* ChatChannelList::CreateChannel(string Name, string Owner, string Pa
|
|||||||
return NewChannel;
|
return NewChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatChannel* ChatChannelList::FindChannel(string Name) {
|
ChatChannel* ChatChannelList::FindChannel(std::string Name) {
|
||||||
|
|
||||||
string NormalisedName = CapitaliseName(Name);
|
std::string NormalisedName = CapitaliseName(Name);
|
||||||
|
|
||||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ void ChatChannelList::SendAllChannels(Client *c) {
|
|||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
string Message;
|
std::string Message;
|
||||||
|
|
||||||
char CountString[10];
|
char CountString[10];
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ int ChatChannel::MemberCount(int Status) {
|
|||||||
return Count;
|
return Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::SetPassword(string inPassword) {
|
void ChatChannel::SetPassword(std::string inPassword) {
|
||||||
|
|
||||||
Password = inPassword;
|
Password = inPassword;
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ void ChatChannel::SetPassword(string inPassword) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::SetOwner(string inOwner) {
|
void ChatChannel::SetOwner(std::string inOwner) {
|
||||||
|
|
||||||
Owner = inOwner;
|
Owner = inOwner;
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ void ChatChannel::SendOPList(Client *c) {
|
|||||||
|
|
||||||
c->GeneralChannelMessage("Channel " + Name + " op-list: (Owner=" + Owner + ")");
|
c->GeneralChannelMessage("Channel " + Name + " op-list: (Owner=" + Owner + ")");
|
||||||
|
|
||||||
list<string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++)
|
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++)
|
||||||
c->GeneralChannelMessage((*Iterator));
|
c->GeneralChannelMessage((*Iterator));
|
||||||
@ -327,7 +327,7 @@ void ChatChannel::SendChannelMembers(Client *c) {
|
|||||||
|
|
||||||
sprintf(CountString, "(%i)", MemberCount(c->GetAccountStatus()));
|
sprintf(CountString, "(%i)", MemberCount(c->GetAccountStatus()));
|
||||||
|
|
||||||
string Message = "Channel " + GetName();
|
std::string Message = "Channel " + GetName();
|
||||||
|
|
||||||
Message += CountString;
|
Message += CountString;
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ void ChatChannel::SendChannelMembers(Client *c) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::SendMessageToChannel(string Message, Client* Sender) {
|
void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
|
||||||
|
|
||||||
if(!Sender) return;
|
if(!Sender) return;
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ bool ChatChannel::IsClientInChannel(Client *c) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c) {
|
ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client *c) {
|
||||||
|
|
||||||
if(!c) return nullptr;
|
if(!c) return nullptr;
|
||||||
|
|
||||||
@ -459,11 +459,11 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
string NormalisedName, Password;
|
std::string NormalisedName, Password;
|
||||||
|
|
||||||
string::size_type Colon = ChannelName.find_first_of(":");
|
std::string::size_type Colon = ChannelName.find_first_of(":");
|
||||||
|
|
||||||
if(Colon == string::npos)
|
if(Colon == std::string::npos)
|
||||||
NormalisedName = CapitaliseName(ChannelName);
|
NormalisedName = CapitaliseName(ChannelName);
|
||||||
else {
|
else {
|
||||||
NormalisedName = CapitaliseName(ChannelName.substr(0, Colon));
|
NormalisedName = CapitaliseName(ChannelName.substr(0, Colon));
|
||||||
@ -487,7 +487,7 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
|
|||||||
|
|
||||||
if(RequiredChannel->GetMinStatus() > c->GetAccountStatus()) {
|
if(RequiredChannel->GetMinStatus() > c->GetAccountStatus()) {
|
||||||
|
|
||||||
string Message = "You do not have the required account status to join channel " + NormalisedName;
|
std::string Message = "You do not have the required account status to join channel " + NormalisedName;
|
||||||
|
|
||||||
c->GeneralChannelMessage(Message);
|
c->GeneralChannelMessage(Message);
|
||||||
|
|
||||||
@ -519,11 +519,11 @@ ChatChannel *ChatChannelList::AddClientToChannel(string ChannelName, Client *c)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatChannel *ChatChannelList::RemoveClientFromChannel(string inChannelName, Client *c) {
|
ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName, Client *c) {
|
||||||
|
|
||||||
if(!c) return nullptr;
|
if(!c) return nullptr;
|
||||||
|
|
||||||
string ChannelName = inChannelName;
|
std::string ChannelName = inChannelName;
|
||||||
|
|
||||||
if((inChannelName.length() > 0) && isdigit(ChannelName[0]))
|
if((inChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||||
ChannelName = c->ChannelSlotName(atoi(inChannelName.c_str()));
|
ChannelName = c->ChannelSlotName(atoi(inChannelName.c_str()));
|
||||||
@ -565,7 +565,7 @@ void ChatChannelList::Process() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::AddInvitee(string Invitee) {
|
void ChatChannel::AddInvitee(std::string Invitee) {
|
||||||
|
|
||||||
if(!IsInvitee(Invitee)) {
|
if(!IsInvitee(Invitee)) {
|
||||||
|
|
||||||
@ -576,9 +576,9 @@ void ChatChannel::AddInvitee(string Invitee) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::RemoveInvitee(string Invitee) {
|
void ChatChannel::RemoveInvitee(std::string Invitee) {
|
||||||
|
|
||||||
list<string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); Iterator++) {
|
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); Iterator++) {
|
||||||
|
|
||||||
@ -593,9 +593,9 @@ void ChatChannel::RemoveInvitee(string Invitee) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatChannel::IsInvitee(string Invitee) {
|
bool ChatChannel::IsInvitee(std::string Invitee) {
|
||||||
|
|
||||||
list<string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); Iterator++) {
|
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); Iterator++) {
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ bool ChatChannel::IsInvitee(string Invitee) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::AddModerator(string Moderator) {
|
void ChatChannel::AddModerator(std::string Moderator) {
|
||||||
|
|
||||||
if(!IsModerator(Moderator)) {
|
if(!IsModerator(Moderator)) {
|
||||||
|
|
||||||
@ -617,9 +617,9 @@ void ChatChannel::AddModerator(string Moderator) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::RemoveModerator(string Moderator) {
|
void ChatChannel::RemoveModerator(std::string Moderator) {
|
||||||
|
|
||||||
list<string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++) {
|
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++) {
|
||||||
|
|
||||||
@ -634,9 +634,9 @@ void ChatChannel::RemoveModerator(string Moderator) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatChannel::IsModerator(string Moderator) {
|
bool ChatChannel::IsModerator(std::string Moderator) {
|
||||||
|
|
||||||
list<string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++) {
|
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); Iterator++) {
|
||||||
|
|
||||||
@ -647,7 +647,7 @@ bool ChatChannel::IsModerator(string Moderator) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::AddVoice(string inVoiced) {
|
void ChatChannel::AddVoice(std::string inVoiced) {
|
||||||
|
|
||||||
if(!HasVoice(inVoiced)) {
|
if(!HasVoice(inVoiced)) {
|
||||||
|
|
||||||
@ -658,9 +658,9 @@ void ChatChannel::AddVoice(string inVoiced) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::RemoveVoice(string inVoiced) {
|
void ChatChannel::RemoveVoice(std::string inVoiced) {
|
||||||
|
|
||||||
list<string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); Iterator++) {
|
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); Iterator++) {
|
||||||
|
|
||||||
@ -675,9 +675,9 @@ void ChatChannel::RemoveVoice(string inVoiced) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatChannel::HasVoice(string inVoiced) {
|
bool ChatChannel::HasVoice(std::string inVoiced) {
|
||||||
|
|
||||||
list<string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); Iterator++) {
|
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); Iterator++) {
|
||||||
|
|
||||||
@ -688,9 +688,9 @@ bool ChatChannel::HasVoice(string inVoiced) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string CapitaliseName(string inString) {
|
std::string CapitaliseName(std::string inString) {
|
||||||
|
|
||||||
string NormalisedName = inString;
|
std::string NormalisedName = inString;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < NormalisedName.length(); i++) {
|
for(unsigned int i = 0; i < NormalisedName.length(); i++) {
|
||||||
|
|
||||||
|
|||||||
@ -7,15 +7,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class Client;
|
class Client;
|
||||||
|
|
||||||
class ChatChannel {
|
class ChatChannel {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ChatChannel(string inName, string inOwner, string inPassword, bool inPermanent, int inMinimumStatus = 0);
|
ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus = 0);
|
||||||
~ChatChannel();
|
~ChatChannel();
|
||||||
|
|
||||||
void AddClient(Client *c);
|
void AddClient(Client *c);
|
||||||
@ -23,25 +21,25 @@ public:
|
|||||||
bool IsClientInChannel(Client *c);
|
bool IsClientInChannel(Client *c);
|
||||||
|
|
||||||
int MemberCount(int Status);
|
int MemberCount(int Status);
|
||||||
string GetName() { return Name; }
|
std::string GetName() { return Name; }
|
||||||
void SendMessageToChannel(string Message, Client* Sender);
|
void SendMessageToChannel(std::string Message, Client* Sender);
|
||||||
bool CheckPassword(string inPassword) { return ((Password.length() == 0) || (Password == inPassword)); }
|
bool CheckPassword(std::string inPassword) { return ((Password.length() == 0) || (Password == inPassword)); }
|
||||||
void SetPassword(string inPassword);
|
void SetPassword(std::string inPassword);
|
||||||
bool IsOwner(string Name) { return (Owner == Name); }
|
bool IsOwner(std::string Name) { return (Owner == Name); }
|
||||||
void SetOwner(string inOwner);
|
void SetOwner(std::string inOwner);
|
||||||
void SendChannelMembers(Client *c);
|
void SendChannelMembers(Client *c);
|
||||||
int GetMinStatus() { return MinimumStatus; }
|
int GetMinStatus() { return MinimumStatus; }
|
||||||
bool ReadyToDelete() { return DeleteTimer.Check(); }
|
bool ReadyToDelete() { return DeleteTimer.Check(); }
|
||||||
void SendOPList(Client *c);
|
void SendOPList(Client *c);
|
||||||
void AddInvitee(string Invitee);
|
void AddInvitee(std::string Invitee);
|
||||||
void RemoveInvitee(string Invitee);
|
void RemoveInvitee(std::string Invitee);
|
||||||
bool IsInvitee(string Invitee);
|
bool IsInvitee(std::string Invitee);
|
||||||
void AddModerator(string Moderator);
|
void AddModerator(std::string Moderator);
|
||||||
void RemoveModerator(string Modeerator);
|
void RemoveModerator(std::string Modeerator);
|
||||||
bool IsModerator(string Moderator);
|
bool IsModerator(std::string Moderator);
|
||||||
void AddVoice(string Voiced);
|
void AddVoice(std::string Voiced);
|
||||||
void RemoveVoice(string Voiced);
|
void RemoveVoice(std::string Voiced);
|
||||||
bool HasVoice(string Voiced);
|
bool HasVoice(std::string Voiced);
|
||||||
inline bool IsModerated() { return Moderated; }
|
inline bool IsModerated() { return Moderated; }
|
||||||
void SetModerated(bool inModerated);
|
void SetModerated(bool inModerated);
|
||||||
|
|
||||||
@ -49,9 +47,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
string Name;
|
std::string Name;
|
||||||
string Owner;
|
std::string Owner;
|
||||||
string Password;
|
std::string Password;
|
||||||
|
|
||||||
bool Permanent;
|
bool Permanent;
|
||||||
bool Moderated;
|
bool Moderated;
|
||||||
@ -62,19 +60,19 @@ private:
|
|||||||
|
|
||||||
LinkedList<Client*> ClientsInChannel;
|
LinkedList<Client*> ClientsInChannel;
|
||||||
|
|
||||||
list<string> Moderators;
|
std::list<std::string> Moderators;
|
||||||
list<string> Invitees;
|
std::list<std::string> Invitees;
|
||||||
list<string> Voiced;
|
std::list<std::string> Voiced;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChatChannelList {
|
class ChatChannelList {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ChatChannel* CreateChannel(string Name, string Owner, string Passwordi, bool Permanent, int MinimumStatus = 0);
|
ChatChannel* CreateChannel(std::string Name, std::string Owner, std::string Passwordi, bool Permanent, int MinimumStatus = 0);
|
||||||
ChatChannel* FindChannel(string Name);
|
ChatChannel* FindChannel(std::string Name);
|
||||||
ChatChannel* AddClientToChannel(string Channel, Client *c);
|
ChatChannel* AddClientToChannel(std::string Channel, Client *c);
|
||||||
ChatChannel* RemoveClientFromChannel(string Channel, Client *c);
|
ChatChannel* RemoveClientFromChannel(std::string Channel, Client *c);
|
||||||
void RemoveClientFromAllChannels(Client *c);
|
void RemoveClientFromAllChannels(Client *c);
|
||||||
void RemoveChannel(ChatChannel *Channel);
|
void RemoveChannel(ChatChannel *Channel);
|
||||||
void RemoveAllChannels();
|
void RemoveAllChannels();
|
||||||
@ -87,6 +85,6 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
string CapitaliseName(string inString);
|
std::string CapitaliseName(std::string inString);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../common/debug.h"
|
#include "../common/debug.h"
|
||||||
#include "../common/MiscFunctions.h"
|
#include "../common/StringUtil.h"
|
||||||
|
|
||||||
#include "clientlist.h"
|
#include "clientlist.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
@ -33,11 +33,9 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
extern Database database;
|
extern Database database;
|
||||||
extern string WorldShortName;
|
extern std::string WorldShortName;
|
||||||
extern string GetMailPrefix();
|
extern std::string GetMailPrefix();
|
||||||
extern ChatChannelList *ChannelList;
|
extern ChatChannelList *ChannelList;
|
||||||
extern Clientlist *CL;
|
extern Clientlist *CL;
|
||||||
extern uint32 ChatMessagesSent;
|
extern uint32 ChatMessagesSent;
|
||||||
@ -77,7 +75,7 @@ void Client::SendUptime() {
|
|||||||
safe_delete_array(Buffer);
|
safe_delete_array(Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> ParseRecipients(string RecipientString) {
|
std::vector<std::string> ParseRecipients(std::string RecipientString) {
|
||||||
|
|
||||||
// This method parses the Recipient List in the mailto command, which can look like this example:
|
// This method parses the Recipient List in the mailto command, which can look like this example:
|
||||||
//
|
//
|
||||||
@ -111,19 +109,19 @@ vector<string> ParseRecipients(string RecipientString) {
|
|||||||
//
|
//
|
||||||
// The '-' prefix indicates 'Secret To' (like BCC:)
|
// The '-' prefix indicates 'Secret To' (like BCC:)
|
||||||
//
|
//
|
||||||
vector<string> RecipientList;
|
std::vector<std::string> RecipientList;
|
||||||
|
|
||||||
string Secret;
|
std::string Secret;
|
||||||
|
|
||||||
string::size_type CurrentPos, Comma, FirstLT, LastGT, Space, LastPeriod;
|
std::string::size_type CurrentPos, Comma, FirstLT, LastGT, Space, LastPeriod;
|
||||||
|
|
||||||
CurrentPos = 0;
|
CurrentPos = 0;
|
||||||
|
|
||||||
while(CurrentPos != string::npos) {
|
while(CurrentPos != std::string::npos) {
|
||||||
|
|
||||||
Comma = RecipientString.find_first_of(",", CurrentPos);
|
Comma = RecipientString.find_first_of(",", CurrentPos);
|
||||||
|
|
||||||
if(Comma == string::npos) {
|
if(Comma == std::string::npos) {
|
||||||
|
|
||||||
RecipientList.push_back(RecipientString.substr(CurrentPos));
|
RecipientList.push_back(RecipientString.substr(CurrentPos));
|
||||||
|
|
||||||
@ -134,7 +132,7 @@ vector<string> ParseRecipients(string RecipientString) {
|
|||||||
CurrentPos = Comma + 2;
|
CurrentPos = Comma + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string>::iterator Iterator;
|
std::vector<std::string>::iterator Iterator;
|
||||||
|
|
||||||
Iterator = RecipientList.begin();
|
Iterator = RecipientList.begin();
|
||||||
|
|
||||||
@ -152,27 +150,27 @@ vector<string> ParseRecipients(string RecipientString) {
|
|||||||
|
|
||||||
FirstLT = (*Iterator).find_first_of("<");
|
FirstLT = (*Iterator).find_first_of("<");
|
||||||
|
|
||||||
if(FirstLT != string::npos) {
|
if(FirstLT != std::string::npos) {
|
||||||
|
|
||||||
LastGT = (*Iterator).find_last_of(">");
|
LastGT = (*Iterator).find_last_of(">");
|
||||||
|
|
||||||
if(LastGT != string::npos) {
|
if(LastGT != std::string::npos) {
|
||||||
|
|
||||||
(*Iterator) = (*Iterator).substr(FirstLT + 1, LastGT - FirstLT - 1);
|
(*Iterator) = (*Iterator).substr(FirstLT + 1, LastGT - FirstLT - 1);
|
||||||
|
|
||||||
if((*Iterator).find_first_of(" ") != string::npos) {
|
if((*Iterator).find_first_of(" ") != std::string::npos) {
|
||||||
|
|
||||||
string Recips = (*Iterator);
|
std::string Recips = (*Iterator);
|
||||||
|
|
||||||
RecipientList.erase(Iterator);
|
RecipientList.erase(Iterator);
|
||||||
|
|
||||||
CurrentPos = 0;
|
CurrentPos = 0;
|
||||||
|
|
||||||
while(CurrentPos != string::npos) {
|
while(CurrentPos != std::string::npos) {
|
||||||
|
|
||||||
Space = Recips.find_first_of(" ", CurrentPos);
|
Space = Recips.find_first_of(" ", CurrentPos);
|
||||||
|
|
||||||
if(Space == string::npos) {
|
if(Space == std::string::npos) {
|
||||||
|
|
||||||
RecipientList.push_back(Secret + Recips.substr(CurrentPos));
|
RecipientList.push_back(Secret + Recips.substr(CurrentPos));
|
||||||
|
|
||||||
@ -207,7 +205,7 @@ vector<string> ParseRecipients(string RecipientString) {
|
|||||||
|
|
||||||
LastPeriod = (*Iterator).find_last_of(".");
|
LastPeriod = (*Iterator).find_last_of(".");
|
||||||
|
|
||||||
if(LastPeriod != string::npos) {
|
if(LastPeriod != std::string::npos) {
|
||||||
|
|
||||||
(*Iterator) = (*Iterator).substr(LastPeriod + 1);
|
(*Iterator) = (*Iterator).substr(LastPeriod + 1);
|
||||||
|
|
||||||
@ -227,7 +225,7 @@ vector<string> ParseRecipients(string RecipientString) {
|
|||||||
|
|
||||||
sort(RecipientList.begin(), RecipientList.end());
|
sort(RecipientList.begin(), RecipientList.end());
|
||||||
|
|
||||||
vector<string>::iterator new_end_pos = unique(RecipientList.begin(), RecipientList.end());
|
std::vector<std::string>::iterator new_end_pos = unique(RecipientList.begin(), RecipientList.end());
|
||||||
|
|
||||||
RecipientList.erase(new_end_pos, RecipientList.end());
|
RecipientList.erase(new_end_pos, RecipientList.end());
|
||||||
|
|
||||||
@ -235,27 +233,27 @@ vector<string> ParseRecipients(string RecipientString) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessMailTo(Client *c, string MailMessage) {
|
static void ProcessMailTo(Client *c, std::string MailMessage) {
|
||||||
|
|
||||||
_log(UCS__TRACE, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str());
|
_log(UCS__TRACE, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str());
|
||||||
|
|
||||||
vector<string> Recipients;
|
std::vector<std::string> Recipients;
|
||||||
|
|
||||||
string::size_type FirstQuote = MailMessage.find_first_of("\"", 0);
|
std::string::size_type FirstQuote = MailMessage.find_first_of("\"", 0);
|
||||||
|
|
||||||
string::size_type NextQuote = MailMessage.find_first_of("\"", FirstQuote + 1);
|
std::string::size_type NextQuote = MailMessage.find_first_of("\"", FirstQuote + 1);
|
||||||
|
|
||||||
string RecipientsString = MailMessage.substr(FirstQuote+1, NextQuote-FirstQuote - 1);
|
std::string RecipientsString = MailMessage.substr(FirstQuote+1, NextQuote-FirstQuote - 1);
|
||||||
|
|
||||||
Recipients = ParseRecipients(RecipientsString);
|
Recipients = ParseRecipients(RecipientsString);
|
||||||
|
|
||||||
// Now extract the subject field. This is in quotes if it is more than one word
|
// Now extract the subject field. This is in quotes if it is more than one word
|
||||||
//
|
//
|
||||||
string Subject;
|
std::string Subject;
|
||||||
|
|
||||||
string::size_type SubjectStart = NextQuote + 2;
|
std::string::size_type SubjectStart = NextQuote + 2;
|
||||||
|
|
||||||
string::size_type SubjectEnd;
|
std::string::size_type SubjectEnd;
|
||||||
|
|
||||||
if(MailMessage.substr(SubjectStart, 1) == "\"") {
|
if(MailMessage.substr(SubjectStart, 1) == "\"") {
|
||||||
|
|
||||||
@ -274,7 +272,7 @@ static void ProcessMailTo(Client *c, string MailMessage) {
|
|||||||
SubjectEnd++;
|
SubjectEnd++;
|
||||||
|
|
||||||
}
|
}
|
||||||
string Body = MailMessage.substr(SubjectEnd);
|
std::string Body = MailMessage.substr(SubjectEnd);
|
||||||
|
|
||||||
bool Success = true;
|
bool Success = true;
|
||||||
|
|
||||||
@ -353,7 +351,10 @@ static void ProcessMailTo(Client *c, string MailMessage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessSetMessageStatus(string SetMessageCommand) {
|
static void ProcessMailTo(Client *c, std::string from, std::string subject, std::string message) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ProcessSetMessageStatus(std::string SetMessageCommand) {
|
||||||
|
|
||||||
int MessageNumber;
|
int MessageNumber;
|
||||||
|
|
||||||
@ -373,13 +374,13 @@ static void ProcessSetMessageStatus(string SetMessageCommand) {
|
|||||||
Status = 0;
|
Status = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
string::size_type NumStart = SetMessageCommand.find_first_of("123456789");
|
std::string::size_type NumStart = SetMessageCommand.find_first_of("123456789");
|
||||||
|
|
||||||
while(NumStart != string::npos) {
|
while(NumStart != std::string::npos) {
|
||||||
|
|
||||||
string::size_type NumEnd = SetMessageCommand.find_first_of(" ", NumStart);
|
std::string::size_type NumEnd = SetMessageCommand.find_first_of(" ", NumStart);
|
||||||
|
|
||||||
if(NumEnd == string::npos) {
|
if(NumEnd == std::string::npos) {
|
||||||
|
|
||||||
MessageNumber = atoi(SetMessageCommand.substr(NumStart).c_str());
|
MessageNumber = atoi(SetMessageCommand.substr(NumStart).c_str());
|
||||||
|
|
||||||
@ -396,7 +397,7 @@ static void ProcessSetMessageStatus(string SetMessageCommand) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessCommandBuddy(Client *c, string Buddy) {
|
static void ProcessCommandBuddy(Client *c, std::string Buddy) {
|
||||||
|
|
||||||
_log(UCS__TRACE, "Received buddy command with parameters %s", Buddy.c_str());
|
_log(UCS__TRACE, "Received buddy command with parameters %s", Buddy.c_str());
|
||||||
c->GeneralChannelMessage("Buddy list modified");
|
c->GeneralChannelMessage("Buddy list modified");
|
||||||
@ -426,7 +427,7 @@ static void ProcessCommandBuddy(Client *c, string Buddy) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessCommandIgnore(Client *c, string Ignoree) {
|
static void ProcessCommandIgnore(Client *c, std::string Ignoree) {
|
||||||
|
|
||||||
_log(UCS__TRACE, "Received ignore command with parameters %s", Ignoree.c_str());
|
_log(UCS__TRACE, "Received ignore command with parameters %s", Ignoree.c_str());
|
||||||
c->GeneralChannelMessage("Ignore list modified");
|
c->GeneralChannelMessage("Ignore list modified");
|
||||||
@ -439,11 +440,11 @@ static void ProcessCommandIgnore(Client *c, string Ignoree) {
|
|||||||
|
|
||||||
// Strip off the SOE.EQ.<shortname>.
|
// Strip off the SOE.EQ.<shortname>.
|
||||||
//
|
//
|
||||||
string CharacterName;
|
std::string CharacterName;
|
||||||
|
|
||||||
string::size_type LastPeriod = Ignoree.find_last_of(".");
|
std::string::size_type LastPeriod = Ignoree.find_last_of(".");
|
||||||
|
|
||||||
if(LastPeriod == string::npos)
|
if(LastPeriod == std::string::npos)
|
||||||
CharacterName = Ignoree;
|
CharacterName = Ignoree;
|
||||||
else
|
else
|
||||||
CharacterName = Ignoree.substr(LastPeriod + 1);
|
CharacterName = Ignoree.substr(LastPeriod + 1);
|
||||||
@ -551,7 +552,7 @@ void Clientlist::CheckForStaleConnections(Client *c) {
|
|||||||
|
|
||||||
if(!c) return;
|
if(!c) return;
|
||||||
|
|
||||||
list<Client*>::iterator Iterator;
|
std::list<Client*>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
||||||
|
|
||||||
@ -593,7 +594,7 @@ void Clientlist::Process() {
|
|||||||
ClientChatConnections.push_back(c);
|
ClientChatConnections.push_back(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
list<Client*>::iterator Iterator;
|
std::list<Client*>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
||||||
|
|
||||||
@ -654,13 +655,13 @@ void Clientlist::Process() {
|
|||||||
|
|
||||||
VARSTRUCT_DECODE_STRING(Key, PacketBuffer);
|
VARSTRUCT_DECODE_STRING(Key, PacketBuffer);
|
||||||
|
|
||||||
string MailBoxString = MailBox, CharacterName;
|
std::string MailBoxString = MailBox, CharacterName;
|
||||||
|
|
||||||
// Strip off the SOE.EQ.<shortname>.
|
// Strip off the SOE.EQ.<shortname>.
|
||||||
//
|
//
|
||||||
string::size_type LastPeriod = MailBoxString.find_last_of(".");
|
std::string::size_type LastPeriod = MailBoxString.find_last_of(".");
|
||||||
|
|
||||||
if(LastPeriod == string::npos)
|
if(LastPeriod == std::string::npos)
|
||||||
CharacterName = MailBoxString;
|
CharacterName = MailBoxString;
|
||||||
else
|
else
|
||||||
CharacterName = MailBoxString.substr(LastPeriod + 1);
|
CharacterName = MailBoxString.substr(LastPeriod + 1);
|
||||||
@ -692,7 +693,7 @@ void Clientlist::Process() {
|
|||||||
|
|
||||||
case OP_Mail: {
|
case OP_Mail: {
|
||||||
|
|
||||||
string CommandString = (const char*)app->pBuffer;
|
std::string CommandString = (const char*)app->pBuffer;
|
||||||
|
|
||||||
ProcessOPMailCommand((*Iterator), CommandString);
|
ProcessOPMailCommand((*Iterator), CommandString);
|
||||||
|
|
||||||
@ -732,7 +733,7 @@ void Clientlist::Process() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
|
void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(CommandString.length() == 0)
|
if(CommandString.length() == 0)
|
||||||
@ -753,17 +754,17 @@ void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Command, Parameters;
|
std::string Command, Parameters;
|
||||||
|
|
||||||
string::size_type Space = CommandString.find_first_of(" ");
|
std::string::size_type Space = CommandString.find_first_of(" ");
|
||||||
|
|
||||||
if(Space != string::npos) {
|
if(Space != std::string::npos) {
|
||||||
|
|
||||||
Command = CommandString.substr(0, Space);
|
Command = CommandString.substr(0, Space);
|
||||||
|
|
||||||
string::size_type ParametersStart = CommandString.find_first_not_of(" ", Space);
|
std::string::size_type ParametersStart = CommandString.find_first_not_of(" ", Space);
|
||||||
|
|
||||||
if(ParametersStart != string::npos)
|
if(ParametersStart != std::string::npos)
|
||||||
Parameters = CommandString.substr(ParametersStart);
|
Parameters = CommandString.substr(ParametersStart);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -864,7 +865,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
|
|||||||
|
|
||||||
case CommandSelectMailBox:
|
case CommandSelectMailBox:
|
||||||
{
|
{
|
||||||
string::size_type NumStart = Parameters.find_first_of("0123456789");
|
std::string::size_type NumStart = Parameters.find_first_of("0123456789");
|
||||||
c->ChangeMailBox(atoi(Parameters.substr(NumStart).c_str()));
|
c->ChangeMailBox(atoi(Parameters.substr(NumStart).c_str()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -890,7 +891,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, string CommandString)
|
|||||||
void Clientlist::CloseAllConnections() {
|
void Clientlist::CloseAllConnections() {
|
||||||
|
|
||||||
|
|
||||||
list<Client*>::iterator Iterator;
|
std::list<Client*>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
||||||
|
|
||||||
@ -918,7 +919,7 @@ void Client::SendMailBoxes() {
|
|||||||
|
|
||||||
int PacketLength = 10;
|
int PacketLength = 10;
|
||||||
|
|
||||||
string s;
|
std::string s;
|
||||||
|
|
||||||
for(int i = 0; i < Count; i++) {
|
for(int i = 0; i < Count; i++) {
|
||||||
|
|
||||||
@ -948,9 +949,9 @@ void Client::SendMailBoxes() {
|
|||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *Clientlist::FindCharacter(string CharacterName) {
|
Client *Clientlist::FindCharacter(std::string CharacterName) {
|
||||||
|
|
||||||
list<Client*>::iterator Iterator;
|
std::list<Client*>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
||||||
|
|
||||||
@ -1002,7 +1003,7 @@ int Client::ChannelCount() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::JoinChannels(string ChannelNameList) {
|
void Client::JoinChannels(std::string ChannelNameList) {
|
||||||
|
|
||||||
for(int x = 0; x < ChannelNameList.size(); ++x)
|
for(int x = 0; x < ChannelNameList.size(); ++x)
|
||||||
{
|
{
|
||||||
@ -1016,9 +1017,9 @@ void Client::JoinChannels(string ChannelNameList) {
|
|||||||
|
|
||||||
int NumberOfChannels = ChannelCount();
|
int NumberOfChannels = ChannelCount();
|
||||||
|
|
||||||
string::size_type CurrentPos = ChannelNameList.find_first_not_of(" ");
|
std::string::size_type CurrentPos = ChannelNameList.find_first_not_of(" ");
|
||||||
|
|
||||||
while(CurrentPos != string::npos) {
|
while(CurrentPos != std::string::npos) {
|
||||||
|
|
||||||
if(NumberOfChannels == MAX_JOINED_CHANNELS) {
|
if(NumberOfChannels == MAX_JOINED_CHANNELS) {
|
||||||
|
|
||||||
@ -1027,9 +1028,9 @@ void Client::JoinChannels(string ChannelNameList) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos);
|
std::string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos);
|
||||||
|
|
||||||
if(Comma == string::npos) {
|
if(Comma == std::string::npos) {
|
||||||
|
|
||||||
ChatChannel* JoinedChannel = ChannelList->AddClientToChannel(ChannelNameList.substr(CurrentPos), this);
|
ChatChannel* JoinedChannel = ChannelList->AddClientToChannel(ChannelNameList.substr(CurrentPos), this);
|
||||||
|
|
||||||
@ -1051,7 +1052,7 @@ void Client::JoinChannels(string ChannelNameList) {
|
|||||||
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
|
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
string JoinedChannelsList, ChannelMessage;
|
std::string JoinedChannelsList, ChannelMessage;
|
||||||
|
|
||||||
ChannelMessage = "Channels: ";
|
ChannelMessage = "Channels: ";
|
||||||
|
|
||||||
@ -1112,17 +1113,17 @@ void Client::JoinChannels(string ChannelNameList) {
|
|||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::LeaveChannels(string ChannelNameList) {
|
void Client::LeaveChannels(std::string ChannelNameList) {
|
||||||
|
|
||||||
_log(UCS__TRACE, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str());
|
_log(UCS__TRACE, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str());
|
||||||
|
|
||||||
string::size_type CurrentPos = 0;
|
std::string::size_type CurrentPos = 0;
|
||||||
|
|
||||||
while(CurrentPos != string::npos) {
|
while(CurrentPos != std::string::npos) {
|
||||||
|
|
||||||
string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos);
|
std::string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos);
|
||||||
|
|
||||||
if(Comma == string::npos) {
|
if(Comma == std::string::npos) {
|
||||||
|
|
||||||
ChatChannel* JoinedChannel = ChannelList->RemoveClientFromChannel(ChannelNameList.substr(CurrentPos), this);
|
ChatChannel* JoinedChannel = ChannelList->RemoveClientFromChannel(ChannelNameList.substr(CurrentPos), this);
|
||||||
|
|
||||||
@ -1140,7 +1141,7 @@ void Client::LeaveChannels(string ChannelNameList) {
|
|||||||
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
|
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
string JoinedChannelsList, ChannelMessage;
|
std::string JoinedChannelsList, ChannelMessage;
|
||||||
|
|
||||||
ChannelMessage = "Channels: ";
|
ChannelMessage = "Channels: ";
|
||||||
|
|
||||||
@ -1217,7 +1218,7 @@ void Client::LeaveAllChannels(bool SendUpdatedChannelList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Client::ProcessChannelList(string Input) {
|
void Client::ProcessChannelList(std::string Input) {
|
||||||
|
|
||||||
if(Input.length() == 0) {
|
if(Input.length() == 0) {
|
||||||
|
|
||||||
@ -1226,7 +1227,7 @@ void Client::ProcessChannelList(string Input) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ChannelName = Input;
|
std::string ChannelName = Input;
|
||||||
|
|
||||||
if(isdigit(ChannelName[0]))
|
if(isdigit(ChannelName[0]))
|
||||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||||
@ -1243,7 +1244,7 @@ void Client::ProcessChannelList(string Input) {
|
|||||||
|
|
||||||
void Client::SendChannelList() {
|
void Client::SendChannelList() {
|
||||||
|
|
||||||
string ChannelMessage;
|
std::string ChannelMessage;
|
||||||
|
|
||||||
ChannelMessage = "Channels: ";
|
ChannelMessage = "Channels: ";
|
||||||
|
|
||||||
@ -1284,15 +1285,15 @@ void Client::SendChannelList() {
|
|||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendChannelMessage(string Message)
|
void Client::SendChannelMessage(std::string Message)
|
||||||
{
|
{
|
||||||
|
|
||||||
string::size_type MessageStart = Message.find_first_of(" ");
|
std::string::size_type MessageStart = Message.find_first_of(" ");
|
||||||
|
|
||||||
if(MessageStart == string::npos)
|
if(MessageStart == std::string::npos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string ChannelName = Message.substr(1, MessageStart-1);
|
std::string ChannelName = Message.substr(1, MessageStart-1);
|
||||||
|
|
||||||
_log(UCS__TRACE, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str());
|
_log(UCS__TRACE, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str());
|
||||||
|
|
||||||
@ -1329,7 +1330,6 @@ void Client::SendChannelMessage(string Message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(RequiredChannel)
|
if(RequiredChannel)
|
||||||
{
|
|
||||||
if(RuleB(Chat, EnableAntiSpam))
|
if(RuleB(Chat, EnableAntiSpam))
|
||||||
{
|
{
|
||||||
if(!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) ||
|
if(!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) ||
|
||||||
@ -1384,15 +1384,14 @@ void Client::SendChannelMessage(string Message)
|
|||||||
else
|
else
|
||||||
GeneralChannelMessage("Channel " + ChannelName + " is moderated and you have not been granted a voice.");
|
GeneralChannelMessage("Channel " + ChannelName + " is moderated and you have not been granted a voice.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendChannelMessageByNumber(string Message) {
|
void Client::SendChannelMessageByNumber(std::string Message) {
|
||||||
|
|
||||||
string::size_type MessageStart = Message.find_first_of(" ");
|
std::string::size_type MessageStart = Message.find_first_of(" ");
|
||||||
|
|
||||||
if(MessageStart == string::npos)
|
if(MessageStart == std::string::npos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int ChannelNumber = atoi(Message.substr(0, MessageStart).c_str());
|
int ChannelNumber = atoi(Message.substr(0, MessageStart).c_str());
|
||||||
@ -1502,11 +1501,11 @@ void Client::SendChannelMessageByNumber(string Message) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendChannelMessage(string ChannelName, string Message, Client *Sender) {
|
void Client::SendChannelMessage(std::string ChannelName, std::string Message, Client *Sender) {
|
||||||
|
|
||||||
if(!Sender) return;
|
if(!Sender) return;
|
||||||
|
|
||||||
string FQSenderName = WorldShortName + "." + Sender->GetName();
|
std::string FQSenderName = WorldShortName + "." + Sender->GetName();
|
||||||
|
|
||||||
int PacketLength = ChannelName.length() + Message.length() + FQSenderName.length() + 3;
|
int PacketLength = ChannelName.length() + Message.length() + FQSenderName.length() + 3;
|
||||||
|
|
||||||
@ -1530,7 +1529,7 @@ void Client::SendChannelMessage(string ChannelName, string Message, Client *Send
|
|||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::ToggleAnnounce(string State)
|
void Client::ToggleAnnounce(std::string State)
|
||||||
{
|
{
|
||||||
if(State == "")
|
if(State == "")
|
||||||
Announce = !Announce;
|
Announce = !Announce;
|
||||||
@ -1539,7 +1538,7 @@ void Client::ToggleAnnounce(string State)
|
|||||||
else
|
else
|
||||||
Announce = false;
|
Announce = false;
|
||||||
|
|
||||||
string Message = "Announcing now ";
|
std::string Message = "Announcing now ";
|
||||||
|
|
||||||
if(Announce)
|
if(Announce)
|
||||||
Message += "on";
|
Message += "on";
|
||||||
@ -1593,13 +1592,13 @@ void Client::GeneralChannelMessage(const char *Characters) {
|
|||||||
|
|
||||||
if(!Characters) return;
|
if(!Characters) return;
|
||||||
|
|
||||||
string Message = Characters;
|
std::string Message = Characters;
|
||||||
|
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::GeneralChannelMessage(string Message) {
|
void Client::GeneralChannelMessage(std::string Message) {
|
||||||
|
|
||||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_ChannelMessage, Message.length() + 3);
|
EQApplicationPacket *outapp = new EQApplicationPacket(OP_ChannelMessage, Message.length() + 3);
|
||||||
char *PacketBuffer = (char *)outapp->pBuffer;
|
char *PacketBuffer = (char *)outapp->pBuffer;
|
||||||
@ -1613,40 +1612,40 @@ void Client::GeneralChannelMessage(string Message) {
|
|||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SetChannelPassword(string ChannelPassword) {
|
void Client::SetChannelPassword(std::string ChannelPassword) {
|
||||||
|
|
||||||
string::size_type PasswordStart = ChannelPassword.find_first_not_of(" ");
|
std::string::size_type PasswordStart = ChannelPassword.find_first_not_of(" ");
|
||||||
|
|
||||||
if(PasswordStart == string::npos) {
|
if(PasswordStart == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat password <new password> <channel name>";
|
std::string Message = "Incorrect syntax: /chat password <new password> <channel name>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string::size_type Space = ChannelPassword.find_first_of(" ", PasswordStart);
|
std::string::size_type Space = ChannelPassword.find_first_of(" ", PasswordStart);
|
||||||
|
|
||||||
if(Space == string::npos) {
|
if(Space == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat password <new password> <channel name>";
|
std::string Message = "Incorrect syntax: /chat password <new password> <channel name>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Password = ChannelPassword.substr(PasswordStart, Space - PasswordStart);
|
std::string Password = ChannelPassword.substr(PasswordStart, Space - PasswordStart);
|
||||||
|
|
||||||
string::size_type ChannelStart = ChannelPassword.find_first_not_of(" ", Space);
|
std::string::size_type ChannelStart = ChannelPassword.find_first_not_of(" ", Space);
|
||||||
|
|
||||||
if(ChannelStart == string::npos) {
|
if(ChannelStart == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat password <new password> <channel name>";
|
std::string Message = "Incorrect syntax: /chat password <new password> <channel name>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ChannelName = ChannelPassword.substr(ChannelStart);
|
std::string ChannelName = ChannelPassword.substr(ChannelStart);
|
||||||
|
|
||||||
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||||
|
|
||||||
string Message;
|
std::string Message;
|
||||||
|
|
||||||
if(!strcasecmp(Password.c_str(), "remove")) {
|
if(!strcasecmp(Password.c_str(), "remove")) {
|
||||||
Password.clear();
|
Password.clear();
|
||||||
@ -1660,13 +1659,13 @@ void Client::SetChannelPassword(string ChannelPassword) {
|
|||||||
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
|
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
|
||||||
|
|
||||||
if(!RequiredChannel) {
|
if(!RequiredChannel) {
|
||||||
string Message = "Channel not found.";
|
std::string Message = "Channel not found.";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) {
|
if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) {
|
||||||
string Message = "You do not own or have moderator rights on channel " + ChannelName;
|
std::string Message = "You do not own or have moderator rights on channel " + ChannelName;
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1677,35 +1676,35 @@ void Client::SetChannelPassword(string ChannelPassword) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SetChannelOwner(string CommandString) {
|
void Client::SetChannelOwner(std::string CommandString) {
|
||||||
|
|
||||||
string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
if(PlayerStart == string::npos) {
|
if(PlayerStart == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat setowner <player> <channel>";
|
std::string Message = "Incorrect syntax: /chat setowner <player> <channel>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
||||||
|
|
||||||
if(Space == string::npos) {
|
if(Space == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat setowner <player> <channel>";
|
std::string Message = "Incorrect syntax: /chat setowner <player> <channel>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string NewOwner = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
std::string NewOwner = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
||||||
|
|
||||||
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
||||||
|
|
||||||
if(ChannelStart == string::npos) {
|
if(ChannelStart == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat setowner <player> <channel>";
|
std::string Message = "Incorrect syntax: /chat setowner <player> <channel>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||||
|
|
||||||
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||||
@ -1720,7 +1719,7 @@ void Client::SetChannelOwner(string CommandString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!RequiredChannel->IsOwner(GetName()) && !IsChannelAdmin()) {
|
if(!RequiredChannel->IsOwner(GetName()) && !IsChannelAdmin()) {
|
||||||
string Message = "You do not own channel " + ChannelName;
|
std::string Message = "You do not own channel " + ChannelName;
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1740,17 +1739,17 @@ void Client::SetChannelOwner(string CommandString) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::OPList(string CommandString) {
|
void Client::OPList(std::string CommandString) {
|
||||||
|
|
||||||
string::size_type ChannelStart = CommandString.find_first_not_of(" ");
|
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
if(ChannelStart == string::npos) {
|
if(ChannelStart == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat oplist <channel>";
|
std::string Message = "Incorrect syntax: /chat oplist <channel>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||||
|
|
||||||
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||||
@ -1765,35 +1764,35 @@ void Client::OPList(string CommandString) {
|
|||||||
RequiredChannel->SendOPList(this);
|
RequiredChannel->SendOPList(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelInvite(string CommandString) {
|
void Client::ChannelInvite(std::string CommandString) {
|
||||||
|
|
||||||
string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
if(PlayerStart == string::npos) {
|
if(PlayerStart == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat invite <player> <channel>";
|
std::string Message = "Incorrect syntax: /chat invite <player> <channel>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
||||||
|
|
||||||
if(Space == string::npos) {
|
if(Space == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat invite <player> <channel>";
|
std::string Message = "Incorrect syntax: /chat invite <player> <channel>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Invitee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
std::string Invitee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
||||||
|
|
||||||
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
||||||
|
|
||||||
if(ChannelStart == string::npos) {
|
if(ChannelStart == std::string::npos) {
|
||||||
string Message = "Incorrect syntax: /chat invite <player> <channel>";
|
std::string Message = "Incorrect syntax: /chat invite <player> <channel>";
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||||
|
|
||||||
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||||
@ -1830,7 +1829,7 @@ void Client::ChannelInvite(string CommandString) {
|
|||||||
|
|
||||||
if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName())) {
|
if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName())) {
|
||||||
|
|
||||||
string Message = "You do not own or have moderator rights to channel " + ChannelName;
|
std::string Message = "You do not own or have moderator rights to channel " + ChannelName;
|
||||||
|
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
@ -1851,19 +1850,19 @@ void Client::ChannelInvite(string CommandString) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelModerate(string CommandString) {
|
void Client::ChannelModerate(std::string CommandString) {
|
||||||
|
|
||||||
string::size_type ChannelStart = CommandString.find_first_not_of(" ");
|
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
if(ChannelStart == string::npos) {
|
if(ChannelStart == std::string::npos) {
|
||||||
|
|
||||||
string Message = "Incorrect syntax: /chat moderate <channel>";
|
std::string Message = "Incorrect syntax: /chat moderate <channel>";
|
||||||
|
|
||||||
GeneralChannelMessage(Message);
|
GeneralChannelMessage(Message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||||
|
|
||||||
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||||
@ -1884,44 +1883,43 @@ void Client::ChannelModerate(string CommandString) {
|
|||||||
|
|
||||||
RequiredChannel->SetModerated(!RequiredChannel->IsModerated());
|
RequiredChannel->SetModerated(!RequiredChannel->IsModerated());
|
||||||
|
|
||||||
if(!RequiredChannel->IsClientInChannel(this)) {
|
if(!RequiredChannel->IsClientInChannel(this))
|
||||||
if(RequiredChannel->IsModerated())
|
if(RequiredChannel->IsModerated())
|
||||||
GeneralChannelMessage("Channel " + ChannelName + " is now moderated.");
|
GeneralChannelMessage("Channel " + ChannelName + " is now moderated.");
|
||||||
else
|
else
|
||||||
GeneralChannelMessage("Channel " + ChannelName + " is no longer moderated.");
|
GeneralChannelMessage("Channel " + ChannelName + " is no longer moderated.");
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelGrantModerator(string CommandString) {
|
void Client::ChannelGrantModerator(std::string CommandString) {
|
||||||
|
|
||||||
string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
if(PlayerStart == string::npos) {
|
if(PlayerStart == std::string::npos) {
|
||||||
|
|
||||||
GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>");
|
GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
||||||
|
|
||||||
if(Space == string::npos) {
|
if(Space == std::string::npos) {
|
||||||
|
|
||||||
GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>");
|
GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Moderator = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
std::string Moderator = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
||||||
|
|
||||||
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
||||||
|
|
||||||
if(ChannelStart == string::npos) {
|
if(ChannelStart == std::string::npos) {
|
||||||
|
|
||||||
GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>");
|
GeneralChannelMessage("Incorrect syntax: /chat grant <player> <channel>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||||
|
|
||||||
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||||
@ -1976,33 +1974,33 @@ void Client::ChannelGrantModerator(string CommandString) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelGrantVoice(string CommandString) {
|
void Client::ChannelGrantVoice(std::string CommandString) {
|
||||||
|
|
||||||
string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
if(PlayerStart == string::npos) {
|
if(PlayerStart == std::string::npos) {
|
||||||
|
|
||||||
GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>");
|
GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
||||||
|
|
||||||
if(Space == string::npos) {
|
if(Space == std::string::npos) {
|
||||||
GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>");
|
GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Voicee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
std::string Voicee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
||||||
|
|
||||||
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
||||||
|
|
||||||
if(ChannelStart == string::npos) {
|
if(ChannelStart == std::string::npos) {
|
||||||
GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>");
|
GeneralChannelMessage("Incorrect syntax: /chat voice <player> <channel>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||||
|
|
||||||
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||||
@ -2063,34 +2061,34 @@ void Client::ChannelGrantVoice(string CommandString) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelKick(string CommandString) {
|
void Client::ChannelKick(std::string CommandString) {
|
||||||
|
|
||||||
string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
if(PlayerStart == string::npos) {
|
if(PlayerStart == std::string::npos) {
|
||||||
|
|
||||||
GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>");
|
GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart);
|
||||||
|
|
||||||
if(Space == string::npos) {
|
if(Space == std::string::npos) {
|
||||||
|
|
||||||
GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>");
|
GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Kickee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
std::string Kickee = CapitaliseName(CommandString.substr(PlayerStart, Space - PlayerStart));
|
||||||
|
|
||||||
string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space);
|
||||||
|
|
||||||
if(ChannelStart == string::npos) {
|
if(ChannelStart == std::string::npos) {
|
||||||
|
|
||||||
GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>");
|
GeneralChannelMessage("Incorrect syntax: /chat kick <player> <channel>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart));
|
||||||
|
|
||||||
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
|
||||||
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
|
||||||
@ -2164,7 +2162,7 @@ void Client::ToggleInvites() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string Client::ChannelSlotName(int SlotNumber) {
|
std::string Client::ChannelSlotName(int SlotNumber) {
|
||||||
|
|
||||||
if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS))
|
if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS))
|
||||||
return "";
|
return "";
|
||||||
@ -2234,7 +2232,7 @@ void Client::SetConnectionType(char c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *Clientlist::IsCharacterOnline(string CharacterName) {
|
Client *Clientlist::IsCharacterOnline(std::string CharacterName) {
|
||||||
|
|
||||||
// This method is used to determine if the character we are a sending an email to is connected to the mailserver,
|
// This method is used to determine if the character we are a sending an email to is connected to the mailserver,
|
||||||
// so we can send them a new email notification.
|
// so we can send them a new email notification.
|
||||||
@ -2243,7 +2241,7 @@ Client *Clientlist::IsCharacterOnline(string CharacterName) {
|
|||||||
// i.e. for the character they are logged in as, or for the character whose mailbox they have selected in the
|
// i.e. for the character they are logged in as, or for the character whose mailbox they have selected in the
|
||||||
// mail window.
|
// mail window.
|
||||||
//
|
//
|
||||||
list<Client*>::iterator Iterator;
|
std::list<Client*>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); Iterator++) {
|
||||||
|
|
||||||
@ -2262,7 +2260,7 @@ Client *Clientlist::IsCharacterOnline(string CharacterName) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Client::GetMailBoxNumber(string CharacterName) {
|
int Client::GetMailBoxNumber(std::string CharacterName) {
|
||||||
|
|
||||||
for(unsigned int i = 0; i < Characters.size(); i++)
|
for(unsigned int i = 0; i < Characters.size(); i++)
|
||||||
if(Characters[i].Name == CharacterName)
|
if(Characters[i].Name == CharacterName)
|
||||||
@ -2271,7 +2269,7 @@ int Client::GetMailBoxNumber(string CharacterName) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendNotification(int MailBoxNumber, string Subject, string From, int MessageID) {
|
void Client::SendNotification(int MailBoxNumber, std::string Subject, std::string From, int MessageID) {
|
||||||
|
|
||||||
char TimeStamp[100];
|
char TimeStamp[100];
|
||||||
|
|
||||||
@ -2328,13 +2326,13 @@ void Client::ChangeMailBox(int NewMailBox) {
|
|||||||
|
|
||||||
void Client::SendFriends() {
|
void Client::SendFriends() {
|
||||||
|
|
||||||
vector<string> Friends, Ignorees;
|
std::vector<std::string> Friends, Ignorees;
|
||||||
|
|
||||||
database.GetFriendsAndIgnore(GetCharID(), Friends, Ignorees);
|
database.GetFriendsAndIgnore(GetCharID(), Friends, Ignorees);
|
||||||
|
|
||||||
EQApplicationPacket *outapp;
|
EQApplicationPacket *outapp;
|
||||||
|
|
||||||
vector<string>::iterator Iterator;
|
std::vector<std::string>::iterator Iterator;
|
||||||
|
|
||||||
Iterator = Friends.begin();
|
Iterator = Friends.begin();
|
||||||
|
|
||||||
@ -2361,7 +2359,7 @@ void Client::SendFriends() {
|
|||||||
|
|
||||||
while(Iterator != Ignorees.end()) {
|
while(Iterator != Ignorees.end()) {
|
||||||
|
|
||||||
string Ignoree = "SOE.EQ." + WorldShortName + "." + (*Iterator);
|
std::string Ignoree = "SOE.EQ." + WorldShortName + "." + (*Iterator);
|
||||||
|
|
||||||
outapp = new EQApplicationPacket(OP_Ignore, Ignoree.length() + 2);
|
outapp = new EQApplicationPacket(OP_Ignore, Ignoree.length() + 2);
|
||||||
|
|
||||||
@ -2381,7 +2379,7 @@ void Client::SendFriends() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string Client::MailBoxName() {
|
std::string Client::MailBoxName() {
|
||||||
|
|
||||||
if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1)))
|
if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1)))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -78,7 +78,7 @@ static const CommandEntry Commands[] = {
|
|||||||
struct CharacterEntry {
|
struct CharacterEntry {
|
||||||
int CharID;
|
int CharID;
|
||||||
int Level;
|
int Level;
|
||||||
string Name;
|
std::string Name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
@ -92,25 +92,25 @@ public:
|
|||||||
void ClearCharacters() { Characters.clear(); }
|
void ClearCharacters() { Characters.clear(); }
|
||||||
void SendMailBoxes();
|
void SendMailBoxes();
|
||||||
inline void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) { ClientStream->QueuePacket(p, ack_req); }
|
inline void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) { ClientStream->QueuePacket(p, ack_req); }
|
||||||
string GetName() { if(Characters.size()) return Characters[0].Name; else return ""; }
|
std::string GetName() { if(Characters.size()) return Characters[0].Name; else return ""; }
|
||||||
void JoinChannels(string ChannelList);
|
void JoinChannels(std::string ChannelList);
|
||||||
void LeaveChannels(string ChannelList);
|
void LeaveChannels(std::string ChannelList);
|
||||||
void LeaveAllChannels(bool SendUpdatedChannelList = true);
|
void LeaveAllChannels(bool SendUpdatedChannelList = true);
|
||||||
void AddToChannelList(ChatChannel *JoinedChannel);
|
void AddToChannelList(ChatChannel *JoinedChannel);
|
||||||
void RemoveFromChannelList(ChatChannel *JoinedChannel);
|
void RemoveFromChannelList(ChatChannel *JoinedChannel);
|
||||||
void SendChannelMessage(string Message);
|
void SendChannelMessage(std::string Message);
|
||||||
void SendChannelMessage(string ChannelName, string Message, Client *Sender);
|
void SendChannelMessage(std::string ChannelName, std::string Message, Client *Sender);
|
||||||
void SendChannelMessageByNumber(string Message);
|
void SendChannelMessageByNumber(std::string Message);
|
||||||
void SendChannelList();
|
void SendChannelList();
|
||||||
void CloseConnection();
|
void CloseConnection();
|
||||||
void ToggleAnnounce(string State);
|
void ToggleAnnounce(std::string State);
|
||||||
bool IsAnnounceOn() { return (Announce == true); }
|
bool IsAnnounceOn() { return (Announce == true); }
|
||||||
void AnnounceJoin(ChatChannel *Channel, Client *c);
|
void AnnounceJoin(ChatChannel *Channel, Client *c);
|
||||||
void AnnounceLeave(ChatChannel *Channel, Client *c);
|
void AnnounceLeave(ChatChannel *Channel, Client *c);
|
||||||
void GeneralChannelMessage(string Message);
|
void GeneralChannelMessage(std::string Message);
|
||||||
void GeneralChannelMessage(const char *Characters);
|
void GeneralChannelMessage(const char *Characters);
|
||||||
void SetChannelPassword(string ChannelPassword);
|
void SetChannelPassword(std::string ChannelPassword);
|
||||||
void ProcessChannelList(string CommandString);
|
void ProcessChannelList(std::string CommandString);
|
||||||
void AccountUpdate();
|
void AccountUpdate();
|
||||||
int ChannelCount();
|
int ChannelCount();
|
||||||
inline void SetAccountID(int inAccountID) { AccountID = inAccountID; }
|
inline void SetAccountID(int inAccountID) { AccountID = inAccountID; }
|
||||||
@ -121,14 +121,14 @@ public:
|
|||||||
inline int GetAccountStatus() { return Status; }
|
inline int GetAccountStatus() { return Status; }
|
||||||
inline bool GetHideMe() { return HideMe; }
|
inline bool GetHideMe() { return HideMe; }
|
||||||
inline uint32 GetKarma() { return TotalKarma; }
|
inline uint32 GetKarma() { return TotalKarma; }
|
||||||
void SetChannelOwner(string CommandString);
|
void SetChannelOwner(std::string CommandString);
|
||||||
void OPList(string CommandString);
|
void OPList(std::string CommandString);
|
||||||
void ChannelInvite(string CommandString);
|
void ChannelInvite(std::string CommandString);
|
||||||
void ChannelGrantModerator(string CommandString);
|
void ChannelGrantModerator(std::string CommandString);
|
||||||
void ChannelGrantVoice(string CommandString);
|
void ChannelGrantVoice(std::string CommandString);
|
||||||
void ChannelKick(string CommandString);
|
void ChannelKick(std::string CommandString);
|
||||||
void ChannelModerate(string CommandString);
|
void ChannelModerate(std::string CommandString);
|
||||||
string ChannelSlotName(int ChannelNumber);
|
std::string ChannelSlotName(int ChannelNumber);
|
||||||
void ToggleInvites();
|
void ToggleInvites();
|
||||||
bool InvitesAllowed() { return AllowInvites; }
|
bool InvitesAllowed() { return AllowInvites; }
|
||||||
bool IsRevoked() { return Revoked; }
|
bool IsRevoked() { return Revoked; }
|
||||||
@ -137,13 +137,13 @@ public:
|
|||||||
inline bool CanListAllChannels() { return (Status >= RuleI(Channels, RequiredStatusListAll)); }
|
inline bool CanListAllChannels() { return (Status >= RuleI(Channels, RequiredStatusListAll)); }
|
||||||
void SendHelp();
|
void SendHelp();
|
||||||
inline bool GetForceDisconnect() { return ForceDisconnect; }
|
inline bool GetForceDisconnect() { return ForceDisconnect; }
|
||||||
string MailBoxName();
|
std::string MailBoxName();
|
||||||
int GetMailBoxNumber() { return CurrentMailBox; }
|
int GetMailBoxNumber() { return CurrentMailBox; }
|
||||||
int GetMailBoxNumber(string CharacterName);
|
int GetMailBoxNumber(std::string CharacterName);
|
||||||
void SetConnectionType(char c);
|
void SetConnectionType(char c);
|
||||||
ConnectionType GetConnectionType() { return TypeOfConnection; }
|
ConnectionType GetConnectionType() { return TypeOfConnection; }
|
||||||
inline bool IsMailConnection() { return (TypeOfConnection == ConnectionTypeMail) || (TypeOfConnection == ConnectionTypeCombined); }
|
inline bool IsMailConnection() { return (TypeOfConnection == ConnectionTypeMail) || (TypeOfConnection == ConnectionTypeCombined); }
|
||||||
void SendNotification(int MailBoxNumber, string From, string Subject, int MessageID);
|
void SendNotification(int MailBoxNumber, std::string From, std::string Subject, int MessageID);
|
||||||
void ChangeMailBox(int NewMailBox);
|
void ChangeMailBox(int NewMailBox);
|
||||||
inline void SetMailBox(int NewMailBox) { CurrentMailBox = NewMailBox; }
|
inline void SetMailBox(int NewMailBox) { CurrentMailBox = NewMailBox; }
|
||||||
void SendFriends();
|
void SendFriends();
|
||||||
@ -152,7 +152,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int CurrentMailBox;
|
unsigned int CurrentMailBox;
|
||||||
vector<CharacterEntry> Characters;
|
std::vector<CharacterEntry> Characters;
|
||||||
ChatChannel *JoinedChannels[MAX_JOINED_CHANNELS];
|
ChatChannel *JoinedChannels[MAX_JOINED_CHANNELS];
|
||||||
bool Announce;
|
bool Announce;
|
||||||
int AccountID;
|
int AccountID;
|
||||||
@ -178,16 +178,16 @@ public:
|
|||||||
Clientlist(int MailPort);
|
Clientlist(int MailPort);
|
||||||
void Process();
|
void Process();
|
||||||
void CloseAllConnections();
|
void CloseAllConnections();
|
||||||
Client *FindCharacter(string CharacterName);
|
Client *FindCharacter(std::string CharacterName);
|
||||||
void CheckForStaleConnections(Client *c);
|
void CheckForStaleConnections(Client *c);
|
||||||
Client *IsCharacterOnline(string CharacterName);
|
Client *IsCharacterOnline(std::string CharacterName);
|
||||||
void ProcessOPMailCommand(Client *c, string CommandString);
|
void ProcessOPMailCommand(Client *c, std::string CommandString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
EQStreamFactory *chatsf;
|
EQStreamFactory *chatsf;
|
||||||
|
|
||||||
list<Client*> ClientChatConnections;
|
std::list<Client*> ClientChatConnections;
|
||||||
|
|
||||||
OpcodeManager *ChatOpMgr;
|
OpcodeManager *ChatOpMgr;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "../common/debug.h"
|
#include "../common/debug.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -45,10 +44,11 @@ using namespace std;
|
|||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "../common/eq_packet_structs.h"
|
#include "../common/eq_packet_structs.h"
|
||||||
#include "../common/MiscFunctions.h"
|
#include "../common/MiscFunctions.h"
|
||||||
|
#include "../common/StringUtil.h"
|
||||||
#include "chatchannel.h"
|
#include "chatchannel.h"
|
||||||
|
|
||||||
extern Clientlist *CL;
|
extern Clientlist *CL;
|
||||||
extern string GetMailPrefix();
|
extern std::string GetMailPrefix();
|
||||||
extern ChatChannelList *ChannelList;
|
extern ChatChannelList *ChannelList;
|
||||||
extern uint32 MailMessagesSent;
|
extern uint32 MailMessagesSent;
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ int Database::FindAccount(const char *CharacterName, Client *c) {
|
|||||||
return AccountID;
|
return AccountID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::VerifyMailKey(string CharacterName, int IPAddress, string MailKey) {
|
bool Database::VerifyMailKey(std::string CharacterName, int IPAddress, std::string MailKey) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
char* query = 0;
|
char* query = 0;
|
||||||
@ -328,9 +328,9 @@ bool Database::LoadChatChannels() {
|
|||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
|
|
||||||
string ChannelName = row[0];
|
std::string ChannelName = row[0];
|
||||||
string ChannelOwner = row[1];
|
std::string ChannelOwner = row[1];
|
||||||
string ChannelPassword = row[2];
|
std::string ChannelPassword = row[2];
|
||||||
|
|
||||||
ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, atoi(row[3]));
|
ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, atoi(row[3]));
|
||||||
}
|
}
|
||||||
@ -340,7 +340,7 @@ bool Database::LoadChatChannels() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::SetChannelPassword(string ChannelName, string Password) {
|
void Database::SetChannelPassword(std::string ChannelName, std::string Password) {
|
||||||
|
|
||||||
_log(UCS__TRACE, "Database::SetChannelPassword(%s, %s)", ChannelName.c_str(), Password.c_str());
|
_log(UCS__TRACE, "Database::SetChannelPassword(%s, %s)", ChannelName.c_str(), Password.c_str());
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ void Database::SetChannelPassword(string ChannelName, string Password) {
|
|||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::SetChannelOwner(string ChannelName, string Owner) {
|
void Database::SetChannelOwner(std::string ChannelName, std::string Owner) {
|
||||||
|
|
||||||
_log(UCS__TRACE, "Database::SetChannelOwner(%s, %s)", ChannelName.c_str(), Owner.c_str());
|
_log(UCS__TRACE, "Database::SetChannelOwner(%s, %s)", ChannelName.c_str(), Owner.c_str());
|
||||||
|
|
||||||
@ -541,17 +541,17 @@ void Database::SendBody(Client *c, int MessageNumber) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::SendMail(string Recipient, string From, string Subject, string Body, string RecipientsString) {
|
bool Database::SendMail(std::string Recipient, std::string From, std::string Subject, std::string Body, std::string RecipientsString) {
|
||||||
|
|
||||||
int CharacterID;
|
int CharacterID;
|
||||||
|
|
||||||
string CharacterName;
|
std::string CharacterName;
|
||||||
|
|
||||||
//printf("Database::SendMail(%s, %s, %s)\n", Recipient.c_str(), From.c_str(), Subject.c_str());
|
//printf("Database::SendMail(%s, %s, %s)\n", Recipient.c_str(), From.c_str(), Subject.c_str());
|
||||||
|
|
||||||
string::size_type LastPeriod = Recipient.find_last_of(".");
|
std::string::size_type LastPeriod = Recipient.find_last_of(".");
|
||||||
|
|
||||||
if(LastPeriod == string::npos)
|
if(LastPeriod == std::string::npos)
|
||||||
CharacterName = Recipient;
|
CharacterName = Recipient;
|
||||||
else
|
else
|
||||||
CharacterName = Recipient.substr(LastPeriod+1);
|
CharacterName = Recipient.substr(LastPeriod+1);
|
||||||
@ -604,7 +604,7 @@ bool Database::SendMail(string Recipient, string From, string Subject, string Bo
|
|||||||
Client *c = CL->IsCharacterOnline(CharacterName);
|
Client *c = CL->IsCharacterOnline(CharacterName);
|
||||||
|
|
||||||
if(c) {
|
if(c) {
|
||||||
string FQN = GetMailPrefix() + From;
|
std::string FQN = GetMailPrefix() + From;
|
||||||
|
|
||||||
c->SendNotification(c->GetMailBoxNumber(CharacterName), Subject, FQN, LastMsgID);
|
c->SendNotification(c->GetMailBoxNumber(CharacterName), Subject, FQN, LastMsgID);
|
||||||
}
|
}
|
||||||
@ -691,7 +691,7 @@ void Database::ExpireMail() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::AddFriendOrIgnore(int CharID, int Type, string Name) {
|
void Database::AddFriendOrIgnore(int CharID, int Type, std::string Name) {
|
||||||
|
|
||||||
const char *FriendsQuery="INSERT INTO `friends` (`charid`, `type`, `name`) VALUES ('%i', %i, '%s')";
|
const char *FriendsQuery="INSERT INTO `friends` (`charid`, `type`, `name`) VALUES ('%i', %i, '%s')";
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ void Database::AddFriendOrIgnore(int CharID, int Type, string Name) {
|
|||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::RemoveFriendOrIgnore(int CharID, int Type, string Name) {
|
void Database::RemoveFriendOrIgnore(int CharID, int Type, std::string Name) {
|
||||||
|
|
||||||
const char *FriendsQuery="DELETE FROM `friends` WHERE `charid`=%i AND `type`=%i and `name`='%s'";
|
const char *FriendsQuery="DELETE FROM `friends` WHERE `charid`=%i AND `type`=%i and `name`='%s'";
|
||||||
|
|
||||||
@ -726,7 +726,7 @@ void Database::RemoveFriendOrIgnore(int CharID, int Type, string Name) {
|
|||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::GetFriendsAndIgnore(int CharID, vector<string> &Friends, vector<string> &Ignorees) {
|
void Database::GetFriendsAndIgnore(int CharID, std::vector<std::string> &Friends, std::vector<std::string> &Ignorees) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
char* query = 0;
|
char* query = 0;
|
||||||
@ -748,7 +748,7 @@ void Database::GetFriendsAndIgnore(int CharID, vector<string> &Friends, vector<s
|
|||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
|
|
||||||
string Name = row[1];
|
std::string Name = row[1];
|
||||||
|
|
||||||
if(atoi(row[0]) == 0)
|
if(atoi(row[0]) == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -31,7 +31,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//atoi is not uint32 or uint32 safe!!!!
|
//atoi is not uint32 or uint32 safe!!!!
|
||||||
#define atoul(str) strtoul(str, nullptr, 10)
|
#define atoul(str) strtoul(str, nullptr, 10)
|
||||||
@ -45,20 +44,20 @@ public:
|
|||||||
|
|
||||||
int FindAccount(const char *CharacterName, Client *c);
|
int FindAccount(const char *CharacterName, Client *c);
|
||||||
int FindCharacter(const char *CharacterName);
|
int FindCharacter(const char *CharacterName);
|
||||||
bool VerifyMailKey(string CharacterName, int IPAddress, string MailKey);
|
bool VerifyMailKey(std::string CharacterName, int IPAddress, std::string MailKey);
|
||||||
bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len);
|
bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len);
|
||||||
bool LoadChatChannels();
|
bool LoadChatChannels();
|
||||||
void GetAccountStatus(Client *c);
|
void GetAccountStatus(Client *c);
|
||||||
void SetChannelPassword(string ChannelName, string Password);
|
void SetChannelPassword(std::string ChannelName, std::string Password);
|
||||||
void SetChannelOwner(string ChannelName, string Owner);
|
void SetChannelOwner(std::string ChannelName, std::string Owner);
|
||||||
void SendHeaders(Client *c);
|
void SendHeaders(Client *c);
|
||||||
void SendBody(Client *c, int MessageNumber);
|
void SendBody(Client *c, int MessageNumber);
|
||||||
bool SendMail(string Recipient, string From, string Subject, string Body, string RecipientsString);
|
bool SendMail(std::string Recipient, std::string From, std::string Subject, std::string Body, std::string RecipientsString);
|
||||||
void SetMessageStatus(int MessageNumber, int Status);
|
void SetMessageStatus(int MessageNumber, int Status);
|
||||||
void ExpireMail();
|
void ExpireMail();
|
||||||
void AddFriendOrIgnore(int CharID, int Type, string Name);
|
void AddFriendOrIgnore(int CharID, int Type, std::string Name);
|
||||||
void RemoveFriendOrIgnore(int CharID, int Type, string Name);
|
void RemoveFriendOrIgnore(int CharID, int Type, std::string Name);
|
||||||
void GetFriendsAndIgnore(int CharID, vector<string> &Friends, vector<string> &Ignorees);
|
void GetFriendsAndIgnore(int CharID, std::vector<std::string> &Friends, std::vector<std::string> &Ignorees);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -45,7 +45,7 @@ ChatChannelList *ChannelList;
|
|||||||
|
|
||||||
Database database;
|
Database database;
|
||||||
|
|
||||||
string WorldShortName;
|
std::string WorldShortName;
|
||||||
|
|
||||||
const ucsconfig *Config;
|
const ucsconfig *Config;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ void CatchSignal(int sig_num) {
|
|||||||
worldserver->Disconnect();
|
worldserver->Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetMailPrefix() {
|
std::string GetMailPrefix() {
|
||||||
|
|
||||||
return "SOE.EQ." + WorldShortName + ".";
|
return "SOE.EQ." + WorldShortName + ".";
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user