mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 12:41:30 +00:00
Remove trailing whitespace
This commit is contained in:
parent
7a93966158
commit
ffcff4aea1
@ -37,25 +37,25 @@ IF(MSVC)
|
||||
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86")
|
||||
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86")
|
||||
ENDIF(CMAKE_CL_64)
|
||||
|
||||
|
||||
#disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere
|
||||
OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON)
|
||||
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
|
||||
|
||||
|
||||
#fast FP if you'd like it
|
||||
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
|
||||
IF(EQEMU_FAST_FLOATINGPOINT)
|
||||
ADD_DEFINITIONS(/fp:fast)
|
||||
ENDIF(EQEMU_FAST_FLOATINGPOINT)
|
||||
|
||||
|
||||
#crash logging currently only works on windows x86/x64
|
||||
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
|
||||
IF(EQEMU_ENABLE_CRASH_LOGGING)
|
||||
ADD_DEFINITIONS(-DCRASH_LOGGING)
|
||||
ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
|
||||
|
||||
|
||||
#Disable safe SEH or not?
|
||||
OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF)
|
||||
IF(EQEMU_DISABLE_SAFESEH)
|
||||
@ -72,7 +72,7 @@ IF(MSVC)
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
|
||||
ENDIF(EQEMU_DISABLE_SAFESEH)
|
||||
|
||||
|
||||
#We want to compile /MT not /MD so we change that
|
||||
FOREACH(flag_var CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||
IF(${flag_var} MATCHES "/MD")
|
||||
|
||||
@ -37,7 +37,7 @@ IF(MYSQL_ROOT)
|
||||
PATHS ${MYSQL_ROOT}/lib/debug /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
|
||||
|
||||
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATHS ${MYSQL_ROOT}/lib /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
@ -49,7 +49,7 @@ ELSE(MYSQL_ROOT)
|
||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
|
||||
|
||||
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
@ -82,4 +82,3 @@ MARK_AS_ADVANCED(
|
||||
MySQL_LIBRARY_RELEASE
|
||||
MySQL_INCLUDE_DIR
|
||||
)
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -108,7 +108,7 @@ void BasePacket::ReadString(char *str, uint32 Offset, uint32 MaxLength) const
|
||||
while((j < size) && (i < MaxLength) && (str[i - 1] != 0));
|
||||
|
||||
str[i - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void DumpPacketHex(const BasePacket* app)
|
||||
{
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -71,7 +71,7 @@ public:
|
||||
uint32 ReadUInt32(uint32 Offset) const { uint32 value = *(uint32 *)(pBuffer + Offset); return value; }
|
||||
void ReadString(char *str) { uint32 len = static_cast<uint32>(strlen((char *)(pBuffer + _rpos))) + 1; memcpy(str, pBuffer + _rpos, len); _rpos += len; }
|
||||
void ReadString(char *str, uint32 Offset, uint32 MaxLength) const;
|
||||
|
||||
|
||||
uint32 GetWritePosition() { return _wpos; }
|
||||
uint32 GetReadPosition() { return _rpos; }
|
||||
void SetWritePosition(uint32 Newwpos) { _wpos = Newwpos; }
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "crc32.h"
|
||||
|
||||
uint16 CRC16(const unsigned char *buf, int size, int key)
|
||||
uint16 CRC16(const unsigned char *buf, int size, int key)
|
||||
{
|
||||
// This is computed as the lowest 16 bits of an Ethernet CRC32 checksum
|
||||
// where the key is prepended to the data in little endian order.
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -29,7 +29,7 @@
|
||||
#ifdef _WINDOWS
|
||||
|
||||
|
||||
Condition::Condition()
|
||||
Condition::Condition()
|
||||
{
|
||||
m_events[SignalEvent] = CreateEvent (nullptr, // security
|
||||
FALSE, // is auto-reset event?
|
||||
@ -69,28 +69,28 @@ void Condition::SignalAll()
|
||||
void Condition::Wait()
|
||||
{
|
||||
EnterCriticalSection(&CSMutex);
|
||||
|
||||
|
||||
m_waiters++;
|
||||
|
||||
|
||||
|
||||
|
||||
LeaveCriticalSection(&CSMutex);
|
||||
int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE);
|
||||
EnterCriticalSection(&CSMutex);
|
||||
|
||||
|
||||
m_waiters--;
|
||||
|
||||
|
||||
//see if we are the last person waiting on the condition, and there was a broadcast
|
||||
//if so, we need to reset the broadcast event.
|
||||
if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent))
|
||||
ResetEvent(m_events[BroadcastEvent]);
|
||||
|
||||
|
||||
LeaveCriticalSection(&CSMutex);
|
||||
}
|
||||
|
||||
|
||||
#else //!WIN32
|
||||
|
||||
Condition::Condition()
|
||||
Condition::Condition()
|
||||
{
|
||||
pthread_cond_init(&cond,nullptr);
|
||||
pthread_mutex_init(&mutex,nullptr);
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -64,9 +64,9 @@ EQDBRes * EQDB::query(Const_char *q) {
|
||||
Const_char *EQDB::escape_string(Const_char *from) {
|
||||
int len = strlen(from);
|
||||
char *res = new char[len*2+1];
|
||||
|
||||
|
||||
mysql_real_escape_string(mysql_ref,res,from,len);
|
||||
|
||||
|
||||
res[len*2] = '\0';
|
||||
m_escapeBuffer = res;
|
||||
delete[] res;
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -32,10 +32,10 @@ public:
|
||||
static EQDB *Singleton() { return(&s_EQDB); }
|
||||
|
||||
static void SetMySQL(MYSQL *m) { s_EQDB.mysql_ref=m; }
|
||||
|
||||
|
||||
//BEGIN PERL EXPORT
|
||||
//NOTE: you must have a space after the * of a return value
|
||||
|
||||
|
||||
unsigned int field_count();
|
||||
unsigned long affected_rows();
|
||||
unsigned long insert_id();
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -23,7 +23,7 @@ vector<string> EQDBRes::fetch_row_array() {
|
||||
vector<string> array;
|
||||
if(res == nullptr)
|
||||
return(array);
|
||||
|
||||
|
||||
int count=mysql_num_fields(res);
|
||||
MYSQL_ROW row=mysql_fetch_row(res);
|
||||
for (int i=0;i<count;i++)
|
||||
@ -36,7 +36,7 @@ map<string,string> EQDBRes::fetch_row_hash() {
|
||||
map<string,string> rowhash;
|
||||
if(res == nullptr)
|
||||
return(rowhash);
|
||||
|
||||
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_ROW row;
|
||||
unsigned long num_fields,i;
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -30,7 +30,7 @@ class EQDBRes {
|
||||
public:
|
||||
EQDBRes(MYSQL_RES *r) { res=r; }
|
||||
~EQDBRes() { finish(); }
|
||||
|
||||
|
||||
//BEGIN PERL EXPORT
|
||||
unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; }
|
||||
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -71,7 +71,7 @@ void AddEQEMuError(eEQEMuError iError, bool iExitNow) {
|
||||
}
|
||||
iterator.Advance();
|
||||
}
|
||||
|
||||
|
||||
char* tmp = new char[6];
|
||||
tmp[0] = 1;
|
||||
tmp[5] = 0;
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
#include "../common/types.h"
|
||||
|
||||
enum eEQEMuError { EQEMuError_NoError,
|
||||
enum eEQEMuError { EQEMuError_NoError,
|
||||
EQEMuError_Mysql_1405,
|
||||
EQEMuError_Mysql_2003,
|
||||
EQEMuError_Mysql_2005,
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -63,7 +63,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
|
||||
text=ParseTextBlock(sub_ele,"port",true);
|
||||
if (text)
|
||||
LoginPort=atoi(text);
|
||||
|
||||
|
||||
text=ParseTextBlock(sub_ele,"account",true);
|
||||
if (text)
|
||||
LoginAccount=text;
|
||||
@ -97,7 +97,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
|
||||
}
|
||||
} while(sub_ele);
|
||||
}
|
||||
|
||||
|
||||
// Check for locked
|
||||
sub_ele = ele->FirstChildElement("locked");
|
||||
if (sub_ele != nullptr)
|
||||
@ -140,7 +140,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
|
||||
text = sub_ele->Attribute("enabled");
|
||||
if (text && !strcasecmp(text,"true"))
|
||||
WorldHTTPEnabled=true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ void EQEmuConfig::do_chatserver(TiXmlElement *ele) {
|
||||
if (text)
|
||||
ChatPort=atoi(text);
|
||||
}
|
||||
|
||||
|
||||
void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
|
||||
@ -167,7 +167,7 @@ void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
|
||||
if (text)
|
||||
MailPort=atoi(text);
|
||||
}
|
||||
|
||||
|
||||
void EQEmuConfig::do_database(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
|
||||
@ -192,7 +192,7 @@ void EQEmuConfig::do_database(TiXmlElement *ele) {
|
||||
DatabaseDB=text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EQEmuConfig::do_qsdatabase(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -52,11 +52,11 @@ public:
|
||||
uint16 WorldHTTPPort;
|
||||
string WorldHTTPMimeFile;
|
||||
string SharedKey;
|
||||
|
||||
|
||||
// From <chatserver/>
|
||||
string ChatHost;
|
||||
uint16 ChatPort;
|
||||
|
||||
|
||||
// From <mailserver/>
|
||||
string MailHost;
|
||||
uint16 MailPort;
|
||||
@ -85,7 +85,7 @@ public:
|
||||
string MapDir;
|
||||
string QuestDir;
|
||||
string PluginDir;
|
||||
|
||||
|
||||
// From <launcher/>
|
||||
string LogPrefix;
|
||||
string LogSuffix;
|
||||
@ -103,7 +103,7 @@ public:
|
||||
// uint16 DynamicCount;
|
||||
|
||||
// map<string,uint16> StaticZones;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static EQEmuConfig *_config;
|
||||
@ -168,7 +168,7 @@ protected:
|
||||
MapDir="Maps";
|
||||
QuestDir="quests";
|
||||
PluginDir="plugins";
|
||||
|
||||
|
||||
// Launcher
|
||||
LogPrefix = "logs/zone-";
|
||||
LogSuffix = ".log";
|
||||
@ -181,22 +181,22 @@ protected:
|
||||
#else
|
||||
ZoneExe = "./zone";
|
||||
#endif
|
||||
|
||||
|
||||
// Zones
|
||||
ZonePortLow=7000;
|
||||
ZonePortHigh=7999;
|
||||
DefaultStatus=0;
|
||||
|
||||
|
||||
// For where zones need to connect to.
|
||||
WorldIP="127.0.0.1";
|
||||
|
||||
|
||||
// Dynamics to start
|
||||
//DynamicCount=5;
|
||||
|
||||
|
||||
MaxClients=-1;
|
||||
|
||||
|
||||
LoginCount=0;
|
||||
|
||||
|
||||
}
|
||||
virtual ~EQEmuConfig() {}
|
||||
|
||||
@ -204,7 +204,7 @@ public:
|
||||
|
||||
// Produce a const singleton
|
||||
static const EQEmuConfig *get() {
|
||||
if (_config == nullptr)
|
||||
if (_config == nullptr)
|
||||
LoadConfig();
|
||||
return(_config);
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
/*
|
||||
* EQStream classes, by Quagmire
|
||||
*/
|
||||
|
||||
@ -61,17 +61,17 @@ using namespace std;
|
||||
//#define PRIORITYTEST
|
||||
|
||||
template <typename type> // LO_BYTE
|
||||
type LO_BYTE (type a) {return (a&=0xff);}
|
||||
template <typename type> // HI_BYTE
|
||||
type HI_BYTE (type a) {return (a&=0xff00);}
|
||||
type LO_BYTE (type a) {return (a&=0xff);}
|
||||
template <typename type> // HI_BYTE
|
||||
type HI_BYTE (type a) {return (a&=0xff00);}
|
||||
template <typename type> // LO_WORD
|
||||
type LO_WORD (type a) {return (a&=0xffff);}
|
||||
template <typename type> // HI_WORD
|
||||
type HI_WORD (type a) {return (a&=0xffff0000);}
|
||||
type LO_WORD (type a) {return (a&=0xffff);}
|
||||
template <typename type> // HI_WORD
|
||||
type HI_WORD (type a) {return (a&=0xffff0000);}
|
||||
template <typename type> // HI_LOSWAPshort
|
||||
type HI_LOSWAPshort (type a) {return (LO_BYTE(a)<<8) | (HI_BYTE(a)>>8);}
|
||||
type HI_LOSWAPshort (type a) {return (LO_BYTE(a)<<8) | (HI_BYTE(a)>>8);}
|
||||
template <typename type> // HI_LOSWAPlong
|
||||
type HI_LOSWAPlong (type x) {return (LO_WORD(a)<<16) | (HIWORD(a)>>16);}
|
||||
type HI_LOSWAPlong (type x) {return (LO_WORD(a)<<16) | (HIWORD(a)>>16);}
|
||||
|
||||
EQStreamServer::EQStreamServer(uint16 iPort) {
|
||||
RunLoop = false;
|
||||
@ -125,7 +125,7 @@ bool EQStreamServer::Open(uint16 iPort) {
|
||||
unsigned long nonblocking = 1;
|
||||
#endif
|
||||
|
||||
/* Setup internet address information.
|
||||
/* Setup internet address information.
|
||||
This is used with the bind() call */
|
||||
memset((char *) &address, 0, sizeof(address));
|
||||
address.sin_family = AF_INET;
|
||||
@ -207,7 +207,7 @@ void EQStreamServer::Process() {
|
||||
}
|
||||
|
||||
uchar buffer[1518];
|
||||
|
||||
|
||||
int status;
|
||||
struct sockaddr_in from;
|
||||
unsigned int fromlen;
|
||||
@ -240,13 +240,13 @@ void EQStreamServer::Process() {
|
||||
connection_list.erase(tmp);
|
||||
continue;
|
||||
}
|
||||
EQStream* eqs_data = connection->second;
|
||||
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
|
||||
EQStream* eqs_data = connection->second;
|
||||
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
|
||||
map <string, EQStream*>::iterator tmp=connection;
|
||||
connection++;
|
||||
safe_delete(eqs_data);
|
||||
connection_list.erase(tmp);
|
||||
}
|
||||
}
|
||||
else if(!eqs_data->RunLoop) {
|
||||
eqs_data->Process(sock);
|
||||
connection++;
|
||||
@ -291,7 +291,7 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
|
||||
return;
|
||||
}
|
||||
|
||||
if (data[1]==0x01) {
|
||||
if (data[1]==0x01) {
|
||||
cout << "New EQStream Connection." << endl;
|
||||
EQStream* tmp = new EQStream(irIP, irPort);
|
||||
tmp->RecvData(data, size);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Copyright (C) 2005 Michael S. Finger
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -43,7 +43,7 @@ EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
|
||||
void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
|
||||
buffer += sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]\n", emu_opcode, size);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
|
||||
fprintf(to, "[EmuOpCode 0x%04x Size=%lu]\n",emu_opcode,(unsigned long)size);
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
|
||||
buffer += sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]\n",opcode,size);
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
|
||||
fprintf(to, "[ProtoOpCode 0x%04x Size=%lu]\n",opcode,(unsigned long)size);
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
buffer += sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||
#else
|
||||
@ -144,7 +144,7 @@ void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
fprintf(to, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||
#else
|
||||
@ -156,7 +156,7 @@ void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) con
|
||||
{
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
buffer += sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
|
||||
#else
|
||||
@ -190,7 +190,7 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
fprintf(to, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
|
||||
#else
|
||||
@ -421,7 +421,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
|
||||
{
|
||||
test[i]=buffer[i]^KC;
|
||||
}
|
||||
memcpy(buffer,test,size);
|
||||
memcpy(buffer,test,size);
|
||||
free(test);
|
||||
}
|
||||
}
|
||||
@ -445,7 +445,7 @@ void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey
|
||||
{
|
||||
test[i]=buffer[i]^KC;
|
||||
}
|
||||
memcpy(buffer,test,size);
|
||||
memcpy(buffer,test,size);
|
||||
free(test);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Copyright (C) 2005 Michael S. Finger
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -39,9 +39,9 @@ class EQPacket : public BasePacket {
|
||||
friend class EQStream;
|
||||
public:
|
||||
virtual ~EQPacket() {}
|
||||
|
||||
|
||||
uint32 Size() const { return size+2; }
|
||||
|
||||
|
||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||
virtual void build_header_dump(char *buffer) const;
|
||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
@ -50,7 +50,7 @@ public:
|
||||
void SetOpcode(EmuOpcode op) { emu_opcode = op; }
|
||||
const EmuOpcode GetOpcode() const { return(emu_opcode); }
|
||||
// const char *GetOpcodeName() const;
|
||||
|
||||
|
||||
protected:
|
||||
//this is just a cache so we dont look it up several times on Get()
|
||||
//and it is mutable so we can store the cached copy even on a const object
|
||||
@ -68,32 +68,32 @@ class EQProtocolPacket : public BasePacket {
|
||||
friend class EQStream;
|
||||
friend class EQStreamPair;
|
||||
public:
|
||||
EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) : BasePacket(buf,len), opcode(op) { acked = false; }
|
||||
EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) : BasePacket(buf,len), opcode(op) { acked = false; }
|
||||
// EQProtocolPacket(const unsigned char *buf, uint32 len);
|
||||
bool combine(const EQProtocolPacket *rhs);
|
||||
uint32 serialize (unsigned char *dest) const;
|
||||
EQProtocolPacket *Copy() { return new EQProtocolPacket(opcode,pBuffer,size); }
|
||||
EQRawApplicationPacket *MakeAppPacket() const;
|
||||
|
||||
|
||||
bool acked;
|
||||
|
||||
|
||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||
virtual void build_header_dump(char *buffer) const;
|
||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
static bool ValidateCRC(const unsigned char *buffer, int length, uint32 Key);
|
||||
static uint32 Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize);
|
||||
static uint32 Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize);
|
||||
static void ChatDecode(unsigned char *buffer, int size, int DecodeKey);
|
||||
static void ChatEncode(unsigned char *buffer, int size, int EncodeKey);
|
||||
|
||||
|
||||
uint16 GetRawOpcode() const { return(opcode); }
|
||||
|
||||
|
||||
uint32 Size() const { return size+2; }
|
||||
|
||||
|
||||
//the actual raw EQ opcode
|
||||
uint16 opcode;
|
||||
};
|
||||
@ -102,25 +102,25 @@ class EQApplicationPacket : public EQPacket {
|
||||
// friend class EQProtocolPacket;
|
||||
friend class EQStream;
|
||||
public:
|
||||
EQApplicationPacket() : EQPacket(OP_Unknown,nullptr,0)
|
||||
EQApplicationPacket() : EQPacket(OP_Unknown,nullptr,0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op) : EQPacket(op,nullptr,0)
|
||||
EQApplicationPacket(const EmuOpcode op) : EQPacket(op,nullptr,0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,nullptr,len)
|
||||
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,nullptr,len)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len)
|
||||
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
bool combine(const EQApplicationPacket *rhs);
|
||||
uint32 serialize (uint16 opcode, unsigned char *dest) const;
|
||||
uint32 Size() const { return size+app_opcode_size; }
|
||||
|
||||
|
||||
virtual EQApplicationPacket *Copy() const;
|
||||
|
||||
|
||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||
virtual void build_header_dump(char *buffer) const;
|
||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
uint8 app_opcode_size;
|
||||
@ -135,17 +135,17 @@ class EQRawApplicationPacket : public EQApplicationPacket {
|
||||
public:
|
||||
EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len);
|
||||
uint16 GetRawOpcode() const { return(opcode); }
|
||||
|
||||
|
||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||
virtual void build_header_dump(char *buffer) const;
|
||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
//the actual raw EQ opcode
|
||||
uint16 opcode;
|
||||
|
||||
|
||||
EQRawApplicationPacket(const unsigned char *buf, const uint32 len);
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Copyright (C) 2005 Michael S. Finger
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -106,11 +106,11 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf
|
||||
|
||||
EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32 len) {
|
||||
uint16 proto_opcode = ntohs(*(const uint16 *)buf);
|
||||
|
||||
|
||||
//advance over opcode.
|
||||
buf += 2;
|
||||
len -= 2;
|
||||
|
||||
|
||||
return(new EQProtocolPacket(proto_opcode, buf, len));
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ uint32 processed=0,subpacket_length=0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case OP_AppCombined: {
|
||||
processed=0;
|
||||
while(processed<p->size) {
|
||||
@ -171,7 +171,7 @@ uint32 processed=0,subpacket_length=0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case OP_Packet: {
|
||||
if(!p->pBuffer || (p->Size() < 4))
|
||||
{
|
||||
@ -221,7 +221,7 @@ uint32 processed=0,subpacket_length=0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case OP_Fragment: {
|
||||
if(!p->pBuffer || (p->Size() < 4))
|
||||
{
|
||||
@ -317,10 +317,10 @@ uint32 processed=0,subpacket_length=0;
|
||||
#ifndef COLLECTOR
|
||||
if (GetState()==ESTABLISHED) {
|
||||
_log(NET__ERROR, _L "Received OP_SessionRequest in ESTABLISHED state (%d)" __L, GetState());
|
||||
|
||||
|
||||
/*RemoveData();
|
||||
init();
|
||||
State=UNESTABLISHED;*/
|
||||
init();
|
||||
State=UNESTABLISHED;*/
|
||||
_SendDisconnect();
|
||||
SetState(CLOSED);
|
||||
break;
|
||||
@ -360,7 +360,7 @@ uint32 processed=0,subpacket_length=0;
|
||||
encoded=(Response->Format&FLAG_ENCODED);
|
||||
|
||||
_log(NET__NET_TRACE, _L "Received OP_SessionResponse: session %lu, maxlen %d, key %lu, compressed? %s, encoded? %s" __L, (unsigned long)Session, MaxLen, (unsigned long)Key, compressed?"yes":"no", encoded?"yes":"no");
|
||||
|
||||
|
||||
// Kinda kludgy, but trie for now
|
||||
if (StreamType==UnknownStream) {
|
||||
if (compressed) {
|
||||
@ -406,7 +406,7 @@ uint32 processed=0,subpacket_length=0;
|
||||
#ifndef COLLECTOR
|
||||
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
|
||||
MOutboundQueue.lock();
|
||||
|
||||
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "Pre-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
@ -457,9 +457,9 @@ if(NextSequencedSend > SequencedQueue.size()) {
|
||||
}
|
||||
#ifndef COLLECTOR
|
||||
SessionStats *Stats=(SessionStats *)p->pBuffer;
|
||||
_log(NET__NET_TRACE, _L "Received Stats: %lu packets received, %lu packets sent, Deltas: local %lu, (%lu <- %lu -> %lu) remote %lu" __L,
|
||||
(unsigned long)ntohl(Stats->packets_received), (unsigned long)ntohl(Stats->packets_sent), (unsigned long)ntohl(Stats->last_local_delta),
|
||||
(unsigned long)ntohl(Stats->low_delta), (unsigned long)ntohl(Stats->average_delta),
|
||||
_log(NET__NET_TRACE, _L "Received Stats: %lu packets received, %lu packets sent, Deltas: local %lu, (%lu <- %lu -> %lu) remote %lu" __L,
|
||||
(unsigned long)ntohl(Stats->packets_received), (unsigned long)ntohl(Stats->packets_sent), (unsigned long)ntohl(Stats->last_local_delta),
|
||||
(unsigned long)ntohl(Stats->low_delta), (unsigned long)ntohl(Stats->average_delta),
|
||||
(unsigned long)ntohl(Stats->high_delta), (unsigned long)ntohl(Stats->last_remote_delta));
|
||||
uint64 x=Stats->packets_received;
|
||||
Stats->packets_received=Stats->packets_sent;
|
||||
@ -502,7 +502,7 @@ void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
|
||||
{
|
||||
if(p == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
EQApplicationPacket *newp = p->Copy();
|
||||
|
||||
if (newp != nullptr)
|
||||
@ -513,18 +513,18 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
|
||||
{
|
||||
EQApplicationPacket *pack=*p;
|
||||
*p = nullptr; //clear caller's pointer.. effectively takes ownership
|
||||
|
||||
|
||||
if(pack == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
if(OpMgr == nullptr || *OpMgr == nullptr) {
|
||||
_log(NET__DEBUG, _L "Packet enqueued into a stream with no opcode manager, dropping." __L);
|
||||
delete pack;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uint16 opcode = (*OpMgr)->EmuToEQ(pack->emu_opcode);
|
||||
|
||||
|
||||
//make sure this packet is compatible with this stream
|
||||
/* if(StreamType == UnknownStream || StreamType == ChatOrMailStream) {
|
||||
_log(NET__DEBUG, _L "Stream type undetermined (%s), packet ignored" __L, StreamTypeString(StreamType));
|
||||
@ -534,9 +534,9 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
|
||||
_log(NET__ERROR, _L "Trying to queue a packet of type %s into a stream of type %s, dropping it." __L, StreamTypeString(pack->GetPacketType()), StreamTypeString(StreamType));
|
||||
return;
|
||||
}*/
|
||||
|
||||
|
||||
_log(NET__APP_TRACE, "Queueing %sacked packet with opcode 0x%x (%s) and length %d", ack_req?"":"non-", opcode, OpcodeManager::EmuToName(pack->emu_opcode), pack->size);
|
||||
|
||||
|
||||
if (!ack_req) {
|
||||
NonSequencedPush(new EQProtocolPacket(opcode, pack->pBuffer, pack->size));
|
||||
delete pack;
|
||||
@ -556,15 +556,15 @@ uint32 length;
|
||||
|
||||
unsigned char *tmpbuff=new unsigned char[p->size+3];
|
||||
length=p->serialize(opcode, tmpbuff);
|
||||
|
||||
|
||||
EQProtocolPacket *out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
|
||||
*(uint32 *)(out->pBuffer+2)=htonl(p->Size());
|
||||
used=MaxLen-10;
|
||||
memcpy(out->pBuffer+6,tmpbuff,used);
|
||||
_log(NET__FRAGMENT, _L "First fragment: used %d/%d. Put size %d in the packet" __L, used, p->size, p->Size());
|
||||
SequencedPush(out);
|
||||
|
||||
|
||||
|
||||
|
||||
while (used<length) {
|
||||
out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
|
||||
chunksize=min(length-used,MaxLen-6);
|
||||
@ -684,7 +684,7 @@ deque<EQProtocolPacket *>::iterator sitr;
|
||||
sitr = SequencedQueue.begin();
|
||||
if (sitr!=SequencedQueue.end())
|
||||
sitr += NextSequencedSend;
|
||||
|
||||
|
||||
// Loop until both are empty or MaxSends is reached
|
||||
while(!SeqEmpty || !NonSeqEmpty) {
|
||||
|
||||
@ -703,7 +703,7 @@ deque<EQProtocolPacket *>::iterator sitr;
|
||||
ReadyToSend.push(p);
|
||||
BytesWritten+=p->size;
|
||||
p=nullptr;
|
||||
|
||||
|
||||
if (BytesWritten > threshold) {
|
||||
// Sent enough this round, lets stop to be fair
|
||||
_log(NET__RATES, _L "Exceeded write threshold in nonseq (%d > %d)" __L, BytesWritten, threshold);
|
||||
@ -721,7 +721,7 @@ deque<EQProtocolPacket *>::iterator sitr;
|
||||
}
|
||||
|
||||
if (sitr!=SequencedQueue.end()) {
|
||||
//_log(NET__NET_COMBINE, _L "Send Seq with %d seq packets starting at seq %d, next send %d, and %d non-seq packets." __L,
|
||||
//_log(NET__NET_COMBINE, _L "Send Seq with %d seq packets starting at seq %d, next send %d, and %d non-seq packets." __L,
|
||||
// SequencedQueue.size(), SequencedBase, NextSequencedSend, NonSequencedQueue.size());
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "Pre-Send Seq NSS=%d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, NextSequencedSend, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
@ -802,7 +802,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
|
||||
delete p;
|
||||
ReadyToSend.pop();
|
||||
}
|
||||
|
||||
|
||||
//see if we need to send our disconnect and finish our close
|
||||
if(SeqEmpty && NonSeqEmpty) {
|
||||
//no more data to send
|
||||
@ -825,7 +825,7 @@ sockaddr_in address;
|
||||
address.sin_port=remote_port;
|
||||
#ifdef NOWAY
|
||||
uint32 ip=address.sin_addr.s_addr;
|
||||
cout << "Sending to: "
|
||||
cout << "Sending to: "
|
||||
<< (int)*(unsigned char *)&ip
|
||||
<< "." << (int)*((unsigned char *)&ip+1)
|
||||
<< "." << (int)*((unsigned char *)&ip+2)
|
||||
@ -886,7 +886,7 @@ char temp[15];
|
||||
ntohs(from->sin_port));
|
||||
//cout << timestamp() << "Data from: " << temp << " OpCode 0x" << hex << setw(2) << setfill('0') << (int)p->opcode << dec << endl;
|
||||
//dump_message(p->pBuffer,p->size,timestamp());
|
||||
|
||||
|
||||
}
|
||||
return p;
|
||||
}*/
|
||||
@ -904,12 +904,12 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(Ses
|
||||
if (encoded)
|
||||
Response->Format|=FLAG_ENCODED;
|
||||
Response->Key=htonl(Key);
|
||||
|
||||
|
||||
out->size=sizeof(SessionResponse);
|
||||
|
||||
|
||||
_log(NET__NET_TRACE, _L "Sending OP_SessionResponse: session %lu, maxlen=%d, key=0x%x, compressed? %s, encoded? %s" __L,
|
||||
(unsigned long)Session, MaxLen, Key, compressed?"yes":"no", encoded?"yes":"no");
|
||||
|
||||
|
||||
NonSequencedPush(out);
|
||||
}
|
||||
|
||||
@ -920,9 +920,9 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(Sess
|
||||
memset(Request,0,sizeof(SessionRequest));
|
||||
Request->Session=htonl(time(nullptr));
|
||||
Request->MaxLength=htonl(512);
|
||||
|
||||
|
||||
_log(NET__NET_TRACE, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength));
|
||||
|
||||
|
||||
NonSequencedPush(out);
|
||||
}
|
||||
|
||||
@ -930,11 +930,11 @@ void EQStream::_SendDisconnect()
|
||||
{
|
||||
if(GetState() == CLOSED)
|
||||
return;
|
||||
|
||||
|
||||
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionDisconnect,nullptr,sizeof(uint32));
|
||||
*(uint32 *)out->pBuffer=htonl(Session);
|
||||
NonSequencedPush(out);
|
||||
|
||||
|
||||
_log(NET__NET_TRACE, _L "Sending OP_SessionDisconnect: session %lu" __L, (unsigned long)Session);
|
||||
}
|
||||
|
||||
@ -956,7 +956,7 @@ EQRawApplicationPacket *p=nullptr;
|
||||
InboundQueue.erase(itr);
|
||||
}
|
||||
MInboundQueue.unlock();
|
||||
|
||||
|
||||
//resolve the opcode if we can.
|
||||
if(p) {
|
||||
if(OpMgr != nullptr && *OpMgr != nullptr) {
|
||||
@ -969,7 +969,7 @@ EQRawApplicationPacket *p=nullptr;
|
||||
p->SetOpcode(emu_op);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -984,7 +984,7 @@ EQRawApplicationPacket *p=nullptr;
|
||||
InboundQueue.erase(itr);
|
||||
}
|
||||
MInboundQueue.unlock();
|
||||
|
||||
|
||||
//resolve the opcode if we can.
|
||||
if(p) {
|
||||
if(OpMgr != nullptr && *OpMgr != nullptr) {
|
||||
@ -1018,9 +1018,9 @@ EQRawApplicationPacket *p=nullptr;
|
||||
void EQStream::InboundQueueClear()
|
||||
{
|
||||
EQApplicationPacket *p=nullptr;
|
||||
|
||||
|
||||
_log(NET__APP_TRACE, _L "Clearing inbound queue" __L);
|
||||
|
||||
|
||||
MInboundQueue.lock();
|
||||
if (!InboundQueue.empty()) {
|
||||
vector<EQRawApplicationPacket *>::iterator itr;
|
||||
@ -1036,11 +1036,11 @@ EQApplicationPacket *p=nullptr;
|
||||
bool EQStream::HasOutgoingData()
|
||||
{
|
||||
bool flag;
|
||||
|
||||
|
||||
//once closed, we have nothing more to say
|
||||
if(CheckClosed())
|
||||
return(false);
|
||||
|
||||
|
||||
MOutboundQueue.lock();
|
||||
flag=(!NonSequencedQueue.empty());
|
||||
if (!flag) {
|
||||
@ -1063,7 +1063,7 @@ void EQStream::OutboundQueueClear()
|
||||
EQProtocolPacket *p=nullptr;
|
||||
|
||||
_log(NET__APP_TRACE, _L "Clearing outbound queue" __L);
|
||||
|
||||
|
||||
MOutboundQueue.lock();
|
||||
while(!NonSequencedQueue.empty()) {
|
||||
delete NonSequencedQueue.front();
|
||||
@ -1078,7 +1078,7 @@ EQProtocolPacket *p=nullptr;
|
||||
SequencedQueue.clear();
|
||||
}
|
||||
MOutboundQueue.unlock();
|
||||
|
||||
|
||||
/*if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "Out-bound Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
@ -1093,7 +1093,7 @@ void EQStream::PacketQueueClear()
|
||||
EQProtocolPacket *p=nullptr;
|
||||
|
||||
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
|
||||
|
||||
|
||||
if(!PacketQueue.empty()) {
|
||||
map<unsigned short,EQProtocolPacket *>::iterator itr;
|
||||
for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) {
|
||||
@ -1150,7 +1150,7 @@ long EQStream::GetLastAckSent()
|
||||
void EQStream::AckPackets(uint16 seq)
|
||||
{
|
||||
deque<EQProtocolPacket *>::iterator itr, tmp;
|
||||
|
||||
|
||||
MOutboundQueue.lock();
|
||||
//do a bit of sanity checking.
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
@ -1159,7 +1159,7 @@ if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Pre-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
|
||||
|
||||
SeqOrder ord = CompareSequence(SequencedBase, seq);
|
||||
if(ord == SeqInOrder) {
|
||||
//they are not acking anything new...
|
||||
@ -1197,7 +1197,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Post-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MOutboundQueue.unlock();
|
||||
}
|
||||
|
||||
@ -1222,7 +1222,7 @@ void EQStream::ProcessQueue()
|
||||
if(PacketQueue.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
EQProtocolPacket *qp=nullptr;
|
||||
while((qp=RemoveQueue(NextInSeq))!=nullptr) {
|
||||
_log(NET__DEBUG, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq);
|
||||
@ -1326,9 +1326,9 @@ void EQStream::SetState(EQStreamState state) {
|
||||
|
||||
|
||||
void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
|
||||
|
||||
|
||||
bool outgoing_data = HasOutgoingData(); //up here to avoid recursive locking
|
||||
|
||||
|
||||
EQStreamState orig_state = GetState();
|
||||
if (orig_state == CLOSING && !outgoing_data) {
|
||||
_log(NET__NET_TRACE, _L "Out of data in closing state, disconnecting." __L);
|
||||
@ -1410,7 +1410,7 @@ void EQStream::Close() {
|
||||
EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
|
||||
EQRawApplicationPacket *p = nullptr;
|
||||
MatchState res = MatchNotReady;
|
||||
|
||||
|
||||
MInboundQueue.lock();
|
||||
if (!InboundQueue.empty()) {
|
||||
//this is already getting hackish...
|
||||
@ -1444,7 +1444,7 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
|
||||
}
|
||||
}
|
||||
MInboundQueue.unlock();
|
||||
|
||||
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
||||
@ -55,10 +55,10 @@ struct SessionStats {
|
||||
/*030*/ uint64 packets_received;
|
||||
/*038*/
|
||||
};
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
class OpcodeManager;
|
||||
class OpcodeManager;
|
||||
//extern OpcodeManager *EQNetworkOpcodeManager;
|
||||
|
||||
//class EQStreamFactory;
|
||||
@ -73,7 +73,7 @@ class EQStream : public EQStreamInterface {
|
||||
SeqInOrder,
|
||||
SeqFuture
|
||||
} SeqOrder;
|
||||
|
||||
|
||||
uint32 remote_ip;
|
||||
uint16 remote_port;
|
||||
uint8 buffer[8192];
|
||||
@ -119,10 +119,10 @@ class EQStream : public EQStreamInterface {
|
||||
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
|
||||
long NextSequencedSend; //index into SequencedQueue
|
||||
Mutex MOutboundQueue;
|
||||
|
||||
|
||||
//a buffer we use for compression/decompression
|
||||
unsigned char _tempBuffer[2048];
|
||||
|
||||
|
||||
// Packets waiting to be processed
|
||||
vector<EQRawApplicationPacket *> InboundQueue;
|
||||
map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
|
||||
@ -136,18 +136,18 @@ class EQStream : public EQStreamInterface {
|
||||
int32 RateThreshold;
|
||||
int32 DecayRate;
|
||||
|
||||
|
||||
|
||||
OpcodeManager **OpMgr;
|
||||
|
||||
|
||||
// EQStreamFactory *const Factory;
|
||||
|
||||
EQRawApplicationPacket *MakeApplicationPacket(EQProtocolPacket *p);
|
||||
EQRawApplicationPacket *MakeApplicationPacket(const unsigned char *buf, uint32 len);
|
||||
EQProtocolPacket *MakeProtocolPacket(const unsigned char *buf, uint32 len);
|
||||
void SendPacket(uint16 opcode, EQApplicationPacket *p);
|
||||
|
||||
|
||||
void SetState(EQStreamState state);
|
||||
|
||||
|
||||
void SendSessionResponse();
|
||||
void SendSessionRequest();
|
||||
void SendAck(uint16 seq);
|
||||
@ -157,7 +157,7 @@ class EQStream : public EQStreamInterface {
|
||||
void NonSequencedPush(EQProtocolPacket *p);
|
||||
void SequencedPush(EQProtocolPacket *p);
|
||||
void WritePacket(int fd,EQProtocolPacket *p);
|
||||
|
||||
|
||||
|
||||
uint32 GetKey() { return Key; }
|
||||
void SetKey(uint32 k) { Key=k; }
|
||||
@ -172,16 +172,16 @@ class EQStream : public EQStreamInterface {
|
||||
void InboundQueuePush(EQRawApplicationPacket *p);
|
||||
EQRawApplicationPacket *PeekPacket(); //for collector.
|
||||
EQRawApplicationPacket *PopRawPacket(); //for collector.
|
||||
|
||||
|
||||
void InboundQueueClear();
|
||||
void OutboundQueueClear();
|
||||
void PacketQueueClear();
|
||||
|
||||
|
||||
void ProcessQueue();
|
||||
EQProtocolPacket *RemoveQueue(uint16 seq);
|
||||
|
||||
|
||||
void _SendDisconnect();
|
||||
|
||||
|
||||
void init();
|
||||
public:
|
||||
EQStream() { init(); remote_ip = 0; remote_port = 0; State=UNESTABLISHED; StreamType=UnknownStream; compressed=true; encoded=false; app_opcode_size=2; bytes_sent=0; bytes_recv=0; create_time=Timer::GetTimeSeconds(); }
|
||||
@ -201,21 +201,21 @@ class EQStream : public EQStreamInterface {
|
||||
virtual void RemoveData() { InboundQueueClear(); OutboundQueueClear(); PacketQueueClear(); /*if (CombinedAppPacket) delete CombinedAppPacket;*/ }
|
||||
virtual bool CheckState(EQStreamState state) { return GetState() == state; }
|
||||
virtual std::string Describe() const { return("Direct EQStream"); }
|
||||
|
||||
|
||||
void SetOpcodeManager(OpcodeManager **opm) { OpMgr = opm; }
|
||||
|
||||
|
||||
void CheckTimeout(uint32 now, uint32 timeout=30);
|
||||
bool HasOutgoingData();
|
||||
void Process(const unsigned char *data, const uint32 length);
|
||||
void SetLastPacketTime(uint32 t) {LastPacket=t;}
|
||||
void Write(int eq_fd);
|
||||
|
||||
|
||||
//
|
||||
inline bool IsInUse() { bool flag; MInUse.lock(); flag=(active_users>0); MInUse.unlock(); return flag; }
|
||||
inline void PutInUse() { MInUse.lock(); active_users++; MInUse.unlock(); }
|
||||
|
||||
|
||||
inline EQStreamState GetState() { EQStreamState s; MState.lock(); s=State; MState.unlock(); return s; }
|
||||
|
||||
|
||||
// static EQProtocolPacket *Read(int eq_fd, sockaddr_in *from);
|
||||
static SeqOrder CompareSequence(uint16 expected_seq , uint16 seq);
|
||||
|
||||
@ -259,7 +259,7 @@ class EQStream : public EQStreamInterface {
|
||||
return 0;
|
||||
return bytes_recv / (Timer::GetTimeSeconds() - create_time);
|
||||
}
|
||||
|
||||
|
||||
//used for dynamic stream identification
|
||||
class Signature {
|
||||
public:
|
||||
@ -274,7 +274,7 @@ class EQStream : public EQStreamInterface {
|
||||
MatchFailed
|
||||
} MatchState;
|
||||
MatchState CheckSignature(const Signature *sig);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -24,28 +24,28 @@ using namespace std;
|
||||
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
|
||||
{
|
||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
|
||||
fs->ReaderLoop();
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
|
||||
ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
|
||||
{
|
||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
|
||||
fs->WriterLoop();
|
||||
|
||||
#ifndef WIN32
|
||||
@ -55,7 +55,7 @@ ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
|
||||
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
|
||||
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
|
||||
: Timeoutable(5000), stream_timeout(timeout)
|
||||
{
|
||||
StreamType=type;
|
||||
@ -81,7 +81,7 @@ struct sockaddr_in address;
|
||||
#ifndef WIN32
|
||||
pthread_t t1,t2;
|
||||
#endif
|
||||
/* Setup internet address information.
|
||||
/* Setup internet address information.
|
||||
This is used with the bind() call */
|
||||
memset((char *) &address, 0, sizeof(address));
|
||||
address.sin_family = AF_INET;
|
||||
@ -172,10 +172,10 @@ timeval sleep_time;
|
||||
continue;
|
||||
} else if (num==0)
|
||||
continue;
|
||||
|
||||
|
||||
if(sock == -1)
|
||||
break; //somebody closed us while we were sleeping.
|
||||
|
||||
|
||||
if (FD_ISSET(sock,&readset)) {
|
||||
#ifdef _WINDOWS
|
||||
if ((length=recvfrom(sock,(char*)buffer,sizeof(buffer),0,(struct sockaddr*)&from,(int *)&socklen)) < 2)
|
||||
@ -208,7 +208,7 @@ timeval sleep_time;
|
||||
else
|
||||
curstream->PutInUse();
|
||||
MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it.
|
||||
|
||||
|
||||
if(curstream) {
|
||||
curstream->AddBytesRecv(length);
|
||||
curstream->Process(buffer,length);
|
||||
@ -225,17 +225,17 @@ void EQStreamFactory::CheckTimeout()
|
||||
{
|
||||
//lock streams the entire time were checking timeouts, it should be fast.
|
||||
MStreams.lock();
|
||||
|
||||
|
||||
unsigned long now=Timer::GetCurrentTime();
|
||||
map<string,EQStream *>::iterator stream_itr;
|
||||
|
||||
|
||||
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
|
||||
EQStream *s = stream_itr->second;
|
||||
|
||||
|
||||
s->CheckTimeout(now, stream_timeout);
|
||||
|
||||
|
||||
EQStreamState state = s->GetState();
|
||||
|
||||
|
||||
//not part of the else so we check it right away on state change
|
||||
if (state==CLOSED) {
|
||||
if (s->IsInUse()) {
|
||||
@ -267,7 +267,7 @@ bool decay=false;
|
||||
uint32 stream_count;
|
||||
|
||||
Timer DecayTimer(20);
|
||||
|
||||
|
||||
WriterRunning=true;
|
||||
DecayTimer.Enable();
|
||||
while(sock!=-1) {
|
||||
@ -278,12 +278,12 @@ Timer DecayTimer(20);
|
||||
if (!WriterRunning)
|
||||
break;
|
||||
MWriterRunning.unlock();
|
||||
|
||||
|
||||
havework = false;
|
||||
wants_write.clear();
|
||||
|
||||
decay=DecayTimer.Check();
|
||||
|
||||
|
||||
//copy streams into a seperate list so we dont have to keep
|
||||
//MStreams locked while we are writting
|
||||
MStreams.lock();
|
||||
@ -291,13 +291,13 @@ Timer DecayTimer(20);
|
||||
// If it's time to decay the bytes sent, then let's do it before we try to write
|
||||
if (decay)
|
||||
stream_itr->second->Decay();
|
||||
|
||||
|
||||
//bullshit checking, to see if this is really happening, GDB seems to think so...
|
||||
if(stream_itr->second == nullptr) {
|
||||
fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %s", stream_itr->first.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (stream_itr->second->HasOutgoingData()) {
|
||||
havework=true;
|
||||
stream_itr->second->PutInUse();
|
||||
@ -305,7 +305,7 @@ Timer DecayTimer(20);
|
||||
}
|
||||
}
|
||||
MStreams.unlock();
|
||||
|
||||
|
||||
//do the actual writes
|
||||
cur = wants_write.begin();
|
||||
end = wants_write.end();
|
||||
@ -313,7 +313,7 @@ Timer DecayTimer(20);
|
||||
(*cur)->Write(sock);
|
||||
(*cur)->ReleaseFromUse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Sleep(10);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ class EQStreamFactory : private Timeoutable {
|
||||
Condition WriterWork;
|
||||
|
||||
EQStreamType StreamType;
|
||||
|
||||
|
||||
queue<EQStream *> NewStreams;
|
||||
Mutex MNewStreams;
|
||||
|
||||
|
||||
@ -39,12 +39,12 @@ void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const cha
|
||||
void EQStreamIdentifier::Process() {
|
||||
vector<Record *>::iterator cur;
|
||||
vector<Patch *>::iterator curp, endp;
|
||||
|
||||
|
||||
//foreach pending stream.
|
||||
cur = m_streams.begin();
|
||||
while(cur != m_streams.end()) {
|
||||
Record *r = *cur;
|
||||
|
||||
|
||||
//first see if this stream has expired
|
||||
if(r->expire.Check(false)) {
|
||||
//this stream has failed to match any pattern in our timeframe.
|
||||
@ -54,7 +54,7 @@ void EQStreamIdentifier::Process() {
|
||||
cur = m_streams.erase(cur);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//then make sure the stream is still active
|
||||
//if stream hasn't finished initializing then continue;
|
||||
if(r->stream->GetState() == UNESTABLISHED)
|
||||
@ -87,18 +87,18 @@ void EQStreamIdentifier::Process() {
|
||||
cur = m_streams.erase(cur);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//not expired, check against all patch signatures
|
||||
|
||||
|
||||
bool found_one = false; //"we found a matching patch for this stream"
|
||||
bool all_ready = true; //"all signatures were ready to check the stream"
|
||||
|
||||
|
||||
//foreach possbile patch...
|
||||
curp = m_patches.begin();
|
||||
endp = m_patches.end();
|
||||
for(; !found_one && curp != endp; curp++) {
|
||||
Patch *p = *curp;
|
||||
|
||||
|
||||
//ask the stream to see if it matches the supplied signature
|
||||
EQStream::MatchState res = r->stream->CheckSignature(&p->signature);
|
||||
switch(res) {
|
||||
@ -109,13 +109,13 @@ void EQStreamIdentifier::Process() {
|
||||
break;
|
||||
case EQStream::MatchSuccessful: {
|
||||
//yay, a match.
|
||||
|
||||
|
||||
_log(NET__IDENTIFY, "Identified stream %s:%d with signature %s", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
|
||||
|
||||
|
||||
//might want to do something less-specific here... some day..
|
||||
EQStreamInterface *s = new EQStreamProxy(r->stream, p->structs, p->opcodes);
|
||||
m_identified.push(s);
|
||||
|
||||
|
||||
found_one = true;
|
||||
break;
|
||||
}
|
||||
@ -125,14 +125,14 @@ void EQStreamIdentifier::Process() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if we checked all patches and did not find a match.
|
||||
if(all_ready && !found_one) {
|
||||
//the stream cannot be identified.
|
||||
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d, no match found.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||
r->stream->ReleaseFromUse();
|
||||
}
|
||||
|
||||
|
||||
//if we found a match, or were not able to identify it
|
||||
if(found_one || all_ready) {
|
||||
//cannot print ip/port here. r->stream is invalid.
|
||||
@ -156,7 +156,7 @@ EQStreamInterface *EQStreamIdentifier::PopIdentified() {
|
||||
m_identified.pop();
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
||||
EQStreamIdentifier::Record::Record(EQStream *s)
|
||||
: stream(s),
|
||||
expire(STREAM_IDENT_WAIT_MS)
|
||||
|
||||
@ -15,17 +15,17 @@ class StructStrategy;
|
||||
class EQStreamIdentifier {
|
||||
public:
|
||||
~EQStreamIdentifier();
|
||||
|
||||
|
||||
//registration interface.
|
||||
void RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs);
|
||||
|
||||
|
||||
//main processing interface
|
||||
void Process();
|
||||
void AddStream(EQStream *& eqs);
|
||||
EQStreamInterface *PopIdentified();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
//registered patches..
|
||||
class Patch {
|
||||
public:
|
||||
@ -35,7 +35,7 @@ protected:
|
||||
const StructStrategy *structs;
|
||||
};
|
||||
std::vector<Patch *> m_patches; //we own these objects.
|
||||
|
||||
|
||||
//pending streams..
|
||||
class Record {
|
||||
public:
|
||||
|
||||
@ -19,7 +19,7 @@ class EQApplicationPacket;
|
||||
class EQStreamInterface {
|
||||
public:
|
||||
virtual ~EQStreamInterface() {}
|
||||
|
||||
|
||||
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) = 0;
|
||||
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true) = 0;
|
||||
virtual EQApplicationPacket *PopPacket() = 0;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Copyright (C) 2005 EQEmulator Team
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -66,7 +66,7 @@ if(res)
|
||||
else
|
||||
printf(": False\n");*/
|
||||
|
||||
|
||||
|
||||
if(l.src_ip != r.src_ip)
|
||||
return(l.src_ip < r.src_ip);
|
||||
if(l.dst_ip != r.dst_ip)
|
||||
@ -74,7 +74,7 @@ else
|
||||
if(l.src_port != r.src_port)
|
||||
return(l.src_port < r.src_port);
|
||||
return(l.dst_port < r.dst_port);
|
||||
|
||||
|
||||
/* //so, this turned out uglier than I had hoped
|
||||
if(l.src_ip < r.src_ip)
|
||||
return(true);
|
||||
@ -105,35 +105,35 @@ class EQStreamLocator {
|
||||
protected:
|
||||
typedef typename map<const EQStreamInfo, T *>::iterator iterator;
|
||||
public:
|
||||
|
||||
|
||||
void Clear() {
|
||||
streams.clear();
|
||||
}
|
||||
|
||||
|
||||
void AddStream(const EQStreamInfo &i, T *o) {
|
||||
//do we care to check if it exists?
|
||||
|
||||
|
||||
//add this stream, and its inverse
|
||||
streams[i] = o;
|
||||
EQStreamInfo inv;
|
||||
i.invert(inv);
|
||||
streams[inv] = o;
|
||||
}
|
||||
|
||||
|
||||
//deletes this stream, and its inverse
|
||||
void RemoveStream(const EQStreamInfo &i) {
|
||||
iterator res;
|
||||
res = streams.find(i);
|
||||
if(res != streams.end())
|
||||
streams.erase(res);
|
||||
|
||||
|
||||
EQStreamInfo inv;
|
||||
i.invert(inv);
|
||||
res = streams.find(inv);
|
||||
if(res != streams.end())
|
||||
streams.erase(res);
|
||||
}
|
||||
|
||||
|
||||
//removes every occurance of this stream from the list
|
||||
void RemoveStream(T *it) {
|
||||
iterator cur, end;
|
||||
@ -142,14 +142,14 @@ public:
|
||||
for(; cur != end; cur++) {
|
||||
if(cur->second == it) {
|
||||
streams.erase(cur);
|
||||
//lazy recursive delete for now, since we have to redo
|
||||
//lazy recursive delete for now, since we have to redo
|
||||
//our iterators anyways
|
||||
RemoveStream(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
T *GetStream(const EQStreamInfo &i) {
|
||||
iterator res;
|
||||
res = streams.find(i);
|
||||
@ -160,12 +160,12 @@ public:
|
||||
return(nullptr);
|
||||
return(res->second);
|
||||
}
|
||||
|
||||
|
||||
//allow people to iterate over the const struct
|
||||
// typedef map<const EQStreamInfo, T *>::const_iterator iterator;
|
||||
// inline iterator begin() const { return(streams.begin()); }
|
||||
// inline iterator end() const { return(streams.end()); }
|
||||
|
||||
|
||||
protected:
|
||||
map<const EQStreamInfo, T *> streams;
|
||||
};
|
||||
|
||||
@ -30,7 +30,7 @@ const EQClientVersion EQStreamProxy::ClientVersion() const
|
||||
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
|
||||
if(p == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
EQApplicationPacket *newp = p->Copy();
|
||||
FastQueuePacket(&newp, ack_req);
|
||||
}
|
||||
@ -45,7 +45,7 @@ EQApplicationPacket *EQStreamProxy::PopPacket() {
|
||||
EQApplicationPacket *pack = m_stream->PopPacket();
|
||||
if(pack == nullptr)
|
||||
return(nullptr);
|
||||
|
||||
|
||||
//pass this packet through the struct strategy.
|
||||
m_structs->Decode(pack);
|
||||
return(pack);
|
||||
|
||||
@ -15,7 +15,7 @@ public:
|
||||
//takes ownership of the stream.
|
||||
EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes);
|
||||
virtual ~EQStreamProxy();
|
||||
|
||||
|
||||
//EQStreamInterface:
|
||||
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true);
|
||||
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true);
|
||||
@ -28,7 +28,7 @@ public:
|
||||
virtual bool CheckState(EQStreamState state);
|
||||
virtual std::string Describe() const;
|
||||
virtual const EQClientVersion ClientVersion() const;
|
||||
|
||||
|
||||
virtual const uint32 GetBytesSent() const;
|
||||
virtual const uint32 GetBytesRecieved() const;
|
||||
virtual const uint32 GetBytesSentPerSecond() const;
|
||||
@ -39,7 +39,7 @@ protected:
|
||||
const StructStrategy *const m_structs; //we do not own this object.
|
||||
//this is a pointer to a pointer to make it less likely that a packet will
|
||||
//reference an invalid opcode manager when they are being reloaded.
|
||||
OpcodeManager **const m_opcodes; //we do not own this object.
|
||||
OpcodeManager **const m_opcodes; //we do not own this object.
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -17,30 +17,30 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* There are really two or three different objects shoe-hored into this
|
||||
* connection object. Sombody really needs to factor out the relay link
|
||||
* crap into its own subclass of this object, it will clean things up
|
||||
* crap into its own subclass of this object, it will clean things up
|
||||
* tremendously.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
@ -92,7 +92,7 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_s
|
||||
RelayServer = false;
|
||||
RelayCount = 0;
|
||||
RemoteID = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//client outgoing connection case (and client side relay)
|
||||
@ -246,7 +246,7 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
|
||||
return false;
|
||||
if (GetMode() != modePacket)
|
||||
return false;
|
||||
|
||||
|
||||
LockMutex lock(&MState);
|
||||
eTCPMode tmp = GetMode();
|
||||
if (tmp == modeTransition) {
|
||||
@ -391,13 +391,13 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return(TCPConnection::LineOutQueuePush(line));
|
||||
}
|
||||
|
||||
void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
|
||||
TCPConnection::Disconnect();
|
||||
|
||||
|
||||
if (RelayLink) {
|
||||
RelayLink->RemoveRelay(this, iSendRelayDisconnect);
|
||||
RelayLink = 0;
|
||||
@ -407,7 +407,7 @@ void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
|
||||
bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
|
||||
if(!TCPConnection::ConnectIP(irIP, irPort, errbuf))
|
||||
return(false);
|
||||
|
||||
|
||||
MSendQueue.lock();
|
||||
#ifdef MINILOGIN
|
||||
TCPMode = modePacket;
|
||||
@ -453,22 +453,22 @@ bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
|
||||
}
|
||||
#endif
|
||||
MSendQueue.unlock();
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void EmuTCPConnection::ClearBuffers() {
|
||||
TCPConnection::ClearBuffers();
|
||||
|
||||
|
||||
LockMutex lock2(&MOutQueueLock);
|
||||
ServerPacket* pack = 0;
|
||||
while ((pack = OutQueue.pop()))
|
||||
safe_delete(pack);
|
||||
|
||||
|
||||
EmuTCPNetPacket_Struct* tnps = 0;
|
||||
while ((tnps = InModeQueue.pop()))
|
||||
safe_delete(tnps);
|
||||
|
||||
|
||||
keepalive_timer.Start();
|
||||
timeout_timer.Start();
|
||||
}
|
||||
@ -810,7 +810,7 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
|
||||
sent_something = false;
|
||||
if(!TCPConnection::SendData(sent_something, errbuf))
|
||||
return(false);
|
||||
|
||||
|
||||
if(sent_something)
|
||||
keepalive_timer.Start();
|
||||
else if (TCPMode == modePacket && keepalive_timer.Check()) {
|
||||
@ -821,7 +821,7 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
|
||||
cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -832,13 +832,13 @@ bool EmuTCPConnection::RecvData(char* errbuf) {
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
if ((TCPMode == modePacket || TCPMode == modeTransition) && timeout_timer.Check()) {
|
||||
if (errbuf)
|
||||
snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Connection timeout");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
@ -31,67 +31,67 @@ class EmuTCPConnection : public TCPConnection {
|
||||
public:
|
||||
enum eTCPMode { modeConsole, modeTransition, modePacket };
|
||||
enum ePacketMode { packetModeZone, packetModeLauncher, packetModeLogin, packetModeUCS, packetModeQueryServ };
|
||||
|
||||
|
||||
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET iSock, uint32 irIP, uint16 irPort, bool iOldFormat = false);
|
||||
EmuTCPConnection(bool iOldFormat = false, EmuTCPServer* iRelayServer = 0, eTCPMode iMode = modePacket); // for outgoing connections
|
||||
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort); // for relay connections
|
||||
virtual ~EmuTCPConnection();
|
||||
|
||||
|
||||
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
|
||||
virtual void Disconnect(bool iSendRelayDisconnect = true);
|
||||
|
||||
|
||||
static EmuTCPNetPacket_Struct* MakePacket(ServerPacket* pack, uint32 iDestination = 0);
|
||||
static SPackSendQueue* MakeOldPacket(ServerPacket* pack);
|
||||
|
||||
|
||||
virtual bool SendPacket(ServerPacket* pack, uint32 iDestination = 0);
|
||||
virtual bool SendPacket(EmuTCPNetPacket_Struct* tnps);
|
||||
ServerPacket* PopPacket(); // OutQueuePop()
|
||||
void SetPacketMode(ePacketMode mode) { PacketMode = mode; }
|
||||
|
||||
|
||||
eTCPMode GetMode() const { return TCPMode; }
|
||||
ePacketMode GetPacketMode() const { return(PacketMode); }
|
||||
|
||||
|
||||
//relay crap:
|
||||
inline bool IsRelayServer() const { return RelayServer; }
|
||||
inline TCPConnection* GetRelayLink() const { return RelayLink; }
|
||||
inline uint32 GetRemoteID() const { return RemoteID; }
|
||||
|
||||
|
||||
protected:
|
||||
void OutQueuePush(ServerPacket* pack);
|
||||
void RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect);
|
||||
|
||||
|
||||
void SendNetErrorPacket(const char* reason = 0);
|
||||
|
||||
|
||||
virtual bool SendData(bool &sent_something, char* errbuf = 0);
|
||||
virtual bool RecvData(char* errbuf = 0);
|
||||
|
||||
|
||||
virtual bool ProcessReceivedData(char* errbuf = 0);
|
||||
bool ProcessReceivedDataAsPackets(char* errbuf = 0);
|
||||
bool ProcessReceivedDataAsOldPackets(char* errbuf = 0);
|
||||
void ProcessNetworkLayerPacket(ServerPacket* pack);
|
||||
|
||||
|
||||
virtual bool LineOutQueuePush(char* line);
|
||||
virtual void ClearBuffers();
|
||||
|
||||
|
||||
EmuTCPServer* Server;
|
||||
|
||||
|
||||
eTCPMode TCPMode;
|
||||
ePacketMode PacketMode;
|
||||
bool pOldFormat;
|
||||
|
||||
|
||||
Timer keepalive_timer;
|
||||
Timer timeout_timer;
|
||||
|
||||
|
||||
//relay crap:
|
||||
EmuTCPConnection* RelayLink;
|
||||
int32 RelayCount;
|
||||
bool RelayServer;
|
||||
uint32 RemoteID;
|
||||
|
||||
|
||||
//input queue...
|
||||
void InModeQueuePush(EmuTCPNetPacket_Struct* tnps);
|
||||
MyQueue<EmuTCPNetPacket_Struct> InModeQueue;
|
||||
|
||||
|
||||
//output queue...
|
||||
MyQueue<ServerPacket> OutQueue;
|
||||
Mutex MOutQueueLock;
|
||||
|
||||
292
common/Item.cpp
292
common/Item.cpp
@ -42,7 +42,7 @@ int32 NextItemInstSerialNumber = 1;
|
||||
|
||||
static inline int32 GetNextItemInstSerialNumber() {
|
||||
|
||||
// The Bazaar relies on each item a client has up for Trade having a unique
|
||||
// The Bazaar relies on each item a client has up for Trade having a unique
|
||||
// identifier. This 'SerialNumber' is sent in Serialized item packets and
|
||||
// is used in Bazaar packets to identify the item a player is buying or inspecting.
|
||||
//
|
||||
@ -103,8 +103,8 @@ ItemInstQueue::~ItemInstQueue() {
|
||||
|
||||
Inventory::~Inventory() {
|
||||
map<int16, ItemInst*>::iterator cur,end;
|
||||
|
||||
|
||||
|
||||
|
||||
cur = m_worn.begin();
|
||||
end = m_worn.end();
|
||||
for(; cur != end; cur++) {
|
||||
@ -112,7 +112,7 @@ Inventory::~Inventory() {
|
||||
safe_delete(tmp);
|
||||
}
|
||||
m_worn.clear();
|
||||
|
||||
|
||||
cur = m_inv.begin();
|
||||
end = m_inv.end();
|
||||
for(; cur != end; cur++) {
|
||||
@ -120,7 +120,7 @@ Inventory::~Inventory() {
|
||||
safe_delete(tmp);
|
||||
}
|
||||
m_inv.clear();
|
||||
|
||||
|
||||
cur = m_bank.begin();
|
||||
end = m_bank.end();
|
||||
for(; cur != end; cur++) {
|
||||
@ -128,7 +128,7 @@ Inventory::~Inventory() {
|
||||
safe_delete(tmp);
|
||||
}
|
||||
m_bank.clear();
|
||||
|
||||
|
||||
cur = m_shbank.begin();
|
||||
end = m_shbank.end();
|
||||
for(; cur != end; cur++) {
|
||||
@ -136,7 +136,7 @@ Inventory::~Inventory() {
|
||||
safe_delete(tmp);
|
||||
}
|
||||
m_shbank.clear();
|
||||
|
||||
|
||||
cur = m_trade.begin();
|
||||
end = m_trade.end();
|
||||
for(; cur != end; cur++) {
|
||||
@ -163,11 +163,11 @@ ItemInst::ItemInst(const ItemInst& copy)
|
||||
for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) {
|
||||
ItemInst* inst_old = it->second;
|
||||
ItemInst* inst_new = nullptr;
|
||||
|
||||
|
||||
if (inst_old) {
|
||||
inst_new = inst_old->Clone();
|
||||
}
|
||||
|
||||
|
||||
if (inst_new != nullptr) {
|
||||
m_contents[it->first] = inst_new;
|
||||
}
|
||||
@ -200,11 +200,11 @@ bool ItemInst::IsType(ItemClass item_class) const
|
||||
{
|
||||
// Check usage type
|
||||
if ((m_use_type == ItemUseWorldContainer) && (item_class == ItemClassContainer))
|
||||
|
||||
|
||||
return true;
|
||||
if (!m_item)
|
||||
return false;
|
||||
|
||||
|
||||
return (m_item->ItemClass == item_class);
|
||||
}
|
||||
|
||||
@ -229,14 +229,14 @@ bool ItemInst::IsEquipable(int16 slot_id) const
|
||||
{
|
||||
if (!m_item)
|
||||
return false;
|
||||
|
||||
|
||||
if(slot_id == 9999) {
|
||||
slot_id = 22;
|
||||
uint32 slot_mask = (1 << slot_id);
|
||||
if (slot_mask & m_item->Slots)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (slot_id < 22) {
|
||||
uint32 slot_mask = (1 << slot_id);
|
||||
if (slot_mask & m_item->Slots)
|
||||
@ -321,7 +321,7 @@ bool ItemInst::IsAmmo() const {
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Retrieve augment inside item
|
||||
@ -329,7 +329,7 @@ ItemInst* ItemInst::GetAugment(uint8 slot) const
|
||||
{
|
||||
if (m_item->ItemClass == ItemClassCommon)
|
||||
return GetItem(slot);
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ ItemInst* ItemInst::GetItem(uint8 index) const
|
||||
ItemInst* inst = it->second;
|
||||
return inst;
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -384,8 +384,8 @@ void ItemInst::PutItem(uint8 index, const ItemInst& inst)
|
||||
{
|
||||
// Clean up item already in slot (if exists)
|
||||
DeleteItem(index);
|
||||
|
||||
|
||||
|
||||
|
||||
// Delegate to internal method
|
||||
_PutItem(index, inst.Clone());
|
||||
}
|
||||
@ -423,7 +423,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent)
|
||||
const Item_Struct* item = inst->GetItem();
|
||||
del = cur;
|
||||
cur++;
|
||||
|
||||
|
||||
switch(is_nodrop) {
|
||||
case byFlagSet:
|
||||
if (item->NoDrop == 0) {
|
||||
@ -440,7 +440,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch(is_norent) {
|
||||
case byFlagSet:
|
||||
if (item->NoRent == 0) {
|
||||
@ -470,7 +470,7 @@ ItemInst* ItemInst::PopItem(uint8 index)
|
||||
m_contents.erase(index);
|
||||
return inst;
|
||||
}
|
||||
|
||||
|
||||
// Return pointer that needs to be deleted (or otherwise managed)
|
||||
return nullptr;
|
||||
}
|
||||
@ -492,7 +492,7 @@ ItemInst* ItemInstQueue::pop()
|
||||
{
|
||||
if (m_list.size() == 0)
|
||||
return nullptr;
|
||||
|
||||
|
||||
ItemInst* inst = m_list.front();
|
||||
m_list.pop_front();
|
||||
return inst;
|
||||
@ -509,13 +509,13 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
|
||||
{
|
||||
_CP(Inventory_GetItem);
|
||||
ItemInst* result = nullptr;
|
||||
|
||||
|
||||
// Cursor
|
||||
if (slot_id == SLOT_CURSOR) {
|
||||
// Cursor slot
|
||||
result = m_cursor.peek_front();
|
||||
}
|
||||
|
||||
|
||||
// Non bag slots
|
||||
else if (slot_id>=3000 && slot_id<=3007) {
|
||||
// Trade slots
|
||||
@ -537,7 +537,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
|
||||
// Equippable slots (on body)
|
||||
result = _GetItem(m_worn, slot_id);
|
||||
}
|
||||
|
||||
|
||||
// Inner bag slots
|
||||
else if (slot_id>=3031 && slot_id<=3110) {
|
||||
// Trade bag slots
|
||||
@ -574,7 +574,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
|
||||
result = inst->GetItem(Inventory::CalcBagIdx(slot_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -656,13 +656,13 @@ int16 Inventory::PutItem(int16 slot_id, const ItemInst& inst)
|
||||
{
|
||||
// Clean up item already in slot (if exists)
|
||||
DeleteItem(slot_id);
|
||||
|
||||
|
||||
if (!inst) {
|
||||
// User is effectively deleting the item
|
||||
// in the slot, why hold a null ptr in map<>?
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
// Delegate to internal method
|
||||
return _PutItem(slot_id, inst.Clone());
|
||||
}
|
||||
@ -693,48 +693,48 @@ int16 Inventory::HasItem(uint32 item_id, uint8 quantity, uint8 where)
|
||||
{
|
||||
_CP(Inventory_HasItem);
|
||||
int16 slot_id = SLOT_INVALID;
|
||||
|
||||
|
||||
//Altered by Father Nitwit to support a specification of
|
||||
//where to search, with a default value to maintain compatibility
|
||||
|
||||
|
||||
// Check each inventory bucket
|
||||
if(where & invWhereWorn) {
|
||||
slot_id = _HasItem(m_worn, item_id, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWherePersonal) {
|
||||
slot_id = _HasItem(m_inv, item_id, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereBank) {
|
||||
slot_id = _HasItem(m_bank, item_id, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereSharedBank) {
|
||||
slot_id = _HasItem(m_shbank, item_id, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereTrading) {
|
||||
slot_id = _HasItem(m_trade, item_id, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereCursor) {
|
||||
// Check cursor queue
|
||||
slot_id = _HasItem(m_cursor, item_id, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
@ -743,90 +743,90 @@ int16 Inventory::HasItem(uint32 item_id, uint8 quantity, uint8 where)
|
||||
int16 Inventory::HasItemByUse(uint8 use, uint8 quantity, uint8 where)
|
||||
{
|
||||
int16 slot_id = SLOT_INVALID;
|
||||
|
||||
|
||||
// Check each inventory bucket
|
||||
if(where & invWhereWorn) {
|
||||
slot_id = _HasItemByUse(m_worn, use, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWherePersonal) {
|
||||
slot_id = _HasItemByUse(m_inv, use, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereBank) {
|
||||
slot_id = _HasItemByUse(m_bank, use, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereSharedBank) {
|
||||
slot_id = _HasItemByUse(m_shbank, use, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereTrading) {
|
||||
slot_id = _HasItemByUse(m_trade, use, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereCursor) {
|
||||
// Check cursor queue
|
||||
slot_id = _HasItemByUse(m_cursor, use, quantity);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
int16 Inventory::HasItemByLoreGroup(uint32 loregroup, uint8 where)
|
||||
int16 Inventory::HasItemByLoreGroup(uint32 loregroup, uint8 where)
|
||||
{
|
||||
int16 slot_id = SLOT_INVALID;
|
||||
|
||||
|
||||
// Check each inventory bucket
|
||||
if(where & invWhereWorn) {
|
||||
slot_id = _HasItemByLoreGroup(m_worn, loregroup);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWherePersonal) {
|
||||
slot_id = _HasItemByLoreGroup(m_inv, loregroup);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereBank) {
|
||||
slot_id = _HasItemByLoreGroup(m_bank, loregroup);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereSharedBank) {
|
||||
slot_id = _HasItemByLoreGroup(m_shbank, loregroup);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereTrading) {
|
||||
slot_id = _HasItemByLoreGroup(m_trade, loregroup);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
if(where & invWhereCursor) {
|
||||
// Check cursor queue
|
||||
slot_id = _HasItemByLoreGroup(m_cursor, loregroup);
|
||||
if (slot_id != SLOT_INVALID)
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
@ -835,13 +835,13 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
|
||||
if(ItemToTry->Stackable) {
|
||||
|
||||
for(int16 i = 22; i <= 29; i++) {
|
||||
|
||||
|
||||
ItemInst* InvItem = GetItem(i);
|
||||
|
||||
if(InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) && (InvItem->GetCharges() < InvItem->GetItem()->StackSize)) {
|
||||
|
||||
int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges();
|
||||
|
||||
|
||||
if(Quantity <= ChargeSlotsLeft)
|
||||
return true;
|
||||
|
||||
@ -860,7 +860,7 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
|
||||
(InvItem->GetCharges() < InvItem->GetItem()->StackSize)) {
|
||||
|
||||
int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges();
|
||||
|
||||
|
||||
if(Quantity <= ChargeSlotsLeft)
|
||||
return true;
|
||||
|
||||
@ -930,7 +930,7 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
|
||||
{
|
||||
// Pop item out of inventory map (or queue)
|
||||
ItemInst* item_to_delete = PopItem(slot_id);
|
||||
|
||||
|
||||
// Determine if object should be fully deleted, or
|
||||
// just a quantity of charges of the item can be deleted
|
||||
if (item_to_delete && (quantity > 0)) {
|
||||
@ -942,7 +942,7 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
|
||||
// If the item is stackable (e.g arrows), or
|
||||
// the item is not stackable, and is not a charged item, or is expendable, delete it
|
||||
if(item_to_delete->IsStackable() ||
|
||||
(!item_to_delete->IsStackable() &&
|
||||
(!item_to_delete->IsStackable() &&
|
||||
((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable()))) {
|
||||
// Item can now be destroyed
|
||||
safe_delete(item_to_delete);
|
||||
@ -954,11 +954,11 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
|
||||
_PutItem(slot_id, item_to_delete);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
safe_delete(item_to_delete);
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Checks All items in a bag for No Drop
|
||||
@ -980,7 +980,7 @@ bool Inventory::CheckNoDrop(int16 slot_id) {
|
||||
ItemInst* Inventory::PopItem(int16 slot_id)
|
||||
{
|
||||
ItemInst* p = nullptr;
|
||||
|
||||
|
||||
if (slot_id==SLOT_CURSOR) { // Cursor
|
||||
p = m_cursor.pop();
|
||||
}
|
||||
@ -1011,7 +1011,7 @@ ItemInst* Inventory::PopItem(int16 slot_id)
|
||||
p = baginst->PopItem(Inventory::CalcBagIdx(slot_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return pointer that needs to be deleted (or otherwise managed)
|
||||
return p;
|
||||
}
|
||||
@ -1026,12 +1026,12 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
|
||||
// Found available slot in personal inventory
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
if (!for_bag) {
|
||||
for (int16 i=22; i<=29; i++) {
|
||||
const ItemInst* inst = GetItem(i);
|
||||
if (inst && inst->IsType(ItemClassContainer)
|
||||
&& inst->GetItem()->BagSize >= min_size)
|
||||
if (inst && inst->IsType(ItemClassContainer)
|
||||
&& inst->GetItem()->BagSize >= min_size)
|
||||
{
|
||||
if(inst->GetItem()->BagType == bagTypeQuiver && inst->GetItem()->ItemType != ItemTypeArrow)
|
||||
{
|
||||
@ -1050,12 +1050,12 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (try_cursor)
|
||||
// Always room on cursor (it's a queue)
|
||||
// (we may wish to cap this in the future)
|
||||
return SLOT_CURSOR;
|
||||
|
||||
|
||||
// No available slots
|
||||
return SLOT_INVALID;
|
||||
}
|
||||
@ -1064,7 +1064,7 @@ void Inventory::dumpInventory() {
|
||||
iter_inst it;
|
||||
iter_contents itb;
|
||||
ItemInst* inst = nullptr;
|
||||
|
||||
|
||||
// Check item: After failed checks, check bag contents (if bag)
|
||||
printf("Worn items:\n");
|
||||
for (it=m_worn.begin(); it!=m_worn.end(); it++) {
|
||||
@ -1072,9 +1072,9 @@ void Inventory::dumpInventory() {
|
||||
it->first;
|
||||
if(!inst || !inst->GetItem())
|
||||
continue;
|
||||
|
||||
|
||||
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
|
||||
|
||||
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
@ -1086,16 +1086,16 @@ void Inventory::dumpInventory() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("Inventory items:\n");
|
||||
for (it=m_inv.begin(); it!=m_inv.end(); it++) {
|
||||
inst = it->second;
|
||||
it->first;
|
||||
if(!inst || !inst->GetItem())
|
||||
continue;
|
||||
|
||||
|
||||
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
|
||||
|
||||
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
@ -1104,57 +1104,57 @@ void Inventory::dumpInventory() {
|
||||
continue;
|
||||
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
|
||||
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("Bank items:\n");
|
||||
for (it=m_bank.begin(); it!=m_bank.end(); it++) {
|
||||
inst = it->second;
|
||||
it->first;
|
||||
if(!inst || !inst->GetItem())
|
||||
continue;
|
||||
|
||||
|
||||
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
|
||||
|
||||
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
|
||||
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
ItemInst* baginst = itb->second;
|
||||
if(!baginst || !baginst->GetItem())
|
||||
continue;
|
||||
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
|
||||
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("Shared Bank items:\n");
|
||||
for (it=m_shbank.begin(); it!=m_shbank.end(); it++) {
|
||||
inst = it->second;
|
||||
it->first;
|
||||
if(!inst || !inst->GetItem())
|
||||
continue;
|
||||
|
||||
|
||||
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
|
||||
|
||||
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
|
||||
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
ItemInst* baginst = itb->second;
|
||||
if(!baginst || !baginst->GetItem())
|
||||
continue;
|
||||
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
|
||||
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
@ -1166,7 +1166,7 @@ ItemInst* Inventory::_GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id
|
||||
if (it != bucket.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
// Not found!
|
||||
return nullptr;
|
||||
}
|
||||
@ -1181,9 +1181,9 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
|
||||
PopItem(slot_id);
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
|
||||
int16 result = SLOT_INVALID;
|
||||
|
||||
|
||||
if (slot_id==SLOT_CURSOR) { // Cursor
|
||||
// Replace current item on cursor, if exists
|
||||
m_cursor.pop(); // no memory delete, clients of this function know what they are doing
|
||||
@ -1218,12 +1218,12 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
|
||||
result = slot_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (result == SLOT_INVALID) {
|
||||
LogFile->write(EQEMuLog::Error, "Inventory::_PutItem: Invalid slot_id specified (%i)", slot_id);
|
||||
safe_delete(inst); // Slot not found, clean up
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1234,7 +1234,7 @@ int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 q
|
||||
iter_contents itb;
|
||||
ItemInst* inst = nullptr;
|
||||
uint8 quantity_found = 0;
|
||||
|
||||
|
||||
// Check item: After failed checks, check bag contents (if bag)
|
||||
for (it=bucket.begin(); it!=bucket.end(); it++) {
|
||||
inst = it->second;
|
||||
@ -1244,15 +1244,15 @@ int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 q
|
||||
if (quantity_found >= quantity)
|
||||
return it->first;
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
|
||||
if (inst->GetAugmentItemID(i) == item_id && quantity <= 1)
|
||||
if (inst->GetAugmentItemID(i) == item_id && quantity <= 1)
|
||||
return SLOT_AUGMENT; // Only one augment per slot.
|
||||
}
|
||||
}
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
|
||||
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
ItemInst* baginst = itb->second;
|
||||
if (baginst->GetID() == item_id) {
|
||||
@ -1261,13 +1261,13 @@ int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 q
|
||||
return Inventory::CalcSlotId(it->first, itb->first);
|
||||
}
|
||||
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
|
||||
if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1)
|
||||
if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1)
|
||||
return SLOT_AUGMENT; // Only one augment per slot.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Not found
|
||||
return SLOT_INVALID;
|
||||
}
|
||||
@ -1278,7 +1278,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
|
||||
iter_queue it;
|
||||
iter_contents itb;
|
||||
uint8 quantity_found = 0;
|
||||
|
||||
|
||||
// Read-only iteration of queue
|
||||
for (it=iqueue.begin(); it!=iqueue.end(); it++) {
|
||||
ItemInst* inst = *it;
|
||||
@ -1290,13 +1290,13 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
|
||||
return SLOT_CURSOR;
|
||||
}
|
||||
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
|
||||
if (inst->GetAugmentItemID(i) == item_id && quantity <= 1)
|
||||
if (inst->GetAugmentItemID(i) == item_id && quantity <= 1)
|
||||
return SLOT_AUGMENT; // Only one augment per slot.
|
||||
}
|
||||
}
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
|
||||
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
ItemInst* baginst = itb->second;
|
||||
if (baginst->GetID() == item_id) {
|
||||
@ -1305,14 +1305,14 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
|
||||
return Inventory::CalcSlotId(SLOT_CURSOR, itb->first);
|
||||
}
|
||||
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
|
||||
if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1)
|
||||
if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1)
|
||||
return SLOT_AUGMENT; // Only one augment per slot.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Not found
|
||||
return SLOT_INVALID;
|
||||
}
|
||||
@ -1324,7 +1324,7 @@ int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 q
|
||||
iter_contents itb;
|
||||
ItemInst* inst = nullptr;
|
||||
uint8 quantity_found = 0;
|
||||
|
||||
|
||||
// Check item: After failed checks, check bag contents (if bag)
|
||||
for (it=bucket.begin(); it!=bucket.end(); it++) {
|
||||
inst = it->second;
|
||||
@ -1333,10 +1333,10 @@ int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 q
|
||||
if (quantity_found >= quantity)
|
||||
return it->first;
|
||||
}
|
||||
|
||||
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
|
||||
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
ItemInst* baginst = itb->second;
|
||||
if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->ItemType == use) {
|
||||
@ -1347,7 +1347,7 @@ int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 q
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Not found
|
||||
return SLOT_INVALID;
|
||||
}
|
||||
@ -1358,7 +1358,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
|
||||
iter_queue it;
|
||||
iter_contents itb;
|
||||
uint8 quantity_found = 0;
|
||||
|
||||
|
||||
// Read-only iteration of queue
|
||||
for (it=iqueue.begin(); it!=iqueue.end(); it++) {
|
||||
ItemInst* inst = *it;
|
||||
@ -1367,10 +1367,10 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
|
||||
if (quantity_found >= quantity)
|
||||
return SLOT_CURSOR;
|
||||
}
|
||||
|
||||
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
|
||||
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
ItemInst* baginst = itb->second;
|
||||
if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->ItemType == use) {
|
||||
@ -1381,24 +1381,24 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Not found
|
||||
return SLOT_INVALID;
|
||||
}
|
||||
|
||||
int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup)
|
||||
int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup)
|
||||
{
|
||||
iter_inst it;
|
||||
iter_contents itb;
|
||||
ItemInst* inst = nullptr;
|
||||
|
||||
|
||||
// Check item: After failed checks, check bag contents (if bag)
|
||||
for (it=bucket.begin(); it!=bucket.end(); it++) {
|
||||
inst = it->second;
|
||||
if (inst) {
|
||||
if (inst->GetItem()->LoreGroup == loregroup)
|
||||
if (inst->GetItem()->LoreGroup == loregroup)
|
||||
return it->first;
|
||||
|
||||
|
||||
ItemInst* Aug;
|
||||
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
|
||||
Aug = inst->GetAugment(i);
|
||||
@ -1408,12 +1408,12 @@ int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loreg
|
||||
}
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
|
||||
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
ItemInst* baginst = itb->second;
|
||||
if (baginst && baginst->IsType(ItemClassCommon)&& baginst->GetItem()->LoreGroup == loregroup)
|
||||
if (baginst && baginst->IsType(ItemClassCommon)&& baginst->GetItem()->LoreGroup == loregroup)
|
||||
return Inventory::CalcSlotId(it->first, itb->first);
|
||||
|
||||
|
||||
ItemInst* Aug2;
|
||||
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
|
||||
Aug2 = baginst->GetAugment(i);
|
||||
@ -1423,7 +1423,7 @@ int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loreg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Not found
|
||||
return SLOT_INVALID;
|
||||
}
|
||||
@ -1433,15 +1433,15 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup)
|
||||
{
|
||||
iter_queue it;
|
||||
iter_contents itb;
|
||||
|
||||
|
||||
// Read-only iteration of queue
|
||||
for (it=iqueue.begin(); it!=iqueue.end(); it++) {
|
||||
ItemInst* inst = *it;
|
||||
if (inst)
|
||||
{
|
||||
if (inst->GetItem()->LoreGroup == loregroup)
|
||||
if (inst->GetItem()->LoreGroup == loregroup)
|
||||
return SLOT_CURSOR;
|
||||
|
||||
|
||||
ItemInst* Aug;
|
||||
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
|
||||
Aug = inst->GetAugment(i);
|
||||
@ -1451,13 +1451,13 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup)
|
||||
}
|
||||
// Go through bag, if bag
|
||||
if (inst && inst->IsType(ItemClassContainer)) {
|
||||
|
||||
|
||||
for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
|
||||
ItemInst* baginst = itb->second;
|
||||
if (baginst && baginst->IsType(ItemClassCommon)&& baginst->GetItem()->LoreGroup == loregroup)
|
||||
if (baginst && baginst->IsType(ItemClassCommon)&& baginst->GetItem()->LoreGroup == loregroup)
|
||||
return Inventory::CalcSlotId(SLOT_CURSOR, itb->first);
|
||||
|
||||
|
||||
|
||||
|
||||
ItemInst* Aug2;
|
||||
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
|
||||
Aug2 = baginst->GetAugment(i);
|
||||
@ -1468,7 +1468,7 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Not found
|
||||
return SLOT_INVALID;
|
||||
}
|
||||
@ -1513,7 +1513,7 @@ bool ItemInst::IsNoneEmptyContainer()
|
||||
for(int i = 0; i < m_item->BagSlots; ++i)
|
||||
if(GetItem(i))
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1522,7 +1522,7 @@ bool ItemInst::IsAugmented()
|
||||
for(int i = 0; i < MAX_AUGMENT_SLOTS; ++i)
|
||||
if (GetAugmentItemID(i))
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1532,9 +1532,9 @@ int16 Inventory::CalcSlotId(int16 bagslot_id, uint8 bagidx)
|
||||
if (!Inventory::SupportsContainers(bagslot_id)) {
|
||||
return SLOT_INVALID;
|
||||
}
|
||||
|
||||
|
||||
int16 slot_id = SLOT_INVALID;
|
||||
|
||||
|
||||
if (bagslot_id==SLOT_CURSOR || bagslot_id==8000) // Cursor
|
||||
slot_id = IDX_CURSOR_BAG + bagidx;
|
||||
else if (bagslot_id>=22 && bagslot_id<=29) // Inventory slots
|
||||
@ -1545,7 +1545,7 @@ int16 Inventory::CalcSlotId(int16 bagslot_id, uint8 bagidx)
|
||||
slot_id = IDX_SHBANK_BAG + (bagslot_id-2500)*MAX_ITEMS_PER_BAG + bagidx;
|
||||
else if (bagslot_id>=3000 && bagslot_id<=3007) // Trade window slots
|
||||
slot_id = IDX_TRADE_BAG + (bagslot_id-3000)*MAX_ITEMS_PER_BAG + bagidx;
|
||||
|
||||
|
||||
return slot_id;
|
||||
}
|
||||
|
||||
@ -1553,7 +1553,7 @@ int16 Inventory::CalcSlotId(int16 bagslot_id, uint8 bagidx)
|
||||
int16 Inventory::CalcSlotId(int16 slot_id)
|
||||
{
|
||||
int16 parent_slot_id = SLOT_INVALID;
|
||||
|
||||
|
||||
if (slot_id>=251 && slot_id<=330)
|
||||
parent_slot_id = IDX_INV + (slot_id-251) / MAX_ITEMS_PER_BAG;
|
||||
else if (slot_id>=331 && slot_id<=340)
|
||||
@ -1566,14 +1566,14 @@ int16 Inventory::CalcSlotId(int16 slot_id)
|
||||
parent_slot_id = IDX_SHBANK + (slot_id-2531) / MAX_ITEMS_PER_BAG;
|
||||
else if (slot_id>=3100 && slot_id<=3179)
|
||||
parent_slot_id = IDX_TRADE + (slot_id-3100) / MAX_ITEMS_PER_BAG;
|
||||
|
||||
|
||||
return parent_slot_id;
|
||||
}
|
||||
|
||||
uint8 Inventory::CalcBagIdx(int16 slot_id)
|
||||
{
|
||||
uint8 index = 0;
|
||||
|
||||
|
||||
if (slot_id>=251 && slot_id<=330)
|
||||
index = (slot_id-251) % MAX_ITEMS_PER_BAG;
|
||||
else if (slot_id>=331 && slot_id<=340)
|
||||
@ -1588,7 +1588,7 @@ uint8 Inventory::CalcBagIdx(int16 slot_id)
|
||||
index = (slot_id-3100) % MAX_ITEMS_PER_BAG;
|
||||
else if (slot_id>=4000 && slot_id<=4009)
|
||||
index = (slot_id-4000) % MAX_ITEMS_PER_BAG;
|
||||
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -1691,11 +1691,11 @@ EvoItemInst::EvoItemInst(const EvoItemInst ©) {
|
||||
for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) {
|
||||
ItemInst* inst_old = it->second;
|
||||
ItemInst* inst_new = nullptr;
|
||||
|
||||
|
||||
if (inst_old) {
|
||||
inst_new = inst_old->Clone();
|
||||
}
|
||||
|
||||
|
||||
if (inst_new != nullptr) {
|
||||
m_contents[it->first] = inst_new;
|
||||
}
|
||||
@ -1717,7 +1717,7 @@ EvoItemInst::EvoItemInst(const EvoItemInst ©) {
|
||||
|
||||
EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
|
||||
EvoItemInst* copy = (EvoItemInst*)&basecopy;
|
||||
|
||||
|
||||
m_use_type=copy->m_use_type;
|
||||
m_item=copy->m_item;
|
||||
m_charges=copy->m_charges;
|
||||
@ -1732,11 +1732,11 @@ EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
|
||||
for (it=copy->m_contents.begin(); it!=copy->m_contents.end(); it++) {
|
||||
ItemInst* inst_old = it->second;
|
||||
ItemInst* inst_new = nullptr;
|
||||
|
||||
|
||||
if (inst_old) {
|
||||
inst_new = inst_old->Clone();
|
||||
}
|
||||
|
||||
|
||||
if (inst_new != nullptr) {
|
||||
m_contents[it->first] = inst_new;
|
||||
}
|
||||
@ -1775,7 +1775,7 @@ EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
|
||||
}
|
||||
|
||||
EvoItemInst::~EvoItemInst() {
|
||||
safe_delete(m_scaledItem);
|
||||
safe_delete(m_scaledItem);
|
||||
}
|
||||
|
||||
EvoItemInst* EvoItemInst::Clone() const {
|
||||
@ -1812,7 +1812,7 @@ void EvoItemInst::Initialize(SharedDatabase *db) {
|
||||
void EvoItemInst::ScaleItem() {
|
||||
// free memory from any previously scaled item data
|
||||
safe_delete(m_scaledItem);
|
||||
|
||||
|
||||
m_scaledItem = new Item_Struct(*m_item);
|
||||
float Mult = (float)(GetExp())/10000; // scaling is determined by exp, with 10,000 being full stats
|
||||
|
||||
@ -1829,7 +1829,7 @@ void EvoItemInst::ScaleItem() {
|
||||
m_scaledItem->DR = (int8)((float)m_item->DR*Mult);
|
||||
m_scaledItem->CR = (int8)((float)m_item->CR*Mult);
|
||||
m_scaledItem->FR = (int8)((float)m_item->FR*Mult);
|
||||
|
||||
|
||||
m_scaledItem->HP = (int32)((float)m_item->HP*Mult);
|
||||
m_scaledItem->Mana = (int32)((float)m_item->Mana*Mult);
|
||||
m_scaledItem->AC = (int32)((float)m_item->AC*Mult);
|
||||
@ -1862,8 +1862,8 @@ void EvoItemInst::ScaleItem() {
|
||||
m_scaledItem->EnduranceRegen = (uint32)((float)m_item->EnduranceRegen*Mult);
|
||||
m_scaledItem->Haste = (uint32)((float)m_item->Haste*Mult);
|
||||
m_scaledItem->DamageShield = (uint32)((float)m_item->DamageShield*Mult);
|
||||
|
||||
|
||||
|
||||
|
||||
m_scaledItem->CharmFileID = 0; // this stops the client from trying to scale the item itself.
|
||||
}
|
||||
|
||||
@ -1874,14 +1874,14 @@ bool EvoItemInst::EvolveOnAllKills() const {
|
||||
int8 EvoItemInst::GetMaxEvolveLvl() const {
|
||||
if(m_evolveInfo)
|
||||
return m_evolveInfo->MaxLvl;
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 EvoItemInst::GetKillsNeeded(uint8 currentlevel) {
|
||||
uint32 kills = -1; // default to -1 (max uint32 value) because this value is usually divided by, so we don't want to ever return zero.
|
||||
if (m_evolveInfo)
|
||||
if (currentlevel != m_evolveInfo->MaxLvl)
|
||||
if (m_evolveInfo)
|
||||
if (currentlevel != m_evolveInfo->MaxLvl)
|
||||
kills = m_evolveInfo->LvlKills[currentlevel-1];
|
||||
|
||||
if (kills == 0)
|
||||
@ -1913,7 +1913,7 @@ bool Item_Struct::IsEquipable(uint16 Race, uint16 Class_) const
|
||||
{
|
||||
bool IsRace = false;
|
||||
bool IsClass = false;
|
||||
|
||||
|
||||
uint32 Classes_ = Classes;
|
||||
|
||||
uint32 Races_ = Races;
|
||||
|
||||
@ -105,23 +105,23 @@ public:
|
||||
/////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////
|
||||
|
||||
|
||||
inline iter_queue begin() { return m_list.begin(); }
|
||||
inline iter_queue end() { return m_list.end(); }
|
||||
|
||||
|
||||
void push(ItemInst* inst);
|
||||
void push_front(ItemInst* inst);
|
||||
ItemInst* pop();
|
||||
ItemInst* peek_front() const;
|
||||
inline int size() { return static_cast<int>(m_list.size()); }
|
||||
|
||||
|
||||
protected:
|
||||
/////////////////////////
|
||||
// Protected Members
|
||||
/////////////////////////
|
||||
|
||||
|
||||
list<ItemInst*> m_list;
|
||||
|
||||
|
||||
};
|
||||
|
||||
// ########################################
|
||||
@ -134,9 +134,9 @@ public:
|
||||
///////////////////////////////
|
||||
// Public Methods
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
virtual ~Inventory();
|
||||
|
||||
|
||||
// Retrieve a writeable item at specified slot
|
||||
ItemInst* GetItem(int16 slot_id) const;
|
||||
ItemInst* GetItem(int16 slot_id, uint8 bagidx) const;
|
||||
@ -144,16 +144,16 @@ public:
|
||||
inline iter_queue cursor_begin() { return m_cursor.begin(); }
|
||||
inline iter_queue cursor_end() { return m_cursor.end(); }
|
||||
inline bool CursorEmpty() { return (m_cursor.size() == 0); }
|
||||
|
||||
|
||||
// Retrieve a read-only item from inventory
|
||||
inline const ItemInst* operator[](int16 slot_id) const { return GetItem(slot_id); }
|
||||
|
||||
|
||||
// Add item to inventory
|
||||
int16 PutItem(int16 slot_id, const ItemInst& inst);
|
||||
|
||||
// Add item to cursor queue
|
||||
int16 PushCursor(const ItemInst& inst);
|
||||
|
||||
|
||||
// Swap items in inventory
|
||||
bool SwapItem(int16 slot_a, int16 slot_b);
|
||||
|
||||
@ -162,17 +162,17 @@ public:
|
||||
|
||||
// Checks All items in a bag for No Drop
|
||||
bool CheckNoDrop(int16 slot_id);
|
||||
|
||||
|
||||
// Remove item from inventory (and take control of memory)
|
||||
ItemInst* PopItem(int16 slot_id);
|
||||
|
||||
|
||||
// Check whether item exists in inventory
|
||||
// where argument specifies OR'd list of invWhere constants to look
|
||||
int16 HasItem(uint32 item_id, uint8 quantity=0, uint8 where=0xFF);
|
||||
|
||||
// Check whether there is space for the specified number of the specified item.
|
||||
bool HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity);
|
||||
|
||||
|
||||
// Check whether item exists in inventory
|
||||
// where argument specifies OR'd list of invWhere constants to look
|
||||
int16 HasItemByUse(uint8 use, uint8 quantity=0, uint8 where=0xFF);
|
||||
@ -180,10 +180,10 @@ public:
|
||||
// Check whether item exists in inventory
|
||||
// where argument specifies OR'd list of invWhere constants to look
|
||||
int16 HasItemByLoreGroup(uint32 loregroup, uint8 where=0xFF);
|
||||
|
||||
|
||||
// Locate an available inventory slot
|
||||
int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false);
|
||||
|
||||
|
||||
// Calculate slot_id for an item within a bag
|
||||
static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id
|
||||
static int16 CalcSlotId(int16 bagslot_id, uint8 bagidx); // Calc slot_id for item inside bag
|
||||
@ -195,7 +195,7 @@ public:
|
||||
|
||||
// Test whether a given slot can support a container item
|
||||
static bool SupportsContainers(int16 slot_id);
|
||||
|
||||
|
||||
void dumpInventory();
|
||||
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value);
|
||||
@ -207,13 +207,13 @@ protected:
|
||||
///////////////////////////////
|
||||
// Protected Methods
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
// Retrieves item within an inventory bucket
|
||||
ItemInst* _GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const;
|
||||
|
||||
|
||||
// Private "put" item into bucket, without regard for what is currently in bucket
|
||||
int16 _PutItem(int16 slot_id, ItemInst* inst);
|
||||
|
||||
|
||||
// Checks an inventory bucket for a particular item
|
||||
int16 _HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity);
|
||||
int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity);
|
||||
@ -221,8 +221,8 @@ protected:
|
||||
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
|
||||
int16 _HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup);
|
||||
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
|
||||
|
||||
|
||||
|
||||
|
||||
// Player inventory
|
||||
map<int16, ItemInst*> m_worn; // Items worn by character
|
||||
map<int16, ItemInst*> m_inv; // Items in character personal inventory
|
||||
@ -245,12 +245,12 @@ public:
|
||||
/////////////////////////
|
||||
// Methods
|
||||
/////////////////////////
|
||||
|
||||
|
||||
// Constructors/Destructor
|
||||
ItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
|
||||
|
||||
|
||||
ItemInst(SharedDatabase *db, uint32 item_id, int16 charges = 0);
|
||||
|
||||
|
||||
ItemInst(ItemUseType use_type) {
|
||||
m_use_type = use_type;
|
||||
m_item = nullptr;
|
||||
@ -262,19 +262,19 @@ public:
|
||||
}
|
||||
|
||||
ItemInst(const ItemInst& copy);
|
||||
|
||||
|
||||
virtual ~ItemInst();
|
||||
|
||||
|
||||
// Query item type
|
||||
virtual bool IsType(ItemClass item_class) const;
|
||||
|
||||
|
||||
// Can item be stacked?
|
||||
virtual bool IsStackable() const;
|
||||
|
||||
// Can item be equipped by/at?
|
||||
virtual bool IsEquipable(uint16 race, uint16 class_) const;
|
||||
virtual bool IsEquipable(int16 slot_id) const;
|
||||
|
||||
|
||||
//
|
||||
// Augements
|
||||
//
|
||||
@ -322,13 +322,13 @@ public:
|
||||
const uint32 GetItemScriptID() const { return m_item->ScriptFileID; }
|
||||
virtual const Item_Struct* GetItem() const { return m_item; }
|
||||
void SetItem(const Item_Struct* item) { m_item = item; }
|
||||
|
||||
|
||||
int16 GetCharges() const { return m_charges; }
|
||||
void SetCharges(int16 charges) { m_charges = charges; }
|
||||
|
||||
|
||||
uint32 GetPrice() const { return m_price; }
|
||||
void SetPrice(uint32 price) { m_price = price; }
|
||||
|
||||
|
||||
void SetColor(uint32 color) { m_color = color; }
|
||||
uint32 GetColor() const { return m_color; }
|
||||
|
||||
@ -358,14 +358,14 @@ public:
|
||||
|
||||
// Allows treatment of this object as though it were a pointer to m_item
|
||||
operator bool() const { return (m_item != nullptr); }
|
||||
|
||||
|
||||
// Compare inner Item_Struct of two ItemInst objects
|
||||
bool operator==(const ItemInst& right) const { return (this->m_item == right.m_item); }
|
||||
bool operator!=(const ItemInst& right) const { return (this->m_item != right.m_item); }
|
||||
|
||||
|
||||
// Clone current item
|
||||
virtual ItemInst* Clone() const;
|
||||
|
||||
|
||||
bool IsSlotAllowed(int16 slot_id) const;
|
||||
|
||||
virtual bool IsScaling() const { return false; }
|
||||
@ -383,10 +383,10 @@ protected:
|
||||
iter_contents _end() { return m_contents.end(); }
|
||||
|
||||
friend class Inventory;
|
||||
|
||||
|
||||
|
||||
|
||||
void _PutItem(uint8 index, ItemInst* inst) { m_contents[index] = inst; }
|
||||
|
||||
|
||||
ItemUseType m_use_type; // Usage type for item
|
||||
const Item_Struct* m_item; // Ptr to item data
|
||||
int16 m_charges; // # of charges for chargeable items
|
||||
@ -410,7 +410,7 @@ public:
|
||||
EvoItemInst(const ItemInst& copy);
|
||||
EvoItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
|
||||
~EvoItemInst();
|
||||
|
||||
|
||||
// accessors... a lot of these are for evolving items (not complete yet)
|
||||
bool IsScaling() const { return (m_evolveLvl == -1); }
|
||||
bool IsEvolving() const { return (m_evolveLvl >= 1); }
|
||||
@ -420,16 +420,16 @@ public:
|
||||
bool IsActivated() { return m_activated; }
|
||||
void SetActivated(bool activated) { m_activated = activated; }
|
||||
int8 GetEvolveLvl() const { return m_evolveLvl; }
|
||||
|
||||
|
||||
EvoItemInst* Clone() const;
|
||||
const Item_Struct* GetItem() const;
|
||||
const Item_Struct* GetUnscaledItem() const;
|
||||
void Initialize(SharedDatabase *db = nullptr);
|
||||
void ScaleItem();
|
||||
bool EvolveOnAllKills() const;
|
||||
bool EvolveOnAllKills() const;
|
||||
int8 GetMaxEvolveLvl() const;
|
||||
uint32 GetKillsNeeded(uint8 currentlevel);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
uint32 m_exp;
|
||||
@ -447,7 +447,7 @@ public:
|
||||
uint32 FirstItem;
|
||||
uint8 MaxLvl;
|
||||
bool AllKills;
|
||||
|
||||
|
||||
EvolveInfo();
|
||||
EvolveInfo(uint32 first, uint8 max, bool allkills, uint32 L2, uint32 L3, uint32 L4, uint32 L5, uint32 L6, uint32 L7, uint32 L8, uint32 L9, uint32 L10);
|
||||
~EvolveInfo();
|
||||
|
||||
3110
common/MaxSkill.cpp
3110
common/MaxSkill.cpp
File diff suppressed because it is too large
Load Diff
@ -83,7 +83,7 @@ void CoutTimestamp(bool ms) {
|
||||
time(&rawtime);
|
||||
gmt_t = gmtime(&rawtime);
|
||||
|
||||
struct timeval read_time;
|
||||
struct timeval read_time;
|
||||
gettimeofday(&read_time,0);
|
||||
|
||||
cout << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec;
|
||||
@ -383,7 +383,7 @@ const char * itoa(int num, char* a,int b) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
/*
|
||||
* generate a random integer in the range low-high this
|
||||
* should be used instead of the rand()%limit method
|
||||
*/
|
||||
@ -425,9 +425,9 @@ uint32 rnd_hash( time_t t, clock_t c )
|
||||
// Get a uint32 from t and c
|
||||
// Better than uint32(x) in case x is floating point in [0,1]
|
||||
// Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
|
||||
|
||||
|
||||
static uint32 differ = 0; // guarantee time-based seeds will change
|
||||
|
||||
|
||||
uint32 h1 = 0;
|
||||
unsigned char *p = (unsigned char *) &t;
|
||||
for( size_t i = 0; i < sizeof(t); ++i )
|
||||
@ -553,7 +553,7 @@ static unsigned int case_6 (void){
|
||||
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
|
||||
|
||||
@ -32,8 +32,8 @@
|
||||
// These are helper macros for dealing with packets of variable length, typically those that contain
|
||||
// variable length strings where it is not convenient to use a fixed length struct.
|
||||
//
|
||||
#define VARSTRUCT_DECODE_TYPE(Type, Buffer) *(Type *)Buffer; Buffer += sizeof(Type);
|
||||
#define VARSTRUCT_DECODE_STRING(String, Buffer) strcpy(String, Buffer); Buffer += strlen(String)+1;
|
||||
#define VARSTRUCT_DECODE_TYPE(Type, Buffer) *(Type *)Buffer; Buffer += sizeof(Type);
|
||||
#define VARSTRUCT_DECODE_STRING(String, Buffer) strcpy(String, Buffer); Buffer += strlen(String)+1;
|
||||
#define VARSTRUCT_ENCODE_STRING(Buffer, String) { sprintf(Buffer, String); Buffer += strlen(String) + 1; }
|
||||
#define VARSTRUCT_ENCODE_INTSTRING(Buffer, Number) { sprintf(Buffer, "%i", Number); Buffer += strlen(Buffer) + 1; }
|
||||
#define VARSTRUCT_ENCODE_TYPE(Type, Buffer, Value) { *(Type *)Buffer = Value; Buffer += sizeof(Type); }
|
||||
|
||||
@ -23,7 +23,7 @@ using namespace std;
|
||||
|
||||
#define DEBUG_MUTEX_CLASS 0
|
||||
#if DEBUG_MUTEX_CLASS >= 1
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -71,7 +71,7 @@ void ProcLauncher::Process() {
|
||||
//GetLastError();
|
||||
TerminateProcess(cur->second->proc_info.hProcess, 1);
|
||||
}
|
||||
|
||||
|
||||
//if we get here, the current process died.
|
||||
tmp = cur;
|
||||
tmp++;
|
||||
@ -85,7 +85,7 @@ void ProcLauncher::Process() {
|
||||
ProcRef died = waitpid(-1, &status, WNOHANG);
|
||||
if(died == -1) {
|
||||
//error waiting... shouldent really happen...
|
||||
|
||||
|
||||
} else if(died == 0) {
|
||||
//nothing pending...
|
||||
break;
|
||||
@ -102,14 +102,14 @@ void ProcLauncher::Process() {
|
||||
}
|
||||
}
|
||||
#endif //!WIN32
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) {
|
||||
|
||||
|
||||
if(it->second->handler != nullptr)
|
||||
it->second->handler->OnTerminate(it->first, it->second);
|
||||
|
||||
|
||||
#ifdef _WINDOWS
|
||||
CloseHandle(it->second->proc_info.hProcess);
|
||||
#else //!WIN32
|
||||
@ -125,18 +125,18 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
|
||||
|
||||
#ifdef _WINDOWS
|
||||
STARTUPINFO siStartInfo;
|
||||
BOOL bFuncRetn = FALSE;
|
||||
|
||||
// Set up members of the PROCESS_INFORMATION structure.
|
||||
|
||||
BOOL bFuncRetn = FALSE;
|
||||
|
||||
// Set up members of the PROCESS_INFORMATION structure.
|
||||
|
||||
ZeroMemory( &it->proc_info, sizeof(PROCESS_INFORMATION) );
|
||||
|
||||
// Set up members of the STARTUPINFO structure.
|
||||
|
||||
|
||||
// Set up members of the STARTUPINFO structure.
|
||||
|
||||
ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
|
||||
siStartInfo.cb = sizeof(STARTUPINFO);
|
||||
siStartInfo.cb = sizeof(STARTUPINFO);
|
||||
siStartInfo.dwFlags = 0;
|
||||
|
||||
|
||||
//handle output redirection.
|
||||
HANDLE logOut = nullptr;
|
||||
BOOL inherit_handles = FALSE;
|
||||
@ -144,9 +144,9 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
|
||||
inherit_handles = TRUE;
|
||||
// Set up our log file to redirect output into.
|
||||
SECURITY_ATTRIBUTES saAttr;
|
||||
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
saAttr.bInheritHandle = TRUE; //we want this handle to be inherited by the child.
|
||||
saAttr.lpSecurityDescriptor = nullptr;
|
||||
saAttr.lpSecurityDescriptor = nullptr;
|
||||
logOut = CreateFile(
|
||||
it->logFile.c_str(), //lpFileName
|
||||
FILE_WRITE_DATA, //dwDesiredAccess
|
||||
@ -155,7 +155,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
|
||||
CREATE_ALWAYS, //dwCreationDisposition
|
||||
FILE_FLAG_NO_BUFFERING, //dwFlagsAndAttributes
|
||||
nullptr ); //hTemplateFile
|
||||
|
||||
|
||||
//configure the startup info to redirect output appropriately.
|
||||
siStartInfo.hStdError = logOut;
|
||||
siStartInfo.hStdOutput = logOut;
|
||||
@ -164,9 +164,9 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
|
||||
}
|
||||
|
||||
siStartInfo.dwFlags |= CREATE_NEW_CONSOLE;
|
||||
|
||||
// Create the child process.
|
||||
|
||||
|
||||
// Create the child process.
|
||||
|
||||
//glue together all the nice command line arguments
|
||||
string args(it->program);
|
||||
vector<string>::iterator cur, end;
|
||||
@ -176,39 +176,39 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
|
||||
args += " ";
|
||||
args += *cur;
|
||||
}
|
||||
|
||||
bFuncRetn = CreateProcess(it->program.c_str(),
|
||||
const_cast<char *>(args.c_str()), // command line
|
||||
nullptr, // process security attributes
|
||||
nullptr, // primary thread security attributes
|
||||
inherit_handles, // handles are not inherited
|
||||
|
||||
bFuncRetn = CreateProcess(it->program.c_str(),
|
||||
const_cast<char *>(args.c_str()), // command line
|
||||
nullptr, // process security attributes
|
||||
nullptr, // primary thread security attributes
|
||||
inherit_handles, // handles are not inherited
|
||||
0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe)
|
||||
nullptr, // use parent's environment
|
||||
nullptr, // use parent's current directory
|
||||
&siStartInfo, // STARTUPINFO pointer
|
||||
&it->proc_info); // receives PROCESS_INFORMATION
|
||||
|
||||
nullptr, // use parent's environment
|
||||
nullptr, // use parent's current directory
|
||||
&siStartInfo, // STARTUPINFO pointer
|
||||
&it->proc_info); // receives PROCESS_INFORMATION
|
||||
|
||||
if (bFuncRetn == 0) {
|
||||
safe_delete(it);
|
||||
//GetLastError()
|
||||
return(ProcError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//keep process handle open to get exit code
|
||||
CloseHandle(it->proc_info.hThread); //we dont need their thread handle
|
||||
if(logOut != nullptr)
|
||||
CloseHandle(logOut); //we dont want their output handle either.
|
||||
|
||||
|
||||
ProcRef res = it->proc_info.dwProcessId;
|
||||
|
||||
|
||||
//record this entry..
|
||||
m_running[res] = it;
|
||||
|
||||
|
||||
return(res);
|
||||
|
||||
|
||||
#else //!WIN32
|
||||
|
||||
|
||||
//build argv
|
||||
char **argv = new char *[it->args.size()+2];
|
||||
unsigned int r;
|
||||
@ -217,7 +217,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
|
||||
argv[r] = const_cast<char *>(it->args[r-1].c_str());
|
||||
}
|
||||
argv[r] = nullptr;
|
||||
|
||||
|
||||
ProcRef res = fork(); //cant use vfork since we are opening the log file.
|
||||
if(res == -1) {
|
||||
//error forking... errno
|
||||
@ -225,10 +225,10 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
|
||||
safe_delete_array(argv);
|
||||
return(ProcError);
|
||||
}
|
||||
|
||||
|
||||
if(res == 0) {
|
||||
//child... exec this bitch
|
||||
|
||||
|
||||
//handle output redirection if requested.
|
||||
if(it->logFile.length() > 0) {
|
||||
//we will put their output directly into a file.
|
||||
@ -252,20 +252,20 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
|
||||
write(outfd, err, strlen(err));
|
||||
}
|
||||
close(STDIN_FILENO);
|
||||
|
||||
|
||||
close(outfd); //dont need this one, we have two more copies...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//call it...
|
||||
execv(argv[0], argv);
|
||||
_exit(1);
|
||||
}
|
||||
safe_delete_array(argv);
|
||||
|
||||
|
||||
//record this entry..
|
||||
m_running[res] = it;
|
||||
|
||||
|
||||
return(res);
|
||||
#endif //!WIN32
|
||||
}
|
||||
@ -277,10 +277,10 @@ bool ProcLauncher::Terminate(const ProcRef &proc, bool graceful) {
|
||||
std::map<ProcRef, Spec *>::iterator res = m_running.find(proc);
|
||||
if(res == m_running.end())
|
||||
return(false);
|
||||
|
||||
|
||||
//we do not remove it from the list until we have been notified
|
||||
//that they have been terminated.
|
||||
|
||||
|
||||
#ifdef _WINDOWS
|
||||
if(!TerminateProcess(res->second->proc_info.hProcess, 0)) {
|
||||
return(false);
|
||||
@ -311,7 +311,7 @@ void ProcLauncher::TerminateAll(bool final) {
|
||||
//kill each process and remove it from the list
|
||||
std::map<ProcRef, Spec *> running(m_running);
|
||||
m_running.clear();
|
||||
|
||||
|
||||
std::map<ProcRef, Spec *>::iterator cur, end;
|
||||
cur = running.begin();
|
||||
end = running.end();
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -32,7 +32,7 @@ public:
|
||||
//Singleton method
|
||||
static ProcLauncher *get() { return(&s_launcher); }
|
||||
static void ProcessInThisThread();
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
typedef DWORD ProcRef;
|
||||
static const ProcRef ProcError;
|
||||
@ -47,7 +47,7 @@ public:
|
||||
Spec();
|
||||
Spec(const Spec &other);
|
||||
Spec &operator=(const Spec &other);
|
||||
|
||||
|
||||
std::string program;
|
||||
std::vector<std::string> args;
|
||||
//std::map<std::string,std::string> environment;
|
||||
@ -64,18 +64,18 @@ public:
|
||||
virtual ~EventHandler() {}
|
||||
virtual void OnTerminate(const ProcRef &ref, const Spec *spec) = 0;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* The main launch method, call to start a new background process.
|
||||
*/
|
||||
ProcRef Launch(Spec *&to_launch); //takes ownership of the pointer
|
||||
|
||||
|
||||
/*
|
||||
* The terminate method
|
||||
*/
|
||||
bool Terminate(const ProcRef &proc, bool graceful = true);
|
||||
void TerminateAll(bool final = true);
|
||||
|
||||
|
||||
/*
|
||||
* The main processing method. Call regularly to check for terminated
|
||||
* background processes.
|
||||
@ -85,9 +85,9 @@ public:
|
||||
protected:
|
||||
// std::vector<Spec *> m_specs;
|
||||
std::map<ProcRef, Spec *> m_running; //we own the pointers in this map
|
||||
|
||||
|
||||
void ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it);
|
||||
|
||||
|
||||
private:
|
||||
static ProcLauncher s_launcher;
|
||||
#ifndef WIN32
|
||||
|
||||
@ -28,13 +28,13 @@ void StructStrategy::Decode(EQApplicationPacket *p) const {
|
||||
proc(p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bool ack_req) {
|
||||
EQApplicationPacket *p = *in_p;
|
||||
*in_p = nullptr;
|
||||
|
||||
|
||||
_log(NET__STRUCTS, "Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode()));
|
||||
|
||||
|
||||
delete p;
|
||||
}
|
||||
|
||||
@ -56,13 +56,13 @@ void StructStrategy::PassDecoder(EQApplicationPacket *p) {
|
||||
|
||||
//effectively a singleton, but I decided to do it this way for no apparent reason.
|
||||
namespace StructStrategyFactory {
|
||||
|
||||
|
||||
static map<EmuOpcode, const StructStrategy *> strategies;
|
||||
|
||||
|
||||
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
|
||||
strategies[first_opcode] = structs;
|
||||
}
|
||||
|
||||
|
||||
const StructStrategy *FindPatch(EmuOpcode first_opcode) {
|
||||
map<EmuOpcode, const StructStrategy *>::const_iterator res;
|
||||
res = strategies.find(first_opcode);
|
||||
@ -70,7 +70,7 @@ namespace StructStrategyFactory {
|
||||
return(nullptr);
|
||||
return(res->second);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -14,18 +14,18 @@ public:
|
||||
typedef void (*Encoder)(EQApplicationPacket **p, EQStream *dest, bool ack_req);
|
||||
//the decoder may only edit the supplied packet, producing a single packet for eqemu to consume.
|
||||
typedef void (*Decoder)(EQApplicationPacket *p);
|
||||
|
||||
|
||||
StructStrategy();
|
||||
virtual ~StructStrategy() {}
|
||||
|
||||
|
||||
//this method takes an eqemu struct, and enqueues the produced structs into the stream.
|
||||
void Encode(EQApplicationPacket **p, EQStream *dest, bool ack_req) const;
|
||||
//this method takes an EQ wire struct, and converts it into an eqemu struct
|
||||
void Decode(EQApplicationPacket *p) const;
|
||||
|
||||
|
||||
virtual std::string Describe() const = 0;
|
||||
virtual const EQClientVersion ClientVersion() const = 0;
|
||||
|
||||
|
||||
protected:
|
||||
//some common coders:
|
||||
//Print an error saying unknown struct/opcode and drop it
|
||||
@ -34,7 +34,7 @@ protected:
|
||||
//pass the packet through without modification (emu == EQ) (default)
|
||||
static void PassEncoder(EQApplicationPacket **p, EQStream *dest, bool ack_req);
|
||||
static void PassDecoder(EQApplicationPacket *p);
|
||||
|
||||
|
||||
Encoder encoders[_maxEmuOpcode];
|
||||
Decoder decoders[_maxEmuOpcode];
|
||||
};
|
||||
@ -42,7 +42,7 @@ protected:
|
||||
//effectively a singleton, but I decided to do it this way for no apparent reason.
|
||||
namespace StructStrategyFactory {
|
||||
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs);
|
||||
|
||||
|
||||
//does NOT return ownership of the strategy.
|
||||
const StructStrategy *FindPatch(EmuOpcode first_opcode);
|
||||
};
|
||||
|
||||
@ -490,7 +490,7 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
|
||||
|
||||
SetEcho(false);
|
||||
ClearBuffers();
|
||||
|
||||
|
||||
rIP = in_ip;
|
||||
rPort = in_port;
|
||||
SetState(TCPS_Connected);
|
||||
@ -504,7 +504,7 @@ void TCPConnection::ClearBuffers() {
|
||||
LockMutex lock4(&MState);
|
||||
safe_delete_array(recvbuf);
|
||||
safe_delete_array(sendbuf);
|
||||
|
||||
|
||||
char* line = 0;
|
||||
while ((line = LineOutQueue.pop()))
|
||||
safe_delete_array(line);
|
||||
@ -520,7 +520,7 @@ bool TCPConnection::CheckNetActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This is always called from an IO thread. Either the server socket's thread, or a
|
||||
/* This is always called from an IO thread. Either the server socket's thread, or a
|
||||
* special thread we create when we make an outbound connection. */
|
||||
bool TCPConnection::Process() {
|
||||
char errbuf[TCPConnection_ErrorBufferSize];
|
||||
@ -535,7 +535,7 @@ bool TCPConnection::Process() {
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
|
||||
|
||||
case TCPS_Connected:
|
||||
// only receive data in the connected state, no others...
|
||||
if (!RecvData(errbuf)) {
|
||||
@ -546,7 +546,7 @@ bool TCPConnection::Process() {
|
||||
}
|
||||
/* we break to do the send */
|
||||
break;
|
||||
|
||||
|
||||
case TCPS_Disconnecting: {
|
||||
//waiting for any sending data to go out...
|
||||
MSendQueue.lock();
|
||||
@ -562,7 +562,7 @@ bool TCPConnection::Process() {
|
||||
MSendQueue.unlock();
|
||||
}
|
||||
/* Fallthrough */
|
||||
|
||||
|
||||
case TCPS_Disconnected:
|
||||
FinishDisconnect();
|
||||
MRunLoop.lock();
|
||||
@ -570,19 +570,19 @@ bool TCPConnection::Process() {
|
||||
MRunLoop.unlock();
|
||||
// SetState(TCPS_Ready); //reset the state in case they want to use it again...
|
||||
return(false);
|
||||
|
||||
|
||||
case TCPS_Closing:
|
||||
//I dont understand this state...
|
||||
|
||||
|
||||
case TCPS_Error:
|
||||
MRunLoop.lock();
|
||||
pRunLoop = false;
|
||||
MRunLoop.unlock();
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
/* we get here in connected or disconnecting with more data to send */
|
||||
|
||||
|
||||
bool sent_something = false;
|
||||
if (!SendData(sent_something, errbuf)) {
|
||||
struct in_addr in;
|
||||
@ -590,7 +590,7 @@ bool TCPConnection::Process() {
|
||||
cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -770,15 +770,15 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
|
||||
i = -1;
|
||||
m_previousLineEnd = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(line != nullptr) {
|
||||
bool finish_proc = false;
|
||||
finish_proc = LineOutQueuePush(line);
|
||||
if(finish_proc)
|
||||
return(true); //break early as requested by LineOutQueuePush
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case 8: // backspace
|
||||
@ -877,13 +877,13 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
|
||||
snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::SendData(): send(): Errorcode: %s", strerror(errno));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//if we get an error while disconnecting, just jump to disconnected
|
||||
MState.lock();
|
||||
if(pState == TCPS_Disconnecting)
|
||||
pState = TCPS_Disconnected;
|
||||
MState.unlock();
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -908,7 +908,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
|
||||
if (!tcpc->ConnectReady()) {
|
||||
_CP(TCPConnectionLoop);
|
||||
if (!tcpc->Process()) {
|
||||
//the processing loop has detecting an error..
|
||||
//the processing loop has detecting an error..
|
||||
//we want to drop the link immediately, so we clear buffers too.
|
||||
tcpc->ClearBuffers();
|
||||
tcpc->Disconnect();
|
||||
@ -927,11 +927,11 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
|
||||
Sleep(10); //nothing to do.
|
||||
}
|
||||
tcpc->MLoopRunning.unlock();
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -75,15 +75,15 @@ protected:
|
||||
TCPS_Closing = 250,
|
||||
TCPS_Error = 255
|
||||
} State_t;
|
||||
|
||||
|
||||
public:
|
||||
//socket created by a server (incoming)
|
||||
TCPConnection(uint32 ID, SOCKET iSock, uint32 irIP, uint16 irPort);
|
||||
//socket created to connect to a server (outgoing)
|
||||
TCPConnection(); // for outgoing connections
|
||||
|
||||
|
||||
virtual ~TCPConnection();
|
||||
|
||||
|
||||
// Functions for outgoing connections
|
||||
bool Connect(const char* irAddress, uint16 irPort, char* errbuf = 0);
|
||||
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
|
||||
@ -92,7 +92,7 @@ public:
|
||||
virtual void Disconnect();
|
||||
|
||||
bool Send(const uchar* data, int32 size);
|
||||
|
||||
|
||||
char* PopLine(); //returns ownership of allocated byte array
|
||||
inline uint32 GetrIP() const { return rIP; }
|
||||
inline uint16 GetrPort() const { return rPort; }
|
||||
@ -106,7 +106,7 @@ public:
|
||||
bool GetEcho();
|
||||
void SetEcho(bool iValue);
|
||||
bool GetSockName(char *host, uint16 *port);
|
||||
|
||||
|
||||
//should only be used by TCPServer<T>:
|
||||
bool CheckNetActive();
|
||||
inline bool IsFree() const { return pFree; }
|
||||
@ -129,10 +129,10 @@ protected:
|
||||
virtual bool ProcessReceivedData(char* errbuf = 0);
|
||||
virtual bool SendData(bool &sent_something, char* errbuf = 0);
|
||||
virtual bool RecvData(char* errbuf = 0);
|
||||
|
||||
|
||||
virtual void ClearBuffers();
|
||||
|
||||
|
||||
|
||||
bool m_previousLineEnd;
|
||||
|
||||
eConnectionType ConnectionType;
|
||||
@ -144,22 +144,22 @@ protected:
|
||||
uint32 rIP;
|
||||
uint16 rPort; // host byte order
|
||||
bool pFree;
|
||||
|
||||
|
||||
mutable Mutex MState;
|
||||
State_t pState;
|
||||
|
||||
|
||||
//text based line out queue.
|
||||
Mutex MLineOutQueue;
|
||||
virtual bool LineOutQueuePush(char* line); //this is really kinda a hack for the transition to packet mode. Returns true to stop processing the output.
|
||||
MyQueue<char> LineOutQueue;
|
||||
|
||||
|
||||
uchar* recvbuf;
|
||||
int32 recvbuf_size;
|
||||
int32 recvbuf_used;
|
||||
|
||||
|
||||
int32 recvbuf_echo;
|
||||
volatile bool pEcho;
|
||||
|
||||
|
||||
Mutex MSendQueue;
|
||||
uchar* sendbuf;
|
||||
int32 sendbuf_size;
|
||||
@ -169,7 +169,7 @@ protected:
|
||||
void ServerSendQueuePushEnd(const uchar* data, int32 size);
|
||||
void ServerSendQueuePushEnd(uchar** data, int32 size);
|
||||
void ServerSendQueuePushFront(uchar* data, int32 size);
|
||||
|
||||
|
||||
private:
|
||||
void FinishDisconnect();
|
||||
};
|
||||
|
||||
@ -70,11 +70,11 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
BaseTCPServer* tcps = (BaseTCPServer*) tmp;
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting TCPServerLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
|
||||
tcps->MLoopRunning.lock();
|
||||
while (tcps->RunLoop()) {
|
||||
_CP(BaseTCPServerLoop);
|
||||
@ -82,11 +82,11 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
|
||||
tcps->Process();
|
||||
}
|
||||
tcps->MLoopRunning.unlock();
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ void BaseTCPServer::ListenNewConnections() {
|
||||
struct in_addr in;
|
||||
unsigned int fromlen;
|
||||
unsigned short port;
|
||||
|
||||
|
||||
from.sin_family = AF_INET;
|
||||
fromlen = sizeof(from);
|
||||
LockMutex lock(&MSock);
|
||||
@ -124,7 +124,7 @@ void BaseTCPServer::ListenNewConnections() {
|
||||
setsockopt(tmpsock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize));
|
||||
port = from.sin_port;
|
||||
in.s_addr = from.sin_addr.s_addr;
|
||||
|
||||
|
||||
// New TCP connection, this must consume the socket.
|
||||
CreateNewConnection(GetNextID(), tmpsock, in.s_addr, ntohs(from.sin_port));
|
||||
}
|
||||
@ -151,7 +151,7 @@ bool BaseTCPServer::Open(uint16 in_port, char* errbuf) {
|
||||
#endif
|
||||
int reuse_addr = 1;
|
||||
|
||||
// Setup internet address information.
|
||||
// Setup internet address information.
|
||||
// This is used with the bind() call
|
||||
memset((char *) &address, 0, sizeof(address));
|
||||
address.sin_family = AF_INET;
|
||||
@ -211,7 +211,7 @@ bool BaseTCPServer::Open(uint16 in_port, char* errbuf) {
|
||||
|
||||
void BaseTCPServer::Close() {
|
||||
StopLoopAndWait();
|
||||
|
||||
|
||||
LockMutex lock(&MSock);
|
||||
if (sock) {
|
||||
#ifdef _WINDOWS
|
||||
|
||||
@ -22,17 +22,17 @@ public:
|
||||
|
||||
protected:
|
||||
static ThreadReturnType TCPServerLoop(void* tmp);
|
||||
|
||||
|
||||
//factory method:
|
||||
virtual void CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void Process();
|
||||
bool RunLoop();
|
||||
Mutex MLoopRunning;
|
||||
|
||||
|
||||
void StopLoopAndWait();
|
||||
|
||||
|
||||
void ListenNewConnections();
|
||||
|
||||
uint32 NextID;
|
||||
@ -55,10 +55,10 @@ public:
|
||||
TCPServer(uint16 iPort = 0)
|
||||
: BaseTCPServer(iPort) {
|
||||
}
|
||||
|
||||
|
||||
virtual ~TCPServer() {
|
||||
StopLoopAndWait();
|
||||
|
||||
|
||||
//im not sure what the right thing to do here is...
|
||||
//we are freeing a connection which somebody likely has a pointer to..
|
||||
//but, we really shouldent ever get called anyhow..
|
||||
@ -69,7 +69,7 @@ public:
|
||||
delete *cur;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
T * NewQueuePop() {
|
||||
T * ret = nullptr;
|
||||
MNewQueue.lock();
|
||||
@ -80,11 +80,11 @@ public:
|
||||
MNewQueue.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
virtual void Process() {
|
||||
BaseTCPServer::Process();
|
||||
|
||||
|
||||
vitr cur;
|
||||
cur = m_list.begin();
|
||||
while(cur != m_list.end()) {
|
||||
@ -102,18 +102,18 @@ protected:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AddConnection(T *con) {
|
||||
m_list.push_back(con);
|
||||
MNewQueue.lock();
|
||||
m_NewQueue.push(con);
|
||||
MNewQueue.unlock();
|
||||
}
|
||||
|
||||
|
||||
//queue of new connections, for the app to pull from
|
||||
Mutex MNewQueue;
|
||||
std::queue<T *> m_NewQueue;
|
||||
|
||||
|
||||
vstore m_list;
|
||||
};
|
||||
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -29,7 +29,7 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
|
||||
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
TiXmlElement *root = doc.FirstChildElement( root_ele );
|
||||
if(root == nullptr) {
|
||||
printf("Unable to find root '%s' in %s\n",root_ele, file);
|
||||
@ -37,7 +37,7 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
|
||||
}
|
||||
|
||||
ParseOkay=true;
|
||||
|
||||
|
||||
TiXmlNode *main_element = nullptr;
|
||||
while( (main_element = root->IterateChildren( main_element )) ) {
|
||||
if(main_element->Type() != TiXmlNode::ELEMENT)
|
||||
@ -47,25 +47,25 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
|
||||
handler=Handlers.find(ele->Value());
|
||||
if (handler!=Handlers.end() && handler->second) {
|
||||
ElementHandler h=handler->second;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* This is kinda a sketchy operation here, since all of these
|
||||
* element handler methods will be functions in child classes.
|
||||
* This essentially causes us to do an un-checkable (and hence
|
||||
* un-handle-properly-able) cast down to the child class. This
|
||||
* WILL BREAK if any children classes do multiple inheritance.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
(this->*h)(ele);
|
||||
} else {
|
||||
//unhandled element.... do nothing for now
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return(ParseOkay);
|
||||
}
|
||||
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -34,13 +34,13 @@ using namespace std;
|
||||
class XMLParser {
|
||||
public:
|
||||
typedef void (XMLParser::*ElementHandler)(TiXmlElement *ele);
|
||||
|
||||
|
||||
XMLParser();
|
||||
virtual ~XMLParser() {}
|
||||
|
||||
|
||||
bool ParseFile(const char *file, const char *root_ele);
|
||||
bool ParseStatus() const { return ParseOkay; }
|
||||
|
||||
|
||||
protected:
|
||||
const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false);
|
||||
const char *GetText(TiXmlNode *within, bool optional = false);
|
||||
@ -48,7 +48,7 @@ protected:
|
||||
map<string,ElementHandler> Handlers;
|
||||
|
||||
bool ParseOkay;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ typedef enum {
|
||||
BT_Giant = 4,
|
||||
BT_Construct = 5,
|
||||
BT_Extraplanar = 6,
|
||||
BT_Magical = 7, //this name might be a bit off,
|
||||
BT_Magical = 7, //this name might be a bit off,
|
||||
BT_SummonedUndead = 8,
|
||||
BT_RaidGiant = 9,
|
||||
// ...
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
@ -20,226 +20,226 @@
|
||||
|
||||
const char* GetEQClassName(uint8 class_, uint8 level) {
|
||||
switch(class_) {
|
||||
case WARRIOR:
|
||||
if (level >= 70)
|
||||
return "Vanquisher";
|
||||
else if (level >= 65)
|
||||
case WARRIOR:
|
||||
if (level >= 70)
|
||||
return "Vanquisher";
|
||||
else if (level >= 65)
|
||||
return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE.
|
||||
else if (level >= 60)
|
||||
return "Warlord";
|
||||
else if (level >= 55)
|
||||
return "Myrmidon";
|
||||
else if (level >= 51)
|
||||
return "Champion";
|
||||
else
|
||||
return "Warrior";
|
||||
else if (level >= 60)
|
||||
return "Warlord";
|
||||
else if (level >= 55)
|
||||
return "Myrmidon";
|
||||
else if (level >= 51)
|
||||
return "Champion";
|
||||
else
|
||||
return "Warrior";
|
||||
case CLERIC:
|
||||
if (level >= 70)
|
||||
return "Prelate";
|
||||
else if (level >= 65)
|
||||
return "Archon";
|
||||
else if (level >= 60)
|
||||
return "High Priest";
|
||||
else if (level >= 55)
|
||||
return "Templar";
|
||||
else if (level >= 51)
|
||||
return "Vicar";
|
||||
else
|
||||
return "Cleric";
|
||||
case PALADIN:
|
||||
if (level >= 70)
|
||||
return "Lord";
|
||||
else if (level >= 65)
|
||||
return "Lord Protector";
|
||||
else if (level >= 60)
|
||||
return "Crusader";
|
||||
else if (level >= 55)
|
||||
return "Knight";
|
||||
else if (level >= 51)
|
||||
return "Cavalier";
|
||||
else
|
||||
return "Paladin";
|
||||
if (level >= 70)
|
||||
return "Prelate";
|
||||
else if (level >= 65)
|
||||
return "Archon";
|
||||
else if (level >= 60)
|
||||
return "High Priest";
|
||||
else if (level >= 55)
|
||||
return "Templar";
|
||||
else if (level >= 51)
|
||||
return "Vicar";
|
||||
else
|
||||
return "Cleric";
|
||||
case PALADIN:
|
||||
if (level >= 70)
|
||||
return "Lord";
|
||||
else if (level >= 65)
|
||||
return "Lord Protector";
|
||||
else if (level >= 60)
|
||||
return "Crusader";
|
||||
else if (level >= 55)
|
||||
return "Knight";
|
||||
else if (level >= 51)
|
||||
return "Cavalier";
|
||||
else
|
||||
return "Paladin";
|
||||
case RANGER:
|
||||
if (level >= 70)
|
||||
return "Plainswalker";
|
||||
else if (level >= 65)
|
||||
return "Forest Stalker";
|
||||
else if (level >= 60)
|
||||
return "Warder";
|
||||
else if (level >= 55)
|
||||
return "Outrider";
|
||||
else if (level >= 51)
|
||||
return "Pathfinder";
|
||||
else
|
||||
return "Ranger";
|
||||
if (level >= 70)
|
||||
return "Plainswalker";
|
||||
else if (level >= 65)
|
||||
return "Forest Stalker";
|
||||
else if (level >= 60)
|
||||
return "Warder";
|
||||
else if (level >= 55)
|
||||
return "Outrider";
|
||||
else if (level >= 51)
|
||||
return "Pathfinder";
|
||||
else
|
||||
return "Ranger";
|
||||
case SHADOWKNIGHT:
|
||||
if (level >= 70)
|
||||
return "Scourge Knight";
|
||||
else if (level >= 65)
|
||||
return "Dread Lord";
|
||||
else if (level >= 60)
|
||||
return "Grave Lord";
|
||||
else if (level >= 55)
|
||||
return "Revenant";
|
||||
else if (level >= 51)
|
||||
return "Reaver";
|
||||
else
|
||||
return "Shadowknight";
|
||||
if (level >= 70)
|
||||
return "Scourge Knight";
|
||||
else if (level >= 65)
|
||||
return "Dread Lord";
|
||||
else if (level >= 60)
|
||||
return "Grave Lord";
|
||||
else if (level >= 55)
|
||||
return "Revenant";
|
||||
else if (level >= 51)
|
||||
return "Reaver";
|
||||
else
|
||||
return "Shadowknight";
|
||||
case DRUID:
|
||||
if (level >= 70)
|
||||
return "Natureguard";
|
||||
else if (level >= 65)
|
||||
return "Storm Warden";
|
||||
else if (level >= 60)
|
||||
return "Hierophant";
|
||||
else if (level >= 55)
|
||||
return "Preserver";
|
||||
else if (level >= 51)
|
||||
return "Wanderer";
|
||||
else
|
||||
return "Druid";
|
||||
if (level >= 70)
|
||||
return "Natureguard";
|
||||
else if (level >= 65)
|
||||
return "Storm Warden";
|
||||
else if (level >= 60)
|
||||
return "Hierophant";
|
||||
else if (level >= 55)
|
||||
return "Preserver";
|
||||
else if (level >= 51)
|
||||
return "Wanderer";
|
||||
else
|
||||
return "Druid";
|
||||
case MONK:
|
||||
if (level >= 70)
|
||||
return "Stone Fist";
|
||||
else if (level >= 65)
|
||||
return "Transcendent";
|
||||
else if (level >= 60)
|
||||
return "Grandmaster";
|
||||
else if (level >= 55)
|
||||
return "Master";
|
||||
else if (level >= 51)
|
||||
return "Disciple";
|
||||
else
|
||||
return "Monk";
|
||||
case BARD:
|
||||
if (level >= 70)
|
||||
if (level >= 70)
|
||||
return "Stone Fist";
|
||||
else if (level >= 65)
|
||||
return "Transcendent";
|
||||
else if (level >= 60)
|
||||
return "Grandmaster";
|
||||
else if (level >= 55)
|
||||
return "Master";
|
||||
else if (level >= 51)
|
||||
return "Disciple";
|
||||
else
|
||||
return "Monk";
|
||||
case BARD:
|
||||
if (level >= 70)
|
||||
return "Performer";
|
||||
else if (level >= 65)
|
||||
return "Maestro";
|
||||
else if (level >= 60)
|
||||
return "Virtuoso";
|
||||
else if (level >= 55)
|
||||
return "Troubadour";
|
||||
else if (level >= 51)
|
||||
return "Minstrel";
|
||||
else
|
||||
return "Bard";
|
||||
case ROGUE:
|
||||
if (level >= 70)
|
||||
return "Nemesis";
|
||||
else if (level >= 65)
|
||||
return "Deceiver";
|
||||
else if (level >= 60)
|
||||
return "Assassin";
|
||||
else if (level >= 55)
|
||||
return "Blackguard";
|
||||
else if (level >= 51)
|
||||
return "Rake";
|
||||
else
|
||||
return "Rogue";
|
||||
case SHAMAN:
|
||||
if (level >= 70)
|
||||
else if (level >= 65)
|
||||
return "Maestro";
|
||||
else if (level >= 60)
|
||||
return "Virtuoso";
|
||||
else if (level >= 55)
|
||||
return "Troubadour";
|
||||
else if (level >= 51)
|
||||
return "Minstrel";
|
||||
else
|
||||
return "Bard";
|
||||
case ROGUE:
|
||||
if (level >= 70)
|
||||
return "Nemesis";
|
||||
else if (level >= 65)
|
||||
return "Deceiver";
|
||||
else if (level >= 60)
|
||||
return "Assassin";
|
||||
else if (level >= 55)
|
||||
return "Blackguard";
|
||||
else if (level >= 51)
|
||||
return "Rake";
|
||||
else
|
||||
return "Rogue";
|
||||
case SHAMAN:
|
||||
if (level >= 70)
|
||||
return "Soothsayer";
|
||||
else if (level >= 65)
|
||||
return "Prophet";
|
||||
else if (level >= 60)
|
||||
return "Oracle";
|
||||
else if (level >= 55)
|
||||
return "Luminary";
|
||||
else if (level >= 51)
|
||||
return "Mystic";
|
||||
else
|
||||
return "Shaman";
|
||||
case NECROMANCER:
|
||||
if (level >= 70)
|
||||
return "Wraith";
|
||||
else if (level >= 65)
|
||||
return "Arch Lich";
|
||||
else if (level >= 60)
|
||||
return "Warlock";
|
||||
else if (level >= 55)
|
||||
return "Defiler";
|
||||
else if (level >= 51)
|
||||
return "Heretic";
|
||||
else
|
||||
return "Necromancer";
|
||||
case WIZARD:
|
||||
if (level >= 70)
|
||||
return "Grand Arcanist";
|
||||
else if (level >= 65)
|
||||
return "Arcanist";
|
||||
else if (level >= 60)
|
||||
return "Sorcerer";
|
||||
else if (level >= 55)
|
||||
return "Evoker";
|
||||
else if (level >= 51)
|
||||
return "Channeler";
|
||||
else
|
||||
return "Wizard";
|
||||
case MAGICIAN:
|
||||
if (level >= 70)
|
||||
return "Arch Magus";
|
||||
else if (level >= 65)
|
||||
return "Arch Convoker";
|
||||
else if (level >= 60)
|
||||
return "Arch Mage";
|
||||
else if (level >= 55)
|
||||
return "Conjurer";
|
||||
if (level >= 51)
|
||||
return "Elementalist";
|
||||
else
|
||||
return "Magician";
|
||||
case ENCHANTER:
|
||||
if (level >= 70)
|
||||
return "Bedazzler";
|
||||
else if (level >= 65)
|
||||
return "Coercer";
|
||||
else if (level >= 60)
|
||||
return "Phantasmist";
|
||||
else if (level >= 55)
|
||||
return "Beguiler";
|
||||
else if (level >= 51)
|
||||
return "Illusionist";
|
||||
else
|
||||
return "Enchanter";
|
||||
case BEASTLORD:
|
||||
if (level >= 70)
|
||||
return "Wildblood";
|
||||
else if (level >= 65)
|
||||
return "Feral Lord";
|
||||
else if (level >= 60)
|
||||
return "Savage Lord";
|
||||
else if (level >= 55)
|
||||
return "Animist";
|
||||
else if (level >= 51)
|
||||
return "Primalist";
|
||||
else
|
||||
return "Beastlord";
|
||||
case BERSERKER:
|
||||
if (level >= 70)
|
||||
return "Ravager";
|
||||
else if (level >= 65)
|
||||
return "Fury";
|
||||
else if (level >= 60)
|
||||
return "Rager";
|
||||
else if (level >= 55)
|
||||
return "Vehement";
|
||||
else if (level >= 51)
|
||||
return "Brawler";
|
||||
else
|
||||
return "Berserker";
|
||||
case BANKER:
|
||||
if (level >= 70)
|
||||
return "Master Banker";
|
||||
else if (level >= 65)
|
||||
return "Elder Banker";
|
||||
else if (level >= 60)
|
||||
return "Oldest Banker";
|
||||
else if (level >= 55)
|
||||
return "Older Banker";
|
||||
else if (level >= 51)
|
||||
return "Old Banker";
|
||||
else
|
||||
else if (level >= 65)
|
||||
return "Prophet";
|
||||
else if (level >= 60)
|
||||
return "Oracle";
|
||||
else if (level >= 55)
|
||||
return "Luminary";
|
||||
else if (level >= 51)
|
||||
return "Mystic";
|
||||
else
|
||||
return "Shaman";
|
||||
case NECROMANCER:
|
||||
if (level >= 70)
|
||||
return "Wraith";
|
||||
else if (level >= 65)
|
||||
return "Arch Lich";
|
||||
else if (level >= 60)
|
||||
return "Warlock";
|
||||
else if (level >= 55)
|
||||
return "Defiler";
|
||||
else if (level >= 51)
|
||||
return "Heretic";
|
||||
else
|
||||
return "Necromancer";
|
||||
case WIZARD:
|
||||
if (level >= 70)
|
||||
return "Grand Arcanist";
|
||||
else if (level >= 65)
|
||||
return "Arcanist";
|
||||
else if (level >= 60)
|
||||
return "Sorcerer";
|
||||
else if (level >= 55)
|
||||
return "Evoker";
|
||||
else if (level >= 51)
|
||||
return "Channeler";
|
||||
else
|
||||
return "Wizard";
|
||||
case MAGICIAN:
|
||||
if (level >= 70)
|
||||
return "Arch Magus";
|
||||
else if (level >= 65)
|
||||
return "Arch Convoker";
|
||||
else if (level >= 60)
|
||||
return "Arch Mage";
|
||||
else if (level >= 55)
|
||||
return "Conjurer";
|
||||
if (level >= 51)
|
||||
return "Elementalist";
|
||||
else
|
||||
return "Magician";
|
||||
case ENCHANTER:
|
||||
if (level >= 70)
|
||||
return "Bedazzler";
|
||||
else if (level >= 65)
|
||||
return "Coercer";
|
||||
else if (level >= 60)
|
||||
return "Phantasmist";
|
||||
else if (level >= 55)
|
||||
return "Beguiler";
|
||||
else if (level >= 51)
|
||||
return "Illusionist";
|
||||
else
|
||||
return "Enchanter";
|
||||
case BEASTLORD:
|
||||
if (level >= 70)
|
||||
return "Wildblood";
|
||||
else if (level >= 65)
|
||||
return "Feral Lord";
|
||||
else if (level >= 60)
|
||||
return "Savage Lord";
|
||||
else if (level >= 55)
|
||||
return "Animist";
|
||||
else if (level >= 51)
|
||||
return "Primalist";
|
||||
else
|
||||
return "Beastlord";
|
||||
case BERSERKER:
|
||||
if (level >= 70)
|
||||
return "Ravager";
|
||||
else if (level >= 65)
|
||||
return "Fury";
|
||||
else if (level >= 60)
|
||||
return "Rager";
|
||||
else if (level >= 55)
|
||||
return "Vehement";
|
||||
else if (level >= 51)
|
||||
return "Brawler";
|
||||
else
|
||||
return "Berserker";
|
||||
case BANKER:
|
||||
if (level >= 70)
|
||||
return "Master Banker";
|
||||
else if (level >= 65)
|
||||
return "Elder Banker";
|
||||
else if (level >= 60)
|
||||
return "Oldest Banker";
|
||||
else if (level >= 55)
|
||||
return "Older Banker";
|
||||
else if (level >= 51)
|
||||
return "Old Banker";
|
||||
else
|
||||
return "Banker";
|
||||
case WARRIORGM:
|
||||
return "Warrior Guildmaster";
|
||||
|
||||
@ -37,23 +37,23 @@
|
||||
#define BEASTLORD 15
|
||||
#define BERSERKER 16
|
||||
#define PLAYER_CLASS_COUNT 16 // used for array defines, must be the count of playable classes
|
||||
#define WARRIORGM 20
|
||||
#define CLERICGM 21
|
||||
#define PALADINGM 22
|
||||
#define RANGERGM 23
|
||||
#define SHADOWKNIGHTGM 24
|
||||
#define DRUIDGM 25
|
||||
#define MONKGM 26
|
||||
#define BARDGM 27
|
||||
#define ROGUEGM 28
|
||||
#define SHAMANGM 29
|
||||
#define NECROMANCERGM 30
|
||||
#define WIZARDGM 31
|
||||
#define MAGICIANGM 32
|
||||
#define ENCHANTERGM 33
|
||||
#define WARRIORGM 20
|
||||
#define CLERICGM 21
|
||||
#define PALADINGM 22
|
||||
#define RANGERGM 23
|
||||
#define SHADOWKNIGHTGM 24
|
||||
#define DRUIDGM 25
|
||||
#define MONKGM 26
|
||||
#define BARDGM 27
|
||||
#define ROGUEGM 28
|
||||
#define SHAMANGM 29
|
||||
#define NECROMANCERGM 30
|
||||
#define WIZARDGM 31
|
||||
#define MAGICIANGM 32
|
||||
#define ENCHANTERGM 33
|
||||
#define BEASTLORDGM 34
|
||||
#define BERSERKERGM 35
|
||||
#define BANKER 40
|
||||
#define BANKER 40
|
||||
#define MERCHANT 41
|
||||
#define DISCORD_MERCHANT 59
|
||||
#define ADVENTURERECRUITER 60
|
||||
|
||||
@ -45,41 +45,41 @@ public:
|
||||
Database_DBLoadItems,
|
||||
Database_GetWaypoints,
|
||||
Database_DBLoadNPCFactionLists,
|
||||
|
||||
|
||||
DBcore_RunQuery,
|
||||
|
||||
|
||||
DBAsync_ProcessWork,
|
||||
DBAsync_DispatchWork,
|
||||
DBAsyncLoop_loop,
|
||||
|
||||
|
||||
EQStreamServer_Process,
|
||||
|
||||
|
||||
EQStream_Process,
|
||||
|
||||
|
||||
EQStreamServerLoop,
|
||||
EQStreamInLoop,
|
||||
EQStreamOutLoop,
|
||||
TCPServerLoop,
|
||||
TCPConnectionLoop,
|
||||
|
||||
|
||||
Inventory_GetItem,
|
||||
Inventory_HasItem,
|
||||
|
||||
|
||||
BaseTCPServerLoop,
|
||||
|
||||
MakeRandomInt,
|
||||
MakeRandomFloat,
|
||||
|
||||
|
||||
Mutex_lock,
|
||||
Timer_Check,
|
||||
|
||||
|
||||
WorldConnection_Process,
|
||||
|
||||
|
||||
MaxCommonProfilerId
|
||||
};
|
||||
|
||||
|
||||
inline CommonProfiler() : GeneralProfiler(MaxCommonProfilerId) { }
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern CommonProfiler _cp;
|
||||
|
||||
@ -9,7 +9,7 @@ class EQEmuStackWalker : public StackWalker
|
||||
public:
|
||||
EQEmuStackWalker() : StackWalker() { }
|
||||
EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { }
|
||||
virtual void OnOutput(LPCSTR szText) {
|
||||
virtual void OnOutput(LPCSTR szText) {
|
||||
char buffer[4096];
|
||||
for(int i = 0; i < 4096; ++i) {
|
||||
if(szText[i] == 0) {
|
||||
@ -24,8 +24,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
LogFile->write(EQEMuLog::Crash, buffer);
|
||||
StackWalker::OnOutput(szText);
|
||||
LogFile->write(EQEMuLog::Crash, buffer);
|
||||
StackWalker::OnOutput(szText);
|
||||
}
|
||||
};
|
||||
|
||||
@ -97,12 +97,12 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
||||
LogFile->write(EQEMuLog::Crash, "Unknown Exception");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
|
||||
{
|
||||
EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
|
||||
@ -85,9 +85,9 @@ void CRC32::SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at)
|
||||
{
|
||||
unsigned long data;
|
||||
unsigned long check = 0xffffffff;
|
||||
|
||||
|
||||
assert(in_length >= start_at && in_data);
|
||||
|
||||
|
||||
for(uint32 i=start_at; i<in_length; i++)
|
||||
{
|
||||
data = in_data[i];
|
||||
@ -97,7 +97,7 @@ void CRC32::SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at)
|
||||
data = CRC32Table[data];
|
||||
check = check ^ data;
|
||||
}
|
||||
|
||||
|
||||
memcpy(in_data, (char*)&check, 4);
|
||||
}
|
||||
|
||||
|
||||
@ -8,12 +8,12 @@ public:
|
||||
static uint32 Generate(const uint8* buf, uint32 bufsize);
|
||||
static uint32 GenerateNoFlip(const uint8* buf, uint32 bufsize); // Same as Generate(), but without the ~
|
||||
static void SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at=4);
|
||||
|
||||
|
||||
// Multiple buffer CRC32
|
||||
static uint32 Update(const uint8* buf, uint32 bufsize, uint32 crc32 = 0xFFFFFFFF);
|
||||
static inline uint32 Finish(uint32 crc32) { return ~crc32; }
|
||||
static inline void Finish(uint32* crc32) { *crc32 = ~(*crc32); }
|
||||
|
||||
|
||||
private:
|
||||
static inline void Calc(const uint8 byte, uint32& crc32);
|
||||
};
|
||||
|
||||
@ -248,7 +248,7 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes)
|
||||
return true;
|
||||
}
|
||||
//End Lieka Edit
|
||||
|
||||
|
||||
bool Database::CheckGMIPs(const char* ip_address, uint32 account_id) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
@ -268,7 +268,7 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes)
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1379,7 +1379,7 @@ const char* Database::GetZoneName(uint32 zoneID, bool ErrorUnknown) {
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (zoneID <= max_zonename) {
|
||||
if (zonename_array[zoneID])
|
||||
return zonename_array[zoneID];
|
||||
@ -1406,9 +1406,9 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
|
||||
MYSQL_ROW row;
|
||||
int peqzone = 0;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT peqzone from zone where zoneidnumber='%i' AND (version=%i OR version=0) ORDER BY version DESC", zoneID, version), errbuf, &result))
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT peqzone from zone where zoneidnumber='%i' AND (version=%i OR version=0) ORDER BY version DESC", zoneID, version), errbuf, &result))
|
||||
{
|
||||
if (mysql_num_rows(result) > 0)
|
||||
if (mysql_num_rows(result) > 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
peqzone = atoi(row[0]);
|
||||
@ -1425,7 +1425,7 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
|
||||
return peqzone;
|
||||
}
|
||||
|
||||
bool Database::CheckNameFilter(const char* name, bool surname)
|
||||
bool Database::CheckNameFilter(const char* name, bool surname)
|
||||
{
|
||||
std::string str_name = name;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
@ -2257,7 +2257,7 @@ uint32 Database::GetRaidID(const char* name){
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
uint32 raidid=0;
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT raidid from raid_members where name='%s'", name),
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT raidid from raid_members where name='%s'", name),
|
||||
errbuf, &result)) {
|
||||
if((row = mysql_fetch_row(result)))
|
||||
{
|
||||
@ -2282,8 +2282,8 @@ const char *Database::GetRaidLeaderName(uint32 rid)
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT name FROM raid_members WHERE raidid=%u AND israidleader=1",
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT name FROM raid_members WHERE raidid=%u AND israidleader=1",
|
||||
rid), errbuf, &result)) {
|
||||
if((row = mysql_fetch_row(result)) != nullptr)
|
||||
{
|
||||
@ -2326,11 +2326,11 @@ bool Database::VerifyZoneInstance(uint32 zone_id, uint16 instance_id)
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_lockout where id=%u AND zone=%u",
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_lockout where id=%u AND zone=%u",
|
||||
instance_id, zone_id), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
return true;
|
||||
@ -2341,7 +2341,7 @@ bool Database::VerifyZoneInstance(uint32 zone_id, uint16 instance_id)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
@ -2356,17 +2356,17 @@ bool Database::CharacterInInstanceGroup(uint16 instance_id, uint32 char_id)
|
||||
MYSQL_RES *result;
|
||||
bool lockout_instance_player = false;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT charid FROM instance_lockout_player where id=%u AND charid=%u",
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT charid FROM instance_lockout_player where id=%u AND charid=%u",
|
||||
instance_id, char_id), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) == 1)
|
||||
if (mysql_num_rows(result) == 1)
|
||||
{
|
||||
lockout_instance_player = true;
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
}
|
||||
@ -2402,11 +2402,11 @@ bool Database::CheckInstanceExpired(uint16 instance_id)
|
||||
int32 start_time = 0;
|
||||
int32 duration = 0;
|
||||
uint32 never_expires = 0;
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT start_time, duration, never_expires FROM instance_lockout WHERE id=%u",
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT start_time, duration, never_expires FROM instance_lockout WHERE id=%u",
|
||||
instance_id), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
start_time = atoi(row[0]);
|
||||
@ -2420,7 +2420,7 @@ bool Database::CheckInstanceExpired(uint16 instance_id)
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return true;
|
||||
@ -2448,16 +2448,16 @@ uint32 Database::ZoneIDFromInstanceID(uint16 instance_id)
|
||||
MYSQL_ROW row;
|
||||
uint32 ret;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT zone FROM instance_lockout where id=%u", instance_id),
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT zone FROM instance_lockout where id=%u", instance_id),
|
||||
errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
ret = atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2465,7 +2465,7 @@ uint32 Database::ZoneIDFromInstanceID(uint16 instance_id)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
@ -2481,16 +2481,16 @@ uint32 Database::VersionFromInstanceID(uint16 instance_id)
|
||||
MYSQL_ROW row;
|
||||
uint32 ret;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT version FROM instance_lockout where id=%u", instance_id),
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT version FROM instance_lockout where id=%u", instance_id),
|
||||
errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
ret = atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2498,7 +2498,7 @@ uint32 Database::VersionFromInstanceID(uint16 instance_id)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
@ -2516,11 +2516,11 @@ uint32 Database::GetTimeRemainingInstance(uint16 instance_id, bool &is_perma)
|
||||
uint32 duration = 0;
|
||||
uint32 never_expires = 0;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT start_time, duration, never_expires FROM instance_lockout WHERE id=%u",
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT start_time, duration, never_expires FROM instance_lockout WHERE id=%u",
|
||||
instance_id), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
start_time = atoi(row[0]);
|
||||
@ -2535,7 +2535,7 @@ uint32 Database::GetTimeRemainingInstance(uint16 instance_id, bool &is_perma)
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
is_perma = false;
|
||||
@ -2567,7 +2567,7 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT COUNT(*) FROM instance_lockout"), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
int count = atoi(row[0]);
|
||||
@ -2584,7 +2584,7 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
instance_id = 0;
|
||||
@ -2597,7 +2597,7 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_lockout where id >= %i ORDER BY id", count), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
while((row = mysql_fetch_row(result)))
|
||||
{
|
||||
@ -2624,7 +2624,7 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
||||
mysql_free_result(result);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
}
|
||||
@ -2638,13 +2638,13 @@ bool Database::CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "INSERT INTO instance_lockout (id, zone, version, start_time, duration)"
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "INSERT INTO instance_lockout (id, zone, version, start_time, duration)"
|
||||
" values(%lu, %lu, %lu, UNIX_TIMESTAMP(), %lu)", (unsigned long)instance_id, (unsigned long)zone_id, (unsigned long)version, (unsigned long)duration), errbuf))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
@ -2663,7 +2663,7 @@ void Database::PurgeExpiredInstances()
|
||||
"(start_time+duration) <= UNIX_TIMESTAMP() and never_expires = 0"), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) > 0)
|
||||
if (mysql_num_rows(result) > 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
while(row != nullptr)
|
||||
@ -2675,7 +2675,7 @@ void Database::PurgeExpiredInstances()
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
}
|
||||
@ -2692,7 +2692,7 @@ bool Database::AddClientToInstance(uint16 instance_id, uint32 char_id)
|
||||
safe_delete_array(query);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
@ -2704,13 +2704,13 @@ bool Database::RemoveClientFromInstance(uint16 instance_id, uint32 char_id)
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "DELETE FROM instance_lockout_player WHERE id=%lu AND charid=%lu",
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "DELETE FROM instance_lockout_player WHERE id=%lu AND charid=%lu",
|
||||
(unsigned long)instance_id, (unsigned long)char_id), errbuf))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
@ -2722,13 +2722,13 @@ bool Database::RemoveClientsFromInstance(uint16 instance_id)
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "DELETE FROM instance_lockout_player WHERE id=%lu",
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "DELETE FROM instance_lockout_player WHERE id=%lu",
|
||||
(unsigned long)instance_id), errbuf))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
@ -2741,11 +2741,11 @@ bool Database::CheckInstanceExists(uint16 instance_id)
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT * FROM instance_lockout where id=%u", instance_id),
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT * FROM instance_lockout where id=%u", instance_id),
|
||||
errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
return true;
|
||||
@ -2753,7 +2753,7 @@ bool Database::CheckInstanceExists(uint16 instance_id)
|
||||
mysql_free_result(result);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
@ -2767,7 +2767,7 @@ void Database::BuryCorpsesInInstance(uint16 instance_id)
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "UPDATE player_corpses SET IsBurried=1, instanceid=0 WHERE instanceid=%u",
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "UPDATE player_corpses SET IsBurried=1, instanceid=0 WHERE instanceid=%u",
|
||||
instance_id), errbuf, &result))
|
||||
{
|
||||
mysql_free_result(result);
|
||||
@ -2786,16 +2786,16 @@ uint16 Database::GetInstanceVersion(uint16 instance_id)
|
||||
MYSQL_ROW row;
|
||||
uint32 ret;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT version FROM instance_lockout where id=%u", instance_id),
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT version FROM instance_lockout where id=%u", instance_id),
|
||||
errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
ret = atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2803,7 +2803,7 @@ uint16 Database::GetInstanceVersion(uint16 instance_id)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
@ -2824,12 +2824,12 @@ uint16 Database::GetInstanceID(const char* zone, uint32 charid, int16 version)
|
||||
"instance_lockout_player.charid=%u LIMIT 1;", GetZoneID(zone), version, charid, charid), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
ret = atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2837,7 +2837,7 @@ uint16 Database::GetInstanceID(const char* zone, uint32 charid, int16 version)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
@ -2861,12 +2861,12 @@ uint16 Database::GetInstanceID(uint32 zone, uint32 charid, int16 version)
|
||||
"instance_lockout_player.charid=%u LIMIT 1;", zone, version, charid), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) != 0)
|
||||
if (mysql_num_rows(result) != 0)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
ret = atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2874,7 +2874,7 @@ uint16 Database::GetInstanceID(uint32 zone, uint32 charid, int16 version)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
@ -2891,7 +2891,7 @@ void Database::AssignGroupToInstance(uint32 gid, uint32 instance_id)
|
||||
uint32 zone_id = ZoneIDFromInstanceID(instance_id);
|
||||
uint16 version = VersionFromInstanceID(instance_id);
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT charid FROM group_id WHERE groupid=%u", gid),
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT charid FROM group_id WHERE groupid=%u", gid),
|
||||
errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
@ -2905,7 +2905,7 @@ void Database::AssignGroupToInstance(uint32 gid, uint32 instance_id)
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
}
|
||||
@ -2920,7 +2920,7 @@ void Database::AssignRaidToInstance(uint32 rid, uint32 instance_id)
|
||||
uint32 zone_id = ZoneIDFromInstanceID(instance_id);
|
||||
uint16 version = VersionFromInstanceID(instance_id);
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT charid FROM raid_members WHERE raidid=%u", rid),
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT charid FROM raid_members WHERE raidid=%u", rid),
|
||||
errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
@ -2934,7 +2934,7 @@ void Database::AssignRaidToInstance(uint32 rid, uint32 instance_id)
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
}
|
||||
@ -3012,7 +3012,7 @@ bool Database::GlobalInstance(uint16 instance_id)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
@ -3125,7 +3125,7 @@ void Database::UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win)
|
||||
}
|
||||
}
|
||||
|
||||
bool Database::GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w,
|
||||
bool Database::GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w,
|
||||
uint32 &tak_w, uint32 &guk_l, uint32 &mir_l, uint32 &mmc_l, uint32 &ruj_l, uint32 &tak_l)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
@ -3134,7 +3134,7 @@ bool Database::GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, u
|
||||
MYSQL_ROW row;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT `guk_wins`, `mir_wins`, `mmc_wins`, `ruj_wins`, `tak_wins`, "
|
||||
"`guk_losses`, `mir_losses`, `mmc_losses`, `ruj_losses`, `tak_losses` FROM `adventure_stats` WHERE player_id=%u",
|
||||
"`guk_losses`, `mir_losses`, `mmc_losses`, `ruj_losses`, `tak_losses` FROM `adventure_stats` WHERE player_id=%u",
|
||||
char_id), errbuf, &result))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
@ -3154,7 +3154,7 @@ bool Database::GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, u
|
||||
mysql_free_result(result);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
|
||||
@ -76,7 +76,7 @@ EventLogDetails_Struct eld[255];
|
||||
};
|
||||
|
||||
|
||||
// Added By Hogie
|
||||
// Added By Hogie
|
||||
// INSERT into variables (varname,value) values('decaytime [minlevel] [maxlevel]','[number of seconds]');
|
||||
// IE: decaytime 1 54 = Levels 1 through 54
|
||||
// decaytime 55 100 = Levels 55 through 100
|
||||
@ -106,7 +106,7 @@ public:
|
||||
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||
bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||
~Database();
|
||||
|
||||
|
||||
/*
|
||||
* General Character Related Stuff
|
||||
*/
|
||||
@ -175,7 +175,7 @@ public:
|
||||
* Adventure related.
|
||||
*/
|
||||
void UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win);
|
||||
bool GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w, uint32 &tak_w,
|
||||
bool GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w, uint32 &tak_w,
|
||||
uint32 &guk_l, uint32 &mir_l, uint32 &mmc_l, uint32 &ruj_l, uint32 &tak_l);
|
||||
|
||||
/*
|
||||
@ -194,7 +194,7 @@ public:
|
||||
bool GetLiveChar(uint32 account_id, char* cname);
|
||||
uint8 GetAgreementFlag(uint32 acctid);
|
||||
void SetAgreementFlag(uint32 acctid);
|
||||
|
||||
|
||||
/*
|
||||
* Groups
|
||||
*/
|
||||
@ -202,7 +202,7 @@ public:
|
||||
void SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ismerc = false);
|
||||
void ClearGroup(uint32 gid = 0);
|
||||
char* GetGroupLeaderForLogin(const char* name,char* leaderbuf);
|
||||
|
||||
|
||||
void SetGroupLeaderName(uint32 gid, const char* name);
|
||||
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr,
|
||||
GroupLeadershipAA_Struct* GLAA = nullptr);
|
||||
@ -224,7 +224,7 @@ public:
|
||||
bool LoadVariables();
|
||||
uint32 LoadVariables_MQ(char** query);
|
||||
bool LoadVariables_result(MYSQL_RES* result);
|
||||
|
||||
|
||||
/*
|
||||
* General Queries
|
||||
*/
|
||||
@ -243,22 +243,22 @@ public:
|
||||
bool LoadPTimers(uint32 charid, PTimerList &into);
|
||||
void ClearPTimers(uint32 charid);
|
||||
void ClearMerchantTemp();
|
||||
void SetLFP(uint32 CharID, bool LFP);
|
||||
void SetLFP(uint32 CharID, bool LFP);
|
||||
void SetLFG(uint32 CharID, bool LFG);
|
||||
void SetFirstLogon(uint32 CharID, uint8 firstlogon);
|
||||
void SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon);
|
||||
void SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon);
|
||||
void AddReport(std::string who, std::string against, std::string lines);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
void HandleMysqlError(uint32 errnum);
|
||||
|
||||
|
||||
private:
|
||||
void DBInitVars();
|
||||
|
||||
|
||||
uint32 max_zonename;
|
||||
char** zonename_array;
|
||||
|
||||
|
||||
Mutex Mvarcache;
|
||||
uint32 varcache_max;
|
||||
VarCache_Struct** varcache_array;
|
||||
|
||||
@ -41,11 +41,11 @@ void AsyncLoadVariables(DBAsync *dba, Database *db) {
|
||||
//which will get signaled when somebody puts something on the queue
|
||||
ThreadReturnType DBAsyncLoop(void* tmp) {
|
||||
DBAsync* dba = (DBAsync*) tmp;
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting DBAsyncLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
|
||||
dba->MLoopRunning.lock();
|
||||
while (dba->RunLoop()) {
|
||||
//wait before working so we check the loop condition
|
||||
@ -60,11 +60,11 @@ ThreadReturnType DBAsyncLoop(void* tmp) {
|
||||
// Sleep(ASYNC_LOOP_GRANULARITY);
|
||||
}
|
||||
dba->MLoopRunning.unlock();
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending DBAsyncLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
|
||||
@ -92,14 +92,14 @@ bool DBAsync::StopThread() {
|
||||
ret = pRunLoop;
|
||||
pRunLoop = false;
|
||||
MRunLoop.unlock();
|
||||
|
||||
|
||||
//signal the condition so we exit the loop if were waiting
|
||||
CInList.Signal();
|
||||
|
||||
|
||||
//this effectively waits for the processing thread to finish
|
||||
MLoopRunning.lock();
|
||||
MLoopRunning.unlock();
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -120,10 +120,10 @@ uint32 DBAsync::AddWork(DBAsyncWork** iWork, uint32 iDelay) {
|
||||
#endif
|
||||
*iWork = 0;
|
||||
MInList.unlock();
|
||||
|
||||
|
||||
//wake up the processing thread and tell it to get to work.
|
||||
CInList.Signal();
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ void DBAsync::CheckTimeout() {
|
||||
MFQList.unlock();
|
||||
}
|
||||
catch(...){
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,10 +31,10 @@ protected:
|
||||
Condition CInList;
|
||||
bool RunLoop();
|
||||
void Process();
|
||||
|
||||
|
||||
private:
|
||||
virtual void CheckTimeout();
|
||||
|
||||
|
||||
void ProcessWork(DBAsyncWork* iWork, bool iSleep = true);
|
||||
void DispatchWork(DBAsyncWork* iWork);
|
||||
inline uint32 GetNextID() { return pNextID++; }
|
||||
@ -64,7 +64,7 @@ private:
|
||||
|
||||
/*
|
||||
DB Work Complete Callback:
|
||||
This will be called under the DBAsync thread! Never access any non-threadsafe
|
||||
This will be called under the DBAsync thread! Never access any non-threadsafe
|
||||
data/functions/classes. (ie: zone, entitylist, client, etc are not threadsafe)
|
||||
Function prototype:
|
||||
return value: true if we should delete the data, false if we should keep it
|
||||
@ -103,7 +103,7 @@ public:
|
||||
// Pops finished queries off the work
|
||||
DBAsyncQuery* PopAnswer();
|
||||
uint32 QueryCount();
|
||||
|
||||
|
||||
Database *GetDB() const { return(m_db); }
|
||||
|
||||
bool CheckTimeout(uint32 iFQTimeout);
|
||||
|
||||
@ -190,7 +190,7 @@ bool DBcore::Open(uint32* errnum, char* errbuf) {
|
||||
/*
|
||||
Added CLIENT_FOUND_ROWS flag to the connect
|
||||
otherwise DB update calls would say 0 rows affected when the value already equalled
|
||||
what the function was tring to set it to, therefore the function would think it failed
|
||||
what the function was tring to set it to, therefore the function would think it failed
|
||||
*/
|
||||
uint32 flags = CLIENT_FOUND_ROWS;
|
||||
if (pCompress)
|
||||
|
||||
@ -26,7 +26,7 @@ public:
|
||||
uint32 DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen);
|
||||
void ping();
|
||||
MYSQL* getMySQL(){ return &mysql; }
|
||||
|
||||
|
||||
protected:
|
||||
bool Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase, uint32 iPort, uint32* errnum = 0, char* errbuf = 0, bool iCompress = false, bool iSSL = false);
|
||||
private:
|
||||
|
||||
@ -29,7 +29,7 @@ int32 Database::GetDoorsCount(uint32* oMaxID) {
|
||||
delete[] query;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
|
||||
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
|
||||
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
|
||||
@ -210,7 +210,7 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
|
||||
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
|
||||
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
|
||||
@ -273,7 +273,7 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
|
||||
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
|
||||
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
|
||||
@ -347,7 +347,7 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
|
||||
LockMutex lock(&MLog[id]);
|
||||
if (!logFileValid)
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
|
||||
|
||||
write(id, "Dumping Packet: %i", size);
|
||||
// Output as HEX
|
||||
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
|
||||
@ -382,7 +382,7 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
|
||||
safe_delete_array(ascii);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void EQEMuLog::SetCallback(LogIDs id, msgCallbackFmt proc) {
|
||||
if (!logFileValid)
|
||||
return;
|
||||
|
||||
@ -106,19 +106,19 @@ public:
|
||||
Crash,
|
||||
MaxLogID
|
||||
};
|
||||
|
||||
|
||||
//these are callbacks called for each
|
||||
typedef void (* msgCallbackBuf)(LogIDs id, const char *buf, uint8 size, uint32 count);
|
||||
typedef void (* msgCallbackFmt)(LogIDs id, const char *fmt, va_list ap);
|
||||
typedef void (* msgCallbackPva)(LogIDs id, const char *prefix, const char *fmt, va_list ap);
|
||||
|
||||
|
||||
void SetAllCallbacks(msgCallbackFmt proc);
|
||||
void SetAllCallbacks(msgCallbackBuf proc);
|
||||
void SetAllCallbacks(msgCallbackPva proc);
|
||||
void SetCallback(LogIDs id, msgCallbackFmt proc);
|
||||
void SetCallback(LogIDs id, msgCallbackBuf proc);
|
||||
void SetCallback(LogIDs id, msgCallbackPva proc);
|
||||
|
||||
|
||||
bool writebuf(LogIDs id, const char *buf, uint8 size, uint32 count);
|
||||
bool write(LogIDs id, const char *fmt, ...);
|
||||
bool writePVA(LogIDs id, const char *prefix, const char *fmt, va_list args);
|
||||
@ -137,7 +137,7 @@ private:
|
||||
8 = use stderr instead (2 must be set)
|
||||
*/
|
||||
uint8 pLogStatus[MaxLogID];
|
||||
|
||||
|
||||
msgCallbackFmt logCallbackFmt[MaxLogID];
|
||||
msgCallbackBuf logCallbackBuf[MaxLogID];
|
||||
msgCallbackPva logCallbackPva[MaxLogID];
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#ifndef DEITY_H
|
||||
#define DEITY_H
|
||||
|
||||
/*
|
||||
/*
|
||||
** Diety List
|
||||
*/
|
||||
#define DEITY_AGNOSTIC 396 //drop the high bit for 140
|
||||
@ -37,7 +37,7 @@
|
||||
#define DEITY_TUNARE 215
|
||||
|
||||
//Guessed:
|
||||
#define DEITY_BERTOX 201
|
||||
#define DEITY_BERTOX 201
|
||||
#define DEITY_RODCET 212
|
||||
#define DEITY_VEESHAN 216
|
||||
|
||||
|
||||
@ -21,13 +21,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
|
||||
|
||||
const char *OpcodeNames[_maxEmuOpcode+1] = {
|
||||
"OP_Unknown",
|
||||
|
||||
|
||||
//a preprocessor hack so we dont have to maintain two lists
|
||||
#define N(x) #x
|
||||
#include "emu_oplist.h"
|
||||
#include "mail_oplist.h"
|
||||
#undef N
|
||||
|
||||
|
||||
""
|
||||
};
|
||||
|
||||
|
||||
@ -413,7 +413,7 @@ N(OP_PetBuffWindow),
|
||||
N(OP_RaidJoin),
|
||||
N(OP_Translocate),
|
||||
N(OP_Sacrifice),
|
||||
N(OP_KeyRing),
|
||||
N(OP_KeyRing),
|
||||
N(OP_PopupResponse),
|
||||
N(OP_DeleteCharge),
|
||||
N(OP_PotionBelt),
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef EQ_CONSTANTS_H
|
||||
#define EQ_CONSTANTS_H
|
||||
#define EQ_CONSTANTS_H
|
||||
|
||||
#include "skills.h"
|
||||
|
||||
@ -170,7 +170,7 @@ typedef enum {
|
||||
_eaMaxAppearance
|
||||
} EmuAppearance;
|
||||
|
||||
/*
|
||||
/*
|
||||
** Diety List
|
||||
*/
|
||||
#define DEITY_UNKNOWN 0
|
||||
@ -190,11 +190,11 @@ typedef enum {
|
||||
#define DEITY_TUNARE 215
|
||||
|
||||
//Guessed:
|
||||
#define DEITY_BERT 201
|
||||
#define DEITY_BERT 201
|
||||
#define DEITY_RODCET 212
|
||||
#define DEITY_VEESHAN 216
|
||||
|
||||
// msg_type's for custom usercolors
|
||||
// msg_type's for custom usercolors
|
||||
#define MT_Say 256
|
||||
#define MT_Tell 257
|
||||
#define MT_Group 258
|
||||
@ -435,33 +435,33 @@ typedef enum {
|
||||
#define STAT_HASTE 19
|
||||
#define STAT_DAMAGE_SHIELD 20
|
||||
|
||||
/**
|
||||
* Recast timer types. Used as an off set to charProfileStruct timers.
|
||||
*/
|
||||
enum RecastTypes
|
||||
{
|
||||
RecastTimer0 = 0,
|
||||
RecastTimer1,
|
||||
WeaponHealClickTimer, // 2
|
||||
MuramiteBaneNukeClickTimer, // 3
|
||||
RecastTimer4,
|
||||
DispellClickTimer, // 5 (also click heal orbs?)
|
||||
EpicTimer, // 6
|
||||
OoWBPClickTimer, // 7
|
||||
VishQuestClassItemTimer, // 8
|
||||
HealPotionTimer, // 9
|
||||
RecastTimer10,
|
||||
RecastTimer11,
|
||||
RecastTimer12,
|
||||
RecastTimer13,
|
||||
RecastTimer14,
|
||||
RecastTimer15,
|
||||
RecastTimer16,
|
||||
RecastTimer17,
|
||||
RecastTimer18,
|
||||
ModRodTimer // 19
|
||||
/**
|
||||
* Recast timer types. Used as an off set to charProfileStruct timers.
|
||||
*/
|
||||
enum RecastTypes
|
||||
{
|
||||
RecastTimer0 = 0,
|
||||
RecastTimer1,
|
||||
WeaponHealClickTimer, // 2
|
||||
MuramiteBaneNukeClickTimer, // 3
|
||||
RecastTimer4,
|
||||
DispellClickTimer, // 5 (also click heal orbs?)
|
||||
EpicTimer, // 6
|
||||
OoWBPClickTimer, // 7
|
||||
VishQuestClassItemTimer, // 8
|
||||
HealPotionTimer, // 9
|
||||
RecastTimer10,
|
||||
RecastTimer11,
|
||||
RecastTimer12,
|
||||
RecastTimer13,
|
||||
RecastTimer14,
|
||||
RecastTimer15,
|
||||
RecastTimer16,
|
||||
RecastTimer17,
|
||||
RecastTimer18,
|
||||
ModRodTimer // 19
|
||||
};
|
||||
|
||||
|
||||
enum GroupUpdateAction
|
||||
{
|
||||
GUA_Joined = 0,
|
||||
@ -593,7 +593,7 @@ enum InventorySlot
|
||||
////////////////////////
|
||||
// Equip slots
|
||||
////////////////////////
|
||||
|
||||
|
||||
SLOT_CHARM = 0,
|
||||
SLOT_EAR01 = 1,
|
||||
SLOT_HEAD = 2,
|
||||
@ -616,38 +616,38 @@ enum InventorySlot
|
||||
SLOT_FEET = 19,
|
||||
SLOT_WAIST = 20,
|
||||
SLOT_AMMO = 21,
|
||||
|
||||
|
||||
////////////////////////
|
||||
// All other slots
|
||||
////////////////////////
|
||||
SLOT_PERSONAL_BEGIN = 22,
|
||||
SLOT_PERSONAL_END = 29,
|
||||
|
||||
|
||||
SLOT_CURSOR = 30,
|
||||
|
||||
|
||||
SLOT_CURSOR_END = (int16)0xFFFE, // Last item on cursor queue
|
||||
// Cursor bag slots are 331->340 (10 slots)
|
||||
|
||||
|
||||
// Personal Inventory Slots
|
||||
// Slots 1 through 8 are slots 22->29
|
||||
// Inventory bag slots are 251->330 (10 slots per bag)
|
||||
|
||||
|
||||
// Tribute slots are 400-404? (upper bound unknown)
|
||||
// storing these in worn item's map
|
||||
|
||||
|
||||
// Bank slots
|
||||
// Bank slots 1 through 16 are slots 2000->2015
|
||||
// Bank bag slots are 2031->2190
|
||||
|
||||
|
||||
// Shared bank slots
|
||||
// Shared bank slots 1 through 2 are slots 2500->2501
|
||||
// Shared bank bag slots are 2531->2550
|
||||
|
||||
|
||||
// Trade session slots
|
||||
// Trade slots 1 through 8 are slots 3000->3007
|
||||
// Trade bag slots are technically 0->79 when passed to client,
|
||||
// but in our code, we treat them as slots 3100->3179
|
||||
|
||||
|
||||
// Slot used in OP_TradeSkillCombine for world tradeskill containers
|
||||
SLOT_TRADESKILL = 1000,
|
||||
SLOT_AUGMENT = 1001,
|
||||
|
||||
@ -547,7 +547,7 @@ struct BuffRemoveRequest_Struct
|
||||
struct PetBuff_Struct {
|
||||
/*000*/ uint32 petid;
|
||||
/*004*/ uint32 spellid[BUFF_COUNT];
|
||||
/*104*/ uint32 unknown700;
|
||||
/*104*/ uint32 unknown700;
|
||||
/*108*/ uint32 unknown701;
|
||||
/*112*/ uint32 unknown702;
|
||||
/*116*/ uint32 unknown703;
|
||||
@ -867,7 +867,7 @@ struct PlayerProfile_Struct
|
||||
/*0116*/ uint32 level; // Level of player (might be one byte)
|
||||
/*0120*/ BindStruct binds[5]; // Bind points (primary is first, home city is fifth)
|
||||
/*0220*/ uint32 deity; // deity
|
||||
/*0224*/ uint32 guild_id;
|
||||
/*0224*/ uint32 guild_id;
|
||||
/*0228*/ uint32 birthday; // characters bday
|
||||
/*0232*/ uint32 lastlogin; // last login or zone time
|
||||
/*0236*/ uint32 timePlayedMin; // in minutes
|
||||
@ -1906,7 +1906,7 @@ struct AdventureFinish_Struct{
|
||||
};
|
||||
|
||||
struct Weblink_Struct{
|
||||
/*000*/ char weblink[1];
|
||||
/*000*/ char weblink[1];
|
||||
/*004*/
|
||||
};
|
||||
|
||||
@ -2040,22 +2040,22 @@ struct Illusion_Struct_Old {
|
||||
struct QuestReward_Struct
|
||||
{
|
||||
/*000*/ uint32 from_mob; // ID of mob awarding the client
|
||||
/*004*/ uint32 unknown004;
|
||||
/*008*/ uint32 unknown008;
|
||||
/*012*/ uint32 unknown012;
|
||||
/*016*/ uint32 unknown016;
|
||||
/*020*/ uint32 unknown020;
|
||||
/*004*/ uint32 unknown004;
|
||||
/*008*/ uint32 unknown008;
|
||||
/*012*/ uint32 unknown012;
|
||||
/*016*/ uint32 unknown016;
|
||||
/*020*/ uint32 unknown020;
|
||||
/*024*/ uint32 silver; // Gives silver to the client
|
||||
/*028*/ uint32 gold; // Gives gold to the client
|
||||
/*032*/ uint32 platinum; // Gives platinum to the client
|
||||
/*036*/ uint32 unknown036;
|
||||
/*040*/ uint32 unknown040;
|
||||
/*044*/ uint32 unknown044;
|
||||
/*048*/ uint32 unknown048;
|
||||
/*052*/ uint32 unknown052;
|
||||
/*056*/ uint32 unknown056;
|
||||
/*060*/ uint32 unknown060;
|
||||
/*064*/ uint32 unknown064;
|
||||
/*036*/ uint32 unknown036;
|
||||
/*040*/ uint32 unknown040;
|
||||
/*044*/ uint32 unknown044;
|
||||
/*048*/ uint32 unknown048;
|
||||
/*052*/ uint32 unknown052;
|
||||
/*056*/ uint32 unknown056;
|
||||
/*060*/ uint32 unknown060;
|
||||
/*064*/ uint32 unknown064;
|
||||
/*068*/
|
||||
};
|
||||
|
||||
@ -2760,7 +2760,7 @@ struct BarterSearchRequest_Struct {
|
||||
|
||||
struct BuyerItemSearchLinkRequest_Struct {
|
||||
/*000*/ uint32 Action; // 0x00000015
|
||||
/*004*/ uint32 ItemID;
|
||||
/*004*/ uint32 ItemID;
|
||||
/*008*/ uint32 Unknown008;
|
||||
/*012*/ uint32 Unknown012;
|
||||
};
|
||||
@ -3435,7 +3435,7 @@ struct MerchantList{
|
||||
uint32 item;
|
||||
int16 faction_required;
|
||||
int8 level_required;
|
||||
uint16 alt_currency_cost;
|
||||
uint16 alt_currency_cost;
|
||||
};
|
||||
struct TempMerchantList{
|
||||
uint32 npcid;
|
||||
@ -4195,7 +4195,7 @@ struct RespawnWindow_Struct {
|
||||
/**
|
||||
* Shroud spawn. For others shrouding, this has their spawnId and
|
||||
* spawnStruct.
|
||||
*
|
||||
*
|
||||
* Length: 586
|
||||
* OpCode: OP_Shroud
|
||||
*/
|
||||
@ -4650,7 +4650,7 @@ struct GroupMakeLeader_Struct
|
||||
//any items come after in much the same way adventure merchant items do except there is no theme included
|
||||
#define ALT_CURRENCY_OP_POPULATE 8
|
||||
#define ALT_CURRENCY_OP_UPDATE 7
|
||||
|
||||
|
||||
//Server -> Client
|
||||
//Populates the initial Alternate Currency Window
|
||||
struct AltCurrencyPopulateEntry_Struct
|
||||
@ -4681,7 +4681,7 @@ struct AltCurrencyUpdate_Struct {
|
||||
/*084*/ uint32 unknown084; //seen 0
|
||||
};
|
||||
|
||||
//Client -> Server
|
||||
//Client -> Server
|
||||
//When an item is selected while the alt currency merchant window is open
|
||||
struct AltCurrencySelectItem_Struct {
|
||||
/*000*/ uint32 merchant_entity_id;
|
||||
@ -4711,7 +4711,7 @@ struct AltCurrencySelectItem_Struct {
|
||||
//eg: "I will give you no doubloons for a cloth cap."
|
||||
//Probably also sends amounts somewhere
|
||||
struct AltCurrencySelectItemReply_Struct {
|
||||
/*000*/ uint32 unknown000;
|
||||
/*000*/ uint32 unknown000;
|
||||
/*004*/ uint8 unknown004; //0xff
|
||||
/*005*/ uint8 unknown005; //0xff
|
||||
/*006*/ uint8 unknown006; //0xff
|
||||
@ -4839,7 +4839,7 @@ struct Membership_Entry_Struct
|
||||
{
|
||||
/*000*/ uint32 purchase_id; // Seen 1, then increments 90287 to 90300
|
||||
/*004*/ uint32 bitwise_entry; // Seen 16 to 65536 - Skips 4096
|
||||
/*008*/
|
||||
/*008*/
|
||||
};
|
||||
|
||||
struct Membership_Setting_Struct
|
||||
@ -4847,7 +4847,7 @@ struct Membership_Setting_Struct
|
||||
/*000*/ uint32 setting_index; // 0, 1, or 2
|
||||
/*004*/ uint32 setting_id; // 0 to 21
|
||||
/*008*/ int32 setting_value; // All can be 0, 1, or -1
|
||||
/*012*/
|
||||
/*012*/
|
||||
};
|
||||
|
||||
struct Membership_Details_Struct
|
||||
@ -4891,7 +4891,7 @@ struct MercenaryList_Struct {
|
||||
/*0045*/ uint32 MercUnk02; // Unknown (normally see 1, but sometimes 2 or 0)
|
||||
/*0049*/ uint32 StanceCount; // Iterations of MercenaryStance_Struct - Normally 2 to 4 seen
|
||||
/*0053*/ int32 MercUnk03; // Unknown (always 0 at merchant) - Seen on active merc: 93 a4 03 77, b8 ed 2f 26, 88 d5 8b c3, and 93 a4 ad 77
|
||||
/*0057*/ uint8 MercUnk04; // Seen 1
|
||||
/*0057*/ uint8 MercUnk04; // Seen 1
|
||||
/*0058*/ char MercName[1]; // Null Terminated Mercenary Name (00 at merchants)
|
||||
};
|
||||
|
||||
@ -4913,7 +4913,7 @@ struct MercenaryListEntry_Struct {
|
||||
/*0045*/ uint32 MercUnk02; // Unknown (normally see 1, but sometimes 2 or 0)
|
||||
/*0049*/ uint32 StanceCount; // Iterations of MercenaryStance_Struct - Normally 2 to 4 seen
|
||||
/*0053*/ int32 MercUnk03; // Unknown (always 0 at merchant) - Seen on active merc: 93 a4 03 77, b8 ed 2f 26, 88 d5 8b c3, and 93 a4 ad 77
|
||||
/*0057*/ uint8 MercUnk04; // Seen 1
|
||||
/*0057*/ uint8 MercUnk04; // Seen 1
|
||||
/*0058*/ char MercName[1]; // Null Terminated Mercenary Name (00 at merchants)
|
||||
/*0000*/ MercenaryStance_Struct Stances[MAX_MERC_STANCES]; // Count Varies, but hard set to 5 max for now - From dbstr_us.txt - 1^24^Passive^0, 2^24^Balanced^0, etc (1 to 9 as of April 2012)
|
||||
};
|
||||
@ -4953,7 +4953,7 @@ struct MercenaryData_Struct {
|
||||
/*0045*/ uint32 MercUnk02; // Unknown (normally see 1, but sometimes 2 or 0)
|
||||
/*0049*/ uint32 StanceCount; // Iterations of MercenaryStance_Struct - Normally 2 to 4 seen
|
||||
/*0053*/ int32 MercUnk03; // Unknown (always 0 at merchant) - Seen on active merc: 93 a4 03 77, b8 ed 2f 26, 88 d5 8b c3, and 93 a4 ad 77
|
||||
/*0057*/ uint8 MercUnk04; // Seen 1
|
||||
/*0057*/ uint8 MercUnk04; // Seen 1
|
||||
/*0058*/ char MercName[64]; // Null Terminated Mercenary Name (00 at merchants)
|
||||
/*0000*/ MercenaryStance_Struct Stances[MAX_MERC_STANCES]; // Count Varies, but hard set to 2 for now - From dbstr_us.txt - 1^24^Passive^0, 2^24^Balanced^0, etc (1 to 9 as of April 2012)
|
||||
/*0000*/ uint32 MercUnk05; // Seen 1 - Extra Merc Data field that differs from MercenaryListEntry_Struct
|
||||
@ -4963,7 +4963,7 @@ struct MercenaryData_Struct {
|
||||
// [OPCode: 0x6537] On Live as of April 2 2012 [Server->Client]
|
||||
// Should be named OP_MercenaryDataResponse, but the current opcode using that name should be renamed first
|
||||
// Size varies if mercenary is hired or if browsing Mercenary Merchant
|
||||
// This may also be the response for Client->Server 0x0327 (size 0) packet On Live as of April 2 2012
|
||||
// This may also be the response for Client->Server 0x0327 (size 0) packet On Live as of April 2 2012
|
||||
struct MercenaryDataUpdate_Struct {
|
||||
/*0000*/ int32 MercStatus; // Seen 0 with merc and -1 with no merc hired
|
||||
/*0004*/ uint32 MercCount; // Seen 1 with 1 merc hired and 0 with no merc hired
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -18,17 +18,17 @@
|
||||
|
||||
#include "eqemu_exception.h"
|
||||
|
||||
namespace EQEmu
|
||||
namespace EQEmu
|
||||
{
|
||||
Exception::Exception(const char* name, const std::string& description, const char* file, long line)
|
||||
: line_(line),
|
||||
Exception::Exception(const char* name, const std::string& description, const char* file, long line)
|
||||
: line_(line),
|
||||
file_(file),
|
||||
desc_(description),
|
||||
name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
Exception::Exception(const Exception& e)
|
||||
|
||||
Exception::Exception(const Exception& e)
|
||||
: line_(e.line_),
|
||||
file_(e.file_),
|
||||
desc_(e.desc_),
|
||||
@ -37,7 +37,7 @@ namespace EQEmu
|
||||
}
|
||||
|
||||
#ifdef EQEMU_RVALUE_MOVE
|
||||
Exception::Exception(const Exception&& e)
|
||||
Exception::Exception(const Exception&& e)
|
||||
: line_(e.line_),
|
||||
file_(e.file_),
|
||||
desc_(e.desc_),
|
||||
@ -45,7 +45,7 @@ namespace EQEmu
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void Exception::operator=(const Exception& e) {
|
||||
line_ = e.line_;
|
||||
file_ = e.file_;
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -30,7 +30,7 @@ namespace EQEmu
|
||||
*/
|
||||
class Exception : public std::exception {
|
||||
public:
|
||||
|
||||
|
||||
//! Detailed Constructor
|
||||
/*!
|
||||
\param name The name given for this exception.
|
||||
@ -39,55 +39,55 @@ namespace EQEmu
|
||||
\param line The line number for this exception.
|
||||
*/
|
||||
Exception(const char* name, const std::string& description, const char* file, long line);
|
||||
|
||||
|
||||
//! Copy Constructor
|
||||
Exception(const Exception& e);
|
||||
|
||||
|
||||
//! Move Constructor
|
||||
#ifdef EQEMU_RVALUE_MOVE
|
||||
Exception(const Exception&& e);
|
||||
#endif
|
||||
|
||||
|
||||
//! Destructor
|
||||
~Exception() throw() { }
|
||||
|
||||
|
||||
//! Assignment Operator
|
||||
void operator=(const Exception& e);
|
||||
|
||||
//! Get Name
|
||||
/*!
|
||||
Gets the name of the exception as it was when it was created.
|
||||
Gets the name of the exception as it was when it was created.
|
||||
These are typically descriptive categories that the exception would fall under.
|
||||
*/
|
||||
virtual const std::string& name() const { return name_; }
|
||||
|
||||
|
||||
//! Get Basic Description
|
||||
/*!
|
||||
Gets the description of the exception as it was when it was created.
|
||||
Gets the description of the exception as it was when it was created.
|
||||
This tends to explain the circumstances of why the exception was thrown.
|
||||
*/
|
||||
virtual const std::string& description() const { return desc_; }
|
||||
|
||||
|
||||
//! Get Full Description
|
||||
/*!
|
||||
Gets a full description for this exception.
|
||||
Gets a full description for this exception.
|
||||
This is a string containing the name, description, file and line number in a custom format.
|
||||
This string is created the first time the full_description is accessed.
|
||||
*/
|
||||
virtual const std::string& full_description() const;
|
||||
|
||||
|
||||
//! Get File Name
|
||||
/*!
|
||||
Gets the name of the file this exception was thrown from.
|
||||
*/
|
||||
virtual const std::string& file() const { return file_; }
|
||||
|
||||
|
||||
//! Get File Line
|
||||
/*!
|
||||
Gets the file line this exception was thrown from.
|
||||
*/
|
||||
virtual const long& line() const { return line_; }
|
||||
|
||||
|
||||
//! std::exception overload
|
||||
/*!
|
||||
Overload from std::exception
|
||||
|
||||
@ -145,7 +145,7 @@ bool EQTime::saveFile(const char *filename)
|
||||
return false;
|
||||
}
|
||||
//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 << (long)eqTime.start_eqtime.day << endl;
|
||||
of << (long)eqTime.start_eqtime.hour << endl;
|
||||
@ -182,7 +182,7 @@ bool EQTime::loadFile(const char *filename)
|
||||
//in >> eqTime.start_eqtime.hour;
|
||||
in >> in_data;
|
||||
eqTime.start_eqtime.hour = in_data;
|
||||
in.ignore(80, '\n');
|
||||
in.ignore(80, '\n');
|
||||
//in >> eqTime.start_eqtime.minute;
|
||||
in >> in_data;
|
||||
in.ignore(80, '\n');
|
||||
@ -195,7 +195,7 @@ bool EQTime::loadFile(const char *filename)
|
||||
in.ignore(80, '\n');
|
||||
in >> eqTime.start_realtime;
|
||||
//Enable for debugging...
|
||||
//cout << "LOAD: 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 << "LOAD: 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;
|
||||
in.close();
|
||||
return true;
|
||||
}
|
||||
@ -228,7 +228,7 @@ bool EQTime::IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test) {
|
||||
|
||||
void EQTime::AddMinutes(uint32 minutes, TimeOfDay_Struct *to) {
|
||||
uint32 cur;
|
||||
|
||||
|
||||
//minutes start at 0, everything else starts at 1
|
||||
cur = to->minute;
|
||||
cur += minutes;
|
||||
|
||||
@ -34,13 +34,13 @@ public:
|
||||
//Set functions
|
||||
int setEQTimeOfDay(TimeOfDay_Struct start_eq, time_t start_real);
|
||||
void setEQTimeZone(int32 in_timezone) { timezone=in_timezone; }
|
||||
|
||||
|
||||
//Time math/logic functions
|
||||
static bool IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test); //is test before base
|
||||
static void AddMinutes(uint32 minutes, TimeOfDay_Struct *to);
|
||||
|
||||
|
||||
static void ToString(TimeOfDay_Struct *t, string &str);
|
||||
|
||||
|
||||
//Database functions
|
||||
//bool loadDB(Database q);
|
||||
//bool setDB(Database q);
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
|
||||
@ -35,10 +35,10 @@ bool SetExtendedProfile(ExtendedProfile_Struct *to, char *old, unsigned int len)
|
||||
memcpy(to, old, sizeof(ExtendedProfile_Struct));
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
//convert an old block of memory of size old to the new struct
|
||||
//and store the new results in 'to'
|
||||
|
||||
|
||||
//generic converter that will work as long as the structre
|
||||
//only grows, and nothign gets re-arranged
|
||||
if(len < sizeof(ExtendedProfile_Struct)) {
|
||||
@ -46,7 +46,7 @@ bool SetExtendedProfile(ExtendedProfile_Struct *to, char *old, unsigned int len)
|
||||
memcpy(to, old, len);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef EXTENDED_PROFILE_H
|
||||
#define EXTENDED_PROFILE_H
|
||||
#define EXTENDED_PROFILE_H
|
||||
|
||||
#include "eq_packet_structs.h"
|
||||
#include "Item.h"
|
||||
@ -27,11 +27,11 @@
|
||||
/*
|
||||
This is a place to store data that dosent have a home in the
|
||||
official player profile.
|
||||
|
||||
|
||||
Try not to expand or re-arrange thing in this struct
|
||||
to make conversion between sizes easier.
|
||||
if something gets removed from here, just turn it into an unused
|
||||
item, so conversion is not needed. Then reuse old unused values if
|
||||
item, so conversion is not needed. Then reuse old unused values if
|
||||
possible later instead of adding more, so long as old values left
|
||||
over would not be extrememly unpleasent side effects.
|
||||
*/
|
||||
@ -43,7 +43,7 @@ struct ExtendedProfile_Struct {
|
||||
SpellBuff_Struct pet_buffs[BUFF_COUNT];
|
||||
uint32 pet_items[MAX_MATERIALS];
|
||||
char merc_name[64];
|
||||
|
||||
|
||||
uint32 aa_effects;
|
||||
uint32 perAA; //% of exp going to AAs
|
||||
uint32 expended_aa; // Total of expended AA
|
||||
|
||||
@ -28,9 +28,9 @@ enum FACTION_VALUE {
|
||||
FACTION_WARMLY = 2,
|
||||
FACTION_KINDLY = 3,
|
||||
FACTION_AMIABLE = 4,
|
||||
|
||||
|
||||
FACTION_INDIFFERENT = 5,
|
||||
|
||||
|
||||
FACTION_APPREHENSIVE = 6,
|
||||
FACTION_DUBIOUS = 7,
|
||||
FACTION_THREATENLY = 8,
|
||||
@ -63,13 +63,13 @@ struct Faction {
|
||||
};
|
||||
|
||||
typedef std::map<uint32, int16> faction_map;
|
||||
struct NPCFaction
|
||||
{
|
||||
struct NPCFaction
|
||||
{
|
||||
uint32 factionID;
|
||||
int32 value_mod;
|
||||
int8 npc_value;
|
||||
uint8 temp;
|
||||
};
|
||||
uint8 temp;
|
||||
};
|
||||
|
||||
const char *FactionValueToString(FACTION_VALUE fv);
|
||||
FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value);
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
This file defines many optional features for the emu
|
||||
as well as various parameters used by the emu.
|
||||
|
||||
|
||||
If ambitious, most of these could prolly be turned into
|
||||
database variables, but the really frequently run pieces
|
||||
of code, should not be done that way for speed reasons IMO
|
||||
@ -185,7 +185,7 @@ enum { //timer settings, all in milliseconds
|
||||
};
|
||||
|
||||
enum { //some random constants
|
||||
//each of these attack modifiers are added to the NPC's level to determine their
|
||||
//each of these attack modifiers are added to the NPC's level to determine their
|
||||
//probability of executing such an attack (which may or may not hit)
|
||||
NPCDualAttackModifier = 20,
|
||||
NPCTripleAttackModifier = 0,
|
||||
@ -200,7 +200,7 @@ enum { //some random constants
|
||||
//an npc can be and still let the theif PP them
|
||||
#define THIEF_PICKPOCKET_OVER 5
|
||||
|
||||
//this is the % chance that an NPC will dual wield a 2nd weapon
|
||||
//this is the % chance that an NPC will dual wield a 2nd weapon
|
||||
//in its loot table, if it is able to.
|
||||
//Aug 2007: was 5% chance.. changed to 100% by default since that seems more normal
|
||||
//Kept it intact codewise incase someone wants to or is already using it.
|
||||
@ -221,7 +221,7 @@ enum { //some random constants
|
||||
//minimum level to do alchemy
|
||||
#define MIN_LEVEL_ALCHEMY 25
|
||||
|
||||
//chance ratio that a
|
||||
//chance ratio that a
|
||||
#define THREATENLY_ARRGO_CHANCE 32 // 32/128 (25%) chance that a mob will arrgo on con Threatenly
|
||||
|
||||
// max factions per npc faction list
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
namespace EQEmu {
|
||||
|
||||
/*! Simple HashSet designed to be used in fixed memory that may be difficult to use an
|
||||
/*! Simple HashSet designed to be used in fixed memory that may be difficult to use an
|
||||
allocator for (shared memory), we assume all keys are unsigned int
|
||||
*/
|
||||
template<class T>
|
||||
@ -41,7 +41,7 @@ namespace EQEmu {
|
||||
Constructor which initializes the hash set
|
||||
\param data Raw data
|
||||
\param size Raw data size
|
||||
\param element_count Max number of possible unique elements that can be inserted.
|
||||
\param element_count Max number of possible unique elements that can be inserted.
|
||||
\param max_element_id Number of offsets to store: eg highest "key" that will be used.
|
||||
*/
|
||||
FixedMemoryHashSet(byte *data, size_type size, key_type element_count, key_type max_element_id) {
|
||||
@ -69,7 +69,7 @@ namespace EQEmu {
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructor which does not initialize the hash set. Builds the hash set from what data is
|
||||
Constructor which does not initialize the hash set. Builds the hash set from what data is
|
||||
stored in the data pointer passed.
|
||||
\param data Raw data
|
||||
\param size Raw data size
|
||||
@ -136,7 +136,7 @@ namespace EQEmu {
|
||||
elements_ = other.elements_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//! Returns whether the set is empty (has 0 elements) or not
|
||||
bool empty() const {
|
||||
return current_elements_ == 0;
|
||||
@ -156,7 +156,7 @@ namespace EQEmu {
|
||||
key_type max_key() const {
|
||||
return offset_count_ > 0 ? (offset_count_ - 1) : 0;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Retrieve value operator
|
||||
\param i Index to retrieve the value from
|
||||
@ -229,7 +229,7 @@ namespace EQEmu {
|
||||
}
|
||||
}
|
||||
|
||||
//! Calculates how much memory we should allocate based on element size and count
|
||||
//! Calculates how much memory we should allocate based on element size and count
|
||||
static size_type estimated_size(key_type element_count, key_type max_elements) {
|
||||
size_type total_size = 3 * sizeof(key_type);
|
||||
total_size += sizeof(key_type) * (max_elements + 1);
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
namespace EQEmu {
|
||||
|
||||
/*! Simple HashSet designed to be used in fixed memory that may be difficult to use an
|
||||
/*! Simple HashSet designed to be used in fixed memory that may be difficult to use an
|
||||
allocator for (shared memory), we assume all keys are unsigned int, values are a pointer and size
|
||||
*/
|
||||
template<class T>
|
||||
@ -49,17 +49,17 @@ namespace EQEmu {
|
||||
remaining_size_ = size_ - (sizeof(key_type) * 3) - (sizeof(key_type) * (max_element_id + 1));
|
||||
|
||||
byte *ptr = data;
|
||||
*reinterpret_cast<key_type*>(ptr) = max_element_id + 1;
|
||||
*reinterpret_cast<key_type*>(ptr) = max_element_id + 1;
|
||||
offset_count_ = max_element_id + 1;
|
||||
ptr += sizeof(key_type);
|
||||
|
||||
*reinterpret_cast<key_type*>(ptr) = remaining_size_;
|
||||
ptr += sizeof(key_type);
|
||||
|
||||
|
||||
*reinterpret_cast<key_type*>(ptr) = 0;
|
||||
current_offset_ = 0;
|
||||
ptr += sizeof(key_type);
|
||||
|
||||
|
||||
|
||||
offsets_ = reinterpret_cast<key_type*>(ptr);
|
||||
memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1));
|
||||
@ -69,7 +69,7 @@ namespace EQEmu {
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructor which does not initialize the hash set. Builds the hash set from what data is
|
||||
Constructor which does not initialize the hash set. Builds the hash set from what data is
|
||||
stored in the data pointer passed.
|
||||
\param data Raw data
|
||||
\param size Raw data size
|
||||
@ -87,7 +87,7 @@ namespace EQEmu {
|
||||
|
||||
current_offset_ = *reinterpret_cast<key_type*>(ptr);
|
||||
ptr += sizeof(key_type);
|
||||
|
||||
|
||||
offsets_ = reinterpret_cast<key_type*>(ptr);
|
||||
ptr += sizeof(key_type) * offset_count_;
|
||||
|
||||
@ -135,7 +135,7 @@ namespace EQEmu {
|
||||
elements_ = other.elements_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//! Returns the number of bytes in the set currently
|
||||
size_type size() const {
|
||||
return size_ - remaining_size_;
|
||||
@ -150,7 +150,7 @@ namespace EQEmu {
|
||||
key_type max_key() const {
|
||||
return offset_count_ > 0 ? (offset_count_ - 1) : 0;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Retrieve value operator
|
||||
\param i Index to retrieve the value from
|
||||
@ -208,7 +208,7 @@ namespace EQEmu {
|
||||
if(i >= offset_count_) {
|
||||
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range.");
|
||||
}
|
||||
|
||||
|
||||
if(size > remaining_size_) {
|
||||
EQ_EXCEPT("Fixed Memory Hash Set", "Not enough room in hash set to insert this value.");
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,7 @@ public:
|
||||
uint16 level;
|
||||
uint32 time_last_on;
|
||||
uint32 zone_id;
|
||||
|
||||
|
||||
//fields from `guild_members`
|
||||
uint32 guild_id;
|
||||
uint8 rank;
|
||||
@ -34,13 +34,13 @@ class BaseGuildManager {
|
||||
public:
|
||||
BaseGuildManager();
|
||||
virtual ~BaseGuildManager();
|
||||
|
||||
|
||||
//this must be called before doing anything else with this object
|
||||
void SetDatabase(Database *db) { m_db = db; }
|
||||
|
||||
|
||||
bool LoadGuilds();
|
||||
bool RefreshGuild(uint32 guild_id);
|
||||
|
||||
|
||||
//guild edit actions.
|
||||
uint32 CreateGuild(const char* name, uint32 leader_char_id);
|
||||
bool DeleteGuild(uint32 guild_id);
|
||||
@ -48,7 +48,7 @@ public:
|
||||
bool SetGuildMOTD(uint32 guild_id, const char* motd, const char *setter);
|
||||
bool SetGuildURL(uint32 GuildID, const char* URL);
|
||||
bool SetGuildChannel(uint32 GuildID, const char* Channel);
|
||||
|
||||
|
||||
//character edit actions
|
||||
bool SetGuildLeader(uint32 guild_id, uint32 leader_char_id);
|
||||
bool SetGuild(uint32 charid, uint32 guild_id, uint8 rank);
|
||||
@ -59,7 +59,7 @@ public:
|
||||
bool GetBankerFlag(uint32 CharID);
|
||||
bool SetTributeFlag(uint32 charid, bool enabled);
|
||||
bool SetPublicNote(uint32 charid, const char *note);
|
||||
|
||||
|
||||
//queries
|
||||
bool GetCharInfo(const char *char_name, CharGuildInfo &into);
|
||||
bool GetCharInfo(uint32 char_id, CharGuildInfo &into);
|
||||
@ -82,19 +82,19 @@ public:
|
||||
uint32 NumberInGuild(uint32 guild_id);
|
||||
// bool GetGuildRanks(uint32 guildeqid, GuildRanks_Struct* gr);
|
||||
// bool EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct* grl);
|
||||
|
||||
|
||||
uint8 *MakeGuildList(const char *head_name, uint32 &length) const; //make a guild list packet, returns ownership of the buffer.
|
||||
|
||||
|
||||
static const char *const GuildActionNames[_MaxGuildAction];
|
||||
uint32 DoesAccountContainAGuildLeader(uint32 AccountID);
|
||||
|
||||
|
||||
protected:
|
||||
//the methods which must be defined by base classes.
|
||||
virtual void SendGuildRefresh(uint32 guild_id, bool name, bool motd, bool rank, bool relation) = 0;
|
||||
virtual void SendCharRefresh(uint32 old_guild_id, uint32 guild_id, uint32 charid) = 0;
|
||||
virtual void SendRankUpdate(uint32 CharID) = 0;
|
||||
virtual void SendGuildDelete(uint32 guild_id) = 0;
|
||||
|
||||
|
||||
uint32 DBCreateGuild(const char* name, uint32 leader_char_id);
|
||||
bool DBDeleteGuild(uint32 guild_id);
|
||||
bool DBRenameGuild(uint32 guild_id, const char* name);
|
||||
@ -110,9 +110,9 @@ protected:
|
||||
bool DBSetPublicNote(uint32 charid, const char *note);
|
||||
bool _RunQuery(char *&query, int len, const char *errmsg);
|
||||
// void DBSetPublicNote(uint32 guild_id,char* charname, char* note);
|
||||
|
||||
|
||||
bool LocalDeleteGuild(uint32 guild_id);
|
||||
|
||||
|
||||
class RankInfo {
|
||||
public:
|
||||
RankInfo();
|
||||
@ -133,12 +133,12 @@ protected:
|
||||
//tribute is not in here on purpose, since it is only valid in world!
|
||||
RankInfo ranks[GUILD_MAX_RANK+1];
|
||||
};
|
||||
|
||||
|
||||
std::map<uint32, GuildInfo *> m_guilds; //we own the pointers in this map
|
||||
void ClearGuilds(); //clears internal structure
|
||||
|
||||
|
||||
Database *m_db; //we do not own this
|
||||
|
||||
|
||||
bool _StoreGuildDB(uint32 guild_id);
|
||||
GuildInfo *_CreateGuild(uint32 guild_id, const char *guild_name, uint32 account_id, uint8 minstatus, const char *guild_motd, const char *motd_setter, const char *Channel, const char *URL);
|
||||
uint32 _GetFreeGuildID();
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -63,7 +63,7 @@ uint32 Database::NumberInGuild(uint32 guild_id) {
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "Select count(id) from character_ where guild=%i", guild_id), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) == 1) {
|
||||
@ -85,7 +85,7 @@ bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET guild=%i, guildrank=%i WHERE name='%s'", guild_id, guildrank, name), errbuf, 0, &affected_rows)) {
|
||||
safe_delete_array(query);
|
||||
if (affected_rows == 1)
|
||||
@ -105,7 +105,7 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET guild=%i, guildrank=%i WHERE id=%i", guild_id, guildrank, charid), errbuf, 0, &affected_rows)) {
|
||||
safe_delete_array(query);
|
||||
if (affected_rows == 1)
|
||||
@ -119,7 +119,7 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ bool Database::DeleteGuild(uint32 guild_id)
|
||||
char *query = 0;
|
||||
char *query2 = 0;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "DELETE FROM guilds WHERE id=%i;", guild_id), errbuf, 0, &affected_rows)) {
|
||||
safe_delete_array(query);
|
||||
if (affected_rows == 1) {
|
||||
@ -146,7 +146,7 @@ bool Database::DeleteGuild(uint32 guild_id)
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
|
||||
uint32 affected_rows = 0;
|
||||
char buf[65];
|
||||
DoEscapeString(buf, name, strlen(name)) ;
|
||||
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "Update guilds set name='%s' WHERE id=%i;", buf, guild_id), errbuf, 0, &affected_rows)) {
|
||||
safe_delete_array(query);
|
||||
if (affected_rows == 1)
|
||||
@ -169,7 +169,7 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -192,12 +192,12 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
|
||||
buf2[GUILD_DEMOTE] = grl->demote + '0';
|
||||
buf2[GUILD_MOTD] = grl->motd + '0';
|
||||
buf2[GUILD_WARPEACE] = grl->warpeace + '0';
|
||||
|
||||
|
||||
if (ranknum == 0)
|
||||
chars = MakeAnyLenString(&query, "Update guilds set rank%ititle='%s' WHERE id=%i;", ranknum, buf, guild_id);
|
||||
else
|
||||
chars = MakeAnyLenString(&query, "Update guilds set rank%ititle='%s', rank%i='%s' WHERE id=%i;", ranknum, buf, ranknum, buf2, guild_id);
|
||||
|
||||
|
||||
if (RunQuery(query, chars, errbuf, 0, &affected_rows)) {
|
||||
safe_delete_array(query);
|
||||
if (affected_rows == 1)
|
||||
@ -210,7 +210,7 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -219,8 +219,8 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
MYSQL_ROW row;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "select name from guilds where id='%i'", guild_id), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
row = mysql_fetch_row(result);
|
||||
@ -234,7 +234,7 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ uint32 Database::GetGuildIDbyLeader(uint32 leader)
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM guilds WHERE leader=%i", leader), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) == 1)
|
||||
@ -260,7 +260,7 @@ uint32 Database::GetGuildIDbyLeader(uint32 leader)
|
||||
LogFile->write(EQEMuLog::Error, "Error in Getguild_idbyLeader query '%s': %s", query, errbuf);
|
||||
safe_delete_array(query);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "UPDATE guilds SET leader=%i WHERE id=%i", leader, guild_id), errbuf, 0, &affected_rows)) {
|
||||
safe_delete_array(query);
|
||||
if (affected_rows == 1)
|
||||
@ -282,7 +282,7 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -291,11 +291,11 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
|
||||
char *query = 0;
|
||||
char* motdbuf = 0;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
|
||||
motdbuf = new char[(strlen(motd)*2)+3];
|
||||
|
||||
DoEscapeString(motdbuf, motd, strlen(motd)) ;
|
||||
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "Update guilds set motd='%s' WHERE id=%i;", motdbuf, guild_id), errbuf, 0, &affected_rows)) {
|
||||
safe_delete_array(query);
|
||||
delete motdbuf;
|
||||
@ -311,7 +311,7 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
|
||||
delete motdbuf;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -22,10 +22,10 @@
|
||||
#include <string>
|
||||
|
||||
namespace EQEmu {
|
||||
|
||||
|
||||
//! Interprocess Named Binary Semaphore (Mutex)
|
||||
/*!
|
||||
Important to note: while this can be used to synchronize processes, it is not in itself re-entrant or thread-safe
|
||||
Important to note: while this can be used to synchronize processes, it is not in itself re-entrant or thread-safe
|
||||
and thus should be used from one thread and non-recursively. It was intended to be a simple synchronization method
|
||||
for our MemoryMappedFile loading.
|
||||
*/
|
||||
@ -38,16 +38,16 @@ namespace EQEmu {
|
||||
\param name The name of this mutex.
|
||||
*/
|
||||
IPCMutex(std::string name);
|
||||
|
||||
|
||||
//! Destructor
|
||||
~IPCMutex();
|
||||
|
||||
|
||||
//! Lock the mutex
|
||||
/*!
|
||||
Same basic function as P(): for(;;) { if(S > 0) { S -= 1; break; } }
|
||||
*/
|
||||
bool Lock();
|
||||
|
||||
|
||||
//! Unlocks the mutex
|
||||
/*!
|
||||
Same basic function as V(): S += 1;
|
||||
@ -56,7 +56,7 @@ namespace EQEmu {
|
||||
private:
|
||||
IPCMutex(const IPCMutex&);
|
||||
const IPCMutex& operator=(const IPCMutex&);
|
||||
|
||||
|
||||
bool locked_; //!< Whether this mutex is locked or not
|
||||
Implementation *imp_;
|
||||
};
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemulator.org)
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemulator.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef LANGUAGES_H
|
||||
#define LANGUAGES_H
|
||||
#include "../common/types.h"
|
||||
|
||||
@ -24,7 +24,7 @@ enum direction{FORWARD,BACKWARD};
|
||||
|
||||
template<class TYPE> class LinkedListIterator;
|
||||
|
||||
template<class TYPE>
|
||||
template<class TYPE>
|
||||
class ListElement
|
||||
{
|
||||
private:
|
||||
@ -56,17 +56,17 @@ public:
|
||||
inline const TYPE& GetData () const { return data ; }
|
||||
|
||||
void SetData ( const TYPE& d ) { data = d ; } // Quagmire - this may look like a mem leak, but dont change it, this behavior is expected where it's called
|
||||
void SetLastNext ( ListElement<TYPE>* p )
|
||||
void SetLastNext ( ListElement<TYPE>* p )
|
||||
{
|
||||
GetLast()->SetNext(p);
|
||||
}
|
||||
void SetNext (ListElement<TYPE>* n) { next = n ; }
|
||||
void SetPrev (ListElement<TYPE>* p) { prev = p ; }
|
||||
}
|
||||
void SetNext (ListElement<TYPE>* n) { next = n ; }
|
||||
void SetPrev (ListElement<TYPE>* p) { prev = p ; }
|
||||
|
||||
void ReplaceData(const TYPE&);
|
||||
};
|
||||
|
||||
template<class TYPE>
|
||||
template<class TYPE>
|
||||
class LinkedList
|
||||
{
|
||||
private:
|
||||
@ -94,20 +94,20 @@ public:
|
||||
friend class LinkedListIterator<TYPE>;
|
||||
};
|
||||
|
||||
template<class TYPE>
|
||||
template<class TYPE>
|
||||
class LinkedListIterator
|
||||
{
|
||||
private:
|
||||
LinkedList<TYPE>& list;
|
||||
ListElement<TYPE>* current_element;
|
||||
direction dir;
|
||||
|
||||
|
||||
public:
|
||||
LinkedListIterator(LinkedList<TYPE>& l,direction d = FORWARD) : list(l), dir(d) {};
|
||||
|
||||
void Advance();
|
||||
const TYPE& GetData();
|
||||
bool IsFirst()
|
||||
bool IsFirst()
|
||||
{
|
||||
if (current_element->GetPrev() == 0)
|
||||
return true;
|
||||
@ -283,7 +283,7 @@ void LinkedListIterator<TYPE>::Reset()
|
||||
current_element=0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (dir == FORWARD)
|
||||
{
|
||||
current_element = list.first;
|
||||
@ -389,7 +389,7 @@ template<class TYPE>
|
||||
void LinkedList<TYPE>::Append(const TYPE& data)
|
||||
{
|
||||
ListElement<TYPE>* new_element = new ListElement<TYPE>(data);
|
||||
|
||||
|
||||
if (first == 0)
|
||||
{
|
||||
first = new_element;
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -33,7 +33,7 @@ const char *log_category_names[NUMBER_OF_LOG_CATEGORIES] = {
|
||||
|
||||
//this array is private to this file, only a const version of it is exposed
|
||||
#define LOG_TYPE(category, type, enabled) { enabled, LOG_ ##category, #category "__" #type },
|
||||
static LogTypeStatus real_log_type_info[NUMBER_OF_LOG_TYPES+1] =
|
||||
static LogTypeStatus real_log_type_info[NUMBER_OF_LOG_TYPES+1] =
|
||||
{
|
||||
#include "logtypes.h"
|
||||
{ false, NUMBER_OF_LOG_CATEGORIES, "BAD TYPE" } /* dummy trailing record */
|
||||
@ -97,14 +97,14 @@ bool load_log_settings(const char *filename) {
|
||||
#ifdef _WINDOWS
|
||||
if (sscanf(linebuf, "%[^=]=%[^\n]\n", type_name, value) != 2)
|
||||
continue;
|
||||
#else
|
||||
#else
|
||||
if (sscanf(linebuf, "%[^=]=%[^\r\n]\n", type_name, value) != 2)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
|
||||
if(type_name[0] == '\0' || type_name[0] == '#')
|
||||
continue;
|
||||
|
||||
|
||||
//first make sure we understand the value
|
||||
bool enabled;
|
||||
if(!strcasecmp(value, "on") || !strcasecmp(value, "true") || !strcasecmp(value, "yes") || !strcasecmp(value, "enabled") || !strcmp(value, "1"))
|
||||
@ -115,7 +115,7 @@ bool load_log_settings(const char *filename) {
|
||||
printf("Unable to parse value '%s' from %s. Skipping line.", value, filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int r;
|
||||
//first see if it is a category name
|
||||
for(r = 0; r < NUMBER_OF_LOG_CATEGORIES; r++) {
|
||||
@ -135,7 +135,7 @@ bool load_log_settings(const char *filename) {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
for(r = 0; r < NUMBER_OF_LOG_TYPES; r++) {
|
||||
if(!strcasecmp(log_type_info[r].name, type_name))
|
||||
break;
|
||||
@ -144,7 +144,7 @@ bool load_log_settings(const char *filename) {
|
||||
printf("Unable to locate log type %s from file %s. Skipping line.", type_name, filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//got it all figured out, do something now...
|
||||
if(enabled)
|
||||
log_enable(LogType(r));
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -19,9 +19,9 @@
|
||||
#define LOGSYS_H_
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
*
|
||||
* These are the main functions provided by logsys:
|
||||
* - _log(TYPE, fmt, ...) - Log a message in any context
|
||||
* - mlog(TYPE, fmt, ...) - Zone only. Log a message from a Mob:: context, prefixing it with the mob's name.
|
||||
@ -32,14 +32,14 @@
|
||||
* - _pkt(TYPE, BasePacket *) - Log a packet hex dump with header in any context.
|
||||
* - mhex(TYPE, data, length) - Zone only. Log a packet hex dump from a Mob:: context, prefixing it with the mob's name
|
||||
* Types are defined in logtypes.h
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* this is very C-ish, not C++ish, but thats how I felt like writting it
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
@ -180,7 +180,7 @@ extern bool load_log_settings(const char *filename);
|
||||
|
||||
#endif /*LOGSYS_H_*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -33,7 +33,7 @@ void log_messageVA(LogType type, const char *fmt, va_list args) {
|
||||
char prefix_buffer[256];
|
||||
snprintf(prefix_buffer, 255, "[%s] ", log_type_info[type].name);
|
||||
prefix_buffer[255] = '\0';
|
||||
|
||||
|
||||
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args);
|
||||
}
|
||||
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
@ -61,7 +61,7 @@ MD5::operator const char* () {
|
||||
snprintf(pMD5String, sizeof(pMD5String), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", pMD5[0], pMD5[1], pMD5[2], pMD5[3], pMD5[4], pMD5[5], pMD5[6], pMD5[7], pMD5[8], pMD5[9], pMD5[10], pMD5[11], pMD5[12], pMD5[13], pMD5[14], pMD5[15]);
|
||||
return pMD5String;
|
||||
}
|
||||
|
||||
|
||||
bool MD5::operator== (const MD5& iMD5) {
|
||||
if (memcmp(pMD5, iMD5.pMD5, 16) == 0)
|
||||
return true;
|
||||
@ -268,4 +268,4 @@ void MD5::Transform(uint32 hash[4], const uint32 input[16]) {
|
||||
MD5STEP(F4, b, c, d, a, input[ 9]+0xeb86d391, 21);
|
||||
|
||||
hash[0] += a; hash[1] += b; hash[2] += c; hash[3] += d;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ public:
|
||||
uint32 input[16];
|
||||
};
|
||||
static void Generate(const uint8* buf, uint32 len, uint8 digest[16]);
|
||||
|
||||
|
||||
static void Init(struct MD5Context *context);
|
||||
static void Update(struct MD5Context *context, const uint8 *buf, uint32 len);
|
||||
static void Final(uint8 digest[16], struct MD5Context *context);
|
||||
@ -21,7 +21,7 @@ public:
|
||||
MD5(const char* buf, uint32 len);
|
||||
MD5(const uint8 buf[16]);
|
||||
MD5(const char* iMD5String);
|
||||
|
||||
|
||||
void Generate(const char* iString);
|
||||
void Generate(const uint8* buf, uint32 len);
|
||||
bool Set(const uint8 buf[16]);
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -40,45 +40,45 @@ namespace EQEmu {
|
||||
#endif
|
||||
};
|
||||
|
||||
MemoryMappedFile::MemoryMappedFile(std::string filename, uint32 size)
|
||||
MemoryMappedFile::MemoryMappedFile(std::string filename, uint32 size)
|
||||
: filename_(filename), size_(size) {
|
||||
imp_ = new Implementation;
|
||||
|
||||
|
||||
#ifdef _WINDOWS
|
||||
DWORD total_size = size + sizeof(shared_memory_struct);
|
||||
HANDLE file = CreateFile(filename.c_str(),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
HANDLE file = CreateFile(filename.c_str(),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr,
|
||||
OPEN_ALWAYS,
|
||||
0,
|
||||
nullptr);
|
||||
|
||||
|
||||
if(file == INVALID_HANDLE_VALUE) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
|
||||
}
|
||||
|
||||
|
||||
imp_->mapped_object_ = CreateFileMapping(file,
|
||||
nullptr,
|
||||
PAGE_READWRITE,
|
||||
PAGE_READWRITE,
|
||||
0,
|
||||
total_size,
|
||||
filename.c_str());
|
||||
|
||||
|
||||
if(!imp_->mapped_object_) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");
|
||||
}
|
||||
|
||||
|
||||
memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
total_size));
|
||||
|
||||
|
||||
if(!memory_) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file.");
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
size_t total_size = size + sizeof(shared_memory_struct);
|
||||
imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
@ -98,11 +98,11 @@ namespace EQEmu {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
MemoryMappedFile::MemoryMappedFile(std::string filename)
|
||||
|
||||
MemoryMappedFile::MemoryMappedFile(std::string filename)
|
||||
: filename_(filename) {
|
||||
imp_ = new Implementation;
|
||||
|
||||
|
||||
//get existing size
|
||||
FILE *f = fopen(filename.c_str(), "rb");
|
||||
if(!f) {
|
||||
@ -115,39 +115,39 @@ namespace EQEmu {
|
||||
|
||||
#ifdef _WINDOWS
|
||||
DWORD total_size = size + sizeof(shared_memory_struct);
|
||||
HANDLE file = CreateFile(filename.c_str(),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
HANDLE file = CreateFile(filename.c_str(),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr,
|
||||
OPEN_ALWAYS,
|
||||
0,
|
||||
nullptr);
|
||||
|
||||
|
||||
if(file == INVALID_HANDLE_VALUE) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
|
||||
}
|
||||
|
||||
|
||||
imp_->mapped_object_ = CreateFileMapping(file,
|
||||
nullptr,
|
||||
PAGE_READWRITE,
|
||||
PAGE_READWRITE,
|
||||
0,
|
||||
total_size,
|
||||
filename.c_str());
|
||||
|
||||
|
||||
if(!imp_->mapped_object_) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");
|
||||
}
|
||||
|
||||
|
||||
memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
total_size));
|
||||
|
||||
|
||||
if(!memory_) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file.");
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
size_t total_size = size + sizeof(shared_memory_struct);
|
||||
imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
@ -182,7 +182,7 @@ namespace EQEmu {
|
||||
#endif
|
||||
delete imp_;
|
||||
}
|
||||
|
||||
|
||||
void MemoryMappedFile::ZeroFile() {
|
||||
memset(reinterpret_cast<void*>(memory_), 0, sizeof(shared_memory_struct));
|
||||
memset(memory_->data, 0, size_);
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -26,7 +26,7 @@ namespace EQEmu {
|
||||
|
||||
//! Memory Backed Shared Memory
|
||||
/*!
|
||||
Allows us to create shared memory that is backed by a file on both windows and unix platforms that
|
||||
Allows us to create shared memory that is backed by a file on both windows and unix platforms that
|
||||
works in a consistent manner. Non-copyable.
|
||||
*/
|
||||
class MemoryMappedFile {
|
||||
@ -40,15 +40,15 @@ namespace EQEmu {
|
||||
};
|
||||
public:
|
||||
//! Constructor
|
||||
/*!
|
||||
/*!
|
||||
Creates a mmf for the given filename and of size.
|
||||
\param filename Actual filename of the mmf.
|
||||
\param size Size in bytes of the mmf.
|
||||
*/
|
||||
MemoryMappedFile(std::string filename, uint32 size);
|
||||
|
||||
|
||||
//! Constructor
|
||||
/*!
|
||||
/*!
|
||||
Creates a mmf for the given filename and gets the size based on the existing size.
|
||||
\param filename Actual filename of the mmf.
|
||||
*/
|
||||
@ -59,19 +59,19 @@ namespace EQEmu {
|
||||
|
||||
//! Get Data Operator
|
||||
inline void *operator->() const { return memory_->data; }
|
||||
|
||||
|
||||
//! Get Data Function
|
||||
inline void *Get() const { return memory_->data; }
|
||||
|
||||
|
||||
//! Get Size Function
|
||||
inline uint32 Size() const { return memory_->size; }
|
||||
|
||||
|
||||
//! Zeros all the memory in the file, and set it to be unloaded
|
||||
void ZeroFile();
|
||||
private:
|
||||
//! Copy Constructor
|
||||
MemoryMappedFile(const MemoryMappedFile&);
|
||||
|
||||
|
||||
//! Assignment Operator
|
||||
const MemoryMappedFile& operator=(const MemoryMappedFile&);
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ There are currently eight (times two) dispatch modes possible, the different
|
||||
modes for a given state differ only in the arguments which
|
||||
are passed to the dispatch function.
|
||||
|
||||
The variable length versions ensure that the packet is
|
||||
The variable length versions ensure that the packet is
|
||||
AT LEAST as long as the supplied structure.
|
||||
|
||||
The variable length versions should only be used when the packet
|
||||
@ -76,7 +76,7 @@ IN_Cz(OP_ReqNewZone);
|
||||
IN_Cz(OP_SendExpZonein);
|
||||
//IN_Cr(OP_ZoneComplete);
|
||||
|
||||
//these three should stay raw, since we ignore their contents and
|
||||
//these three should stay raw, since we ignore their contents and
|
||||
//they overlap with the connected opcodes
|
||||
IN_Cr(OP_SpawnAppearance);
|
||||
IN_Cr(OP_WearChange);
|
||||
@ -477,14 +477,14 @@ OUT(OP_ZoneEntry, ServerZoneEntry_Struct);
|
||||
void Handle_##op ();
|
||||
#define INr(op) \
|
||||
void Handle_##op (const EQApplicationPacket *app);
|
||||
#define OUT_C(op, s)
|
||||
#define OUT_Cv(op, s)
|
||||
#define OUT_Cz(op)
|
||||
#define OUT_Cr(op)
|
||||
#define OUT(op, s)
|
||||
#define OUTv(op, s)
|
||||
#define OUTz(op)
|
||||
#define OUTr(op)
|
||||
#define OUT_C(op, s)
|
||||
#define OUT_Cv(op, s)
|
||||
#define OUT_Cz(op)
|
||||
#define OUT_Cr(op)
|
||||
#define OUT(op, s)
|
||||
#define OUTv(op, s)
|
||||
#define OUTz(op)
|
||||
#define OUTr(op)
|
||||
#include "opcode_dispatch.h"
|
||||
#undef IN_C
|
||||
#undef IN_Cr
|
||||
@ -514,7 +514,7 @@ public:
|
||||
RawOpcodeDispatcher(proc p) {
|
||||
d = p;
|
||||
}
|
||||
|
||||
|
||||
virtual void dispatch(Client *on, const EQApplicationPacket *app) {
|
||||
(on->*d)(app);
|
||||
}
|
||||
@ -528,7 +528,7 @@ public:
|
||||
ZeroOpcodeDispatcher(proc p) {
|
||||
d = p;
|
||||
}
|
||||
|
||||
|
||||
virtual void dispatch(Client *on, const EQApplicationPacket *app) {
|
||||
if(app->size != 0) {
|
||||
//error..
|
||||
@ -548,7 +548,7 @@ public:
|
||||
d = p;
|
||||
struct_name = sn;
|
||||
}
|
||||
|
||||
|
||||
virtual void dispatch(Client *on, const EQApplicationPacket *app) {
|
||||
if(app->size != sizeof(T)) {
|
||||
//error..
|
||||
@ -557,7 +557,7 @@ public:
|
||||
T * tmp = (T *) app->pBuffer;
|
||||
(on->*d)(tmp);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
proc d;
|
||||
const char *struct_name;
|
||||
@ -571,7 +571,7 @@ public:
|
||||
d = p;
|
||||
struct_name = sn;
|
||||
}
|
||||
|
||||
|
||||
virtual void dispatch(Client *on, const EQApplicationPacket *app) {
|
||||
if(app->size < sizeof(T)) {
|
||||
//error..
|
||||
@ -580,13 +580,13 @@ public:
|
||||
T * tmp = (T *) app->pBuffer;
|
||||
(on->*d)(tmp, app->size);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
proc d;
|
||||
const char *struct_name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//... client_packet.cpp
|
||||
void MapOpcodes() {
|
||||
@ -607,14 +607,14 @@ void MapOpcodes() {
|
||||
ConnectedOpcodes[op] = new ZeroOpcodeDispatcher(&Client::Handle_##op);
|
||||
#define INr(op) \
|
||||
ConnectedOpcodes[op] = new RawOpcodeDispatcher(&Client::Handle_##op);
|
||||
#define OUT_C(op, s)
|
||||
#define OUT_Cv(op, s)
|
||||
#define OUT_Cz(op)
|
||||
#define OUT_Cr(op)
|
||||
#define OUT(op, s)
|
||||
#define OUTv(op, s)
|
||||
#define OUTz(op)
|
||||
#define OUTr(op)
|
||||
#define OUT_C(op, s)
|
||||
#define OUT_Cv(op, s)
|
||||
#define OUT_Cz(op)
|
||||
#define OUT_Cr(op)
|
||||
#define OUT(op, s)
|
||||
#define OUTv(op, s)
|
||||
#define OUTz(op)
|
||||
#define OUTr(op)
|
||||
#include "opcode_dispatch.h"
|
||||
#undef IN_C
|
||||
#undef IN_Cr
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -37,9 +37,9 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
|
||||
fprintf(stderr, "Unable to open opcodes file '%s'. Thats bad.\n", filename);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
map<string, uint16> eq;
|
||||
|
||||
|
||||
//load the opcode file into eq, could swap in a nice XML parser here
|
||||
char line[2048];
|
||||
int lineno = 0;
|
||||
@ -49,11 +49,11 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
|
||||
line[0] = '\0'; //for blank line at end of file
|
||||
if(fgets(line, sizeof(line), opf) == nullptr)
|
||||
break;
|
||||
|
||||
|
||||
//ignore any line that dosent start with OP_
|
||||
if(line[0] != 'O' || line[1] != 'P' || line[2] != '_')
|
||||
continue;
|
||||
|
||||
|
||||
char *num = line+3; //skip OP_
|
||||
//look for the = sign
|
||||
while(*num != '=' && *num != '\0') {
|
||||
@ -66,19 +66,19 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
|
||||
}
|
||||
*num = '\0'; //null terminate the name
|
||||
num++; //num should point to the opcode
|
||||
|
||||
|
||||
//read the opcode
|
||||
if(sscanf(num, "0x%hx", &curop) != 1) {
|
||||
if(report_errors) fprintf(stderr, "Malformed opcode at %s:%d\n", filename, lineno);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//we have a name and our opcode... stick it in the map
|
||||
eq[line] = curop;
|
||||
}
|
||||
fclose(opf);
|
||||
|
||||
|
||||
|
||||
|
||||
//do the mapping and store them in the shared memory array
|
||||
bool ret = true;
|
||||
EmuOpcode emu_op;
|
||||
@ -92,7 +92,7 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
|
||||
if(report_errors) printf("I will let you continue, since you may have gotten all the opcodes you need.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//find the opcode in the file
|
||||
res = eq.find(op_name);
|
||||
if(res == eq.end()) {
|
||||
@ -100,11 +100,11 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
|
||||
//ret = false;
|
||||
continue; //continue to give them a list of all missing opcodes
|
||||
}
|
||||
|
||||
|
||||
//ship the mapping off to shared mem.
|
||||
s->Set(emu_op, res->second);
|
||||
}
|
||||
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -148,17 +148,17 @@ bool RegularOpcodeManager::LoadOpcodes(const char *filename, bool report_errors)
|
||||
NormalMemStrategy s;
|
||||
s.it = this;
|
||||
MOpcodes.lock();
|
||||
|
||||
|
||||
loaded = true;
|
||||
eq_to_emu = new EmuOpcode[MAX_EQ_OPCODE];
|
||||
emu_to_eq = new uint16[_maxEmuOpcode];
|
||||
EQOpcodeCount = MAX_EQ_OPCODE;
|
||||
EmuOpcodeCount = _maxEmuOpcode;
|
||||
|
||||
|
||||
//dont need to set eq_to_emu cause every element should get a value
|
||||
memset(eq_to_emu, 0, sizeof(EmuOpcode)*MAX_EQ_OPCODE);
|
||||
memset(emu_to_eq, 0, sizeof(uint16)*_maxEmuOpcode);
|
||||
|
||||
|
||||
bool ret = LoadOpcodesFile(filename, &s, report_errors);
|
||||
MOpcodes.unlock();
|
||||
return ret;
|
||||
@ -167,15 +167,15 @@ bool RegularOpcodeManager::LoadOpcodes(const char *filename, bool report_errors)
|
||||
bool RegularOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors) {
|
||||
if(!loaded)
|
||||
return(LoadOpcodes(filename));
|
||||
|
||||
|
||||
NormalMemStrategy s;
|
||||
s.it = this;
|
||||
MOpcodes.lock();
|
||||
|
||||
|
||||
memset(eq_to_emu, 0, sizeof(uint16)*MAX_EQ_OPCODE);
|
||||
|
||||
|
||||
bool ret = LoadOpcodesFile(filename, &s, report_errors);
|
||||
|
||||
|
||||
MOpcodes.unlock();
|
||||
return(ret);
|
||||
}
|
||||
@ -209,12 +209,12 @@ EmuOpcode RegularOpcodeManager::EQToEmu(const uint16 eq_op) {
|
||||
}
|
||||
|
||||
void RegularOpcodeManager::SetOpcode(EmuOpcode emu_op, uint16 eq_op) {
|
||||
|
||||
|
||||
//clear out old mapping
|
||||
uint16 oldop = emu_to_eq[emu_op];
|
||||
if(oldop != 0)
|
||||
eq_to_emu[oldop] = OP_Unknown;
|
||||
|
||||
|
||||
//use our strategy, since we have it
|
||||
NormalMemStrategy s;
|
||||
s.it = this;
|
||||
@ -233,7 +233,7 @@ NullOpcodeManager::NullOpcodeManager()
|
||||
: MutableOpcodeManager() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool NullOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
|
||||
return(true);
|
||||
}
|
||||
@ -241,7 +241,7 @@ bool NullOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
|
||||
bool NullOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors) {
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
uint16 NullOpcodeManager::EmuToEQ(const EmuOpcode emu_op) {
|
||||
return(0);
|
||||
}
|
||||
@ -254,7 +254,7 @@ EmptyOpcodeManager::EmptyOpcodeManager()
|
||||
: MutableOpcodeManager() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EmptyOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
|
||||
return(true);
|
||||
}
|
||||
@ -262,7 +262,7 @@ bool EmptyOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
|
||||
bool EmptyOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors) {
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
uint16 EmptyOpcodeManager::EmuToEQ(const EmuOpcode emu_op) {
|
||||
map<EmuOpcode, uint16>::iterator f;
|
||||
f = emu_to_eq.find(emu_op);
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@ -38,18 +38,18 @@ class OpcodeManager {
|
||||
public:
|
||||
OpcodeManager();
|
||||
virtual ~OpcodeManager() {}
|
||||
|
||||
|
||||
virtual bool Mutable() { return(false); }
|
||||
virtual bool LoadOpcodes(const char *filename, bool report_errors = false) = 0;
|
||||
virtual bool ReloadOpcodes(const char *filename, bool report_errors = false) = 0;
|
||||
|
||||
|
||||
virtual uint16 EmuToEQ(const EmuOpcode emu_op) = 0;
|
||||
virtual EmuOpcode EQToEmu(const uint16 eq_op) = 0;
|
||||
|
||||
|
||||
static const char *EmuToName(const EmuOpcode emu_op);
|
||||
const char *EQToName(const uint16 emu_op);
|
||||
EmuOpcode NameSearch(const char *name);
|
||||
|
||||
|
||||
//This has to be public for stupid visual studio
|
||||
class OpcodeSetStrategy {
|
||||
public:
|
||||
@ -61,7 +61,7 @@ protected:
|
||||
bool loaded; //true if all opcodes loaded
|
||||
Mutex MOpcodes; //this only protects the local machine
|
||||
//in a shared manager, this dosent protect others
|
||||
|
||||
|
||||
static bool LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors);
|
||||
};
|
||||
|
||||
@ -77,13 +77,13 @@ public:
|
||||
class SharedOpcodeManager : public OpcodeManager {
|
||||
public:
|
||||
virtual ~SharedOpcodeManager() {}
|
||||
|
||||
|
||||
virtual bool LoadOpcodes(const char *filename, bool report_errors = false);
|
||||
virtual bool ReloadOpcodes(const char *filename, bool report_errors = false);
|
||||
|
||||
|
||||
virtual uint16 EmuToEQ(const EmuOpcode emu_op);
|
||||
virtual EmuOpcode EQToEmu(const uint16 eq_op);
|
||||
|
||||
|
||||
protected:
|
||||
class SharedMemStrategy : public OpcodeManager::OpcodeSetStrategy {
|
||||
public:
|
||||
@ -99,17 +99,17 @@ class RegularOpcodeManager : public MutableOpcodeManager {
|
||||
public:
|
||||
RegularOpcodeManager();
|
||||
virtual ~RegularOpcodeManager();
|
||||
|
||||
|
||||
virtual bool Editable() { return(true); }
|
||||
virtual bool LoadOpcodes(const char *filename, bool report_errors = false);
|
||||
virtual bool ReloadOpcodes(const char *filename, bool report_errors = false);
|
||||
|
||||
|
||||
virtual uint16 EmuToEQ(const EmuOpcode emu_op);
|
||||
virtual EmuOpcode EQToEmu(const uint16 eq_op);
|
||||
|
||||
|
||||
//implement our editing interface
|
||||
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op);
|
||||
|
||||
|
||||
protected:
|
||||
class NormalMemStrategy : public OpcodeManager::OpcodeSetStrategy {
|
||||
public:
|
||||
@ -118,7 +118,7 @@ protected:
|
||||
void Set(EmuOpcode emu_op, uint16 eq_op);
|
||||
};
|
||||
friend class NormalMemStrategy;
|
||||
|
||||
|
||||
uint16 *emu_to_eq;
|
||||
EmuOpcode *eq_to_emu;
|
||||
uint32 EQOpcodeCount;
|
||||
@ -129,13 +129,13 @@ protected:
|
||||
class NullOpcodeManager : public MutableOpcodeManager {
|
||||
public:
|
||||
NullOpcodeManager();
|
||||
|
||||
|
||||
virtual bool LoadOpcodes(const char *filename, bool report_errors = false);
|
||||
virtual bool ReloadOpcodes(const char *filename, bool report_errors = false);
|
||||
|
||||
|
||||
virtual uint16 EmuToEQ(const EmuOpcode emu_op);
|
||||
virtual EmuOpcode EQToEmu(const uint16 eq_op);
|
||||
|
||||
|
||||
//fake it, just used for testing anyways
|
||||
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op) {}
|
||||
};
|
||||
@ -146,13 +146,13 @@ public:
|
||||
class EmptyOpcodeManager : public MutableOpcodeManager {
|
||||
public:
|
||||
EmptyOpcodeManager();
|
||||
|
||||
|
||||
virtual bool LoadOpcodes(const char *filename, bool report_errors = false);
|
||||
virtual bool ReloadOpcodes(const char *filename, bool report_errors = false);
|
||||
|
||||
|
||||
virtual uint16 EmuToEQ(const EmuOpcode emu_op);
|
||||
virtual EmuOpcode EQToEmu(const uint16 eq_op);
|
||||
|
||||
|
||||
//fake it, just used for testing anyways
|
||||
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op);
|
||||
protected:
|
||||
|
||||
@ -55,8 +55,8 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
|
||||
return;
|
||||
// Output as HEX
|
||||
char output[4];
|
||||
int j = 0;
|
||||
char* ascii = new char[cols+1];
|
||||
int j = 0;
|
||||
char* ascii = new char[cols+1];
|
||||
memset(ascii, 0, cols+1);
|
||||
uint32 i;
|
||||
for(i=skip; i<size; i++)
|
||||
|
||||
@ -86,7 +86,7 @@ void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, u
|
||||
sprintf(output, "%02X ",(unsigned char)buf[i]);
|
||||
logfile << output;
|
||||
// logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " ";
|
||||
}
|
||||
}
|
||||
logfile << endl << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -38,11 +38,11 @@ void EncryptProfilePacket(uchar* pBuffer, uint32 size) {
|
||||
uint64 crypt = 0x659365E7;
|
||||
uint64 next_crypt;
|
||||
uint32 len = size >> 3;
|
||||
|
||||
|
||||
uint64 swap = data[0];
|
||||
data[0] = data[len/2];
|
||||
data[len/2] = swap;
|
||||
|
||||
|
||||
for(uint32 i=0; i<len;i++) {
|
||||
next_crypt = crypt+data[i]-0x422437A9;
|
||||
data[i] = ((data[i]>>0x19)|(data[i]<<0x27))+0x422437A9;
|
||||
@ -61,11 +61,11 @@ void EncryptZoneSpawnPacket(uchar* pBuffer, uint32 size) {
|
||||
uint64 crypt = 0x0000;
|
||||
uint64 next_crypt;
|
||||
uint32 len = size >> 3;
|
||||
|
||||
|
||||
uint64 swap = data[0];
|
||||
data[0] = data[len/2];
|
||||
data[len/2] = swap;
|
||||
|
||||
|
||||
for(uint32 i=0; i<len;i++) {
|
||||
next_crypt = crypt+data[i]-0x659365E7;
|
||||
data[i] = ((data[i]<<0x1d)|(data[i]>>0x23))+0x659365E7;
|
||||
@ -101,7 +101,7 @@ int DeflatePacket(const unsigned char* in_data, int in_length, unsigned char* ou
|
||||
static bool inited = false;
|
||||
static z_stream zstream;
|
||||
int zerror;
|
||||
|
||||
|
||||
if(in_data == nullptr && out_data == nullptr && in_length == 0 && max_out_length == 0) {
|
||||
//special delete state
|
||||
deflateEnd(&zstream);
|
||||
@ -114,7 +114,7 @@ int DeflatePacket(const unsigned char* in_data, int in_length, unsigned char* ou
|
||||
zstream.opaque = Z_NULL;
|
||||
deflateInit(&zstream, Z_FINISH);
|
||||
}
|
||||
|
||||
|
||||
zstream.next_in = const_cast<unsigned char *>(in_data);
|
||||
zstream.avail_in = in_length;
|
||||
/* zstream.zalloc = Z_NULL;
|
||||
@ -124,9 +124,9 @@ int DeflatePacket(const unsigned char* in_data, int in_length, unsigned char* ou
|
||||
zstream.next_out = out_data;
|
||||
zstream.avail_out = max_out_length;
|
||||
zerror = deflate(&zstream, Z_FINISH);
|
||||
|
||||
|
||||
deflateReset(&zstream);
|
||||
|
||||
|
||||
if (zerror == Z_STREAM_END)
|
||||
{
|
||||
// deflateEnd(&zstream);
|
||||
@ -141,11 +141,11 @@ int DeflatePacket(const unsigned char* in_data, int in_length, unsigned char* ou
|
||||
if(in_data == nullptr) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
z_stream zstream;
|
||||
memset(&zstream, 0, sizeof(zstream));
|
||||
int zerror;
|
||||
|
||||
|
||||
zstream.next_in = const_cast<unsigned char *>(in_data);
|
||||
zstream.avail_in = in_length;
|
||||
zstream.zalloc = eqemu_alloc_func;
|
||||
@ -155,7 +155,7 @@ int DeflatePacket(const unsigned char* in_data, int in_length, unsigned char* ou
|
||||
zstream.next_out = out_data;
|
||||
zstream.avail_out = max_out_length;
|
||||
zerror = deflate(&zstream, Z_FINISH);
|
||||
|
||||
|
||||
if (zerror == Z_STREAM_END)
|
||||
{
|
||||
deflateEnd(&zstream);
|
||||
@ -174,7 +174,7 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
|
||||
static bool inited = false;
|
||||
static z_stream zstream;
|
||||
int zerror;
|
||||
|
||||
|
||||
if(indata == nullptr && outdata == nullptr && indatalen == 0 && outdatalen == 0) {
|
||||
//special delete state
|
||||
inflateEnd(&zstream);
|
||||
@ -194,16 +194,16 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
|
||||
zstream.zalloc = eqemu_alloc_func;
|
||||
zstream.zfree = eqemu_free_func;
|
||||
zstream.opaque = Z_NULL;
|
||||
|
||||
i = inflateInit2( &zstream, 15 );
|
||||
if (i != Z_OK) {
|
||||
|
||||
i = inflateInit2( &zstream, 15 );
|
||||
if (i != Z_OK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
zerror = inflate( &zstream, Z_FINISH );
|
||||
|
||||
|
||||
inflateReset(&zstream);
|
||||
|
||||
|
||||
if(zerror == Z_STREAM_END) {
|
||||
return zstream.total_out;
|
||||
}
|
||||
@ -217,22 +217,22 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
|
||||
DumpPacket(indata-16, indatalen+16);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (zerror == -4 && zstream.msg == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if(indata == nullptr)
|
||||
return(0);
|
||||
|
||||
|
||||
z_stream zstream;
|
||||
int zerror = 0;
|
||||
int i;
|
||||
|
||||
|
||||
zstream.next_in = const_cast<unsigned char *>(indata);
|
||||
zstream.avail_in = indatalen;
|
||||
zstream.next_out = outdata;
|
||||
@ -240,14 +240,14 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
|
||||
zstream.zalloc = eqemu_alloc_func;
|
||||
zstream.zfree = eqemu_free_func;
|
||||
zstream.opaque = Z_NULL;
|
||||
|
||||
i = inflateInit2( &zstream, 15 );
|
||||
if (i != Z_OK) {
|
||||
|
||||
i = inflateInit2( &zstream, 15 );
|
||||
if (i != Z_OK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
zerror = inflate( &zstream, Z_FINISH );
|
||||
|
||||
|
||||
if(zerror == Z_STREAM_END) {
|
||||
inflateEnd( &zstream );
|
||||
return zstream.total_out;
|
||||
@ -262,12 +262,12 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
|
||||
DumpPacket(indata-16, indatalen+16);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (zerror == -4 && zstream.msg == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
zerror = inflateEnd( &zstream );
|
||||
return 0;
|
||||
}
|
||||
@ -293,30 +293,30 @@ uint64 rorl(uint64 in, uint8 bits) {
|
||||
uint32 CRCLookup(uchar idx) {
|
||||
if (idx == 0)
|
||||
return 0x00000000;
|
||||
|
||||
|
||||
if (idx == 1)
|
||||
return 0x77073096;
|
||||
|
||||
|
||||
if (idx == 2)
|
||||
return roll(CRCLookup(1), 1);
|
||||
|
||||
|
||||
if (idx == 4)
|
||||
return 0x076DC419;
|
||||
|
||||
|
||||
for (uchar b=7; b>0; b--) {
|
||||
uchar bv = 1 << b;
|
||||
|
||||
|
||||
if (!(idx ^ bv)) {
|
||||
// bit is only one set
|
||||
return ( roll(CRCLookup (4), b - 2) );
|
||||
}
|
||||
|
||||
|
||||
if (idx&bv) {
|
||||
// bit is set
|
||||
return( CRCLookup(bv) ^ CRCLookup(idx&(bv - 1)) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Failure
|
||||
return false;
|
||||
}
|
||||
@ -325,10 +325,10 @@ uint32 GenerateCRC(uint32 b, uint32 bufsize, uchar *buf) {
|
||||
uint32 CRC = (b ^ 0xFFFFFFFF);
|
||||
uint32 bufremain = bufsize;
|
||||
uchar* bufptr = buf;
|
||||
|
||||
|
||||
while (bufremain--) {
|
||||
CRC = CRCLookup((uchar)(*(bufptr++)^ (CRC&0xFF))) ^ (CRC >> 8);
|
||||
}
|
||||
|
||||
|
||||
return (htonl (CRC ^ 0xFFFFFFFF));
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
@ -32,15 +32,15 @@ bool PacketFileWriter::SetPacketStamp(const char *name, uint32 stamp) {
|
||||
fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
unsigned long magic = 0;
|
||||
|
||||
|
||||
if(fread(&magic, sizeof(magic), 1, in) != 1) {
|
||||
fprintf(stderr, "Error reading header from packet file: %s\n", strerror(errno));
|
||||
fclose(in);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
PacketFileReader *ret = NULL;
|
||||
if(magic == OLD_PACKET_FILE_MAGIC) {
|
||||
OldPacketFileHeader *pos = 0;
|
||||
@ -69,33 +69,33 @@ bool PacketFileWriter::SetPacketStamp(const char *name, uint32 stamp) {
|
||||
fclose(in);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
fclose(in);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
bool PacketFileWriter::OpenFile(const char *name) {
|
||||
CloseFile();
|
||||
|
||||
|
||||
printf("Opening packet file: %s\n", name);
|
||||
|
||||
|
||||
out = fopen(name, "wb");
|
||||
if(out == NULL) {
|
||||
fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
PacketFileHeader head;
|
||||
head.packet_file_magic = PACKET_FILE_MAGIC;
|
||||
head.packet_file_version = PACKET_FILE_CURRENT_VERSION;
|
||||
head.packet_file_stamp = time(NULL);
|
||||
|
||||
|
||||
if(fwrite(&head, sizeof(head), 1, out) != 1) {
|
||||
fprintf(stderr, "Error writting header to packet file: %s\n", strerror(errno));
|
||||
fclose(out);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -110,13 +110,13 @@ void PacketFileWriter::CloseFile() {
|
||||
void PacketFileWriter::WritePacket(uint16 eq_op, uint32 packlen, const unsigned char *packet, bool to_server, const struct timeval &tv) {
|
||||
if(out == NULL)
|
||||
return;
|
||||
|
||||
|
||||
_WriteBlock(eq_op, packet, packlen, to_server, tv);
|
||||
|
||||
|
||||
/*
|
||||
Could log only the packets we care about, but this is most of the stream,
|
||||
so just log them all...
|
||||
|
||||
|
||||
switch(eq_op) {
|
||||
case OP_NewZone:
|
||||
case OP_ZoneSpawns:
|
||||
@ -139,23 +139,23 @@ void PacketFileWriter::WritePacket(uint16 eq_op, uint32 packlen, const unsigned
|
||||
bool PacketFileWriter::_WriteBlock(uint16 eq_op, const void *d, uint16 len, bool to_server, const struct timeval &tv) {
|
||||
if(out == NULL)
|
||||
return(false);
|
||||
|
||||
|
||||
PacketFileSection s;
|
||||
s.opcode = eq_op;
|
||||
s.len = len;
|
||||
s.tv_sec = tv.tv_sec;
|
||||
s.tv_msec = tv.tv_usec/1000;
|
||||
|
||||
|
||||
if(to_server)
|
||||
SetToServer(s);
|
||||
else
|
||||
SetToClient(s);
|
||||
|
||||
|
||||
if(fwrite(&s, sizeof(s), 1, out) != 1) {
|
||||
fprintf(stderr, "Error writting block header: %s\n", strerror(errno));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
if(fwrite(d, 1, len, out) != len) {
|
||||
fprintf(stderr, "Error writting block body: %s\n", strerror(errno));
|
||||
return(false);
|
||||
@ -163,7 +163,7 @@ bool PacketFileWriter::_WriteBlock(uint16 eq_op, const void *d, uint16 len, bool
|
||||
|
||||
if(force_flush)
|
||||
fflush(out);
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -179,15 +179,15 @@ PacketFileReader *PacketFileReader::OpenPacketFile(const char *name) {
|
||||
fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
unsigned long magic = 0;
|
||||
|
||||
|
||||
if(fread(&magic, sizeof(magic), 1, in) != 1) {
|
||||
fprintf(stderr, "Error reading header to packet file: %s\n", strerror(errno));
|
||||
fclose(in);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
PacketFileReader *ret = NULL;
|
||||
if(magic == OLD_PACKET_FILE_MAGIC) {
|
||||
ret = new OldPacketFileReader();
|
||||
@ -198,12 +198,12 @@ PacketFileReader *PacketFileReader::OpenPacketFile(const char *name) {
|
||||
fclose(in);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
if(!ret->OpenFile(name)) {
|
||||
safe_delete(ret);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -220,26 +220,26 @@ OldPacketFileReader::OldPacketFileReader()
|
||||
OldPacketFileReader::~OldPacketFileReader() {
|
||||
CloseFile();
|
||||
}
|
||||
|
||||
|
||||
bool OldPacketFileReader::OpenFile(const char *name) {
|
||||
CloseFile();
|
||||
|
||||
|
||||
//printf("Opening packet file: %s\n", name);
|
||||
|
||||
|
||||
in = fopen(name, "rb");
|
||||
if(in == NULL) {
|
||||
fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
OldPacketFileHeader head;
|
||||
|
||||
|
||||
if(fread(&head, sizeof(head), 1, in) != 1) {
|
||||
fprintf(stderr, "Error reading header to packet file: %s\n", strerror(errno));
|
||||
fclose(in);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
if(head.packet_file_magic != OLD_PACKET_FILE_MAGIC) {
|
||||
fclose(in);
|
||||
if(head.packet_file_magic > (OLD_PACKET_FILE_MAGIC)) {
|
||||
@ -249,16 +249,16 @@ bool OldPacketFileReader::OpenFile(const char *name) {
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
uint32 now = time(NULL);
|
||||
if(head.packet_file_stamp > now) {
|
||||
fprintf(stderr, "Error: invalid timestamp in file. Your clock or the collector's is wrong (%d sec ahead).\n", head.packet_file_stamp-now);
|
||||
fclose(in);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
packet_file_stamp = head.packet_file_stamp;
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -274,14 +274,14 @@ bool OldPacketFileReader::ResetFile() {
|
||||
if(in == NULL)
|
||||
return(false);
|
||||
rewind(in);
|
||||
|
||||
|
||||
//gotta read past the header again
|
||||
OldPacketFileHeader head;
|
||||
|
||||
|
||||
if(fread(&head, sizeof(head), 1, in) != 1) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -290,23 +290,23 @@ bool OldPacketFileReader::ReadPacket(uint16 &eq_op, uint32 &packlen, unsigned ch
|
||||
return(false);
|
||||
if(feof(in))
|
||||
return(false);
|
||||
|
||||
|
||||
OldPacketFileSection s;
|
||||
|
||||
|
||||
if(fread(&s, sizeof(s), 1, in) != 1) {
|
||||
if(!feof(in))
|
||||
fprintf(stderr, "Error reading section header: %s\n", strerror(errno));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
eq_op = s.opcode;
|
||||
|
||||
|
||||
if(packlen < s.len) {
|
||||
fprintf(stderr, "Packet buffer is too small! %d < %d, skipping\n", packlen, s.len);
|
||||
fseek(in, s.len, SEEK_CUR);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
if(fread(packet, 1, s.len, in) != s.len) {
|
||||
if(feof(in))
|
||||
fprintf(stderr, "Error: EOF encountered when expecting packet data.\n");
|
||||
@ -314,12 +314,12 @@ bool OldPacketFileReader::ReadPacket(uint16 &eq_op, uint32 &packlen, unsigned ch
|
||||
fprintf(stderr, "Error reading packet body: %s\n", strerror(errno));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
packlen = s.len;
|
||||
to_server = false;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -333,26 +333,26 @@ NewPacketFileReader::NewPacketFileReader()
|
||||
NewPacketFileReader::~NewPacketFileReader() {
|
||||
CloseFile();
|
||||
}
|
||||
|
||||
|
||||
bool NewPacketFileReader::OpenFile(const char *name) {
|
||||
CloseFile();
|
||||
|
||||
|
||||
//printf("Opening packet file: %s\n", name);
|
||||
|
||||
|
||||
in = fopen(name, "rb");
|
||||
if(in == NULL) {
|
||||
fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
PacketFileHeader head;
|
||||
|
||||
|
||||
if(fread(&head, sizeof(head), 1, in) != 1) {
|
||||
fprintf(stderr, "Error reading header to packet file: %s\n", strerror(errno));
|
||||
fclose(in);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
if(head.packet_file_magic != PACKET_FILE_MAGIC) {
|
||||
fclose(in);
|
||||
if(head.packet_file_magic == (PACKET_FILE_MAGIC+1)) {
|
||||
@ -362,16 +362,16 @@ bool NewPacketFileReader::OpenFile(const char *name) {
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
uint32 now = time(NULL);
|
||||
if(head.packet_file_stamp > now) {
|
||||
fprintf(stderr, "Error: invalid timestamp in file. Your clock or the collector's is wrong (%d sec ahead).\n", head.packet_file_stamp-now);
|
||||
fclose(in);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
packet_file_stamp = head.packet_file_stamp;
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -387,14 +387,14 @@ bool NewPacketFileReader::ResetFile() {
|
||||
if(in == NULL)
|
||||
return(false);
|
||||
rewind(in);
|
||||
|
||||
|
||||
//gotta read past the header again
|
||||
PacketFileHeader head;
|
||||
|
||||
|
||||
if(fread(&head, sizeof(head), 1, in) != 1) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -403,23 +403,23 @@ bool NewPacketFileReader::ReadPacket(uint16 &eq_op, uint32 &packlen, unsigned ch
|
||||
return(false);
|
||||
if(feof(in))
|
||||
return(false);
|
||||
|
||||
|
||||
PacketFileSection s;
|
||||
|
||||
|
||||
if(fread(&s, sizeof(s), 1, in) != 1) {
|
||||
if(!feof(in))
|
||||
fprintf(stderr, "Error reading section header: %s\n", strerror(errno));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
eq_op = s.opcode;
|
||||
|
||||
|
||||
if(packlen < s.len) {
|
||||
fprintf(stderr, "Packet buffer is too small! %d < %d, skipping\n", packlen, s.len);
|
||||
fseek(in, s.len, SEEK_CUR);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
if(fread(packet, 1, s.len, in) != s.len) {
|
||||
if(feof(in))
|
||||
fprintf(stderr, "Error: EOF encountered when expecting packet data.\n");
|
||||
@ -427,12 +427,12 @@ bool NewPacketFileReader::ReadPacket(uint16 &eq_op, uint32 &packlen, unsigned ch
|
||||
fprintf(stderr, "Error reading packet body: %s\n", strerror(errno));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
packlen = s.len;
|
||||
to_server = IsToServer(s);
|
||||
tv.tv_sec = s.tv_sec;
|
||||
tv.tv_usec = 1000*s.tv_msec;
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
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