Remove trailing whitespace

This commit is contained in:
j883376
2013-05-06 13:07:41 -04:00
parent 7a93966158
commit ffcff4aea1
548 changed files with 16397 additions and 16398 deletions
+5 -5
View File
@@ -37,25 +37,25 @@ IF(MSVC)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86") SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86") SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86")
ENDIF(CMAKE_CL_64) ENDIF(CMAKE_CL_64)
#disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere #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) OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON)
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS) IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS) ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
#fast FP if you'd like it #fast FP if you'd like it
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON) OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
IF(EQEMU_FAST_FLOATINGPOINT) IF(EQEMU_FAST_FLOATINGPOINT)
ADD_DEFINITIONS(/fp:fast) ADD_DEFINITIONS(/fp:fast)
ENDIF(EQEMU_FAST_FLOATINGPOINT) ENDIF(EQEMU_FAST_FLOATINGPOINT)
#crash logging currently only works on windows x86/x64 #crash logging currently only works on windows x86/x64
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON) OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
IF(EQEMU_ENABLE_CRASH_LOGGING) IF(EQEMU_ENABLE_CRASH_LOGGING)
ADD_DEFINITIONS(-DCRASH_LOGGING) ADD_DEFINITIONS(-DCRASH_LOGGING)
ENDIF(EQEMU_ENABLE_CRASH_LOGGING) ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
#Disable safe SEH or not? #Disable safe SEH or not?
OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF) OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF)
IF(EQEMU_DISABLE_SAFESEH) 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_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
SET(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO") SET(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
ENDIF(EQEMU_DISABLE_SAFESEH) ENDIF(EQEMU_DISABLE_SAFESEH)
#We want to compile /MT not /MD so we change that #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) 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") IF(${flag_var} MATCHES "/MD")
+2 -3
View File
@@ -37,7 +37,7 @@ IF(MYSQL_ROOT)
PATHS ${MYSQL_ROOT}/lib/debug /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 PATHS ${MYSQL_ROOT}/lib/debug /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
FIND_LIBRARY(MySQL_LIBRARY_RELEASE FIND_LIBRARY(MySQL_LIBRARY_RELEASE
NAMES ${MySQL_NAMES} NAMES ${MySQL_NAMES}
PATHS ${MYSQL_ROOT}/lib /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 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 PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
FIND_LIBRARY(MySQL_LIBRARY_RELEASE FIND_LIBRARY(MySQL_LIBRARY_RELEASE
NAMES ${MySQL_NAMES} NAMES ${MySQL_NAMES}
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
@@ -82,4 +82,3 @@ MARK_AS_ADVANCED(
MySQL_LIBRARY_RELEASE MySQL_LIBRARY_RELEASE
MySQL_INCLUDE_DIR MySQL_INCLUDE_DIR
) )
+3 -3
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -108,7 +108,7 @@ void BasePacket::ReadString(char *str, uint32 Offset, uint32 MaxLength) const
while((j < size) && (i < MaxLength) && (str[i - 1] != 0)); while((j < size) && (i < MaxLength) && (str[i - 1] != 0));
str[i - 1] = '\0'; str[i - 1] = '\0';
} }
void DumpPacketHex(const BasePacket* app) void DumpPacketHex(const BasePacket* app)
{ {
+3 -3
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -71,7 +71,7 @@ public:
uint32 ReadUInt32(uint32 Offset) const { uint32 value = *(uint32 *)(pBuffer + Offset); return value; } 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 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; void ReadString(char *str, uint32 Offset, uint32 MaxLength) const;
uint32 GetWritePosition() { return _wpos; } uint32 GetWritePosition() { return _wpos; }
uint32 GetReadPosition() { return _rpos; } uint32 GetReadPosition() { return _rpos; }
void SetWritePosition(uint32 Newwpos) { _wpos = Newwpos; } void SetWritePosition(uint32 Newwpos) { _wpos = Newwpos; }
+1 -1
View File
@@ -1,6 +1,6 @@
#include "crc32.h" #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 // 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. // where the key is prepended to the data in little endian order.
+10 -10
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -29,7 +29,7 @@
#ifdef _WINDOWS #ifdef _WINDOWS
Condition::Condition() Condition::Condition()
{ {
m_events[SignalEvent] = CreateEvent (nullptr, // security m_events[SignalEvent] = CreateEvent (nullptr, // security
FALSE, // is auto-reset event? FALSE, // is auto-reset event?
@@ -69,28 +69,28 @@ void Condition::SignalAll()
void Condition::Wait() void Condition::Wait()
{ {
EnterCriticalSection(&CSMutex); EnterCriticalSection(&CSMutex);
m_waiters++; m_waiters++;
LeaveCriticalSection(&CSMutex); LeaveCriticalSection(&CSMutex);
int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE); int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE);
EnterCriticalSection(&CSMutex); EnterCriticalSection(&CSMutex);
m_waiters--; m_waiters--;
//see if we are the last person waiting on the condition, and there was a broadcast //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 so, we need to reset the broadcast event.
if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent)) if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent))
ResetEvent(m_events[BroadcastEvent]); ResetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex); LeaveCriticalSection(&CSMutex);
} }
#else //!WIN32 #else //!WIN32
Condition::Condition() Condition::Condition()
{ {
pthread_cond_init(&cond,nullptr); pthread_cond_init(&cond,nullptr);
pthread_mutex_init(&mutex,nullptr); pthread_mutex_init(&mutex,nullptr);
+2 -2
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+4 -4
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -64,9 +64,9 @@ EQDBRes * EQDB::query(Const_char *q) {
Const_char *EQDB::escape_string(Const_char *from) { Const_char *EQDB::escape_string(Const_char *from) {
int len = strlen(from); int len = strlen(from);
char *res = new char[len*2+1]; char *res = new char[len*2+1];
mysql_real_escape_string(mysql_ref,res,from,len); mysql_real_escape_string(mysql_ref,res,from,len);
res[len*2] = '\0'; res[len*2] = '\0';
m_escapeBuffer = res; m_escapeBuffer = res;
delete[] res; delete[] res;
+4 -4
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -32,10 +32,10 @@ public:
static EQDB *Singleton() { return(&s_EQDB); } static EQDB *Singleton() { return(&s_EQDB); }
static void SetMySQL(MYSQL *m) { s_EQDB.mysql_ref=m; } static void SetMySQL(MYSQL *m) { s_EQDB.mysql_ref=m; }
//BEGIN PERL EXPORT //BEGIN PERL EXPORT
//NOTE: you must have a space after the * of a return value //NOTE: you must have a space after the * of a return value
unsigned int field_count(); unsigned int field_count();
unsigned long affected_rows(); unsigned long affected_rows();
unsigned long insert_id(); unsigned long insert_id();
+4 -4
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -23,7 +23,7 @@ vector<string> EQDBRes::fetch_row_array() {
vector<string> array; vector<string> array;
if(res == nullptr) if(res == nullptr)
return(array); return(array);
int count=mysql_num_fields(res); int count=mysql_num_fields(res);
MYSQL_ROW row=mysql_fetch_row(res); MYSQL_ROW row=mysql_fetch_row(res);
for (int i=0;i<count;i++) for (int i=0;i<count;i++)
@@ -36,7 +36,7 @@ map<string,string> EQDBRes::fetch_row_hash() {
map<string,string> rowhash; map<string,string> rowhash;
if(res == nullptr) if(res == nullptr)
return(rowhash); return(rowhash);
MYSQL_FIELD *fields; MYSQL_FIELD *fields;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long num_fields,i; unsigned long num_fields,i;
+3 -3
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -30,7 +30,7 @@ class EQDBRes {
public: public:
EQDBRes(MYSQL_RES *r) { res=r; } EQDBRes(MYSQL_RES *r) { res=r; }
~EQDBRes() { finish(); } ~EQDBRes() { finish(); }
//BEGIN PERL EXPORT //BEGIN PERL EXPORT
unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; } unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; }
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; } unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
+3 -3
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -71,7 +71,7 @@ void AddEQEMuError(eEQEMuError iError, bool iExitNow) {
} }
iterator.Advance(); iterator.Advance();
} }
char* tmp = new char[6]; char* tmp = new char[6];
tmp[0] = 1; tmp[0] = 1;
tmp[5] = 0; tmp[5] = 0;
+3 -3
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -20,7 +20,7 @@
#include "../common/types.h" #include "../common/types.h"
enum eEQEMuError { EQEMuError_NoError, enum eEQEMuError { EQEMuError_NoError,
EQEMuError_Mysql_1405, EQEMuError_Mysql_1405,
EQEMuError_Mysql_2003, EQEMuError_Mysql_2003,
EQEMuError_Mysql_2005, EQEMuError_Mysql_2005,
+8 -8
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -63,7 +63,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
text=ParseTextBlock(sub_ele,"port",true); text=ParseTextBlock(sub_ele,"port",true);
if (text) if (text)
LoginPort=atoi(text); LoginPort=atoi(text);
text=ParseTextBlock(sub_ele,"account",true); text=ParseTextBlock(sub_ele,"account",true);
if (text) if (text)
LoginAccount=text; LoginAccount=text;
@@ -97,7 +97,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
} }
} while(sub_ele); } while(sub_ele);
} }
// Check for locked // Check for locked
sub_ele = ele->FirstChildElement("locked"); sub_ele = ele->FirstChildElement("locked");
if (sub_ele != nullptr) if (sub_ele != nullptr)
@@ -140,7 +140,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
text = sub_ele->Attribute("enabled"); text = sub_ele->Attribute("enabled");
if (text && !strcasecmp(text,"true")) if (text && !strcasecmp(text,"true"))
WorldHTTPEnabled=true; WorldHTTPEnabled=true;
} }
} }
@@ -155,7 +155,7 @@ void EQEmuConfig::do_chatserver(TiXmlElement *ele) {
if (text) if (text)
ChatPort=atoi(text); ChatPort=atoi(text);
} }
void EQEmuConfig::do_mailserver(TiXmlElement *ele) { void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
const char *text; const char *text;
@@ -167,7 +167,7 @@ void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
if (text) if (text)
MailPort=atoi(text); MailPort=atoi(text);
} }
void EQEmuConfig::do_database(TiXmlElement *ele) { void EQEmuConfig::do_database(TiXmlElement *ele) {
const char *text; const char *text;
@@ -192,7 +192,7 @@ void EQEmuConfig::do_database(TiXmlElement *ele) {
DatabaseDB=text; DatabaseDB=text;
} }
void EQEmuConfig::do_qsdatabase(TiXmlElement *ele) { void EQEmuConfig::do_qsdatabase(TiXmlElement *ele) {
const char *text; const char *text;
+14 -14
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -52,11 +52,11 @@ public:
uint16 WorldHTTPPort; uint16 WorldHTTPPort;
string WorldHTTPMimeFile; string WorldHTTPMimeFile;
string SharedKey; string SharedKey;
// From <chatserver/> // From <chatserver/>
string ChatHost; string ChatHost;
uint16 ChatPort; uint16 ChatPort;
// From <mailserver/> // From <mailserver/>
string MailHost; string MailHost;
uint16 MailPort; uint16 MailPort;
@@ -85,7 +85,7 @@ public:
string MapDir; string MapDir;
string QuestDir; string QuestDir;
string PluginDir; string PluginDir;
// From <launcher/> // From <launcher/>
string LogPrefix; string LogPrefix;
string LogSuffix; string LogSuffix;
@@ -103,7 +103,7 @@ public:
// uint16 DynamicCount; // uint16 DynamicCount;
// map<string,uint16> StaticZones; // map<string,uint16> StaticZones;
protected: protected:
static EQEmuConfig *_config; static EQEmuConfig *_config;
@@ -168,7 +168,7 @@ protected:
MapDir="Maps"; MapDir="Maps";
QuestDir="quests"; QuestDir="quests";
PluginDir="plugins"; PluginDir="plugins";
// Launcher // Launcher
LogPrefix = "logs/zone-"; LogPrefix = "logs/zone-";
LogSuffix = ".log"; LogSuffix = ".log";
@@ -181,22 +181,22 @@ protected:
#else #else
ZoneExe = "./zone"; ZoneExe = "./zone";
#endif #endif
// Zones // Zones
ZonePortLow=7000; ZonePortLow=7000;
ZonePortHigh=7999; ZonePortHigh=7999;
DefaultStatus=0; DefaultStatus=0;
// For where zones need to connect to. // For where zones need to connect to.
WorldIP="127.0.0.1"; WorldIP="127.0.0.1";
// Dynamics to start // Dynamics to start
//DynamicCount=5; //DynamicCount=5;
MaxClients=-1; MaxClients=-1;
LoginCount=0; LoginCount=0;
} }
virtual ~EQEmuConfig() {} virtual ~EQEmuConfig() {}
@@ -204,7 +204,7 @@ public:
// Produce a const singleton // Produce a const singleton
static const EQEmuConfig *get() { static const EQEmuConfig *get() {
if (_config == nullptr) if (_config == nullptr)
LoadConfig(); LoadConfig();
return(_config); return(_config);
} }
+15 -15
View File
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* /*
* EQStream classes, by Quagmire * EQStream classes, by Quagmire
*/ */
@@ -61,17 +61,17 @@ using namespace std;
//#define PRIORITYTEST //#define PRIORITYTEST
template <typename type> // LO_BYTE template <typename type> // LO_BYTE
type LO_BYTE (type a) {return (a&=0xff);} type LO_BYTE (type a) {return (a&=0xff);}
template <typename type> // HI_BYTE template <typename type> // HI_BYTE
type HI_BYTE (type a) {return (a&=0xff00);} type HI_BYTE (type a) {return (a&=0xff00);}
template <typename type> // LO_WORD template <typename type> // LO_WORD
type LO_WORD (type a) {return (a&=0xffff);} type LO_WORD (type a) {return (a&=0xffff);}
template <typename type> // HI_WORD template <typename type> // HI_WORD
type HI_WORD (type a) {return (a&=0xffff0000);} type HI_WORD (type a) {return (a&=0xffff0000);}
template <typename type> // HI_LOSWAPshort 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 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) { EQStreamServer::EQStreamServer(uint16 iPort) {
RunLoop = false; RunLoop = false;
@@ -125,7 +125,7 @@ bool EQStreamServer::Open(uint16 iPort) {
unsigned long nonblocking = 1; unsigned long nonblocking = 1;
#endif #endif
/* Setup internet address information. /* Setup internet address information.
This is used with the bind() call */ This is used with the bind() call */
memset((char *) &address, 0, sizeof(address)); memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET; address.sin_family = AF_INET;
@@ -207,7 +207,7 @@ void EQStreamServer::Process() {
} }
uchar buffer[1518]; uchar buffer[1518];
int status; int status;
struct sockaddr_in from; struct sockaddr_in from;
unsigned int fromlen; unsigned int fromlen;
@@ -240,13 +240,13 @@ void EQStreamServer::Process() {
connection_list.erase(tmp); connection_list.erase(tmp);
continue; continue;
} }
EQStream* eqs_data = connection->second; EQStream* eqs_data = connection->second;
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) { if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
map <string, EQStream*>::iterator tmp=connection; map <string, EQStream*>::iterator tmp=connection;
connection++; connection++;
safe_delete(eqs_data); safe_delete(eqs_data);
connection_list.erase(tmp); connection_list.erase(tmp);
} }
else if(!eqs_data->RunLoop) { else if(!eqs_data->RunLoop) {
eqs_data->Process(sock); eqs_data->Process(sock);
connection++; connection++;
@@ -291,7 +291,7 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
return; return;
} }
if (data[1]==0x01) { if (data[1]==0x01) {
cout << "New EQStream Connection." << endl; cout << "New EQStream Connection." << endl;
EQStream* tmp = new EQStream(irIP, irPort); EQStream* tmp = new EQStream(irIP, irPort);
tmp->RecvData(data, size); tmp->RecvData(data, size);
+11 -11
View File
@@ -1,4 +1,4 @@
/* /*
Copyright (C) 2005 Michael S. Finger Copyright (C) 2005 Michael S. Finger
This program is free software; you can redistribute it and/or modify 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 { void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
BasePacket::build_raw_header_dump(buffer, seq); BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer); buffer += strlen(buffer);
buffer += sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]\n", emu_opcode, size); 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) if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq); fprintf(to, "[Seq=%u] ",seq);
fprintf(to, "[EmuOpCode 0x%04x Size=%lu]\n",emu_opcode,(unsigned long)size); 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); BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer); buffer += strlen(buffer);
buffer += sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]\n",opcode,size); 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) if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq); fprintf(to, "[Seq=%u] ",seq);
fprintf(to, "[ProtoOpCode 0x%04x Size=%lu]\n",opcode,(unsigned long)size); 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); BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer); buffer += strlen(buffer);
#ifdef STATIC_OPCODE #ifdef STATIC_OPCODE
buffer += sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size); buffer += sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
#else #else
@@ -144,7 +144,7 @@ void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
} }
if (seq != 0xffff) if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq); fprintf(to, "[Seq=%u] ",seq);
#ifdef STATIC_OPCODE #ifdef STATIC_OPCODE
fprintf(to, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size); fprintf(to, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
#else #else
@@ -156,7 +156,7 @@ void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) con
{ {
BasePacket::build_raw_header_dump(buffer, seq); BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer); buffer += strlen(buffer);
#ifdef STATIC_OPCODE #ifdef STATIC_OPCODE
buffer += sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size); buffer += sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
#else #else
@@ -190,7 +190,7 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
} }
if (seq != 0xffff) if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq); fprintf(to, "[Seq=%u] ",seq);
#ifdef STATIC_OPCODE #ifdef STATIC_OPCODE
fprintf(to, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size); fprintf(to, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
#else #else
@@ -421,7 +421,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
{ {
test[i]=buffer[i]^KC; test[i]=buffer[i]^KC;
} }
memcpy(buffer,test,size); memcpy(buffer,test,size);
free(test); free(test);
} }
} }
@@ -445,7 +445,7 @@ void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey
{ {
test[i]=buffer[i]^KC; test[i]=buffer[i]^KC;
} }
memcpy(buffer,test,size); memcpy(buffer,test,size);
free(test); free(test);
} }
} }
+22 -22
View File
@@ -1,4 +1,4 @@
/* /*
Copyright (C) 2005 Michael S. Finger Copyright (C) 2005 Michael S. Finger
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -39,9 +39,9 @@ class EQPacket : public BasePacket {
friend class EQStream; friend class EQStream;
public: public:
virtual ~EQPacket() {} virtual ~EQPacket() {}
uint32 Size() const { return size+2; } uint32 Size() const { return size+2; }
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const; virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const; virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const; virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
@@ -50,7 +50,7 @@ public:
void SetOpcode(EmuOpcode op) { emu_opcode = op; } void SetOpcode(EmuOpcode op) { emu_opcode = op; }
const EmuOpcode GetOpcode() const { return(emu_opcode); } const EmuOpcode GetOpcode() const { return(emu_opcode); }
// const char *GetOpcodeName() const; // const char *GetOpcodeName() const;
protected: protected:
//this is just a cache so we dont look it up several times on Get() //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 //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 EQStream;
friend class EQStreamPair; friend class EQStreamPair;
public: 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); // EQProtocolPacket(const unsigned char *buf, uint32 len);
bool combine(const EQProtocolPacket *rhs); bool combine(const EQProtocolPacket *rhs);
uint32 serialize (unsigned char *dest) const; uint32 serialize (unsigned char *dest) const;
EQProtocolPacket *Copy() { return new EQProtocolPacket(opcode,pBuffer,size); } EQProtocolPacket *Copy() { return new EQProtocolPacket(opcode,pBuffer,size); }
EQRawApplicationPacket *MakeAppPacket() const; EQRawApplicationPacket *MakeAppPacket() const;
bool acked; bool acked;
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const; virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const; virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const; virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const; virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
protected: protected:
static bool ValidateCRC(const unsigned char *buffer, int length, uint32 Key); 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 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 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 ChatDecode(unsigned char *buffer, int size, int DecodeKey);
static void ChatEncode(unsigned char *buffer, int size, int EncodeKey); static void ChatEncode(unsigned char *buffer, int size, int EncodeKey);
uint16 GetRawOpcode() const { return(opcode); } uint16 GetRawOpcode() const { return(opcode); }
uint32 Size() const { return size+2; } uint32 Size() const { return size+2; }
//the actual raw EQ opcode //the actual raw EQ opcode
uint16 opcode; uint16 opcode;
}; };
@@ -102,25 +102,25 @@ class EQApplicationPacket : public EQPacket {
// friend class EQProtocolPacket; // friend class EQProtocolPacket;
friend class EQStream; friend class EQStream;
public: public:
EQApplicationPacket() : EQPacket(OP_Unknown,nullptr,0) EQApplicationPacket() : EQPacket(OP_Unknown,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } { 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; } { 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; } { 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; } { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
bool combine(const EQApplicationPacket *rhs); bool combine(const EQApplicationPacket *rhs);
uint32 serialize (uint16 opcode, unsigned char *dest) const; uint32 serialize (uint16 opcode, unsigned char *dest) const;
uint32 Size() const { return size+app_opcode_size; } uint32 Size() const { return size+app_opcode_size; }
virtual EQApplicationPacket *Copy() const; virtual EQApplicationPacket *Copy() const;
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const; virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const; virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const; virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const; virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
protected: protected:
uint8 app_opcode_size; uint8 app_opcode_size;
@@ -135,17 +135,17 @@ class EQRawApplicationPacket : public EQApplicationPacket {
public: public:
EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len); EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len);
uint16 GetRawOpcode() const { return(opcode); } uint16 GetRawOpcode() const { return(opcode); }
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const; virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const; virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const; virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const; virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
protected: protected:
//the actual raw EQ opcode //the actual raw EQ opcode
uint16 opcode; uint16 opcode;
EQRawApplicationPacket(const unsigned char *buf, const uint32 len); EQRawApplicationPacket(const unsigned char *buf, const uint32 len);
}; };
+55 -55
View File
@@ -1,4 +1,4 @@
/* /*
Copyright (C) 2005 Michael S. Finger Copyright (C) 2005 Michael S. Finger
This program is free software; you can redistribute it and/or modify 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) { EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32 len) {
uint16 proto_opcode = ntohs(*(const uint16 *)buf); uint16 proto_opcode = ntohs(*(const uint16 *)buf);
//advance over opcode. //advance over opcode.
buf += 2; buf += 2;
len -= 2; len -= 2;
return(new EQProtocolPacket(proto_opcode, buf, len)); return(new EQProtocolPacket(proto_opcode, buf, len));
} }
@@ -149,7 +149,7 @@ uint32 processed=0,subpacket_length=0;
} }
} }
break; break;
case OP_AppCombined: { case OP_AppCombined: {
processed=0; processed=0;
while(processed<p->size) { while(processed<p->size) {
@@ -171,7 +171,7 @@ uint32 processed=0,subpacket_length=0;
} }
} }
break; break;
case OP_Packet: { case OP_Packet: {
if(!p->pBuffer || (p->Size() < 4)) if(!p->pBuffer || (p->Size() < 4))
{ {
@@ -221,7 +221,7 @@ uint32 processed=0,subpacket_length=0;
} }
} }
break; break;
case OP_Fragment: { case OP_Fragment: {
if(!p->pBuffer || (p->Size() < 4)) if(!p->pBuffer || (p->Size() < 4))
{ {
@@ -317,10 +317,10 @@ uint32 processed=0,subpacket_length=0;
#ifndef COLLECTOR #ifndef COLLECTOR
if (GetState()==ESTABLISHED) { if (GetState()==ESTABLISHED) {
_log(NET__ERROR, _L "Received OP_SessionRequest in ESTABLISHED state (%d)" __L, GetState()); _log(NET__ERROR, _L "Received OP_SessionRequest in ESTABLISHED state (%d)" __L, GetState());
/*RemoveData(); /*RemoveData();
init(); init();
State=UNESTABLISHED;*/ State=UNESTABLISHED;*/
_SendDisconnect(); _SendDisconnect();
SetState(CLOSED); SetState(CLOSED);
break; break;
@@ -360,7 +360,7 @@ uint32 processed=0,subpacket_length=0;
encoded=(Response->Format&FLAG_ENCODED); 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"); _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 // Kinda kludgy, but trie for now
if (StreamType==UnknownStream) { if (StreamType==UnknownStream) {
if (compressed) { if (compressed) {
@@ -406,7 +406,7 @@ uint32 processed=0,subpacket_length=0;
#ifndef COLLECTOR #ifndef COLLECTOR
uint16 seq=ntohs(*(uint16 *)(p->pBuffer)); uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
MOutboundQueue.lock(); MOutboundQueue.lock();
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { 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); _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 #ifndef COLLECTOR
SessionStats *Stats=(SessionStats *)p->pBuffer; 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, _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->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->low_delta), (unsigned long)ntohl(Stats->average_delta),
(unsigned long)ntohl(Stats->high_delta), (unsigned long)ntohl(Stats->last_remote_delta)); (unsigned long)ntohl(Stats->high_delta), (unsigned long)ntohl(Stats->last_remote_delta));
uint64 x=Stats->packets_received; uint64 x=Stats->packets_received;
Stats->packets_received=Stats->packets_sent; Stats->packets_received=Stats->packets_sent;
@@ -502,7 +502,7 @@ void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
{ {
if(p == nullptr) if(p == nullptr)
return; return;
EQApplicationPacket *newp = p->Copy(); EQApplicationPacket *newp = p->Copy();
if (newp != nullptr) if (newp != nullptr)
@@ -513,18 +513,18 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
{ {
EQApplicationPacket *pack=*p; EQApplicationPacket *pack=*p;
*p = nullptr; //clear caller's pointer.. effectively takes ownership *p = nullptr; //clear caller's pointer.. effectively takes ownership
if(pack == nullptr) if(pack == nullptr)
return; return;
if(OpMgr == nullptr || *OpMgr == nullptr) { if(OpMgr == nullptr || *OpMgr == nullptr) {
_log(NET__DEBUG, _L "Packet enqueued into a stream with no opcode manager, dropping." __L); _log(NET__DEBUG, _L "Packet enqueued into a stream with no opcode manager, dropping." __L);
delete pack; delete pack;
return; return;
} }
uint16 opcode = (*OpMgr)->EmuToEQ(pack->emu_opcode); uint16 opcode = (*OpMgr)->EmuToEQ(pack->emu_opcode);
//make sure this packet is compatible with this stream //make sure this packet is compatible with this stream
/* if(StreamType == UnknownStream || StreamType == ChatOrMailStream) { /* if(StreamType == UnknownStream || StreamType == ChatOrMailStream) {
_log(NET__DEBUG, _L "Stream type undetermined (%s), packet ignored" __L, StreamTypeString(StreamType)); _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)); _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; 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); _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) { if (!ack_req) {
NonSequencedPush(new EQProtocolPacket(opcode, pack->pBuffer, pack->size)); NonSequencedPush(new EQProtocolPacket(opcode, pack->pBuffer, pack->size));
delete pack; delete pack;
@@ -556,15 +556,15 @@ uint32 length;
unsigned char *tmpbuff=new unsigned char[p->size+3]; unsigned char *tmpbuff=new unsigned char[p->size+3];
length=p->serialize(opcode, tmpbuff); length=p->serialize(opcode, tmpbuff);
EQProtocolPacket *out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4); EQProtocolPacket *out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
*(uint32 *)(out->pBuffer+2)=htonl(p->Size()); *(uint32 *)(out->pBuffer+2)=htonl(p->Size());
used=MaxLen-10; used=MaxLen-10;
memcpy(out->pBuffer+6,tmpbuff,used); 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()); _log(NET__FRAGMENT, _L "First fragment: used %d/%d. Put size %d in the packet" __L, used, p->size, p->Size());
SequencedPush(out); SequencedPush(out);
while (used<length) { while (used<length) {
out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4); out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
chunksize=min(length-used,MaxLen-6); chunksize=min(length-used,MaxLen-6);
@@ -684,7 +684,7 @@ deque<EQProtocolPacket *>::iterator sitr;
sitr = SequencedQueue.begin(); sitr = SequencedQueue.begin();
if (sitr!=SequencedQueue.end()) if (sitr!=SequencedQueue.end())
sitr += NextSequencedSend; sitr += NextSequencedSend;
// Loop until both are empty or MaxSends is reached // Loop until both are empty or MaxSends is reached
while(!SeqEmpty || !NonSeqEmpty) { while(!SeqEmpty || !NonSeqEmpty) {
@@ -703,7 +703,7 @@ deque<EQProtocolPacket *>::iterator sitr;
ReadyToSend.push(p); ReadyToSend.push(p);
BytesWritten+=p->size; BytesWritten+=p->size;
p=nullptr; p=nullptr;
if (BytesWritten > threshold) { if (BytesWritten > threshold) {
// Sent enough this round, lets stop to be fair // Sent enough this round, lets stop to be fair
_log(NET__RATES, _L "Exceeded write threshold in nonseq (%d > %d)" __L, BytesWritten, threshold); _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()) { 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()); // SequencedQueue.size(), SequencedBase, NextSequencedSend, NonSequencedQueue.size());
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { 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); _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; delete p;
ReadyToSend.pop(); ReadyToSend.pop();
} }
//see if we need to send our disconnect and finish our close //see if we need to send our disconnect and finish our close
if(SeqEmpty && NonSeqEmpty) { if(SeqEmpty && NonSeqEmpty) {
//no more data to send //no more data to send
@@ -825,7 +825,7 @@ sockaddr_in address;
address.sin_port=remote_port; address.sin_port=remote_port;
#ifdef NOWAY #ifdef NOWAY
uint32 ip=address.sin_addr.s_addr; uint32 ip=address.sin_addr.s_addr;
cout << "Sending to: " cout << "Sending to: "
<< (int)*(unsigned char *)&ip << (int)*(unsigned char *)&ip
<< "." << (int)*((unsigned char *)&ip+1) << "." << (int)*((unsigned char *)&ip+1)
<< "." << (int)*((unsigned char *)&ip+2) << "." << (int)*((unsigned char *)&ip+2)
@@ -886,7 +886,7 @@ char temp[15];
ntohs(from->sin_port)); ntohs(from->sin_port));
//cout << timestamp() << "Data from: " << temp << " OpCode 0x" << hex << setw(2) << setfill('0') << (int)p->opcode << dec << endl; //cout << timestamp() << "Data from: " << temp << " OpCode 0x" << hex << setw(2) << setfill('0') << (int)p->opcode << dec << endl;
//dump_message(p->pBuffer,p->size,timestamp()); //dump_message(p->pBuffer,p->size,timestamp());
} }
return p; return p;
}*/ }*/
@@ -904,12 +904,12 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(Ses
if (encoded) if (encoded)
Response->Format|=FLAG_ENCODED; Response->Format|=FLAG_ENCODED;
Response->Key=htonl(Key); Response->Key=htonl(Key);
out->size=sizeof(SessionResponse); out->size=sizeof(SessionResponse);
_log(NET__NET_TRACE, _L "Sending OP_SessionResponse: session %lu, maxlen=%d, key=0x%x, compressed? %s, encoded? %s" __L, _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"); (unsigned long)Session, MaxLen, Key, compressed?"yes":"no", encoded?"yes":"no");
NonSequencedPush(out); NonSequencedPush(out);
} }
@@ -920,9 +920,9 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(Sess
memset(Request,0,sizeof(SessionRequest)); memset(Request,0,sizeof(SessionRequest));
Request->Session=htonl(time(nullptr)); Request->Session=htonl(time(nullptr));
Request->MaxLength=htonl(512); 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)); _log(NET__NET_TRACE, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength));
NonSequencedPush(out); NonSequencedPush(out);
} }
@@ -930,11 +930,11 @@ void EQStream::_SendDisconnect()
{ {
if(GetState() == CLOSED) if(GetState() == CLOSED)
return; return;
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionDisconnect,nullptr,sizeof(uint32)); EQProtocolPacket *out=new EQProtocolPacket(OP_SessionDisconnect,nullptr,sizeof(uint32));
*(uint32 *)out->pBuffer=htonl(Session); *(uint32 *)out->pBuffer=htonl(Session);
NonSequencedPush(out); NonSequencedPush(out);
_log(NET__NET_TRACE, _L "Sending OP_SessionDisconnect: session %lu" __L, (unsigned long)Session); _log(NET__NET_TRACE, _L "Sending OP_SessionDisconnect: session %lu" __L, (unsigned long)Session);
} }
@@ -956,7 +956,7 @@ EQRawApplicationPacket *p=nullptr;
InboundQueue.erase(itr); InboundQueue.erase(itr);
} }
MInboundQueue.unlock(); MInboundQueue.unlock();
//resolve the opcode if we can. //resolve the opcode if we can.
if(p) { if(p) {
if(OpMgr != nullptr && *OpMgr != nullptr) { if(OpMgr != nullptr && *OpMgr != nullptr) {
@@ -969,7 +969,7 @@ EQRawApplicationPacket *p=nullptr;
p->SetOpcode(emu_op); p->SetOpcode(emu_op);
} }
} }
return p; return p;
} }
@@ -984,7 +984,7 @@ EQRawApplicationPacket *p=nullptr;
InboundQueue.erase(itr); InboundQueue.erase(itr);
} }
MInboundQueue.unlock(); MInboundQueue.unlock();
//resolve the opcode if we can. //resolve the opcode if we can.
if(p) { if(p) {
if(OpMgr != nullptr && *OpMgr != nullptr) { if(OpMgr != nullptr && *OpMgr != nullptr) {
@@ -1018,9 +1018,9 @@ EQRawApplicationPacket *p=nullptr;
void EQStream::InboundQueueClear() void EQStream::InboundQueueClear()
{ {
EQApplicationPacket *p=nullptr; EQApplicationPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing inbound queue" __L); _log(NET__APP_TRACE, _L "Clearing inbound queue" __L);
MInboundQueue.lock(); MInboundQueue.lock();
if (!InboundQueue.empty()) { if (!InboundQueue.empty()) {
vector<EQRawApplicationPacket *>::iterator itr; vector<EQRawApplicationPacket *>::iterator itr;
@@ -1036,11 +1036,11 @@ EQApplicationPacket *p=nullptr;
bool EQStream::HasOutgoingData() bool EQStream::HasOutgoingData()
{ {
bool flag; bool flag;
//once closed, we have nothing more to say //once closed, we have nothing more to say
if(CheckClosed()) if(CheckClosed())
return(false); return(false);
MOutboundQueue.lock(); MOutboundQueue.lock();
flag=(!NonSequencedQueue.empty()); flag=(!NonSequencedQueue.empty());
if (!flag) { if (!flag) {
@@ -1063,7 +1063,7 @@ void EQStream::OutboundQueueClear()
EQProtocolPacket *p=nullptr; EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing outbound queue" __L); _log(NET__APP_TRACE, _L "Clearing outbound queue" __L);
MOutboundQueue.lock(); MOutboundQueue.lock();
while(!NonSequencedQueue.empty()) { while(!NonSequencedQueue.empty()) {
delete NonSequencedQueue.front(); delete NonSequencedQueue.front();
@@ -1078,7 +1078,7 @@ EQProtocolPacket *p=nullptr;
SequencedQueue.clear(); SequencedQueue.clear();
} }
MOutboundQueue.unlock(); MOutboundQueue.unlock();
/*if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { /*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); _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; EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L); _log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
if(!PacketQueue.empty()) { if(!PacketQueue.empty()) {
map<unsigned short,EQProtocolPacket *>::iterator itr; map<unsigned short,EQProtocolPacket *>::iterator itr;
for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) { for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) {
@@ -1150,7 +1150,7 @@ long EQStream::GetLastAckSent()
void EQStream::AckPackets(uint16 seq) void EQStream::AckPackets(uint16 seq)
{ {
deque<EQProtocolPacket *>::iterator itr, tmp; deque<EQProtocolPacket *>::iterator itr, tmp;
MOutboundQueue.lock(); MOutboundQueue.lock();
//do a bit of sanity checking. //do a bit of sanity checking.
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
@@ -1159,7 +1159,7 @@ if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
if(NextSequencedSend > SequencedQueue.size()) { 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()); _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); SeqOrder ord = CompareSequence(SequencedBase, seq);
if(ord == SeqInOrder) { if(ord == SeqInOrder) {
//they are not acking anything new... //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()); _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(); MOutboundQueue.unlock();
} }
@@ -1222,7 +1222,7 @@ void EQStream::ProcessQueue()
if(PacketQueue.empty()) { if(PacketQueue.empty()) {
return; return;
} }
EQProtocolPacket *qp=nullptr; EQProtocolPacket *qp=nullptr;
while((qp=RemoveQueue(NextInSeq))!=nullptr) { while((qp=RemoveQueue(NextInSeq))!=nullptr) {
_log(NET__DEBUG, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq); _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) { void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
bool outgoing_data = HasOutgoingData(); //up here to avoid recursive locking bool outgoing_data = HasOutgoingData(); //up here to avoid recursive locking
EQStreamState orig_state = GetState(); EQStreamState orig_state = GetState();
if (orig_state == CLOSING && !outgoing_data) { if (orig_state == CLOSING && !outgoing_data) {
_log(NET__NET_TRACE, _L "Out of data in closing state, disconnecting." __L); _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) { EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
EQRawApplicationPacket *p = nullptr; EQRawApplicationPacket *p = nullptr;
MatchState res = MatchNotReady; MatchState res = MatchNotReady;
MInboundQueue.lock(); MInboundQueue.lock();
if (!InboundQueue.empty()) { if (!InboundQueue.empty()) {
//this is already getting hackish... //this is already getting hackish...
@@ -1444,7 +1444,7 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
} }
} }
MInboundQueue.unlock(); MInboundQueue.unlock();
return(res); return(res);
} }
+21 -21
View File
@@ -55,10 +55,10 @@ struct SessionStats {
/*030*/ uint64 packets_received; /*030*/ uint64 packets_received;
/*038*/ /*038*/
}; };
#pragma pack() #pragma pack()
class OpcodeManager; class OpcodeManager;
//extern OpcodeManager *EQNetworkOpcodeManager; //extern OpcodeManager *EQNetworkOpcodeManager;
//class EQStreamFactory; //class EQStreamFactory;
@@ -73,7 +73,7 @@ class EQStream : public EQStreamInterface {
SeqInOrder, SeqInOrder,
SeqFuture SeqFuture
} SeqOrder; } SeqOrder;
uint32 remote_ip; uint32 remote_ip;
uint16 remote_port; uint16 remote_port;
uint8 buffer[8192]; uint8 buffer[8192];
@@ -119,10 +119,10 @@ class EQStream : public EQStreamInterface {
uint16 SequencedBase; //the sequence number of SequencedQueue[0] uint16 SequencedBase; //the sequence number of SequencedQueue[0]
long NextSequencedSend; //index into SequencedQueue long NextSequencedSend; //index into SequencedQueue
Mutex MOutboundQueue; Mutex MOutboundQueue;
//a buffer we use for compression/decompression //a buffer we use for compression/decompression
unsigned char _tempBuffer[2048]; unsigned char _tempBuffer[2048];
// Packets waiting to be processed // Packets waiting to be processed
vector<EQRawApplicationPacket *> InboundQueue; vector<EQRawApplicationPacket *> InboundQueue;
map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process() 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 RateThreshold;
int32 DecayRate; int32 DecayRate;
OpcodeManager **OpMgr; OpcodeManager **OpMgr;
// EQStreamFactory *const Factory; // EQStreamFactory *const Factory;
EQRawApplicationPacket *MakeApplicationPacket(EQProtocolPacket *p); EQRawApplicationPacket *MakeApplicationPacket(EQProtocolPacket *p);
EQRawApplicationPacket *MakeApplicationPacket(const unsigned char *buf, uint32 len); EQRawApplicationPacket *MakeApplicationPacket(const unsigned char *buf, uint32 len);
EQProtocolPacket *MakeProtocolPacket(const unsigned char *buf, uint32 len); EQProtocolPacket *MakeProtocolPacket(const unsigned char *buf, uint32 len);
void SendPacket(uint16 opcode, EQApplicationPacket *p); void SendPacket(uint16 opcode, EQApplicationPacket *p);
void SetState(EQStreamState state); void SetState(EQStreamState state);
void SendSessionResponse(); void SendSessionResponse();
void SendSessionRequest(); void SendSessionRequest();
void SendAck(uint16 seq); void SendAck(uint16 seq);
@@ -157,7 +157,7 @@ class EQStream : public EQStreamInterface {
void NonSequencedPush(EQProtocolPacket *p); void NonSequencedPush(EQProtocolPacket *p);
void SequencedPush(EQProtocolPacket *p); void SequencedPush(EQProtocolPacket *p);
void WritePacket(int fd,EQProtocolPacket *p); void WritePacket(int fd,EQProtocolPacket *p);
uint32 GetKey() { return Key; } uint32 GetKey() { return Key; }
void SetKey(uint32 k) { Key=k; } void SetKey(uint32 k) { Key=k; }
@@ -172,16 +172,16 @@ class EQStream : public EQStreamInterface {
void InboundQueuePush(EQRawApplicationPacket *p); void InboundQueuePush(EQRawApplicationPacket *p);
EQRawApplicationPacket *PeekPacket(); //for collector. EQRawApplicationPacket *PeekPacket(); //for collector.
EQRawApplicationPacket *PopRawPacket(); //for collector. EQRawApplicationPacket *PopRawPacket(); //for collector.
void InboundQueueClear(); void InboundQueueClear();
void OutboundQueueClear(); void OutboundQueueClear();
void PacketQueueClear(); void PacketQueueClear();
void ProcessQueue(); void ProcessQueue();
EQProtocolPacket *RemoveQueue(uint16 seq); EQProtocolPacket *RemoveQueue(uint16 seq);
void _SendDisconnect(); void _SendDisconnect();
void init(); void init();
public: 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(); } 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 void RemoveData() { InboundQueueClear(); OutboundQueueClear(); PacketQueueClear(); /*if (CombinedAppPacket) delete CombinedAppPacket;*/ }
virtual bool CheckState(EQStreamState state) { return GetState() == state; } virtual bool CheckState(EQStreamState state) { return GetState() == state; }
virtual std::string Describe() const { return("Direct EQStream"); } virtual std::string Describe() const { return("Direct EQStream"); }
void SetOpcodeManager(OpcodeManager **opm) { OpMgr = opm; } void SetOpcodeManager(OpcodeManager **opm) { OpMgr = opm; }
void CheckTimeout(uint32 now, uint32 timeout=30); void CheckTimeout(uint32 now, uint32 timeout=30);
bool HasOutgoingData(); bool HasOutgoingData();
void Process(const unsigned char *data, const uint32 length); void Process(const unsigned char *data, const uint32 length);
void SetLastPacketTime(uint32 t) {LastPacket=t;} void SetLastPacketTime(uint32 t) {LastPacket=t;}
void Write(int eq_fd); void Write(int eq_fd);
// //
inline bool IsInUse() { bool flag; MInUse.lock(); flag=(active_users>0); MInUse.unlock(); return flag; } 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 void PutInUse() { MInUse.lock(); active_users++; MInUse.unlock(); }
inline EQStreamState GetState() { EQStreamState s; MState.lock(); s=State; MState.unlock(); return s; } inline EQStreamState GetState() { EQStreamState s; MState.lock(); s=State; MState.unlock(); return s; }
// static EQProtocolPacket *Read(int eq_fd, sockaddr_in *from); // static EQProtocolPacket *Read(int eq_fd, sockaddr_in *from);
static SeqOrder CompareSequence(uint16 expected_seq , uint16 seq); static SeqOrder CompareSequence(uint16 expected_seq , uint16 seq);
@@ -259,7 +259,7 @@ class EQStream : public EQStreamInterface {
return 0; return 0;
return bytes_recv / (Timer::GetTimeSeconds() - create_time); return bytes_recv / (Timer::GetTimeSeconds() - create_time);
} }
//used for dynamic stream identification //used for dynamic stream identification
class Signature { class Signature {
public: public:
@@ -274,7 +274,7 @@ class EQStream : public EQStreamInterface {
MatchFailed MatchFailed
} MatchState; } MatchState;
MatchState CheckSignature(const Signature *sig); MatchState CheckSignature(const Signature *sig);
}; };
+22 -22
View File
@@ -24,28 +24,28 @@ using namespace std;
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs) ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
{ {
EQStreamFactory *fs=(EQStreamFactory *)eqfs; EQStreamFactory *fs=(EQStreamFactory *)eqfs;
#ifndef WIN32 #ifndef WIN32
_log(COMMON__THREADS, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
#endif #endif
fs->ReaderLoop(); fs->ReaderLoop();
#ifndef WIN32 #ifndef WIN32
_log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(nullptr); THREAD_RETURN(nullptr);
} }
ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs) ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
{ {
EQStreamFactory *fs=(EQStreamFactory *)eqfs; EQStreamFactory *fs=(EQStreamFactory *)eqfs;
#ifndef WIN32 #ifndef WIN32
_log(COMMON__THREADS, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
#endif #endif
fs->WriterLoop(); fs->WriterLoop();
#ifndef WIN32 #ifndef WIN32
@@ -55,7 +55,7 @@ ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
THREAD_RETURN(nullptr); THREAD_RETURN(nullptr);
} }
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout) EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
: Timeoutable(5000), stream_timeout(timeout) : Timeoutable(5000), stream_timeout(timeout)
{ {
StreamType=type; StreamType=type;
@@ -81,7 +81,7 @@ struct sockaddr_in address;
#ifndef WIN32 #ifndef WIN32
pthread_t t1,t2; pthread_t t1,t2;
#endif #endif
/* Setup internet address information. /* Setup internet address information.
This is used with the bind() call */ This is used with the bind() call */
memset((char *) &address, 0, sizeof(address)); memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET; address.sin_family = AF_INET;
@@ -172,10 +172,10 @@ timeval sleep_time;
continue; continue;
} else if (num==0) } else if (num==0)
continue; continue;
if(sock == -1) if(sock == -1)
break; //somebody closed us while we were sleeping. break; //somebody closed us while we were sleeping.
if (FD_ISSET(sock,&readset)) { if (FD_ISSET(sock,&readset)) {
#ifdef _WINDOWS #ifdef _WINDOWS
if ((length=recvfrom(sock,(char*)buffer,sizeof(buffer),0,(struct sockaddr*)&from,(int *)&socklen)) < 2) if ((length=recvfrom(sock,(char*)buffer,sizeof(buffer),0,(struct sockaddr*)&from,(int *)&socklen)) < 2)
@@ -208,7 +208,7 @@ timeval sleep_time;
else else
curstream->PutInUse(); curstream->PutInUse();
MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it. MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it.
if(curstream) { if(curstream) {
curstream->AddBytesRecv(length); curstream->AddBytesRecv(length);
curstream->Process(buffer,length); curstream->Process(buffer,length);
@@ -225,17 +225,17 @@ void EQStreamFactory::CheckTimeout()
{ {
//lock streams the entire time were checking timeouts, it should be fast. //lock streams the entire time were checking timeouts, it should be fast.
MStreams.lock(); MStreams.lock();
unsigned long now=Timer::GetCurrentTime(); unsigned long now=Timer::GetCurrentTime();
map<string,EQStream *>::iterator stream_itr; map<string,EQStream *>::iterator stream_itr;
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) { for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
EQStream *s = stream_itr->second; EQStream *s = stream_itr->second;
s->CheckTimeout(now, stream_timeout); s->CheckTimeout(now, stream_timeout);
EQStreamState state = s->GetState(); EQStreamState state = s->GetState();
//not part of the else so we check it right away on state change //not part of the else so we check it right away on state change
if (state==CLOSED) { if (state==CLOSED) {
if (s->IsInUse()) { if (s->IsInUse()) {
@@ -267,7 +267,7 @@ bool decay=false;
uint32 stream_count; uint32 stream_count;
Timer DecayTimer(20); Timer DecayTimer(20);
WriterRunning=true; WriterRunning=true;
DecayTimer.Enable(); DecayTimer.Enable();
while(sock!=-1) { while(sock!=-1) {
@@ -278,12 +278,12 @@ Timer DecayTimer(20);
if (!WriterRunning) if (!WriterRunning)
break; break;
MWriterRunning.unlock(); MWriterRunning.unlock();
havework = false; havework = false;
wants_write.clear(); wants_write.clear();
decay=DecayTimer.Check(); decay=DecayTimer.Check();
//copy streams into a seperate list so we dont have to keep //copy streams into a seperate list so we dont have to keep
//MStreams locked while we are writting //MStreams locked while we are writting
MStreams.lock(); 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 it's time to decay the bytes sent, then let's do it before we try to write
if (decay) if (decay)
stream_itr->second->Decay(); stream_itr->second->Decay();
//bullshit checking, to see if this is really happening, GDB seems to think so... //bullshit checking, to see if this is really happening, GDB seems to think so...
if(stream_itr->second == nullptr) { if(stream_itr->second == nullptr) {
fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %s", stream_itr->first.c_str()); fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %s", stream_itr->first.c_str());
continue; continue;
} }
if (stream_itr->second->HasOutgoingData()) { if (stream_itr->second->HasOutgoingData()) {
havework=true; havework=true;
stream_itr->second->PutInUse(); stream_itr->second->PutInUse();
@@ -305,7 +305,7 @@ Timer DecayTimer(20);
} }
} }
MStreams.unlock(); MStreams.unlock();
//do the actual writes //do the actual writes
cur = wants_write.begin(); cur = wants_write.begin();
end = wants_write.end(); end = wants_write.end();
@@ -313,7 +313,7 @@ Timer DecayTimer(20);
(*cur)->Write(sock); (*cur)->Write(sock);
(*cur)->ReleaseFromUse(); (*cur)->ReleaseFromUse();
} }
Sleep(10); Sleep(10);
+1 -1
View File
@@ -23,7 +23,7 @@ class EQStreamFactory : private Timeoutable {
Condition WriterWork; Condition WriterWork;
EQStreamType StreamType; EQStreamType StreamType;
queue<EQStream *> NewStreams; queue<EQStream *> NewStreams;
Mutex MNewStreams; Mutex MNewStreams;
+13 -13
View File
@@ -39,12 +39,12 @@ void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const cha
void EQStreamIdentifier::Process() { void EQStreamIdentifier::Process() {
vector<Record *>::iterator cur; vector<Record *>::iterator cur;
vector<Patch *>::iterator curp, endp; vector<Patch *>::iterator curp, endp;
//foreach pending stream. //foreach pending stream.
cur = m_streams.begin(); cur = m_streams.begin();
while(cur != m_streams.end()) { while(cur != m_streams.end()) {
Record *r = *cur; Record *r = *cur;
//first see if this stream has expired //first see if this stream has expired
if(r->expire.Check(false)) { if(r->expire.Check(false)) {
//this stream has failed to match any pattern in our timeframe. //this stream has failed to match any pattern in our timeframe.
@@ -54,7 +54,7 @@ void EQStreamIdentifier::Process() {
cur = m_streams.erase(cur); cur = m_streams.erase(cur);
continue; continue;
} }
//then make sure the stream is still active //then make sure the stream is still active
//if stream hasn't finished initializing then continue; //if stream hasn't finished initializing then continue;
if(r->stream->GetState() == UNESTABLISHED) if(r->stream->GetState() == UNESTABLISHED)
@@ -87,18 +87,18 @@ void EQStreamIdentifier::Process() {
cur = m_streams.erase(cur); cur = m_streams.erase(cur);
continue; continue;
} }
//not expired, check against all patch signatures //not expired, check against all patch signatures
bool found_one = false; //"we found a matching patch for this stream" bool found_one = false; //"we found a matching patch for this stream"
bool all_ready = true; //"all signatures were ready to check the stream" bool all_ready = true; //"all signatures were ready to check the stream"
//foreach possbile patch... //foreach possbile patch...
curp = m_patches.begin(); curp = m_patches.begin();
endp = m_patches.end(); endp = m_patches.end();
for(; !found_one && curp != endp; curp++) { for(; !found_one && curp != endp; curp++) {
Patch *p = *curp; Patch *p = *curp;
//ask the stream to see if it matches the supplied signature //ask the stream to see if it matches the supplied signature
EQStream::MatchState res = r->stream->CheckSignature(&p->signature); EQStream::MatchState res = r->stream->CheckSignature(&p->signature);
switch(res) { switch(res) {
@@ -109,13 +109,13 @@ void EQStreamIdentifier::Process() {
break; break;
case EQStream::MatchSuccessful: { case EQStream::MatchSuccessful: {
//yay, a match. //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()); _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.. //might want to do something less-specific here... some day..
EQStreamInterface *s = new EQStreamProxy(r->stream, p->structs, p->opcodes); EQStreamInterface *s = new EQStreamProxy(r->stream, p->structs, p->opcodes);
m_identified.push(s); m_identified.push(s);
found_one = true; found_one = true;
break; break;
} }
@@ -125,14 +125,14 @@ void EQStreamIdentifier::Process() {
break; break;
} }
} }
//if we checked all patches and did not find a match. //if we checked all patches and did not find a match.
if(all_ready && !found_one) { if(all_ready && !found_one) {
//the stream cannot be identified. //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())); _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(); r->stream->ReleaseFromUse();
} }
//if we found a match, or were not able to identify it //if we found a match, or were not able to identify it
if(found_one || all_ready) { if(found_one || all_ready) {
//cannot print ip/port here. r->stream is invalid. //cannot print ip/port here. r->stream is invalid.
@@ -156,7 +156,7 @@ EQStreamInterface *EQStreamIdentifier::PopIdentified() {
m_identified.pop(); m_identified.pop();
return(res); return(res);
} }
EQStreamIdentifier::Record::Record(EQStream *s) EQStreamIdentifier::Record::Record(EQStream *s)
: stream(s), : stream(s),
expire(STREAM_IDENT_WAIT_MS) expire(STREAM_IDENT_WAIT_MS)
+5 -5
View File
@@ -15,17 +15,17 @@ class StructStrategy;
class EQStreamIdentifier { class EQStreamIdentifier {
public: public:
~EQStreamIdentifier(); ~EQStreamIdentifier();
//registration interface. //registration interface.
void RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs); void RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs);
//main processing interface //main processing interface
void Process(); void Process();
void AddStream(EQStream *& eqs); void AddStream(EQStream *& eqs);
EQStreamInterface *PopIdentified(); EQStreamInterface *PopIdentified();
protected: protected:
//registered patches.. //registered patches..
class Patch { class Patch {
public: public:
@@ -35,7 +35,7 @@ protected:
const StructStrategy *structs; const StructStrategy *structs;
}; };
std::vector<Patch *> m_patches; //we own these objects. std::vector<Patch *> m_patches; //we own these objects.
//pending streams.. //pending streams..
class Record { class Record {
public: public:
+1 -1
View File
@@ -19,7 +19,7 @@ class EQApplicationPacket;
class EQStreamInterface { class EQStreamInterface {
public: public:
virtual ~EQStreamInterface() {} virtual ~EQStreamInterface() {}
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) = 0; virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) = 0;
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true) = 0; virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true) = 0;
virtual EQApplicationPacket *PopPacket() = 0; virtual EQApplicationPacket *PopPacket() = 0;
+13 -13
View File
@@ -1,4 +1,4 @@
/* /*
Copyright (C) 2005 EQEmulator Team Copyright (C) 2005 EQEmulator Team
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -66,7 +66,7 @@ if(res)
else else
printf(": False\n");*/ printf(": False\n");*/
if(l.src_ip != r.src_ip) if(l.src_ip != r.src_ip)
return(l.src_ip < r.src_ip); return(l.src_ip < r.src_ip);
if(l.dst_ip != r.dst_ip) if(l.dst_ip != r.dst_ip)
@@ -74,7 +74,7 @@ else
if(l.src_port != r.src_port) if(l.src_port != r.src_port)
return(l.src_port < r.src_port); return(l.src_port < r.src_port);
return(l.dst_port < r.dst_port); return(l.dst_port < r.dst_port);
/* //so, this turned out uglier than I had hoped /* //so, this turned out uglier than I had hoped
if(l.src_ip < r.src_ip) if(l.src_ip < r.src_ip)
return(true); return(true);
@@ -105,35 +105,35 @@ class EQStreamLocator {
protected: protected:
typedef typename map<const EQStreamInfo, T *>::iterator iterator; typedef typename map<const EQStreamInfo, T *>::iterator iterator;
public: public:
void Clear() { void Clear() {
streams.clear(); streams.clear();
} }
void AddStream(const EQStreamInfo &i, T *o) { void AddStream(const EQStreamInfo &i, T *o) {
//do we care to check if it exists? //do we care to check if it exists?
//add this stream, and its inverse //add this stream, and its inverse
streams[i] = o; streams[i] = o;
EQStreamInfo inv; EQStreamInfo inv;
i.invert(inv); i.invert(inv);
streams[inv] = o; streams[inv] = o;
} }
//deletes this stream, and its inverse //deletes this stream, and its inverse
void RemoveStream(const EQStreamInfo &i) { void RemoveStream(const EQStreamInfo &i) {
iterator res; iterator res;
res = streams.find(i); res = streams.find(i);
if(res != streams.end()) if(res != streams.end())
streams.erase(res); streams.erase(res);
EQStreamInfo inv; EQStreamInfo inv;
i.invert(inv); i.invert(inv);
res = streams.find(inv); res = streams.find(inv);
if(res != streams.end()) if(res != streams.end())
streams.erase(res); streams.erase(res);
} }
//removes every occurance of this stream from the list //removes every occurance of this stream from the list
void RemoveStream(T *it) { void RemoveStream(T *it) {
iterator cur, end; iterator cur, end;
@@ -142,14 +142,14 @@ public:
for(; cur != end; cur++) { for(; cur != end; cur++) {
if(cur->second == it) { if(cur->second == it) {
streams.erase(cur); 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 //our iterators anyways
RemoveStream(it); RemoveStream(it);
return; return;
} }
} }
} }
T *GetStream(const EQStreamInfo &i) { T *GetStream(const EQStreamInfo &i) {
iterator res; iterator res;
res = streams.find(i); res = streams.find(i);
@@ -160,12 +160,12 @@ public:
return(nullptr); return(nullptr);
return(res->second); return(res->second);
} }
//allow people to iterate over the const struct //allow people to iterate over the const struct
// typedef map<const EQStreamInfo, T *>::const_iterator iterator; // typedef map<const EQStreamInfo, T *>::const_iterator iterator;
// inline iterator begin() const { return(streams.begin()); } // inline iterator begin() const { return(streams.begin()); }
// inline iterator end() const { return(streams.end()); } // inline iterator end() const { return(streams.end()); }
protected: protected:
map<const EQStreamInfo, T *> streams; map<const EQStreamInfo, T *> streams;
}; };
+2 -2
View File
@@ -30,7 +30,7 @@ const EQClientVersion EQStreamProxy::ClientVersion() const
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) { void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
if(p == nullptr) if(p == nullptr)
return; return;
EQApplicationPacket *newp = p->Copy(); EQApplicationPacket *newp = p->Copy();
FastQueuePacket(&newp, ack_req); FastQueuePacket(&newp, ack_req);
} }
@@ -45,7 +45,7 @@ EQApplicationPacket *EQStreamProxy::PopPacket() {
EQApplicationPacket *pack = m_stream->PopPacket(); EQApplicationPacket *pack = m_stream->PopPacket();
if(pack == nullptr) if(pack == nullptr)
return(nullptr); return(nullptr);
//pass this packet through the struct strategy. //pass this packet through the struct strategy.
m_structs->Decode(pack); m_structs->Decode(pack);
return(pack); return(pack);
+3 -3
View File
@@ -15,7 +15,7 @@ public:
//takes ownership of the stream. //takes ownership of the stream.
EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes); EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes);
virtual ~EQStreamProxy(); virtual ~EQStreamProxy();
//EQStreamInterface: //EQStreamInterface:
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true); virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true);
virtual void FastQueuePacket(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 bool CheckState(EQStreamState state);
virtual std::string Describe() const; virtual std::string Describe() const;
virtual const EQClientVersion ClientVersion() const; virtual const EQClientVersion ClientVersion() const;
virtual const uint32 GetBytesSent() const; virtual const uint32 GetBytesSent() const;
virtual const uint32 GetBytesRecieved() const; virtual const uint32 GetBytesRecieved() const;
virtual const uint32 GetBytesSentPerSecond() const; virtual const uint32 GetBytesSentPerSecond() const;
@@ -39,7 +39,7 @@ protected:
const StructStrategy *const m_structs; //we do not own this object. 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 //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. //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.
}; };
+34 -34
View File
@@ -17,30 +17,30 @@
*/ */
/* /*
* *
* *
* *
* *
* There are really two or three different objects shoe-hored into this * There are really two or three different objects shoe-hored into this
* connection object. Sombody really needs to factor out the relay link * 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. * tremendously.
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*/ */
#include "../common/debug.h" #include "../common/debug.h"
@@ -92,7 +92,7 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_s
RelayServer = false; RelayServer = false;
RelayCount = 0; RelayCount = 0;
RemoteID = 0; RemoteID = 0;
} }
//client outgoing connection case (and client side relay) //client outgoing connection case (and client side relay)
@@ -246,7 +246,7 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
return false; return false;
if (GetMode() != modePacket) if (GetMode() != modePacket)
return false; return false;
LockMutex lock(&MState); LockMutex lock(&MState);
eTCPMode tmp = GetMode(); eTCPMode tmp = GetMode();
if (tmp == modeTransition) { if (tmp == modeTransition) {
@@ -391,13 +391,13 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
} }
} }
return(TCPConnection::LineOutQueuePush(line)); return(TCPConnection::LineOutQueuePush(line));
} }
void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) { void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
TCPConnection::Disconnect(); TCPConnection::Disconnect();
if (RelayLink) { if (RelayLink) {
RelayLink->RemoveRelay(this, iSendRelayDisconnect); RelayLink->RemoveRelay(this, iSendRelayDisconnect);
RelayLink = 0; RelayLink = 0;
@@ -407,7 +407,7 @@ void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) { bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
if(!TCPConnection::ConnectIP(irIP, irPort, errbuf)) if(!TCPConnection::ConnectIP(irIP, irPort, errbuf))
return(false); return(false);
MSendQueue.lock(); MSendQueue.lock();
#ifdef MINILOGIN #ifdef MINILOGIN
TCPMode = modePacket; TCPMode = modePacket;
@@ -453,22 +453,22 @@ bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
} }
#endif #endif
MSendQueue.unlock(); MSendQueue.unlock();
return(true); return(true);
} }
void EmuTCPConnection::ClearBuffers() { void EmuTCPConnection::ClearBuffers() {
TCPConnection::ClearBuffers(); TCPConnection::ClearBuffers();
LockMutex lock2(&MOutQueueLock); LockMutex lock2(&MOutQueueLock);
ServerPacket* pack = 0; ServerPacket* pack = 0;
while ((pack = OutQueue.pop())) while ((pack = OutQueue.pop()))
safe_delete(pack); safe_delete(pack);
EmuTCPNetPacket_Struct* tnps = 0; EmuTCPNetPacket_Struct* tnps = 0;
while ((tnps = InModeQueue.pop())) while ((tnps = InModeQueue.pop()))
safe_delete(tnps); safe_delete(tnps);
keepalive_timer.Start(); keepalive_timer.Start();
timeout_timer.Start(); timeout_timer.Start();
} }
@@ -810,7 +810,7 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
sent_something = false; sent_something = false;
if(!TCPConnection::SendData(sent_something, errbuf)) if(!TCPConnection::SendData(sent_something, errbuf))
return(false); return(false);
if(sent_something) if(sent_something)
keepalive_timer.Start(); keepalive_timer.Start();
else if (TCPMode == modePacket && keepalive_timer.Check()) { 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; cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << endl;
#endif #endif
} }
return(true); return(true);
} }
@@ -832,13 +832,13 @@ bool EmuTCPConnection::RecvData(char* errbuf) {
else else
return(false); return(false);
} }
if ((TCPMode == modePacket || TCPMode == modeTransition) && timeout_timer.Check()) { if ((TCPMode == modePacket || TCPMode == modeTransition) && timeout_timer.Check()) {
if (errbuf) if (errbuf)
snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Connection timeout"); snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Connection timeout");
return false; return false;
} }
return(true); return(true);
} }
+17 -17
View File
@@ -31,67 +31,67 @@ class EmuTCPConnection : public TCPConnection {
public: public:
enum eTCPMode { modeConsole, modeTransition, modePacket }; enum eTCPMode { modeConsole, modeTransition, modePacket };
enum ePacketMode { packetModeZone, packetModeLauncher, packetModeLogin, packetModeUCS, packetModeQueryServ }; enum ePacketMode { packetModeZone, packetModeLauncher, packetModeLogin, packetModeUCS, packetModeQueryServ };
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET iSock, uint32 irIP, uint16 irPort, bool iOldFormat = false); 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(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 EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort); // for relay connections
virtual ~EmuTCPConnection(); virtual ~EmuTCPConnection();
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0); virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
virtual void Disconnect(bool iSendRelayDisconnect = true); virtual void Disconnect(bool iSendRelayDisconnect = true);
static EmuTCPNetPacket_Struct* MakePacket(ServerPacket* pack, uint32 iDestination = 0); static EmuTCPNetPacket_Struct* MakePacket(ServerPacket* pack, uint32 iDestination = 0);
static SPackSendQueue* MakeOldPacket(ServerPacket* pack); static SPackSendQueue* MakeOldPacket(ServerPacket* pack);
virtual bool SendPacket(ServerPacket* pack, uint32 iDestination = 0); virtual bool SendPacket(ServerPacket* pack, uint32 iDestination = 0);
virtual bool SendPacket(EmuTCPNetPacket_Struct* tnps); virtual bool SendPacket(EmuTCPNetPacket_Struct* tnps);
ServerPacket* PopPacket(); // OutQueuePop() ServerPacket* PopPacket(); // OutQueuePop()
void SetPacketMode(ePacketMode mode) { PacketMode = mode; } void SetPacketMode(ePacketMode mode) { PacketMode = mode; }
eTCPMode GetMode() const { return TCPMode; } eTCPMode GetMode() const { return TCPMode; }
ePacketMode GetPacketMode() const { return(PacketMode); } ePacketMode GetPacketMode() const { return(PacketMode); }
//relay crap: //relay crap:
inline bool IsRelayServer() const { return RelayServer; } inline bool IsRelayServer() const { return RelayServer; }
inline TCPConnection* GetRelayLink() const { return RelayLink; } inline TCPConnection* GetRelayLink() const { return RelayLink; }
inline uint32 GetRemoteID() const { return RemoteID; } inline uint32 GetRemoteID() const { return RemoteID; }
protected: protected:
void OutQueuePush(ServerPacket* pack); void OutQueuePush(ServerPacket* pack);
void RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect); void RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect);
void SendNetErrorPacket(const char* reason = 0); void SendNetErrorPacket(const char* reason = 0);
virtual bool SendData(bool &sent_something, char* errbuf = 0); virtual bool SendData(bool &sent_something, char* errbuf = 0);
virtual bool RecvData(char* errbuf = 0); virtual bool RecvData(char* errbuf = 0);
virtual bool ProcessReceivedData(char* errbuf = 0); virtual bool ProcessReceivedData(char* errbuf = 0);
bool ProcessReceivedDataAsPackets(char* errbuf = 0); bool ProcessReceivedDataAsPackets(char* errbuf = 0);
bool ProcessReceivedDataAsOldPackets(char* errbuf = 0); bool ProcessReceivedDataAsOldPackets(char* errbuf = 0);
void ProcessNetworkLayerPacket(ServerPacket* pack); void ProcessNetworkLayerPacket(ServerPacket* pack);
virtual bool LineOutQueuePush(char* line); virtual bool LineOutQueuePush(char* line);
virtual void ClearBuffers(); virtual void ClearBuffers();
EmuTCPServer* Server; EmuTCPServer* Server;
eTCPMode TCPMode; eTCPMode TCPMode;
ePacketMode PacketMode; ePacketMode PacketMode;
bool pOldFormat; bool pOldFormat;
Timer keepalive_timer; Timer keepalive_timer;
Timer timeout_timer; Timer timeout_timer;
//relay crap: //relay crap:
EmuTCPConnection* RelayLink; EmuTCPConnection* RelayLink;
int32 RelayCount; int32 RelayCount;
bool RelayServer; bool RelayServer;
uint32 RemoteID; uint32 RemoteID;
//input queue... //input queue...
void InModeQueuePush(EmuTCPNetPacket_Struct* tnps); void InModeQueuePush(EmuTCPNetPacket_Struct* tnps);
MyQueue<EmuTCPNetPacket_Struct> InModeQueue; MyQueue<EmuTCPNetPacket_Struct> InModeQueue;
//output queue... //output queue...
MyQueue<ServerPacket> OutQueue; MyQueue<ServerPacket> OutQueue;
Mutex MOutQueueLock; Mutex MOutQueueLock;
+146 -146
View File
@@ -42,7 +42,7 @@ int32 NextItemInstSerialNumber = 1;
static inline int32 GetNextItemInstSerialNumber() { 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 // 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. // is used in Bazaar packets to identify the item a player is buying or inspecting.
// //
@@ -103,8 +103,8 @@ ItemInstQueue::~ItemInstQueue() {
Inventory::~Inventory() { Inventory::~Inventory() {
map<int16, ItemInst*>::iterator cur,end; map<int16, ItemInst*>::iterator cur,end;
cur = m_worn.begin(); cur = m_worn.begin();
end = m_worn.end(); end = m_worn.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@@ -112,7 +112,7 @@ Inventory::~Inventory() {
safe_delete(tmp); safe_delete(tmp);
} }
m_worn.clear(); m_worn.clear();
cur = m_inv.begin(); cur = m_inv.begin();
end = m_inv.end(); end = m_inv.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@@ -120,7 +120,7 @@ Inventory::~Inventory() {
safe_delete(tmp); safe_delete(tmp);
} }
m_inv.clear(); m_inv.clear();
cur = m_bank.begin(); cur = m_bank.begin();
end = m_bank.end(); end = m_bank.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@@ -128,7 +128,7 @@ Inventory::~Inventory() {
safe_delete(tmp); safe_delete(tmp);
} }
m_bank.clear(); m_bank.clear();
cur = m_shbank.begin(); cur = m_shbank.begin();
end = m_shbank.end(); end = m_shbank.end();
for(; cur != end; cur++) { for(; cur != end; cur++) {
@@ -136,7 +136,7 @@ Inventory::~Inventory() {
safe_delete(tmp); safe_delete(tmp);
} }
m_shbank.clear(); m_shbank.clear();
cur = m_trade.begin(); cur = m_trade.begin();
end = m_trade.end(); end = m_trade.end();
for(; cur != end; cur++) { 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++) { for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = nullptr; ItemInst* inst_new = nullptr;
if (inst_old) { if (inst_old) {
inst_new = inst_old->Clone(); inst_new = inst_old->Clone();
} }
if (inst_new != nullptr) { if (inst_new != nullptr) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
@@ -200,11 +200,11 @@ bool ItemInst::IsType(ItemClass item_class) const
{ {
// Check usage type // Check usage type
if ((m_use_type == ItemUseWorldContainer) && (item_class == ItemClassContainer)) if ((m_use_type == ItemUseWorldContainer) && (item_class == ItemClassContainer))
return true; return true;
if (!m_item) if (!m_item)
return false; return false;
return (m_item->ItemClass == item_class); return (m_item->ItemClass == item_class);
} }
@@ -229,14 +229,14 @@ bool ItemInst::IsEquipable(int16 slot_id) const
{ {
if (!m_item) if (!m_item)
return false; return false;
if(slot_id == 9999) { if(slot_id == 9999) {
slot_id = 22; slot_id = 22;
uint32 slot_mask = (1 << slot_id); uint32 slot_mask = (1 << slot_id);
if (slot_mask & m_item->Slots) if (slot_mask & m_item->Slots)
return true; return true;
} }
if (slot_id < 22) { if (slot_id < 22) {
uint32 slot_mask = (1 << slot_id); uint32 slot_mask = (1 << slot_id);
if (slot_mask & m_item->Slots) if (slot_mask & m_item->Slots)
@@ -321,7 +321,7 @@ bool ItemInst::IsAmmo() const {
return true; return true;
return false; return false;
} }
// Retrieve augment inside item // Retrieve augment inside item
@@ -329,7 +329,7 @@ ItemInst* ItemInst::GetAugment(uint8 slot) const
{ {
if (m_item->ItemClass == ItemClassCommon) if (m_item->ItemClass == ItemClassCommon)
return GetItem(slot); return GetItem(slot);
return nullptr; return nullptr;
} }
@@ -376,7 +376,7 @@ ItemInst* ItemInst::GetItem(uint8 index) const
ItemInst* inst = it->second; ItemInst* inst = it->second;
return inst; return inst;
} }
return nullptr; return nullptr;
} }
@@ -384,8 +384,8 @@ void ItemInst::PutItem(uint8 index, const ItemInst& inst)
{ {
// Clean up item already in slot (if exists) // Clean up item already in slot (if exists)
DeleteItem(index); DeleteItem(index);
// Delegate to internal method // Delegate to internal method
_PutItem(index, inst.Clone()); _PutItem(index, inst.Clone());
} }
@@ -423,7 +423,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent)
const Item_Struct* item = inst->GetItem(); const Item_Struct* item = inst->GetItem();
del = cur; del = cur;
cur++; cur++;
switch(is_nodrop) { switch(is_nodrop) {
case byFlagSet: case byFlagSet:
if (item->NoDrop == 0) { if (item->NoDrop == 0) {
@@ -440,7 +440,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent)
default: default:
break; break;
} }
switch(is_norent) { switch(is_norent) {
case byFlagSet: case byFlagSet:
if (item->NoRent == 0) { if (item->NoRent == 0) {
@@ -470,7 +470,7 @@ ItemInst* ItemInst::PopItem(uint8 index)
m_contents.erase(index); m_contents.erase(index);
return inst; return inst;
} }
// Return pointer that needs to be deleted (or otherwise managed) // Return pointer that needs to be deleted (or otherwise managed)
return nullptr; return nullptr;
} }
@@ -492,7 +492,7 @@ ItemInst* ItemInstQueue::pop()
{ {
if (m_list.size() == 0) if (m_list.size() == 0)
return nullptr; return nullptr;
ItemInst* inst = m_list.front(); ItemInst* inst = m_list.front();
m_list.pop_front(); m_list.pop_front();
return inst; return inst;
@@ -509,13 +509,13 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
{ {
_CP(Inventory_GetItem); _CP(Inventory_GetItem);
ItemInst* result = nullptr; ItemInst* result = nullptr;
// Cursor // Cursor
if (slot_id == SLOT_CURSOR) { if (slot_id == SLOT_CURSOR) {
// Cursor slot // Cursor slot
result = m_cursor.peek_front(); result = m_cursor.peek_front();
} }
// Non bag slots // Non bag slots
else if (slot_id>=3000 && slot_id<=3007) { else if (slot_id>=3000 && slot_id<=3007) {
// Trade slots // Trade slots
@@ -537,7 +537,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
// Equippable slots (on body) // Equippable slots (on body)
result = _GetItem(m_worn, slot_id); result = _GetItem(m_worn, slot_id);
} }
// Inner bag slots // Inner bag slots
else if (slot_id>=3031 && slot_id<=3110) { else if (slot_id>=3031 && slot_id<=3110) {
// Trade bag slots // Trade bag slots
@@ -574,7 +574,7 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); result = inst->GetItem(Inventory::CalcBagIdx(slot_id));
} }
} }
return result; return result;
} }
@@ -656,13 +656,13 @@ int16 Inventory::PutItem(int16 slot_id, const ItemInst& inst)
{ {
// Clean up item already in slot (if exists) // Clean up item already in slot (if exists)
DeleteItem(slot_id); DeleteItem(slot_id);
if (!inst) { if (!inst) {
// User is effectively deleting the item // User is effectively deleting the item
// in the slot, why hold a null ptr in map<>? // in the slot, why hold a null ptr in map<>?
return slot_id; return slot_id;
} }
// Delegate to internal method // Delegate to internal method
return _PutItem(slot_id, inst.Clone()); return _PutItem(slot_id, inst.Clone());
} }
@@ -693,48 +693,48 @@ int16 Inventory::HasItem(uint32 item_id, uint8 quantity, uint8 where)
{ {
_CP(Inventory_HasItem); _CP(Inventory_HasItem);
int16 slot_id = SLOT_INVALID; int16 slot_id = SLOT_INVALID;
//Altered by Father Nitwit to support a specification of //Altered by Father Nitwit to support a specification of
//where to search, with a default value to maintain compatibility //where to search, with a default value to maintain compatibility
// Check each inventory bucket // Check each inventory bucket
if(where & invWhereWorn) { if(where & invWhereWorn) {
slot_id = _HasItem(m_worn, item_id, quantity); slot_id = _HasItem(m_worn, item_id, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWherePersonal) { if(where & invWherePersonal) {
slot_id = _HasItem(m_inv, item_id, quantity); slot_id = _HasItem(m_inv, item_id, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereBank) { if(where & invWhereBank) {
slot_id = _HasItem(m_bank, item_id, quantity); slot_id = _HasItem(m_bank, item_id, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereSharedBank) { if(where & invWhereSharedBank) {
slot_id = _HasItem(m_shbank, item_id, quantity); slot_id = _HasItem(m_shbank, item_id, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereTrading) { if(where & invWhereTrading) {
slot_id = _HasItem(m_trade, item_id, quantity); slot_id = _HasItem(m_trade, item_id, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereCursor) { if(where & invWhereCursor) {
// Check cursor queue // Check cursor queue
slot_id = _HasItem(m_cursor, item_id, quantity); slot_id = _HasItem(m_cursor, item_id, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
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 Inventory::HasItemByUse(uint8 use, uint8 quantity, uint8 where)
{ {
int16 slot_id = SLOT_INVALID; int16 slot_id = SLOT_INVALID;
// Check each inventory bucket // Check each inventory bucket
if(where & invWhereWorn) { if(where & invWhereWorn) {
slot_id = _HasItemByUse(m_worn, use, quantity); slot_id = _HasItemByUse(m_worn, use, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWherePersonal) { if(where & invWherePersonal) {
slot_id = _HasItemByUse(m_inv, use, quantity); slot_id = _HasItemByUse(m_inv, use, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereBank) { if(where & invWhereBank) {
slot_id = _HasItemByUse(m_bank, use, quantity); slot_id = _HasItemByUse(m_bank, use, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereSharedBank) { if(where & invWhereSharedBank) {
slot_id = _HasItemByUse(m_shbank, use, quantity); slot_id = _HasItemByUse(m_shbank, use, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereTrading) { if(where & invWhereTrading) {
slot_id = _HasItemByUse(m_trade, use, quantity); slot_id = _HasItemByUse(m_trade, use, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereCursor) { if(where & invWhereCursor) {
// Check cursor queue // Check cursor queue
slot_id = _HasItemByUse(m_cursor, use, quantity); slot_id = _HasItemByUse(m_cursor, use, quantity);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
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; int16 slot_id = SLOT_INVALID;
// Check each inventory bucket // Check each inventory bucket
if(where & invWhereWorn) { if(where & invWhereWorn) {
slot_id = _HasItemByLoreGroup(m_worn, loregroup); slot_id = _HasItemByLoreGroup(m_worn, loregroup);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWherePersonal) { if(where & invWherePersonal) {
slot_id = _HasItemByLoreGroup(m_inv, loregroup); slot_id = _HasItemByLoreGroup(m_inv, loregroup);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereBank) { if(where & invWhereBank) {
slot_id = _HasItemByLoreGroup(m_bank, loregroup); slot_id = _HasItemByLoreGroup(m_bank, loregroup);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereSharedBank) { if(where & invWhereSharedBank) {
slot_id = _HasItemByLoreGroup(m_shbank, loregroup); slot_id = _HasItemByLoreGroup(m_shbank, loregroup);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereTrading) { if(where & invWhereTrading) {
slot_id = _HasItemByLoreGroup(m_trade, loregroup); slot_id = _HasItemByLoreGroup(m_trade, loregroup);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
if(where & invWhereCursor) { if(where & invWhereCursor) {
// Check cursor queue // Check cursor queue
slot_id = _HasItemByLoreGroup(m_cursor, loregroup); slot_id = _HasItemByLoreGroup(m_cursor, loregroup);
if (slot_id != SLOT_INVALID) if (slot_id != SLOT_INVALID)
return slot_id; return slot_id;
} }
return slot_id; return slot_id;
} }
@@ -835,13 +835,13 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
if(ItemToTry->Stackable) { if(ItemToTry->Stackable) {
for(int16 i = 22; i <= 29; i++) { for(int16 i = 22; i <= 29; i++) {
ItemInst* InvItem = GetItem(i); ItemInst* InvItem = GetItem(i);
if(InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) && (InvItem->GetCharges() < InvItem->GetItem()->StackSize)) { if(InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) && (InvItem->GetCharges() < InvItem->GetItem()->StackSize)) {
int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges(); int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges();
if(Quantity <= ChargeSlotsLeft) if(Quantity <= ChargeSlotsLeft)
return true; return true;
@@ -860,7 +860,7 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
(InvItem->GetCharges() < InvItem->GetItem()->StackSize)) { (InvItem->GetCharges() < InvItem->GetItem()->StackSize)) {
int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges(); int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges();
if(Quantity <= ChargeSlotsLeft) if(Quantity <= ChargeSlotsLeft)
return true; return true;
@@ -930,7 +930,7 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
{ {
// Pop item out of inventory map (or queue) // Pop item out of inventory map (or queue)
ItemInst* item_to_delete = PopItem(slot_id); ItemInst* item_to_delete = PopItem(slot_id);
// Determine if object should be fully deleted, or // Determine if object should be fully deleted, or
// just a quantity of charges of the item can be deleted // just a quantity of charges of the item can be deleted
if (item_to_delete && (quantity > 0)) { 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 // 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 // the item is not stackable, and is not a charged item, or is expendable, delete it
if(item_to_delete->IsStackable() || if(item_to_delete->IsStackable() ||
(!item_to_delete->IsStackable() && (!item_to_delete->IsStackable() &&
((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable()))) { ((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable()))) {
// Item can now be destroyed // Item can now be destroyed
safe_delete(item_to_delete); safe_delete(item_to_delete);
@@ -954,11 +954,11 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
_PutItem(slot_id, item_to_delete); _PutItem(slot_id, item_to_delete);
return false; return false;
} }
safe_delete(item_to_delete); safe_delete(item_to_delete);
return true; return true;
} }
// Checks All items in a bag for No Drop // 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* Inventory::PopItem(int16 slot_id)
{ {
ItemInst* p = nullptr; ItemInst* p = nullptr;
if (slot_id==SLOT_CURSOR) { // Cursor if (slot_id==SLOT_CURSOR) { // Cursor
p = m_cursor.pop(); p = m_cursor.pop();
} }
@@ -1011,7 +1011,7 @@ ItemInst* Inventory::PopItem(int16 slot_id)
p = baginst->PopItem(Inventory::CalcBagIdx(slot_id)); p = baginst->PopItem(Inventory::CalcBagIdx(slot_id));
} }
} }
// Return pointer that needs to be deleted (or otherwise managed) // Return pointer that needs to be deleted (or otherwise managed)
return p; 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 // Found available slot in personal inventory
return i; return i;
} }
if (!for_bag) { if (!for_bag) {
for (int16 i=22; i<=29; i++) { for (int16 i=22; i<=29; i++) {
const ItemInst* inst = GetItem(i); const ItemInst* inst = GetItem(i);
if (inst && inst->IsType(ItemClassContainer) if (inst && inst->IsType(ItemClassContainer)
&& inst->GetItem()->BagSize >= min_size) && inst->GetItem()->BagSize >= min_size)
{ {
if(inst->GetItem()->BagType == bagTypeQuiver && inst->GetItem()->ItemType != ItemTypeArrow) 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) if (try_cursor)
// Always room on cursor (it's a queue) // Always room on cursor (it's a queue)
// (we may wish to cap this in the future) // (we may wish to cap this in the future)
return SLOT_CURSOR; return SLOT_CURSOR;
// No available slots // No available slots
return SLOT_INVALID; return SLOT_INVALID;
} }
@@ -1064,7 +1064,7 @@ void Inventory::dumpInventory() {
iter_inst it; iter_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = nullptr; ItemInst* inst = nullptr;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
printf("Worn items:\n"); printf("Worn items:\n");
for (it=m_worn.begin(); it!=m_worn.end(); it++) { for (it=m_worn.begin(); it!=m_worn.end(); it++) {
@@ -1072,9 +1072,9 @@ void Inventory::dumpInventory() {
it->first; it->first;
if(!inst || !inst->GetItem()) if(!inst || !inst->GetItem())
continue; continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
@@ -1086,16 +1086,16 @@ void Inventory::dumpInventory() {
} }
} }
} }
printf("Inventory items:\n"); printf("Inventory items:\n");
for (it=m_inv.begin(); it!=m_inv.end(); it++) { for (it=m_inv.begin(); it!=m_inv.end(); it++) {
inst = it->second; inst = it->second;
it->first; it->first;
if(!inst || !inst->GetItem()) if(!inst || !inst->GetItem())
continue; continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
@@ -1104,57 +1104,57 @@ void Inventory::dumpInventory() {
continue; continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
} }
} }
} }
printf("Bank items:\n"); printf("Bank items:\n");
for (it=m_bank.begin(); it!=m_bank.end(); it++) { for (it=m_bank.begin(); it!=m_bank.end(); it++) {
inst = it->second; inst = it->second;
it->first; it->first;
if(!inst || !inst->GetItem()) if(!inst || !inst->GetItem())
continue; continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second; ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem()) if(!baginst || !baginst->GetItem())
continue; continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
} }
} }
} }
printf("Shared Bank items:\n"); printf("Shared Bank items:\n");
for (it=m_shbank.begin(); it!=m_shbank.end(); it++) { for (it=m_shbank.begin(); it!=m_shbank.end(); it++) {
inst = it->second; inst = it->second;
it->first; it->first;
if(!inst || !inst->GetItem()) if(!inst || !inst->GetItem())
continue; continue;
printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges());
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second; ItemInst* baginst = itb->second;
if(!baginst || !baginst->GetItem()) if(!baginst || !baginst->GetItem())
continue; continue;
printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first),
baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges());
} }
} }
} }
printf("\n"); printf("\n");
fflush(stdout); fflush(stdout);
} }
@@ -1166,7 +1166,7 @@ ItemInst* Inventory::_GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id
if (it != bucket.end()) { if (it != bucket.end()) {
return it->second; return it->second;
} }
// Not found! // Not found!
return nullptr; return nullptr;
} }
@@ -1181,9 +1181,9 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
PopItem(slot_id); PopItem(slot_id);
return slot_id; return slot_id;
} }
int16 result = SLOT_INVALID; int16 result = SLOT_INVALID;
if (slot_id==SLOT_CURSOR) { // Cursor if (slot_id==SLOT_CURSOR) { // Cursor
// Replace current item on cursor, if exists // Replace current item on cursor, if exists
m_cursor.pop(); // no memory delete, clients of this function know what they are doing 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; result = slot_id;
} }
} }
if (result == SLOT_INVALID) { if (result == SLOT_INVALID) {
LogFile->write(EQEMuLog::Error, "Inventory::_PutItem: Invalid slot_id specified (%i)", slot_id); LogFile->write(EQEMuLog::Error, "Inventory::_PutItem: Invalid slot_id specified (%i)", slot_id);
safe_delete(inst); // Slot not found, clean up safe_delete(inst); // Slot not found, clean up
} }
return result; return result;
} }
@@ -1234,7 +1234,7 @@ int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 q
iter_contents itb; iter_contents itb;
ItemInst* inst = nullptr; ItemInst* inst = nullptr;
uint8 quantity_found = 0; uint8 quantity_found = 0;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
for (it=bucket.begin(); it!=bucket.end(); it++) { for (it=bucket.begin(); it!=bucket.end(); it++) {
inst = it->second; inst = it->second;
@@ -1244,15 +1244,15 @@ int16 Inventory::_HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 q
if (quantity_found >= quantity) if (quantity_found >= quantity)
return it->first; return it->first;
} }
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { 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. return SLOT_AUGMENT; // Only one augment per slot.
} }
} }
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second; ItemInst* baginst = itb->second;
if (baginst->GetID() == item_id) { 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); return Inventory::CalcSlotId(it->first, itb->first);
} }
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { 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. return SLOT_AUGMENT; // Only one augment per slot.
} }
} }
} }
} }
// Not found // Not found
return SLOT_INVALID; return SLOT_INVALID;
} }
@@ -1278,7 +1278,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
iter_queue it; iter_queue it;
iter_contents itb; iter_contents itb;
uint8 quantity_found = 0; uint8 quantity_found = 0;
// Read-only iteration of queue // Read-only iteration of queue
for (it=iqueue.begin(); it!=iqueue.end(); it++) { for (it=iqueue.begin(); it!=iqueue.end(); it++) {
ItemInst* inst = *it; ItemInst* inst = *it;
@@ -1290,13 +1290,13 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity)
return SLOT_CURSOR; return SLOT_CURSOR;
} }
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { 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. return SLOT_AUGMENT; // Only one augment per slot.
} }
} }
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second; ItemInst* baginst = itb->second;
if (baginst->GetID() == item_id) { 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); return Inventory::CalcSlotId(SLOT_CURSOR, itb->first);
} }
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { 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. return SLOT_AUGMENT; // Only one augment per slot.
} }
} }
} }
} }
// Not found // Not found
return SLOT_INVALID; return SLOT_INVALID;
} }
@@ -1324,7 +1324,7 @@ int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 q
iter_contents itb; iter_contents itb;
ItemInst* inst = nullptr; ItemInst* inst = nullptr;
uint8 quantity_found = 0; uint8 quantity_found = 0;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
for (it=bucket.begin(); it!=bucket.end(); it++) { for (it=bucket.begin(); it!=bucket.end(); it++) {
inst = it->second; inst = it->second;
@@ -1333,10 +1333,10 @@ int16 Inventory::_HasItemByUse(map<int16, ItemInst*>& bucket, uint8 use, uint8 q
if (quantity_found >= quantity) if (quantity_found >= quantity)
return it->first; return it->first;
} }
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second; ItemInst* baginst = itb->second;
if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->ItemType == use) { 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 // Not found
return SLOT_INVALID; return SLOT_INVALID;
} }
@@ -1358,7 +1358,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
iter_queue it; iter_queue it;
iter_contents itb; iter_contents itb;
uint8 quantity_found = 0; uint8 quantity_found = 0;
// Read-only iteration of queue // Read-only iteration of queue
for (it=iqueue.begin(); it!=iqueue.end(); it++) { for (it=iqueue.begin(); it!=iqueue.end(); it++) {
ItemInst* inst = *it; ItemInst* inst = *it;
@@ -1367,10 +1367,10 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
if (quantity_found >= quantity) if (quantity_found >= quantity)
return SLOT_CURSOR; return SLOT_CURSOR;
} }
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second; ItemInst* baginst = itb->second;
if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->ItemType == use) { if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->ItemType == use) {
@@ -1381,24 +1381,24 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity)
} }
} }
} }
// Not found // Not found
return SLOT_INVALID; 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_inst it;
iter_contents itb; iter_contents itb;
ItemInst* inst = nullptr; ItemInst* inst = nullptr;
// Check item: After failed checks, check bag contents (if bag) // Check item: After failed checks, check bag contents (if bag)
for (it=bucket.begin(); it!=bucket.end(); it++) { for (it=bucket.begin(); it!=bucket.end(); it++) {
inst = it->second; inst = it->second;
if (inst) { if (inst) {
if (inst->GetItem()->LoreGroup == loregroup) if (inst->GetItem()->LoreGroup == loregroup)
return it->first; return it->first;
ItemInst* Aug; ItemInst* Aug;
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
Aug = inst->GetAugment(i); Aug = inst->GetAugment(i);
@@ -1408,12 +1408,12 @@ int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loreg
} }
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second; 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); return Inventory::CalcSlotId(it->first, itb->first);
ItemInst* Aug2; ItemInst* Aug2;
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
Aug2 = baginst->GetAugment(i); Aug2 = baginst->GetAugment(i);
@@ -1423,7 +1423,7 @@ int16 Inventory::_HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loreg
} }
} }
} }
// Not found // Not found
return SLOT_INVALID; return SLOT_INVALID;
} }
@@ -1433,15 +1433,15 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup)
{ {
iter_queue it; iter_queue it;
iter_contents itb; iter_contents itb;
// Read-only iteration of queue // Read-only iteration of queue
for (it=iqueue.begin(); it!=iqueue.end(); it++) { for (it=iqueue.begin(); it!=iqueue.end(); it++) {
ItemInst* inst = *it; ItemInst* inst = *it;
if (inst) if (inst)
{ {
if (inst->GetItem()->LoreGroup == loregroup) if (inst->GetItem()->LoreGroup == loregroup)
return SLOT_CURSOR; return SLOT_CURSOR;
ItemInst* Aug; ItemInst* Aug;
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
Aug = inst->GetAugment(i); Aug = inst->GetAugment(i);
@@ -1451,13 +1451,13 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup)
} }
// Go through bag, if bag // Go through bag, if bag
if (inst && inst->IsType(ItemClassContainer)) { if (inst && inst->IsType(ItemClassContainer)) {
for (itb=inst->_begin(); itb!=inst->_end(); itb++) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) {
ItemInst* baginst = itb->second; 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); return Inventory::CalcSlotId(SLOT_CURSOR, itb->first);
ItemInst* Aug2; ItemInst* Aug2;
for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) {
Aug2 = baginst->GetAugment(i); Aug2 = baginst->GetAugment(i);
@@ -1468,7 +1468,7 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup)
} }
} }
} }
// Not found // Not found
return SLOT_INVALID; return SLOT_INVALID;
} }
@@ -1513,7 +1513,7 @@ bool ItemInst::IsNoneEmptyContainer()
for(int i = 0; i < m_item->BagSlots; ++i) for(int i = 0; i < m_item->BagSlots; ++i)
if(GetItem(i)) if(GetItem(i))
return true; return true;
return false; return false;
} }
@@ -1522,7 +1522,7 @@ bool ItemInst::IsAugmented()
for(int i = 0; i < MAX_AUGMENT_SLOTS; ++i) for(int i = 0; i < MAX_AUGMENT_SLOTS; ++i)
if (GetAugmentItemID(i)) if (GetAugmentItemID(i))
return true; return true;
return false; return false;
} }
@@ -1532,9 +1532,9 @@ int16 Inventory::CalcSlotId(int16 bagslot_id, uint8 bagidx)
if (!Inventory::SupportsContainers(bagslot_id)) { if (!Inventory::SupportsContainers(bagslot_id)) {
return SLOT_INVALID; return SLOT_INVALID;
} }
int16 slot_id = SLOT_INVALID; int16 slot_id = SLOT_INVALID;
if (bagslot_id==SLOT_CURSOR || bagslot_id==8000) // Cursor if (bagslot_id==SLOT_CURSOR || bagslot_id==8000) // Cursor
slot_id = IDX_CURSOR_BAG + bagidx; slot_id = IDX_CURSOR_BAG + bagidx;
else if (bagslot_id>=22 && bagslot_id<=29) // Inventory slots 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; slot_id = IDX_SHBANK_BAG + (bagslot_id-2500)*MAX_ITEMS_PER_BAG + bagidx;
else if (bagslot_id>=3000 && bagslot_id<=3007) // Trade window slots else if (bagslot_id>=3000 && bagslot_id<=3007) // Trade window slots
slot_id = IDX_TRADE_BAG + (bagslot_id-3000)*MAX_ITEMS_PER_BAG + bagidx; slot_id = IDX_TRADE_BAG + (bagslot_id-3000)*MAX_ITEMS_PER_BAG + bagidx;
return slot_id; return slot_id;
} }
@@ -1553,7 +1553,7 @@ int16 Inventory::CalcSlotId(int16 bagslot_id, uint8 bagidx)
int16 Inventory::CalcSlotId(int16 slot_id) int16 Inventory::CalcSlotId(int16 slot_id)
{ {
int16 parent_slot_id = SLOT_INVALID; int16 parent_slot_id = SLOT_INVALID;
if (slot_id>=251 && slot_id<=330) if (slot_id>=251 && slot_id<=330)
parent_slot_id = IDX_INV + (slot_id-251) / MAX_ITEMS_PER_BAG; parent_slot_id = IDX_INV + (slot_id-251) / MAX_ITEMS_PER_BAG;
else if (slot_id>=331 && slot_id<=340) 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; parent_slot_id = IDX_SHBANK + (slot_id-2531) / MAX_ITEMS_PER_BAG;
else if (slot_id>=3100 && slot_id<=3179) else if (slot_id>=3100 && slot_id<=3179)
parent_slot_id = IDX_TRADE + (slot_id-3100) / MAX_ITEMS_PER_BAG; parent_slot_id = IDX_TRADE + (slot_id-3100) / MAX_ITEMS_PER_BAG;
return parent_slot_id; return parent_slot_id;
} }
uint8 Inventory::CalcBagIdx(int16 slot_id) uint8 Inventory::CalcBagIdx(int16 slot_id)
{ {
uint8 index = 0; uint8 index = 0;
if (slot_id>=251 && slot_id<=330) if (slot_id>=251 && slot_id<=330)
index = (slot_id-251) % MAX_ITEMS_PER_BAG; index = (slot_id-251) % MAX_ITEMS_PER_BAG;
else if (slot_id>=331 && slot_id<=340) 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; index = (slot_id-3100) % MAX_ITEMS_PER_BAG;
else if (slot_id>=4000 && slot_id<=4009) else if (slot_id>=4000 && slot_id<=4009)
index = (slot_id-4000) % MAX_ITEMS_PER_BAG; index = (slot_id-4000) % MAX_ITEMS_PER_BAG;
return index; return index;
} }
@@ -1691,11 +1691,11 @@ EvoItemInst::EvoItemInst(const EvoItemInst &copy) {
for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) { for (it=copy.m_contents.begin(); it!=copy.m_contents.end(); it++) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = nullptr; ItemInst* inst_new = nullptr;
if (inst_old) { if (inst_old) {
inst_new = inst_old->Clone(); inst_new = inst_old->Clone();
} }
if (inst_new != nullptr) { if (inst_new != nullptr) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
@@ -1717,7 +1717,7 @@ EvoItemInst::EvoItemInst(const EvoItemInst &copy) {
EvoItemInst::EvoItemInst(const ItemInst &basecopy) { EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
EvoItemInst* copy = (EvoItemInst*)&basecopy; EvoItemInst* copy = (EvoItemInst*)&basecopy;
m_use_type=copy->m_use_type; m_use_type=copy->m_use_type;
m_item=copy->m_item; m_item=copy->m_item;
m_charges=copy->m_charges; 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++) { for (it=copy->m_contents.begin(); it!=copy->m_contents.end(); it++) {
ItemInst* inst_old = it->second; ItemInst* inst_old = it->second;
ItemInst* inst_new = nullptr; ItemInst* inst_new = nullptr;
if (inst_old) { if (inst_old) {
inst_new = inst_old->Clone(); inst_new = inst_old->Clone();
} }
if (inst_new != nullptr) { if (inst_new != nullptr) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
@@ -1775,7 +1775,7 @@ EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
} }
EvoItemInst::~EvoItemInst() { EvoItemInst::~EvoItemInst() {
safe_delete(m_scaledItem); safe_delete(m_scaledItem);
} }
EvoItemInst* EvoItemInst::Clone() const { EvoItemInst* EvoItemInst::Clone() const {
@@ -1812,7 +1812,7 @@ void EvoItemInst::Initialize(SharedDatabase *db) {
void EvoItemInst::ScaleItem() { void EvoItemInst::ScaleItem() {
// free memory from any previously scaled item data // free memory from any previously scaled item data
safe_delete(m_scaledItem); safe_delete(m_scaledItem);
m_scaledItem = new Item_Struct(*m_item); m_scaledItem = new Item_Struct(*m_item);
float Mult = (float)(GetExp())/10000; // scaling is determined by exp, with 10,000 being full stats 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->DR = (int8)((float)m_item->DR*Mult);
m_scaledItem->CR = (int8)((float)m_item->CR*Mult); m_scaledItem->CR = (int8)((float)m_item->CR*Mult);
m_scaledItem->FR = (int8)((float)m_item->FR*Mult); m_scaledItem->FR = (int8)((float)m_item->FR*Mult);
m_scaledItem->HP = (int32)((float)m_item->HP*Mult); m_scaledItem->HP = (int32)((float)m_item->HP*Mult);
m_scaledItem->Mana = (int32)((float)m_item->Mana*Mult); m_scaledItem->Mana = (int32)((float)m_item->Mana*Mult);
m_scaledItem->AC = (int32)((float)m_item->AC*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->EnduranceRegen = (uint32)((float)m_item->EnduranceRegen*Mult);
m_scaledItem->Haste = (uint32)((float)m_item->Haste*Mult); m_scaledItem->Haste = (uint32)((float)m_item->Haste*Mult);
m_scaledItem->DamageShield = (uint32)((float)m_item->DamageShield*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. 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 { int8 EvoItemInst::GetMaxEvolveLvl() const {
if(m_evolveInfo) if(m_evolveInfo)
return m_evolveInfo->MaxLvl; return m_evolveInfo->MaxLvl;
else else
return 0; return 0;
} }
uint32 EvoItemInst::GetKillsNeeded(uint8 currentlevel) { 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. 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 (m_evolveInfo)
if (currentlevel != m_evolveInfo->MaxLvl) if (currentlevel != m_evolveInfo->MaxLvl)
kills = m_evolveInfo->LvlKills[currentlevel-1]; kills = m_evolveInfo->LvlKills[currentlevel-1];
if (kills == 0) if (kills == 0)
@@ -1913,7 +1913,7 @@ bool Item_Struct::IsEquipable(uint16 Race, uint16 Class_) const
{ {
bool IsRace = false; bool IsRace = false;
bool IsClass = false; bool IsClass = false;
uint32 Classes_ = Classes; uint32 Classes_ = Classes;
uint32 Races_ = Races; uint32 Races_ = Races;
+42 -42
View File
@@ -105,23 +105,23 @@ public:
///////////////////////// /////////////////////////
// Public Methods // Public Methods
///////////////////////// /////////////////////////
inline iter_queue begin() { return m_list.begin(); } inline iter_queue begin() { return m_list.begin(); }
inline iter_queue end() { return m_list.end(); } inline iter_queue end() { return m_list.end(); }
void push(ItemInst* inst); void push(ItemInst* inst);
void push_front(ItemInst* inst); void push_front(ItemInst* inst);
ItemInst* pop(); ItemInst* pop();
ItemInst* peek_front() const; ItemInst* peek_front() const;
inline int size() { return static_cast<int>(m_list.size()); } inline int size() { return static_cast<int>(m_list.size()); }
protected: protected:
///////////////////////// /////////////////////////
// Protected Members // Protected Members
///////////////////////// /////////////////////////
list<ItemInst*> m_list; list<ItemInst*> m_list;
}; };
// ######################################## // ########################################
@@ -134,9 +134,9 @@ public:
/////////////////////////////// ///////////////////////////////
// Public Methods // Public Methods
/////////////////////////////// ///////////////////////////////
virtual ~Inventory(); virtual ~Inventory();
// Retrieve a writeable item at specified slot // Retrieve a writeable item at specified slot
ItemInst* GetItem(int16 slot_id) const; ItemInst* GetItem(int16 slot_id) const;
ItemInst* GetItem(int16 slot_id, uint8 bagidx) 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_begin() { return m_cursor.begin(); }
inline iter_queue cursor_end() { return m_cursor.end(); } inline iter_queue cursor_end() { return m_cursor.end(); }
inline bool CursorEmpty() { return (m_cursor.size() == 0); } inline bool CursorEmpty() { return (m_cursor.size() == 0); }
// Retrieve a read-only item from inventory // Retrieve a read-only item from inventory
inline const ItemInst* operator[](int16 slot_id) const { return GetItem(slot_id); } inline const ItemInst* operator[](int16 slot_id) const { return GetItem(slot_id); }
// Add item to inventory // Add item to inventory
int16 PutItem(int16 slot_id, const ItemInst& inst); int16 PutItem(int16 slot_id, const ItemInst& inst);
// Add item to cursor queue // Add item to cursor queue
int16 PushCursor(const ItemInst& inst); int16 PushCursor(const ItemInst& inst);
// Swap items in inventory // Swap items in inventory
bool SwapItem(int16 slot_a, int16 slot_b); bool SwapItem(int16 slot_a, int16 slot_b);
@@ -162,17 +162,17 @@ public:
// Checks All items in a bag for No Drop // Checks All items in a bag for No Drop
bool CheckNoDrop(int16 slot_id); bool CheckNoDrop(int16 slot_id);
// Remove item from inventory (and take control of memory) // Remove item from inventory (and take control of memory)
ItemInst* PopItem(int16 slot_id); ItemInst* PopItem(int16 slot_id);
// Check whether item exists in inventory // Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look // where argument specifies OR'd list of invWhere constants to look
int16 HasItem(uint32 item_id, uint8 quantity=0, uint8 where=0xFF); int16 HasItem(uint32 item_id, uint8 quantity=0, uint8 where=0xFF);
// Check whether there is space for the specified number of the specified item. // Check whether there is space for the specified number of the specified item.
bool HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity); bool HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity);
// Check whether item exists in inventory // Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look // where argument specifies OR'd list of invWhere constants to look
int16 HasItemByUse(uint8 use, uint8 quantity=0, uint8 where=0xFF); int16 HasItemByUse(uint8 use, uint8 quantity=0, uint8 where=0xFF);
@@ -180,10 +180,10 @@ public:
// Check whether item exists in inventory // Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look // where argument specifies OR'd list of invWhere constants to look
int16 HasItemByLoreGroup(uint32 loregroup, uint8 where=0xFF); int16 HasItemByLoreGroup(uint32 loregroup, uint8 where=0xFF);
// Locate an available inventory slot // Locate an available inventory slot
int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false); 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 // 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 slot_id); // Calc parent bag's slot_id
static int16 CalcSlotId(int16 bagslot_id, uint8 bagidx); // Calc slot_id for item inside bag 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 // Test whether a given slot can support a container item
static bool SupportsContainers(int16 slot_id); static bool SupportsContainers(int16 slot_id);
void dumpInventory(); void dumpInventory();
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value); void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value);
@@ -207,13 +207,13 @@ protected:
/////////////////////////////// ///////////////////////////////
// Protected Methods // Protected Methods
/////////////////////////////// ///////////////////////////////
// Retrieves item within an inventory bucket // Retrieves item within an inventory bucket
ItemInst* _GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const; ItemInst* _GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const;
// Private "put" item into bucket, without regard for what is currently in bucket // Private "put" item into bucket, without regard for what is currently in bucket
int16 _PutItem(int16 slot_id, ItemInst* inst); int16 _PutItem(int16 slot_id, ItemInst* inst);
// Checks an inventory bucket for a particular item // Checks an inventory bucket for a particular item
int16 _HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity); int16 _HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity);
int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity); int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity);
@@ -221,8 +221,8 @@ protected:
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity); int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
int16 _HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup); int16 _HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup);
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup); int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
// Player inventory // Player inventory
map<int16, ItemInst*> m_worn; // Items worn by character map<int16, ItemInst*> m_worn; // Items worn by character
map<int16, ItemInst*> m_inv; // Items in character personal inventory map<int16, ItemInst*> m_inv; // Items in character personal inventory
@@ -245,12 +245,12 @@ public:
///////////////////////// /////////////////////////
// Methods // Methods
///////////////////////// /////////////////////////
// Constructors/Destructor // Constructors/Destructor
ItemInst(const Item_Struct* item = nullptr, int16 charges = 0); ItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
ItemInst(SharedDatabase *db, uint32 item_id, int16 charges = 0); ItemInst(SharedDatabase *db, uint32 item_id, int16 charges = 0);
ItemInst(ItemUseType use_type) { ItemInst(ItemUseType use_type) {
m_use_type = use_type; m_use_type = use_type;
m_item = nullptr; m_item = nullptr;
@@ -262,19 +262,19 @@ public:
} }
ItemInst(const ItemInst& copy); ItemInst(const ItemInst& copy);
virtual ~ItemInst(); virtual ~ItemInst();
// Query item type // Query item type
virtual bool IsType(ItemClass item_class) const; virtual bool IsType(ItemClass item_class) const;
// Can item be stacked? // Can item be stacked?
virtual bool IsStackable() const; virtual bool IsStackable() const;
// Can item be equipped by/at? // Can item be equipped by/at?
virtual bool IsEquipable(uint16 race, uint16 class_) const; virtual bool IsEquipable(uint16 race, uint16 class_) const;
virtual bool IsEquipable(int16 slot_id) const; virtual bool IsEquipable(int16 slot_id) const;
// //
// Augements // Augements
// //
@@ -322,13 +322,13 @@ public:
const uint32 GetItemScriptID() const { return m_item->ScriptFileID; } const uint32 GetItemScriptID() const { return m_item->ScriptFileID; }
virtual const Item_Struct* GetItem() const { return m_item; } virtual const Item_Struct* GetItem() const { return m_item; }
void SetItem(const Item_Struct* item) { m_item = item; } void SetItem(const Item_Struct* item) { m_item = item; }
int16 GetCharges() const { return m_charges; } int16 GetCharges() const { return m_charges; }
void SetCharges(int16 charges) { m_charges = charges; } void SetCharges(int16 charges) { m_charges = charges; }
uint32 GetPrice() const { return m_price; } uint32 GetPrice() const { return m_price; }
void SetPrice(uint32 price) { m_price = price; } void SetPrice(uint32 price) { m_price = price; }
void SetColor(uint32 color) { m_color = color; } void SetColor(uint32 color) { m_color = color; }
uint32 GetColor() const { return m_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 // Allows treatment of this object as though it were a pointer to m_item
operator bool() const { return (m_item != nullptr); } operator bool() const { return (m_item != nullptr); }
// Compare inner Item_Struct of two ItemInst objects // 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); }
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 // Clone current item
virtual ItemInst* Clone() const; virtual ItemInst* Clone() const;
bool IsSlotAllowed(int16 slot_id) const; bool IsSlotAllowed(int16 slot_id) const;
virtual bool IsScaling() const { return false; } virtual bool IsScaling() const { return false; }
@@ -383,10 +383,10 @@ protected:
iter_contents _end() { return m_contents.end(); } iter_contents _end() { return m_contents.end(); }
friend class Inventory; friend class Inventory;
void _PutItem(uint8 index, ItemInst* inst) { m_contents[index] = inst; } void _PutItem(uint8 index, ItemInst* inst) { m_contents[index] = inst; }
ItemUseType m_use_type; // Usage type for item ItemUseType m_use_type; // Usage type for item
const Item_Struct* m_item; // Ptr to item data const Item_Struct* m_item; // Ptr to item data
int16 m_charges; // # of charges for chargeable items int16 m_charges; // # of charges for chargeable items
@@ -410,7 +410,7 @@ public:
EvoItemInst(const ItemInst& copy); EvoItemInst(const ItemInst& copy);
EvoItemInst(const Item_Struct* item = nullptr, int16 charges = 0); EvoItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
~EvoItemInst(); ~EvoItemInst();
// accessors... a lot of these are for evolving items (not complete yet) // accessors... a lot of these are for evolving items (not complete yet)
bool IsScaling() const { return (m_evolveLvl == -1); } bool IsScaling() const { return (m_evolveLvl == -1); }
bool IsEvolving() const { return (m_evolveLvl >= 1); } bool IsEvolving() const { return (m_evolveLvl >= 1); }
@@ -420,16 +420,16 @@ public:
bool IsActivated() { return m_activated; } bool IsActivated() { return m_activated; }
void SetActivated(bool activated) { m_activated = activated; } void SetActivated(bool activated) { m_activated = activated; }
int8 GetEvolveLvl() const { return m_evolveLvl; } int8 GetEvolveLvl() const { return m_evolveLvl; }
EvoItemInst* Clone() const; EvoItemInst* Clone() const;
const Item_Struct* GetItem() const; const Item_Struct* GetItem() const;
const Item_Struct* GetUnscaledItem() const; const Item_Struct* GetUnscaledItem() const;
void Initialize(SharedDatabase *db = nullptr); void Initialize(SharedDatabase *db = nullptr);
void ScaleItem(); void ScaleItem();
bool EvolveOnAllKills() const; bool EvolveOnAllKills() const;
int8 GetMaxEvolveLvl() const; int8 GetMaxEvolveLvl() const;
uint32 GetKillsNeeded(uint8 currentlevel); uint32 GetKillsNeeded(uint8 currentlevel);
private: private:
uint32 m_exp; uint32 m_exp;
@@ -447,7 +447,7 @@ public:
uint32 FirstItem; uint32 FirstItem;
uint8 MaxLvl; uint8 MaxLvl;
bool AllKills; bool AllKills;
EvolveInfo(); 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(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(); ~EvolveInfo();
+1555 -1555
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -83,7 +83,7 @@ void CoutTimestamp(bool ms) {
time(&rawtime); time(&rawtime);
gmt_t = gmtime(&rawtime); gmt_t = gmtime(&rawtime);
struct timeval read_time; struct timeval read_time;
gettimeofday(&read_time,0); gettimeofday(&read_time,0);
cout << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec; 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 #endif
/* /*
* generate a random integer in the range low-high this * generate a random integer in the range low-high this
* should be used instead of the rand()%limit method * 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 // Get a uint32 from t and c
// Better than uint32(x) in case x is floating point in [0,1] // Better than uint32(x) in case x is floating point in [0,1]
// Based on code by Lawrence Kirby (fred@genesis.demon.co.uk) // Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
static uint32 differ = 0; // guarantee time-based seeds will change static uint32 differ = 0; // guarantee time-based seeds will change
uint32 h1 = 0; uint32 h1 = 0;
unsigned char *p = (unsigned char *) &t; unsigned char *p = (unsigned char *) &t;
for( size_t i = 0; i < sizeof(t); ++i ) 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) char *CleanMobName(const char *in, char *out)
{ {
unsigned i, j; unsigned i, j;
for(i = j = 0; i < strlen(in); i++) for(i = j = 0; i < strlen(in); i++)
{ {
// convert _ to space.. any other conversions like this? I *think* this // convert _ to space.. any other conversions like this? I *think* this
+2 -2
View File
@@ -32,8 +32,8 @@
// These are helper macros for dealing with packets of variable length, typically those that contain // 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. // 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_TYPE(Type, Buffer) *(Type *)Buffer; Buffer += sizeof(Type);
#define VARSTRUCT_DECODE_STRING(String, Buffer) strcpy(String, Buffer); Buffer += strlen(String)+1; #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_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_INTSTRING(Buffer, Number) { sprintf(Buffer, "%i", Number); Buffer += strlen(Buffer) + 1; }
#define VARSTRUCT_ENCODE_TYPE(Type, Buffer, Value) { *(Type *)Buffer = Value; Buffer += sizeof(Type); } #define VARSTRUCT_ENCODE_TYPE(Type, Buffer, Value) { *(Type *)Buffer = Value; Buffer += sizeof(Type); }
+1 -1
View File
@@ -23,7 +23,7 @@ using namespace std;
#define DEBUG_MUTEX_CLASS 0 #define DEBUG_MUTEX_CLASS 0
#if DEBUG_MUTEX_CLASS >= 1 #if DEBUG_MUTEX_CLASS >= 1
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
+50 -50
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -71,7 +71,7 @@ void ProcLauncher::Process() {
//GetLastError(); //GetLastError();
TerminateProcess(cur->second->proc_info.hProcess, 1); TerminateProcess(cur->second->proc_info.hProcess, 1);
} }
//if we get here, the current process died. //if we get here, the current process died.
tmp = cur; tmp = cur;
tmp++; tmp++;
@@ -85,7 +85,7 @@ void ProcLauncher::Process() {
ProcRef died = waitpid(-1, &status, WNOHANG); ProcRef died = waitpid(-1, &status, WNOHANG);
if(died == -1) { if(died == -1) {
//error waiting... shouldent really happen... //error waiting... shouldent really happen...
} else if(died == 0) { } else if(died == 0) {
//nothing pending... //nothing pending...
break; break;
@@ -102,14 +102,14 @@ void ProcLauncher::Process() {
} }
} }
#endif //!WIN32 #endif //!WIN32
} }
void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) { void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) {
if(it->second->handler != nullptr) if(it->second->handler != nullptr)
it->second->handler->OnTerminate(it->first, it->second); it->second->handler->OnTerminate(it->first, it->second);
#ifdef _WINDOWS #ifdef _WINDOWS
CloseHandle(it->second->proc_info.hProcess); CloseHandle(it->second->proc_info.hProcess);
#else //!WIN32 #else //!WIN32
@@ -125,18 +125,18 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
#ifdef _WINDOWS #ifdef _WINDOWS
STARTUPINFO siStartInfo; STARTUPINFO siStartInfo;
BOOL bFuncRetn = FALSE; BOOL bFuncRetn = FALSE;
// Set up members of the PROCESS_INFORMATION structure. // Set up members of the PROCESS_INFORMATION structure.
ZeroMemory( &it->proc_info, sizeof(PROCESS_INFORMATION) ); 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) ); ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
siStartInfo.cb = sizeof(STARTUPINFO); siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.dwFlags = 0; siStartInfo.dwFlags = 0;
//handle output redirection. //handle output redirection.
HANDLE logOut = nullptr; HANDLE logOut = nullptr;
BOOL inherit_handles = FALSE; BOOL inherit_handles = FALSE;
@@ -144,9 +144,9 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
inherit_handles = TRUE; inherit_handles = TRUE;
// Set up our log file to redirect output into. // Set up our log file to redirect output into.
SECURITY_ATTRIBUTES saAttr; 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.bInheritHandle = TRUE; //we want this handle to be inherited by the child.
saAttr.lpSecurityDescriptor = nullptr; saAttr.lpSecurityDescriptor = nullptr;
logOut = CreateFile( logOut = CreateFile(
it->logFile.c_str(), //lpFileName it->logFile.c_str(), //lpFileName
FILE_WRITE_DATA, //dwDesiredAccess FILE_WRITE_DATA, //dwDesiredAccess
@@ -155,7 +155,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
CREATE_ALWAYS, //dwCreationDisposition CREATE_ALWAYS, //dwCreationDisposition
FILE_FLAG_NO_BUFFERING, //dwFlagsAndAttributes FILE_FLAG_NO_BUFFERING, //dwFlagsAndAttributes
nullptr ); //hTemplateFile nullptr ); //hTemplateFile
//configure the startup info to redirect output appropriately. //configure the startup info to redirect output appropriately.
siStartInfo.hStdError = logOut; siStartInfo.hStdError = logOut;
siStartInfo.hStdOutput = logOut; siStartInfo.hStdOutput = logOut;
@@ -164,9 +164,9 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
} }
siStartInfo.dwFlags |= CREATE_NEW_CONSOLE; siStartInfo.dwFlags |= CREATE_NEW_CONSOLE;
// Create the child process. // Create the child process.
//glue together all the nice command line arguments //glue together all the nice command line arguments
string args(it->program); string args(it->program);
vector<string>::iterator cur, end; vector<string>::iterator cur, end;
@@ -176,39 +176,39 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
args += " "; args += " ";
args += *cur; args += *cur;
} }
bFuncRetn = CreateProcess(it->program.c_str(), bFuncRetn = CreateProcess(it->program.c_str(),
const_cast<char *>(args.c_str()), // command line const_cast<char *>(args.c_str()), // command line
nullptr, // process security attributes nullptr, // process security attributes
nullptr, // primary thread security attributes nullptr, // primary thread security attributes
inherit_handles, // handles are not inherited inherit_handles, // handles are not inherited
0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe) 0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe)
nullptr, // use parent's environment nullptr, // use parent's environment
nullptr, // use parent's current directory nullptr, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer &siStartInfo, // STARTUPINFO pointer
&it->proc_info); // receives PROCESS_INFORMATION &it->proc_info); // receives PROCESS_INFORMATION
if (bFuncRetn == 0) { if (bFuncRetn == 0) {
safe_delete(it); safe_delete(it);
//GetLastError() //GetLastError()
return(ProcError); return(ProcError);
} }
//keep process handle open to get exit code //keep process handle open to get exit code
CloseHandle(it->proc_info.hThread); //we dont need their thread handle CloseHandle(it->proc_info.hThread); //we dont need their thread handle
if(logOut != nullptr) if(logOut != nullptr)
CloseHandle(logOut); //we dont want their output handle either. CloseHandle(logOut); //we dont want their output handle either.
ProcRef res = it->proc_info.dwProcessId; ProcRef res = it->proc_info.dwProcessId;
//record this entry.. //record this entry..
m_running[res] = it; m_running[res] = it;
return(res); return(res);
#else //!WIN32 #else //!WIN32
//build argv //build argv
char **argv = new char *[it->args.size()+2]; char **argv = new char *[it->args.size()+2];
unsigned int r; 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] = const_cast<char *>(it->args[r-1].c_str());
} }
argv[r] = nullptr; argv[r] = nullptr;
ProcRef res = fork(); //cant use vfork since we are opening the log file. ProcRef res = fork(); //cant use vfork since we are opening the log file.
if(res == -1) { if(res == -1) {
//error forking... errno //error forking... errno
@@ -225,10 +225,10 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
safe_delete_array(argv); safe_delete_array(argv);
return(ProcError); return(ProcError);
} }
if(res == 0) { if(res == 0) {
//child... exec this bitch //child... exec this bitch
//handle output redirection if requested. //handle output redirection if requested.
if(it->logFile.length() > 0) { if(it->logFile.length() > 0) {
//we will put their output directly into a file. //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)); write(outfd, err, strlen(err));
} }
close(STDIN_FILENO); close(STDIN_FILENO);
close(outfd); //dont need this one, we have two more copies... close(outfd); //dont need this one, we have two more copies...
} }
} }
//call it... //call it...
execv(argv[0], argv); execv(argv[0], argv);
_exit(1); _exit(1);
} }
safe_delete_array(argv); safe_delete_array(argv);
//record this entry.. //record this entry..
m_running[res] = it; m_running[res] = it;
return(res); return(res);
#endif //!WIN32 #endif //!WIN32
} }
@@ -277,10 +277,10 @@ bool ProcLauncher::Terminate(const ProcRef &proc, bool graceful) {
std::map<ProcRef, Spec *>::iterator res = m_running.find(proc); std::map<ProcRef, Spec *>::iterator res = m_running.find(proc);
if(res == m_running.end()) if(res == m_running.end())
return(false); return(false);
//we do not remove it from the list until we have been notified //we do not remove it from the list until we have been notified
//that they have been terminated. //that they have been terminated.
#ifdef _WINDOWS #ifdef _WINDOWS
if(!TerminateProcess(res->second->proc_info.hProcess, 0)) { if(!TerminateProcess(res->second->proc_info.hProcess, 0)) {
return(false); return(false);
@@ -311,7 +311,7 @@ void ProcLauncher::TerminateAll(bool final) {
//kill each process and remove it from the list //kill each process and remove it from the list
std::map<ProcRef, Spec *> running(m_running); std::map<ProcRef, Spec *> running(m_running);
m_running.clear(); m_running.clear();
std::map<ProcRef, Spec *>::iterator cur, end; std::map<ProcRef, Spec *>::iterator cur, end;
cur = running.begin(); cur = running.begin();
end = running.end(); end = running.end();
+9 -9
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -32,7 +32,7 @@ public:
//Singleton method //Singleton method
static ProcLauncher *get() { return(&s_launcher); } static ProcLauncher *get() { return(&s_launcher); }
static void ProcessInThisThread(); static void ProcessInThisThread();
#ifdef WIN32 #ifdef WIN32
typedef DWORD ProcRef; typedef DWORD ProcRef;
static const ProcRef ProcError; static const ProcRef ProcError;
@@ -47,7 +47,7 @@ public:
Spec(); Spec();
Spec(const Spec &other); Spec(const Spec &other);
Spec &operator=(const Spec &other); Spec &operator=(const Spec &other);
std::string program; std::string program;
std::vector<std::string> args; std::vector<std::string> args;
//std::map<std::string,std::string> environment; //std::map<std::string,std::string> environment;
@@ -64,18 +64,18 @@ public:
virtual ~EventHandler() {} virtual ~EventHandler() {}
virtual void OnTerminate(const ProcRef &ref, const Spec *spec) = 0; virtual void OnTerminate(const ProcRef &ref, const Spec *spec) = 0;
}; };
/* /*
* The main launch method, call to start a new background process. * The main launch method, call to start a new background process.
*/ */
ProcRef Launch(Spec *&to_launch); //takes ownership of the pointer ProcRef Launch(Spec *&to_launch); //takes ownership of the pointer
/* /*
* The terminate method * The terminate method
*/ */
bool Terminate(const ProcRef &proc, bool graceful = true); bool Terminate(const ProcRef &proc, bool graceful = true);
void TerminateAll(bool final = true); void TerminateAll(bool final = true);
/* /*
* The main processing method. Call regularly to check for terminated * The main processing method. Call regularly to check for terminated
* background processes. * background processes.
@@ -85,9 +85,9 @@ public:
protected: protected:
// std::vector<Spec *> m_specs; // std::vector<Spec *> m_specs;
std::map<ProcRef, Spec *> m_running; //we own the pointers in this map std::map<ProcRef, Spec *> m_running; //we own the pointers in this map
void ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it); void ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it);
private: private:
static ProcLauncher s_launcher; static ProcLauncher s_launcher;
#ifndef WIN32 #ifndef WIN32
+7 -7
View File
@@ -28,13 +28,13 @@ void StructStrategy::Decode(EQApplicationPacket *p) const {
proc(p); proc(p);
} }
void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bool ack_req) { void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bool ack_req) {
EQApplicationPacket *p = *in_p; EQApplicationPacket *p = *in_p;
*in_p = nullptr; *in_p = nullptr;
_log(NET__STRUCTS, "Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode())); _log(NET__STRUCTS, "Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode()));
delete p; 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. //effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory { namespace StructStrategyFactory {
static map<EmuOpcode, const StructStrategy *> strategies; static map<EmuOpcode, const StructStrategy *> strategies;
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) { void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
strategies[first_opcode] = structs; strategies[first_opcode] = structs;
} }
const StructStrategy *FindPatch(EmuOpcode first_opcode) { const StructStrategy *FindPatch(EmuOpcode first_opcode) {
map<EmuOpcode, const StructStrategy *>::const_iterator res; map<EmuOpcode, const StructStrategy *>::const_iterator res;
res = strategies.find(first_opcode); res = strategies.find(first_opcode);
@@ -70,7 +70,7 @@ namespace StructStrategyFactory {
return(nullptr); return(nullptr);
return(res->second); return(res->second);
} }
}; };
+6 -6
View File
@@ -14,18 +14,18 @@ public:
typedef void (*Encoder)(EQApplicationPacket **p, EQStream *dest, bool ack_req); 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. //the decoder may only edit the supplied packet, producing a single packet for eqemu to consume.
typedef void (*Decoder)(EQApplicationPacket *p); typedef void (*Decoder)(EQApplicationPacket *p);
StructStrategy(); StructStrategy();
virtual ~StructStrategy() {} virtual ~StructStrategy() {}
//this method takes an eqemu struct, and enqueues the produced structs into the stream. //this method takes an eqemu struct, and enqueues the produced structs into the stream.
void Encode(EQApplicationPacket **p, EQStream *dest, bool ack_req) const; void Encode(EQApplicationPacket **p, EQStream *dest, bool ack_req) const;
//this method takes an EQ wire struct, and converts it into an eqemu struct //this method takes an EQ wire struct, and converts it into an eqemu struct
void Decode(EQApplicationPacket *p) const; void Decode(EQApplicationPacket *p) const;
virtual std::string Describe() const = 0; virtual std::string Describe() const = 0;
virtual const EQClientVersion ClientVersion() const = 0; virtual const EQClientVersion ClientVersion() const = 0;
protected: protected:
//some common coders: //some common coders:
//Print an error saying unknown struct/opcode and drop it //Print an error saying unknown struct/opcode and drop it
@@ -34,7 +34,7 @@ protected:
//pass the packet through without modification (emu == EQ) (default) //pass the packet through without modification (emu == EQ) (default)
static void PassEncoder(EQApplicationPacket **p, EQStream *dest, bool ack_req); static void PassEncoder(EQApplicationPacket **p, EQStream *dest, bool ack_req);
static void PassDecoder(EQApplicationPacket *p); static void PassDecoder(EQApplicationPacket *p);
Encoder encoders[_maxEmuOpcode]; Encoder encoders[_maxEmuOpcode];
Decoder decoders[_maxEmuOpcode]; Decoder decoders[_maxEmuOpcode];
}; };
@@ -42,7 +42,7 @@ protected:
//effectively a singleton, but I decided to do it this way for no apparent reason. //effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory { namespace StructStrategyFactory {
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs); void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs);
//does NOT return ownership of the strategy. //does NOT return ownership of the strategy.
const StructStrategy *FindPatch(EmuOpcode first_opcode); const StructStrategy *FindPatch(EmuOpcode first_opcode);
}; };
+19 -19
View File
@@ -490,7 +490,7 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
SetEcho(false); SetEcho(false);
ClearBuffers(); ClearBuffers();
rIP = in_ip; rIP = in_ip;
rPort = in_port; rPort = in_port;
SetState(TCPS_Connected); SetState(TCPS_Connected);
@@ -504,7 +504,7 @@ void TCPConnection::ClearBuffers() {
LockMutex lock4(&MState); LockMutex lock4(&MState);
safe_delete_array(recvbuf); safe_delete_array(recvbuf);
safe_delete_array(sendbuf); safe_delete_array(sendbuf);
char* line = 0; char* line = 0;
while ((line = LineOutQueue.pop())) while ((line = LineOutQueue.pop()))
safe_delete_array(line); safe_delete_array(line);
@@ -520,7 +520,7 @@ bool TCPConnection::CheckNetActive() {
return false; 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. */ * special thread we create when we make an outbound connection. */
bool TCPConnection::Process() { bool TCPConnection::Process() {
char errbuf[TCPConnection_ErrorBufferSize]; char errbuf[TCPConnection_ErrorBufferSize];
@@ -535,7 +535,7 @@ bool TCPConnection::Process() {
} }
} }
return(true); return(true);
case TCPS_Connected: case TCPS_Connected:
// only receive data in the connected state, no others... // only receive data in the connected state, no others...
if (!RecvData(errbuf)) { if (!RecvData(errbuf)) {
@@ -546,7 +546,7 @@ bool TCPConnection::Process() {
} }
/* we break to do the send */ /* we break to do the send */
break; break;
case TCPS_Disconnecting: { case TCPS_Disconnecting: {
//waiting for any sending data to go out... //waiting for any sending data to go out...
MSendQueue.lock(); MSendQueue.lock();
@@ -562,7 +562,7 @@ bool TCPConnection::Process() {
MSendQueue.unlock(); MSendQueue.unlock();
} }
/* Fallthrough */ /* Fallthrough */
case TCPS_Disconnected: case TCPS_Disconnected:
FinishDisconnect(); FinishDisconnect();
MRunLoop.lock(); MRunLoop.lock();
@@ -570,19 +570,19 @@ bool TCPConnection::Process() {
MRunLoop.unlock(); MRunLoop.unlock();
// SetState(TCPS_Ready); //reset the state in case they want to use it again... // SetState(TCPS_Ready); //reset the state in case they want to use it again...
return(false); return(false);
case TCPS_Closing: case TCPS_Closing:
//I dont understand this state... //I dont understand this state...
case TCPS_Error: case TCPS_Error:
MRunLoop.lock(); MRunLoop.lock();
pRunLoop = false; pRunLoop = false;
MRunLoop.unlock(); MRunLoop.unlock();
return(false); return(false);
} }
/* we get here in connected or disconnecting with more data to send */ /* we get here in connected or disconnecting with more data to send */
bool sent_something = false; bool sent_something = false;
if (!SendData(sent_something, errbuf)) { if (!SendData(sent_something, errbuf)) {
struct in_addr in; struct in_addr in;
@@ -590,7 +590,7 @@ bool TCPConnection::Process() {
cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl; cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
return false; return false;
} }
return true; return true;
} }
@@ -770,15 +770,15 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
i = -1; i = -1;
m_previousLineEnd = true; m_previousLineEnd = true;
} }
if(line != nullptr) { if(line != nullptr) {
bool finish_proc = false; bool finish_proc = false;
finish_proc = LineOutQueuePush(line); finish_proc = LineOutQueuePush(line);
if(finish_proc) if(finish_proc)
return(true); //break early as requested by LineOutQueuePush return(true); //break early as requested by LineOutQueuePush
} }
break; break;
} }
case 8: // backspace 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)); snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::SendData(): send(): Errorcode: %s", strerror(errno));
#endif #endif
} }
//if we get an error while disconnecting, just jump to disconnected //if we get an error while disconnecting, just jump to disconnected
MState.lock(); MState.lock();
if(pState == TCPS_Disconnecting) if(pState == TCPS_Disconnecting)
pState = TCPS_Disconnected; pState = TCPS_Disconnected;
MState.unlock(); MState.unlock();
return false; return false;
} }
} }
@@ -908,7 +908,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
if (!tcpc->ConnectReady()) { if (!tcpc->ConnectReady()) {
_CP(TCPConnectionLoop); _CP(TCPConnectionLoop);
if (!tcpc->Process()) { 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. //we want to drop the link immediately, so we clear buffers too.
tcpc->ClearBuffers(); tcpc->ClearBuffers();
tcpc->Disconnect(); tcpc->Disconnect();
@@ -927,11 +927,11 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
Sleep(10); //nothing to do. Sleep(10); //nothing to do.
} }
tcpc->MLoopRunning.unlock(); tcpc->MLoopRunning.unlock();
#ifndef WIN32 #ifndef WIN32
_log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(nullptr); THREAD_RETURN(nullptr);
} }
+13 -13
View File
@@ -75,15 +75,15 @@ protected:
TCPS_Closing = 250, TCPS_Closing = 250,
TCPS_Error = 255 TCPS_Error = 255
} State_t; } State_t;
public: public:
//socket created by a server (incoming) //socket created by a server (incoming)
TCPConnection(uint32 ID, SOCKET iSock, uint32 irIP, uint16 irPort); TCPConnection(uint32 ID, SOCKET iSock, uint32 irIP, uint16 irPort);
//socket created to connect to a server (outgoing) //socket created to connect to a server (outgoing)
TCPConnection(); // for outgoing connections TCPConnection(); // for outgoing connections
virtual ~TCPConnection(); virtual ~TCPConnection();
// Functions for outgoing connections // Functions for outgoing connections
bool Connect(const char* irAddress, uint16 irPort, char* errbuf = 0); bool Connect(const char* irAddress, uint16 irPort, char* errbuf = 0);
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0); virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
@@ -92,7 +92,7 @@ public:
virtual void Disconnect(); virtual void Disconnect();
bool Send(const uchar* data, int32 size); bool Send(const uchar* data, int32 size);
char* PopLine(); //returns ownership of allocated byte array char* PopLine(); //returns ownership of allocated byte array
inline uint32 GetrIP() const { return rIP; } inline uint32 GetrIP() const { return rIP; }
inline uint16 GetrPort() const { return rPort; } inline uint16 GetrPort() const { return rPort; }
@@ -106,7 +106,7 @@ public:
bool GetEcho(); bool GetEcho();
void SetEcho(bool iValue); void SetEcho(bool iValue);
bool GetSockName(char *host, uint16 *port); bool GetSockName(char *host, uint16 *port);
//should only be used by TCPServer<T>: //should only be used by TCPServer<T>:
bool CheckNetActive(); bool CheckNetActive();
inline bool IsFree() const { return pFree; } inline bool IsFree() const { return pFree; }
@@ -129,10 +129,10 @@ protected:
virtual bool ProcessReceivedData(char* errbuf = 0); virtual bool ProcessReceivedData(char* errbuf = 0);
virtual bool SendData(bool &sent_something, char* errbuf = 0); virtual bool SendData(bool &sent_something, char* errbuf = 0);
virtual bool RecvData(char* errbuf = 0); virtual bool RecvData(char* errbuf = 0);
virtual void ClearBuffers(); virtual void ClearBuffers();
bool m_previousLineEnd; bool m_previousLineEnd;
eConnectionType ConnectionType; eConnectionType ConnectionType;
@@ -144,22 +144,22 @@ protected:
uint32 rIP; uint32 rIP;
uint16 rPort; // host byte order uint16 rPort; // host byte order
bool pFree; bool pFree;
mutable Mutex MState; mutable Mutex MState;
State_t pState; State_t pState;
//text based line out queue. //text based line out queue.
Mutex MLineOutQueue; 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. 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; MyQueue<char> LineOutQueue;
uchar* recvbuf; uchar* recvbuf;
int32 recvbuf_size; int32 recvbuf_size;
int32 recvbuf_used; int32 recvbuf_used;
int32 recvbuf_echo; int32 recvbuf_echo;
volatile bool pEcho; volatile bool pEcho;
Mutex MSendQueue; Mutex MSendQueue;
uchar* sendbuf; uchar* sendbuf;
int32 sendbuf_size; int32 sendbuf_size;
@@ -169,7 +169,7 @@ protected:
void ServerSendQueuePushEnd(const uchar* data, int32 size); void ServerSendQueuePushEnd(const uchar* data, int32 size);
void ServerSendQueuePushEnd(uchar** data, int32 size); void ServerSendQueuePushEnd(uchar** data, int32 size);
void ServerSendQueuePushFront(uchar* data, int32 size); void ServerSendQueuePushFront(uchar* data, int32 size);
private: private:
void FinishDisconnect(); void FinishDisconnect();
}; };
+8 -8
View File
@@ -70,11 +70,11 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
THREAD_RETURN(nullptr); THREAD_RETURN(nullptr);
} }
BaseTCPServer* tcps = (BaseTCPServer*) tmp; BaseTCPServer* tcps = (BaseTCPServer*) tmp;
#ifndef WIN32 #ifndef WIN32
_log(COMMON__THREADS, "Starting TCPServerLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Starting TCPServerLoop with thread ID %d", pthread_self());
#endif #endif
tcps->MLoopRunning.lock(); tcps->MLoopRunning.lock();
while (tcps->RunLoop()) { while (tcps->RunLoop()) {
_CP(BaseTCPServerLoop); _CP(BaseTCPServerLoop);
@@ -82,11 +82,11 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
tcps->Process(); tcps->Process();
} }
tcps->MLoopRunning.unlock(); tcps->MLoopRunning.unlock();
#ifndef WIN32 #ifndef WIN32
_log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(nullptr); THREAD_RETURN(nullptr);
} }
@@ -100,7 +100,7 @@ void BaseTCPServer::ListenNewConnections() {
struct in_addr in; struct in_addr in;
unsigned int fromlen; unsigned int fromlen;
unsigned short port; unsigned short port;
from.sin_family = AF_INET; from.sin_family = AF_INET;
fromlen = sizeof(from); fromlen = sizeof(from);
LockMutex lock(&MSock); LockMutex lock(&MSock);
@@ -124,7 +124,7 @@ void BaseTCPServer::ListenNewConnections() {
setsockopt(tmpsock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize)); setsockopt(tmpsock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize));
port = from.sin_port; port = from.sin_port;
in.s_addr = from.sin_addr.s_addr; in.s_addr = from.sin_addr.s_addr;
// New TCP connection, this must consume the socket. // New TCP connection, this must consume the socket.
CreateNewConnection(GetNextID(), tmpsock, in.s_addr, ntohs(from.sin_port)); CreateNewConnection(GetNextID(), tmpsock, in.s_addr, ntohs(from.sin_port));
} }
@@ -151,7 +151,7 @@ bool BaseTCPServer::Open(uint16 in_port, char* errbuf) {
#endif #endif
int reuse_addr = 1; int reuse_addr = 1;
// Setup internet address information. // Setup internet address information.
// This is used with the bind() call // This is used with the bind() call
memset((char *) &address, 0, sizeof(address)); memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET; address.sin_family = AF_INET;
@@ -211,7 +211,7 @@ bool BaseTCPServer::Open(uint16 in_port, char* errbuf) {
void BaseTCPServer::Close() { void BaseTCPServer::Close() {
StopLoopAndWait(); StopLoopAndWait();
LockMutex lock(&MSock); LockMutex lock(&MSock);
if (sock) { if (sock) {
#ifdef _WINDOWS #ifdef _WINDOWS
+13 -13
View File
@@ -22,17 +22,17 @@ public:
protected: protected:
static ThreadReturnType TCPServerLoop(void* tmp); static ThreadReturnType TCPServerLoop(void* tmp);
//factory method: //factory method:
virtual void CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) = 0; virtual void CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) = 0;
virtual void Process(); virtual void Process();
bool RunLoop(); bool RunLoop();
Mutex MLoopRunning; Mutex MLoopRunning;
void StopLoopAndWait(); void StopLoopAndWait();
void ListenNewConnections(); void ListenNewConnections();
uint32 NextID; uint32 NextID;
@@ -55,10 +55,10 @@ public:
TCPServer(uint16 iPort = 0) TCPServer(uint16 iPort = 0)
: BaseTCPServer(iPort) { : BaseTCPServer(iPort) {
} }
virtual ~TCPServer() { virtual ~TCPServer() {
StopLoopAndWait(); StopLoopAndWait();
//im not sure what the right thing to do here is... //im not sure what the right thing to do here is...
//we are freeing a connection which somebody likely has a pointer to.. //we are freeing a connection which somebody likely has a pointer to..
//but, we really shouldent ever get called anyhow.. //but, we really shouldent ever get called anyhow..
@@ -69,7 +69,7 @@ public:
delete *cur; delete *cur;
} }
} }
T * NewQueuePop() { T * NewQueuePop() {
T * ret = nullptr; T * ret = nullptr;
MNewQueue.lock(); MNewQueue.lock();
@@ -80,11 +80,11 @@ public:
MNewQueue.unlock(); MNewQueue.unlock();
return ret; return ret;
} }
protected: protected:
virtual void Process() { virtual void Process() {
BaseTCPServer::Process(); BaseTCPServer::Process();
vitr cur; vitr cur;
cur = m_list.begin(); cur = m_list.begin();
while(cur != m_list.end()) { while(cur != m_list.end()) {
@@ -102,18 +102,18 @@ protected:
} }
} }
} }
void AddConnection(T *con) { void AddConnection(T *con) {
m_list.push_back(con); m_list.push_back(con);
MNewQueue.lock(); MNewQueue.lock();
m_NewQueue.push(con); m_NewQueue.push(con);
MNewQueue.unlock(); MNewQueue.unlock();
} }
//queue of new connections, for the app to pull from //queue of new connections, for the app to pull from
Mutex MNewQueue; Mutex MNewQueue;
std::queue<T *> m_NewQueue; std::queue<T *> m_NewQueue;
vstore m_list; vstore m_list;
}; };
+11 -11
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -29,7 +29,7 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc()); printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());
return(false); return(false);
} }
TiXmlElement *root = doc.FirstChildElement( root_ele ); TiXmlElement *root = doc.FirstChildElement( root_ele );
if(root == nullptr) { if(root == nullptr) {
printf("Unable to find root '%s' in %s\n",root_ele, file); 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; ParseOkay=true;
TiXmlNode *main_element = nullptr; TiXmlNode *main_element = nullptr;
while( (main_element = root->IterateChildren( main_element )) ) { while( (main_element = root->IterateChildren( main_element )) ) {
if(main_element->Type() != TiXmlNode::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()); handler=Handlers.find(ele->Value());
if (handler!=Handlers.end() && handler->second) { if (handler!=Handlers.end() && handler->second) {
ElementHandler h=handler->second; ElementHandler h=handler->second;
/* /*
* *
* This is kinda a sketchy operation here, since all of these * This is kinda a sketchy operation here, since all of these
* element handler methods will be functions in child classes. * element handler methods will be functions in child classes.
* This essentially causes us to do an un-checkable (and hence * This essentially causes us to do an un-checkable (and hence
* un-handle-properly-able) cast down to the child class. This * un-handle-properly-able) cast down to the child class. This
* WILL BREAK if any children classes do multiple inheritance. * WILL BREAK if any children classes do multiple inheritance.
* *
* *
*/ */
(this->*h)(ele); (this->*h)(ele);
} else { } else {
//unhandled element.... do nothing for now //unhandled element.... do nothing for now
} }
} }
return(ParseOkay); return(ParseOkay);
} }
+6 -6
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -34,13 +34,13 @@ using namespace std;
class XMLParser { class XMLParser {
public: public:
typedef void (XMLParser::*ElementHandler)(TiXmlElement *ele); typedef void (XMLParser::*ElementHandler)(TiXmlElement *ele);
XMLParser(); XMLParser();
virtual ~XMLParser() {} virtual ~XMLParser() {}
bool ParseFile(const char *file, const char *root_ele); bool ParseFile(const char *file, const char *root_ele);
bool ParseStatus() const { return ParseOkay; } bool ParseStatus() const { return ParseOkay; }
protected: protected:
const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false); const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false);
const char *GetText(TiXmlNode *within, bool optional = false); const char *GetText(TiXmlNode *within, bool optional = false);
@@ -48,7 +48,7 @@ protected:
map<string,ElementHandler> Handlers; map<string,ElementHandler> Handlers;
bool ParseOkay; bool ParseOkay;
}; };
+1 -1
View File
@@ -25,7 +25,7 @@ typedef enum {
BT_Giant = 4, BT_Giant = 4,
BT_Construct = 5, BT_Construct = 5,
BT_Extraplanar = 6, 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_SummonedUndead = 8,
BT_RaidGiant = 9, BT_RaidGiant = 9,
// ... // ...
+2 -2
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+212 -212
View File
@@ -20,226 +20,226 @@
const char* GetEQClassName(uint8 class_, uint8 level) { const char* GetEQClassName(uint8 class_, uint8 level) {
switch(class_) { switch(class_) {
case WARRIOR: case WARRIOR:
if (level >= 70) if (level >= 70)
return "Vanquisher"; return "Vanquisher";
else if (level >= 65) else if (level >= 65)
return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE. return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE.
else if (level >= 60) else if (level >= 60)
return "Warlord"; return "Warlord";
else if (level >= 55) else if (level >= 55)
return "Myrmidon"; return "Myrmidon";
else if (level >= 51) else if (level >= 51)
return "Champion"; return "Champion";
else else
return "Warrior"; return "Warrior";
case CLERIC: case CLERIC:
if (level >= 70) if (level >= 70)
return "Prelate"; return "Prelate";
else if (level >= 65) else if (level >= 65)
return "Archon"; return "Archon";
else if (level >= 60) else if (level >= 60)
return "High Priest"; return "High Priest";
else if (level >= 55) else if (level >= 55)
return "Templar"; return "Templar";
else if (level >= 51) else if (level >= 51)
return "Vicar"; return "Vicar";
else else
return "Cleric"; return "Cleric";
case PALADIN: case PALADIN:
if (level >= 70) if (level >= 70)
return "Lord"; return "Lord";
else if (level >= 65) else if (level >= 65)
return "Lord Protector"; return "Lord Protector";
else if (level >= 60) else if (level >= 60)
return "Crusader"; return "Crusader";
else if (level >= 55) else if (level >= 55)
return "Knight"; return "Knight";
else if (level >= 51) else if (level >= 51)
return "Cavalier"; return "Cavalier";
else else
return "Paladin"; return "Paladin";
case RANGER: case RANGER:
if (level >= 70) if (level >= 70)
return "Plainswalker"; return "Plainswalker";
else if (level >= 65) else if (level >= 65)
return "Forest Stalker"; return "Forest Stalker";
else if (level >= 60) else if (level >= 60)
return "Warder"; return "Warder";
else if (level >= 55) else if (level >= 55)
return "Outrider"; return "Outrider";
else if (level >= 51) else if (level >= 51)
return "Pathfinder"; return "Pathfinder";
else else
return "Ranger"; return "Ranger";
case SHADOWKNIGHT: case SHADOWKNIGHT:
if (level >= 70) if (level >= 70)
return "Scourge Knight"; return "Scourge Knight";
else if (level >= 65) else if (level >= 65)
return "Dread Lord"; return "Dread Lord";
else if (level >= 60) else if (level >= 60)
return "Grave Lord"; return "Grave Lord";
else if (level >= 55) else if (level >= 55)
return "Revenant"; return "Revenant";
else if (level >= 51) else if (level >= 51)
return "Reaver"; return "Reaver";
else else
return "Shadowknight"; return "Shadowknight";
case DRUID: case DRUID:
if (level >= 70) if (level >= 70)
return "Natureguard"; return "Natureguard";
else if (level >= 65) else if (level >= 65)
return "Storm Warden"; return "Storm Warden";
else if (level >= 60) else if (level >= 60)
return "Hierophant"; return "Hierophant";
else if (level >= 55) else if (level >= 55)
return "Preserver"; return "Preserver";
else if (level >= 51) else if (level >= 51)
return "Wanderer"; return "Wanderer";
else else
return "Druid"; return "Druid";
case MONK: case MONK:
if (level >= 70) if (level >= 70)
return "Stone Fist"; return "Stone Fist";
else if (level >= 65) else if (level >= 65)
return "Transcendent"; return "Transcendent";
else if (level >= 60) else if (level >= 60)
return "Grandmaster"; return "Grandmaster";
else if (level >= 55) else if (level >= 55)
return "Master"; return "Master";
else if (level >= 51) else if (level >= 51)
return "Disciple"; return "Disciple";
else else
return "Monk"; return "Monk";
case BARD: case BARD:
if (level >= 70) if (level >= 70)
return "Performer"; return "Performer";
else if (level >= 65) else if (level >= 65)
return "Maestro"; return "Maestro";
else if (level >= 60) else if (level >= 60)
return "Virtuoso"; return "Virtuoso";
else if (level >= 55) else if (level >= 55)
return "Troubadour"; return "Troubadour";
else if (level >= 51) else if (level >= 51)
return "Minstrel"; return "Minstrel";
else else
return "Bard"; return "Bard";
case ROGUE: case ROGUE:
if (level >= 70) if (level >= 70)
return "Nemesis"; return "Nemesis";
else if (level >= 65) else if (level >= 65)
return "Deceiver"; return "Deceiver";
else if (level >= 60) else if (level >= 60)
return "Assassin"; return "Assassin";
else if (level >= 55) else if (level >= 55)
return "Blackguard"; return "Blackguard";
else if (level >= 51) else if (level >= 51)
return "Rake"; return "Rake";
else else
return "Rogue"; return "Rogue";
case SHAMAN: case SHAMAN:
if (level >= 70) if (level >= 70)
return "Soothsayer"; return "Soothsayer";
else if (level >= 65) else if (level >= 65)
return "Prophet"; return "Prophet";
else if (level >= 60) else if (level >= 60)
return "Oracle"; return "Oracle";
else if (level >= 55) else if (level >= 55)
return "Luminary"; return "Luminary";
else if (level >= 51) else if (level >= 51)
return "Mystic"; return "Mystic";
else else
return "Shaman"; return "Shaman";
case NECROMANCER: case NECROMANCER:
if (level >= 70) if (level >= 70)
return "Wraith"; return "Wraith";
else if (level >= 65) else if (level >= 65)
return "Arch Lich"; return "Arch Lich";
else if (level >= 60) else if (level >= 60)
return "Warlock"; return "Warlock";
else if (level >= 55) else if (level >= 55)
return "Defiler"; return "Defiler";
else if (level >= 51) else if (level >= 51)
return "Heretic"; return "Heretic";
else else
return "Necromancer"; return "Necromancer";
case WIZARD: case WIZARD:
if (level >= 70) if (level >= 70)
return "Grand Arcanist"; return "Grand Arcanist";
else if (level >= 65) else if (level >= 65)
return "Arcanist"; return "Arcanist";
else if (level >= 60) else if (level >= 60)
return "Sorcerer"; return "Sorcerer";
else if (level >= 55) else if (level >= 55)
return "Evoker"; return "Evoker";
else if (level >= 51) else if (level >= 51)
return "Channeler"; return "Channeler";
else else
return "Wizard"; return "Wizard";
case MAGICIAN: case MAGICIAN:
if (level >= 70) if (level >= 70)
return "Arch Magus"; return "Arch Magus";
else if (level >= 65) else if (level >= 65)
return "Arch Convoker"; return "Arch Convoker";
else if (level >= 60) else if (level >= 60)
return "Arch Mage"; return "Arch Mage";
else if (level >= 55) else if (level >= 55)
return "Conjurer"; return "Conjurer";
if (level >= 51) if (level >= 51)
return "Elementalist"; return "Elementalist";
else else
return "Magician"; return "Magician";
case ENCHANTER: case ENCHANTER:
if (level >= 70) if (level >= 70)
return "Bedazzler"; return "Bedazzler";
else if (level >= 65) else if (level >= 65)
return "Coercer"; return "Coercer";
else if (level >= 60) else if (level >= 60)
return "Phantasmist"; return "Phantasmist";
else if (level >= 55) else if (level >= 55)
return "Beguiler"; return "Beguiler";
else if (level >= 51) else if (level >= 51)
return "Illusionist"; return "Illusionist";
else else
return "Enchanter"; return "Enchanter";
case BEASTLORD: case BEASTLORD:
if (level >= 70) if (level >= 70)
return "Wildblood"; return "Wildblood";
else if (level >= 65) else if (level >= 65)
return "Feral Lord"; return "Feral Lord";
else if (level >= 60) else if (level >= 60)
return "Savage Lord"; return "Savage Lord";
else if (level >= 55) else if (level >= 55)
return "Animist"; return "Animist";
else if (level >= 51) else if (level >= 51)
return "Primalist"; return "Primalist";
else else
return "Beastlord"; return "Beastlord";
case BERSERKER: case BERSERKER:
if (level >= 70) if (level >= 70)
return "Ravager"; return "Ravager";
else if (level >= 65) else if (level >= 65)
return "Fury"; return "Fury";
else if (level >= 60) else if (level >= 60)
return "Rager"; return "Rager";
else if (level >= 55) else if (level >= 55)
return "Vehement"; return "Vehement";
else if (level >= 51) else if (level >= 51)
return "Brawler"; return "Brawler";
else else
return "Berserker"; return "Berserker";
case BANKER: case BANKER:
if (level >= 70) if (level >= 70)
return "Master Banker"; return "Master Banker";
else if (level >= 65) else if (level >= 65)
return "Elder Banker"; return "Elder Banker";
else if (level >= 60) else if (level >= 60)
return "Oldest Banker"; return "Oldest Banker";
else if (level >= 55) else if (level >= 55)
return "Older Banker"; return "Older Banker";
else if (level >= 51) else if (level >= 51)
return "Old Banker"; return "Old Banker";
else else
return "Banker"; return "Banker";
case WARRIORGM: case WARRIORGM:
return "Warrior Guildmaster"; return "Warrior Guildmaster";
+15 -15
View File
@@ -37,23 +37,23 @@
#define BEASTLORD 15 #define BEASTLORD 15
#define BERSERKER 16 #define BERSERKER 16
#define PLAYER_CLASS_COUNT 16 // used for array defines, must be the count of playable classes #define PLAYER_CLASS_COUNT 16 // used for array defines, must be the count of playable classes
#define WARRIORGM 20 #define WARRIORGM 20
#define CLERICGM 21 #define CLERICGM 21
#define PALADINGM 22 #define PALADINGM 22
#define RANGERGM 23 #define RANGERGM 23
#define SHADOWKNIGHTGM 24 #define SHADOWKNIGHTGM 24
#define DRUIDGM 25 #define DRUIDGM 25
#define MONKGM 26 #define MONKGM 26
#define BARDGM 27 #define BARDGM 27
#define ROGUEGM 28 #define ROGUEGM 28
#define SHAMANGM 29 #define SHAMANGM 29
#define NECROMANCERGM 30 #define NECROMANCERGM 30
#define WIZARDGM 31 #define WIZARDGM 31
#define MAGICIANGM 32 #define MAGICIANGM 32
#define ENCHANTERGM 33 #define ENCHANTERGM 33
#define BEASTLORDGM 34 #define BEASTLORDGM 34
#define BERSERKERGM 35 #define BERSERKERGM 35
#define BANKER 40 #define BANKER 40
#define MERCHANT 41 #define MERCHANT 41
#define DISCORD_MERCHANT 59 #define DISCORD_MERCHANT 59
#define ADVENTURERECRUITER 60 #define ADVENTURERECRUITER 60
+12 -12
View File
@@ -45,41 +45,41 @@ public:
Database_DBLoadItems, Database_DBLoadItems,
Database_GetWaypoints, Database_GetWaypoints,
Database_DBLoadNPCFactionLists, Database_DBLoadNPCFactionLists,
DBcore_RunQuery, DBcore_RunQuery,
DBAsync_ProcessWork, DBAsync_ProcessWork,
DBAsync_DispatchWork, DBAsync_DispatchWork,
DBAsyncLoop_loop, DBAsyncLoop_loop,
EQStreamServer_Process, EQStreamServer_Process,
EQStream_Process, EQStream_Process,
EQStreamServerLoop, EQStreamServerLoop,
EQStreamInLoop, EQStreamInLoop,
EQStreamOutLoop, EQStreamOutLoop,
TCPServerLoop, TCPServerLoop,
TCPConnectionLoop, TCPConnectionLoop,
Inventory_GetItem, Inventory_GetItem,
Inventory_HasItem, Inventory_HasItem,
BaseTCPServerLoop, BaseTCPServerLoop,
MakeRandomInt, MakeRandomInt,
MakeRandomFloat, MakeRandomFloat,
Mutex_lock, Mutex_lock,
Timer_Check, Timer_Check,
WorldConnection_Process, WorldConnection_Process,
MaxCommonProfilerId MaxCommonProfilerId
}; };
inline CommonProfiler() : GeneralProfiler(MaxCommonProfilerId) { } inline CommonProfiler() : GeneralProfiler(MaxCommonProfilerId) { }
}; };
extern CommonProfiler _cp; extern CommonProfiler _cp;
+6 -6
View File
@@ -9,7 +9,7 @@ class EQEmuStackWalker : public StackWalker
public: public:
EQEmuStackWalker() : StackWalker() { } EQEmuStackWalker() : StackWalker() { }
EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { } EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { }
virtual void OnOutput(LPCSTR szText) { virtual void OnOutput(LPCSTR szText) {
char buffer[4096]; char buffer[4096];
for(int i = 0; i < 4096; ++i) { for(int i = 0; i < 4096; ++i) {
if(szText[i] == 0) { if(szText[i] == 0) {
@@ -24,8 +24,8 @@ public:
} }
} }
LogFile->write(EQEMuLog::Crash, buffer); LogFile->write(EQEMuLog::Crash, buffer);
StackWalker::OnOutput(szText); StackWalker::OnOutput(szText);
} }
}; };
@@ -97,12 +97,12 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
LogFile->write(EQEMuLog::Crash, "Unknown Exception"); LogFile->write(EQEMuLog::Crash, "Unknown Exception");
break; break;
} }
if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode) if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
{ {
EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord); EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
} }
return EXCEPTION_EXECUTE_HANDLER; return EXCEPTION_EXECUTE_HANDLER;
} }
+3 -3
View File
@@ -85,9 +85,9 @@ void CRC32::SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at)
{ {
unsigned long data; unsigned long data;
unsigned long check = 0xffffffff; unsigned long check = 0xffffffff;
assert(in_length >= start_at && in_data); assert(in_length >= start_at && in_data);
for(uint32 i=start_at; i<in_length; i++) for(uint32 i=start_at; i<in_length; i++)
{ {
data = in_data[i]; data = in_data[i];
@@ -97,7 +97,7 @@ void CRC32::SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at)
data = CRC32Table[data]; data = CRC32Table[data];
check = check ^ data; check = check ^ data;
} }
memcpy(in_data, (char*)&check, 4); memcpy(in_data, (char*)&check, 4);
} }
+2 -2
View File
@@ -8,12 +8,12 @@ public:
static uint32 Generate(const uint8* buf, uint32 bufsize); static uint32 Generate(const uint8* buf, uint32 bufsize);
static uint32 GenerateNoFlip(const uint8* buf, uint32 bufsize); // Same as Generate(), but without the ~ 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); static void SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at=4);
// Multiple buffer CRC32 // Multiple buffer CRC32
static uint32 Update(const uint8* buf, uint32 bufsize, uint32 crc32 = 0xFFFFFFFF); static uint32 Update(const uint8* buf, uint32 bufsize, uint32 crc32 = 0xFFFFFFFF);
static inline uint32 Finish(uint32 crc32) { return ~crc32; } static inline uint32 Finish(uint32 crc32) { return ~crc32; }
static inline void Finish(uint32* crc32) { *crc32 = ~(*crc32); } static inline void Finish(uint32* crc32) { *crc32 = ~(*crc32); }
private: private:
static inline void Calc(const uint8 byte, uint32& crc32); static inline void Calc(const uint8 byte, uint32& crc32);
}; };
+64 -64
View File
@@ -248,7 +248,7 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes)
return true; return true;
} }
//End Lieka Edit //End Lieka Edit
bool Database::CheckGMIPs(const char* ip_address, uint32 account_id) { bool Database::CheckGMIPs(const char* ip_address, uint32 account_id) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
@@ -268,7 +268,7 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes)
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return false; return false;
} }
@@ -1379,7 +1379,7 @@ const char* Database::GetZoneName(uint32 zoneID, bool ErrorUnknown) {
else else
return 0; return 0;
} }
if (zoneID <= max_zonename) { if (zoneID <= max_zonename) {
if (zonename_array[zoneID]) if (zonename_array[zoneID])
return zonename_array[zoneID]; return zonename_array[zoneID];
@@ -1406,9 +1406,9 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
MYSQL_ROW row; MYSQL_ROW row;
int peqzone = 0; 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); row = mysql_fetch_row(result);
peqzone = atoi(row[0]); peqzone = atoi(row[0]);
@@ -1425,7 +1425,7 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
return peqzone; return peqzone;
} }
bool Database::CheckNameFilter(const char* name, bool surname) bool Database::CheckNameFilter(const char* name, bool surname)
{ {
std::string str_name = name; std::string str_name = name;
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
@@ -2257,7 +2257,7 @@ uint32 Database::GetRaidID(const char* name){
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
uint32 raidid=0; 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)) { errbuf, &result)) {
if((row = mysql_fetch_row(result))) if((row = mysql_fetch_row(result)))
{ {
@@ -2282,8 +2282,8 @@ const char *Database::GetRaidLeaderName(uint32 rid)
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; 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)) { rid), errbuf, &result)) {
if((row = mysql_fetch_row(result)) != nullptr) if((row = mysql_fetch_row(result)) != nullptr)
{ {
@@ -2326,11 +2326,11 @@ bool Database::VerifyZoneInstance(uint32 zone_id, uint16 instance_id)
char *query = 0; char *query = 0;
MYSQL_RES *result; 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)) instance_id, zone_id), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
mysql_free_result(result); mysql_free_result(result);
return true; return true;
@@ -2341,7 +2341,7 @@ bool Database::VerifyZoneInstance(uint32 zone_id, uint16 instance_id)
return false; return false;
} }
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
@@ -2356,17 +2356,17 @@ bool Database::CharacterInInstanceGroup(uint16 instance_id, uint32 char_id)
MYSQL_RES *result; MYSQL_RES *result;
bool lockout_instance_player = false; 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)) instance_id, char_id), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) == 1) if (mysql_num_rows(result) == 1)
{ {
lockout_instance_player = true; lockout_instance_player = true;
} }
mysql_free_result(result); mysql_free_result(result);
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
} }
@@ -2402,11 +2402,11 @@ bool Database::CheckInstanceExpired(uint16 instance_id)
int32 start_time = 0; int32 start_time = 0;
int32 duration = 0; int32 duration = 0;
uint32 never_expires = 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)) instance_id), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
start_time = atoi(row[0]); start_time = atoi(row[0]);
@@ -2420,7 +2420,7 @@ bool Database::CheckInstanceExpired(uint16 instance_id)
} }
mysql_free_result(result); mysql_free_result(result);
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return true; return true;
@@ -2448,16 +2448,16 @@ uint32 Database::ZoneIDFromInstanceID(uint16 instance_id)
MYSQL_ROW row; MYSQL_ROW row;
uint32 ret; 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)) errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
ret = atoi(row[0]); ret = atoi(row[0]);
mysql_free_result(result); mysql_free_result(result);
return ret; return ret;
} }
else else
{ {
@@ -2465,7 +2465,7 @@ uint32 Database::ZoneIDFromInstanceID(uint16 instance_id)
return 0; return 0;
} }
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return 0; return 0;
@@ -2481,16 +2481,16 @@ uint32 Database::VersionFromInstanceID(uint16 instance_id)
MYSQL_ROW row; MYSQL_ROW row;
uint32 ret; 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)) errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
ret = atoi(row[0]); ret = atoi(row[0]);
mysql_free_result(result); mysql_free_result(result);
return ret; return ret;
} }
else else
{ {
@@ -2498,7 +2498,7 @@ uint32 Database::VersionFromInstanceID(uint16 instance_id)
return 0; return 0;
} }
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return 0; return 0;
@@ -2516,11 +2516,11 @@ uint32 Database::GetTimeRemainingInstance(uint16 instance_id, bool &is_perma)
uint32 duration = 0; uint32 duration = 0;
uint32 never_expires = 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)) instance_id), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
start_time = atoi(row[0]); start_time = atoi(row[0]);
@@ -2535,7 +2535,7 @@ uint32 Database::GetTimeRemainingInstance(uint16 instance_id, bool &is_perma)
} }
mysql_free_result(result); mysql_free_result(result);
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
is_perma = false; 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)) if (RunQuery(query, MakeAnyLenString(&query, "SELECT COUNT(*) FROM instance_lockout"), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
int count = atoi(row[0]); int count = atoi(row[0]);
@@ -2584,7 +2584,7 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
} }
mysql_free_result(result); mysql_free_result(result);
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
instance_id = 0; 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)) if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_lockout where id >= %i ORDER BY id", count), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
while((row = mysql_fetch_row(result))) while((row = mysql_fetch_row(result)))
{ {
@@ -2624,7 +2624,7 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
mysql_free_result(result); mysql_free_result(result);
} }
} }
else else
{ {
safe_delete_array(query); 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 errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; 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)) " 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); safe_delete_array(query);
return true; return true;
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
@@ -2663,7 +2663,7 @@ void Database::PurgeExpiredInstances()
"(start_time+duration) <= UNIX_TIMESTAMP() and never_expires = 0"), errbuf, &result)) "(start_time+duration) <= UNIX_TIMESTAMP() and never_expires = 0"), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) > 0) if (mysql_num_rows(result) > 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
while(row != nullptr) while(row != nullptr)
@@ -2675,7 +2675,7 @@ void Database::PurgeExpiredInstances()
} }
mysql_free_result(result); mysql_free_result(result);
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
} }
@@ -2692,7 +2692,7 @@ bool Database::AddClientToInstance(uint16 instance_id, uint32 char_id)
safe_delete_array(query); safe_delete_array(query);
return true; return true;
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
@@ -2704,13 +2704,13 @@ bool Database::RemoveClientFromInstance(uint16 instance_id, uint32 char_id)
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; 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)) (unsigned long)instance_id, (unsigned long)char_id), errbuf))
{ {
safe_delete_array(query); safe_delete_array(query);
return true; return true;
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
@@ -2722,13 +2722,13 @@ bool Database::RemoveClientsFromInstance(uint16 instance_id)
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; 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)) (unsigned long)instance_id), errbuf))
{ {
safe_delete_array(query); safe_delete_array(query);
return true; return true;
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
@@ -2741,11 +2741,11 @@ bool Database::CheckInstanceExists(uint16 instance_id)
char *query = 0; char *query = 0;
MYSQL_RES *result; 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)) errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
mysql_free_result(result); mysql_free_result(result);
return true; return true;
@@ -2753,7 +2753,7 @@ bool Database::CheckInstanceExists(uint16 instance_id)
mysql_free_result(result); mysql_free_result(result);
return false; return false;
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
@@ -2767,7 +2767,7 @@ void Database::BuryCorpsesInInstance(uint16 instance_id)
char *query = 0; char *query = 0;
MYSQL_RES *result; 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)) instance_id), errbuf, &result))
{ {
mysql_free_result(result); mysql_free_result(result);
@@ -2786,16 +2786,16 @@ uint16 Database::GetInstanceVersion(uint16 instance_id)
MYSQL_ROW row; MYSQL_ROW row;
uint32 ret; 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)) errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
ret = atoi(row[0]); ret = atoi(row[0]);
mysql_free_result(result); mysql_free_result(result);
return ret; return ret;
} }
else else
{ {
@@ -2803,7 +2803,7 @@ uint16 Database::GetInstanceVersion(uint16 instance_id)
return 0; return 0;
} }
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return 0; 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)) "instance_lockout_player.charid=%u LIMIT 1;", GetZoneID(zone), version, charid, charid), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
ret = atoi(row[0]); ret = atoi(row[0]);
mysql_free_result(result); mysql_free_result(result);
return ret; return ret;
} }
else else
{ {
@@ -2837,7 +2837,7 @@ uint16 Database::GetInstanceID(const char* zone, uint32 charid, int16 version)
return 0; return 0;
} }
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return 0; 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)) "instance_lockout_player.charid=%u LIMIT 1;", zone, version, charid), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
ret = atoi(row[0]); ret = atoi(row[0]);
mysql_free_result(result); mysql_free_result(result);
return ret; return ret;
} }
else else
{ {
@@ -2874,7 +2874,7 @@ uint16 Database::GetInstanceID(uint32 zone, uint32 charid, int16 version)
return 0; return 0;
} }
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return 0; return 0;
@@ -2891,7 +2891,7 @@ void Database::AssignGroupToInstance(uint32 gid, uint32 instance_id)
uint32 zone_id = ZoneIDFromInstanceID(instance_id); uint32 zone_id = ZoneIDFromInstanceID(instance_id);
uint16 version = VersionFromInstanceID(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)) errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
@@ -2905,7 +2905,7 @@ void Database::AssignGroupToInstance(uint32 gid, uint32 instance_id)
} }
mysql_free_result(result); mysql_free_result(result);
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
} }
@@ -2920,7 +2920,7 @@ void Database::AssignRaidToInstance(uint32 rid, uint32 instance_id)
uint32 zone_id = ZoneIDFromInstanceID(instance_id); uint32 zone_id = ZoneIDFromInstanceID(instance_id);
uint16 version = VersionFromInstanceID(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)) errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
@@ -2934,7 +2934,7 @@ void Database::AssignRaidToInstance(uint32 rid, uint32 instance_id)
} }
mysql_free_result(result); mysql_free_result(result);
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
} }
@@ -3012,7 +3012,7 @@ bool Database::GlobalInstance(uint16 instance_id)
return false; return false;
} }
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return false; 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) uint32 &tak_w, uint32 &guk_l, uint32 &mir_l, uint32 &mmc_l, uint32 &ruj_l, uint32 &tak_l)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; 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; MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT `guk_wins`, `mir_wins`, `mmc_wins`, `ruj_wins`, `tak_wins`, " 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)) char_id), errbuf, &result))
{ {
safe_delete_array(query); 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); mysql_free_result(result);
return true; return true;
} }
else else
{ {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
+12 -12
View File
@@ -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]'); // INSERT into variables (varname,value) values('decaytime [minlevel] [maxlevel]','[number of seconds]');
// IE: decaytime 1 54 = Levels 1 through 54 // IE: decaytime 1 54 = Levels 1 through 54
// decaytime 55 100 = Levels 55 through 100 // 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); 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); bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
~Database(); ~Database();
/* /*
* General Character Related Stuff * General Character Related Stuff
*/ */
@@ -175,7 +175,7 @@ public:
* Adventure related. * Adventure related.
*/ */
void UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win); 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); 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); bool GetLiveChar(uint32 account_id, char* cname);
uint8 GetAgreementFlag(uint32 acctid); uint8 GetAgreementFlag(uint32 acctid);
void SetAgreementFlag(uint32 acctid); void SetAgreementFlag(uint32 acctid);
/* /*
* Groups * Groups
*/ */
@@ -202,7 +202,7 @@ public:
void SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ismerc = false); void SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ismerc = false);
void ClearGroup(uint32 gid = 0); void ClearGroup(uint32 gid = 0);
char* GetGroupLeaderForLogin(const char* name,char* leaderbuf); char* GetGroupLeaderForLogin(const char* name,char* leaderbuf);
void SetGroupLeaderName(uint32 gid, const char* name); 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, char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr,
GroupLeadershipAA_Struct* GLAA = nullptr); GroupLeadershipAA_Struct* GLAA = nullptr);
@@ -224,7 +224,7 @@ public:
bool LoadVariables(); bool LoadVariables();
uint32 LoadVariables_MQ(char** query); uint32 LoadVariables_MQ(char** query);
bool LoadVariables_result(MYSQL_RES* result); bool LoadVariables_result(MYSQL_RES* result);
/* /*
* General Queries * General Queries
*/ */
@@ -243,22 +243,22 @@ public:
bool LoadPTimers(uint32 charid, PTimerList &into); bool LoadPTimers(uint32 charid, PTimerList &into);
void ClearPTimers(uint32 charid); void ClearPTimers(uint32 charid);
void ClearMerchantTemp(); void ClearMerchantTemp();
void SetLFP(uint32 CharID, bool LFP); void SetLFP(uint32 CharID, bool LFP);
void SetLFG(uint32 CharID, bool LFG); void SetLFG(uint32 CharID, bool LFG);
void SetFirstLogon(uint32 CharID, uint8 firstlogon); 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); void AddReport(std::string who, std::string against, std::string lines);
protected: protected:
void HandleMysqlError(uint32 errnum); void HandleMysqlError(uint32 errnum);
private: private:
void DBInitVars(); void DBInitVars();
uint32 max_zonename; uint32 max_zonename;
char** zonename_array; char** zonename_array;
Mutex Mvarcache; Mutex Mvarcache;
uint32 varcache_max; uint32 varcache_max;
VarCache_Struct** varcache_array; VarCache_Struct** varcache_array;
+10 -10
View File
@@ -41,11 +41,11 @@ void AsyncLoadVariables(DBAsync *dba, Database *db) {
//which will get signaled when somebody puts something on the queue //which will get signaled when somebody puts something on the queue
ThreadReturnType DBAsyncLoop(void* tmp) { ThreadReturnType DBAsyncLoop(void* tmp) {
DBAsync* dba = (DBAsync*) tmp; DBAsync* dba = (DBAsync*) tmp;
#ifndef WIN32 #ifndef WIN32
_log(COMMON__THREADS, "Starting DBAsyncLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Starting DBAsyncLoop with thread ID %d", pthread_self());
#endif #endif
dba->MLoopRunning.lock(); dba->MLoopRunning.lock();
while (dba->RunLoop()) { while (dba->RunLoop()) {
//wait before working so we check the loop condition //wait before working so we check the loop condition
@@ -60,11 +60,11 @@ ThreadReturnType DBAsyncLoop(void* tmp) {
// Sleep(ASYNC_LOOP_GRANULARITY); // Sleep(ASYNC_LOOP_GRANULARITY);
} }
dba->MLoopRunning.unlock(); dba->MLoopRunning.unlock();
#ifndef WIN32 #ifndef WIN32
_log(COMMON__THREADS, "Ending DBAsyncLoop with thread ID %d", pthread_self()); _log(COMMON__THREADS, "Ending DBAsyncLoop with thread ID %d", pthread_self());
#endif #endif
THREAD_RETURN(nullptr); THREAD_RETURN(nullptr);
} }
@@ -92,14 +92,14 @@ bool DBAsync::StopThread() {
ret = pRunLoop; ret = pRunLoop;
pRunLoop = false; pRunLoop = false;
MRunLoop.unlock(); MRunLoop.unlock();
//signal the condition so we exit the loop if were waiting //signal the condition so we exit the loop if were waiting
CInList.Signal(); CInList.Signal();
//this effectively waits for the processing thread to finish //this effectively waits for the processing thread to finish
MLoopRunning.lock(); MLoopRunning.lock();
MLoopRunning.unlock(); MLoopRunning.unlock();
return ret; return ret;
} }
@@ -120,10 +120,10 @@ uint32 DBAsync::AddWork(DBAsyncWork** iWork, uint32 iDelay) {
#endif #endif
*iWork = 0; *iWork = 0;
MInList.unlock(); MInList.unlock();
//wake up the processing thread and tell it to get to work. //wake up the processing thread and tell it to get to work.
CInList.Signal(); CInList.Signal();
return ret; return ret;
} }
@@ -268,7 +268,7 @@ void DBAsync::CheckTimeout() {
MFQList.unlock(); MFQList.unlock();
} }
catch(...){ catch(...){
} }
} }
+4 -4
View File
@@ -31,10 +31,10 @@ protected:
Condition CInList; Condition CInList;
bool RunLoop(); bool RunLoop();
void Process(); void Process();
private: private:
virtual void CheckTimeout(); virtual void CheckTimeout();
void ProcessWork(DBAsyncWork* iWork, bool iSleep = true); void ProcessWork(DBAsyncWork* iWork, bool iSleep = true);
void DispatchWork(DBAsyncWork* iWork); void DispatchWork(DBAsyncWork* iWork);
inline uint32 GetNextID() { return pNextID++; } inline uint32 GetNextID() { return pNextID++; }
@@ -64,7 +64,7 @@ private:
/* /*
DB Work Complete Callback: 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) data/functions/classes. (ie: zone, entitylist, client, etc are not threadsafe)
Function prototype: Function prototype:
return value: true if we should delete the data, false if we should keep it 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 // Pops finished queries off the work
DBAsyncQuery* PopAnswer(); DBAsyncQuery* PopAnswer();
uint32 QueryCount(); uint32 QueryCount();
Database *GetDB() const { return(m_db); } Database *GetDB() const { return(m_db); }
bool CheckTimeout(uint32 iFQTimeout); bool CheckTimeout(uint32 iFQTimeout);
+1 -1
View File
@@ -190,7 +190,7 @@ bool DBcore::Open(uint32* errnum, char* errbuf) {
/* /*
Added CLIENT_FOUND_ROWS flag to the connect Added CLIENT_FOUND_ROWS flag to the connect
otherwise DB update calls would say 0 rows affected when the value already equalled 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; uint32 flags = CLIENT_FOUND_ROWS;
if (pCompress) if (pCompress)
+1 -1
View File
@@ -26,7 +26,7 @@ public:
uint32 DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen); uint32 DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen);
void ping(); void ping();
MYSQL* getMySQL(){ return &mysql; } MYSQL* getMySQL(){ return &mysql; }
protected: 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); 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: private:
+1 -1
View File
@@ -29,7 +29,7 @@ int32 Database::GetDoorsCount(uint32* oMaxID) {
delete[] query; delete[] query;
return -1; return -1;
} }
return -1; return -1;
} }
+5 -5
View File
@@ -140,7 +140,7 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
time_t aclock; time_t aclock;
struct tm *newtime; struct tm *newtime;
time( &aclock ); /* Get time in seconds */ time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */ newtime = localtime( &aclock ); /* Convert time to struct */
@@ -210,7 +210,7 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
time_t aclock; time_t aclock;
struct tm *newtime; struct tm *newtime;
time( &aclock ); /* Get time in seconds */ time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */ newtime = localtime( &aclock ); /* Convert time to struct */
@@ -273,7 +273,7 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
time_t aclock; time_t aclock;
struct tm *newtime; struct tm *newtime;
time( &aclock ); /* Get time in seconds */ time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */ newtime = localtime( &aclock ); /* Convert time to struct */
@@ -347,7 +347,7 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
LockMutex lock(&MLog[id]); LockMutex lock(&MLog[id]);
if (!logFileValid) if (!logFileValid)
return false; //check again for threading race reasons (to avoid two mutexes) return false; //check again for threading race reasons (to avoid two mutexes)
write(id, "Dumping Packet: %i", size); write(id, "Dumping Packet: %i", size);
// Output as HEX // Output as HEX
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1); 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); safe_delete_array(ascii);
return true; return true;
} }
void EQEMuLog::SetCallback(LogIDs id, msgCallbackFmt proc) { void EQEMuLog::SetCallback(LogIDs id, msgCallbackFmt proc) {
if (!logFileValid) if (!logFileValid)
return; return;
+4 -4
View File
@@ -106,19 +106,19 @@ public:
Crash, Crash,
MaxLogID MaxLogID
}; };
//these are callbacks called for each //these are callbacks called for each
typedef void (* msgCallbackBuf)(LogIDs id, const char *buf, uint8 size, uint32 count); 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 (* msgCallbackFmt)(LogIDs id, const char *fmt, va_list ap);
typedef void (* msgCallbackPva)(LogIDs id, const char *prefix, 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(msgCallbackFmt proc);
void SetAllCallbacks(msgCallbackBuf proc); void SetAllCallbacks(msgCallbackBuf proc);
void SetAllCallbacks(msgCallbackPva proc); void SetAllCallbacks(msgCallbackPva proc);
void SetCallback(LogIDs id, msgCallbackFmt proc); void SetCallback(LogIDs id, msgCallbackFmt proc);
void SetCallback(LogIDs id, msgCallbackBuf proc); void SetCallback(LogIDs id, msgCallbackBuf proc);
void SetCallback(LogIDs id, msgCallbackPva proc); void SetCallback(LogIDs id, msgCallbackPva proc);
bool writebuf(LogIDs id, const char *buf, uint8 size, uint32 count); bool writebuf(LogIDs id, const char *buf, uint8 size, uint32 count);
bool write(LogIDs id, const char *fmt, ...); bool write(LogIDs id, const char *fmt, ...);
bool writePVA(LogIDs id, const char *prefix, const char *fmt, va_list args); 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) 8 = use stderr instead (2 must be set)
*/ */
uint8 pLogStatus[MaxLogID]; uint8 pLogStatus[MaxLogID];
msgCallbackFmt logCallbackFmt[MaxLogID]; msgCallbackFmt logCallbackFmt[MaxLogID];
msgCallbackBuf logCallbackBuf[MaxLogID]; msgCallbackBuf logCallbackBuf[MaxLogID];
msgCallbackPva logCallbackPva[MaxLogID]; msgCallbackPva logCallbackPva[MaxLogID];
+2 -2
View File
@@ -18,7 +18,7 @@
#ifndef DEITY_H #ifndef DEITY_H
#define DEITY_H #define DEITY_H
/* /*
** Diety List ** Diety List
*/ */
#define DEITY_AGNOSTIC 396 //drop the high bit for 140 #define DEITY_AGNOSTIC 396 //drop the high bit for 140
@@ -37,7 +37,7 @@
#define DEITY_TUNARE 215 #define DEITY_TUNARE 215
//Guessed: //Guessed:
#define DEITY_BERTOX 201 #define DEITY_BERTOX 201
#define DEITY_RODCET 212 #define DEITY_RODCET 212
#define DEITY_VEESHAN 216 #define DEITY_VEESHAN 216
+2 -2
View File
@@ -21,13 +21,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
const char *OpcodeNames[_maxEmuOpcode+1] = { const char *OpcodeNames[_maxEmuOpcode+1] = {
"OP_Unknown", "OP_Unknown",
//a preprocessor hack so we dont have to maintain two lists //a preprocessor hack so we dont have to maintain two lists
#define N(x) #x #define N(x) #x
#include "emu_oplist.h" #include "emu_oplist.h"
#include "mail_oplist.h" #include "mail_oplist.h"
#undef N #undef N
"" ""
}; };
+1 -1
View File
@@ -413,7 +413,7 @@ N(OP_PetBuffWindow),
N(OP_RaidJoin), N(OP_RaidJoin),
N(OP_Translocate), N(OP_Translocate),
N(OP_Sacrifice), N(OP_Sacrifice),
N(OP_KeyRing), N(OP_KeyRing),
N(OP_PopupResponse), N(OP_PopupResponse),
N(OP_DeleteCharge), N(OP_DeleteCharge),
N(OP_PotionBelt), N(OP_PotionBelt),
+40 -40
View File
@@ -16,7 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef EQ_CONSTANTS_H #ifndef EQ_CONSTANTS_H
#define EQ_CONSTANTS_H #define EQ_CONSTANTS_H
#include "skills.h" #include "skills.h"
@@ -170,7 +170,7 @@ typedef enum {
_eaMaxAppearance _eaMaxAppearance
} EmuAppearance; } EmuAppearance;
/* /*
** Diety List ** Diety List
*/ */
#define DEITY_UNKNOWN 0 #define DEITY_UNKNOWN 0
@@ -190,11 +190,11 @@ typedef enum {
#define DEITY_TUNARE 215 #define DEITY_TUNARE 215
//Guessed: //Guessed:
#define DEITY_BERT 201 #define DEITY_BERT 201
#define DEITY_RODCET 212 #define DEITY_RODCET 212
#define DEITY_VEESHAN 216 #define DEITY_VEESHAN 216
// msg_type's for custom usercolors // msg_type's for custom usercolors
#define MT_Say 256 #define MT_Say 256
#define MT_Tell 257 #define MT_Tell 257
#define MT_Group 258 #define MT_Group 258
@@ -435,33 +435,33 @@ typedef enum {
#define STAT_HASTE 19 #define STAT_HASTE 19
#define STAT_DAMAGE_SHIELD 20 #define STAT_DAMAGE_SHIELD 20
/** /**
* Recast timer types. Used as an off set to charProfileStruct timers. * Recast timer types. Used as an off set to charProfileStruct timers.
*/ */
enum RecastTypes enum RecastTypes
{ {
RecastTimer0 = 0, RecastTimer0 = 0,
RecastTimer1, RecastTimer1,
WeaponHealClickTimer, // 2 WeaponHealClickTimer, // 2
MuramiteBaneNukeClickTimer, // 3 MuramiteBaneNukeClickTimer, // 3
RecastTimer4, RecastTimer4,
DispellClickTimer, // 5 (also click heal orbs?) DispellClickTimer, // 5 (also click heal orbs?)
EpicTimer, // 6 EpicTimer, // 6
OoWBPClickTimer, // 7 OoWBPClickTimer, // 7
VishQuestClassItemTimer, // 8 VishQuestClassItemTimer, // 8
HealPotionTimer, // 9 HealPotionTimer, // 9
RecastTimer10, RecastTimer10,
RecastTimer11, RecastTimer11,
RecastTimer12, RecastTimer12,
RecastTimer13, RecastTimer13,
RecastTimer14, RecastTimer14,
RecastTimer15, RecastTimer15,
RecastTimer16, RecastTimer16,
RecastTimer17, RecastTimer17,
RecastTimer18, RecastTimer18,
ModRodTimer // 19 ModRodTimer // 19
}; };
enum GroupUpdateAction enum GroupUpdateAction
{ {
GUA_Joined = 0, GUA_Joined = 0,
@@ -593,7 +593,7 @@ enum InventorySlot
//////////////////////// ////////////////////////
// Equip slots // Equip slots
//////////////////////// ////////////////////////
SLOT_CHARM = 0, SLOT_CHARM = 0,
SLOT_EAR01 = 1, SLOT_EAR01 = 1,
SLOT_HEAD = 2, SLOT_HEAD = 2,
@@ -616,38 +616,38 @@ enum InventorySlot
SLOT_FEET = 19, SLOT_FEET = 19,
SLOT_WAIST = 20, SLOT_WAIST = 20,
SLOT_AMMO = 21, SLOT_AMMO = 21,
//////////////////////// ////////////////////////
// All other slots // All other slots
//////////////////////// ////////////////////////
SLOT_PERSONAL_BEGIN = 22, SLOT_PERSONAL_BEGIN = 22,
SLOT_PERSONAL_END = 29, SLOT_PERSONAL_END = 29,
SLOT_CURSOR = 30, SLOT_CURSOR = 30,
SLOT_CURSOR_END = (int16)0xFFFE, // Last item on cursor queue SLOT_CURSOR_END = (int16)0xFFFE, // Last item on cursor queue
// Cursor bag slots are 331->340 (10 slots) // Cursor bag slots are 331->340 (10 slots)
// Personal Inventory Slots // Personal Inventory Slots
// Slots 1 through 8 are slots 22->29 // Slots 1 through 8 are slots 22->29
// Inventory bag slots are 251->330 (10 slots per bag) // Inventory bag slots are 251->330 (10 slots per bag)
// Tribute slots are 400-404? (upper bound unknown) // Tribute slots are 400-404? (upper bound unknown)
// storing these in worn item's map // storing these in worn item's map
// Bank slots // Bank slots
// Bank slots 1 through 16 are slots 2000->2015 // Bank slots 1 through 16 are slots 2000->2015
// Bank bag slots are 2031->2190 // Bank bag slots are 2031->2190
// Shared bank slots // Shared bank slots
// Shared bank slots 1 through 2 are slots 2500->2501 // Shared bank slots 1 through 2 are slots 2500->2501
// Shared bank bag slots are 2531->2550 // Shared bank bag slots are 2531->2550
// Trade session slots // Trade session slots
// Trade slots 1 through 8 are slots 3000->3007 // Trade slots 1 through 8 are slots 3000->3007
// Trade bag slots are technically 0->79 when passed to client, // Trade bag slots are technically 0->79 when passed to client,
// but in our code, we treat them as slots 3100->3179 // but in our code, we treat them as slots 3100->3179
// Slot used in OP_TradeSkillCombine for world tradeskill containers // Slot used in OP_TradeSkillCombine for world tradeskill containers
SLOT_TRADESKILL = 1000, SLOT_TRADESKILL = 1000,
SLOT_AUGMENT = 1001, SLOT_AUGMENT = 1001,
+28 -28
View File
@@ -547,7 +547,7 @@ struct BuffRemoveRequest_Struct
struct PetBuff_Struct { struct PetBuff_Struct {
/*000*/ uint32 petid; /*000*/ uint32 petid;
/*004*/ uint32 spellid[BUFF_COUNT]; /*004*/ uint32 spellid[BUFF_COUNT];
/*104*/ uint32 unknown700; /*104*/ uint32 unknown700;
/*108*/ uint32 unknown701; /*108*/ uint32 unknown701;
/*112*/ uint32 unknown702; /*112*/ uint32 unknown702;
/*116*/ uint32 unknown703; /*116*/ uint32 unknown703;
@@ -867,7 +867,7 @@ struct PlayerProfile_Struct
/*0116*/ uint32 level; // Level of player (might be one byte) /*0116*/ uint32 level; // Level of player (might be one byte)
/*0120*/ BindStruct binds[5]; // Bind points (primary is first, home city is fifth) /*0120*/ BindStruct binds[5]; // Bind points (primary is first, home city is fifth)
/*0220*/ uint32 deity; // deity /*0220*/ uint32 deity; // deity
/*0224*/ uint32 guild_id; /*0224*/ uint32 guild_id;
/*0228*/ uint32 birthday; // characters bday /*0228*/ uint32 birthday; // characters bday
/*0232*/ uint32 lastlogin; // last login or zone time /*0232*/ uint32 lastlogin; // last login or zone time
/*0236*/ uint32 timePlayedMin; // in minutes /*0236*/ uint32 timePlayedMin; // in minutes
@@ -1906,7 +1906,7 @@ struct AdventureFinish_Struct{
}; };
struct Weblink_Struct{ struct Weblink_Struct{
/*000*/ char weblink[1]; /*000*/ char weblink[1];
/*004*/ /*004*/
}; };
@@ -2040,22 +2040,22 @@ struct Illusion_Struct_Old {
struct QuestReward_Struct struct QuestReward_Struct
{ {
/*000*/ uint32 from_mob; // ID of mob awarding the client /*000*/ uint32 from_mob; // ID of mob awarding the client
/*004*/ uint32 unknown004; /*004*/ uint32 unknown004;
/*008*/ uint32 unknown008; /*008*/ uint32 unknown008;
/*012*/ uint32 unknown012; /*012*/ uint32 unknown012;
/*016*/ uint32 unknown016; /*016*/ uint32 unknown016;
/*020*/ uint32 unknown020; /*020*/ uint32 unknown020;
/*024*/ uint32 silver; // Gives silver to the client /*024*/ uint32 silver; // Gives silver to the client
/*028*/ uint32 gold; // Gives gold to the client /*028*/ uint32 gold; // Gives gold to the client
/*032*/ uint32 platinum; // Gives platinum to the client /*032*/ uint32 platinum; // Gives platinum to the client
/*036*/ uint32 unknown036; /*036*/ uint32 unknown036;
/*040*/ uint32 unknown040; /*040*/ uint32 unknown040;
/*044*/ uint32 unknown044; /*044*/ uint32 unknown044;
/*048*/ uint32 unknown048; /*048*/ uint32 unknown048;
/*052*/ uint32 unknown052; /*052*/ uint32 unknown052;
/*056*/ uint32 unknown056; /*056*/ uint32 unknown056;
/*060*/ uint32 unknown060; /*060*/ uint32 unknown060;
/*064*/ uint32 unknown064; /*064*/ uint32 unknown064;
/*068*/ /*068*/
}; };
@@ -2760,7 +2760,7 @@ struct BarterSearchRequest_Struct {
struct BuyerItemSearchLinkRequest_Struct { struct BuyerItemSearchLinkRequest_Struct {
/*000*/ uint32 Action; // 0x00000015 /*000*/ uint32 Action; // 0x00000015
/*004*/ uint32 ItemID; /*004*/ uint32 ItemID;
/*008*/ uint32 Unknown008; /*008*/ uint32 Unknown008;
/*012*/ uint32 Unknown012; /*012*/ uint32 Unknown012;
}; };
@@ -3435,7 +3435,7 @@ struct MerchantList{
uint32 item; uint32 item;
int16 faction_required; int16 faction_required;
int8 level_required; int8 level_required;
uint16 alt_currency_cost; uint16 alt_currency_cost;
}; };
struct TempMerchantList{ struct TempMerchantList{
uint32 npcid; uint32 npcid;
@@ -4195,7 +4195,7 @@ struct RespawnWindow_Struct {
/** /**
* Shroud spawn. For others shrouding, this has their spawnId and * Shroud spawn. For others shrouding, this has their spawnId and
* spawnStruct. * spawnStruct.
* *
* Length: 586 * Length: 586
* OpCode: OP_Shroud * 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 //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_POPULATE 8
#define ALT_CURRENCY_OP_UPDATE 7 #define ALT_CURRENCY_OP_UPDATE 7
//Server -> Client //Server -> Client
//Populates the initial Alternate Currency Window //Populates the initial Alternate Currency Window
struct AltCurrencyPopulateEntry_Struct struct AltCurrencyPopulateEntry_Struct
@@ -4681,7 +4681,7 @@ struct AltCurrencyUpdate_Struct {
/*084*/ uint32 unknown084; //seen 0 /*084*/ uint32 unknown084; //seen 0
}; };
//Client -> Server //Client -> Server
//When an item is selected while the alt currency merchant window is open //When an item is selected while the alt currency merchant window is open
struct AltCurrencySelectItem_Struct { struct AltCurrencySelectItem_Struct {
/*000*/ uint32 merchant_entity_id; /*000*/ uint32 merchant_entity_id;
@@ -4711,7 +4711,7 @@ struct AltCurrencySelectItem_Struct {
//eg: "I will give you no doubloons for a cloth cap." //eg: "I will give you no doubloons for a cloth cap."
//Probably also sends amounts somewhere //Probably also sends amounts somewhere
struct AltCurrencySelectItemReply_Struct { struct AltCurrencySelectItemReply_Struct {
/*000*/ uint32 unknown000; /*000*/ uint32 unknown000;
/*004*/ uint8 unknown004; //0xff /*004*/ uint8 unknown004; //0xff
/*005*/ uint8 unknown005; //0xff /*005*/ uint8 unknown005; //0xff
/*006*/ uint8 unknown006; //0xff /*006*/ uint8 unknown006; //0xff
@@ -4839,7 +4839,7 @@ struct Membership_Entry_Struct
{ {
/*000*/ uint32 purchase_id; // Seen 1, then increments 90287 to 90300 /*000*/ uint32 purchase_id; // Seen 1, then increments 90287 to 90300
/*004*/ uint32 bitwise_entry; // Seen 16 to 65536 - Skips 4096 /*004*/ uint32 bitwise_entry; // Seen 16 to 65536 - Skips 4096
/*008*/ /*008*/
}; };
struct Membership_Setting_Struct struct Membership_Setting_Struct
@@ -4847,7 +4847,7 @@ struct Membership_Setting_Struct
/*000*/ uint32 setting_index; // 0, 1, or 2 /*000*/ uint32 setting_index; // 0, 1, or 2
/*004*/ uint32 setting_id; // 0 to 21 /*004*/ uint32 setting_id; // 0 to 21
/*008*/ int32 setting_value; // All can be 0, 1, or -1 /*008*/ int32 setting_value; // All can be 0, 1, or -1
/*012*/ /*012*/
}; };
struct Membership_Details_Struct struct Membership_Details_Struct
@@ -4891,7 +4891,7 @@ struct MercenaryList_Struct {
/*0045*/ uint32 MercUnk02; // Unknown (normally see 1, but sometimes 2 or 0) /*0045*/ uint32 MercUnk02; // Unknown (normally see 1, but sometimes 2 or 0)
/*0049*/ uint32 StanceCount; // Iterations of MercenaryStance_Struct - Normally 2 to 4 seen /*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 /*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) /*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) /*0045*/ uint32 MercUnk02; // Unknown (normally see 1, but sometimes 2 or 0)
/*0049*/ uint32 StanceCount; // Iterations of MercenaryStance_Struct - Normally 2 to 4 seen /*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 /*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) /*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) /*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) /*0045*/ uint32 MercUnk02; // Unknown (normally see 1, but sometimes 2 or 0)
/*0049*/ uint32 StanceCount; // Iterations of MercenaryStance_Struct - Normally 2 to 4 seen /*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 /*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) /*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*/ 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 /*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] // [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 // 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 // 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 { struct MercenaryDataUpdate_Struct {
/*0000*/ int32 MercStatus; // Seen 0 with merc and -1 with no merc hired /*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 /*0004*/ uint32 MercCount; // Seen 1 with 1 merc hired and 0 with no merc hired
+9 -9
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -18,17 +18,17 @@
#include "eqemu_exception.h" #include "eqemu_exception.h"
namespace EQEmu namespace EQEmu
{ {
Exception::Exception(const char* name, const std::string& description, const char* file, long line) Exception::Exception(const char* name, const std::string& description, const char* file, long line)
: line_(line), : line_(line),
file_(file), file_(file),
desc_(description), desc_(description),
name_(name) name_(name)
{ {
} }
Exception::Exception(const Exception& e) Exception::Exception(const Exception& e)
: line_(e.line_), : line_(e.line_),
file_(e.file_), file_(e.file_),
desc_(e.desc_), desc_(e.desc_),
@@ -37,7 +37,7 @@ namespace EQEmu
} }
#ifdef EQEMU_RVALUE_MOVE #ifdef EQEMU_RVALUE_MOVE
Exception::Exception(const Exception&& e) Exception::Exception(const Exception&& e)
: line_(e.line_), : line_(e.line_),
file_(e.file_), file_(e.file_),
desc_(e.desc_), desc_(e.desc_),
@@ -45,7 +45,7 @@ namespace EQEmu
{ {
} }
#endif #endif
void Exception::operator=(const Exception& e) { void Exception::operator=(const Exception& e) {
line_ = e.line_; line_ = e.line_;
file_ = e.file_; file_ = e.file_;
+15 -15
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -30,7 +30,7 @@ namespace EQEmu
*/ */
class Exception : public std::exception { class Exception : public std::exception {
public: public:
//! Detailed Constructor //! Detailed Constructor
/*! /*!
\param name The name given for this exception. \param name The name given for this exception.
@@ -39,55 +39,55 @@ namespace EQEmu
\param line The line number for this exception. \param line The line number for this exception.
*/ */
Exception(const char* name, const std::string& description, const char* file, long line); Exception(const char* name, const std::string& description, const char* file, long line);
//! Copy Constructor //! Copy Constructor
Exception(const Exception& e); Exception(const Exception& e);
//! Move Constructor //! Move Constructor
#ifdef EQEMU_RVALUE_MOVE #ifdef EQEMU_RVALUE_MOVE
Exception(const Exception&& e); Exception(const Exception&& e);
#endif #endif
//! Destructor //! Destructor
~Exception() throw() { } ~Exception() throw() { }
//! Assignment Operator //! Assignment Operator
void operator=(const Exception& e); void operator=(const Exception& e);
//! Get Name //! 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. These are typically descriptive categories that the exception would fall under.
*/ */
virtual const std::string& name() const { return name_; } virtual const std::string& name() const { return name_; }
//! Get Basic Description //! 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. This tends to explain the circumstances of why the exception was thrown.
*/ */
virtual const std::string& description() const { return desc_; } virtual const std::string& description() const { return desc_; }
//! Get Full Description //! 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 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. This string is created the first time the full_description is accessed.
*/ */
virtual const std::string& full_description() const; virtual const std::string& full_description() const;
//! Get File Name //! Get File Name
/*! /*!
Gets the name of the file this exception was thrown from. Gets the name of the file this exception was thrown from.
*/ */
virtual const std::string& file() const { return file_; } virtual const std::string& file() const { return file_; }
//! Get File Line //! Get File Line
/*! /*!
Gets the file line this exception was thrown from. Gets the file line this exception was thrown from.
*/ */
virtual const long& line() const { return line_; } virtual const long& line() const { return line_; }
//! std::exception overload //! std::exception overload
/*! /*!
Overload from std::exception Overload from std::exception
+4 -4
View File
@@ -145,7 +145,7 @@ bool EQTime::saveFile(const char *filename)
return false; return false;
} }
//Enable for debugging //Enable for debugging
//cout << "SAVE: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << endl; //cout << "SAVE: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << endl;
of << EQT_VERSION << endl; of << EQT_VERSION << endl;
of << (long)eqTime.start_eqtime.day << endl; of << (long)eqTime.start_eqtime.day << endl;
of << (long)eqTime.start_eqtime.hour << endl; of << (long)eqTime.start_eqtime.hour << endl;
@@ -182,7 +182,7 @@ bool EQTime::loadFile(const char *filename)
//in >> eqTime.start_eqtime.hour; //in >> eqTime.start_eqtime.hour;
in >> in_data; in >> in_data;
eqTime.start_eqtime.hour = in_data; eqTime.start_eqtime.hour = in_data;
in.ignore(80, '\n'); in.ignore(80, '\n');
//in >> eqTime.start_eqtime.minute; //in >> eqTime.start_eqtime.minute;
in >> in_data; in >> in_data;
in.ignore(80, '\n'); in.ignore(80, '\n');
@@ -195,7 +195,7 @@ bool EQTime::loadFile(const char *filename)
in.ignore(80, '\n'); in.ignore(80, '\n');
in >> eqTime.start_realtime; in >> eqTime.start_realtime;
//Enable for debugging... //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(); in.close();
return true; return true;
} }
@@ -228,7 +228,7 @@ bool EQTime::IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test) {
void EQTime::AddMinutes(uint32 minutes, TimeOfDay_Struct *to) { void EQTime::AddMinutes(uint32 minutes, TimeOfDay_Struct *to) {
uint32 cur; uint32 cur;
//minutes start at 0, everything else starts at 1 //minutes start at 0, everything else starts at 1
cur = to->minute; cur = to->minute;
cur += minutes; cur += minutes;
+3 -3
View File
@@ -34,13 +34,13 @@ public:
//Set functions //Set functions
int setEQTimeOfDay(TimeOfDay_Struct start_eq, time_t start_real); int setEQTimeOfDay(TimeOfDay_Struct start_eq, time_t start_real);
void setEQTimeZone(int32 in_timezone) { timezone=in_timezone; } void setEQTimeZone(int32 in_timezone) { timezone=in_timezone; }
//Time math/logic functions //Time math/logic functions
static bool IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test); //is test before base static bool IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test); //is test before base
static void AddMinutes(uint32 minutes, TimeOfDay_Struct *to); static void AddMinutes(uint32 minutes, TimeOfDay_Struct *to);
static void ToString(TimeOfDay_Struct *t, string &str); static void ToString(TimeOfDay_Struct *t, string &str);
//Database functions //Database functions
//bool loadDB(Database q); //bool loadDB(Database q);
//bool setDB(Database q); //bool setDB(Database q);
+3 -3
View File
@@ -1,15 +1,15 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version. version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+3 -3
View File
@@ -35,10 +35,10 @@ bool SetExtendedProfile(ExtendedProfile_Struct *to, char *old, unsigned int len)
memcpy(to, old, sizeof(ExtendedProfile_Struct)); memcpy(to, old, sizeof(ExtendedProfile_Struct));
return(true); return(true);
} }
//convert an old block of memory of size old to the new struct //convert an old block of memory of size old to the new struct
//and store the new results in 'to' //and store the new results in 'to'
//generic converter that will work as long as the structre //generic converter that will work as long as the structre
//only grows, and nothign gets re-arranged //only grows, and nothign gets re-arranged
if(len < sizeof(ExtendedProfile_Struct)) { if(len < sizeof(ExtendedProfile_Struct)) {
@@ -46,7 +46,7 @@ bool SetExtendedProfile(ExtendedProfile_Struct *to, char *old, unsigned int len)
memcpy(to, old, len); memcpy(to, old, len);
return(true); return(true);
} }
return(false); return(false);
} }
+4 -4
View File
@@ -16,7 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef EXTENDED_PROFILE_H #ifndef EXTENDED_PROFILE_H
#define EXTENDED_PROFILE_H #define EXTENDED_PROFILE_H
#include "eq_packet_structs.h" #include "eq_packet_structs.h"
#include "Item.h" #include "Item.h"
@@ -27,11 +27,11 @@
/* /*
This is a place to store data that dosent have a home in the This is a place to store data that dosent have a home in the
official player profile. official player profile.
Try not to expand or re-arrange thing in this struct Try not to expand or re-arrange thing in this struct
to make conversion between sizes easier. to make conversion between sizes easier.
if something gets removed from here, just turn it into an unused 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 possible later instead of adding more, so long as old values left
over would not be extrememly unpleasent side effects. over would not be extrememly unpleasent side effects.
*/ */
@@ -43,7 +43,7 @@ struct ExtendedProfile_Struct {
SpellBuff_Struct pet_buffs[BUFF_COUNT]; SpellBuff_Struct pet_buffs[BUFF_COUNT];
uint32 pet_items[MAX_MATERIALS]; uint32 pet_items[MAX_MATERIALS];
char merc_name[64]; char merc_name[64];
uint32 aa_effects; uint32 aa_effects;
uint32 perAA; //% of exp going to AAs uint32 perAA; //% of exp going to AAs
uint32 expended_aa; // Total of expended AA uint32 expended_aa; // Total of expended AA
+6 -6
View File
@@ -28,9 +28,9 @@ enum FACTION_VALUE {
FACTION_WARMLY = 2, FACTION_WARMLY = 2,
FACTION_KINDLY = 3, FACTION_KINDLY = 3,
FACTION_AMIABLE = 4, FACTION_AMIABLE = 4,
FACTION_INDIFFERENT = 5, FACTION_INDIFFERENT = 5,
FACTION_APPREHENSIVE = 6, FACTION_APPREHENSIVE = 6,
FACTION_DUBIOUS = 7, FACTION_DUBIOUS = 7,
FACTION_THREATENLY = 8, FACTION_THREATENLY = 8,
@@ -63,13 +63,13 @@ struct Faction {
}; };
typedef std::map<uint32, int16> faction_map; typedef std::map<uint32, int16> faction_map;
struct NPCFaction struct NPCFaction
{ {
uint32 factionID; uint32 factionID;
int32 value_mod; int32 value_mod;
int8 npc_value; int8 npc_value;
uint8 temp; uint8 temp;
}; };
const char *FactionValueToString(FACTION_VALUE fv); const char *FactionValueToString(FACTION_VALUE fv);
FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value); FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value);
+4 -4
View File
@@ -22,7 +22,7 @@
This file defines many optional features for the emu This file defines many optional features for the emu
as well as various parameters used by the emu. as well as various parameters used by the emu.
If ambitious, most of these could prolly be turned into If ambitious, most of these could prolly be turned into
database variables, but the really frequently run pieces database variables, but the really frequently run pieces
of code, should not be done that way for speed reasons IMO 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 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) //probability of executing such an attack (which may or may not hit)
NPCDualAttackModifier = 20, NPCDualAttackModifier = 20,
NPCTripleAttackModifier = 0, NPCTripleAttackModifier = 0,
@@ -200,7 +200,7 @@ enum { //some random constants
//an npc can be and still let the theif PP them //an npc can be and still let the theif PP them
#define THIEF_PICKPOCKET_OVER 5 #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. //in its loot table, if it is able to.
//Aug 2007: was 5% chance.. changed to 100% by default since that seems more normal //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. //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 //minimum level to do alchemy
#define MIN_LEVEL_ALCHEMY 25 #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 #define THREATENLY_ARRGO_CHANCE 32 // 32/128 (25%) chance that a mob will arrgo on con Threatenly
// max factions per npc faction list // max factions per npc faction list
+8 -8
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -25,7 +25,7 @@
namespace EQEmu { 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 allocator for (shared memory), we assume all keys are unsigned int
*/ */
template<class T> template<class T>
@@ -41,7 +41,7 @@ namespace EQEmu {
Constructor which initializes the hash set Constructor which initializes the hash set
\param data Raw data \param data Raw data
\param size Raw data size \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. \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) { 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. stored in the data pointer passed.
\param data Raw data \param data Raw data
\param size Raw data size \param size Raw data size
@@ -136,7 +136,7 @@ namespace EQEmu {
elements_ = other.elements_; elements_ = other.elements_;
return *this; return *this;
} }
//! Returns whether the set is empty (has 0 elements) or not //! Returns whether the set is empty (has 0 elements) or not
bool empty() const { bool empty() const {
return current_elements_ == 0; return current_elements_ == 0;
@@ -156,7 +156,7 @@ namespace EQEmu {
key_type max_key() const { key_type max_key() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0; return offset_count_ > 0 ? (offset_count_ - 1) : 0;
} }
/*! /*!
Retrieve value operator Retrieve value operator
\param i Index to retrieve the value from \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) { static size_type estimated_size(key_type element_count, key_type max_elements) {
size_type total_size = 3 * sizeof(key_type); size_type total_size = 3 * sizeof(key_type);
total_size += sizeof(key_type) * (max_elements + 1); total_size += sizeof(key_type) * (max_elements + 1);
+11 -11
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -25,7 +25,7 @@
namespace EQEmu { 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 allocator for (shared memory), we assume all keys are unsigned int, values are a pointer and size
*/ */
template<class T> template<class T>
@@ -49,17 +49,17 @@ namespace EQEmu {
remaining_size_ = size_ - (sizeof(key_type) * 3) - (sizeof(key_type) * (max_element_id + 1)); remaining_size_ = size_ - (sizeof(key_type) * 3) - (sizeof(key_type) * (max_element_id + 1));
byte *ptr = data; 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; offset_count_ = max_element_id + 1;
ptr += sizeof(key_type); ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = remaining_size_; *reinterpret_cast<key_type*>(ptr) = remaining_size_;
ptr += sizeof(key_type); ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = 0; *reinterpret_cast<key_type*>(ptr) = 0;
current_offset_ = 0; current_offset_ = 0;
ptr += sizeof(key_type); ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr); offsets_ = reinterpret_cast<key_type*>(ptr);
memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1)); 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. stored in the data pointer passed.
\param data Raw data \param data Raw data
\param size Raw data size \param size Raw data size
@@ -87,7 +87,7 @@ namespace EQEmu {
current_offset_ = *reinterpret_cast<key_type*>(ptr); current_offset_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type); ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr); offsets_ = reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type) * offset_count_; ptr += sizeof(key_type) * offset_count_;
@@ -135,7 +135,7 @@ namespace EQEmu {
elements_ = other.elements_; elements_ = other.elements_;
return *this; return *this;
} }
//! Returns the number of bytes in the set currently //! Returns the number of bytes in the set currently
size_type size() const { size_type size() const {
return size_ - remaining_size_; return size_ - remaining_size_;
@@ -150,7 +150,7 @@ namespace EQEmu {
key_type max_key() const { key_type max_key() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0; return offset_count_ > 0 ? (offset_count_ - 1) : 0;
} }
/*! /*!
Retrieve value operator Retrieve value operator
\param i Index to retrieve the value from \param i Index to retrieve the value from
@@ -208,7 +208,7 @@ namespace EQEmu {
if(i >= offset_count_) { if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range."); EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range.");
} }
if(size > remaining_size_) { if(size > remaining_size_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Not enough room in hash set to insert this value."); EQ_EXCEPT("Fixed Memory Hash Set", "Not enough room in hash set to insert this value.");
} }
+212 -212
View File
File diff suppressed because it is too large Load Diff
+15 -15
View File
@@ -17,7 +17,7 @@ public:
uint16 level; uint16 level;
uint32 time_last_on; uint32 time_last_on;
uint32 zone_id; uint32 zone_id;
//fields from `guild_members` //fields from `guild_members`
uint32 guild_id; uint32 guild_id;
uint8 rank; uint8 rank;
@@ -34,13 +34,13 @@ class BaseGuildManager {
public: public:
BaseGuildManager(); BaseGuildManager();
virtual ~BaseGuildManager(); virtual ~BaseGuildManager();
//this must be called before doing anything else with this object //this must be called before doing anything else with this object
void SetDatabase(Database *db) { m_db = db; } void SetDatabase(Database *db) { m_db = db; }
bool LoadGuilds(); bool LoadGuilds();
bool RefreshGuild(uint32 guild_id); bool RefreshGuild(uint32 guild_id);
//guild edit actions. //guild edit actions.
uint32 CreateGuild(const char* name, uint32 leader_char_id); uint32 CreateGuild(const char* name, uint32 leader_char_id);
bool DeleteGuild(uint32 guild_id); bool DeleteGuild(uint32 guild_id);
@@ -48,7 +48,7 @@ public:
bool SetGuildMOTD(uint32 guild_id, const char* motd, const char *setter); bool SetGuildMOTD(uint32 guild_id, const char* motd, const char *setter);
bool SetGuildURL(uint32 GuildID, const char* URL); bool SetGuildURL(uint32 GuildID, const char* URL);
bool SetGuildChannel(uint32 GuildID, const char* Channel); bool SetGuildChannel(uint32 GuildID, const char* Channel);
//character edit actions //character edit actions
bool SetGuildLeader(uint32 guild_id, uint32 leader_char_id); bool SetGuildLeader(uint32 guild_id, uint32 leader_char_id);
bool SetGuild(uint32 charid, uint32 guild_id, uint8 rank); bool SetGuild(uint32 charid, uint32 guild_id, uint8 rank);
@@ -59,7 +59,7 @@ public:
bool GetBankerFlag(uint32 CharID); bool GetBankerFlag(uint32 CharID);
bool SetTributeFlag(uint32 charid, bool enabled); bool SetTributeFlag(uint32 charid, bool enabled);
bool SetPublicNote(uint32 charid, const char *note); bool SetPublicNote(uint32 charid, const char *note);
//queries //queries
bool GetCharInfo(const char *char_name, CharGuildInfo &into); bool GetCharInfo(const char *char_name, CharGuildInfo &into);
bool GetCharInfo(uint32 char_id, CharGuildInfo &into); bool GetCharInfo(uint32 char_id, CharGuildInfo &into);
@@ -82,19 +82,19 @@ public:
uint32 NumberInGuild(uint32 guild_id); uint32 NumberInGuild(uint32 guild_id);
// bool GetGuildRanks(uint32 guildeqid, GuildRanks_Struct* gr); // bool GetGuildRanks(uint32 guildeqid, GuildRanks_Struct* gr);
// bool EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct* grl); // 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. 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]; static const char *const GuildActionNames[_MaxGuildAction];
uint32 DoesAccountContainAGuildLeader(uint32 AccountID); uint32 DoesAccountContainAGuildLeader(uint32 AccountID);
protected: protected:
//the methods which must be defined by base classes. //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 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 SendCharRefresh(uint32 old_guild_id, uint32 guild_id, uint32 charid) = 0;
virtual void SendRankUpdate(uint32 CharID) = 0; virtual void SendRankUpdate(uint32 CharID) = 0;
virtual void SendGuildDelete(uint32 guild_id) = 0; virtual void SendGuildDelete(uint32 guild_id) = 0;
uint32 DBCreateGuild(const char* name, uint32 leader_char_id); uint32 DBCreateGuild(const char* name, uint32 leader_char_id);
bool DBDeleteGuild(uint32 guild_id); bool DBDeleteGuild(uint32 guild_id);
bool DBRenameGuild(uint32 guild_id, const char* name); bool DBRenameGuild(uint32 guild_id, const char* name);
@@ -110,9 +110,9 @@ protected:
bool DBSetPublicNote(uint32 charid, const char *note); bool DBSetPublicNote(uint32 charid, const char *note);
bool _RunQuery(char *&query, int len, const char *errmsg); bool _RunQuery(char *&query, int len, const char *errmsg);
// void DBSetPublicNote(uint32 guild_id,char* charname, char* note); // void DBSetPublicNote(uint32 guild_id,char* charname, char* note);
bool LocalDeleteGuild(uint32 guild_id); bool LocalDeleteGuild(uint32 guild_id);
class RankInfo { class RankInfo {
public: public:
RankInfo(); RankInfo();
@@ -133,12 +133,12 @@ protected:
//tribute is not in here on purpose, since it is only valid in world! //tribute is not in here on purpose, since it is only valid in world!
RankInfo ranks[GUILD_MAX_RANK+1]; RankInfo ranks[GUILD_MAX_RANK+1];
}; };
std::map<uint32, GuildInfo *> m_guilds; //we own the pointers in this map std::map<uint32, GuildInfo *> m_guilds; //we own the pointers in this map
void ClearGuilds(); //clears internal structure void ClearGuilds(); //clears internal structure
Database *m_db; //we do not own this Database *m_db; //we do not own this
bool _StoreGuildDB(uint32 guild_id); 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); 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(); uint32 _GetFreeGuildID();
+23 -23
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -63,7 +63,7 @@ uint32 Database::NumberInGuild(uint32 guild_id) {
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "Select count(id) from character_ where guild=%i", guild_id), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "Select count(id) from character_ where guild=%i", guild_id), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) == 1) { 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 errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
uint32 affected_rows = 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)) { 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); safe_delete_array(query);
if (affected_rows == 1) if (affected_rows == 1)
@@ -105,7 +105,7 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
uint32 affected_rows = 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)) { 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); safe_delete_array(query);
if (affected_rows == 1) if (affected_rows == 1)
@@ -119,7 +119,7 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return false; return false;
} }
@@ -129,7 +129,7 @@ bool Database::DeleteGuild(uint32 guild_id)
char *query = 0; char *query = 0;
char *query2 = 0; char *query2 = 0;
uint32 affected_rows = 0; uint32 affected_rows = 0;
if (RunQuery(query, MakeAnyLenString(&query, "DELETE FROM guilds WHERE id=%i;", guild_id), errbuf, 0, &affected_rows)) { if (RunQuery(query, MakeAnyLenString(&query, "DELETE FROM guilds WHERE id=%i;", guild_id), errbuf, 0, &affected_rows)) {
safe_delete_array(query); safe_delete_array(query);
if (affected_rows == 1) { if (affected_rows == 1) {
@@ -146,7 +146,7 @@ bool Database::DeleteGuild(uint32 guild_id)
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return false; return false;
} }
@@ -156,7 +156,7 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
uint32 affected_rows = 0; uint32 affected_rows = 0;
char buf[65]; char buf[65];
DoEscapeString(buf, name, strlen(name)) ; 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)) { if (RunQuery(query, MakeAnyLenString(&query, "Update guilds set name='%s' WHERE id=%i;", buf, guild_id), errbuf, 0, &affected_rows)) {
safe_delete_array(query); safe_delete_array(query);
if (affected_rows == 1) if (affected_rows == 1)
@@ -169,7 +169,7 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
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_DEMOTE] = grl->demote + '0';
buf2[GUILD_MOTD] = grl->motd + '0'; buf2[GUILD_MOTD] = grl->motd + '0';
buf2[GUILD_WARPEACE] = grl->warpeace + '0'; buf2[GUILD_WARPEACE] = grl->warpeace + '0';
if (ranknum == 0) if (ranknum == 0)
chars = MakeAnyLenString(&query, "Update guilds set rank%ititle='%s' WHERE id=%i;", ranknum, buf, guild_id); chars = MakeAnyLenString(&query, "Update guilds set rank%ititle='%s' WHERE id=%i;", ranknum, buf, guild_id);
else else
chars = MakeAnyLenString(&query, "Update guilds set rank%ititle='%s', rank%i='%s' WHERE id=%i;", ranknum, buf, ranknum, buf2, guild_id); 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)) { if (RunQuery(query, chars, errbuf, 0, &affected_rows)) {
safe_delete_array(query); safe_delete_array(query);
if (affected_rows == 1) if (affected_rows == 1)
@@ -210,7 +210,7 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return false; return false;
} }
@@ -219,8 +219,8 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "select name from guilds where id='%i'", guild_id), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "select name from guilds where id='%i'", guild_id), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
row = mysql_fetch_row(result); row = mysql_fetch_row(result);
@@ -234,7 +234,7 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return false; return false;
} }
@@ -244,7 +244,7 @@ uint32 Database::GetGuildIDbyLeader(uint32 leader)
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM guilds WHERE leader=%i", leader), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM guilds WHERE leader=%i", leader), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) == 1) 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); LogFile->write(EQEMuLog::Error, "Error in Getguild_idbyLeader query '%s': %s", query, errbuf);
safe_delete_array(query); safe_delete_array(query);
} }
return 0; return 0;
} }
@@ -269,7 +269,7 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
uint32 affected_rows = 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)) { if (RunQuery(query, MakeAnyLenString(&query, "UPDATE guilds SET leader=%i WHERE id=%i", leader, guild_id), errbuf, 0, &affected_rows)) {
safe_delete_array(query); safe_delete_array(query);
if (affected_rows == 1) if (affected_rows == 1)
@@ -282,7 +282,7 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return false; return false;
} }
@@ -291,11 +291,11 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
char *query = 0; char *query = 0;
char* motdbuf = 0; char* motdbuf = 0;
uint32 affected_rows = 0; uint32 affected_rows = 0;
motdbuf = new char[(strlen(motd)*2)+3]; motdbuf = new char[(strlen(motd)*2)+3];
DoEscapeString(motdbuf, motd, strlen(motd)) ; 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)) { if (RunQuery(query, MakeAnyLenString(&query, "Update guilds set motd='%s' WHERE id=%i;", motdbuf, guild_id), errbuf, 0, &affected_rows)) {
safe_delete_array(query); safe_delete_array(query);
delete motdbuf; delete motdbuf;
@@ -311,7 +311,7 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
delete motdbuf; delete motdbuf;
return false; return false;
} }
return false; return false;
} }
+8 -8
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -22,10 +22,10 @@
#include <string> #include <string>
namespace EQEmu { namespace EQEmu {
//! Interprocess Named Binary Semaphore (Mutex) //! 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 and thus should be used from one thread and non-recursively. It was intended to be a simple synchronization method
for our MemoryMappedFile loading. for our MemoryMappedFile loading.
*/ */
@@ -38,16 +38,16 @@ namespace EQEmu {
\param name The name of this mutex. \param name The name of this mutex.
*/ */
IPCMutex(std::string name); IPCMutex(std::string name);
//! Destructor //! Destructor
~IPCMutex(); ~IPCMutex();
//! Lock the mutex //! Lock the mutex
/*! /*!
Same basic function as P(): for(;;) { if(S > 0) { S -= 1; break; } } Same basic function as P(): for(;;) { if(S > 0) { S -= 1; break; } }
*/ */
bool Lock(); bool Lock();
//! Unlocks the mutex //! Unlocks the mutex
/*! /*!
Same basic function as V(): S += 1; Same basic function as V(): S += 1;
@@ -56,7 +56,7 @@ namespace EQEmu {
private: private:
IPCMutex(const IPCMutex&); IPCMutex(const IPCMutex&);
const IPCMutex& operator=(const IPCMutex&); const IPCMutex& operator=(const IPCMutex&);
bool locked_; //!< Whether this mutex is locked or not bool locked_; //!< Whether this mutex is locked or not
Implementation *imp_; Implementation *imp_;
}; };
+14 -14
View File
@@ -1,20 +1,20 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemulator.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemulator.org)
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef LANGUAGES_H #ifndef LANGUAGES_H
#define LANGUAGES_H #define LANGUAGES_H
#include "../common/types.h" #include "../common/types.h"
+11 -11
View File
@@ -24,7 +24,7 @@ enum direction{FORWARD,BACKWARD};
template<class TYPE> class LinkedListIterator; template<class TYPE> class LinkedListIterator;
template<class TYPE> template<class TYPE>
class ListElement class ListElement
{ {
private: private:
@@ -56,17 +56,17 @@ public:
inline const TYPE& GetData () const { return data ; } 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 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); GetLast()->SetNext(p);
} }
void SetNext (ListElement<TYPE>* n) { next = n ; } void SetNext (ListElement<TYPE>* n) { next = n ; }
void SetPrev (ListElement<TYPE>* p) { prev = p ; } void SetPrev (ListElement<TYPE>* p) { prev = p ; }
void ReplaceData(const TYPE&); void ReplaceData(const TYPE&);
}; };
template<class TYPE> template<class TYPE>
class LinkedList class LinkedList
{ {
private: private:
@@ -94,20 +94,20 @@ public:
friend class LinkedListIterator<TYPE>; friend class LinkedListIterator<TYPE>;
}; };
template<class TYPE> template<class TYPE>
class LinkedListIterator class LinkedListIterator
{ {
private: private:
LinkedList<TYPE>& list; LinkedList<TYPE>& list;
ListElement<TYPE>* current_element; ListElement<TYPE>* current_element;
direction dir; direction dir;
public: public:
LinkedListIterator(LinkedList<TYPE>& l,direction d = FORWARD) : list(l), dir(d) {}; LinkedListIterator(LinkedList<TYPE>& l,direction d = FORWARD) : list(l), dir(d) {};
void Advance(); void Advance();
const TYPE& GetData(); const TYPE& GetData();
bool IsFirst() bool IsFirst()
{ {
if (current_element->GetPrev() == 0) if (current_element->GetPrev() == 0)
return true; return true;
@@ -283,7 +283,7 @@ void LinkedListIterator<TYPE>::Reset()
current_element=0; current_element=0;
return; return;
} }
if (dir == FORWARD) if (dir == FORWARD)
{ {
current_element = list.first; current_element = list.first;
@@ -389,7 +389,7 @@ template<class TYPE>
void LinkedList<TYPE>::Append(const TYPE& data) void LinkedList<TYPE>::Append(const TYPE& data)
{ {
ListElement<TYPE>* new_element = new ListElement<TYPE>(data); ListElement<TYPE>* new_element = new ListElement<TYPE>(data);
if (first == 0) if (first == 0)
{ {
first = new_element; first = new_element;
+9 -9
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -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 //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 }, #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" #include "logtypes.h"
{ false, NUMBER_OF_LOG_CATEGORIES, "BAD TYPE" } /* dummy trailing record */ { false, NUMBER_OF_LOG_CATEGORIES, "BAD TYPE" } /* dummy trailing record */
@@ -97,14 +97,14 @@ bool load_log_settings(const char *filename) {
#ifdef _WINDOWS #ifdef _WINDOWS
if (sscanf(linebuf, "%[^=]=%[^\n]\n", type_name, value) != 2) if (sscanf(linebuf, "%[^=]=%[^\n]\n", type_name, value) != 2)
continue; continue;
#else #else
if (sscanf(linebuf, "%[^=]=%[^\r\n]\n", type_name, value) != 2) if (sscanf(linebuf, "%[^=]=%[^\r\n]\n", type_name, value) != 2)
continue; continue;
#endif #endif
if(type_name[0] == '\0' || type_name[0] == '#') if(type_name[0] == '\0' || type_name[0] == '#')
continue; continue;
//first make sure we understand the value //first make sure we understand the value
bool enabled; bool enabled;
if(!strcasecmp(value, "on") || !strcasecmp(value, "true") || !strcasecmp(value, "yes") || !strcasecmp(value, "enabled") || !strcmp(value, "1")) 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); printf("Unable to parse value '%s' from %s. Skipping line.", value, filename);
continue; continue;
} }
int r; int r;
//first see if it is a category name //first see if it is a category name
for(r = 0; r < NUMBER_OF_LOG_CATEGORIES; r++) { for(r = 0; r < NUMBER_OF_LOG_CATEGORIES; r++) {
@@ -135,7 +135,7 @@ bool load_log_settings(const char *filename) {
} }
continue; continue;
} }
for(r = 0; r < NUMBER_OF_LOG_TYPES; r++) { for(r = 0; r < NUMBER_OF_LOG_TYPES; r++) {
if(!strcasecmp(log_type_info[r].name, type_name)) if(!strcasecmp(log_type_info[r].name, type_name))
break; 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); printf("Unable to locate log type %s from file %s. Skipping line.", type_name, filename);
continue; continue;
} }
//got it all figured out, do something now... //got it all figured out, do something now...
if(enabled) if(enabled)
log_enable(LogType(r)); log_enable(LogType(r));
+12 -12
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,9 +19,9 @@
#define LOGSYS_H_ #define LOGSYS_H_
/* /*
* *
* Usage: * Usage:
* *
* These are the main functions provided by logsys: * These are the main functions provided by logsys:
* - _log(TYPE, fmt, ...) - Log a message in any context * - _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. * - 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. * - _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 * - 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 * Types are defined in logtypes.h
* *
* *
* *
* *
* this is very C-ish, not C++ish, but thats how I felt like writting it * this is very C-ish, not C++ish, but thats how I felt like writting it
* *
* *
* *
*/ */
#include <stdarg.h> #include <stdarg.h>
@@ -180,7 +180,7 @@ extern bool load_log_settings(const char *filename);
#endif /*LOGSYS_H_*/ #endif /*LOGSYS_H_*/
+3 -3
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -33,7 +33,7 @@ void log_messageVA(LogType type, const char *fmt, va_list args) {
char prefix_buffer[256]; char prefix_buffer[256];
snprintf(prefix_buffer, 255, "[%s] ", log_type_info[type].name); snprintf(prefix_buffer, 255, "[%s] ", log_type_info[type].name);
prefix_buffer[255] = '\0'; prefix_buffer[255] = '\0';
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args); LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args);
} }
+2 -2
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+2 -2
View File
@@ -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]); 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; return pMD5String;
} }
bool MD5::operator== (const MD5& iMD5) { bool MD5::operator== (const MD5& iMD5) {
if (memcmp(pMD5, iMD5.pMD5, 16) == 0) if (memcmp(pMD5, iMD5.pMD5, 16) == 0)
return true; 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); MD5STEP(F4, b, c, d, a, input[ 9]+0xeb86d391, 21);
hash[0] += a; hash[1] += b; hash[2] += c; hash[3] += d; hash[0] += a; hash[1] += b; hash[2] += c; hash[3] += d;
} }
+2 -2
View File
@@ -11,7 +11,7 @@ public:
uint32 input[16]; uint32 input[16];
}; };
static void Generate(const uint8* buf, uint32 len, uint8 digest[16]); static void Generate(const uint8* buf, uint32 len, uint8 digest[16]);
static void Init(struct MD5Context *context); static void Init(struct MD5Context *context);
static void Update(struct MD5Context *context, const uint8 *buf, uint32 len); static void Update(struct MD5Context *context, const uint8 *buf, uint32 len);
static void Final(uint8 digest[16], struct MD5Context *context); static void Final(uint8 digest[16], struct MD5Context *context);
@@ -21,7 +21,7 @@ public:
MD5(const char* buf, uint32 len); MD5(const char* buf, uint32 len);
MD5(const uint8 buf[16]); MD5(const uint8 buf[16]);
MD5(const char* iMD5String); MD5(const char* iMD5String);
void Generate(const char* iString); void Generate(const char* iString);
void Generate(const uint8* buf, uint32 len); void Generate(const uint8* buf, uint32 len);
bool Set(const uint8 buf[16]); bool Set(const uint8 buf[16]);
+30 -30
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -40,45 +40,45 @@ namespace EQEmu {
#endif #endif
}; };
MemoryMappedFile::MemoryMappedFile(std::string filename, uint32 size) MemoryMappedFile::MemoryMappedFile(std::string filename, uint32 size)
: filename_(filename), size_(size) { : filename_(filename), size_(size) {
imp_ = new Implementation; imp_ = new Implementation;
#ifdef _WINDOWS #ifdef _WINDOWS
DWORD total_size = size + sizeof(shared_memory_struct); DWORD total_size = size + sizeof(shared_memory_struct);
HANDLE file = CreateFile(filename.c_str(), HANDLE file = CreateFile(filename.c_str(),
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr, nullptr,
OPEN_ALWAYS, OPEN_ALWAYS,
0, 0,
nullptr); nullptr);
if(file == INVALID_HANDLE_VALUE) { if(file == INVALID_HANDLE_VALUE) {
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
} }
imp_->mapped_object_ = CreateFileMapping(file, imp_->mapped_object_ = CreateFileMapping(file,
nullptr, nullptr,
PAGE_READWRITE, PAGE_READWRITE,
0, 0,
total_size, total_size,
filename.c_str()); filename.c_str());
if(!imp_->mapped_object_) { if(!imp_->mapped_object_) {
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file."); 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_, memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_,
FILE_MAP_ALL_ACCESS, FILE_MAP_ALL_ACCESS,
0, 0,
0, 0,
total_size)); total_size));
if(!memory_) { if(!memory_) {
EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file."); EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file.");
} }
#else #else
size_t total_size = size + sizeof(shared_memory_struct); size_t total_size = size + sizeof(shared_memory_struct);
imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
@@ -98,11 +98,11 @@ namespace EQEmu {
} }
#endif #endif
} }
MemoryMappedFile::MemoryMappedFile(std::string filename) MemoryMappedFile::MemoryMappedFile(std::string filename)
: filename_(filename) { : filename_(filename) {
imp_ = new Implementation; imp_ = new Implementation;
//get existing size //get existing size
FILE *f = fopen(filename.c_str(), "rb"); FILE *f = fopen(filename.c_str(), "rb");
if(!f) { if(!f) {
@@ -115,39 +115,39 @@ namespace EQEmu {
#ifdef _WINDOWS #ifdef _WINDOWS
DWORD total_size = size + sizeof(shared_memory_struct); DWORD total_size = size + sizeof(shared_memory_struct);
HANDLE file = CreateFile(filename.c_str(), HANDLE file = CreateFile(filename.c_str(),
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr, nullptr,
OPEN_ALWAYS, OPEN_ALWAYS,
0, 0,
nullptr); nullptr);
if(file == INVALID_HANDLE_VALUE) { if(file == INVALID_HANDLE_VALUE) {
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
} }
imp_->mapped_object_ = CreateFileMapping(file, imp_->mapped_object_ = CreateFileMapping(file,
nullptr, nullptr,
PAGE_READWRITE, PAGE_READWRITE,
0, 0,
total_size, total_size,
filename.c_str()); filename.c_str());
if(!imp_->mapped_object_) { if(!imp_->mapped_object_) {
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file."); 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_, memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_,
FILE_MAP_ALL_ACCESS, FILE_MAP_ALL_ACCESS,
0, 0,
0, 0,
total_size)); total_size));
if(!memory_) { if(!memory_) {
EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file."); EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file.");
} }
#else #else
size_t total_size = size + sizeof(shared_memory_struct); size_t total_size = size + sizeof(shared_memory_struct);
imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
@@ -182,7 +182,7 @@ namespace EQEmu {
#endif #endif
delete imp_; delete imp_;
} }
void MemoryMappedFile::ZeroFile() { void MemoryMappedFile::ZeroFile() {
memset(reinterpret_cast<void*>(memory_), 0, sizeof(shared_memory_struct)); memset(reinterpret_cast<void*>(memory_), 0, sizeof(shared_memory_struct));
memset(memory_->data, 0, size_); memset(memory_->data, 0, size_);
+10 -10
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -26,7 +26,7 @@ namespace EQEmu {
//! Memory Backed Shared Memory //! 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. works in a consistent manner. Non-copyable.
*/ */
class MemoryMappedFile { class MemoryMappedFile {
@@ -40,15 +40,15 @@ namespace EQEmu {
}; };
public: public:
//! Constructor //! Constructor
/*! /*!
Creates a mmf for the given filename and of size. Creates a mmf for the given filename and of size.
\param filename Actual filename of the mmf. \param filename Actual filename of the mmf.
\param size Size in bytes of the mmf. \param size Size in bytes of the mmf.
*/ */
MemoryMappedFile(std::string filename, uint32 size); MemoryMappedFile(std::string filename, uint32 size);
//! Constructor //! Constructor
/*! /*!
Creates a mmf for the given filename and gets the size based on the existing size. Creates a mmf for the given filename and gets the size based on the existing size.
\param filename Actual filename of the mmf. \param filename Actual filename of the mmf.
*/ */
@@ -59,19 +59,19 @@ namespace EQEmu {
//! Get Data Operator //! Get Data Operator
inline void *operator->() const { return memory_->data; } inline void *operator->() const { return memory_->data; }
//! Get Data Function //! Get Data Function
inline void *Get() const { return memory_->data; } inline void *Get() const { return memory_->data; }
//! Get Size Function //! Get Size Function
inline uint32 Size() const { return memory_->size; } inline uint32 Size() const { return memory_->size; }
//! Zeros all the memory in the file, and set it to be unloaded //! Zeros all the memory in the file, and set it to be unloaded
void ZeroFile(); void ZeroFile();
private: private:
//! Copy Constructor //! Copy Constructor
MemoryMappedFile(const MemoryMappedFile&); MemoryMappedFile(const MemoryMappedFile&);
//! Assignment Operator //! Assignment Operator
const MemoryMappedFile& operator=(const MemoryMappedFile&); const MemoryMappedFile& operator=(const MemoryMappedFile&);
+25 -25
View File
@@ -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 modes for a given state differ only in the arguments which
are passed to the dispatch function. 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. AT LEAST as long as the supplied structure.
The variable length versions should only be used when the packet The variable length versions should only be used when the packet
@@ -76,7 +76,7 @@ IN_Cz(OP_ReqNewZone);
IN_Cz(OP_SendExpZonein); IN_Cz(OP_SendExpZonein);
//IN_Cr(OP_ZoneComplete); //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 //they overlap with the connected opcodes
IN_Cr(OP_SpawnAppearance); IN_Cr(OP_SpawnAppearance);
IN_Cr(OP_WearChange); IN_Cr(OP_WearChange);
@@ -477,14 +477,14 @@ OUT(OP_ZoneEntry, ServerZoneEntry_Struct);
void Handle_##op (); void Handle_##op ();
#define INr(op) \ #define INr(op) \
void Handle_##op (const EQApplicationPacket *app); void Handle_##op (const EQApplicationPacket *app);
#define OUT_C(op, s) #define OUT_C(op, s)
#define OUT_Cv(op, s) #define OUT_Cv(op, s)
#define OUT_Cz(op) #define OUT_Cz(op)
#define OUT_Cr(op) #define OUT_Cr(op)
#define OUT(op, s) #define OUT(op, s)
#define OUTv(op, s) #define OUTv(op, s)
#define OUTz(op) #define OUTz(op)
#define OUTr(op) #define OUTr(op)
#include "opcode_dispatch.h" #include "opcode_dispatch.h"
#undef IN_C #undef IN_C
#undef IN_Cr #undef IN_Cr
@@ -514,7 +514,7 @@ public:
RawOpcodeDispatcher(proc p) { RawOpcodeDispatcher(proc p) {
d = p; d = p;
} }
virtual void dispatch(Client *on, const EQApplicationPacket *app) { virtual void dispatch(Client *on, const EQApplicationPacket *app) {
(on->*d)(app); (on->*d)(app);
} }
@@ -528,7 +528,7 @@ public:
ZeroOpcodeDispatcher(proc p) { ZeroOpcodeDispatcher(proc p) {
d = p; d = p;
} }
virtual void dispatch(Client *on, const EQApplicationPacket *app) { virtual void dispatch(Client *on, const EQApplicationPacket *app) {
if(app->size != 0) { if(app->size != 0) {
//error.. //error..
@@ -548,7 +548,7 @@ public:
d = p; d = p;
struct_name = sn; struct_name = sn;
} }
virtual void dispatch(Client *on, const EQApplicationPacket *app) { virtual void dispatch(Client *on, const EQApplicationPacket *app) {
if(app->size != sizeof(T)) { if(app->size != sizeof(T)) {
//error.. //error..
@@ -557,7 +557,7 @@ public:
T * tmp = (T *) app->pBuffer; T * tmp = (T *) app->pBuffer;
(on->*d)(tmp); (on->*d)(tmp);
} }
protected: protected:
proc d; proc d;
const char *struct_name; const char *struct_name;
@@ -571,7 +571,7 @@ public:
d = p; d = p;
struct_name = sn; struct_name = sn;
} }
virtual void dispatch(Client *on, const EQApplicationPacket *app) { virtual void dispatch(Client *on, const EQApplicationPacket *app) {
if(app->size < sizeof(T)) { if(app->size < sizeof(T)) {
//error.. //error..
@@ -580,13 +580,13 @@ public:
T * tmp = (T *) app->pBuffer; T * tmp = (T *) app->pBuffer;
(on->*d)(tmp, app->size); (on->*d)(tmp, app->size);
} }
protected: protected:
proc d; proc d;
const char *struct_name; const char *struct_name;
}; };
//... client_packet.cpp //... client_packet.cpp
void MapOpcodes() { void MapOpcodes() {
@@ -607,14 +607,14 @@ void MapOpcodes() {
ConnectedOpcodes[op] = new ZeroOpcodeDispatcher(&Client::Handle_##op); ConnectedOpcodes[op] = new ZeroOpcodeDispatcher(&Client::Handle_##op);
#define INr(op) \ #define INr(op) \
ConnectedOpcodes[op] = new RawOpcodeDispatcher(&Client::Handle_##op); ConnectedOpcodes[op] = new RawOpcodeDispatcher(&Client::Handle_##op);
#define OUT_C(op, s) #define OUT_C(op, s)
#define OUT_Cv(op, s) #define OUT_Cv(op, s)
#define OUT_Cz(op) #define OUT_Cz(op)
#define OUT_Cr(op) #define OUT_Cr(op)
#define OUT(op, s) #define OUT(op, s)
#define OUTv(op, s) #define OUTv(op, s)
#define OUTz(op) #define OUTz(op)
#define OUTr(op) #define OUTr(op)
#include "opcode_dispatch.h" #include "opcode_dispatch.h"
#undef IN_C #undef IN_C
#undef IN_Cr #undef IN_Cr
+26 -26
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -37,9 +37,9 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
fprintf(stderr, "Unable to open opcodes file '%s'. Thats bad.\n", filename); fprintf(stderr, "Unable to open opcodes file '%s'. Thats bad.\n", filename);
return(false); return(false);
} }
map<string, uint16> eq; map<string, uint16> eq;
//load the opcode file into eq, could swap in a nice XML parser here //load the opcode file into eq, could swap in a nice XML parser here
char line[2048]; char line[2048];
int lineno = 0; 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 line[0] = '\0'; //for blank line at end of file
if(fgets(line, sizeof(line), opf) == nullptr) if(fgets(line, sizeof(line), opf) == nullptr)
break; break;
//ignore any line that dosent start with OP_ //ignore any line that dosent start with OP_
if(line[0] != 'O' || line[1] != 'P' || line[2] != '_') if(line[0] != 'O' || line[1] != 'P' || line[2] != '_')
continue; continue;
char *num = line+3; //skip OP_ char *num = line+3; //skip OP_
//look for the = sign //look for the = sign
while(*num != '=' && *num != '\0') { while(*num != '=' && *num != '\0') {
@@ -66,19 +66,19 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
} }
*num = '\0'; //null terminate the name *num = '\0'; //null terminate the name
num++; //num should point to the opcode num++; //num should point to the opcode
//read the opcode //read the opcode
if(sscanf(num, "0x%hx", &curop) != 1) { if(sscanf(num, "0x%hx", &curop) != 1) {
if(report_errors) fprintf(stderr, "Malformed opcode at %s:%d\n", filename, lineno); if(report_errors) fprintf(stderr, "Malformed opcode at %s:%d\n", filename, lineno);
continue; continue;
} }
//we have a name and our opcode... stick it in the map //we have a name and our opcode... stick it in the map
eq[line] = curop; eq[line] = curop;
} }
fclose(opf); fclose(opf);
//do the mapping and store them in the shared memory array //do the mapping and store them in the shared memory array
bool ret = true; bool ret = true;
EmuOpcode emu_op; EmuOpcode emu_op;
@@ -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"); if(report_errors) printf("I will let you continue, since you may have gotten all the opcodes you need.\n");
break; break;
} }
//find the opcode in the file //find the opcode in the file
res = eq.find(op_name); res = eq.find(op_name);
if(res == eq.end()) { if(res == eq.end()) {
@@ -100,11 +100,11 @@ bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s,
//ret = false; //ret = false;
continue; //continue to give them a list of all missing opcodes continue; //continue to give them a list of all missing opcodes
} }
//ship the mapping off to shared mem. //ship the mapping off to shared mem.
s->Set(emu_op, res->second); s->Set(emu_op, res->second);
} }
return(ret); return(ret);
} }
@@ -148,17 +148,17 @@ bool RegularOpcodeManager::LoadOpcodes(const char *filename, bool report_errors)
NormalMemStrategy s; NormalMemStrategy s;
s.it = this; s.it = this;
MOpcodes.lock(); MOpcodes.lock();
loaded = true; loaded = true;
eq_to_emu = new EmuOpcode[MAX_EQ_OPCODE]; eq_to_emu = new EmuOpcode[MAX_EQ_OPCODE];
emu_to_eq = new uint16[_maxEmuOpcode]; emu_to_eq = new uint16[_maxEmuOpcode];
EQOpcodeCount = MAX_EQ_OPCODE; EQOpcodeCount = MAX_EQ_OPCODE;
EmuOpcodeCount = _maxEmuOpcode; EmuOpcodeCount = _maxEmuOpcode;
//dont need to set eq_to_emu cause every element should get a value //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(eq_to_emu, 0, sizeof(EmuOpcode)*MAX_EQ_OPCODE);
memset(emu_to_eq, 0, sizeof(uint16)*_maxEmuOpcode); memset(emu_to_eq, 0, sizeof(uint16)*_maxEmuOpcode);
bool ret = LoadOpcodesFile(filename, &s, report_errors); bool ret = LoadOpcodesFile(filename, &s, report_errors);
MOpcodes.unlock(); MOpcodes.unlock();
return ret; return ret;
@@ -167,15 +167,15 @@ bool RegularOpcodeManager::LoadOpcodes(const char *filename, bool report_errors)
bool RegularOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors) { bool RegularOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors) {
if(!loaded) if(!loaded)
return(LoadOpcodes(filename)); return(LoadOpcodes(filename));
NormalMemStrategy s; NormalMemStrategy s;
s.it = this; s.it = this;
MOpcodes.lock(); MOpcodes.lock();
memset(eq_to_emu, 0, sizeof(uint16)*MAX_EQ_OPCODE); memset(eq_to_emu, 0, sizeof(uint16)*MAX_EQ_OPCODE);
bool ret = LoadOpcodesFile(filename, &s, report_errors); bool ret = LoadOpcodesFile(filename, &s, report_errors);
MOpcodes.unlock(); MOpcodes.unlock();
return(ret); return(ret);
} }
@@ -209,12 +209,12 @@ EmuOpcode RegularOpcodeManager::EQToEmu(const uint16 eq_op) {
} }
void RegularOpcodeManager::SetOpcode(EmuOpcode emu_op, uint16 eq_op) { void RegularOpcodeManager::SetOpcode(EmuOpcode emu_op, uint16 eq_op) {
//clear out old mapping //clear out old mapping
uint16 oldop = emu_to_eq[emu_op]; uint16 oldop = emu_to_eq[emu_op];
if(oldop != 0) if(oldop != 0)
eq_to_emu[oldop] = OP_Unknown; eq_to_emu[oldop] = OP_Unknown;
//use our strategy, since we have it //use our strategy, since we have it
NormalMemStrategy s; NormalMemStrategy s;
s.it = this; s.it = this;
@@ -233,7 +233,7 @@ NullOpcodeManager::NullOpcodeManager()
: MutableOpcodeManager() { : MutableOpcodeManager() {
} }
bool NullOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) { bool NullOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
return(true); return(true);
} }
@@ -241,7 +241,7 @@ bool NullOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
bool NullOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors) { bool NullOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors) {
return(true); return(true);
} }
uint16 NullOpcodeManager::EmuToEQ(const EmuOpcode emu_op) { uint16 NullOpcodeManager::EmuToEQ(const EmuOpcode emu_op) {
return(0); return(0);
} }
@@ -254,7 +254,7 @@ EmptyOpcodeManager::EmptyOpcodeManager()
: MutableOpcodeManager() { : MutableOpcodeManager() {
} }
bool EmptyOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) { bool EmptyOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
return(true); return(true);
} }
@@ -262,7 +262,7 @@ bool EmptyOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
bool EmptyOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors) { bool EmptyOpcodeManager::ReloadOpcodes(const char *filename, bool report_errors) {
return(true); return(true);
} }
uint16 EmptyOpcodeManager::EmuToEQ(const EmuOpcode emu_op) { uint16 EmptyOpcodeManager::EmuToEQ(const EmuOpcode emu_op) {
map<EmuOpcode, uint16>::iterator f; map<EmuOpcode, uint16>::iterator f;
f = emu_to_eq.find(emu_op); f = emu_to_eq.find(emu_op);
+21 -21
View File
@@ -4,13 +4,13 @@
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product; are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -38,18 +38,18 @@ class OpcodeManager {
public: public:
OpcodeManager(); OpcodeManager();
virtual ~OpcodeManager() {} virtual ~OpcodeManager() {}
virtual bool Mutable() { return(false); } virtual bool Mutable() { return(false); }
virtual bool LoadOpcodes(const char *filename, bool report_errors = false) = 0; virtual bool LoadOpcodes(const char *filename, bool report_errors = false) = 0;
virtual bool ReloadOpcodes(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 uint16 EmuToEQ(const EmuOpcode emu_op) = 0;
virtual EmuOpcode EQToEmu(const uint16 eq_op) = 0; virtual EmuOpcode EQToEmu(const uint16 eq_op) = 0;
static const char *EmuToName(const EmuOpcode emu_op); static const char *EmuToName(const EmuOpcode emu_op);
const char *EQToName(const uint16 emu_op); const char *EQToName(const uint16 emu_op);
EmuOpcode NameSearch(const char *name); EmuOpcode NameSearch(const char *name);
//This has to be public for stupid visual studio //This has to be public for stupid visual studio
class OpcodeSetStrategy { class OpcodeSetStrategy {
public: public:
@@ -61,7 +61,7 @@ protected:
bool loaded; //true if all opcodes loaded bool loaded; //true if all opcodes loaded
Mutex MOpcodes; //this only protects the local machine Mutex MOpcodes; //this only protects the local machine
//in a shared manager, this dosent protect others //in a shared manager, this dosent protect others
static bool LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors); static bool LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors);
}; };
@@ -77,13 +77,13 @@ public:
class SharedOpcodeManager : public OpcodeManager { class SharedOpcodeManager : public OpcodeManager {
public: public:
virtual ~SharedOpcodeManager() {} virtual ~SharedOpcodeManager() {}
virtual bool LoadOpcodes(const char *filename, bool report_errors = false); virtual bool LoadOpcodes(const char *filename, bool report_errors = false);
virtual bool ReloadOpcodes(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 uint16 EmuToEQ(const EmuOpcode emu_op);
virtual EmuOpcode EQToEmu(const uint16 eq_op); virtual EmuOpcode EQToEmu(const uint16 eq_op);
protected: protected:
class SharedMemStrategy : public OpcodeManager::OpcodeSetStrategy { class SharedMemStrategy : public OpcodeManager::OpcodeSetStrategy {
public: public:
@@ -99,17 +99,17 @@ class RegularOpcodeManager : public MutableOpcodeManager {
public: public:
RegularOpcodeManager(); RegularOpcodeManager();
virtual ~RegularOpcodeManager(); virtual ~RegularOpcodeManager();
virtual bool Editable() { return(true); } virtual bool Editable() { return(true); }
virtual bool LoadOpcodes(const char *filename, bool report_errors = false); virtual bool LoadOpcodes(const char *filename, bool report_errors = false);
virtual bool ReloadOpcodes(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 uint16 EmuToEQ(const EmuOpcode emu_op);
virtual EmuOpcode EQToEmu(const uint16 eq_op); virtual EmuOpcode EQToEmu(const uint16 eq_op);
//implement our editing interface //implement our editing interface
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op); virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op);
protected: protected:
class NormalMemStrategy : public OpcodeManager::OpcodeSetStrategy { class NormalMemStrategy : public OpcodeManager::OpcodeSetStrategy {
public: public:
@@ -118,7 +118,7 @@ protected:
void Set(EmuOpcode emu_op, uint16 eq_op); void Set(EmuOpcode emu_op, uint16 eq_op);
}; };
friend class NormalMemStrategy; friend class NormalMemStrategy;
uint16 *emu_to_eq; uint16 *emu_to_eq;
EmuOpcode *eq_to_emu; EmuOpcode *eq_to_emu;
uint32 EQOpcodeCount; uint32 EQOpcodeCount;
@@ -129,13 +129,13 @@ protected:
class NullOpcodeManager : public MutableOpcodeManager { class NullOpcodeManager : public MutableOpcodeManager {
public: public:
NullOpcodeManager(); NullOpcodeManager();
virtual bool LoadOpcodes(const char *filename, bool report_errors = false); virtual bool LoadOpcodes(const char *filename, bool report_errors = false);
virtual bool ReloadOpcodes(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 uint16 EmuToEQ(const EmuOpcode emu_op);
virtual EmuOpcode EQToEmu(const uint16 eq_op); virtual EmuOpcode EQToEmu(const uint16 eq_op);
//fake it, just used for testing anyways //fake it, just used for testing anyways
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op) {} virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op) {}
}; };
@@ -146,13 +146,13 @@ public:
class EmptyOpcodeManager : public MutableOpcodeManager { class EmptyOpcodeManager : public MutableOpcodeManager {
public: public:
EmptyOpcodeManager(); EmptyOpcodeManager();
virtual bool LoadOpcodes(const char *filename, bool report_errors = false); virtual bool LoadOpcodes(const char *filename, bool report_errors = false);
virtual bool ReloadOpcodes(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 uint16 EmuToEQ(const EmuOpcode emu_op);
virtual EmuOpcode EQToEmu(const uint16 eq_op); virtual EmuOpcode EQToEmu(const uint16 eq_op);
//fake it, just used for testing anyways //fake it, just used for testing anyways
virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op); virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op);
protected: protected:
+2 -2
View File
@@ -55,8 +55,8 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
return; return;
// Output as HEX // Output as HEX
char output[4]; char output[4];
int j = 0; int j = 0;
char* ascii = new char[cols+1]; char* ascii = new char[cols+1];
memset(ascii, 0, cols+1); memset(ascii, 0, cols+1);
uint32 i; uint32 i;
for(i=skip; i<size; i++) for(i=skip; i<size; i++)
+1 -1
View File
@@ -86,7 +86,7 @@ void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, u
sprintf(output, "%02X ",(unsigned char)buf[i]); sprintf(output, "%02X ",(unsigned char)buf[i]);
logfile << output; logfile << output;
// logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " "; // logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " ";
} }
logfile << endl << endl; logfile << endl << endl;
} }
+38 -38
View File
@@ -38,11 +38,11 @@ void EncryptProfilePacket(uchar* pBuffer, uint32 size) {
uint64 crypt = 0x659365E7; uint64 crypt = 0x659365E7;
uint64 next_crypt; uint64 next_crypt;
uint32 len = size >> 3; uint32 len = size >> 3;
uint64 swap = data[0]; uint64 swap = data[0];
data[0] = data[len/2]; data[0] = data[len/2];
data[len/2] = swap; data[len/2] = swap;
for(uint32 i=0; i<len;i++) { for(uint32 i=0; i<len;i++) {
next_crypt = crypt+data[i]-0x422437A9; next_crypt = crypt+data[i]-0x422437A9;
data[i] = ((data[i]>>0x19)|(data[i]<<0x27))+0x422437A9; data[i] = ((data[i]>>0x19)|(data[i]<<0x27))+0x422437A9;
@@ -61,11 +61,11 @@ void EncryptZoneSpawnPacket(uchar* pBuffer, uint32 size) {
uint64 crypt = 0x0000; uint64 crypt = 0x0000;
uint64 next_crypt; uint64 next_crypt;
uint32 len = size >> 3; uint32 len = size >> 3;
uint64 swap = data[0]; uint64 swap = data[0];
data[0] = data[len/2]; data[0] = data[len/2];
data[len/2] = swap; data[len/2] = swap;
for(uint32 i=0; i<len;i++) { for(uint32 i=0; i<len;i++) {
next_crypt = crypt+data[i]-0x659365E7; next_crypt = crypt+data[i]-0x659365E7;
data[i] = ((data[i]<<0x1d)|(data[i]>>0x23))+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 bool inited = false;
static z_stream zstream; static z_stream zstream;
int zerror; int zerror;
if(in_data == nullptr && out_data == nullptr && in_length == 0 && max_out_length == 0) { if(in_data == nullptr && out_data == nullptr && in_length == 0 && max_out_length == 0) {
//special delete state //special delete state
deflateEnd(&zstream); deflateEnd(&zstream);
@@ -114,7 +114,7 @@ int DeflatePacket(const unsigned char* in_data, int in_length, unsigned char* ou
zstream.opaque = Z_NULL; zstream.opaque = Z_NULL;
deflateInit(&zstream, Z_FINISH); deflateInit(&zstream, Z_FINISH);
} }
zstream.next_in = const_cast<unsigned char *>(in_data); zstream.next_in = const_cast<unsigned char *>(in_data);
zstream.avail_in = in_length; zstream.avail_in = in_length;
/* zstream.zalloc = Z_NULL; /* 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.next_out = out_data;
zstream.avail_out = max_out_length; zstream.avail_out = max_out_length;
zerror = deflate(&zstream, Z_FINISH); zerror = deflate(&zstream, Z_FINISH);
deflateReset(&zstream); deflateReset(&zstream);
if (zerror == Z_STREAM_END) if (zerror == Z_STREAM_END)
{ {
// deflateEnd(&zstream); // deflateEnd(&zstream);
@@ -141,11 +141,11 @@ int DeflatePacket(const unsigned char* in_data, int in_length, unsigned char* ou
if(in_data == nullptr) { if(in_data == nullptr) {
return(0); return(0);
} }
z_stream zstream; z_stream zstream;
memset(&zstream, 0, sizeof(zstream)); memset(&zstream, 0, sizeof(zstream));
int zerror; int zerror;
zstream.next_in = const_cast<unsigned char *>(in_data); zstream.next_in = const_cast<unsigned char *>(in_data);
zstream.avail_in = in_length; zstream.avail_in = in_length;
zstream.zalloc = eqemu_alloc_func; 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.next_out = out_data;
zstream.avail_out = max_out_length; zstream.avail_out = max_out_length;
zerror = deflate(&zstream, Z_FINISH); zerror = deflate(&zstream, Z_FINISH);
if (zerror == Z_STREAM_END) if (zerror == Z_STREAM_END)
{ {
deflateEnd(&zstream); deflateEnd(&zstream);
@@ -174,7 +174,7 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
static bool inited = false; static bool inited = false;
static z_stream zstream; static z_stream zstream;
int zerror; int zerror;
if(indata == nullptr && outdata == nullptr && indatalen == 0 && outdatalen == 0) { if(indata == nullptr && outdata == nullptr && indatalen == 0 && outdatalen == 0) {
//special delete state //special delete state
inflateEnd(&zstream); inflateEnd(&zstream);
@@ -194,16 +194,16 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
zstream.zalloc = eqemu_alloc_func; zstream.zalloc = eqemu_alloc_func;
zstream.zfree = eqemu_free_func; zstream.zfree = eqemu_free_func;
zstream.opaque = Z_NULL; zstream.opaque = Z_NULL;
i = inflateInit2( &zstream, 15 ); i = inflateInit2( &zstream, 15 );
if (i != Z_OK) { if (i != Z_OK) {
return 0; return 0;
} }
zerror = inflate( &zstream, Z_FINISH ); zerror = inflate( &zstream, Z_FINISH );
inflateReset(&zstream); inflateReset(&zstream);
if(zerror == Z_STREAM_END) { if(zerror == Z_STREAM_END) {
return zstream.total_out; return zstream.total_out;
} }
@@ -217,22 +217,22 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
DumpPacket(indata-16, indatalen+16); DumpPacket(indata-16, indatalen+16);
#endif #endif
} }
if (zerror == -4 && zstream.msg == 0) if (zerror == -4 && zstream.msg == 0)
{ {
return 0; return 0;
} }
return 0; return 0;
} }
#else #else
if(indata == nullptr) if(indata == nullptr)
return(0); return(0);
z_stream zstream; z_stream zstream;
int zerror = 0; int zerror = 0;
int i; int i;
zstream.next_in = const_cast<unsigned char *>(indata); zstream.next_in = const_cast<unsigned char *>(indata);
zstream.avail_in = indatalen; zstream.avail_in = indatalen;
zstream.next_out = outdata; zstream.next_out = outdata;
@@ -240,14 +240,14 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
zstream.zalloc = eqemu_alloc_func; zstream.zalloc = eqemu_alloc_func;
zstream.zfree = eqemu_free_func; zstream.zfree = eqemu_free_func;
zstream.opaque = Z_NULL; zstream.opaque = Z_NULL;
i = inflateInit2( &zstream, 15 ); i = inflateInit2( &zstream, 15 );
if (i != Z_OK) { if (i != Z_OK) {
return 0; return 0;
} }
zerror = inflate( &zstream, Z_FINISH ); zerror = inflate( &zstream, Z_FINISH );
if(zerror == Z_STREAM_END) { if(zerror == Z_STREAM_END) {
inflateEnd( &zstream ); inflateEnd( &zstream );
return zstream.total_out; return zstream.total_out;
@@ -262,12 +262,12 @@ uint32 InflatePacket(const uchar* indata, uint32 indatalen, uchar* outdata, uint
DumpPacket(indata-16, indatalen+16); DumpPacket(indata-16, indatalen+16);
#endif #endif
} }
if (zerror == -4 && zstream.msg == 0) if (zerror == -4 && zstream.msg == 0)
{ {
return 0; return 0;
} }
zerror = inflateEnd( &zstream ); zerror = inflateEnd( &zstream );
return 0; return 0;
} }
@@ -293,30 +293,30 @@ uint64 rorl(uint64 in, uint8 bits) {
uint32 CRCLookup(uchar idx) { uint32 CRCLookup(uchar idx) {
if (idx == 0) if (idx == 0)
return 0x00000000; return 0x00000000;
if (idx == 1) if (idx == 1)
return 0x77073096; return 0x77073096;
if (idx == 2) if (idx == 2)
return roll(CRCLookup(1), 1); return roll(CRCLookup(1), 1);
if (idx == 4) if (idx == 4)
return 0x076DC419; return 0x076DC419;
for (uchar b=7; b>0; b--) { for (uchar b=7; b>0; b--) {
uchar bv = 1 << b; uchar bv = 1 << b;
if (!(idx ^ bv)) { if (!(idx ^ bv)) {
// bit is only one set // bit is only one set
return ( roll(CRCLookup (4), b - 2) ); return ( roll(CRCLookup (4), b - 2) );
} }
if (idx&bv) { if (idx&bv) {
// bit is set // bit is set
return( CRCLookup(bv) ^ CRCLookup(idx&(bv - 1)) ); return( CRCLookup(bv) ^ CRCLookup(idx&(bv - 1)) );
} }
} }
//Failure //Failure
return false; return false;
} }
@@ -325,10 +325,10 @@ uint32 GenerateCRC(uint32 b, uint32 bufsize, uchar *buf) {
uint32 CRC = (b ^ 0xFFFFFFFF); uint32 CRC = (b ^ 0xFFFFFFFF);
uint32 bufremain = bufsize; uint32 bufremain = bufsize;
uchar* bufptr = buf; uchar* bufptr = buf;
while (bufremain--) { while (bufremain--) {
CRC = CRCLookup((uchar)(*(bufptr++)^ (CRC&0xFF))) ^ (CRC >> 8); CRC = CRCLookup((uchar)(*(bufptr++)^ (CRC&0xFF))) ^ (CRC >> 8);
} }
return (htonl (CRC ^ 0xFFFFFFFF)); return (htonl (CRC ^ 0xFFFFFFFF));
} }
+62 -62
View File
@@ -3,7 +3,7 @@
#else #else
#include <winsock2.h> #include <winsock2.h>
#endif #endif
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <time.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)); fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
return(false); return(false);
} }
unsigned long magic = 0; unsigned long magic = 0;
if(fread(&magic, sizeof(magic), 1, in) != 1) { if(fread(&magic, sizeof(magic), 1, in) != 1) {
fprintf(stderr, "Error reading header from packet file: %s\n", strerror(errno)); fprintf(stderr, "Error reading header from packet file: %s\n", strerror(errno));
fclose(in); fclose(in);
return(false); return(false);
} }
PacketFileReader *ret = NULL; PacketFileReader *ret = NULL;
if(magic == OLD_PACKET_FILE_MAGIC) { if(magic == OLD_PACKET_FILE_MAGIC) {
OldPacketFileHeader *pos = 0; OldPacketFileHeader *pos = 0;
@@ -69,33 +69,33 @@ bool PacketFileWriter::SetPacketStamp(const char *name, uint32 stamp) {
fclose(in); fclose(in);
return(false); return(false);
} }
fclose(in); fclose(in);
return(true); return(true);
} }
bool PacketFileWriter::OpenFile(const char *name) { bool PacketFileWriter::OpenFile(const char *name) {
CloseFile(); CloseFile();
printf("Opening packet file: %s\n", name); printf("Opening packet file: %s\n", name);
out = fopen(name, "wb"); out = fopen(name, "wb");
if(out == NULL) { if(out == NULL) {
fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno)); fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
return(false); return(false);
} }
PacketFileHeader head; PacketFileHeader head;
head.packet_file_magic = PACKET_FILE_MAGIC; head.packet_file_magic = PACKET_FILE_MAGIC;
head.packet_file_version = PACKET_FILE_CURRENT_VERSION; head.packet_file_version = PACKET_FILE_CURRENT_VERSION;
head.packet_file_stamp = time(NULL); head.packet_file_stamp = time(NULL);
if(fwrite(&head, sizeof(head), 1, out) != 1) { if(fwrite(&head, sizeof(head), 1, out) != 1) {
fprintf(stderr, "Error writting header to packet file: %s\n", strerror(errno)); fprintf(stderr, "Error writting header to packet file: %s\n", strerror(errno));
fclose(out); fclose(out);
return(false); return(false);
} }
return(true); 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) { void PacketFileWriter::WritePacket(uint16 eq_op, uint32 packlen, const unsigned char *packet, bool to_server, const struct timeval &tv) {
if(out == NULL) if(out == NULL)
return; return;
_WriteBlock(eq_op, packet, packlen, to_server, tv); _WriteBlock(eq_op, packet, packlen, to_server, tv);
/* /*
Could log only the packets we care about, but this is most of the stream, Could log only the packets we care about, but this is most of the stream,
so just log them all... so just log them all...
switch(eq_op) { switch(eq_op) {
case OP_NewZone: case OP_NewZone:
case OP_ZoneSpawns: 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) { bool PacketFileWriter::_WriteBlock(uint16 eq_op, const void *d, uint16 len, bool to_server, const struct timeval &tv) {
if(out == NULL) if(out == NULL)
return(false); return(false);
PacketFileSection s; PacketFileSection s;
s.opcode = eq_op; s.opcode = eq_op;
s.len = len; s.len = len;
s.tv_sec = tv.tv_sec; s.tv_sec = tv.tv_sec;
s.tv_msec = tv.tv_usec/1000; s.tv_msec = tv.tv_usec/1000;
if(to_server) if(to_server)
SetToServer(s); SetToServer(s);
else else
SetToClient(s); SetToClient(s);
if(fwrite(&s, sizeof(s), 1, out) != 1) { if(fwrite(&s, sizeof(s), 1, out) != 1) {
fprintf(stderr, "Error writting block header: %s\n", strerror(errno)); fprintf(stderr, "Error writting block header: %s\n", strerror(errno));
return(false); return(false);
} }
if(fwrite(d, 1, len, out) != len) { if(fwrite(d, 1, len, out) != len) {
fprintf(stderr, "Error writting block body: %s\n", strerror(errno)); fprintf(stderr, "Error writting block body: %s\n", strerror(errno));
return(false); return(false);
@@ -163,7 +163,7 @@ bool PacketFileWriter::_WriteBlock(uint16 eq_op, const void *d, uint16 len, bool
if(force_flush) if(force_flush)
fflush(out); fflush(out);
return(true); return(true);
} }
@@ -179,15 +179,15 @@ PacketFileReader *PacketFileReader::OpenPacketFile(const char *name) {
fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno)); fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
return(NULL); return(NULL);
} }
unsigned long magic = 0; unsigned long magic = 0;
if(fread(&magic, sizeof(magic), 1, in) != 1) { if(fread(&magic, sizeof(magic), 1, in) != 1) {
fprintf(stderr, "Error reading header to packet file: %s\n", strerror(errno)); fprintf(stderr, "Error reading header to packet file: %s\n", strerror(errno));
fclose(in); fclose(in);
return(NULL); return(NULL);
} }
PacketFileReader *ret = NULL; PacketFileReader *ret = NULL;
if(magic == OLD_PACKET_FILE_MAGIC) { if(magic == OLD_PACKET_FILE_MAGIC) {
ret = new OldPacketFileReader(); ret = new OldPacketFileReader();
@@ -198,12 +198,12 @@ PacketFileReader *PacketFileReader::OpenPacketFile(const char *name) {
fclose(in); fclose(in);
return(NULL); return(NULL);
} }
if(!ret->OpenFile(name)) { if(!ret->OpenFile(name)) {
safe_delete(ret); safe_delete(ret);
return(NULL); return(NULL);
} }
return(ret); return(ret);
} }
@@ -220,26 +220,26 @@ OldPacketFileReader::OldPacketFileReader()
OldPacketFileReader::~OldPacketFileReader() { OldPacketFileReader::~OldPacketFileReader() {
CloseFile(); CloseFile();
} }
bool OldPacketFileReader::OpenFile(const char *name) { bool OldPacketFileReader::OpenFile(const char *name) {
CloseFile(); CloseFile();
//printf("Opening packet file: %s\n", name); //printf("Opening packet file: %s\n", name);
in = fopen(name, "rb"); in = fopen(name, "rb");
if(in == NULL) { if(in == NULL) {
fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno)); fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
return(false); return(false);
} }
OldPacketFileHeader head; OldPacketFileHeader head;
if(fread(&head, sizeof(head), 1, in) != 1) { if(fread(&head, sizeof(head), 1, in) != 1) {
fprintf(stderr, "Error reading header to packet file: %s\n", strerror(errno)); fprintf(stderr, "Error reading header to packet file: %s\n", strerror(errno));
fclose(in); fclose(in);
return(false); return(false);
} }
if(head.packet_file_magic != OLD_PACKET_FILE_MAGIC) { if(head.packet_file_magic != OLD_PACKET_FILE_MAGIC) {
fclose(in); fclose(in);
if(head.packet_file_magic > (OLD_PACKET_FILE_MAGIC)) { if(head.packet_file_magic > (OLD_PACKET_FILE_MAGIC)) {
@@ -249,16 +249,16 @@ bool OldPacketFileReader::OpenFile(const char *name) {
} }
return(false); return(false);
} }
uint32 now = time(NULL); uint32 now = time(NULL);
if(head.packet_file_stamp > now) { 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); 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); fclose(in);
return(false); return(false);
} }
packet_file_stamp = head.packet_file_stamp; packet_file_stamp = head.packet_file_stamp;
return(true); return(true);
} }
@@ -274,14 +274,14 @@ bool OldPacketFileReader::ResetFile() {
if(in == NULL) if(in == NULL)
return(false); return(false);
rewind(in); rewind(in);
//gotta read past the header again //gotta read past the header again
OldPacketFileHeader head; OldPacketFileHeader head;
if(fread(&head, sizeof(head), 1, in) != 1) { if(fread(&head, sizeof(head), 1, in) != 1) {
return(false); return(false);
} }
return(true); return(true);
} }
@@ -290,23 +290,23 @@ bool OldPacketFileReader::ReadPacket(uint16 &eq_op, uint32 &packlen, unsigned ch
return(false); return(false);
if(feof(in)) if(feof(in))
return(false); return(false);
OldPacketFileSection s; OldPacketFileSection s;
if(fread(&s, sizeof(s), 1, in) != 1) { if(fread(&s, sizeof(s), 1, in) != 1) {
if(!feof(in)) if(!feof(in))
fprintf(stderr, "Error reading section header: %s\n", strerror(errno)); fprintf(stderr, "Error reading section header: %s\n", strerror(errno));
return(false); return(false);
} }
eq_op = s.opcode; eq_op = s.opcode;
if(packlen < s.len) { if(packlen < s.len) {
fprintf(stderr, "Packet buffer is too small! %d < %d, skipping\n", packlen, s.len); fprintf(stderr, "Packet buffer is too small! %d < %d, skipping\n", packlen, s.len);
fseek(in, s.len, SEEK_CUR); fseek(in, s.len, SEEK_CUR);
return(false); return(false);
} }
if(fread(packet, 1, s.len, in) != s.len) { if(fread(packet, 1, s.len, in) != s.len) {
if(feof(in)) if(feof(in))
fprintf(stderr, "Error: EOF encountered when expecting packet data.\n"); 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)); fprintf(stderr, "Error reading packet body: %s\n", strerror(errno));
return(false); return(false);
} }
packlen = s.len; packlen = s.len;
to_server = false; to_server = false;
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 0; tv.tv_usec = 0;
return(true); return(true);
} }
@@ -333,26 +333,26 @@ NewPacketFileReader::NewPacketFileReader()
NewPacketFileReader::~NewPacketFileReader() { NewPacketFileReader::~NewPacketFileReader() {
CloseFile(); CloseFile();
} }
bool NewPacketFileReader::OpenFile(const char *name) { bool NewPacketFileReader::OpenFile(const char *name) {
CloseFile(); CloseFile();
//printf("Opening packet file: %s\n", name); //printf("Opening packet file: %s\n", name);
in = fopen(name, "rb"); in = fopen(name, "rb");
if(in == NULL) { if(in == NULL) {
fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno)); fprintf(stderr, "Error opening packet file '%s': %s\n", name, strerror(errno));
return(false); return(false);
} }
PacketFileHeader head; PacketFileHeader head;
if(fread(&head, sizeof(head), 1, in) != 1) { if(fread(&head, sizeof(head), 1, in) != 1) {
fprintf(stderr, "Error reading header to packet file: %s\n", strerror(errno)); fprintf(stderr, "Error reading header to packet file: %s\n", strerror(errno));
fclose(in); fclose(in);
return(false); return(false);
} }
if(head.packet_file_magic != PACKET_FILE_MAGIC) { if(head.packet_file_magic != PACKET_FILE_MAGIC) {
fclose(in); fclose(in);
if(head.packet_file_magic == (PACKET_FILE_MAGIC+1)) { if(head.packet_file_magic == (PACKET_FILE_MAGIC+1)) {
@@ -362,16 +362,16 @@ bool NewPacketFileReader::OpenFile(const char *name) {
} }
return(false); return(false);
} }
uint32 now = time(NULL); uint32 now = time(NULL);
if(head.packet_file_stamp > now) { 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); 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); fclose(in);
return(false); return(false);
} }
packet_file_stamp = head.packet_file_stamp; packet_file_stamp = head.packet_file_stamp;
return(true); return(true);
} }
@@ -387,14 +387,14 @@ bool NewPacketFileReader::ResetFile() {
if(in == NULL) if(in == NULL)
return(false); return(false);
rewind(in); rewind(in);
//gotta read past the header again //gotta read past the header again
PacketFileHeader head; PacketFileHeader head;
if(fread(&head, sizeof(head), 1, in) != 1) { if(fread(&head, sizeof(head), 1, in) != 1) {
return(false); return(false);
} }
return(true); return(true);
} }
@@ -403,23 +403,23 @@ bool NewPacketFileReader::ReadPacket(uint16 &eq_op, uint32 &packlen, unsigned ch
return(false); return(false);
if(feof(in)) if(feof(in))
return(false); return(false);
PacketFileSection s; PacketFileSection s;
if(fread(&s, sizeof(s), 1, in) != 1) { if(fread(&s, sizeof(s), 1, in) != 1) {
if(!feof(in)) if(!feof(in))
fprintf(stderr, "Error reading section header: %s\n", strerror(errno)); fprintf(stderr, "Error reading section header: %s\n", strerror(errno));
return(false); return(false);
} }
eq_op = s.opcode; eq_op = s.opcode;
if(packlen < s.len) { if(packlen < s.len) {
fprintf(stderr, "Packet buffer is too small! %d < %d, skipping\n", packlen, s.len); fprintf(stderr, "Packet buffer is too small! %d < %d, skipping\n", packlen, s.len);
fseek(in, s.len, SEEK_CUR); fseek(in, s.len, SEEK_CUR);
return(false); return(false);
} }
if(fread(packet, 1, s.len, in) != s.len) { if(fread(packet, 1, s.len, in) != s.len) {
if(feof(in)) if(feof(in))
fprintf(stderr, "Error: EOF encountered when expecting packet data.\n"); 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)); fprintf(stderr, "Error reading packet body: %s\n", strerror(errno));
return(false); return(false);
} }
packlen = s.len; packlen = s.len;
to_server = IsToServer(s); to_server = IsToServer(s);
tv.tv_sec = s.tv_sec; tv.tv_sec = s.tv_sec;
tv.tv_usec = 1000*s.tv_msec; tv.tv_usec = 1000*s.tv_msec;
return(true); return(true);
} }

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