Merge conflicts

This commit is contained in:
KimLS 2013-05-15 13:22:46 -07:00
commit 9e13a2271c
616 changed files with 38180 additions and 38954 deletions

View File

@ -15,73 +15,73 @@ PROJECT(EQEmu)
#Default build type is set to RelWithDebInfo for generators that honor that like makefiles #Default build type is set to RelWithDebInfo for generators that honor that like makefiles
IF(NOT CMAKE_BUILD_TYPE) IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE) ENDIF(NOT CMAKE_BUILD_TYPE)
#Add our various windows definitions #Add our various windows definitions
IF(MSVC OR MINGW) IF(MSVC OR MINGW)
ADD_DEFINITIONS(-D_WINDOWS) ADD_DEFINITIONS(-D_WINDOWS)
IF(CMAKE_CL_64) IF(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN64) ADD_DEFINITIONS(-DWIN64)
ELSE(CMAKE_CL_64) ELSE(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN32) ADD_DEFINITIONS(-DWIN32)
ENDIF(CMAKE_CL_64) ENDIF(CMAKE_CL_64)
ENDIF(MSVC OR MINGW) ENDIF(MSVC OR MINGW)
IF(MSVC) IF(MSVC)
#Set our default locations for zlib/mysql based on x86/x64 #Set our default locations for zlib/mysql based on x86/x64
IF(CMAKE_CL_64) IF(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64") SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64") SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64")
ELSE(CMAKE_CL_64) ELSE(CMAKE_CL_64)
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)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO") SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO") SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SAFESEH:NO") SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO") SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /SAFESEH:NO") SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO") SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /SAFESEH:NO") SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO") SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /SAFESEH:NO") SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
SET(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO") SET(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
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")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MD") ENDIF(${flag_var} MATCHES "/MD")
ENDFOREACH(flag_var) ENDFOREACH(flag_var)
ELSE(MSVC) ELSE(MSVC)
#Normally set by perl but we don't use the perl flags anymore so we set it. #Normally set by perl but we don't use the perl flags anymore so we set it.
ADD_DEFINITIONS(-DHAS_UNION_SEMUN) ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
ENDIF(MSVC) ENDIF(MSVC)
#FreeBSD support #FreeBSD support
@ -95,24 +95,24 @@ ENDIF(UNIX)
#use stdint.h types if they exist for this platform (we have to guess otherwise) #use stdint.h types if they exist for this platform (we have to guess otherwise)
CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H) CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
IF(HAVE_STDINT_H) IF(HAVE_STDINT_H)
ADD_DEFINITIONS(-DEQEMU_USE_STDINT) ADD_DEFINITIONS(-DEQEMU_USE_STDINT)
ENDIF(HAVE_STDINT_H) ENDIF(HAVE_STDINT_H)
#debug level, 5 is default. Most people wont ever change this but it's there if you want to #debug level, 5 is default. Most people wont ever change this but it's there if you want to
SET(EQEMU_DEBUG_LEVEL 5 CACHE STRING "EQEmu debug level: SET(EQEMU_DEBUG_LEVEL 5 CACHE STRING "EQEmu debug level:
0 - Quiet mode Errors to file Status and Normal ignored 0 - Quiet mode Errors to file Status and Normal ignored
1 - Status and Normal to console, Errors to logfile 1 - Status and Normal to console, Errors to logfile
2 - Status, Normal, and Error to console and logfile 2 - Status, Normal, and Error to console and logfile
3 - Light debug release errors and status 3 - Light debug release errors and status
4 - Moderate debug release errors and status 4 - Moderate debug release errors and status
5 - Maximum debug release errors and status 5 - Maximum debug release errors and status
10 - More errors than you ever wanted to see" 10 - More errors than you ever wanted to see"
) )
#Bots are a compile time option so on/off #Bots are a compile time option so on/off
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF) OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
IF(EQEMU_ENABLE_BOTS) IF(EQEMU_ENABLE_BOTS)
ADD_DEFINITIONS(-DBOTS) ADD_DEFINITIONS(-DBOTS)
ENDIF(EQEMU_ENABLE_BOTS) ENDIF(EQEMU_ENABLE_BOTS)
#What to build #What to build
@ -124,22 +124,22 @@ OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
#C++11 stuff #C++11 stuff
IF(NOT MSVC) IF(NOT MSVC)
ADD_DEFINITIONS(-std=c++0x) ADD_DEFINITIONS(-std=c++0x)
#Rvalue-Move - todo: auto set this based on gcc version #Rvalue-Move - todo: auto set this based on gcc version
OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if GCC 4.3 or higher)" OFF) OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if GCC 4.3 or higher)" OFF)
ELSE(NOT MSVC) ELSE(NOT MSVC)
#Rvalue-Move - todo: auto set this based on msvc version #Rvalue-Move - todo: auto set this based on msvc version
OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if Visual Studio 2010 or higher)" OFF) OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if Visual Studio 2010 or higher)" OFF)
ENDIF(NOT MSVC) ENDIF(NOT MSVC)
IF(EQEMU_ENABLE_RVALUE_MOVE) IF(EQEMU_ENABLE_RVALUE_MOVE)
ADD_DEFINITIONS(-DEQEMU_RVALUE_MOVE) ADD_DEFINITIONS(-DEQEMU_RVALUE_MOVE)
ENDIF(EQEMU_ENABLE_RVALUE_MOVE) ENDIF(EQEMU_ENABLE_RVALUE_MOVE)
#Various definitions #Various definitions
IF(EQEMU_BUILD_PERL) IF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEMBPERL) ADD_DEFINITIONS(-DEMBPERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN) ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
ENDIF(EQEMU_BUILD_PERL) ENDIF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL}) ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL})
ADD_DEFINITIONS(-DINVERSEXY) ADD_DEFINITIONS(-DINVERSEXY)
@ -150,30 +150,30 @@ ADD_DEFINITIONS(-DMAP_DIR="./Maps")
FIND_PACKAGE(ZLIB REQUIRED) FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(MySQL REQUIRED) FIND_PACKAGE(MySQL REQUIRED)
IF(EQEMU_BUILD_PERL) IF(EQEMU_BUILD_PERL)
FIND_PACKAGE(PerlLibs REQUIRED) FIND_PACKAGE(PerlLibs REQUIRED)
INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}") INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}")
ENDIF(EQEMU_BUILD_PERL) ENDIF(EQEMU_BUILD_PERL)
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}") INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}")
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS) IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
ADD_SUBDIRECTORY(common) ADD_SUBDIRECTORY(common)
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS) ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
IF(EQEMU_BUILD_SERVER) IF(EQEMU_BUILD_SERVER)
ADD_SUBDIRECTORY(shared_memory) ADD_SUBDIRECTORY(shared_memory)
ADD_SUBDIRECTORY(world) ADD_SUBDIRECTORY(world)
ADD_SUBDIRECTORY(zone) ADD_SUBDIRECTORY(zone)
ADD_SUBDIRECTORY(ucs) ADD_SUBDIRECTORY(ucs)
ADD_SUBDIRECTORY(queryserv) ADD_SUBDIRECTORY(queryserv)
ADD_SUBDIRECTORY(eqlaunch) ADD_SUBDIRECTORY(eqlaunch)
ENDIF(EQEMU_BUILD_SERVER) ENDIF(EQEMU_BUILD_SERVER)
IF(EQEMU_BUILD_LOGIN) IF(EQEMU_BUILD_LOGIN)
ADD_SUBDIRECTORY(loginserver) ADD_SUBDIRECTORY(loginserver)
ENDIF(EQEMU_BUILD_LOGIN) ENDIF(EQEMU_BUILD_LOGIN)
IF(EQEMU_BUILD_AZONE) IF(EQEMU_BUILD_AZONE)
ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(utils)
ENDIF(EQEMU_BUILD_AZONE) ENDIF(EQEMU_BUILD_AZONE)
IF(EQEMU_BUILD_TESTS) IF(EQEMU_BUILD_TESTS)
ADD_SUBDIRECTORY(tests) ADD_SUBDIRECTORY(tests)
ENDIF(EQEMU_BUILD_TESTS) ENDIF(EQEMU_BUILD_TESTS)

View File

@ -4,65 +4,65 @@
# #
# Find the native MySQL includes and library # Find the native MySQL includes and library
# #
# MySQL_INCLUDE_DIR - where to find mysql.h, etc. # MySQL_INCLUDE_DIR - where to find mysql.h, etc.
# MySQL_LIBRARIES - List of libraries when using MySQL. # MySQL_LIBRARIES - List of libraries when using MySQL.
# MySQL_FOUND - True if MySQL found. # MySQL_FOUND - True if MySQL found.
# The following can be used as a hint as to where to search: # The following can be used as a hint as to where to search:
# MYSQL_ROOT # MYSQL_ROOT
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES) IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
# Already in cache, be silent # Already in cache, be silent
SET(MySQL_FIND_QUIETLY TRUE) SET(MySQL_FIND_QUIETLY TRUE)
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES) ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
# Include dir # Include dir
IF(MYSQL_ROOT) IF(MYSQL_ROOT)
FIND_PATH(MySQL_INCLUDE_DIR FIND_PATH(MySQL_INCLUDE_DIR
NAMES mysql.h NAMES mysql.h
PATHS ${MYSQL_ROOT}/include PATHS ${MYSQL_ROOT}/include
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
ELSE(MYSQL_ROOT) ELSE(MYSQL_ROOT)
FIND_PATH(MySQL_INCLUDE_DIR FIND_PATH(MySQL_INCLUDE_DIR
NAMES mysql.h NAMES mysql.h
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
ENDIF(MYSQL_ROOT) ENDIF(MYSQL_ROOT)
# Library # Library
SET(MySQL_NAMES mysqlclient_r mysqlclient) SET(MySQL_NAMES mysqlclient_r mysqlclient)
IF(MYSQL_ROOT) IF(MYSQL_ROOT)
FIND_LIBRARY(MySQL_LIBRARY_DEBUG FIND_LIBRARY(MySQL_LIBRARY_DEBUG
NAMES ${MySQL_NAMES} NAMES ${MySQL_NAMES}
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
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
ELSE(MYSQL_ROOT) ELSE(MYSQL_ROOT)
FIND_LIBRARY(MySQL_LIBRARY_DEBUG FIND_LIBRARY(MySQL_LIBRARY_DEBUG
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
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
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
) )
ENDIF(MYSQL_ROOT) ENDIF(MYSQL_ROOT)
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE) IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
SET(MySQL_FOUND TRUE) SET(MySQL_FOUND TRUE)
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} ) SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE) ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
SET(MySQL_FOUND FALSE) SET(MySQL_FOUND FALSE)
SET( MySQL_LIBRARIES ) SET( MySQL_LIBRARIES )
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE) ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
@ -72,14 +72,13 @@ INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY_DEBUG MySQL_LIBRARY_RELEASE MySQL_INCLUDE_DIR) FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY_DEBUG MySQL_LIBRARY_RELEASE MySQL_INCLUDE_DIR)
IF(MySQL_FOUND) IF(MySQL_FOUND)
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} ) SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
ELSE(MySQL_FOUND) ELSE(MySQL_FOUND)
SET( MySQL_LIBRARIES ) SET( MySQL_LIBRARIES )
ENDIF(MySQL_FOUND) ENDIF(MySQL_FOUND)
MARK_AS_ADVANCED( MARK_AS_ADVANCED(
MySQL_LIBRARY_DEBUG MySQL_LIBRARY_DEBUG
MySQL_LIBRARY_RELEASE MySQL_LIBRARY_RELEASE
MySQL_INCLUDE_DIR MySQL_INCLUDE_DIR
) )

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "debug.h" #include "debug.h"
#include "BasePacket.h" #include "BasePacket.h"
@ -34,7 +34,7 @@ BasePacket::BasePacket(const unsigned char *buf, uint32 len)
pBuffer= new unsigned char[len]; pBuffer= new unsigned char[len];
if (buf) { if (buf) {
memcpy(this->pBuffer,buf,len); memcpy(this->pBuffer,buf,len);
} else { } else {
memset(this->pBuffer,0,len); memset(this->pBuffer,0,len);
} }
} }
@ -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)
{ {
@ -124,24 +124,3 @@ void DumpPacketBin(const BasePacket* app) {
DumpPacketBin(app->pBuffer, app->size); DumpPacketBin(app->pBuffer, app->size);
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 BASEPACKET_H_ #ifndef BASEPACKET_H_
#define BASEPACKET_H_ #define BASEPACKET_H_
@ -50,7 +50,7 @@ public:
void setSrcInfo(uint32 sip, uint16 sport) { src_ip=sip; src_port=sport; } void setSrcInfo(uint32 sip, uint16 sport) { src_ip=sip; src_port=sport; }
void setDstInfo(uint32 dip, uint16 dport) { dst_ip=dip; dst_port=dport; } void setDstInfo(uint32 dip, uint16 dport) { dst_ip=dip; dst_port=dport; }
void setTimeInfo(uint32 ts_sec, uint32 ts_usec) { timestamp.tv_sec=ts_sec; timestamp.tv_usec=ts_usec; } void setTimeInfo(uint32 ts_sec, uint32 ts_usec) { timestamp.tv_sec=ts_sec; timestamp.tv_usec=ts_usec; }
void copyInfo(const BasePacket *p) { src_ip=p->src_ip; src_port=p->src_port; dst_ip=p->dst_ip; dst_port=p->dst_port; timestamp.tv_sec=p->timestamp.tv_sec; timestamp.tv_usec=p->timestamp.tv_usec; } void copyInfo(const BasePacket *p) { src_ip=p->src_ip; src_port=p->src_port; dst_ip=p->dst_ip; dst_port=p->dst_port; timestamp.tv_sec=p->timestamp.tv_sec; timestamp.tv_usec=p->timestamp.tv_usec; }
inline bool operator<(const BasePacket &rhs) { inline bool operator<(const BasePacket &rhs) {
return (timestamp.tv_sec < rhs.timestamp.tv_sec || (timestamp.tv_sec==rhs.timestamp.tv_sec && timestamp.tv_usec < rhs.timestamp.tv_usec)); return (timestamp.tv_sec < rhs.timestamp.tv_sec || (timestamp.tv_sec==rhs.timestamp.tv_sec && timestamp.tv_usec < rhs.timestamp.tv_usec));
@ -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; }
@ -89,5 +89,3 @@ extern void DumpPacketBin(const BasePacket* app);
#endif /*BASEPACKET_H_*/ #endif /*BASEPACKET_H_*/

View File

@ -1,312 +1,312 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(common_sources SET(common_sources
BasePacket.cpp BasePacket.cpp
classes.cpp classes.cpp
Condition.cpp Condition.cpp
crash.cpp crash.cpp
CRC16.cpp CRC16.cpp
crc32.cpp crc32.cpp
database.cpp database.cpp
dbasync.cpp dbasync.cpp
dbcore.cpp dbcore.cpp
DBMemLeak.cpp DBMemLeak.cpp
debug.cpp debug.cpp
emu_opcodes.cpp emu_opcodes.cpp
EmuTCPConnection.cpp EmuTCPConnection.cpp
EmuTCPServer.cpp EmuTCPServer.cpp
EQDB.cpp EQDB.cpp
EQDBRes.cpp EQDBRes.cpp
eqemu_exception.cpp eqemu_exception.cpp
EQEmuConfig.cpp EQEmuConfig.cpp
EQEMuError.cpp EQEMuError.cpp
EQPacket.cpp EQPacket.cpp
EQStream.cpp EQStream.cpp
EQStreamFactory.cpp EQStreamFactory.cpp
EQStreamIdent.cpp EQStreamIdent.cpp
EQStreamProxy.cpp EQStreamProxy.cpp
eqtime.cpp eqtime.cpp
extprofile.cpp extprofile.cpp
faction.cpp faction.cpp
guild_base.cpp guild_base.cpp
guilds.cpp guilds.cpp
ipc_mutex.cpp ipc_mutex.cpp
Item.cpp Item.cpp
logsys.cpp logsys.cpp
logsys_eqemu.cpp logsys_eqemu.cpp
md5.cpp md5.cpp
memory_mapped_file.cpp memory_mapped_file.cpp
misc.cpp misc.cpp
MiscFunctions.cpp MiscFunctions.cpp
moremath.cpp moremath.cpp
Mutex.cpp Mutex.cpp
opcode_map.cpp opcode_map.cpp
opcodemgr.cpp opcodemgr.cpp
packet_dump.cpp packet_dump.cpp
packet_dump_file.cpp packet_dump_file.cpp
packet_functions.cpp packet_functions.cpp
perl_EQDB.cpp perl_EQDB.cpp
perl_EQDBRes.cpp perl_EQDBRes.cpp
ProcLauncher.cpp ProcLauncher.cpp
ptimer.cpp ptimer.cpp
races.cpp races.cpp
rdtsc.cpp rdtsc.cpp
rulesys.cpp rulesys.cpp
serverinfo.cpp serverinfo.cpp
shareddb.cpp shareddb.cpp
spdat.cpp spdat.cpp
StructStrategy.cpp StructStrategy.cpp
TCPConnection.cpp TCPConnection.cpp
TCPServer.cpp TCPServer.cpp
timeoutmgr.cpp timeoutmgr.cpp
timer.cpp timer.cpp
unix.cpp unix.cpp
worldconn.cpp worldconn.cpp
XMLParser.cpp XMLParser.cpp
platform.cpp platform.cpp
patches/Client62.cpp patches/Client62.cpp
patches/patches.cpp patches/patches.cpp
patches/SoD.cpp patches/SoD.cpp
patches/SoF.cpp patches/SoF.cpp
patches/RoF.cpp patches/RoF.cpp
patches/Titanium.cpp patches/Titanium.cpp
patches/Underfoot.cpp patches/Underfoot.cpp
SocketLib/Base64.cpp SocketLib/Base64.cpp
SocketLib/File.cpp SocketLib/File.cpp
SocketLib/HttpdCookies.cpp SocketLib/HttpdCookies.cpp
SocketLib/HttpdForm.cpp SocketLib/HttpdForm.cpp
SocketLib/HttpdSocket.cpp SocketLib/HttpdSocket.cpp
SocketLib/HTTPSocket.cpp SocketLib/HTTPSocket.cpp
SocketLib/MemFile.cpp SocketLib/MemFile.cpp
SocketLib/Mime.cpp SocketLib/Mime.cpp
SocketLib/Parse.cpp SocketLib/Parse.cpp
SocketLib/socket_include.cpp SocketLib/socket_include.cpp
SocketLib/Utility.cpp SocketLib/Utility.cpp
StackWalker/StackWalker.cpp StackWalker/StackWalker.cpp
tinyxml/tinystr.cpp tinyxml/tinystr.cpp
tinyxml/tinyxml.cpp tinyxml/tinyxml.cpp
tinyxml/tinyxmlerror.cpp tinyxml/tinyxmlerror.cpp
tinyxml/tinyxmlparser.cpp tinyxml/tinyxmlparser.cpp
) )
SET(common_headers SET(common_headers
BasePacket.h BasePacket.h
bodytypes.h bodytypes.h
breakdowns.h breakdowns.h
classes.h classes.h
common_profile.h common_profile.h
Condition.h Condition.h
crash.h crash.h
CRC16.h CRC16.h
crc32.h crc32.h
database.h database.h
dbasync.h dbasync.h
dbcore.h dbcore.h
DBMemLeak.h DBMemLeak.h
debug.h debug.h
deity.h deity.h
emu_opcodes.h emu_opcodes.h
emu_oplist.h emu_oplist.h
EmuTCPConnection.h EmuTCPConnection.h
EmuTCPServer.h EmuTCPServer.h
eq_constants.h eq_constants.h
eq_packet_structs.h eq_packet_structs.h
EQDB.h EQDB.h
EQDBRes.h EQDBRes.h
eqemu_exception.h eqemu_exception.h
EQEmuConfig.h EQEmuConfig.h
EQEmuConfig_elements.h EQEmuConfig_elements.h
EQEMuError.h EQEMuError.h
EQPacket.h EQPacket.h
EQStream.h EQStream.h
EQStreamFactory.h EQStreamFactory.h
EQStreamIdent.h EQStreamIdent.h
EQStreamIntf.h EQStreamIntf.h
EQStreamLocator.h EQStreamLocator.h
EQStreamProxy.h EQStreamProxy.h
EQStreamType.h EQStreamType.h
eqtime.h eqtime.h
errmsg.h errmsg.h
extprofile.h extprofile.h
faction.h faction.h
features.h features.h
fixed_memory_hash_set.h fixed_memory_hash_set.h
fixed_memory_variable_hash_set.h fixed_memory_variable_hash_set.h
guild_base.h guild_base.h
guilds.h guilds.h
ipc_mutex.h ipc_mutex.h
Item.h Item.h
item_fieldlist.h item_fieldlist.h
item_struct.h item_struct.h
languages.h languages.h
linked_list.h linked_list.h
logsys.h logsys.h
logtypes.h logtypes.h
loottable.h loottable.h
mail_oplist.h mail_oplist.h
md5.h md5.h
memory_mapped_file.h memory_mapped_file.h
misc.h misc.h
MiscFunctions.h MiscFunctions.h
moremath.h moremath.h
Mutex.h Mutex.h
op_codes.h op_codes.h
opcode_dispatch.h opcode_dispatch.h
opcodemgr.h opcodemgr.h
packet_dump.h packet_dump.h
packet_dump_file.h packet_dump_file.h
packet_functions.h packet_functions.h
ProcLauncher.h ProcLauncher.h
profiler.h profiler.h
ptimer.h ptimer.h
queue.h queue.h
races.h races.h
rdtsc.h rdtsc.h
rulesys.h rulesys.h
ruletypes.h ruletypes.h
seperator.h seperator.h
serverinfo.h serverinfo.h
servertalk.h servertalk.h
shareddb.h shareddb.h
skills.h skills.h
spdat.h spdat.h
StructStrategy.h StructStrategy.h
TCPBasicServer.h TCPBasicServer.h
TCPConnection.h TCPConnection.h
TCPServer.h TCPServer.h
timeoutmgr.h timeoutmgr.h
timer.h timer.h
types.h types.h
unix.h unix.h
useperl.h useperl.h
version.h version.h
worldconn.h worldconn.h
XMLParser.h XMLParser.h
ZoneNumbers.h ZoneNumbers.h
platform.h platform.h
patches/Client62.h patches/Client62.h
patches/Client62_itemfields.h patches/Client62_itemfields.h
patches/Client62_ops.h patches/Client62_ops.h
patches/Client62_structs.h patches/Client62_structs.h
patches/patches.h patches/patches.h
patches/SoD.h patches/SoD.h
patches/SoD_itemfields.h patches/SoD_itemfields.h
patches/SoD_ops.h patches/SoD_ops.h
patches/SoD_structs.h patches/SoD_structs.h
patches/SoF.h patches/SoF.h
patches/SoF_itemfields.h patches/SoF_itemfields.h
patches/SoF_opcode_list.h patches/SoF_opcode_list.h
patches/SoF_ops.h patches/SoF_ops.h
patches/SoF_structs.h patches/SoF_structs.h
patches/SSDeclare.h patches/SSDeclare.h
patches/SSDefine.h patches/SSDefine.h
patches/SSRegister.h patches/SSRegister.h
patches/RoF.h patches/RoF.h
patches/RoF_itemfields.h patches/RoF_itemfields.h
patches/RoF_ops.h patches/RoF_ops.h
patches/RoF_structs.h patches/RoF_structs.h
patches/Titanium.h patches/Titanium.h
patches/Titanium_itemfields.h patches/Titanium_itemfields.h
patches/Titanium_ops.h patches/Titanium_ops.h
patches/Titanium_structs.h patches/Titanium_structs.h
patches/Underfoot.h patches/Underfoot.h
patches/Underfoot_itemfields.h patches/Underfoot_itemfields.h
patches/Underfoot_ops.h patches/Underfoot_ops.h
patches/Underfoot_structs.h patches/Underfoot_structs.h
SocketLib/Base64.h SocketLib/Base64.h
SocketLib/File.h SocketLib/File.h
SocketLib/HttpdCookies.h SocketLib/HttpdCookies.h
SocketLib/HttpdForm.h SocketLib/HttpdForm.h
SocketLib/HttpdSocket.h SocketLib/HttpdSocket.h
SocketLib/HTTPSocket.h SocketLib/HTTPSocket.h
SocketLib/IFile.h SocketLib/IFile.h
SocketLib/MemFile.h SocketLib/MemFile.h
SocketLib/Mime.h SocketLib/Mime.h
SocketLib/Parse.h SocketLib/Parse.h
SocketLib/socket_include.h SocketLib/socket_include.h
SocketLib/Utility.h SocketLib/Utility.h
StackWalker/StackWalker.h StackWalker/StackWalker.h
tinyxml/tinystr.h tinyxml/tinystr.h
tinyxml/tinyxml.h tinyxml/tinyxml.h
) )
SOURCE_GROUP(Patches FILES SOURCE_GROUP(Patches FILES
patches/Client62.h patches/Client62.h
patches/Client62_itemfields.h patches/Client62_itemfields.h
patches/Client62_ops.h patches/Client62_ops.h
patches/Client62_structs.h patches/Client62_structs.h
patches/patches.h patches/patches.h
patches/SoD.h patches/SoD.h
patches/SoD_itemfields.h patches/SoD_itemfields.h
patches/SoD_ops.h patches/SoD_ops.h
patches/SoD_structs.h patches/SoD_structs.h
patches/SoF.h patches/SoF.h
patches/SoF_itemfields.h patches/SoF_itemfields.h
patches/SoF_opcode_list.h patches/SoF_opcode_list.h
patches/SoF_ops.h patches/SoF_ops.h
patches/SoF_structs.h patches/SoF_structs.h
patches/SSDeclare.h patches/SSDeclare.h
patches/SSDefine.h patches/SSDefine.h
patches/SSRegister.h patches/SSRegister.h
patches/RoF.h patches/RoF.h
patches/RoF_itemfields.h patches/RoF_itemfields.h
patches/RoF_ops.h patches/RoF_ops.h
patches/RoF_structs.h patches/RoF_structs.h
patches/Titanium.h patches/Titanium.h
patches/Titanium_itemfields.h patches/Titanium_itemfields.h
patches/Titanium_ops.h patches/Titanium_ops.h
patches/Titanium_structs.h patches/Titanium_structs.h
patches/Underfoot.h patches/Underfoot.h
patches/Underfoot_itemfields.h patches/Underfoot_itemfields.h
patches/Underfoot_ops.h patches/Underfoot_ops.h
patches/Underfoot_structs.h patches/Underfoot_structs.h
patches/Client62.cpp patches/Client62.cpp
patches/patches.cpp patches/patches.cpp
patches/SoD.cpp patches/SoD.cpp
patches/SoF.cpp patches/SoF.cpp
patches/RoF.cpp patches/RoF.cpp
patches/Titanium.cpp patches/Titanium.cpp
patches/Underfoot.cpp patches/Underfoot.cpp
) )
SOURCE_GROUP(SocketLib FILES SOURCE_GROUP(SocketLib FILES
SocketLib/Base64.h SocketLib/Base64.h
SocketLib/File.h SocketLib/File.h
SocketLib/HttpdCookies.h SocketLib/HttpdCookies.h
SocketLib/HttpdForm.h SocketLib/HttpdForm.h
SocketLib/HttpdSocket.h SocketLib/HttpdSocket.h
SocketLib/HTTPSocket.h SocketLib/HTTPSocket.h
SocketLib/IFile.h SocketLib/IFile.h
SocketLib/MemFile.h SocketLib/MemFile.h
SocketLib/Mime.h SocketLib/Mime.h
SocketLib/Parse.h SocketLib/Parse.h
SocketLib/socket_include.h SocketLib/socket_include.h
SocketLib/Utility.h SocketLib/Utility.h
SocketLib/Base64.cpp SocketLib/Base64.cpp
SocketLib/File.cpp SocketLib/File.cpp
SocketLib/HttpdCookies.cpp SocketLib/HttpdCookies.cpp
SocketLib/HttpdForm.cpp SocketLib/HttpdForm.cpp
SocketLib/HttpdSocket.cpp SocketLib/HttpdSocket.cpp
SocketLib/HTTPSocket.cpp SocketLib/HTTPSocket.cpp
SocketLib/MemFile.cpp SocketLib/MemFile.cpp
SocketLib/Mime.cpp SocketLib/Mime.cpp
SocketLib/Parse.cpp SocketLib/Parse.cpp
SocketLib/socket_include.cpp SocketLib/socket_include.cpp
SocketLib/Utility.cpp SocketLib/Utility.cpp
) )
SOURCE_GROUP(StackWalker FILES SOURCE_GROUP(StackWalker FILES
StackWalker/StackWalker.h StackWalker/StackWalker.h
StackWalker/StackWalker.cpp StackWalker/StackWalker.cpp
) )
SOURCE_GROUP(TinyXML FILES SOURCE_GROUP(TinyXML FILES
tinyxml/tinystr.h tinyxml/tinystr.h
tinyxml/tinyxml.h tinyxml/tinyxml.h
tinyxml/tinystr.cpp tinyxml/tinystr.cpp
tinyxml/tinyxml.cpp tinyxml/tinyxml.cpp
tinyxml/tinyxmlerror.cpp tinyxml/tinyxmlerror.cpp
tinyxml/tinyxmlparser.cpp tinyxml/tinyxmlparser.cpp
) )
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML) INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML)
@ -315,8 +315,8 @@ ADD_LIBRARY(Common ${common_sources} ${common_headers})
IF(UNIX) IF(UNIX)
ADD_DEFINITIONS(-fPIC) ADD_DEFINITIONS(-fPIC)
SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0) SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0)
ENDIF(UNIX) ENDIF(UNIX)
SET(LIBRARY_OUTPUT_PATH ../Bin) SET(LIBRARY_OUTPUT_PATH ../Bin)

View File

@ -1,14 +1,15 @@
#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.
uint8 keyBuf[] = {(uint8)((key >> 0) & 0xff), uint8 keyBuf[] = {(uint8)((key >> 0) & 0xff),
(uint8)((key >> 8) & 0xff), (uint8)((key >> 8) & 0xff),
(uint8)((key >> 16) & 0xff), (uint8)((key >> 16) & 0xff),
(uint8)((key >> 24) & 0xff)}; (uint8)((key >> 24) & 0xff)};
uint32 crc = CRC32::Update(keyBuf, sizeof(uint32)); uint32 crc = CRC32::Update(keyBuf, sizeof(uint32));
crc = CRC32::Update(buf, size, crc); crc = CRC32::Update(buf, size, crc);
return CRC32::Finish(crc) & 0xffff; return CRC32::Finish(crc) & 0xffff;
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "debug.h" #include "debug.h"
@ -29,16 +29,16 @@
#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?
FALSE, // is signaled initially? FALSE, // is signaled initially?
nullptr); // name nullptr); // name
m_events[BroadcastEvent] = CreateEvent (nullptr, // security m_events[BroadcastEvent] = CreateEvent (nullptr, // security
TRUE, // is auto-reset event? TRUE, // is auto-reset event?
FALSE, // is signaled initially? FALSE, // is signaled initially?
nullptr); // name nullptr); // name
m_waiters = 0; m_waiters = 0;
InitializeCriticalSection(&CSMutex); InitializeCriticalSection(&CSMutex);
} }
@ -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);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 __CONDITION_H #ifndef __CONDITION_H
#define __CONDITION_H #define __CONDITION_H

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "debug.h" #include "debug.h"
#include "EQDB.h" #include "EQDB.h"
@ -64,15 +64,12 @@ 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;
return(m_escapeBuffer.c_str()); return(m_escapeBuffer.c_str());
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 EQDB_H_ #ifndef EQDB_H_
#define EQDB_H_ #define EQDB_H_
@ -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();

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "debug.h" #include "debug.h"
#include "EQDBRes.h" #include "EQDBRes.h"
@ -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;
@ -49,3 +49,4 @@ map<string,string> EQDBRes::fetch_row_hash() {
return rowhash; return rowhash;
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 EQDBRes_H_ #ifndef EQDBRes_H_
#define EQDBRes_H_ #define EQDBRes_H_
@ -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; }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
@ -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;

View File

@ -1,26 +1,26 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 EQEMuError_H #ifndef EQEMuError_H
#define EQEMuError_H #define EQEMuError_H
#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,

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include "EQEmuConfig.h" #include "EQEmuConfig.h"
@ -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;
@ -446,27 +446,3 @@ void EQEmuConfig::Dump() const
// cout << "DynamicCount = " << DynamicCount << endl; // cout << "DynamicCount = " << DynamicCount << endl;
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 __EQEmuConfig_H #ifndef __EQEmuConfig_H
#define __EQEmuConfig_H #define __EQEmuConfig_H
@ -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);
} }

View File

@ -1,21 +1,21 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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
*/ */
/* /*
* EQStream classes, by Quagmire * EQStream classes, by Quagmire
*/ */
@ -60,18 +60,18 @@ using namespace std;
#define LOG_RAW_PACKETS_IN 0 #define LOG_RAW_PACKETS_IN 0
//#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,8 +125,8 @@ 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;
address.sin_port = htons(pPort); address.sin_port = htons(pPort);
@ -206,14 +206,14 @@ void EQStreamServer::Process() {
return; return;
} }
uchar buffer[1518]; uchar buffer[1518];
int status;
struct sockaddr_in from;
unsigned int fromlen;
from.sin_family = AF_INET; int status;
fromlen = sizeof(from); struct sockaddr_in from;
unsigned int fromlen;
from.sin_family = AF_INET;
fromlen = sizeof(from);
while (1) { while (1) {
#ifdef WIN32 #ifdef WIN32
@ -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++;
@ -285,13 +285,13 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
tmp->RecvData(data, size); tmp->RecvData(data, size);
return; return;
} }
else if(tmp != NULL && tmp->GetrPort() != irPort) else if(tmp != NULL && tmp->GetrPort() != irPort)
{ {
printf("Conflicting IPs & Ports: IP %i and Port %i is conflicting with IP %i and Port %i\n",irIP,irPort,tmp->GetrIP(),tmp->GetrPort()); printf("Conflicting IPs & Ports: IP %i and Port %i is conflicting with IP %i and Port %i\n",irIP,irPort,tmp->GetrIP(),tmp->GetrPort());
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);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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 EQNETWORK_H #ifndef EQNETWORK_H
#define EQNETWORK_H #define EQNETWORK_H

View File

@ -1,19 +1,19 @@
/* /*
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
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
*/ */
#include "debug.h" #include "debug.h"
#include <stdio.h> #include <stdio.h>
@ -35,15 +35,15 @@
using namespace std; using namespace std;
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len) EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len), : BasePacket(buf, len),
emu_opcode(op) emu_opcode(op)
{ {
} }
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
@ -200,7 +200,7 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
uint32 EQProtocolPacket::serialize(unsigned char *dest) const uint32 EQProtocolPacket::serialize(unsigned char *dest) const
{ {
if (opcode>0xff) { if (opcode>0xff) {
*(uint16 *)dest=opcode; *(uint16 *)dest=opcode;
} else { } else {
*(dest)=0; *(dest)=0;
@ -235,8 +235,8 @@ uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
} }
/*EQProtocolPacket::EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) /*EQProtocolPacket::EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len), : BasePacket(buf, len),
opcode(op) opcode(op)
{ {
uint32 offset; uint32 offset;
@ -364,7 +364,7 @@ uint32 flag_offset=0;
} else } else
flag_offset=1; flag_offset=1;
if (length>2 && buffer[flag_offset]==0x5a) { if (length>2 && buffer[flag_offset]==0x5a) {
newlen=InflatePacket(buffer+flag_offset+1,length-(flag_offset+1)-2,newbuf+flag_offset,newbufsize-flag_offset)+2; newlen=InflatePacket(buffer+flag_offset+1,length-(flag_offset+1)-2,newbuf+flag_offset,newbufsize-flag_offset)+2;
newbuf[newlen++]=buffer[length-2]; newbuf[newlen++]=buffer[length-2];
newbuf[newlen++]=buffer[length-1]; newbuf[newlen++]=buffer[length-1];
@ -409,7 +409,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
buffer+=2; buffer+=2;
size-=2; size-=2;
int i; int i;
for (i = 0 ; i+4 <= size ; i+=4) for (i = 0 ; i+4 <= size ; i+=4)
{ {
int pt = (*(int*)&buffer[i])^(Key); int pt = (*(int*)&buffer[i])^(Key);
@ -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);
} }
} }
@ -461,43 +461,43 @@ EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
} }
EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len) EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len)
: EQApplicationPacket(OP_Unknown, buf, len), : EQApplicationPacket(OP_Unknown, buf, len),
opcode(opcode) opcode(opcode)
{ {
} }
EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len) EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len)
: EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16)) : EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16))
{ {
if(GetExecutablePlatform() != ExePlatformUCS) { if(GetExecutablePlatform() != ExePlatformUCS) {
opcode = *((const uint16 *) buf); opcode = *((const uint16 *) buf);
if(opcode == 0x0000) if(opcode == 0x0000)
{ {
if(len >= 3) if(len >= 3)
{ {
opcode = *((const uint16 *) (buf + 1)); opcode = *((const uint16 *) (buf + 1));
const unsigned char *packet_start = (buf + 3); const unsigned char *packet_start = (buf + 3);
const int32 packet_length = len - 3; const int32 packet_length = len - 3;
safe_delete_array(pBuffer); safe_delete_array(pBuffer);
if(len >= 0) if(len >= 0)
{ {
size = packet_length; size = packet_length;
pBuffer = new unsigned char[size]; pBuffer = new unsigned char[size];
memcpy(pBuffer, packet_start, size); memcpy(pBuffer, packet_start, size);
} }
else else
{ {
size = 0; size = 0;
} }
} }
else else
{ {
safe_delete_array(pBuffer); safe_delete_array(pBuffer);
size = 0; size = 0;
} }
} }
} else { } else {
opcode = *((const uint8 *) buf); opcode = *((const uint8 *) buf);
} }
} }
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) { void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {

View File

@ -1,19 +1,19 @@
/* /*
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
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 _EQPACKET_H #ifndef _EQPACKET_H
#define _EQPACKET_H #define _EQPACKET_H
@ -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);
}; };

View File

@ -1,19 +1,19 @@
/* /*
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
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
*/ */
#include "debug.h" #include "debug.h"
#include <string> #include <string>
@ -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));
} }
@ -121,7 +121,7 @@ uint32 processed=0,subpacket_length=0;
return; return;
// Raw Application packet // Raw Application packet
if (p->opcode > 0xff) { if (p->opcode > 0xff) {
p->opcode = htons(p->opcode); //byte order is backwards in the protocol packet p->opcode = htons(p->opcode); //byte order is backwards in the protocol packet
EQRawApplicationPacket *ap=MakeApplicationPacket(p); EQRawApplicationPacket *ap=MakeApplicationPacket(p);
if (ap) if (ap)
InboundQueuePush(ap); InboundQueuePush(ap);
@ -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))
{ {
@ -192,7 +192,7 @@ uint32 processed=0,subpacket_length=0;
} else if (check == SeqPast) { } else if (check == SeqPast) {
_log(NET__DEBUG, _L "Duplicate OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); _log(NET__DEBUG, _L "Duplicate OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
_raw(NET__DEBUG, seq, p); _raw(NET__DEBUG, seq, p);
SendOutOfOrderAck(seq); //we already got this packet but it was out of order SendOutOfOrderAck(seq); //we already got this packet but it was out of order
} else { } else {
// In case we did queue one before as well. // In case we did queue one before as well.
EQProtocolPacket *qp=RemoveQueue(seq); EQProtocolPacket *qp=RemoveQueue(seq);
@ -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);
} }
@ -418,7 +418,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
_log(NET__NET_TRACE, _L "Received OP_OutOfOrderAck for sequence %d, starting retransmit at the start of our unacked buffer (seq %d, was %d)." __L, _log(NET__NET_TRACE, _L "Received OP_OutOfOrderAck for sequence %d, starting retransmit at the start of our unacked buffer (seq %d, was %d)." __L,
seq, SequencedBase, SequencedBase+NextSequencedSend); seq, SequencedBase, SequencedBase+NextSequencedSend);
#ifdef RETRANSMITS #ifdef RETRANSMITS
if (!RuleB(EQStream, RetransmitAckedPackets)) { if (!RuleB(EQStream, RetransmitAckedPackets)) {
#endif #endif
uint16 sqsize = SequencedQueue.size(); uint16 sqsize = SequencedQueue.size();
uint16 index = seq - SequencedBase; uint16 index = seq - SequencedBase;
@ -431,7 +431,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
} }
#ifdef RETRANSMITS #ifdef RETRANSMITS
} }
if (RuleR(EQStream, RetransmitTimeoutMult)) { // only choose new behavior if multiplier is set if (RuleR(EQStream, RetransmitTimeoutMult)) { // only choose new behavior if multiplier is set
retransmittimer = Timer::GetCurrentTime(); retransmittimer = Timer::GetCurrentTime();
} }
#endif #endif
@ -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,9 +684,9 @@ 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) {
// See if there are more non-sequenced packets left // See if there are more non-sequenced packets left
if (!NonSequencedQueue.empty()) { if (!NonSequencedQueue.empty()) {
@ -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);
@ -1308,7 +1308,7 @@ EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
if (expected_seq==seq) { if (expected_seq==seq) {
// Curent // Curent
return SeqInOrder; return SeqInOrder;
} else if ((seq > expected_seq && (uint32)seq < ((uint32)expected_seq + EQStream::MaxWindowSize)) || seq < (expected_seq - EQStream::MaxWindowSize)) { } else if ((seq > expected_seq && (uint32)seq < ((uint32)expected_seq + EQStream::MaxWindowSize)) || seq < (expected_seq - EQStream::MaxWindowSize)) {
// Future // Future
return SeqFuture; return SeqFuture;
} else { } else {
@ -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,10 +1444,7 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
} }
} }
MInboundQueue.unlock(); MInboundQueue.unlock();
return(res); return(res);
} }

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];
@ -89,7 +89,7 @@ class EQStream : public EQStreamInterface {
uint32 Session, Key; uint32 Session, Key;
uint16 NextInSeq; uint16 NextInSeq;
uint32 MaxLen; uint32 MaxLen;
uint16 MaxSends; uint16 MaxSends;
uint8 active_users; //how many things are actively using this uint8 active_users; //how many things are actively using this
@ -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; }
@ -167,21 +167,21 @@ class EQStream : public EQStreamInterface {
// virtual void DispatchPacket(EQApplicationPacket *p) { p->DumpRaw(); } // virtual void DispatchPacket(EQApplicationPacket *p) { p->DumpRaw(); }
bool Stale(uint32 now, uint32 timeout=30) { return (LastPacket && (now-LastPacket) > timeout); } bool Stale(uint32 now, uint32 timeout=30) { return (LastPacket && (now-LastPacket) > timeout); }
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,14 +259,14 @@ 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:
//this object could get more complicated if needed... //this object could get more complicated if needed...
uint16 ignore_eq_opcode; //0=dont ignore uint16 ignore_eq_opcode; //0=dont ignore
uint16 first_eq_opcode; uint16 first_eq_opcode;
uint32 first_length; //0=dont check length uint32 first_length; //0=dont check length
}; };
typedef enum { typedef enum {
MatchNotReady, MatchNotReady,
@ -274,8 +274,8 @@ class EQStream : public EQStreamInterface {
MatchFailed MatchFailed
} MatchState; } MatchState;
MatchState CheckSignature(const Signature *sig); MatchState CheckSignature(const Signature *sig);
}; };
#endif #endif

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,8 +55,8 @@ 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;
Port=port; Port=port;
@ -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,6 @@ Timer DecayTimer(20);
(*cur)->Write(sock); (*cur)->Write(sock);
(*cur)->ReleaseFromUse(); (*cur)->ReleaseFromUse();
} }
Sleep(10); Sleep(10);
@ -328,20 +327,3 @@ Timer DecayTimer(20);
} }
} }

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;
@ -34,7 +34,7 @@ class EQStreamFactory : private Timeoutable {
Timer *DecayTimer; Timer *DecayTimer;
uint32 stream_timeout; uint32 stream_timeout;
public: public:
EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; } EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; }

View File

@ -1,4 +1,3 @@
#include "debug.h" #include "debug.h"
#include "EQStreamIdent.h" #include "EQStreamIdent.h"
#include "EQStreamProxy.h" #include "EQStreamProxy.h"
@ -39,12 +38,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 +53,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 +86,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 +108,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 +124,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,44 +155,10 @@ 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)
{ {
} }

View File

@ -15,27 +15,27 @@ 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:
std::string name; std::string name;
EQStream::Signature signature; EQStream::Signature signature;
OpcodeManager ** opcodes; OpcodeManager ** opcodes;
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:

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;

View File

@ -1,19 +1,19 @@
/* /*
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
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 _EQSTREAM_LOCATOR_H #ifndef _EQSTREAM_LOCATOR_H
#define _EQSTREAM_LOCATOR_H #define _EQSTREAM_LOCATOR_H
@ -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,16 +160,14 @@ 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;
}; };
#endif #endif

View File

@ -6,9 +6,9 @@
EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes) EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes)
: m_stream(stream), : m_stream(stream),
m_structs(structs), m_structs(structs),
m_opcodes(opcodes) m_opcodes(opcodes)
{ {
stream = nullptr; //take the stream. stream = nullptr; //take the stream.
m_stream->SetOpcodeManager(m_opcodes); m_stream->SetOpcodeManager(m_opcodes);
@ -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);

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,28 +28,19 @@ 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;
virtual const uint32 GetBytesRecvPerSecond() const; virtual const uint32 GetBytesRecvPerSecond() const;
protected: protected:
EQStream *const m_stream; //we own this stream object. EQStream *const m_stream; //we own this stream object.
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.
}; };
#endif /*EQSTREAMPROXY_H_*/ #endif /*EQSTREAMPROXY_H_*/

View File

@ -1,47 +1,27 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
/* /*
* There are really two or three different objects shoe-hored into this
* connection object. Sombody really needs to factor out the relay link
* crap into its own subclass of this object, it will clean things up
* tremendously.
* There are really two or three different objects shoe-hored into this */
* connection object. Sombody really needs to factor out the relay link
* crap into its own subclass of this object, it will clean things up
* tremendously.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
#include "../common/debug.h" #include "../common/debug.h"
@ -71,9 +51,9 @@ using namespace std;
//server side case //server side case
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_socket, uint32 irIP, uint16 irPort, bool iOldFormat) EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_socket, uint32 irIP, uint16 irPort, bool iOldFormat)
: TCPConnection(ID, in_socket, irIP, irPort), : TCPConnection(ID, in_socket, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT), keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2) timeout_timer(SERVER_TIMEOUT * 2)
{ {
id = 0; id = 0;
Server = nullptr; Server = nullptr;
@ -92,14 +72,14 @@ 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)
EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer, eTCPMode iMode) EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer, eTCPMode iMode)
: TCPConnection(), : TCPConnection(),
keepalive_timer(SERVER_TIMEOUT), keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2) timeout_timer(SERVER_TIMEOUT * 2)
{ {
Server = iRelayServer; Server = iRelayServer;
if (Server) if (Server)
@ -119,9 +99,9 @@ EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer,
//server side relay case //server side relay case
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort) EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort)
: TCPConnection(ID, 0, irIP, irPort), : TCPConnection(ID, 0, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT), keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2) timeout_timer(SERVER_TIMEOUT * 2)
{ {
Server = iServer; Server = iServer;
RelayLink = iRelayLink; RelayLink = iRelayLink;
@ -141,7 +121,6 @@ EmuTCPConnection::~EmuTCPConnection() {
//the queues free their content right now I believe. //the queues free their content right now I believe.
} }
EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32 iDestination) { EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32 iDestination) {
int32 size = sizeof(EmuTCPNetPacket_Struct) + pack->size; int32 size = sizeof(EmuTCPNetPacket_Struct) + pack->size;
if (pack->compressed) { if (pack->compressed) {
@ -246,7 +225,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 +370,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 +386,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,27 +432,26 @@ 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();
} }
void EmuTCPConnection::SendNetErrorPacket(const char* reason) { void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
#if TCPC_DEBUG >= 1 #if TCPC_DEBUG >= 1
struct in_addr in; struct in_addr in;
@ -810,7 +788,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()) {
@ -820,9 +798,9 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
#if TCPN_DEBUG >= 5 #if TCPN_DEBUG >= 5
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);
} }
bool EmuTCPConnection::RecvData(char* errbuf) { bool EmuTCPConnection::RecvData(char* errbuf) {
@ -832,24 +810,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);
} }

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;

View File

@ -1,14 +1,10 @@
#include "debug.h" #include "debug.h"
#include "EmuTCPServer.h" #include "EmuTCPServer.h"
#include "EmuTCPConnection.h" #include "EmuTCPConnection.h"
EmuTCPServer::EmuTCPServer(uint16 iPort, bool iOldFormat) EmuTCPServer::EmuTCPServer(uint16 iPort, bool iOldFormat)
: TCPServer<EmuTCPConnection>(iPort), : TCPServer<EmuTCPConnection>(iPort),
pOldFormat(iOldFormat) pOldFormat(iOldFormat)
{ {
} }
@ -83,14 +79,3 @@ EmuTCPConnection *EmuTCPServer::FindConnection(uint32 iID) {
return(nullptr); return(nullptr);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
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
*/ */
// @merth notes: // @merth notes:
@ -86,7 +86,7 @@ typedef enum {
//FatherNitwit: location bits for searching specific //FatherNitwit: location bits for searching specific
//places with HasItem() and HasItemByUse() //places with HasItem() and HasItemByUse()
enum { enum {
invWhereWorn = 0x01, invWhereWorn = 0x01,
invWherePersonal = 0x02, //in the character's inventory invWherePersonal = 0x02, //in the character's inventory
invWhereBank = 0x04, invWhereBank = 0x04,
invWhereSharedBank = 0x08, invWhereSharedBank = 0x08,
@ -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,25 +195,25 @@ 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);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value); void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value); void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value);
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value); void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value);
std::string GetCustomItemData(int16 slot_id, std::string identifier); std::string GetCustomItemData(int16 slot_id, std::string identifier);
protected: 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; }
@ -339,7 +339,7 @@ public:
void SetMerchantCount(int32 count) { m_merchantcount = count; } void SetMerchantCount(int32 count) { m_merchantcount = count; }
int16 GetCurrentSlot() const { return m_currentslot; } int16 GetCurrentSlot() const { return m_currentslot; }
void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; } void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; }
@ -348,24 +348,24 @@ public:
bool IsInstNoDrop() const { return m_instnodrop; } bool IsInstNoDrop() const { return m_instnodrop; }
void SetInstNoDrop(bool flag) { m_instnodrop=flag; } void SetInstNoDrop(bool flag) { m_instnodrop=flag; }
std::string GetCustomDataString() const; std::string GetCustomDataString() const;
void SetCustomData(std::string identifier, std::string value); void SetCustomData(std::string identifier, std::string value);
void SetCustomData(std::string identifier, int value); void SetCustomData(std::string identifier, int value);
void SetCustomData(std::string identifier, float value); void SetCustomData(std::string identifier, float value);
void SetCustomData(std::string identifier, bool value); void SetCustomData(std::string identifier, bool value);
std::string GetCustomData(std::string identifier); std::string GetCustomData(std::string identifier);
void DeleteCustomData(std::string identifier); void DeleteCustomData(std::string identifier);
// 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; }
@ -379,14 +379,14 @@ protected:
////////////////////////// //////////////////////////
// Protected Members // Protected Members
////////////////////////// //////////////////////////
iter_contents _begin() { return m_contents.begin(); } iter_contents _begin() { return m_contents.begin(); }
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
@ -394,13 +394,13 @@ protected:
uint32 m_color; uint32 m_color;
uint32 m_merchantslot; uint32 m_merchantslot;
int16 m_currentslot; int16 m_currentslot;
bool m_instnodrop; bool m_instnodrop;
int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar. int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
// //
// Items inside of this item (augs or contents); // Items inside of this item (augs or contents);
map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9 map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
map<std::string, std::string> m_custom_data; map<std::string, std::string> m_custom_data;
}; };
class EvoItemInst: public ItemInst { class EvoItemInst: public ItemInst {
@ -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();

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include "MiscFunctions.h" #include "MiscFunctions.h"
@ -42,7 +42,7 @@ using namespace std;
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
@ -50,9 +50,9 @@ using namespace std;
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#ifdef FREEBSD //Timothy Whitman - January 7, 2003 #ifdef FREEBSD //Timothy Whitman - January 7, 2003
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <netdb.h> #include <netdb.h>
@ -83,8 +83,8 @@ 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;
if (ms) if (ms)
@ -121,50 +121,50 @@ bool strn0cpyt(char* dest, const char* source, uint32 size) {
} }
const char *MakeUpperString(const char *source) { const char *MakeUpperString(const char *source) {
static char str[128]; static char str[128];
if (!source) if (!source)
return nullptr; return nullptr;
MakeUpperString(source, str); MakeUpperString(source, str);
return str; return str;
} }
void MakeUpperString(const char *source, char *target) { void MakeUpperString(const char *source, char *target) {
if (!source || !target) { if (!source || !target) {
*target=0; *target=0;
return; return;
} }
while (*source) while (*source)
{ {
*target = toupper(*source); *target = toupper(*source);
target++;source++; target++;source++;
} }
*target = 0; *target = 0;
} }
const char *MakeLowerString(const char *source) { const char *MakeLowerString(const char *source) {
static char str[128]; static char str[128];
if (!source) if (!source)
return nullptr; return nullptr;
MakeLowerString(source, str); MakeLowerString(source, str);
return str; return str;
} }
void MakeLowerString(const char *source, char *target) { void MakeLowerString(const char *source, char *target) {
if (!source || !target) { if (!source || !target) {
*target=0; *target=0;
return; return;
} }
while (*source) while (*source)
{ {
*target = tolower(*source); *target = tolower(*source);
target++;source++; target++;source++;
} }
*target = 0; *target = 0;
} }
int MakeAnyLenString(char** ret, const char* format, ...) { int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128; int buf_len = 128;
int chars = -1; int chars = -1;
va_list argptr, tmpargptr; va_list argptr, tmpargptr;
va_start(argptr, format); va_start(argptr, format);
while (chars == -1 || chars >= buf_len) { while (chars == -1 || chars >= buf_len) {
@ -186,7 +186,7 @@ uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const cha
*bufsize = 256; *bufsize = 256;
if (*ret == 0) if (*ret == 0)
*strlen = 0; *strlen = 0;
int chars = -1; int chars = -1;
char* oldret = 0; char* oldret = 0;
va_list argptr, tmpargptr; va_list argptr, tmpargptr;
va_start(argptr, format); va_start(argptr, format);
@ -314,7 +314,7 @@ uint32 ResolveIP(const char* hostname, char* errbuf) {
snprintf(errbuf, ERRBUF_SIZE, "ResolveIP(): hostname == 0"); snprintf(errbuf, ERRBUF_SIZE, "ResolveIP(): hostname == 0");
return 0; return 0;
} }
struct sockaddr_in server_sin; struct sockaddr_in server_sin;
#ifdef _WINDOWS #ifdef _WINDOWS
PHOSTENT phostent = nullptr; PHOSTENT phostent = nullptr;
#else #else
@ -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
*/ */
@ -394,7 +394,7 @@ int MakeRandomInt(int low, int high)
return(low); return(low);
//return (rand()%(high-low+1) + (low)); //return (rand()%(high-low+1) + (low));
if(!WELLRNG_init) { if(!WELLRNG_init) {
WELLRNG_init = true; WELLRNG_init = true;
oneseed( rnd_hash( time(nullptr), clock() ) ); oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1; WELLRNG19937 = case_1;
@ -412,7 +412,7 @@ double MakeRandomFloat(double low, double high)
return(low); return(low);
//return (rand() / (double)RAND_MAX * (high - low) + low); //return (rand() / (double)RAND_MAX * (high - low) + low);
if(!WELLRNG_init) { if(!WELLRNG_init) {
WELLRNG_init = true; WELLRNG_init = true;
oneseed( rnd_hash( time(nullptr), clock() ) ); oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1; WELLRNG19937 = case_1;
@ -422,41 +422,41 @@ double MakeRandomFloat(double low, double high)
uint32 rnd_hash( time_t t, clock_t c ) 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 )
{ {
h1 *= 255 + 2U; h1 *= 255 + 2U;
h1 += p[i]; h1 += p[i];
} }
uint32 h2 = 0; uint32 h2 = 0;
p = (unsigned char *) &c; p = (unsigned char *) &c;
for( size_t j = 0; j < sizeof(c); ++j ) for( size_t j = 0; j < sizeof(c); ++j )
{ {
h2 *= 255 + 2U; h2 *= 255 + 2U;
h2 += p[j]; h2 += p[j];
} }
return ( h1 + differ++ ) ^ h2; return ( h1 + differ++ ) ^ h2;
} }
void oneseed( const uint32 seed ) void oneseed( const uint32 seed )
{ {
// Initialize generator state with seed // Initialize generator state with seed
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier. // See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect // In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto. // only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register int j = 0; register int j = 0;
STATE[j] = seed & 0xffffffffUL; STATE[j] = seed & 0xffffffffUL;
for (j = 1; j < R; j++) for (j = 1; j < R; j++)
{ {
STATE[j] = ( 1812433253UL * ( STATE[j-1] ^ (STATE[j-1] >> 30) ) + j ) & 0xffffffffUL; STATE[j] = ( 1812433253UL * ( STATE[j-1] ^ (STATE[j-1] >> 30) ) + j ) & 0xffffffffUL;
} }
} }
// WELL RNG code // WELL RNG code
@ -472,79 +472,79 @@ void oneseed( const uint32 seed )
/* ***************************************************************************** */ /* ***************************************************************************** */
unsigned int case_1 (void){ unsigned int case_1 (void){
// state_i == 0 // state_i == 0
z0 = (VRm1Under & MASKL) | (VRm2Under & MASKU); z0 = (VRm1Under & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3); z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0Under = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0Under = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = R - 1; state_i = R - 1;
WELLRNG19937 = case_3; WELLRNG19937 = case_3;
return (STATE[state_i] ^ (newVM2Over & BITMASK)); return (STATE[state_i] ^ (newVM2Over & BITMASK));
} }
static unsigned int case_2 (void){ static unsigned int case_2 (void){
// state_i == 1 // state_i == 1
z0 = (VRm1 & MASKL) | (VRm2Under & MASKU); z0 = (VRm1 & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3); z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = 0; state_i = 0;
WELLRNG19937 = case_1; WELLRNG19937 = case_1;
return (STATE[state_i] ^ (newVM2 & BITMASK)); return (STATE[state_i] ^ (newVM2 & BITMASK));
} }
static unsigned int case_3 (void){ static unsigned int case_3 (void){
// state_i+M1 >= R // state_i+M1 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU); z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1Over); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1Over);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over); z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--; state_i--;
if (state_i + M1 < R) if (state_i + M1 < R)
WELLRNG19937 = case_5; WELLRNG19937 = case_5;
return (STATE[state_i] ^ (newVM2Over & BITMASK)); return (STATE[state_i] ^ (newVM2Over & BITMASK));
} }
static unsigned int case_4 (void){ static unsigned int case_4 (void){
// state_i+M3 >= R // state_i+M3 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU); z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3Over); z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--; state_i--;
if (state_i + M3 < R) if (state_i + M3 < R)
WELLRNG19937 = case_6; WELLRNG19937 = case_6;
return (STATE[state_i] ^ (newVM2 & BITMASK)); return (STATE[state_i] ^ (newVM2 & BITMASK));
} }
static unsigned int case_5 (void){ static unsigned int case_5 (void){
// state_i+M2 >= R // state_i+M2 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU); z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over); z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--; state_i--;
if (state_i + M2 < R) if (state_i + M2 < R)
WELLRNG19937 = case_4; WELLRNG19937 = case_4;
return (STATE[state_i] ^ (newVM2Over & BITMASK)); return (STATE[state_i] ^ (newVM2Over & BITMASK));
} }
static unsigned int case_6 (void){ static unsigned int case_6 (void){
// 2 <= state_i <= (R - M3 - 1) // 2 <= state_i <= (R - M3 - 1)
z0 = (VRm1 & MASKL) | (VRm2 & MASKU); z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1); z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3); z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2; newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1); newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--; state_i--;
if (state_i == 1) if (state_i == 1)
WELLRNG19937 = case_2; WELLRNG19937 = case_2;
return (STATE[state_i] ^ (newVM2 & BITMASK)); return (STATE[state_i] ^ (newVM2 & BITMASK));
} }
// end WELL RNG code // end WELL RNG code
@ -553,10 +553,10 @@ 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
// is the only non alpha char that's not stripped but converted. // is the only non alpha char that's not stripped but converted.
if(in[i] == '_') if(in[i] == '_')
{ {
@ -632,7 +632,7 @@ void RemoveApostrophes(std::string &s)
{ {
for(unsigned int i = 0; i < s.length(); ++i) for(unsigned int i = 0; i < s.length(); ++i)
if(s[i] == '\'') if(s[i] == '\'')
s[i] = '_'; s[i] = '_';
} }
char *RemoveApostrophes(const char *s) char *RemoveApostrophes(const char *s)
@ -643,7 +643,7 @@ char *RemoveApostrophes(const char *s)
for(unsigned int i = 0 ; i < strlen(NewString); ++i) for(unsigned int i = 0 ; i < strlen(NewString); ++i)
if(NewString[i] == '\'') if(NewString[i] == '\'')
NewString[i] = '_'; NewString[i] = '_';
return NewString; return NewString;
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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 MISCFUNCTIONS_H #ifndef MISCFUNCTIONS_H
#define MISCFUNCTIONS_H #define MISCFUNCTIONS_H
@ -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); }
@ -63,41 +63,41 @@
#define MAT1(v) v #define MAT1(v) v
#define MAT3POS(t,v) (v>>t) #define MAT3POS(t,v) (v>>t)
#define V0 STATE[state_i] #define V0 STATE[state_i]
#define VM1Over STATE[state_i+M1-R] #define VM1Over STATE[state_i+M1-R]
#define VM1 STATE[state_i+M1] #define VM1 STATE[state_i+M1]
#define VM2Over STATE[state_i+M2-R] #define VM2Over STATE[state_i+M2-R]
#define VM2 STATE[state_i+M2] #define VM2 STATE[state_i+M2]
#define VM3Over STATE[state_i+M3-R] #define VM3Over STATE[state_i+M3-R]
#define VM3 STATE[state_i+M3] #define VM3 STATE[state_i+M3]
#define VRm1 STATE[state_i-1] #define VRm1 STATE[state_i-1]
#define VRm1Under STATE[state_i+R-1] #define VRm1Under STATE[state_i+R-1]
#define VRm2 STATE[state_i-2] #define VRm2 STATE[state_i-2]
#define VRm2Under STATE[state_i+R-2] #define VRm2Under STATE[state_i+R-2]
#define newV0 STATE[state_i-1] #define newV0 STATE[state_i-1]
#define newV0Under STATE[state_i-1+R] #define newV0Under STATE[state_i-1+R]
#define newV1 STATE[state_i] #define newV1 STATE[state_i]
#define newVRm1 STATE[state_i-2] #define newVRm1 STATE[state_i-2]
#define newVRm1Under STATE[state_i-2+R] #define newVRm1Under STATE[state_i-2+R]
#define newVM2Over STATE[state_i+M2-R+1] #define newVM2Over STATE[state_i+M2-R+1]
#define newVM2 STATE[state_i+M2+1] #define newVM2 STATE[state_i+M2+1]
#define BITMASK 0x41180000 #define BITMASK 0x41180000
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// MakeUpperString // MakeUpperString
// i : source - allocated null-terminated string // i: source - allocated null-terminated string
// return: pointer to static buffer with the target string // return: pointer to static buffer with the target string
const char *MakeUpperString(const char *source); const char *MakeUpperString(const char *source);
const char *MakeLowerString(const char *source); const char *MakeLowerString(const char *source);
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// //
// MakeUpperString // MakeUpperString
// i : source - allocated null-terminated string // i : source - allocated null-terminated string
// io: target - allocated buffer, at least of size strlen(source)+1 // io: target - allocated buffer, at least of size strlen(source)+1
void MakeUpperString(const char *source, char *target); void MakeUpperString(const char *source, char *target);
void MakeLowerString(const char *source, char *target); void MakeLowerString(const char *source, char *target);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/Mutex.h" #include "../common/Mutex.h"
@ -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

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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 MYMUTEX_H #ifndef MYMUTEX_H
#define MYMUTEX_H #define MYMUTEX_H

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "debug.h" #include "debug.h"
#include "ProcLauncher.h" #include "ProcLauncher.h"
@ -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();
@ -352,17 +352,3 @@ ProcLauncher::Spec &ProcLauncher::Spec::operator=(const Spec &other) {
return(*this); return(*this);
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 PROCLAUNCHER_H_ #ifndef PROCLAUNCHER_H_
#define PROCLAUNCHER_H_ #define PROCLAUNCHER_H_
@ -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,30 +64,23 @@ 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 background processes. */
* The main processing method. Call regularly to check for terminated
* background processes.
*/
void Process(); void Process();
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
@ -96,29 +89,5 @@ private:
#endif #endif
}; };
#endif /*PROCLAUNCHER_H_*/ #endif /*PROCLAUNCHER_H_*/

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);
} }
}; };

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);
}; };

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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
*/ */
#include "../common/debug.h" #include "../common/debug.h"
@ -47,11 +47,11 @@ InitWinsock winsock;
//client version //client version
TCPConnection::TCPConnection() TCPConnection::TCPConnection()
: ConnectionType(Outgoing), : ConnectionType(Outgoing),
connection_socket(0), connection_socket(0),
id(0), id(0),
rIP(0), rIP(0),
rPort(0) rPort(0)
{ {
pState = TCPS_Ready; pState = TCPS_Ready;
pFree = false; pFree = false;
@ -69,11 +69,11 @@ TCPConnection::TCPConnection()
//server version //server version
TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
: ConnectionType(Incomming), : ConnectionType(Incomming),
connection_socket(in_socket), connection_socket(in_socket),
id(ID), id(ID),
rIP(irIP), rIP(irIP),
rPort(irPort) rPort(irPort)
{ {
pState = TCPS_Connected; pState = TCPS_Connected;
pFree = false; pFree = false;
@ -438,8 +438,8 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
} }
connection_socket = INVALID_SOCKET; connection_socket = INVALID_SOCKET;
struct sockaddr_in server_sin; struct sockaddr_in server_sin;
// struct in_addr in; //struct in_addr in;
if ((connection_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET || connection_socket == 0) { if ((connection_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET || connection_socket == 0) {
#ifdef _WINDOWS #ifdef _WINDOWS
@ -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,18 +535,18 @@ 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)) {
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
//cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl; //cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
return false; return false;
} }
/* 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,27 +570,27 @@ 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;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl; cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
return false; return false;
} }
return true; return true;
} }
@ -621,9 +621,9 @@ bool TCPConnection::RecvData(char* errbuf) {
} }
} }
status = recv(connection_socket, (char *) &recvbuf[recvbuf_used], (recvbuf_size - recvbuf_used), 0); status = recv(connection_socket, (char *) &recvbuf[recvbuf_used], (recvbuf_size - recvbuf_used), 0);
if (status >= 1) { if (status >= 1) {
#if TCPN_LOG_RAW_DATA_IN >= 1 #if TCPN_LOG_RAW_DATA_IN >= 1
struct in_addr in; struct in_addr in;
in.s_addr = GetrIP(); in.s_addr = GetrIP();
@ -642,7 +642,7 @@ bool TCPConnection::RecvData(char* errbuf) {
recvbuf_used += status; recvbuf_used += status;
if (!ProcessReceivedData(errbuf)) if (!ProcessReceivedData(errbuf))
return false; return false;
} }
else if (status == SOCKET_ERROR) { else if (status == SOCKET_ERROR) {
#ifdef _WINDOWS #ifdef _WINDOWS
if (!(WSAGetLastError() == WSAEWOULDBLOCK)) { if (!(WSAGetLastError() == WSAEWOULDBLOCK)) {
@ -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);
} }
@ -943,7 +943,3 @@ bool TCPConnection::RunLoop() {
return ret; return ret;
} }

View File

@ -1,25 +1,25 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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 TCP_CONNECTION_H #ifndef TCP_CONNECTION_H
#define TCP_CONNECTION_H #define TCP_CONNECTION_H
/* /*
Parent classes for interserver TCP Communication. Parent classes for interserver TCP Communication.
-Quagmire -Quagmire
*/ */
#ifdef _WINDOWS #ifdef _WINDOWS
@ -28,7 +28,7 @@
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#include <process.h> #include <process.h>
#else #else
@ -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();
}; };
@ -177,5 +177,3 @@ private:
#endif #endif

View File

@ -1,5 +1,3 @@
#include "debug.h" #include "debug.h"
#include "TCPServer.h" #include "TCPServer.h"
#include <stdio.h> #include <stdio.h>
@ -18,12 +16,8 @@
#define SOCKET_ERROR -1 #define SOCKET_ERROR -1
#endif #endif
#define SERVER_LOOP_GRANULARITY 3 //# of ms between checking our socket/queues #define SERVER_LOOP_GRANULARITY 3 //# of ms between checking our socket/queues
BaseTCPServer::BaseTCPServer(uint16 in_port) { BaseTCPServer::BaseTCPServer(uint16 in_port) {
NextID = 1; NextID = 1;
pPort = in_port; pPort = in_port;
@ -70,11 +64,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 +76,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);
} }
@ -95,14 +89,14 @@ void BaseTCPServer::Process() {
} }
void BaseTCPServer::ListenNewConnections() { void BaseTCPServer::ListenNewConnections() {
SOCKET tmpsock; SOCKET tmpsock;
struct sockaddr_in from; struct sockaddr_in from;
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);
if (!sock) if (!sock)
return; return;
@ -124,7 +118,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 +145,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 +205,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
@ -230,4 +224,3 @@ bool BaseTCPServer::IsOpen() {
return ret; return ret;
} }

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;
}; };

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "debug.h" #include "debug.h"
#include "XMLParser.h" #include "XMLParser.h"
@ -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);
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 XMLParser_H #ifndef XMLParser_H
#define XMLParser_H #define XMLParser_H
@ -29,18 +29,18 @@ using namespace std;
/* /*
* See note in XMLParser::ParseFile() before inheriting this class. * See note in XMLParser::ParseFile() before inheriting this class.
*/ */
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,12 +48,9 @@ protected:
map<string,ElementHandler> Handlers; map<string,ElementHandler> Handlers;
bool ParseOkay; bool ParseOkay;
}; };
#endif #endif

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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 BODYTYPES_H #ifndef BODYTYPES_H
#define BODYTYPES_H #define BODYTYPES_H
@ -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,
// ... // ...
@ -45,7 +45,7 @@ typedef enum {
BT_Dragon = 26, BT_Dragon = 26,
BT_Summoned2 = 27, BT_Summoned2 = 27,
BT_Summoned3 = 28, BT_Summoned3 = 28,
// 29 //29
BT_VeliousDragon = 30, //might not be a tight set BT_VeliousDragon = 30, //might not be a tight set
// ... // ...
BT_Dragon3 = 32, BT_Dragon3 = 32,

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 BREAKDOWNS_H_ #ifndef BREAKDOWNS_H_
#define BREAKDOWNS_H_ #define BREAKDOWNS_H_

View File

@ -1,279 +1,279 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include "../common/classes.h" #include "../common/classes.h"
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";
case CLERICGM: case CLERICGM:
return "Cleric Guildmaster"; return "Cleric Guildmaster";
case PALADINGM: case PALADINGM:
return "Paladin Guildmaster"; return "Paladin Guildmaster";
case RANGERGM: case RANGERGM:
return "Ranger Guildmaster"; return "Ranger Guildmaster";
case SHADOWKNIGHTGM: case SHADOWKNIGHTGM:
return "Shadowknight Guildmaster"; return "Shadowknight Guildmaster";
case DRUIDGM: case DRUIDGM:
return "Druid Guildmaster"; return "Druid Guildmaster";
case MONKGM: case MONKGM:
return "Monk Guildmaster"; return "Monk Guildmaster";
case BARDGM: case BARDGM:
return "Bard Guildmaster"; return "Bard Guildmaster";
case ROGUEGM: case ROGUEGM:
return "Rogue Guildmaster"; return "Rogue Guildmaster";
case SHAMANGM: case SHAMANGM:
return "Shaman Guildmaster"; return "Shaman Guildmaster";
case NECROMANCERGM: case NECROMANCERGM:
return "Necromancer Guildmaster"; return "Necromancer Guildmaster";
case WIZARDGM: case WIZARDGM:
return "Wizard Guildmaster"; return "Wizard Guildmaster";
case MAGICIANGM: case MAGICIANGM:
return "Magician Guildmaster"; return "Magician Guildmaster";
case ENCHANTERGM: case ENCHANTERGM:
return "Enchanter Guildmaster"; return "Enchanter Guildmaster";
case BEASTLORDGM: case BEASTLORDGM:
return "Beastlord Guildmaster"; return "Beastlord Guildmaster";
case BERSERKERGM: case BERSERKERGM:
return "Berserker Guildmaster"; return "Berserker Guildmaster";
case MERCHANT: case MERCHANT:
return "Merchant"; return "Merchant";
case ADVENTURERECRUITER: case ADVENTURERECRUITER:
return "Adventure Recruiter"; return "Adventure Recruiter";
@ -285,7 +285,7 @@ const char* GetEQClassName(uint8 class_, uint8 level) {
return "Tribute Master"; return "Tribute Master";
case GUILD_TRIBUTE_MASTER: case GUILD_TRIBUTE_MASTER:
return "Guild Tribute Master"; return "Guild Tribute Master";
default: default:
return "Unknown"; return "Unknown";
} }
} }

View File

@ -1,59 +1,59 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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 CLASSES_CH #ifndef CLASSES_CH
#define CLASSES_CH #define CLASSES_CH
#include "../common/types.h" #include "../common/types.h"
#define Array_Class_UNKNOWN 0 #define Array_Class_UNKNOWN 0
#define WARRIOR 1 #define WARRIOR 1
#define CLERIC 2 #define CLERIC 2
#define PALADIN 3 #define PALADIN 3
#define RANGER 4 #define RANGER 4
#define SHADOWKNIGHT 5 #define SHADOWKNIGHT 5
#define DRUID 6 #define DRUID 6
#define MONK 7 #define MONK 7
#define BARD 8 #define BARD 8
#define ROGUE 9 #define ROGUE 9
#define SHAMAN 10 #define SHAMAN 10
#define NECROMANCER 11 #define NECROMANCER 11
#define WIZARD 12 #define WIZARD 12
#define MAGICIAN 13 #define MAGICIAN 13
#define ENCHANTER 14 #define ENCHANTER 14
#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

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
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 COMMON_PROFILE_H #ifndef COMMON_PROFILE_H
#define COMMON_PROFILE_H #define COMMON_PROFILE_H
@ -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;

View File

@ -7,107 +7,107 @@
class EQEmuStackWalker : public StackWalker 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) {
buffer[i] = '\0'; buffer[i] = '\0';
break; break;
} }
if(szText[i] == '\n' || szText[i] == '\r') { if(szText[i] == '\n' || szText[i] == '\r') {
buffer[i] = ' '; buffer[i] = ' ';
} else { } else {
buffer[i] = szText[i]; buffer[i] = szText[i];
} }
} }
LogFile->write(EQEMuLog::Crash, buffer); LogFile->write(EQEMuLog::Crash, buffer);
StackWalker::OnOutput(szText); StackWalker::OnOutput(szText);
} }
}; };
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo) LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
{ {
switch(ExceptionInfo->ExceptionRecord->ExceptionCode) switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
{ {
case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_ACCESS_VIOLATION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ACCESS_VIOLATION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_ACCESS_VIOLATION");
break; break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
break; break;
case EXCEPTION_BREAKPOINT: case EXCEPTION_BREAKPOINT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_BREAKPOINT"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_BREAKPOINT");
break; break;
case EXCEPTION_DATATYPE_MISALIGNMENT: case EXCEPTION_DATATYPE_MISALIGNMENT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
break; break;
case EXCEPTION_FLT_DENORMAL_OPERAND: case EXCEPTION_FLT_DENORMAL_OPERAND:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
break; break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO: case EXCEPTION_FLT_DIVIDE_BY_ZERO:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
break; break;
case EXCEPTION_FLT_INEXACT_RESULT: case EXCEPTION_FLT_INEXACT_RESULT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INEXACT_RESULT"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
break; break;
case EXCEPTION_FLT_INVALID_OPERATION: case EXCEPTION_FLT_INVALID_OPERATION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INVALID_OPERATION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
break; break;
case EXCEPTION_FLT_OVERFLOW: case EXCEPTION_FLT_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_OVERFLOW"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_OVERFLOW");
break; break;
case EXCEPTION_FLT_STACK_CHECK: case EXCEPTION_FLT_STACK_CHECK:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_STACK_CHECK"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_STACK_CHECK");
break; break;
case EXCEPTION_FLT_UNDERFLOW: case EXCEPTION_FLT_UNDERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_UNDERFLOW"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_UNDERFLOW");
break; break;
case EXCEPTION_ILLEGAL_INSTRUCTION: case EXCEPTION_ILLEGAL_INSTRUCTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
break; break;
case EXCEPTION_IN_PAGE_ERROR: case EXCEPTION_IN_PAGE_ERROR:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_IN_PAGE_ERROR"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_IN_PAGE_ERROR");
break; break;
case EXCEPTION_INT_DIVIDE_BY_ZERO: case EXCEPTION_INT_DIVIDE_BY_ZERO:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
break; break;
case EXCEPTION_INT_OVERFLOW: case EXCEPTION_INT_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_OVERFLOW"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_OVERFLOW");
break; break;
case EXCEPTION_INVALID_DISPOSITION: case EXCEPTION_INVALID_DISPOSITION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INVALID_DISPOSITION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_INVALID_DISPOSITION");
break; break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION: case EXCEPTION_NONCONTINUABLE_EXCEPTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
break; break;
case EXCEPTION_PRIV_INSTRUCTION: case EXCEPTION_PRIV_INSTRUCTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_PRIV_INSTRUCTION"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_PRIV_INSTRUCTION");
break; break;
case EXCEPTION_SINGLE_STEP: case EXCEPTION_SINGLE_STEP:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_SINGLE_STEP"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_SINGLE_STEP");
break; break;
case EXCEPTION_STACK_OVERFLOW: case EXCEPTION_STACK_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_STACK_OVERFLOW"); LogFile->write(EQEMuLog::Crash, "EXCEPTION_STACK_OVERFLOW");
break; break;
default: default:
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;
} }
void set_exception_handler() { void set_exception_handler() {
SetUnhandledExceptionFilter(windows_exception_handler); SetUnhandledExceptionFilter(windows_exception_handler);
} }
#else #else
// crash is off or an unhandled platform // crash is off or an unhandled platform

View File

@ -84,21 +84,21 @@ uint32 CRC32::GenerateNoFlip(const uint8* buf, uint32 bufsize) {
void CRC32::SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at) 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];
data = data ^ (check); data = data ^ (check);
data = data & 0x000000ff; data = data & 0x000000ff;
check = check >> 8; check = check >> 8;
data = CRC32Table[data]; data = CRC32Table[data];
check = check ^ data; check = check ^ data;
} }
memcpy(in_data, (char*)&check, 4); memcpy(in_data, (char*)&check, 4);
} }
uint32 CRC32::Update(const uint8* buf, uint32 bufsize, uint32 crc32var) { uint32 CRC32::Update(const uint8* buf, uint32 bufsize, uint32 crc32var) {

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);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
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 EQEMU_DATABASE_H #ifndef EQEMU_DATABASE_H
#define EQEMU_DATABASE_H #define EQEMU_DATABASE_H
@ -76,10 +76,10 @@ 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
// It will always put the LAST time for the level (I think) from the Database // It will always put the LAST time for the level (I think) from the Database
struct npcDecayTimes_Struct { struct npcDecayTimes_Struct {
uint16 minlvl; uint16 minlvl;
@ -106,10 +106,10 @@ 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
*/ */
bool MoveCharacterToZone(const char* charname, const char* zonename); bool MoveCharacterToZone(const char* charname, const char* zonename);
bool MoveCharacterToZone(const char* charname, const char* zonename,uint32 zoneid); bool MoveCharacterToZone(const char* charname, const char* zonename,uint32 zoneid);
bool MoveCharacterToZone(uint32 iCharID, const char* iZonename); bool MoveCharacterToZone(uint32 iCharID, const char* iZonename);
@ -124,8 +124,8 @@ public:
uint8 CopyCharacter(const char* oldname, const char* newname, uint32 acctid); uint8 CopyCharacter(const char* oldname, const char* newname, uint32 acctid);
/* /*
* General Information Getting Queries * General Information Getting Queries
*/ */
bool CheckNameFilter(const char* name, bool surname = false); bool CheckNameFilter(const char* name, bool surname = false);
bool CheckUsedName(const char* name); bool CheckUsedName(const char* name);
uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0); uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0);
@ -136,15 +136,15 @@ public:
void GetCharName(uint32 char_id, char* name); void GetCharName(uint32 char_id, char* name);
uint32 GetCharacterInfo(const char* iName, uint32* oAccID = 0, uint32* oZoneID = 0, uint32* oInstanceID = 0,float* oX = 0, float* oY = 0, float* oZ = 0); uint32 GetCharacterInfo(const char* iName, uint32* oAccID = 0, uint32* oZoneID = 0, uint32* oInstanceID = 0,float* oX = 0, float* oY = 0, float* oZ = 0);
uint32 GetCharacterID(const char *name); uint32 GetCharacterID(const char *name);
bool CheckBannedIPs(const char* loginIP); //Lieka Edit: Check incomming connection against banned IP table. bool CheckBannedIPs(const char* loginIP); //Lieka Edit: Check incomming connection against banned IP table.
bool AddBannedIP(char* bannedIP, const char* notes); //Lieka Edit: Add IP address to the Banned_IPs table. bool AddBannedIP(char* bannedIP, const char* notes); //Lieka Edit: Add IP address to the Banned_IPs table.
bool CheckGMIPs(const char* loginIP, uint32 account_id); bool CheckGMIPs(const char* loginIP, uint32 account_id);
bool AddGMIP(char* ip_address, char* name); bool AddGMIP(char* ip_address, char* name);
void LoginIP(uint32 AccountID, const char* LoginIP); void LoginIP(uint32 AccountID, const char* LoginIP);
/* /*
* Instancing Stuff * Instancing Stuff
*/ */
bool VerifyZoneInstance(uint32 zone_id, uint16 instance_id); bool VerifyZoneInstance(uint32 zone_id, uint16 instance_id);
bool VerifyInstanceAlive(uint16 instance_id, uint32 char_id); bool VerifyInstanceAlive(uint16 instance_id, uint32 char_id);
bool CharacterInInstanceGroup(uint16 instance_id, uint32 char_id); bool CharacterInInstanceGroup(uint16 instance_id, uint32 char_id);
@ -172,68 +172,68 @@ public:
bool GlobalInstance(uint16 instance_id); bool GlobalInstance(uint16 instance_id);
/* /*
* 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);
/* /*
* Account Related * Account Related
*/ */
uint32 GetMiniLoginAccount(char* ip); uint32 GetMiniLoginAccount(char* ip);
void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus); void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus);
uint32 CheckLogin(const char* name, const char* password, int16* oStatus = 0); uint32 CheckLogin(const char* name, const char* password, int16* oStatus = 0);
int16 CheckStatus(uint32 account_id); int16 CheckStatus(uint32 account_id);
uint32 CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id = 0); uint32 CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id = 0);
bool DeleteAccount(const char* name); bool DeleteAccount(const char* name);
bool SetAccountStatus(const char* name, int16 status); bool SetAccountStatus(const char* name, int16 status);
bool SetLocalPassword(uint32 accid, const char* password); bool SetLocalPassword(uint32 accid, const char* password);
uint32 GetAccountIDFromLSID(uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0); uint32 GetAccountIDFromLSID(uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0);
bool UpdateLiveChar(char* charname,uint32 lsaccount_id); bool UpdateLiveChar(char* charname,uint32 lsaccount_id);
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
*/ */
uint32 GetGroupID(const char* name); uint32 GetGroupID(const char* name);
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);
void ClearGroupLeader(uint32 gid = 0); void ClearGroupLeader(uint32 gid = 0);
/* /*
* Raids * Raids
*/ */
void ClearRaid(uint32 rid = 0); void ClearRaid(uint32 rid = 0);
void ClearRaidDetails(uint32 rid = 0); void ClearRaidDetails(uint32 rid = 0);
uint32 GetRaidID(const char* name); uint32 GetRaidID(const char* name);
const char *GetRaidLeaderName(uint32 rid); const char *GetRaidLeaderName(uint32 rid);
/* /*
* Database Varaibles * Database Varaibles
*/ */
bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len); bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len);
bool SetVariable(const char* varname, const char* varvalue); bool SetVariable(const char* varname, const char* varvalue);
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
*/ */
bool LoadZoneNames(); bool LoadZoneNames();
bool GetZoneLongName(const char* short_name, char** long_name, char* file_name = 0, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, uint32* graveyard_id = 0, uint32* maxclients = 0); bool GetZoneLongName(const char* short_name, char** long_name, char* file_name = 0, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, uint32* graveyard_id = 0, uint32* maxclients = 0);
bool GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid = 0, float* graveyard_x = 0, float* graveyard_y = 0, float* graveyard_z = 0, float* graveyard_heading = 0); bool GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid = 0, float* graveyard_x = 0, float* graveyard_y = 0, float* graveyard_z = 0, float* graveyard_heading = 0);
uint32 GetZoneGraveyardID(uint32 zone_id, uint32 version); uint32 GetZoneGraveyardID(uint32 zone_id, uint32 version);
uint32 GetZoneID(const char* zonename); uint32 GetZoneID(const char* zonename);
uint8 GetPEQZone(uint32 zoneID, uint32 version); uint8 GetPEQZone(uint32 zoneID, uint32 version);
const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false); const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false);
uint8 GetServerType(); uint8 GetServerType();
bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr); bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr);
@ -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;

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(...){
} }
} }

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);

View File

@ -38,7 +38,7 @@ DBcore::DBcore() {
pDatabase = 0; pDatabase = 0;
pCompress = false; pCompress = false;
pSSL = false; pSSL = false;
pStatus = Closed; pStatus = Closed;
} }
DBcore::~DBcore() { DBcore::~DBcore() {
@ -184,13 +184,13 @@ bool DBcore::Open(uint32* errnum, char* errbuf) {
if (GetStatus() == Error) { if (GetStatus() == Error) {
mysql_close(&mysql); mysql_close(&mysql);
mysql_init(&mysql); // Initialize structure again mysql_init(&mysql); // Initialize structure again
} }
if (!pHost) if (!pHost)
return false; return false;
/* /*
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)

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:

View File

@ -1,12 +1,10 @@
// Doors // Doors
#ifdef SHAREMEM #ifdef SHAREMEM
int32 Database::GetDoorsCount(uint32* oMaxID) { int32 Database::GetDoorsCount(uint32* oMaxID) {
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;
query = new char[256]; query = new char[256];
strcpy(query, "SELECT MAX(id), count(*) FROM doors"); strcpy(query, "SELECT MAX(id), count(*) FROM doors");
if (RunQuery(query, strlen(query), errbuf, &result)) { if (RunQuery(query, strlen(query), errbuf, &result)) {
@ -29,7 +27,7 @@ int32 Database::GetDoorsCount(uint32* oMaxID) {
delete[] query; delete[] query;
return -1; return -1;
} }
return -1; return -1;
} }
@ -65,9 +63,9 @@ bool Database::LoadDoors() {
bool Database::DBLoadDoors(uint32 iDoorCount, uint32 iMaxDoorID) { bool Database::DBLoadDoors(uint32 iDoorCount, uint32 iMaxDoorID) {
cout << "Loading Doors from database..." << endl; cout << "Loading Doors from database..." << endl;
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;
query = new char[256]; query = new char[256];
strcpy(query, "SELECT MAX(id), Count(*) FROM doors"); strcpy(query, "SELECT MAX(id), Count(*) FROM doors");
if (RunQuery(query, strlen(query), errbuf, &result)) if (RunQuery(query, strlen(query), errbuf, &result))

View File

@ -12,7 +12,7 @@ using namespace std;
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -75,34 +75,34 @@ EQEMuLog::~EQEMuLog() {
bool EQEMuLog::open(LogIDs id) { bool EQEMuLog::open(LogIDs id) {
if (!logFileValid) { if (!logFileValid) {
return false; return false;
} }
if (id >= MaxLogID) { if (id >= MaxLogID) {
return false; return false;
} }
LockMutex lock(&MOpen); LockMutex lock(&MOpen);
if (pLogStatus[id] & 4) { if (pLogStatus[id] & 4) {
return false; return false;
} }
if (fp[id]) { if (fp[id]) {
//cerr<<"Warning: LogFile already open"<<endl; //cerr<<"Warning: LogFile already open"<<endl;
return true; return true;
} }
char exename[200] = ""; char exename[200] = "";
const EQEmuExePlatform &platform = GetExecutablePlatform(); const EQEmuExePlatform &platform = GetExecutablePlatform();
if(platform == ExePlatformWorld) { if(platform == ExePlatformWorld) {
snprintf(exename, sizeof(exename), "_world"); snprintf(exename, sizeof(exename), "_world");
} else if(platform == ExePlatformZone) { } else if(platform == ExePlatformZone) {
snprintf(exename, sizeof(exename), "_zone"); snprintf(exename, sizeof(exename), "_zone");
} else if(platform == ExePlatformLaunch) { } else if(platform == ExePlatformLaunch) {
snprintf(exename, sizeof(exename), "_launch"); snprintf(exename, sizeof(exename), "_launch");
} else if(platform == ExePlatformUCS) { } else if(platform == ExePlatformUCS) {
snprintf(exename, sizeof(exename), "_ucs"); snprintf(exename, sizeof(exename), "_ucs");
} else if(platform == ExePlatformQueryServ) { } else if(platform == ExePlatformQueryServ) {
snprintf(exename, sizeof(exename), "_queryserv"); snprintf(exename, sizeof(exename), "_queryserv");
} else if(platform == ExePlatformSharedMemory) { } else if(platform == ExePlatformSharedMemory) {
snprintf(exename, sizeof(exename), "_shared_memory"); snprintf(exename, sizeof(exename), "_shared_memory");
} }
char filename[200]; char filename[200];
#ifndef NO_PIDLOG #ifndef NO_PIDLOG
@ -110,24 +110,24 @@ bool EQEMuLog::open(LogIDs id) {
#else #else
snprintf(filename, sizeof(filename), "%s%s.log", FileNames[id], exename); snprintf(filename, sizeof(filename), "%s%s.log", FileNames[id], exename);
#endif #endif
fp[id] = fopen(filename, "a"); fp[id] = fopen(filename, "a");
if (!fp[id]) { if (!fp[id]) {
cerr << "Failed to open log file: " << filename << endl; cerr << "Failed to open log file: " << filename << endl;
pLogStatus[id] |= 4; // set file state to error pLogStatus[id] |= 4; // set file state to error
return false; return false;
} }
fputs("---------------------------------------------\n",fp[id]); fputs("---------------------------------------------\n",fp[id]);
write(id, "Starting Log: %s", filename); write(id, "Starting Log: %s", filename);
return true; return true;
} }
bool EQEMuLog::write(LogIDs id, const char *fmt, ...) { bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
if (!logFileValid) { if (!logFileValid) {
return false; return false;
} }
if (id >= MaxLogID) { if (id >= MaxLogID) {
return false; return false;
} }
bool dofile = false; bool dofile = false;
if (pLogStatus[id] & 1) { if (pLogStatus[id] & 1) {
dofile = open(id); dofile = open(id);
@ -138,13 +138,13 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
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)
time_t aclock; time_t aclock;
struct tm *newtime; struct tm *newtime;
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
if (dofile) time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
if (dofile)
#ifndef NO_PIDLOG #ifndef NO_PIDLOG
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec); fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
#else #else
@ -162,7 +162,7 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
va_copy(tmpargptr, argptr); va_copy(tmpargptr, argptr);
p(id, fmt, tmpargptr ); p(id, fmt, tmpargptr );
} }
if (pLogStatus[id] & 2) { if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) { if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] ", LogNames[id]); fprintf(stderr, "[%s] ", LogNames[id]);
vfprintf( stderr, fmt, argptr ); vfprintf( stderr, fmt, argptr );
@ -173,9 +173,9 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
} }
} }
va_end(argptr); va_end(argptr);
if (dofile) if (dofile)
fprintf(fp[id], "\n"); fprintf(fp[id], "\n");
if (pLogStatus[id] & 2) { if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) { if (pLogStatus[id] & 8) {
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fflush(stderr); fflush(stderr);
@ -184,19 +184,19 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
fflush(stdout); fflush(stdout);
} }
} }
if(dofile) if(dofile)
fflush(fp[id]); fflush(fp[id]);
return true; return true;
} }
//write with Prefix and a VA_list //write with Prefix and a VA_list
bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list argptr) { bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list argptr) {
if (!logFileValid) { if (!logFileValid) {
return false; return false;
} }
if (id >= MaxLogID) { if (id >= MaxLogID) {
return false; return false;
} }
bool dofile = false; bool dofile = false;
if (pLogStatus[id] & 1) { if (pLogStatus[id] & 1) {
dofile = open(id); dofile = open(id);
@ -208,15 +208,15 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
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)
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 */
va_list tmpargptr; va_list tmpargptr;
if (dofile) { if (dofile) {
#ifndef NO_PIDLOG #ifndef NO_PIDLOG
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] %s", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix); fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] %s", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
#else #else
@ -224,13 +224,13 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
#endif #endif
va_copy(tmpargptr, argptr); va_copy(tmpargptr, argptr);
vfprintf( fp[id], fmt, tmpargptr ); vfprintf( fp[id], fmt, tmpargptr );
} }
if(logCallbackPva[id]) { if(logCallbackPva[id]) {
msgCallbackPva p = logCallbackPva[id]; msgCallbackPva p = logCallbackPva[id];
va_copy(tmpargptr, argptr); va_copy(tmpargptr, argptr);
p(id, prefix, fmt, tmpargptr ); p(id, prefix, fmt, tmpargptr );
} }
if (pLogStatus[id] & 2) { if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) { if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] %s", LogNames[id], prefix); fprintf(stderr, "[%s] %s", LogNames[id], prefix);
vfprintf( stderr, fmt, argptr ); vfprintf( stderr, fmt, argptr );
@ -241,26 +241,26 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
} }
} }
va_end(argptr); va_end(argptr);
if (dofile) if (dofile)
fprintf(fp[id], "\n"); fprintf(fp[id], "\n");
if (pLogStatus[id] & 2) { if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) if (pLogStatus[id] & 8)
fprintf(stderr, "\n"); fprintf(stderr, "\n");
else else
fprintf(stdout, "\n"); fprintf(stdout, "\n");
} }
if(dofile) if(dofile)
fflush(fp[id]); fflush(fp[id]);
return true; return true;
} }
bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) { bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
if (!logFileValid) { if (!logFileValid) {
return false; return false;
} }
if (id >= MaxLogID) { if (id >= MaxLogID) {
return false; return false;
} }
bool dofile = false; bool dofile = false;
if (pLogStatus[id] & 1) { if (pLogStatus[id] & 1) {
dofile = open(id); dofile = open(id);
@ -271,13 +271,13 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
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)
time_t aclock; time_t aclock;
struct tm *newtime; struct tm *newtime;
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
if (dofile) time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
if (dofile)
#ifndef NO_PIDLOG #ifndef NO_PIDLOG
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec); fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
#else #else
@ -292,7 +292,7 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
msgCallbackBuf p = logCallbackBuf[id]; msgCallbackBuf p = logCallbackBuf[id];
p(id, buf, size, count); p(id, buf, size, count);
} }
if (pLogStatus[id] & 2) { if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) { if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] ", LogNames[id]); fprintf(stderr, "[%s] ", LogNames[id]);
fwrite(buf, size, count, stderr); fwrite(buf, size, count, stderr);
@ -303,9 +303,9 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
fprintf(stdout, "\n"); fprintf(stdout, "\n");
} }
} }
if(dofile) if(dofile)
fflush(fp[id]); fflush(fp[id]);
return true; return true;
} }
bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) { bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
@ -315,23 +315,23 @@ bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
va_copy(tmpargptr, argptr); va_copy(tmpargptr, argptr);
vfprintf( fp[id], fmt, tmpargptr ); vfprintf( fp[id], fmt, tmpargptr );
} }
if (pLogStatus[id] & 2) { if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) if (pLogStatus[id] & 8)
vfprintf( stderr, fmt, argptr ); vfprintf( stderr, fmt, argptr );
else else
vfprintf( stdout, fmt, argptr ); vfprintf( stdout, fmt, argptr );
} }
va_end(argptr); va_end(argptr);
return true; return true;
}; };
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) { bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
if (!logFileValid) { if (!logFileValid) {
#if EQDEBUG >= 10 #if EQDEBUG >= 10
cerr << "Error: Dump() from null pointer"<<endl; cerr << "Error: Dump() from null pointer"<<endl;
#endif #endif
return false; return false;
} }
if (size == 0) if (size == 0)
return true; return true;
if (!LogFile) if (!LogFile)
@ -347,12 +347,12 @@ 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);
uint32 i; uint32 i;
for(i=skip; i<size; i++) { for(i=skip; i<size; i++) {
if ((i-skip)%cols==0) { if ((i-skip)%cols==0) {
if (i != skip) if (i != skip)
writeNTS(id, dofile, " | %s\n", ascii); writeNTS(id, dofile, " | %s\n", ascii);
@ -369,7 +369,7 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
ascii[j++] = data[i]; ascii[j++] = data[i];
else else
ascii[j++] = '.'; ascii[j++] = '.';
} }
uint32 k = ((i-skip)-1)%cols; uint32 k = ((i-skip)-1)%cols;
if (k < 8) if (k < 8)
writeNTS(id, dofile, " "); writeNTS(id, dofile, " ");
@ -382,14 +382,14 @@ 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;
if (id >= MaxLogID) { if (id >= MaxLogID) {
return; return;
} }
logCallbackFmt[id] = proc; logCallbackFmt[id] = proc;
} }
void EQEMuLog::SetCallback(LogIDs id, msgCallbackBuf proc) { void EQEMuLog::SetCallback(LogIDs id, msgCallbackBuf proc) {
@ -397,8 +397,8 @@ void EQEMuLog::SetCallback(LogIDs id, msgCallbackBuf proc) {
return; return;
if (id >= MaxLogID) { if (id >= MaxLogID) {
return; return;
} }
logCallbackBuf[id] = proc; logCallbackBuf[id] = proc;
} }
void EQEMuLog::SetCallback(LogIDs id, msgCallbackPva proc) { void EQEMuLog::SetCallback(LogIDs id, msgCallbackPva proc) {
@ -406,8 +406,8 @@ void EQEMuLog::SetCallback(LogIDs id, msgCallbackPva proc) {
return; return;
if (id >= MaxLogID) { if (id >= MaxLogID) {
return; return;
} }
logCallbackPva[id] = proc; logCallbackPva[id] = proc;
} }
void EQEMuLog::SetAllCallbacks(msgCallbackFmt proc) { void EQEMuLog::SetAllCallbacks(msgCallbackFmt proc) {
@ -437,5 +437,3 @@ void EQEMuLog::SetAllCallbacks(msgCallbackPva proc) {
} }
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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
*/ */
// Debug Levels // Debug Levels
@ -23,11 +23,11 @@
////// File/Console options ////// File/Console options
// 0 <= Quiet mode Errors to file Status and Normal ignored // 0 <= Quiet mode Errors to file Status and Normal ignored
// 1 >= Status and Normal to console, Errors to file // 1 >= Status and Normal to console, Errors to file
// 2 >= Status, Normal, and Error to console and logfile // 2 >= Status, Normal, and Error to console and logfile
// 3 >= Lite debug // 3 >= Lite debug
// 4 >= Medium debug // 4 >= Medium debug
// 5 >= Debug release (Anything higher is not recommended for regular use) // 5 >= Debug release (Anything higher is not recommended for regular use)
// 6 == (Reserved for special builds) Login opcode debug All packets dumped // 6 == (Reserved for special builds) Login opcode debug All packets dumped
// 7 == (Reserved for special builds) Chat Opcode debug All packets dumped // 7 == (Reserved for special builds) Chat Opcode debug All packets dumped
// 8 == (Reserved for special builds) World opcode debug All packets dumped // 8 == (Reserved for special builds) World opcode debug All packets dumped
// 9 == (Reserved for special builds) Zone Opcode debug All packets dumped // 9 == (Reserved for special builds) Zone Opcode debug All packets dumped
@ -103,22 +103,22 @@ public:
Debug, Debug,
Quest, Quest,
Commands, Commands,
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];

View File

@ -1,24 +1,24 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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 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

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
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 04111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
*/ */
#include "debug.h" #include "debug.h"
@ -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
"" ""
}; };

View File

@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
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
@ -9,11 +9,11 @@ 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 04111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
*/ */
#ifndef EMU_OPCODES_H #ifndef EMU_OPCODES_H
#define EMU_OPCODES_H #define EMU_OPCODES_H
@ -49,5 +49,3 @@ extern const char *OpcodeNames[_maxEmuOpcode+1];
#endif #endif

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),

View File

@ -1,22 +1,22 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
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 EQ_CONSTANTS_H #ifndef EQ_CONSTANTS_H
#define EQ_CONSTANTS_H #define EQ_CONSTANTS_H
#include "skills.h" #include "skills.h"
@ -53,49 +53,49 @@ enum ItemClass
*/ */
enum ItemTypes enum ItemTypes
{ {
ItemType1HS = 0, ItemType1HS = 0,
ItemType2HS = 1, ItemType2HS = 1,
ItemTypePierce = 2, ItemTypePierce = 2,
ItemType1HB = 3, ItemType1HB = 3,
ItemType2HB = 4, ItemType2HB = 4,
ItemTypeBow = 5, ItemTypeBow = 5,
//6 //6
ItemTypeThrowing = 7, ItemTypeThrowing = 7,
ItemTypeShield = 8, ItemTypeShield = 8,
//9 //9
ItemTypeArmor = 10, ItemTypeArmor = 10,
ItemTypeUnknon = 11, //A lot of random crap has this item use. ItemTypeUnknon = 11, //A lot of random crap has this item use.
ItemTypeLockPick = 12, ItemTypeLockPick = 12,
ItemTypeFood = 14, ItemTypeFood = 14,
ItemTypeDrink = 15, ItemTypeDrink = 15,
ItemTypeLightSource = 16, ItemTypeLightSource = 16,
ItemTypeStackable = 17, //Not all stackable items are this use... ItemTypeStackable = 17, //Not all stackable items are this use...
ItemTypeBandage = 18, ItemTypeBandage = 18,
ItemTypeThrowingv2 = 19, ItemTypeThrowingv2 = 19,
ItemTypeSpell = 20, //spells and tomes ItemTypeSpell = 20, //spells and tomes
ItemTypePotion = 21, ItemTypePotion = 21,
ItemTypeWindInstr = 23, ItemTypeWindInstr = 23,
ItemTypeStringInstr = 24, ItemTypeStringInstr = 24,
ItemTypeBrassInstr = 25, ItemTypeBrassInstr = 25,
ItemTypeDrumInstr = 26, ItemTypeDrumInstr = 26,
ItemTypeArrow = 27, ItemTypeArrow = 27,
ItemTypeJewlery = 29, ItemTypeJewlery = 29,
ItemTypeSkull = 30, ItemTypeSkull = 30,
ItemTypeTome = 31, ItemTypeTome = 31,
ItemTypeNote = 32, ItemTypeNote = 32,
ItemTypeKey = 33, ItemTypeKey = 33,
ItemTypeCoin = 34, ItemTypeCoin = 34,
ItemType2HPierce = 35, ItemType2HPierce = 35,
ItemTypeFishingPole = 36, ItemTypeFishingPole = 36,
ItemTypeFishingBait = 37, ItemTypeFishingBait = 37,
ItemTypeAlcohol = 38, ItemTypeAlcohol = 38,
ItemTypeCompass = 40, ItemTypeCompass = 40,
ItemTypePoison = 42, //might be wrong, but includes poisons ItemTypePoison = 42, //might be wrong, but includes poisons
ItemTypeHand2Hand = 45, ItemTypeHand2Hand = 45,
ItemUseSinging = 50, ItemUseSinging = 50,
ItemUseAllInstruments = 51, ItemUseAllInstruments = 51,
ItemTypeCharm = 52, ItemTypeCharm = 52,
ItemTypeAugment = 54, ItemTypeAugment = 54,
ItemTypeAugmentSolvent = 55, ItemTypeAugmentSolvent = 55,
ItemTypeAugmentDistill = 56 ItemTypeAugmentDistill = 56
}; };
@ -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
@ -284,84 +284,84 @@ typedef enum {
//from showeq //from showeq
enum ChatColor enum ChatColor
{ {
CC_Default = 0, CC_Default = 0,
CC_DarkGrey = 1, CC_DarkGrey = 1,
CC_DarkGreen = 2, CC_DarkGreen = 2,
CC_DarkBlue = 3, CC_DarkBlue = 3,
CC_Purple = 5, CC_Purple = 5,
CC_LightGrey = 6, CC_LightGrey = 6,
CC_User_Say = 256, CC_User_Say = 256,
CC_User_Tell = 257, CC_User_Tell = 257,
CC_User_Group = 258, CC_User_Group = 258,
CC_User_Guild = 259, CC_User_Guild = 259,
CC_User_OOC = 260, CC_User_OOC = 260,
CC_User_Auction = 261, CC_User_Auction = 261,
CC_User_Shout = 262, CC_User_Shout = 262,
CC_User_Emote = 263, CC_User_Emote = 263,
CC_User_Spells = 264, CC_User_Spells = 264,
CC_User_YouHitOther = 265, CC_User_YouHitOther = 265,
CC_User_OtherHitYou = 266, CC_User_OtherHitYou = 266,
CC_User_YouMissOther = 267, CC_User_YouMissOther = 267,
CC_User_OtherMissYou = 268, CC_User_OtherMissYou = 268,
CC_User_Duels = 269, CC_User_Duels = 269,
CC_User_Skills = 270, CC_User_Skills = 270,
CC_User_Disciplines = 271, CC_User_Disciplines = 271,
CC_User_Default = 273, CC_User_Default = 273,
CC_User_MerchantOffer = 275, CC_User_MerchantOffer = 275,
CC_User_MerchantExchange = 276, CC_User_MerchantExchange = 276,
CC_User_YourDeath = 277, CC_User_YourDeath = 277,
CC_User_OtherDeath = 278, CC_User_OtherDeath = 278,
CC_User_OtherHitOther = 279, CC_User_OtherHitOther = 279,
CC_User_OtherMissOther = 280, CC_User_OtherMissOther = 280,
CC_User_Who = 281, CC_User_Who = 281,
CC_User_Yell = 282, CC_User_Yell = 282,
CC_User_NonMelee = 283, CC_User_NonMelee = 283,
CC_User_SpellWornOff = 284, CC_User_SpellWornOff = 284,
CC_User_MoneySplit = 285, CC_User_MoneySplit = 285,
CC_User_Loot = 286, CC_User_Loot = 286,
CC_User_Random = 287, CC_User_Random = 287,
CC_User_OtherSpells = 288, CC_User_OtherSpells = 288,
CC_User_SpellFailure = 289, CC_User_SpellFailure = 289,
CC_User_ChatChannel = 290, CC_User_ChatChannel = 290,
CC_User_Chat1 = 291, CC_User_Chat1 = 291,
CC_User_Chat2 = 292, CC_User_Chat2 = 292,
CC_User_Chat3 = 293, CC_User_Chat3 = 293,
CC_User_Chat4 = 294, CC_User_Chat4 = 294,
CC_User_Chat5 = 295, CC_User_Chat5 = 295,
CC_User_Chat6 = 296, CC_User_Chat6 = 296,
CC_User_Chat7 = 297, CC_User_Chat7 = 297,
CC_User_Chat8 = 298, CC_User_Chat8 = 298,
CC_User_Chat9 = 299, CC_User_Chat9 = 299,
CC_User_Chat10 = 300, CC_User_Chat10 = 300,
CC_User_MeleeCrit = 301, CC_User_MeleeCrit = 301,
CC_User_SpellCrit = 302, CC_User_SpellCrit = 302,
CC_User_TooFarAway = 303, CC_User_TooFarAway = 303,
CC_User_NPCRampage = 304, CC_User_NPCRampage = 304,
CC_User_NPCFurry = 305, CC_User_NPCFurry = 305,
CC_User_NPCEnrage = 306, CC_User_NPCEnrage = 306,
CC_User_EchoSay = 307, CC_User_EchoSay = 307,
CC_User_EchoTell = 308, CC_User_EchoTell = 308,
CC_User_EchoGroup = 309, CC_User_EchoGroup = 309,
CC_User_EchoGuild = 310, CC_User_EchoGuild = 310,
CC_User_EchoOOC = 311, CC_User_EchoOOC = 311,
CC_User_EchoAuction = 312, CC_User_EchoAuction = 312,
CC_User_EchoShout = 313, CC_User_EchoShout = 313,
CC_User_EchoEmote = 314, CC_User_EchoEmote = 314,
CC_User_EchoChat1 = 315, CC_User_EchoChat1 = 315,
CC_User_EchoChat2 = 316, CC_User_EchoChat2 = 316,
CC_User_EchoChat3 = 317, CC_User_EchoChat3 = 317,
CC_User_EchoChat4 = 318, CC_User_EchoChat4 = 318,
CC_User_EchoChat5 = 319, CC_User_EchoChat5 = 319,
CC_User_EchoChat6 = 320, CC_User_EchoChat6 = 320,
CC_User_EchoChat7 = 321, CC_User_EchoChat7 = 321,
CC_User_EchoChat8 = 322, CC_User_EchoChat8 = 322,
CC_User_EchoChat9 = 323, CC_User_EchoChat9 = 323,
CC_User_EchoChat10 = 324, CC_User_EchoChat10 = 324,
CC_User_UnusedAtThisTime = 325, CC_User_UnusedAtThisTime = 325,
CC_User_ItemTags = 326, CC_User_ItemTags = 326,
CC_User_RaidSay = 327, CC_User_RaidSay = 327,
CC_User_MyPet = 328, CC_User_MyPet = 328,
CC_User_DamageShield = 329, CC_User_DamageShield = 329,
}; };
//ZoneChange_Struct->success values //ZoneChange_Struct->success values
@ -435,41 +435,41 @@ 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,
RecastTimer1,
WeaponHealClickTimer, // 2
MuramiteBaneNukeClickTimer, // 3
RecastTimer4,
DispellClickTimer, // 5 (also click heal orbs?)
EpicTimer, // 6
OoWBPClickTimer, // 7
VishQuestClassItemTimer, // 8
HealPotionTimer, // 9
RecastTimer10,
RecastTimer11,
RecastTimer12,
RecastTimer13,
RecastTimer14,
RecastTimer15,
RecastTimer16,
RecastTimer17,
RecastTimer18,
ModRodTimer // 19
};
enum GroupUpdateAction
{ {
GUA_Joined = 0, RecastTimer0 = 0,
GUA_Left = 1, RecastTimer1,
GUA_LastLeft = 6, WeaponHealClickTimer, // 2
GUA_FullGroupInfo = 7, MuramiteBaneNukeClickTimer, // 3
GUA_MakeLeader = 8, RecastTimer4,
GUA_Started = 9 DispellClickTimer, // 5 (also click heal orbs?)
EpicTimer, // 6
OoWBPClickTimer, // 7
VishQuestClassItemTimer, // 8
HealPotionTimer, // 9
RecastTimer10,
RecastTimer11,
RecastTimer12,
RecastTimer13,
RecastTimer14,
RecastTimer15,
RecastTimer16,
RecastTimer17,
RecastTimer18,
ModRodTimer // 19
};
enum GroupUpdateAction
{
GUA_Joined = 0,
GUA_Left = 1,
GUA_LastLeft = 6,
GUA_FullGroupInfo = 7,
GUA_MakeLeader = 8,
GUA_Started = 9
}; };
//0x1c is something... //0x1c is something...
@ -479,81 +479,81 @@ static const uint8 DamageTypeUnknown = 0xFF;
//indexed by 'SkillType' //indexed by 'SkillType'
static const uint8 SkillDamageTypes[HIGHEST_SKILL+1] = { static const uint8 SkillDamageTypes[HIGHEST_SKILL+1] = {
/* _1H_BLUNT */ 0, /* _1H_BLUNT */ 0,
/* _1H_SLASHING */ 1, /* _1H_SLASHING */ 1,
/* _2H_BLUNT */ 0, /* _2H_BLUNT */ 0,
/* _2H_SLASHING */ 1, /* _2H_SLASHING */ 1,
/* ABJURE */ SpellDamageType, /* ABJURE */ SpellDamageType,
/* ALTERATION */ SpellDamageType, /* ALTERATION */ SpellDamageType,
/* APPLY_POISON */ DamageTypeUnknown, /* APPLY_POISON */ DamageTypeUnknown,
/* ARCHERY */ 7, /* ARCHERY */ 7,
/* BACKSTAB */ 8, /* BACKSTAB */ 8,
/* BIND_WOUND */ DamageTypeUnknown, /* BIND_WOUND */ DamageTypeUnknown,
/* BASH */ 10, /* BASH */ 10,
/* BLOCKSKILL */ DamageTypeUnknown, /* BLOCKSKILL */ DamageTypeUnknown,
/* BRASS_INSTRUMENTS */ SpellDamageType, /* BRASS_INSTRUMENTS */ SpellDamageType,
/* CHANNELING */ DamageTypeUnknown, /* CHANNELING */ DamageTypeUnknown,
/* CONJURATION */ SpellDamageType, /* CONJURATION */ SpellDamageType,
/* DEFENSE */ DamageTypeUnknown, /* DEFENSE */ DamageTypeUnknown,
/* DISARM */ DamageTypeUnknown, /* DISARM */ DamageTypeUnknown,
/* DISARM_TRAPS */ DamageTypeUnknown, /* DISARM_TRAPS */ DamageTypeUnknown,
/* DIVINATION */ SpellDamageType, /* DIVINATION */ SpellDamageType,
/* DODGE */ DamageTypeUnknown, /* DODGE */ DamageTypeUnknown,
/* DOUBLE_ATTACK */ DamageTypeUnknown, /* DOUBLE_ATTACK */ DamageTypeUnknown,
/* DRAGON_PUNCH */ 21, /* DRAGON_PUNCH */ 21,
/* DUAL_WIELD */ DamageTypeUnknown, /* DUAL_WIELD */ DamageTypeUnknown,
/* EAGLE_STRIKE */ 23, /* EAGLE_STRIKE */ 23,
/* EVOCATION */ SpellDamageType, /* EVOCATION */ SpellDamageType,
/* FEIGN_DEATH */ 4, /* FEIGN_DEATH */ 4,
/* FLYING_KICK */ 30, /* FLYING_KICK */ 30,
/* FORAGE */ DamageTypeUnknown, /* FORAGE */ DamageTypeUnknown,
/* HAND_TO_HAND */ 4, /* HAND_TO_HAND */ 4,
/* HIDE */ DamageTypeUnknown, /* HIDE */ DamageTypeUnknown,
/* KICK */ 30, /* KICK */ 30,
/* MEDITATE */ DamageTypeUnknown, /* MEDITATE */ DamageTypeUnknown,
/* MEND */ DamageTypeUnknown, /* MEND */ DamageTypeUnknown,
/* OFFENSE */ DamageTypeUnknown, /* OFFENSE */ DamageTypeUnknown,
/* PARRY */ DamageTypeUnknown, /* PARRY */ DamageTypeUnknown,
/* PICK_LOCK */ DamageTypeUnknown, /* PICK_LOCK */ DamageTypeUnknown,
/* PIERCING */ 36, /* PIERCING */ 36,
/* RIPOSTE */ DamageTypeUnknown, /* RIPOSTE */ DamageTypeUnknown,
/* ROUND_KICK */ 30, /* ROUND_KICK */ 30,
/* SAFE_FALL */ DamageTypeUnknown, /* SAFE_FALL */ DamageTypeUnknown,
/* SENSE_HEADING */ DamageTypeUnknown, /* SENSE_HEADING */ DamageTypeUnknown,
/* SINGING */ SpellDamageType, /* SINGING */ SpellDamageType,
/* SNEAK */ DamageTypeUnknown, /* SNEAK */ DamageTypeUnknown,
/* SPECIALIZE_ABJURE */ DamageTypeUnknown, /* SPECIALIZE_ABJURE */ DamageTypeUnknown,
/* SPECIALIZE_ALTERATION */ DamageTypeUnknown, /* SPECIALIZE_ALTERATION */ DamageTypeUnknown,
/* SPECIALIZE_CONJURATION */ DamageTypeUnknown, /* SPECIALIZE_CONJURATION */ DamageTypeUnknown,
/* SPECIALIZE_DIVINATION */ DamageTypeUnknown, /* SPECIALIZE_DIVINATION */ DamageTypeUnknown,
/* SPECIALIZE_EVOCATION */ DamageTypeUnknown, /* SPECIALIZE_EVOCATION */ DamageTypeUnknown,
/* PICK_POCKETS */ DamageTypeUnknown, /* PICK_POCKETS */ DamageTypeUnknown,
/* STRINGED_INSTRUMENTS */ SpellDamageType, /* STRINGED_INSTRUMENTS */ SpellDamageType,
/* SWIMMING */ DamageTypeUnknown, /* SWIMMING */ DamageTypeUnknown,
/* THROWING */ 51, /* THROWING */ 51,
/* TIGER_CLAW */ 23, /* TIGER_CLAW */ 23,
/* TRACKING */ DamageTypeUnknown, /* TRACKING */ DamageTypeUnknown,
/* WIND_INSTRUMENTS */ SpellDamageType, /* WIND_INSTRUMENTS */ SpellDamageType,
/* FISHING */ DamageTypeUnknown, /* FISHING */ DamageTypeUnknown,
/* MAKE_POISON */ DamageTypeUnknown, /* MAKE_POISON */ DamageTypeUnknown,
/* TINKERING */ DamageTypeUnknown, /* TINKERING */ DamageTypeUnknown,
/* RESEARCH */ DamageTypeUnknown, /* RESEARCH */ DamageTypeUnknown,
/* ALCHEMY */ DamageTypeUnknown, /* ALCHEMY */ DamageTypeUnknown,
/* BAKING */ DamageTypeUnknown, /* BAKING */ DamageTypeUnknown,
/* TAILORING */ DamageTypeUnknown, /* TAILORING */ DamageTypeUnknown,
/* SENSE_TRAPS */ DamageTypeUnknown, /* SENSE_TRAPS */ DamageTypeUnknown,
/* BLACKSMITHING */ DamageTypeUnknown, /* BLACKSMITHING */ DamageTypeUnknown,
/* FLETCHING */ DamageTypeUnknown, /* FLETCHING */ DamageTypeUnknown,
/* BREWING */ DamageTypeUnknown, /* BREWING */ DamageTypeUnknown,
/* ALCOHOL_TOLERANCE */ DamageTypeUnknown, /* ALCOHOL_TOLERANCE */ DamageTypeUnknown,
/* BEGGING */ DamageTypeUnknown, /* BEGGING */ DamageTypeUnknown,
/* JEWELRY_MAKING */ DamageTypeUnknown, /* JEWELRY_MAKING */ DamageTypeUnknown,
/* POTTERY */ DamageTypeUnknown, /* POTTERY */ DamageTypeUnknown,
/* PERCUSSION_INSTRUMENTS */ SpellDamageType, /* PERCUSSION_INSTRUMENTS */ SpellDamageType,
/* INTIMIDATION */ DamageTypeUnknown, /* INTIMIDATION */ DamageTypeUnknown,
/* BERSERKING */ DamageTypeUnknown, /* BERSERKING */ DamageTypeUnknown,
/* TAUNT */ DamageTypeUnknown, /* TAUNT */ DamageTypeUnknown,
/* FRENZY */ 74 /* FRENZY */ 74
}; };
// Indexing positions into item material arrays // Indexing positions into item material arrays
@ -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,

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,65 @@
/* EQEmu: Everquest Server Emulator /* EQEmu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEmu Development Team (http://www.eqemulator.net) Copyright (C) 2001-2013 EQEmu Development Team (http://www.eqemulator.net)
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
*/ */
#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_),
name_(e.name_) name_(e.name_)
{ {
} }
#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_),
name_(e.name_) name_(e.name_)
{ {
} }
#endif #endif
void Exception::operator=(const Exception& e) {
line_ = e.line_;
file_ = e.file_;
desc_ = e.desc_;
name_ = e.name_;
}
const std::string& Exception::full_description() const { void Exception::operator=(const Exception& e) {
if(full_desc_.empty()) { line_ = e.line_;
std::stringstream ss; file_ = e.file_;
ss << "EQEmu Exception (" << name_ << ") in " << file_; desc_ = e.desc_;
ss << " at line (" << line_ << "): " << desc_; name_ = e.name_;
full_desc_ = ss.str(); }
}
return full_desc_; const std::string& Exception::full_description() const {
} if(full_desc_.empty()) {
std::stringstream ss;
ss << "EQEmu Exception (" << name_ << ") in " << file_;
ss << " at line (" << line_ << "): " << desc_;
full_desc_ = ss.str();
}
return full_desc_;
}
} // EQEmu } // EQEmu

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
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 _EQEMU_EQEMUEXCEPTION_H #ifndef _EQEMU_EQEMUEXCEPTION_H
@ -24,83 +24,83 @@
namespace EQEmu namespace EQEmu
{ {
//! EQEmu Exception Class //! EQEmu Exception Class
/*! /*!
A custom exception class for things EQEmu throws. A custom exception class for things EQEmu throws.
*/ */
class Exception : public std::exception { class Exception : public std::exception {
public: public:
//! Detailed Constructor
/*!
\param name The name given for this exception.
\param description The description for this exception.
\param file The file name for this exception.
\param line The line number for this exception.
*/
Exception(const char* name, const std::string& description, const char* file, long line);
//! Copy Constructor
Exception(const Exception& e);
//! Move Constructor
#ifdef EQEMU_RVALUE_MOVE
Exception(const Exception&& e);
#endif
//! Destructor
~Exception() throw() { }
//! Assignment Operator
void operator=(const Exception& e);
//! Get Name //! Detailed Constructor
/*! /*!
Gets the name of the exception as it was when it was created. \param name The name given for this exception.
These are typically descriptive categories that the exception would fall under. \param description The description for this exception.
*/ \param file The file name for this exception.
virtual const std::string& name() const { return name_; } \param line The line number for this exception.
*/
//! Get Basic Description Exception(const char* name, const std::string& description, const char* file, long line);
/*!
Gets the description of the exception as it was when it was created. //! Copy Constructor
This tends to explain the circumstances of why the exception was thrown. Exception(const Exception& e);
*/
virtual const std::string& description() const { return desc_; } //! Move Constructor
#ifdef EQEMU_RVALUE_MOVE
//! Get Full Description Exception(const Exception&& e);
/*! #endif
Gets a full description for this exception.
This is a string containing the name, description, file and line number in a custom format. //! Destructor
This string is created the first time the full_description is accessed. ~Exception() throw() { }
*/
virtual const std::string& full_description() const; //! Assignment Operator
void operator=(const Exception& e);
//! Get File Name
/*! //! Get Name
Gets the name of the file this exception was thrown from. /*!
*/ Gets the name of the exception as it was when it was created.
virtual const std::string& file() const { return file_; } These are typically descriptive categories that the exception would fall under.
*/
//! Get File Line virtual const std::string& name() const { return name_; }
/*!
Gets the file line this exception was thrown from. //! Get Basic Description
*/ /*!
virtual const long& line() const { return line_; } 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.
//! std::exception overload */
/*! virtual const std::string& description() const { return desc_; }
Overload from std::exception
Allows it to be caught as a std::exception without casting which is nice, returns the full description. //! Get Full Description
*/ /*!
const char* what() const throw() { return full_description().c_str(); } Gets a full description for this exception.
protected: This is a string containing the name, description, file and line number in a custom format.
std::string name_; //!< Exception name This string is created the first time the full_description is accessed.
std::string desc_; //!< Exception Description */
mutable std::string full_desc_; //!< Full Exception Description virtual const std::string& full_description() const;
std::string file_; //!< File Name
long line_; //<! File Line //! Get File Name
}; /*!
Gets the name of the file this exception was thrown from.
*/
virtual const std::string& file() const { return file_; }
//! Get File Line
/*!
Gets the file line this exception was thrown from.
*/
virtual const long& line() const { return line_; }
//! std::exception overload
/*!
Overload from std::exception
Allows it to be caught as a std::exception without casting which is nice, returns the full description.
*/
const char* what() const throw() { return full_description().c_str(); }
protected:
std::string name_; //!< Exception name
std::string desc_; //!< Exception Description
mutable std::string full_desc_; //!< Full Exception Description
std::string file_; //!< File Name
long line_; //<! File Line
};
} // EQEmu } // EQEmu
#ifndef EQ_EXCEPT #ifndef EQ_EXCEPT

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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
*/ */
#include <fstream> #include <fstream>
@ -69,58 +69,58 @@ EQTime::~EQTime()
int EQTime::getEQTimeOfDay( time_t timeConvert, struct TimeOfDay_Struct *eqTimeOfDay ) int EQTime::getEQTimeOfDay( time_t timeConvert, struct TimeOfDay_Struct *eqTimeOfDay )
{ {
/* check to see if we have a reference time to go by. */ /* check to see if we have a reference time to go by. */
if( eqTime.start_realtime == 0 ) if( eqTime.start_realtime == 0 )
return 0; return 0;
unsigned long diff = timeConvert - eqTime.start_realtime; unsigned long diff = timeConvert - eqTime.start_realtime;
/* There are 3 seconds per 1 EQ Minute */ /* There are 3 seconds per 1 EQ Minute */
diff /= 3; diff /= 3;
/* Start off timezone offset */ /* Start off timezone offset */
int32 ntz = timezone; int32 ntz = timezone;
/* The minutes range from 0 - 59 */ /* The minutes range from 0 - 59 */
diff += eqTime.start_eqtime.minute + (ntz%60); diff += eqTime.start_eqtime.minute + (ntz%60);
eqTimeOfDay->minute = diff % 60; eqTimeOfDay->minute = diff % 60;
diff /= 60; diff /= 60;
ntz /= 60; ntz /= 60;
// The hours range from 1-24 // The hours range from 1-24
// 1 = 1am // 1 = 1am
// 2 = 2am // 2 = 2am
// ... // ...
// 23 = 11 pm // 23 = 11 pm
// 24 = 12 am // 24 = 12 am
// //
// Modify it so that it works from // Modify it so that it works from
// 0-23 for our calculations // 0-23 for our calculations
diff += ( eqTime.start_eqtime.hour - 1) + (ntz%24); diff += ( eqTime.start_eqtime.hour - 1) + (ntz%24);
eqTimeOfDay->hour = (diff%24) + 1; eqTimeOfDay->hour = (diff%24) + 1;
diff /= 24; diff /= 24;
ntz /= 24; ntz /= 24;
// The days range from 1-28 // The days range from 1-28
// Modify it so that it works from // Modify it so that it works from
// 0-27 for our calculations // 0-27 for our calculations
diff += ( eqTime.start_eqtime.day - 1 ) + (ntz%28); diff += ( eqTime.start_eqtime.day - 1 ) + (ntz%28);
eqTimeOfDay->day = (diff%28) + 1; eqTimeOfDay->day = (diff%28) + 1;
diff /= 28; diff /= 28;
ntz /= 28; ntz /= 28;
// The months range from 1-12 // The months range from 1-12
// Modify it so that it works from // Modify it so that it works from
// 0-11 for our calculations // 0-11 for our calculations
diff += ( eqTime.start_eqtime.month - 1 ) + (ntz%12); diff += ( eqTime.start_eqtime.month - 1 ) + (ntz%12);
eqTimeOfDay->month = (diff%12) + 1; eqTimeOfDay->month = (diff%12) + 1;
diff /= 12; diff /= 12;
ntz /= 12; ntz /= 12;
eqTimeOfDay->year = eqTime.start_eqtime.year + diff + ntz; eqTimeOfDay->year = eqTime.start_eqtime.year + diff + ntz;
return 1; return 1;
} }
//setEQTimeOfDay //setEQTimeOfDay
@ -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;
@ -172,7 +172,7 @@ bool EQTime::loadFile(const char *filename)
in.ignore(80, '\n'); in.ignore(80, '\n');
if(version != EQT_VERSION) if(version != EQT_VERSION)
{ {
LogFile->write(EQEMuLog::Error, "'%s' is NOT a valid EQTime file. File version is %i, EQTime version is %i", filename, version, EQT_VERSION); LogFile->write(EQEMuLog::Error, "'%s' is NOT a valid EQTime file. File version is %i, EQTime version is %i", filename, version, EQT_VERSION);
return false; return false;
} }
//in >> eqTime.start_eqtime.day; //in >> eqTime.start_eqtime.day;
@ -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;
@ -273,8 +273,3 @@ void EQTime::ToString(TimeOfDay_Struct *t, string &str) {
str = buf; str = buf;
} }

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);

View File

@ -1,22 +1,22 @@
/* 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
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/* Error messages for mysql clients */ This library is free software; you can redistribute it and/or
/* error messages for the demon is in share/language/errmsg.sys */ modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/* Error messages for mysql clients */
/* error messages for the demon is in share/language/errmsg.sys */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "debug.h" #include "debug.h"
@ -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,12 +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);
} }

View File

@ -1,22 +1,22 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
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 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

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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
*/ */
#include "debug.h" #include "debug.h"
#include "faction.h" #include "faction.h"
@ -29,20 +29,20 @@ const char *FactionValueToString(FACTION_VALUE fv) {
return("Kindly"); return("Kindly");
case FACTION_AMIABLE: case FACTION_AMIABLE:
return("Amiable"); return("Amiable");
case FACTION_INDIFFERENT: case FACTION_INDIFFERENT:
return("Indifferent"); return("Indifferent");
case FACTION_APPREHENSIVE: case FACTION_APPREHENSIVE:
return("Apprehensive"); return("Apprehensive");
case FACTION_DUBIOUS: case FACTION_DUBIOUS:
return("Dubious"); return("Dubious");
case FACTION_THREATENLY: case FACTION_THREATENLY:
return("Threatenly"); return("Threatenly");
case FACTION_SCOWLS: case FACTION_SCOWLS:
return("Scowls, ready to attack."); return("Scowls, ready to attack.");
default: default:
break; break;
} }
return("Unknown Faction Con"); return("Unknown Faction Con");
} }
@ -50,21 +50,21 @@ const char *FactionValueToString(FACTION_VALUE fv) {
//| Name: CalculateFaction; rembrant, Dec. 16, 2001 //| Name: CalculateFaction; rembrant, Dec. 16, 2001
//o-------------------------------------------------------------- //o--------------------------------------------------------------
//| Notes: Returns the faction message value. //| Notes: Returns the faction message value.
//| Modify these values to taste. //| Modify these values to taste.
//o-------------------------------------------------------------- //o--------------------------------------------------------------
FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value) FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value)
{ {
int32 character_value = tmpCharacter_value; int32 character_value = tmpCharacter_value;
if (fm) if (fm)
character_value += fm->base + fm->class_mod + fm->race_mod + fm->deity_mod; character_value += fm->base + fm->class_mod + fm->race_mod + fm->deity_mod;
if(character_value >= 1101) return FACTION_ALLY; if(character_value >= 1101) return FACTION_ALLY;
if(character_value >= 701 && character_value <= 1100) return FACTION_WARMLY; if(character_value >= 701 && character_value <= 1100) return FACTION_WARMLY;
if(character_value >= 401 && character_value <= 700) return FACTION_KINDLY; if(character_value >= 401 && character_value <= 700) return FACTION_KINDLY;
if(character_value >= 101 && character_value <= 400) return FACTION_AMIABLE; if(character_value >= 101 && character_value <= 400) return FACTION_AMIABLE;
if(character_value >= 0 && character_value <= 100) return FACTION_INDIFFERENT; if(character_value >= 0 && character_value <= 100) return FACTION_INDIFFERENT;
if(character_value >= -100 && character_value <= -1) return FACTION_APPREHENSIVE; if(character_value >= -100 && character_value <= -1) return FACTION_APPREHENSIVE;
if(character_value >= -700 && character_value <= -101) return FACTION_DUBIOUS; if(character_value >= -700 && character_value <= -101) return FACTION_DUBIOUS;
if(character_value >= -999 && character_value <= -701) return FACTION_THREATENLY; if(character_value >= -999 && character_value <= -701) return FACTION_THREATENLY;
if(character_value <= -1000) return FACTION_SCOWLS; if(character_value <= -1000) return FACTION_SCOWLS;
return FACTION_INDIFFERENT; return FACTION_INDIFFERENT;
} }
@ -72,70 +72,70 @@ FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value)
// neotokyo: this function should check if some races have more than one race define // neotokyo: this function should check if some races have more than one race define
bool IsOfEqualRace(int r1, int r2) bool IsOfEqualRace(int r1, int r2)
{ {
if (r1 == r2) if (r1 == r2)
return true; return true;
// TODO: add more values // TODO: add more values
switch(r1) switch(r1)
{ {
case DARK_ELF: case DARK_ELF:
if (r2 == 77) if (r2 == 77)
return true; return true;
break; break;
case BARBARIAN: case BARBARIAN:
if (r2 == 90) if (r2 == 90)
return true; return true;
} }
return false; return false;
} }
// neotokyo: trolls endure ogres, dark elves, ... // neotokyo: trolls endure ogres, dark elves, ...
bool IsOfIndiffRace(int r1, int r2) bool IsOfIndiffRace(int r1, int r2)
{ {
if (r1 == r2) if (r1 == r2)
return true; return true;
// TODO: add more values // TODO: add more values
switch(r1) switch(r1)
{ {
case DARK_ELF: case DARK_ELF:
case OGRE: case OGRE:
case TROLL: case TROLL:
if (r2 == OGRE || r2 == TROLL || r2 == DARK_ELF) if (r2 == OGRE || r2 == TROLL || r2 == DARK_ELF)
return true; return true;
break; break;
case HUMAN: case HUMAN:
case BARBARIAN: case BARBARIAN:
case HALF_ELF: case HALF_ELF:
case GNOME: case GNOME:
case HALFLING: case HALFLING:
case WOOD_ELF: case WOOD_ELF:
if (r2 == HUMAN || if (r2 == HUMAN ||
r2 == BARBARIAN || r2 == BARBARIAN ||
r2 == ERUDITE || r2 == ERUDITE ||
r2 == HALF_ELF || r2 == HALF_ELF ||
r2 == GNOME || r2 == GNOME ||
r2 == HALFLING || r2 == HALFLING ||
r2 == DWARF || r2 == DWARF ||
r2 == HIGH_ELF || r2 == HIGH_ELF ||
r2 == WOOD_ELF) r2 == WOOD_ELF)
return true; return true;
break; break;
case ERUDITE: case ERUDITE:
if (r2 == HUMAN || r2 == HALF_ELF) if (r2 == HUMAN || r2 == HALF_ELF)
return true; return true;
break; break;
case DWARF: case DWARF:
if (r2 == HALFLING || r2 == GNOME) if (r2 == HALFLING || r2 == GNOME)
return true; return true;
break; break;
case HIGH_ELF: case HIGH_ELF:
if (r2 == WOOD_ELF) if (r2 == WOOD_ELF)
return true; return true;
break; break;
case VAHSHIR: case VAHSHIR:
return true; return true;
case IKSAR: case IKSAR:
return false; return false;
} }
return false; return false;
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2013 EQEMu Development Team (http://eqemu.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 _EQEMU_FACTION_H #ifndef _EQEMU_FACTION_H
#define _EQEMU_FACTION_H #define _EQEMU_FACTION_H
@ -28,13 +28,13 @@ 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,
FACTION_SCOWLS = 9 FACTION_SCOWLS = 9
}; };
struct NPCFactionList { struct NPCFactionList {
@ -57,19 +57,19 @@ struct FactionMods
struct Faction { struct Faction {
int32 id; int32 id;
std::map<std::string, int16> mods; std::map<std::string, int16> mods;
int16 base; int16 base;
char name[50]; char name[50];
}; };
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);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.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 FEATURES_H #ifndef FEATURES_H
#define FEATURES_H #define FEATURES_H
@ -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,14 +221,14 @@ 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
#define MAX_NPC_FACTIONS 20 #define MAX_NPC_FACTIONS 20
//value caps //value caps
#define MAX_FACTION 1500 #define MAX_FACTION 1500
#define MIN_FACTION -1500 #define MIN_FACTION -1500
//The Level Cap: //The Level Cap:

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
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 _EQEMU_FIXED_MEMORY_HASHSET_H #ifndef _EQEMU_FIXED_MEMORY_HASHSET_H
@ -25,227 +25,228 @@
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>
class FixedMemoryHashSet { class FixedMemoryHashSet {
typedef uint32 key_type; typedef uint32 key_type;
typedef T value_type; typedef T value_type;
typedef uint8 byte; typedef uint8 byte;
typedef value_type& reference; typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
typedef size_t size_type; typedef size_t size_type;
public: public:
/*! /*!
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) {
data_ = data; data_ = data;
size_ = size; size_ = size;
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) = element_count; *reinterpret_cast<key_type*>(ptr) = element_count;
max_elements_ = element_count; max_elements_ = element_count;
ptr += sizeof(key_type); ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = 0; *reinterpret_cast<key_type*>(ptr) = 0;
current_elements_ = 0; current_elements_ = 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));
ptr += sizeof(key_type) * (max_element_id + 1); ptr += sizeof(key_type) * (max_element_id + 1);
elements_ = reinterpret_cast<value_type*>(ptr); elements_ = reinterpret_cast<value_type*>(ptr);
} }
/*! /*!
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
*/ */
FixedMemoryHashSet(byte *data, size_type size) { FixedMemoryHashSet(byte *data, size_type size) {
data_ = data; data_ = data;
size_ = size; size_ = size;
byte *ptr = data; byte *ptr = data;
offset_count_ = *reinterpret_cast<key_type*>(ptr); offset_count_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type); ptr += sizeof(key_type);
max_elements_ = *reinterpret_cast<key_type*>(ptr); max_elements_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type); ptr += sizeof(key_type);
current_elements_ = *reinterpret_cast<key_type*>(ptr); current_elements_ = *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_;
elements_ = reinterpret_cast<value_type*>(ptr); elements_ = reinterpret_cast<value_type*>(ptr);
} }
//! Copy Constructor //! Copy Constructor
FixedMemoryHashSet(const FixedMemoryHashSet& other) : FixedMemoryHashSet(const FixedMemoryHashSet& other) :
data_(other.data_), data_(other.data_),
size_(other.size_), size_(other.size_),
offset_count_(other.offset_count_), offset_count_(other.offset_count_),
max_elements_(other.max_elements_), max_elements_(other.max_elements_),
current_elements_(other.current_elements_), current_elements_(other.current_elements_),
offsets_(other.offsets_), offsets_(other.offsets_),
elements_(other.elements_) elements_(other.elements_)
{ {
} }
//! RValue-Move Constructor //! RValue-Move Constructor
#ifdef EQEMU_RVALUE_MOVE #ifdef EQEMU_RVALUE_MOVE
FixedMemoryHashSet(FixedMemoryHashSet&& other) : FixedMemoryHashSet(FixedMemoryHashSet&& other) :
data_(other.data_), data_(other.data_),
size_(other.size_), size_(other.size_),
offset_count_(other.offset_count_), offset_count_(other.offset_count_),
max_elements_(other.max_elements_), max_elements_(other.max_elements_),
current_elements_(other.current_elements_), current_elements_(other.current_elements_),
offsets_(other.offsets_), offsets_(other.offsets_),
elements_(other.elements_) elements_(other.elements_)
{ {
} }
#endif #endif
//! Destructor //! Destructor
~FixedMemoryHashSet() { ~FixedMemoryHashSet() {
} }
//! Assignment operator //! Assignment operator
const FixedMemoryHashSet& operator=(const FixedMemoryHashSet& other) { const FixedMemoryHashSet& operator=(const FixedMemoryHashSet& other) {
data_ = other.data_; data_ = other.data_;
size_ = other.size_; size_ = other.size_;
offset_count_ = other.offset_count_; offset_count_ = other.offset_count_;
max_elements_ = other.max_elements_; max_elements_ = other.max_elements_;
current_elements_ = other.current_elements_; current_elements_ = other.current_elements_;
offsets_ = other.offsets_; offsets_ = other.offsets_;
elements_ = other.elements_; elements_ = other.elements_;
return *this; return *this;
} }
//! Returns whether the set is empty (has 0 elements) or not
bool empty() const {
return current_elements_ == 0;
}
//! Returns the number of unique elements in the set currently //! Returns whether the set is empty (has 0 elements) or not
size_type size() const { bool empty() const {
return current_elements_; return current_elements_ == 0;
} }
//! Returns the maximum number of elements one can insert into the set. //! Returns the number of unique elements in the set currently
size_type max_size() const { size_type size() const {
return max_elements_; return current_elements_;
} }
//! Returns the maximum key one can use with the set. //! Returns the maximum number of elements one can insert into the set.
key_type max_key() const { size_type max_size() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0; return max_elements_;
} }
/*!
Retrieve value operator
\param i Index to retrieve the value from
*/
reference operator[](const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range");
}
if(offsets_[i] == 0xFFFFFFFFU) { //! Returns the maximum key one can use with the set.
EQ_EXCEPT("Fixed Memory Hash Set", "Element not found."); key_type max_key() const {
} return offset_count_ > 0 ? (offset_count_ - 1) : 0;
}
return elements_[offsets_[i]]; /*!
} Retrieve value operator
\param i Index to retrieve the value from
*/
reference operator[](const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range");
}
/*! if(offsets_[i] == 0xFFFFFFFFU) {
Retrieve value function EQ_EXCEPT("Fixed Memory Hash Set", "Element not found.");
\param i Index to retrieve the value from }
*/
reference at(const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
}
if(offsets_[i] == 0xFFFFFFFFU) { return elements_[offsets_[i]];
EQ_EXCEPT("Fixed Memory Hash Set", "Element not found."); }
}
return elements_[offsets_[i]]; /*!
} Retrieve value function
\param i Index to retrieve the value from
*/
reference at(const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
}
/*! if(offsets_[i] == 0xFFFFFFFFU) {
Checks if there is a value at a certain index EQ_EXCEPT("Fixed Memory Hash Set", "Element not found.");
\param i Index to check for a value }
*/
bool exists(const key_type& i) const {
if(i >= offset_count_) {
return false;
}
if(offsets_[i] == 0xFFFFFFFFU) { return elements_[offsets_[i]];
return false; }
}
return true; /*!
} Checks if there is a value at a certain index
\param i Index to check for a value
*/
bool exists(const key_type& i) const {
if(i >= offset_count_) {
return false;
}
/*! if(offsets_[i] == 0xFFFFFFFFU) {
Inserts a value into the set at a specific index return false;
\param i Index to insert the value at }
\param v Value to insert
*/
void insert(const key_type& i, const_reference v) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
}
if(offsets_[i] != 0xFFFFFFFFU) { return true;
elements_[offsets_[i]] = v; }
} else {
if(current_elements_ >= max_elements_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Insert pointer out of range.");
}
offsets_[i] = current_elements_; /*!
memcpy(&elements_[current_elements_], &v, sizeof(value_type)); Inserts a value into the set at a specific index
++current_elements_; \param i Index to insert the value at
*reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_elements_; \param v Value to insert
} */
} void insert(const key_type& i, const_reference v) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
}
//! Calculates how much memory we should allocate based on element size and count if(offsets_[i] != 0xFFFFFFFFU) {
static size_type estimated_size(key_type element_count, key_type max_elements) { elements_[offsets_[i]] = v;
size_type total_size = 3 * sizeof(key_type); } else {
total_size += sizeof(key_type) * (max_elements + 1); if(current_elements_ >= max_elements_) {
total_size += sizeof(T) * element_count; EQ_EXCEPT("Fixed Memory Hash Set", "Insert pointer out of range.");
return total_size; }
}
private: offsets_[i] = current_elements_;
unsigned char *data_; memcpy(&elements_[current_elements_], &v, sizeof(value_type));
size_type size_; ++current_elements_;
key_type offset_count_; *reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_elements_;
key_type max_elements_; }
key_type current_elements_; }
key_type *offsets_;
value_type *elements_; //! Calculates how much memory we should allocate based on element size and count
}; static size_type estimated_size(key_type element_count, key_type max_elements) {
size_type total_size = 3 * sizeof(key_type);
total_size += sizeof(key_type) * (max_elements + 1);
total_size += sizeof(T) * element_count;
return total_size;
}
private:
unsigned char *data_;
size_type size_;
key_type offset_count_;
key_type max_elements_;
key_type current_elements_;
key_type *offsets_;
value_type *elements_;
};
} // EQEmu } // EQEmu
#endif #endif

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
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 _EQEMU_FIXED_MEMORY_VARIABLE_HASHSET_H #ifndef _EQEMU_FIXED_MEMORY_VARIABLE_HASHSET_H
@ -25,217 +25,217 @@
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>
class FixedMemoryVariableHashSet { class FixedMemoryVariableHashSet {
typedef uint32 key_type; typedef uint32 key_type;
typedef T value_type; typedef T value_type;
typedef uint8 byte; typedef uint8 byte;
typedef value_type& reference; typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
typedef uint32 size_type; typedef uint32 size_type;
public: public:
/*! /*!
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 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.
*/ */
FixedMemoryVariableHashSet(byte *data, size_type size, key_type max_element_id) { FixedMemoryVariableHashSet(byte *data, size_type size, key_type max_element_id) {
data_ = data; data_ = data;
size_ = size; size_ = size;
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;
current_offset_ = 0;
ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr); *reinterpret_cast<key_type*>(ptr) = 0;
memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1)); current_offset_ = 0;
ptr += sizeof(key_type) * (max_element_id + 1); ptr += sizeof(key_type);
elements_ = reinterpret_cast<byte*>(ptr);
}
/*! offsets_ = reinterpret_cast<key_type*>(ptr);
Constructor which does not initialize the hash set. Builds the hash set from what data is memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1));
stored in the data pointer passed. ptr += sizeof(key_type) * (max_element_id + 1);
\param data Raw data
\param size Raw data size
*/
FixedMemoryVariableHashSet(byte *data, size_type size) {
data_ = data;
size_ = size;
byte *ptr = data; elements_ = reinterpret_cast<byte*>(ptr);
offset_count_ = *reinterpret_cast<key_type*>(ptr); }
ptr += sizeof(key_type);
remaining_size_ = *reinterpret_cast<key_type*>(ptr); /*!
ptr += sizeof(key_type); Constructor which does not initialize the hash set. Builds the hash set from what data is
stored in the data pointer passed.
\param data Raw data
\param size Raw data size
*/
FixedMemoryVariableHashSet(byte *data, size_type size) {
data_ = data;
size_ = size;
current_offset_ = *reinterpret_cast<key_type*>(ptr); byte *ptr = data;
ptr += sizeof(key_type); offset_count_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type) * offset_count_;
elements_ = reinterpret_cast<byte*>(ptr); remaining_size_ = *reinterpret_cast<key_type*>(ptr);
} ptr += sizeof(key_type);
//! Copy Constructor current_offset_ = *reinterpret_cast<key_type*>(ptr);
FixedMemoryVariableHashSet(const FixedMemoryVariableHashSet& other) : ptr += sizeof(key_type);
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
remaining_size_(other.remaining_size_),
current_offset_(other.current_offset_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
//! RValue-Move Constructor offsets_ = reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type) * offset_count_;
elements_ = reinterpret_cast<byte*>(ptr);
}
//! Copy Constructor
FixedMemoryVariableHashSet(const FixedMemoryVariableHashSet& other) :
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
remaining_size_(other.remaining_size_),
current_offset_(other.current_offset_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
//! RValue-Move Constructor
#ifdef EQEMU_RVALUE_MOVE #ifdef EQEMU_RVALUE_MOVE
FixedMemoryVariableHashSet(FixedMemoryVariableHashSet&& other) : FixedMemoryVariableHashSet(FixedMemoryVariableHashSet&& other) :
data_(other.data_), data_(other.data_),
size_(other.size_), size_(other.size_),
offset_count_(other.offset_count_), offset_count_(other.offset_count_),
remaining_size_(other.remaining_size_), remaining_size_(other.remaining_size_),
current_offset_(other.current_offset_), current_offset_(other.current_offset_),
offsets_(other.offsets_), offsets_(other.offsets_),
elements_(other.elements_) elements_(other.elements_)
{ {
} }
#endif #endif
//! Destructor //! Destructor
~FixedMemoryVariableHashSet() { ~FixedMemoryVariableHashSet() {
} }
//! Assignment operator //! Assignment operator
const FixedMemoryVariableHashSet& operator=(const FixedMemoryVariableHashSet& other) { const FixedMemoryVariableHashSet& operator=(const FixedMemoryVariableHashSet& other) {
data_ = other.data_; data_ = other.data_;
size_ = other.size_; size_ = other.size_;
offset_count_ = other.offset_count_; offset_count_ = other.offset_count_;
remaining_size_ = other.remaining_size_; remaining_size_ = other.remaining_size_;
current_offset_ = other.current_offset_; current_offset_ = other.current_offset_;
offsets_ = other.offsets_; offsets_ = other.offsets_;
elements_ = other.elements_; elements_ = other.elements_;
return *this; return *this;
} }
//! Returns the number of bytes in the set currently
size_type size() const {
return size_ - remaining_size_;
}
//! Returns the maximum number of bytes one can insert into the set. //! Returns the number of bytes in the set currently
size_type max_size() const { size_type size() const {
return size_ - (sizeof(key_type) * 2); return size_ - remaining_size_;
} }
//! Returns the maximum key one can use with the set. //! Returns the maximum number of bytes one can insert into the set.
key_type max_key() const { size_type max_size() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0; return size_ - (sizeof(key_type) * 2);
} }
/*!
Retrieve value operator
\param i Index to retrieve the value from
*/
reference operator[](const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
}
if(offsets_[i] == 0xFFFFFFFFU) { //! Returns the maximum key one can use with the set.
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found."); key_type max_key() const {
} return offset_count_ > 0 ? (offset_count_ - 1) : 0;
}
return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]); /*!
} Retrieve value operator
\param i Index to retrieve the value from
*/
reference operator[](const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
}
/*! if(offsets_[i] == 0xFFFFFFFFU) {
Retrieve value function EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found.");
\param i Index to retrieve the value from }
*/
reference at(const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
}
if(offsets_[i] == 0xFFFFFFFFU) { return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]);
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found."); }
}
return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]); /*!
} Retrieve value function
\param i Index to retrieve the value from
*/
reference at(const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
}
/*! if(offsets_[i] == 0xFFFFFFFFU) {
Checks if there is a value at a certain index EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found.");
\param i Index to check for a value }
*/
bool exists(const key_type& i) const {
if(i >= offset_count_) {
return false;
}
if(offsets_[i] == 0xFFFFFFFFU) { return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]);
return false; }
}
return true; /*!
} Checks if there is a value at a certain index
\param i Index to check for a value
*/
bool exists(const key_type& i) const {
if(i >= offset_count_) {
return false;
}
/*! if(offsets_[i] == 0xFFFFFFFFU) {
Inserts a value into the set at a specific index return false;
\param i Index to insert the value at }
\param v Value to insert
*/
void insert(const key_type& i, byte *data, size_type size) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range.");
}
if(size > remaining_size_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Not enough room in hash set to insert this value.");
}
if(offsets_[i] != 0xFFFFFFFFU) { return true;
EQ_EXCEPT("Fixed Memory Hash Set", "Could not insert a repeat value at this index."); }
} else {
offsets_[i] = current_offset_;
memcpy(&elements_[current_offset_], data, size);
remaining_size_ -= size; /*!
*reinterpret_cast<key_type*>(data_ + sizeof(key_type)) = remaining_size_; Inserts a value into the set at a specific index
\param i Index to insert the value at
\param v Value to insert
*/
void insert(const key_type& i, byte *data, size_type size) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range.");
}
current_offset_ += size; if(size > remaining_size_) {
*reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_offset_; EQ_EXCEPT("Fixed Memory Hash Set", "Not enough room in hash set to insert this value.");
} }
}
private: if(offsets_[i] != 0xFFFFFFFFU) {
unsigned char *data_; EQ_EXCEPT("Fixed Memory Hash Set", "Could not insert a repeat value at this index.");
size_type size_; } else {
size_type remaining_size_; offsets_[i] = current_offset_;
key_type current_offset_; memcpy(&elements_[current_offset_], data, size);
key_type offset_count_;
key_type *offsets_; remaining_size_ -= size;
byte *elements_; *reinterpret_cast<key_type*>(data_ + sizeof(key_type)) = remaining_size_;
};
current_offset_ += size;
*reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_offset_;
}
}
private:
unsigned char *data_;
size_type size_;
size_type remaining_size_;
key_type current_offset_;
key_type offset_count_;
key_type *offsets_;
byte *elements_;
};
} // EQEmu } // EQEmu
#endif #endif

File diff suppressed because it is too large Load Diff

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();

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include "MiscFunctions.h" #include "MiscFunctions.h"
@ -29,7 +29,7 @@
/* /*
void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){ void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
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;
uint32 count=0; uint32 count=0;
@ -59,11 +59,11 @@ void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
} }
uint32 Database::NumberInGuild(uint32 guild_id) { uint32 Database::NumberInGuild(uint32 guild_id) {
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 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) {
@ -83,9 +83,9 @@ uint32 Database::NumberInGuild(uint32 guild_id) {
} }
bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) { 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)
@ -103,9 +103,9 @@ bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) { 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,17 +119,17 @@ 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;
} }
bool Database::DeleteGuild(uint32 guild_id) bool Database::DeleteGuild(uint32 guild_id)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
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,17 +146,17 @@ bool Database::DeleteGuild(uint32 guild_id)
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return false; return false;
} }
bool Database::RenameGuild(uint32 guild_id, const char* name) { bool Database::RenameGuild(uint32 guild_id, const char* name) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
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;
} }
@ -178,8 +178,8 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct* grl) bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct* grl)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
int chars = 0; int chars = 0;
uint32 affected_rows = 0; uint32 affected_rows = 0;
char buf[203]; char buf[203];
char buf2[8]; char buf2[8];
@ -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,17 +210,17 @@ 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;
} }
bool Database::GetGuildNameByID(uint32 guild_id, char * name) { bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
if (!name || !guild_id) return false; if (!name || !guild_id) return false;
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,17 +234,17 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return false; return false;
} }
uint32 Database::GetGuildIDbyLeader(uint32 leader) uint32 Database::GetGuildIDbyLeader(uint32 leader)
{ {
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 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,16 +260,16 @@ 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;
} }
bool Database::SetGuildLeader(uint32 guild_id, uint32 leader) 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,20 +282,20 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
return false; return false;
} }
bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) { bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
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,16 +311,16 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
delete motdbuf; delete motdbuf;
return false; return false;
} }
return false; return false;
} }
string Database::GetGuildMOTD(uint32 guild_id) string Database::GetGuildMOTD(uint32 guild_id)
{ {
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;
string motd_str; string motd_str;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT motd FROM guilds WHERE id=%i", guild_id), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT motd FROM guilds WHERE id=%i", guild_id), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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 GUILD_H #ifndef GUILD_H
@ -23,7 +23,7 @@
#define GUILD_NONE 0xFFFFFFFF // user has no guild #define GUILD_NONE 0xFFFFFFFF // user has no guild
#define GUILD_MAX_RANK 8 // 0-2 - some places in the code assume a single digit, dont go above 9 #define GUILD_MAX_RANK 8 // 0-2 - some places in the code assume a single digit, dont go above 9
//defines for standard ranks //defines for standard ranks
#define GUILD_MEMBER 0 #define GUILD_MEMBER 0

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "ipc_mutex.h" #include "ipc_mutex.h"
@ -30,91 +30,91 @@
namespace EQEmu { namespace EQEmu {
struct IPCMutex::Implementation { struct IPCMutex::Implementation {
#ifdef _WINDOWS #ifdef _WINDOWS
HANDLE mut_; HANDLE mut_;
#else #else
int fd_; int fd_;
#endif #endif
}; };
IPCMutex::IPCMutex(std::string name) : locked_(false) { IPCMutex::IPCMutex(std::string name) : locked_(false) {
imp_ = new Implementation; imp_ = new Implementation;
#ifdef _WINDOWS #ifdef _WINDOWS
std::string final_name = "EQEmuMutex_"; std::string final_name = "EQEmuMutex_";
final_name += name; final_name += name;
imp_->mut_ = CreateMutex(nullptr, imp_->mut_ = CreateMutex(nullptr,
FALSE, FALSE,
final_name.c_str()); final_name.c_str());
if(!imp_->mut_) { if(!imp_->mut_) {
EQ_EXCEPT("IPC Mutex", "Could not create mutex."); EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
} }
#else #else
std::string final_name = name; std::string final_name = name;
final_name += ".lock"; final_name += ".lock";
imp_->fd_ = open(final_name.c_str(), imp_->fd_ = open(final_name.c_str(),
O_RDWR | O_CREAT | O_CLOEXEC, O_RDWR | O_CREAT | O_CLOEXEC,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if(imp_->fd_ == -1) { if(imp_->fd_ == -1) {
EQ_EXCEPT("IPC Mutex", "Could not create mutex."); EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
} }
#endif #endif
} }
IPCMutex::~IPCMutex() { IPCMutex::~IPCMutex() {
#ifdef _WINDOWS #ifdef _WINDOWS
if(locked_) { if(locked_) {
ReleaseMutex(imp_->mut_); ReleaseMutex(imp_->mut_);
} }
CloseHandle(imp_->mut_); CloseHandle(imp_->mut_);
#else #else
if(locked_) { if(locked_) {
lockf(imp_->fd_, F_ULOCK, 0); lockf(imp_->fd_, F_ULOCK, 0);
} }
close(imp_->fd_); close(imp_->fd_);
#endif #endif
delete imp_; delete imp_;
} }
bool IPCMutex::Lock() { bool IPCMutex::Lock() {
if(locked_) { if(locked_) {
return false; return false;
} }
#ifdef _WINDOWS #ifdef _WINDOWS
DWORD wait_result = WaitForSingleObject(imp_->mut_, INFINITE); DWORD wait_result = WaitForSingleObject(imp_->mut_, INFINITE);
if(wait_result != WAIT_OBJECT_0) { if(wait_result != WAIT_OBJECT_0) {
return false; return false;
} }
#else #else
if(lockf(imp_->fd_, F_LOCK, 0) != 0) { if(lockf(imp_->fd_, F_LOCK, 0) != 0) {
return false; return false;
} }
#endif #endif
locked_ = true; locked_ = true;
return true; return true;
} }
bool IPCMutex::Unlock() { bool IPCMutex::Unlock() {
if(!locked_) { if(!locked_) {
return false; return false;
} }
#ifdef _WINDOWS #ifdef _WINDOWS
if(!ReleaseMutex(imp_->mut_)) { if(!ReleaseMutex(imp_->mut_)) {
return false; return false;
} }
#else #else
if(lockf(imp_->fd_, F_ULOCK, 0) != 0) { if(lockf(imp_->fd_, F_ULOCK, 0) != 0) {
return false; return false;
} }
#endif #endif
locked_ = false; locked_ = false;
return true; return true;
} }
} }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
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 _MUTEX_H_ #ifndef _MUTEX_H_
@ -22,44 +22,44 @@
#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.
*/ */
class IPCMutex { class IPCMutex {
struct Implementation; struct Implementation;
public: public:
//! Constructor //! Constructor
/*! /*!
Creates a named binary semaphore, basically a semaphore that is init S <- 1 Creates a named binary semaphore, basically a semaphore that is init S <- 1
\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;
*/ */
bool Unlock(); bool Unlock();
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_;
}; };
} }
#endif #endif

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
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 04111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
*/ */
#ifndef ITEM_STRUCT_H #ifndef ITEM_STRUCT_H
@ -21,25 +21,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
/* /*
* Note: (Doodman) * Note: (Doodman)
* This structure has field names that match the DB name exactly. * This structure has field names that match the DB name exactly.
* Please take care as to not mess this up as it should make * Please take care as to not mess this up as it should make
* everyones life (i.e. mine) much easier. And the DB names * everyones life (i.e. mine) much easier. And the DB names
* match the field name from the 13th floor (SEQ) item collectors, * match the field name from the 13th floor (SEQ) item collectors,
* so please maintain that as well. * so please maintain that as well.
* *
* Note #2: (Doodman) * Note #2: (Doodman)
* UnkXXX fields are left in here for completeness but commented * UnkXXX fields are left in here for completeness but commented
* out since they are really unknown and since the items are now * out since they are really unknown and since the items are now
* preserialized they should not be needed. Conversly if they * preserialized they should not be needed. Conversly if they
* -are- needed, then they shouldn't be unkown. * -are- needed, then they shouldn't be unkown.
* *
* Note #3: (Doodman) * Note #3: (Doodman)
* Please take care when adding new found data fields to add them * Please take care when adding new found data fields to add them
* to the appropriate structure. Item_Struct has elements that are * to the appropriate structure. Item_Struct has elements that are
* global to all types of items only. * global to all types of items only.
* *
* Note #4: (Doodman) * Note #4: (Doodman)
* Made ya look! Ha! * Made ya look! Ha!
*/ */
#include "eq_constants.h" #include "eq_constants.h"
@ -93,7 +93,7 @@ struct Item_Struct {
bool PendingLoreFlag; bool PendingLoreFlag;
bool ArtifactFlag; bool ArtifactFlag;
bool SummonedFlag; bool SummonedFlag;
uint8 FVNoDrop; // Firiona Vie nodrop flag uint8 FVNoDrop; // Firiona Vie nodrop flag
uint32 Favor; // Individual favor uint32 Favor; // Individual favor
uint32 GuildFavor; // Guild favor uint32 GuildFavor; // Guild favor
uint32 PointType; uint32 PointType;
@ -155,8 +155,8 @@ struct Item_Struct {
float SellRate; // Sell rate float SellRate; // Sell rate
//uint32 Unk059; //uint32 Unk059;
union { union {
uint32 Fulfilment; // Food fulfilment (How long it lasts) uint32 Fulfilment; // Food fulfilment (How long it lasts)
int16 CastTime; // Cast Time for clicky effects, in milliseconds int16 CastTime; // Cast Time for clicky effects, in milliseconds
}; };
uint32 EliteMaterial; uint32 EliteMaterial;
int32 ProcRate; int32 ProcRate;
@ -205,7 +205,7 @@ struct Item_Struct {
bool Stackable; bool Stackable;
bool NoTransfer; bool NoTransfer;
bool QuestItemFlag; bool QuestItemFlag;
int16 StackSize; int16 StackSize;
uint8 PotionBeltSlots; uint8 PotionBeltSlots;
ItemEffect_Struct Click, Proc, Worn, Focus, Scroll, Bard; ItemEffect_Struct Click, Proc, Worn, Focus, Scroll, Bard;

View File

@ -1,52 +1,52 @@
/* 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"
#define LANG_COMMON_TONGUE 0 #define LANG_COMMON_TONGUE 0
#define LANG_BARBARIAN 1 #define LANG_BARBARIAN 1
#define LANG_ERUDIAN 2 #define LANG_ERUDIAN 2
#define LANG_ELVISH 3 #define LANG_ELVISH 3
#define LANG_DARK_ELVISH 4 #define LANG_DARK_ELVISH 4
#define LANG_DWARVISH 5 #define LANG_DWARVISH 5
#define LANG_TROLL 6 #define LANG_TROLL 6
#define LANG_OGRE 7 #define LANG_OGRE 7
#define LANG_GNOMISH 8 #define LANG_GNOMISH 8
#define LANG_HALFLING 9 #define LANG_HALFLING 9
#define LANG_THIEVES_CANT 10 #define LANG_THIEVES_CANT 10
#define LANG_OLD_ERUDIAN 11 #define LANG_OLD_ERUDIAN 11
#define LANG_ELDER_ELVISH 12 #define LANG_ELDER_ELVISH 12
#define LANG_FROGLOK 13 #define LANG_FROGLOK 13
#define LANG_GOBLIN 14 #define LANG_GOBLIN 14
#define LANG_GNOLL 15 #define LANG_GNOLL 15
#define LANG_COMBINE_TONGUE 16 #define LANG_COMBINE_TONGUE 16
#define LANG_ELDER_TEIRDAL 17 #define LANG_ELDER_TEIRDAL 17
#define LANG_LIZARDMAN 18 #define LANG_LIZARDMAN 18
#define LANG_ORCISH 19 #define LANG_ORCISH 19
#define LANG_FAERIE 20 #define LANG_FAERIE 20
#define LANG_DRAGON 21 #define LANG_DRAGON 21
#define LANG_ELDER_DRAGON 22 #define LANG_ELDER_DRAGON 22
#define LANG_DARK_SPEECH 23 #define LANG_DARK_SPEECH 23
#define LANG_VAH_SHIR 24 #define LANG_VAH_SHIR 24
#define LANG_ALARAN 25 #define LANG_ALARAN 25
#define LANG_HADAL 26 #define LANG_HADAL 26
#define LANG_UNKNOWN 27 #define LANG_UNKNOWN 27
#endif #endif

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.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 LINKEDLIST_H #ifndef LINKEDLIST_H
#define LINKEDLIST_H #define LINKEDLIST_H
@ -24,90 +24,90 @@ 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:
TYPE data; TYPE data;
ListElement<TYPE>* next; ListElement<TYPE>* next;
ListElement<TYPE>* prev; ListElement<TYPE>* prev;
public: public:
ListElement (); ListElement ();
ListElement (const TYPE&); ListElement (const TYPE&);
ListElement (const ListElement<TYPE>&); ListElement (const ListElement<TYPE>&);
~ListElement (); ~ListElement ();
ListElement<TYPE>& operator= (const ListElement<TYPE>&); ListElement<TYPE>& operator= (const ListElement<TYPE>&);
ListElement<TYPE>* GetLast () ListElement<TYPE>* GetLast ()
{ {
ListElement<TYPE>* tmp = this; ListElement<TYPE>* tmp = this;
while (tmp->GetNext()) { while (tmp->GetNext()) {
tmp = tmp->GetNext(); tmp = tmp->GetNext();
}
return tmp;
} }
return tmp; ListElement<TYPE>* GetNext () const { return next ; }
} ListElement<TYPE>* GetPrev () const { return prev ; }
ListElement<TYPE>* GetNext () const { return next ; }
ListElement<TYPE>* GetPrev () const { return prev ; }
inline TYPE& GetData () { return data ; } inline TYPE& GetData () { return data ; }
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:
uint32 count; uint32 count;
ListElement<TYPE>* first; ListElement<TYPE>* first;
bool list_destructor_invoked; bool list_destructor_invoked;
public: public:
LinkedList(); LinkedList();
~LinkedList(); ~LinkedList();
bool dont_delete; bool dont_delete;
LinkedList<TYPE>& operator= (const LinkedList<TYPE>&); LinkedList<TYPE>& operator= (const LinkedList<TYPE>&);
void Append (const TYPE&); void Append (const TYPE&);
void Insert (const TYPE&); void Insert (const TYPE&);
TYPE Pop(); TYPE Pop();
TYPE PeekTop(); TYPE PeekTop();
void Clear(); void Clear();
void LCount() { count--; } void LCount() { count--; }
void ResetCount() { count=0; } void ResetCount() { count=0; }
uint32 Count() { return count; } uint32 Count() { return count; }
ListElement<TYPE>* GetFirst() { return first; } ListElement<TYPE>* GetFirst() { return first; }
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:
LinkedListIterator(LinkedList<TYPE>& l,direction d = FORWARD) : list(l), dir(d) {};
void Advance(); public:
const TYPE& GetData(); LinkedListIterator(LinkedList<TYPE>& l,direction d = FORWARD) : list(l), dir(d) {};
bool IsFirst()
void Advance();
const TYPE& GetData();
bool IsFirst()
{ {
if (current_element->GetPrev() == 0) if (current_element->GetPrev() == 0)
return true; return true;
@ -121,13 +121,13 @@ public:
else else
return false; return false;
} }
bool MoreElements(); bool MoreElements();
void MoveFirst(); void MoveFirst();
void MoveLast(); void MoveLast();
void RemoveCurrent(bool DeleteData = true); void RemoveCurrent(bool DeleteData = true);
void Replace(const TYPE& new_data); void Replace(const TYPE& new_data);
void Reset(); void Reset();
void SetDir(direction); void SetDir(direction);
}; };
template<class TYPE> template<class TYPE>
@ -169,110 +169,110 @@ void LinkedListIterator<TYPE>::Advance()
template<class TYPE> template<class TYPE>
bool LinkedListIterator<TYPE>::MoreElements() bool LinkedListIterator<TYPE>::MoreElements()
{ {
if (current_element == 0) if (current_element == 0)
return false; return false;
return true; return true;
} }
template<class TYPE> template<class TYPE>
const TYPE& LinkedListIterator<TYPE>::GetData() const TYPE& LinkedListIterator<TYPE>::GetData()
{ {
return current_element->GetData(); return current_element->GetData();
} }
template<class TYPE> template<class TYPE>
void LinkedListIterator<TYPE>::MoveFirst() void LinkedListIterator<TYPE>::MoveFirst()
{ {
ListElement<TYPE>* prev = current_element->GetPrev(); ListElement<TYPE>* prev = current_element->GetPrev();
ListElement<TYPE>* next = current_element->GetNext(); ListElement<TYPE>* next = current_element->GetNext();
if (prev == 0) if (prev == 0)
{ {
return; return;
} }
// if (prev != 0) //if (prev != 0)
// { //{
prev->SetNext(next); prev->SetNext(next);
// } //}
if (next != 0) if (next != 0)
{ {
next->SetPrev(prev); next->SetPrev(prev);
} }
current_element->SetPrev(0); current_element->SetPrev(0);
current_element->SetNext(list.first); current_element->SetNext(list.first);
list.first->SetPrev(current_element); list.first->SetPrev(current_element);
list.first = current_element; list.first = current_element;
} }
template<class TYPE> template<class TYPE>
void LinkedListIterator<TYPE>::MoveLast() void LinkedListIterator<TYPE>::MoveLast()
{ {
ListElement<TYPE>* prev = current_element->GetPrev(); ListElement<TYPE>* prev = current_element->GetPrev();
ListElement<TYPE>* next = current_element->GetNext(); ListElement<TYPE>* next = current_element->GetNext();
if (next == 0) if (next == 0)
{ {
return; return;
} }
if (prev != 0) if (prev != 0)
{ {
prev->SetNext(next); prev->SetNext(next);
} }
else else
{ {
list.first = next; list.first = next;
} }
// if (next != 0) //if (next != 0)
// { //{
next->SetPrev(prev); next->SetPrev(prev);
// } //}
current_element->SetNext(0); current_element->SetNext(0);
current_element->SetPrev(next->GetLast()); current_element->SetPrev(next->GetLast());
next->GetLast()->SetNext(current_element); next->GetLast()->SetNext(current_element);
} }
template<class TYPE> template<class TYPE>
void LinkedListIterator<TYPE>::RemoveCurrent(bool DeleteData) void LinkedListIterator<TYPE>::RemoveCurrent(bool DeleteData)
{ {
ListElement<TYPE>* save; ListElement<TYPE>* save;
if (list.first == current_element) if (list.first == current_element)
{ {
list.first = current_element->GetNext(); list.first = current_element->GetNext();
} }
if (current_element->GetPrev() != 0) if (current_element->GetPrev() != 0)
{ {
current_element->GetPrev()->SetNext(current_element->GetNext()); current_element->GetPrev()->SetNext(current_element->GetNext());
} }
if (current_element->GetNext() != 0) if (current_element->GetNext() != 0)
{ {
current_element->GetNext()->SetPrev(current_element->GetPrev()); current_element->GetNext()->SetPrev(current_element->GetPrev());
} }
if (dir == FORWARD) if (dir == FORWARD)
{ {
save = current_element->GetNext(); save = current_element->GetNext();
} }
else else
{ {
save = current_element->GetPrev(); save = current_element->GetPrev();
} }
current_element->SetNext(0); current_element->SetNext(0);
current_element->SetPrev(0); current_element->SetPrev(0);
if (!DeleteData) if (!DeleteData)
current_element->SetData(0); current_element->SetData(0);
safe_delete(current_element); safe_delete(current_element);
current_element = save; current_element = save;
list.LCount(); list.LCount();
} }
template<class TYPE> template<class TYPE>
void LinkedListIterator<TYPE>::Replace(const TYPE& new_data) void LinkedListIterator<TYPE>::Replace(const TYPE& new_data)
{ {
current_element->ReplaceData(new_data); current_element->ReplaceData(new_data);
} }
template<class TYPE> template<class TYPE>
@ -280,10 +280,10 @@ void LinkedListIterator<TYPE>::Reset()
{ {
if (!(&list)) if (!(&list))
{ {
current_element=0; current_element=0;
return; return;
} }
if (dir == FORWARD) if (dir == FORWARD)
{ {
current_element = list.first; current_element = list.first;
@ -323,15 +323,15 @@ void LinkedListIterator<TYPE>::Reset()
template<class TYPE> template<class TYPE>
void LinkedListIterator<TYPE>::SetDir(direction d) void LinkedListIterator<TYPE>::SetDir(direction d)
{ {
dir = d; dir = d;
} }
template<class TYPE> template<class TYPE>
ListElement<TYPE>::ListElement(const TYPE& d) ListElement<TYPE>::ListElement(const TYPE& d)
{ {
data = d; data = d;
next = 0; next = 0;
prev = 0; prev = 0;
} }
template<class TYPE> template<class TYPE>
@ -353,7 +353,7 @@ template<class TYPE>
void ListElement<TYPE>::ReplaceData(const TYPE& new_data) void ListElement<TYPE>::ReplaceData(const TYPE& new_data)
{ {
if (data != 0) if (data != 0)
safe_delete(data); safe_delete(data);
data = new_data; data = new_data;
} }
@ -388,32 +388,32 @@ void LinkedList<TYPE>::Clear() {
template<class TYPE> 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;
} }
else else
{ {
new_element->SetPrev(first->GetLast()); new_element->SetPrev(first->GetLast());
first->SetLastNext(new_element); first->SetLastNext(new_element);
} }
count++; count++;
} }
template<class TYPE> template<class TYPE>
void LinkedList<TYPE>::Insert(const TYPE& data) void LinkedList<TYPE>::Insert(const TYPE& data)
{ {
ListElement<TYPE>* new_element = new ListElement<TYPE>(data); ListElement<TYPE>* new_element = new ListElement<TYPE>(data);
new_element->SetNext(first); new_element->SetNext(first);
if (first != 0) if (first != 0)
{ {
first->SetPrev(new_element); first->SetPrev(new_element);
} }
first = new_element; first = new_element;
count++; count++;
} }
template<class TYPE> template<class TYPE>

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "logsys.h" #include "logsys.h"
@ -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,25 +97,25 @@ 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"))
enabled = true; enabled = true;
else if(!strcasecmp(value, "off") || !strcasecmp(value, "false") || !strcasecmp(value, "no") || !strcasecmp(value, "disabled") || !strcmp(value, "0")) else if(!strcasecmp(value, "off") || !strcasecmp(value, "false") || !strcasecmp(value, "no") || !strcasecmp(value, "disabled") || !strcmp(value, "0"))
enabled = false; enabled = false;
else { else {
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));
@ -155,6 +155,3 @@ bool load_log_settings(const char *filename) {
return(true); return(true);
} }

View File

@ -1,46 +1,40 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 LOGSYS_H_ #ifndef LOGSYS_H_
#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.
* - clog(TYPE, fmt, ...) - World only. Log a message from a Client:: context, prefixing it with the client's account name. * - clog(TYPE, fmt, ...) - World only. Log a message from a Client:: context, prefixing it with the client's account name.
* - zlog(TYPE, fmt, ...) - World only. Log a message from a ZoneServer:: context, prefixing it with the zones id/name or ip/port. * - zlog(TYPE, fmt, ...) - World only. Log a message from a ZoneServer:: context, prefixing it with the zones id/name or ip/port.
* - _hex(TYPE, data, length) - Log hex dump in any context. * - _hex(TYPE, data, length) - Log hex dump in any context.
* - mhex(TYPE, data, length) - Zone only. Log a hex dump from a Mob:: context, prefixing it with the mob's name * - mhex(TYPE, data, length) - Zone only. Log a hex dump from a Mob:: context, prefixing it with the mob's name
* - _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>
#include "types.h" #include "types.h"
@ -175,13 +169,5 @@ extern void log_toggle(LogType t);
extern bool load_log_settings(const char *filename); extern bool load_log_settings(const char *filename);
#endif /*LOGSYS_H_*/ #endif /*LOGSYS_H_*/

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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
*/ */
#include "debug.h" #include "debug.h"
@ -33,11 +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);
} }

View File

@ -1,23 +1,21 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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 LOG_CATEGORY #ifndef LOG_CATEGORY
#define LOG_CATEGORY(name) #define LOG_CATEGORY(name)
#endif #endif
@ -32,8 +30,6 @@
#endif #endif
LOG_CATEGORY( CHAT ) LOG_CATEGORY( CHAT )
LOG_TYPE( CHAT, SAY, DISABLED ) LOG_TYPE( CHAT, SAY, DISABLED )
LOG_TYPE( CHAT, EMOTE, DISABLED ) LOG_TYPE( CHAT, EMOTE, DISABLED )
@ -189,10 +185,10 @@ LOG_TYPE( CLIENT, NET_IN_TRACE, DISABLED )
LOG_TYPE( CLIENT, EXP, DISABLED ) LOG_TYPE( CLIENT, EXP, DISABLED )
LOG_CATEGORY( SKILLS ) LOG_CATEGORY( SKILLS )
LOG_TYPE( SKILLS, GAIN, DISABLED ) LOG_TYPE( SKILLS, GAIN, DISABLED )
LOG_CATEGORY( RULES ) LOG_CATEGORY( RULES )
LOG_TYPE( RULES, ERROR, DISABLED ) LOG_TYPE( RULES, ERROR, DISABLED )
LOG_TYPE( RULES, CHANGE, DISABLED ) LOG_TYPE( RULES, CHANGE, DISABLED )
LOG_CATEGORY( NET ) LOG_CATEGORY( NET )
@ -260,6 +256,3 @@ LOG_TYPE( WORLD, LAUNCH_TRACE, ENABLED )
#undef LOG_TYPE #undef LOG_TYPE
#undef LOG_CATEGORY #undef LOG_CATEGORY

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2013 EQEMu Development Team (http://eqemu.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 _EQEMU_LOOTTABLE_H #ifndef _EQEMU_LOOTTABLE_H
@ -26,7 +26,7 @@ struct LootTableEntries_Struct {
uint8 droplimit; uint8 droplimit;
uint8 mindrop; uint8 mindrop;
uint8 multiplier; uint8 multiplier;
float probability; float probability;
}; };
struct LootTable_Struct { struct LootTable_Struct {

View File

@ -1,7 +1,7 @@
/* md5.c -- An implementation of Ron Rivest's MD5 message-digest algorithm. /* md5.c -- An implementation of Ron Rivest's MD5 message-digest algorithm.
* Written by Colin Plumb in 1993, no copyright is claimed. This code is in the * Written by Colin Plumb in 1993, no copyright is claimed. This code is in the
* public domain; do with it what you wish. Equivalent code is available from * public domain; do with it what you wish. Equivalent code is available from
* RSA Data Security, Inc. This code does not oblige you to include legal * RSA Data Security, Inc. This code does not oblige you to include legal
* boilerplate in the documentation. To compute the message digest of a string * boilerplate in the documentation. To compute the message digest of a string
* of bytes, declare an MD5Context structure, pass it to MD5Init, call * of bytes, declare an MD5Context structure, pass it to MD5Init, call
* MD5Update as needed on buffers full of bytes, and then call MD5Final, which * MD5Update as needed on buffers full of bytes, and then call MD5Final, which
@ -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;
@ -99,12 +99,12 @@ MD5* MD5::operator= (const MD5* iMD5) {
/* Byte-swap an array of words to little-endian. (Byte-sex independent) */ /* Byte-swap an array of words to little-endian. (Byte-sex independent) */
void MD5::byteSwap(uint32 *buf, uint32 words) { void MD5::byteSwap(uint32 *buf, uint32 words) {
uint8 *p = (uint8 *)buf; uint8 *p = (uint8 *)buf;
do { do {
*buf++ = (uint32)((uint32)p[3]<<8 | p[2]) << 16 | *buf++ = (uint32)((uint32)p[3]<<8 | p[2]) << 16 |
((uint32)p[1]<<8 | p[0]); ((uint32)p[1]<<8 | p[0]);
p += 4; p += 4;
} while (--words); } while (--words);
} }
void MD5::Generate(const uint8* buf, uint32 len, uint8 digest[16]) { void MD5::Generate(const uint8* buf, uint32 len, uint8 digest[16]) {
@ -116,70 +116,70 @@ void MD5::Generate(const uint8* buf, uint32 len, uint8 digest[16]) {
/* Start MD5 accumulation. */ /* Start MD5 accumulation. */
void MD5::Init(struct MD5Context *ctx) { void MD5::Init(struct MD5Context *ctx) {
ctx->hash[0] = 0x67452301; ctx->hash[0] = 0x67452301;
ctx->hash[1] = 0xefcdab89; ctx->hash[1] = 0xefcdab89;
ctx->hash[2] = 0x98badcfe; ctx->hash[2] = 0x98badcfe;
ctx->hash[3] = 0x10325476; ctx->hash[3] = 0x10325476;
ctx->bytes[1] = ctx->bytes[0] = 0; ctx->bytes[1] = ctx->bytes[0] = 0;
} }
/* Update ctx to reflect the addition of another buffer full of bytes. */ /* Update ctx to reflect the addition of another buffer full of bytes. */
void MD5::Update(struct MD5Context *ctx, uint8 const *buf, uint32 len) { void MD5::Update(struct MD5Context *ctx, uint8 const *buf, uint32 len) {
uint32 t = ctx->bytes[0]; uint32 t = ctx->bytes[0];
if ((ctx->bytes[0] = t + len) < t) /* Update 64-bit byte count */ if ((ctx->bytes[0] = t + len) < t) /* Update 64-bit byte count */
ctx->bytes[1]++; /* Carry from low to high */ ctx->bytes[1]++; /* Carry from low to high */
t = 64 - (t & 0x3f); /* Bytes available in ctx->input (>= 1) */ t = 64 - (t & 0x3f); /* Bytes available in ctx->input (>= 1) */
if (t > len) { if (t > len) {
memcpy((uint8*)ctx->input+64-t, buf, len); memcpy((uint8*)ctx->input+64-t, buf, len);
return; return;
} }
/* First chunk is an odd size */ /* First chunk is an odd size */
memcpy((uint8*)ctx->input+64-t, buf, t); memcpy((uint8*)ctx->input+64-t, buf, t);
byteSwap(ctx->input, 16); byteSwap(ctx->input, 16);
Transform(ctx->hash, ctx->input); Transform(ctx->hash, ctx->input);
buf += t; buf += t;
len -= t; len -= t;
/* Process data in 64-byte chunks */ /* Process data in 64-byte chunks */
while (len >= 64) { while (len >= 64) {
memcpy(ctx->input, buf, 64); memcpy(ctx->input, buf, 64);
byteSwap(ctx->input, 16); byteSwap(ctx->input, 16);
Transform(ctx->hash, ctx->input); Transform(ctx->hash, ctx->input);
buf += 64; buf += 64;
len -= 64; len -= 64;
} }
/* Buffer any remaining bytes of data */ /* Buffer any remaining bytes of data */
memcpy(ctx->input, buf, len); memcpy(ctx->input, buf, len);
} }
/* Final wrapup - pad to 64-byte boundary with the bit pattern /* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, LSB-first) */ * 1 0* (64-bit count of bits processed, LSB-first) */
void MD5::Final(uint8 digest[16], MD5Context *ctx) { void MD5::Final(uint8 digest[16], MD5Context *ctx) {
int count = ctx->bytes[0] & 0x3F; /* Bytes mod 64 */ int count = ctx->bytes[0] & 0x3F; /* Bytes mod 64 */
uint8 *p = (uint8*)ctx->input + count; uint8 *p = (uint8*)ctx->input + count;
/* Set the first byte of padding to 0x80. There is always room. */ /* Set the first byte of padding to 0x80. There is always room. */
*p++ = 0x80; *p++ = 0x80;
/* Bytes of zero padding needed to make 56 bytes (-8..55) */ /* Bytes of zero padding needed to make 56 bytes (-8..55) */
count = 56 - 1 - count; count = 56 - 1 - count;
if (count < 0) { /* Padding forces an extra block */ if (count < 0) { /* Padding forces an extra block */
memset(p, 0, count+8); memset(p, 0, count+8);
byteSwap(ctx->input, 16); byteSwap(ctx->input, 16);
Transform(ctx->hash, ctx->input); Transform(ctx->hash, ctx->input);
p = (uint8*)ctx->input; p = (uint8*)ctx->input;
count = 56; count = 56;
} }
memset(p, 0, count); memset(p, 0, count);
byteSwap(ctx->input, 14); byteSwap(ctx->input, 14);
/* Append 8 bytes of length in *bits* and transform */ /* Append 8 bytes of length in *bits* and transform */
ctx->input[14] = ctx->bytes[0] << 3; ctx->input[14] = ctx->bytes[0] << 3;
ctx->input[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29; ctx->input[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
Transform(ctx->hash, ctx->input); Transform(ctx->hash, ctx->input);
byteSwap(ctx->hash, 4); byteSwap(ctx->hash, 4);
memcpy(digest, ctx->hash, 16); memcpy(digest, ctx->hash, 16);
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
} }
/* The four core functions */ /* The four core functions */
@ -194,78 +194,82 @@ void MD5::Final(uint8 digest[16], MD5Context *ctx) {
/* The heart of the MD5 algorithm. */ /* The heart of the MD5 algorithm. */
void MD5::Transform(uint32 hash[4], const uint32 input[16]) { void MD5::Transform(uint32 hash[4], const uint32 input[16]) {
register uint32 a = hash[0], b = hash[1], c = hash[2], d = hash[3]; register uint32 a = hash[0], b = hash[1], c = hash[2], d = hash[3];
MD5STEP(F1, a, b, c, d, input[ 0]+0xd76aa478, 7); MD5STEP(F1, a, b, c, d, input[ 0]+0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, input[ 1]+0xe8c7b756, 12); MD5STEP(F1, d, a, b, c, input[ 1]+0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, input[ 2]+0x242070db, 17); MD5STEP(F1, c, d, a, b, input[ 2]+0x242070db, 17);
MD5STEP(F1, b, c, d, a, input[ 3]+0xc1bdceee, 22); MD5STEP(F1, b, c, d, a, input[ 3]+0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, input[ 4]+0xf57c0faf, 7); MD5STEP(F1, a, b, c, d, input[ 4]+0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, input[ 5]+0x4787c62a, 12); MD5STEP(F1, d, a, b, c, input[ 5]+0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, input[ 6]+0xa8304613, 17); MD5STEP(F1, c, d, a, b, input[ 6]+0xa8304613, 17);
MD5STEP(F1, b, c, d, a, input[ 7]+0xfd469501, 22); MD5STEP(F1, b, c, d, a, input[ 7]+0xfd469501, 22);
MD5STEP(F1, a, b, c, d, input[ 8]+0x698098d8, 7); MD5STEP(F1, a, b, c, d, input[ 8]+0x698098d8, 7);
MD5STEP(F1, d, a, b, c, input[ 9]+0x8b44f7af, 12); MD5STEP(F1, d, a, b, c, input[ 9]+0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, input[10]+0xffff5bb1, 17); MD5STEP(F1, c, d, a, b, input[10]+0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, input[11]+0x895cd7be, 22); MD5STEP(F1, b, c, d, a, input[11]+0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, input[12]+0x6b901122, 7); MD5STEP(F1, a, b, c, d, input[12]+0x6b901122, 7);
MD5STEP(F1, d, a, b, c, input[13]+0xfd987193, 12); MD5STEP(F1, d, a, b, c, input[13]+0xfd987193, 12);
MD5STEP(F1, c, d, a, b, input[14]+0xa679438e, 17); MD5STEP(F1, c, d, a, b, input[14]+0xa679438e, 17);
MD5STEP(F1, b, c, d, a, input[15]+0x49b40821, 22); MD5STEP(F1, b, c, d, a, input[15]+0x49b40821, 22);
MD5STEP(F2, a, b, c, d, input[ 1]+0xf61e2562, 5); MD5STEP(F2, a, b, c, d, input[ 1]+0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, input[ 6]+0xc040b340, 9); MD5STEP(F2, d, a, b, c, input[ 6]+0xc040b340, 9);
MD5STEP(F2, c, d, a, b, input[11]+0x265e5a51, 14); MD5STEP(F2, c, d, a, b, input[11]+0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, input[ 0]+0xe9b6c7aa, 20); MD5STEP(F2, b, c, d, a, input[ 0]+0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, input[ 5]+0xd62f105d, 5); MD5STEP(F2, a, b, c, d, input[ 5]+0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, input[10]+0x02441453, 9); MD5STEP(F2, d, a, b, c, input[10]+0x02441453, 9);
MD5STEP(F2, c, d, a, b, input[15]+0xd8a1e681, 14); MD5STEP(F2, c, d, a, b, input[15]+0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, input[ 4]+0xe7d3fbc8, 20); MD5STEP(F2, b, c, d, a, input[ 4]+0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, input[ 9]+0x21e1cde6, 5); MD5STEP(F2, a, b, c, d, input[ 9]+0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, input[14]+0xc33707d6, 9); MD5STEP(F2, d, a, b, c, input[14]+0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, input[ 3]+0xf4d50d87, 14); MD5STEP(F2, c, d, a, b, input[ 3]+0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, input[ 8]+0x455a14ed, 20); MD5STEP(F2, b, c, d, a, input[ 8]+0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, input[13]+0xa9e3e905, 5); MD5STEP(F2, a, b, c, d, input[13]+0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, input[ 2]+0xfcefa3f8, 9); MD5STEP(F2, d, a, b, c, input[ 2]+0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, input[ 7]+0x676f02d9, 14); MD5STEP(F2, c, d, a, b, input[ 7]+0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, input[12]+0x8d2a4c8a, 20); MD5STEP(F2, b, c, d, a, input[12]+0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, input[ 5]+0xfffa3942, 4); MD5STEP(F3, a, b, c, d, input[ 5]+0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, input[ 8]+0x8771f681, 11); MD5STEP(F3, d, a, b, c, input[ 8]+0x8771f681, 11);
MD5STEP(F3, c, d, a, b, input[11]+0x6d9d6122, 16); MD5STEP(F3, c, d, a, b, input[11]+0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, input[14]+0xfde5380c, 23); MD5STEP(F3, b, c, d, a, input[14]+0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, input[ 1]+0xa4beea44, 4); MD5STEP(F3, a, b, c, d, input[ 1]+0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, input[ 4]+0x4bdecfa9, 11); MD5STEP(F3, d, a, b, c, input[ 4]+0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, input[ 7]+0xf6bb4b60, 16); MD5STEP(F3, c, d, a, b, input[ 7]+0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, input[10]+0xbebfbc70, 23); MD5STEP(F3, b, c, d, a, input[10]+0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, input[13]+0x289b7ec6, 4); MD5STEP(F3, a, b, c, d, input[13]+0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, input[ 0]+0xeaa127fa, 11); MD5STEP(F3, d, a, b, c, input[ 0]+0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, input[ 3]+0xd4ef3085, 16); MD5STEP(F3, c, d, a, b, input[ 3]+0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, input[ 6]+0x04881d05, 23); MD5STEP(F3, b, c, d, a, input[ 6]+0x04881d05, 23);
MD5STEP(F3, a, b, c, d, input[ 9]+0xd9d4d039, 4); MD5STEP(F3, a, b, c, d, input[ 9]+0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, input[12]+0xe6db99e5, 11); MD5STEP(F3, d, a, b, c, input[12]+0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, input[15]+0x1fa27cf8, 16); MD5STEP(F3, c, d, a, b, input[15]+0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, input[ 2]+0xc4ac5665, 23); MD5STEP(F3, b, c, d, a, input[ 2]+0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, input[ 0]+0xf4292244, 6); MD5STEP(F4, a, b, c, d, input[ 0]+0xf4292244, 6);
MD5STEP(F4, d, a, b, c, input[ 7]+0x432aff97, 10); MD5STEP(F4, d, a, b, c, input[ 7]+0x432aff97, 10);
MD5STEP(F4, c, d, a, b, input[14]+0xab9423a7, 15); MD5STEP(F4, c, d, a, b, input[14]+0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, input[ 5]+0xfc93a039, 21); MD5STEP(F4, b, c, d, a, input[ 5]+0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, input[12]+0x655b59c3, 6); MD5STEP(F4, a, b, c, d, input[12]+0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, input[ 3]+0x8f0ccc92, 10); MD5STEP(F4, d, a, b, c, input[ 3]+0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, input[10]+0xffeff47d, 15); MD5STEP(F4, c, d, a, b, input[10]+0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, input[ 1]+0x85845dd1, 21); MD5STEP(F4, b, c, d, a, input[ 1]+0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, input[ 8]+0x6fa87e4f, 6); MD5STEP(F4, a, b, c, d, input[ 8]+0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, input[15]+0xfe2ce6e0, 10); MD5STEP(F4, d, a, b, c, input[15]+0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, input[ 6]+0xa3014314, 15); MD5STEP(F4, c, d, a, b, input[ 6]+0xa3014314, 15);
MD5STEP(F4, b, c, d, a, input[13]+0x4e0811a1, 21); MD5STEP(F4, b, c, d, a, input[13]+0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, input[ 4]+0xf7537e82, 6); MD5STEP(F4, a, b, c, d, input[ 4]+0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, input[11]+0xbd3af235, 10); MD5STEP(F4, d, a, b, c, input[11]+0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, input[ 2]+0x2ad7d2bb, 15); MD5STEP(F4, c, d, a, b, input[ 2]+0x2ad7d2bb, 15);
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;
}

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