Change space indentation to tabs

This commit is contained in:
j883376 2013-05-09 10:44:08 -04:00
parent ffcff4aea1
commit 4bdd8b2502
393 changed files with 22463 additions and 23238 deletions

View File

@ -15,96 +15,96 @@ 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)
#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
@ -116,22 +116,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)
@ -142,30 +142,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,13 +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);
} }
} }
@ -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));
@ -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

@ -2,13 +2,14 @@
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"
@ -31,14 +31,14 @@
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);
} }

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"
@ -73,6 +73,3 @@ Const_char *EQDB::escape_string(Const_char *from) {
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_

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"
@ -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_

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>

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 EQEMuError_H #ifndef EQEMuError_H
#define EQEMuError_H #define EQEMuError_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 "../common/debug.h" #include "../common/debug.h"
#include "EQEmuConfig.h" #include "EQEmuConfig.h"
@ -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

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
*/ */
/* /*
* 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; int status;
struct sockaddr_in from; struct sockaddr_in from;
unsigned int fromlen; unsigned int fromlen;
from.sin_family = AF_INET; from.sin_family = AF_INET;
fromlen = sizeof(from); fromlen = sizeof(from);
while (1) { while (1) {
#ifdef WIN32 #ifdef WIN32
@ -285,7 +285,7 @@ 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;

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,8 +35,8 @@
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)
{ {
} }
@ -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);
@ -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
@ -103,13 +103,13 @@ class EQApplicationPacket : public EQPacket {
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; }

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>
@ -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);
@ -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);
@ -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
@ -686,7 +686,7 @@ deque<EQProtocolPacket *>::iterator sitr;
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()) {
@ -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 {
@ -1448,6 +1448,3 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
return(res); return(res);
} }

View File

@ -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
@ -167,7 +167,7 @@ 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.
@ -264,9 +264,9 @@ class EQStream : public EQStreamInterface {
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,
@ -277,5 +277,5 @@ class EQStream : public EQStreamInterface {
}; };
#endif #endif

View File

@ -56,7 +56,7 @@ ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
} }
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;
@ -314,7 +314,6 @@ Timer DecayTimer(20);
(*cur)->ReleaseFromUse(); (*cur)->ReleaseFromUse();
} }
Sleep(10); Sleep(10);
MStreams.lock(); MStreams.lock();
@ -328,20 +327,3 @@ Timer DecayTimer(20);
} }
} }

View File

@ -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"
@ -158,42 +157,8 @@ EQStreamInterface *EQStreamIdentifier::PopIdentified() {
} }
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

@ -30,7 +30,7 @@ protected:
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;
}; };

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
@ -170,6 +170,4 @@ 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);

View File

@ -35,21 +35,12 @@ public:
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;
@ -97,9 +77,9 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_s
//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) {
@ -473,7 +452,6 @@ void EmuTCPConnection::ClearBuffers() {
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;
@ -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) {
@ -842,14 +820,3 @@ bool EmuTCPConnection::RecvData(char* errbuf) {
return(true); return(true);
} }

View File

@ -49,7 +49,7 @@ public:
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; }

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

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
*/ */
#ifdef _WINDOWS #ifdef _WINDOWS
@ -172,12 +172,12 @@ ItemInst::ItemInst(const ItemInst& copy)
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
} }
std::map<std::string, std::string>::const_iterator iter; std::map<std::string, std::string>::const_iterator iter;
for (iter = copy.m_custom_data.begin(); iter != copy.m_custom_data.end(); iter++) { for (iter = copy.m_custom_data.begin(); iter != copy.m_custom_data.end(); iter++) {
m_custom_data[iter->first] = iter->second; m_custom_data[iter->first] = iter->second;
} }
m_SerialNumber = copy.m_SerialNumber; m_SerialNumber = copy.m_SerialNumber;
m_custom_data = copy.m_custom_data; m_custom_data = copy.m_custom_data;
} }
// Clean up container contents // Clean up container contents
@ -316,9 +316,9 @@ bool ItemInst::IsAmmo() const {
if(!m_item) return false; if(!m_item) return false;
if((m_item->ItemType == ItemTypeArrow) || if((m_item->ItemType == ItemTypeArrow) ||
(m_item->ItemType == ItemTypeThrowing) || (m_item->ItemType == ItemTypeThrowing) ||
(m_item->ItemType == ItemTypeThrowingv2)) (m_item->ItemType == ItemTypeThrowingv2))
return true; return true;
return false; return false;
@ -579,64 +579,64 @@ ItemInst* Inventory::GetItem(int16 slot_id) const
} }
std::string ItemInst::GetCustomDataString() const { std::string ItemInst::GetCustomDataString() const {
std::string ret_val; std::string ret_val;
map<std::string, std::string>::const_iterator iter = m_custom_data.begin(); map<std::string, std::string>::const_iterator iter = m_custom_data.begin();
while(iter != m_custom_data.end()) { while(iter != m_custom_data.end()) {
if(ret_val.length() > 0) { if(ret_val.length() > 0) {
ret_val += "^"; ret_val += "^";
} }
ret_val += iter->first; ret_val += iter->first;
ret_val += "^"; ret_val += "^";
ret_val += iter->second; ret_val += iter->second;
iter++; iter++;
if(ret_val.length() > 0) { if(ret_val.length() > 0) {
ret_val += "^"; ret_val += "^";
} }
} }
return ret_val; return ret_val;
} }
void ItemInst::SetCustomData(std::string identifier, std::string value) { void ItemInst::SetCustomData(std::string identifier, std::string value) {
DeleteCustomData(identifier); DeleteCustomData(identifier);
m_custom_data[identifier] = value; m_custom_data[identifier] = value;
} }
void ItemInst::SetCustomData(std::string identifier, int value) { void ItemInst::SetCustomData(std::string identifier, int value) {
DeleteCustomData(identifier); DeleteCustomData(identifier);
std::stringstream ss; std::stringstream ss;
ss << value; ss << value;
m_custom_data[identifier] = ss.str(); m_custom_data[identifier] = ss.str();
} }
void ItemInst::SetCustomData(std::string identifier, float value) { void ItemInst::SetCustomData(std::string identifier, float value) {
DeleteCustomData(identifier); DeleteCustomData(identifier);
std::stringstream ss; std::stringstream ss;
ss << value; ss << value;
m_custom_data[identifier] = ss.str(); m_custom_data[identifier] = ss.str();
} }
void ItemInst::SetCustomData(std::string identifier, bool value) { void ItemInst::SetCustomData(std::string identifier, bool value) {
DeleteCustomData(identifier); DeleteCustomData(identifier);
std::stringstream ss; std::stringstream ss;
ss << value; ss << value;
m_custom_data[identifier] = ss.str(); m_custom_data[identifier] = ss.str();
} }
void ItemInst::DeleteCustomData(std::string identifier) { void ItemInst::DeleteCustomData(std::string identifier) {
map<std::string, std::string>::iterator iter = m_custom_data.find(identifier); map<std::string, std::string>::iterator iter = m_custom_data.find(identifier);
if(iter != m_custom_data.end()) { if(iter != m_custom_data.end()) {
m_custom_data.erase(iter); m_custom_data.erase(iter);
} }
} }
std::string ItemInst::GetCustomData(std::string identifier) { std::string ItemInst::GetCustomData(std::string identifier) {
map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier); map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier);
if(iter != m_custom_data.end()) { if(iter != m_custom_data.end()) {
return iter->second; return iter->second;
} }
return ""; return "";
} }
// Retrieve item at specified position within bag // Retrieve item at specified position within bag
@ -857,7 +857,7 @@ bool Inventory::HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity) {
InvItem = GetItem(BaseSlotID + BagSlot); InvItem = GetItem(BaseSlotID + BagSlot);
if(InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) && if(InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) &&
(InvItem->GetCharges() < InvItem->GetItem()->StackSize)) { (InvItem->GetCharges() < InvItem->GetItem()->StackSize)) {
int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges(); int ChargeSlotsLeft = InvItem->GetItem()->StackSize - InvItem->GetCharges();
@ -940,17 +940,17 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
// If there are no charges left on the item, // If there are no charges left on the item,
if(item_to_delete->GetCharges() <= 0) { if(item_to_delete->GetCharges() <= 0) {
// If the item is stackable (e.g arrows), or // If the item is stackable (e.g arrows), or
// the item is not stackable, and is not a charged item, or is expendable, delete it // the item is not stackable, and is not a charged item, or is expendable, delete it
if(item_to_delete->IsStackable() || if(item_to_delete->IsStackable() ||
(!item_to_delete->IsStackable() && (!item_to_delete->IsStackable() &&
((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable()))) { ((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable()))) {
// Item can now be destroyed // Item can now be destroyed
safe_delete(item_to_delete); safe_delete(item_to_delete);
return true; return true;
} }
} }
// Charges still exist, or it is a charged item that is not expendable. Put back into inventory // Charges still exist, or it is a charged item that is not expendable. Put back into inventory
_PutItem(slot_id, item_to_delete); _PutItem(slot_id, item_to_delete);
return false; return false;
} }
@ -963,7 +963,7 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity)
// Checks All items in a bag for No Drop // Checks All items in a bag for No Drop
bool Inventory::CheckNoDrop(int16 slot_id) { bool Inventory::CheckNoDrop(int16 slot_id) {
ItemInst* inst = GetItem(slot_id); ItemInst* inst = GetItem(slot_id);
if (!inst) return false; if (!inst) return false;
if (!inst->GetItem()->NoDrop) return true; if (!inst->GetItem()->NoDrop) return true;
if (inst->GetItem()->ItemClass == 1) { if (inst->GetItem()->ItemClass == 1) {
@ -1700,10 +1700,10 @@ EvoItemInst::EvoItemInst(const EvoItemInst &copy) {
m_contents[it->first] = inst_new; m_contents[it->first] = inst_new;
} }
} }
std::map<std::string, std::string>::const_iterator iter; std::map<std::string, std::string>::const_iterator iter;
for (iter = copy.m_custom_data.begin(); iter != copy.m_custom_data.end(); iter++) { for (iter = copy.m_custom_data.begin(); iter != copy.m_custom_data.end(); iter++) {
m_custom_data[iter->first] = iter->second; m_custom_data[iter->first] = iter->second;
} }
m_SerialNumber = copy.m_SerialNumber; m_SerialNumber = copy.m_SerialNumber;
m_exp = copy.m_exp; m_exp = copy.m_exp;
m_evolveLvl = copy.m_evolveLvl; m_evolveLvl = copy.m_evolveLvl;
@ -1742,10 +1742,10 @@ EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
} }
} }
std::map<std::string, std::string>::const_iterator iter; std::map<std::string, std::string>::const_iterator iter;
for (iter = copy->m_custom_data.begin(); iter != copy->m_custom_data.end(); iter++) { for (iter = copy->m_custom_data.begin(); iter != copy->m_custom_data.end(); iter++) {
m_custom_data[iter->first] = iter->second; m_custom_data[iter->first] = iter->second;
} }
m_SerialNumber = copy->m_SerialNumber; m_SerialNumber = copy->m_SerialNumber;
m_exp = 0; m_exp = 0;
m_evolveLvl = 0; m_evolveLvl = 0;
@ -1924,9 +1924,9 @@ bool Item_Struct::IsEquipable(uint16 Race, uint16 Class_) const
{ {
if (Classes_ % 2 == 1) if (Classes_ % 2 == 1)
{ {
if (CurrentClass == Class_) if (CurrentClass == Class_)
{ {
IsClass = true; IsClass = true;
break; break;
} }
} }
@ -1939,11 +1939,11 @@ bool Item_Struct::IsEquipable(uint16 Race, uint16 Class_) const
{ {
if (Races_ % 2 == 1) if (Races_ % 2 == 1)
{ {
if (CurrentRace == Race_) if (CurrentRace == Race_)
{ {
IsRace = true; IsRace = true;
break; break;
} }
} }
Races_ >>= 1; Races_ >>= 1;
} }

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,
@ -113,7 +113,7 @@ public:
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:
///////////////////////// /////////////////////////
@ -199,10 +199,10 @@ public:
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
@ -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,13 +348,13 @@ 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); }
@ -379,8 +379,8 @@ 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;
@ -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 {

View File

@ -643,9 +643,8 @@ uint8 MaxSkillTable(uint16 skillid, uint16 race, uint16 eqclass, uint16 level) {
// Melee // Melee
case MONK: case MONKGM:{ case MONK: case MONKGM:{
// 1 252 252 // 1 252 252
r_value = level*7; // This can't be right can it? r_value = level*7; // This can't be right can it?
break break;
;
} }
case WARRIOR: case WARRIORGM: case WARRIOR: case WARRIORGM:
case ROGUE: case ROGUEGM: { case ROGUE: case ROGUEGM: {
@ -1894,7 +1893,7 @@ uint8 MaxSkillTable(uint16 skillid, uint16 race, uint16 eqclass, uint16 level) {
break; break;
} }
} // end switch (skillid) } // end switch (skillid)
// NO skill may go over 252 // NO skill may go over 252
if (r_value > 252) if (r_value > 252)
r_value = 252; r_value = 252;
return r_value; return r_value;

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
@ -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
@ -556,7 +556,7 @@ char *CleanMobName(const char *in, char *out)
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,7 +32,7 @@
// 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; }
@ -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"

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"
@ -145,7 +145,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
// 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
@ -178,15 +178,15 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
} }
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);
@ -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_
@ -65,25 +65,18 @@ public:
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);
@ -96,29 +89,5 @@ private:
#endif #endif
}; };
#endif /*PROCLAUNCHER_H_*/ #endif /*PROCLAUNCHER_H_*/

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
@ -539,7 +539,7 @@ bool TCPConnection::Process() {
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;
@ -585,7 +585,7 @@ bool TCPConnection::Process() {
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;
@ -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)) {
@ -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
@ -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;
@ -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;
@ -230,4 +224,3 @@ bool BaseTCPServer::IsOpen() {
return ret; return ret;
} }

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"
@ -49,15 +49,15 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
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 {

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,8 +29,8 @@ 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);
@ -54,6 +54,3 @@ protected:
#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
@ -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,41 +1,41 @@
/* 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

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

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

@ -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 "../common/rulesys.h" #include "../common/rulesys.h"
@ -56,7 +56,7 @@ server after the world server, or inbetween zones when that is finished
/* /*
Establish a connection to a mysql database with the supplied parameters Establish a connection to a mysql database with the supplied parameters
Added a very simple .ini file parser - Bounce Added a very simple .ini file parser - Bounce
Modify to use for win32 & linux - misanthropicfiend Modify to use for win32 & linux - misanthropicfiend
*/ */
@ -158,9 +158,9 @@ Zero will also be returned if there is a database error.
*/ */
uint32 Database::CheckLogin(const char* name, const char* password, int16* oStatus) { uint32 Database::CheckLogin(const char* name, const char* password, int16* oStatus) {
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(strlen(name) >= 50 || strlen(password) >= 50) if(strlen(name) >= 50 || strlen(password) >= 50)
return(0); return(0);
@ -202,50 +202,50 @@ uint32 Database::CheckLogin(const char* name, const char* password, int16* oStat
} }
//Lieka: Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table. //Lieka: Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table.
bool Database::CheckBannedIPs(const char* loginIP) bool Database::CheckBannedIPs(const char* loginIP)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
//cout << "Checking against Banned IPs table."<< endl; //Lieka: Debugging //cout << "Checking against Banned IPs table."<< endl; //Lieka: Debugging
if (RunQuery(query, MakeAnyLenString(&query, "SELECT ip_address FROM Banned_IPs WHERE ip_address='%s'", loginIP), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT ip_address FROM Banned_IPs WHERE ip_address='%s'", loginIP), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) != 0) if (mysql_num_rows(result) != 0)
{ {
//cout << loginIP << " was present in the banned IPs table" << endl; //Lieka: Debugging //cout << loginIP << " was present in the banned IPs table" << endl; //Lieka: Debugging
mysql_free_result(result); mysql_free_result(result);
return true; return true;
} }
else else
{ {
//cout << loginIP << " was not present in the banned IPs table." << endl; //Lieka: Debugging //cout << loginIP << " was not present in the banned IPs table." << endl; //Lieka: Debugging
mysql_free_result(result); mysql_free_result(result);
return false; return false;
} }
mysql_free_result(result); mysql_free_result(result);
} }
else else
{ {
cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << endl; cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << endl;
safe_delete_array(query); safe_delete_array(query);
return true; return true;
} }
return true; return true;
} }
bool Database::AddBannedIP(char* bannedIP, const char* notes) bool Database::AddBannedIP(char* bannedIP, const char* notes)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes), errbuf)) { if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes), errbuf)) {
cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl; cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl;
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
safe_delete_array(query); safe_delete_array(query);
return true; return true;
} }
//End Lieka Edit //End Lieka Edit
@ -287,12 +287,12 @@ bool Database::AddGMIP(char* ip_address, char* name) {
void Database::LoginIP(uint32 AccountID, const char* LoginIP) void Database::LoginIP(uint32 AccountID, const char* LoginIP)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP), errbuf)) { if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP), errbuf)) {
cerr << "Error in Log IP query '" << query << "' " << errbuf << endl; cerr << "Error in Log IP query '" << query << "' " << errbuf << endl;
} }
safe_delete_array(query); safe_delete_array(query);
} }
int16 Database::CheckStatus(uint32 account_id) int16 Database::CheckStatus(uint32 account_id)
@ -303,7 +303,7 @@ int16 Database::CheckStatus(uint32 account_id)
MYSQL_ROW row; MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT `status`, UNIX_TIMESTAMP(`suspendeduntil`) as `suspendeduntil`, UNIX_TIMESTAMP() as `current`" if (RunQuery(query, MakeAnyLenString(&query, "SELECT `status`, UNIX_TIMESTAMP(`suspendeduntil`) as `suspendeduntil`, UNIX_TIMESTAMP() as `current`"
" FROM `account` WHERE `id` = %i", account_id), errbuf, &result)) " FROM `account` WHERE `id` = %i", account_id), errbuf, &result))
{ {
safe_delete_array(query); safe_delete_array(query);
@ -343,7 +343,7 @@ int16 Database::CheckStatus(uint32 account_id)
uint32 Database::CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id) { uint32 Database::CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
uint32 querylen; uint32 querylen;
uint32 last_insert_id; uint32 last_insert_id;
@ -370,7 +370,7 @@ uint32 Database::CreateAccount(const char* name, const char* password, int16 sta
bool Database::DeleteAccount(const char* name) { bool Database::DeleteAccount(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;
cerr << "Account Attempting to be deleted:" << name << endl; cerr << "Account Attempting to be deleted:" << name << endl;
@ -391,7 +391,7 @@ bool Database::DeleteAccount(const char* name) {
bool Database::SetLocalPassword(uint32 accid, const char* password) { bool Database::SetLocalPassword(uint32 accid, const char* password) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET password=MD5('%s') where id=%i;", password, accid), errbuf)) { if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET password=MD5('%s') where id=%i;", password, accid), errbuf)) {
cerr << "Error in SetLocalPassword query '" << query << "' " << errbuf << endl; cerr << "Error in SetLocalPassword query '" << query << "' " << errbuf << endl;
@ -426,7 +426,7 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
bool Database::ReserveName(uint32 account_id, char* name) bool Database::ReserveName(uint32 account_id, char* name)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=NULL", account_id, name), errbuf)) { if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into character_ SET account_id=%i, name='%s', profile=NULL", account_id, name), errbuf)) {
cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl; cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl;
@ -651,34 +651,34 @@ bool Database::DeleteCharacter(char *name)
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" keyring"); printf(" keyring");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM keyring WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM keyring WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = nullptr; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" factions"); printf(" factions");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM faction_values WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM faction_values WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = nullptr; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" instances"); printf(" instances");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM instance_lockout_player WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM instance_lockout_player WHERE charid='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = nullptr; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" _character"); printf(" _character");
@ -696,14 +696,14 @@ bool Database::DeleteCharacter(char *name)
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf(" alternate currency"); printf(" alternate currency");
#endif #endif
RunQuery(query, MakeAnyLenString(&query, "DELETE FROM character_alt_currency WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows); RunQuery(query, MakeAnyLenString(&query, "DELETE FROM character_alt_currency WHERE char_id='%d'", charid), errbuf, nullptr, &affected_rows);
if(query) if(query)
{ {
safe_delete_array(query); safe_delete_array(query);
query = nullptr; query = nullptr;
} }
#if DEBUG >= 5 #if DEBUG >= 5
printf("\n"); printf("\n");
@ -744,7 +744,7 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inven
errbuf, errbuf,
&result &result
)) { )) {
safe_delete_array(charidquery); safe_delete_array(charidquery);
LogFile->write(EQEMuLog::Error, "Error in char store id query: %s: %s", charidquery, errbuf); LogFile->write(EQEMuLog::Error, "Error in char store id query: %s: %s", charidquery, errbuf);
return(false); return(false);
} }
@ -816,15 +816,15 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inven
RunQuery(invquery, strlen(invquery), errbuf, 0, &affected_rows); RunQuery(invquery, strlen(invquery), errbuf, 0, &affected_rows);
if(!affected_rows) if(!affected_rows)
{ {
LogFile->write(EQEMuLog::Error, "StoreCharacter inventory failed. Query '%s' %s", invquery, errbuf); LogFile->write(EQEMuLog::Error, "StoreCharacter inventory failed. Query '%s' %s", invquery, errbuf);
} }
#if EQDEBUG >= 9 #if EQDEBUG >= 9
else else
{ {
LogFile->write(EQEMuLog::Debug, "StoreCharacter inventory succeeded. Query '%s' %s", invquery, errbuf); LogFile->write(EQEMuLog::Debug, "StoreCharacter inventory succeeded. Query '%s' %s", invquery, errbuf);
} }
#endif #endif
safe_delete_array(invquery); safe_delete_array(invquery);
} }
if(i==30){ //end of standard inventory/cursor, jump to internals of bags/cursor if(i==30){ //end of standard inventory/cursor, jump to internals of bags/cursor
@ -859,9 +859,9 @@ Zero will also be returned if there is a database error.
*/ */
uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) { uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
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 account_id, id FROM character_ WHERE name='%s'", charname), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT account_id, id FROM character_ WHERE name='%s'", charname), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
@ -887,9 +887,9 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
// Retrieve account_id for a given char_id // Retrieve account_id for a given char_id
uint32 Database::GetAccountIDByChar(uint32 char_id) { uint32 Database::GetAccountIDByChar(uint32 char_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;
uint32 ret = 0; uint32 ret = 0;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT account_id FROM character_ WHERE id=%i", char_id), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT account_id FROM character_ WHERE id=%i", char_id), errbuf, &result)) {
@ -909,9 +909,9 @@ uint32 Database::GetAccountIDByChar(uint32 char_id) {
uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32* lsid) { uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32* lsid) {
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;
for (unsigned int i=0; i<strlen(accname); i++) { for (unsigned int i=0; i<strlen(accname); i++) {
@ -949,9 +949,9 @@ uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32*
void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID) { void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID) {
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, lsaccount_id FROM account WHERE id='%i'", accountid), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT name, lsaccount_id FROM account WHERE id='%i'", accountid), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
@ -974,9 +974,9 @@ void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID
void Database::GetCharName(uint32 char_id, char* name) { void Database::GetCharName(uint32 char_id, char* name) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT name FROM character_ WHERE id='%i'", char_id), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT name FROM character_ WHERE id='%i'", char_id), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
@ -997,8 +997,8 @@ void Database::GetCharName(uint32 char_id, char* name) {
bool Database::LoadVariables() { bool Database::LoadVariables() {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
if (RunQuery(query, LoadVariables_MQ(&query), errbuf, &result)) { if (RunQuery(query, LoadVariables_MQ(&query), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
@ -1021,7 +1021,7 @@ uint32 Database::LoadVariables_MQ(char** query) {
bool Database::LoadVariables_result(MYSQL_RES* result) { bool Database::LoadVariables_result(MYSQL_RES* result) {
uint32 i; uint32 i;
MYSQL_ROW row; MYSQL_ROW row;
LockMutex lock(&Mvarcache); LockMutex lock(&Mvarcache);
if (mysql_num_rows(result) > 0) { if (mysql_num_rows(result) > 0) {
if (!varcache_array) { if (!varcache_array) {
@ -1099,7 +1099,7 @@ bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_
bool Database::SetVariable(const char* varname_in, const char* varvalue_in) { bool Database::SetVariable(const char* varname_in, const char* varvalue_in) {
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 *varname,*varvalue; char *varname,*varvalue;
@ -1140,8 +1140,8 @@ bool Database::SetVariable(const char* varname_in, const char* varvalue_in) {
uint32 Database::GetMiniLoginAccount(char* ip){ uint32 Database::GetMiniLoginAccount(char* ip){
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 retid = 0; uint32 retid = 0;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM account WHERE minilogin_ip='%s'", ip), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM account WHERE minilogin_ip='%s'", ip), errbuf, &result)) {
@ -1161,11 +1161,11 @@ uint32 Database::GetMiniLoginAccount(char* ip){
// Pyro: Get zone starting points from DB // Pyro: Get zone starting points from DB
bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe_x, float* safe_y, float* safe_z, int16* minstatus, uint8* minlevel, char *flag_needed) { bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe_x, float* safe_y, float* safe_z, int16* minstatus, uint8* minlevel, char *flag_needed) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
// int buf_len = 256; // int buf_len = 256;
// int chars = -1; // int chars = -1;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, if (RunQuery(query, MakeAnyLenString(&query,
"SELECT safe_x, safe_y, safe_z, min_status, min_level, " "SELECT safe_x, safe_y, safe_z, min_status, min_level, "
@ -1208,9 +1208,9 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe
bool Database::GetZoneLongName(const char* short_name, char** long_name, char* file_name, float* safe_x, float* safe_y, float* safe_z, uint32* graveyard_id, uint32* maxclients) { bool Database::GetZoneLongName(const char* short_name, char** long_name, char* file_name, float* safe_x, float* safe_y, float* safe_z, uint32* graveyard_id, uint32* maxclients) {
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 long_name, file_name, safe_x, safe_y, safe_z, graveyard_id, maxclients FROM zone WHERE short_name='%s' AND version=0", short_name), errbuf, &result)) if (RunQuery(query, MakeAnyLenString(&query, "SELECT long_name, file_name, safe_x, safe_y, safe_z, graveyard_id, maxclients FROM zone WHERE short_name='%s' AND version=0", short_name), errbuf, &result))
{ {
@ -1252,10 +1252,10 @@ bool Database::GetZoneLongName(const char* short_name, char** long_name, char* f
} }
uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) { uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) {
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 GraveyardID = 0; uint32 GraveyardID = 0;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT graveyard_id FROM zone WHERE zoneidnumber='%u' AND (version=%i OR version=0) ORDER BY version DESC", zone_id, version), errbuf, &result)) if (RunQuery(query, MakeAnyLenString(&query, "SELECT graveyard_id FROM zone WHERE zoneidnumber='%u' AND (version=%i OR version=0) ORDER BY version DESC", zone_id, version), errbuf, &result))
{ {
@ -1277,9 +1277,9 @@ uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) {
bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid, float* graveyard_x, float* graveyard_y, float* graveyard_z, float* graveyard_heading) { bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid, float* graveyard_x, float* graveyard_y, float* graveyard_z, float* graveyard_heading) {
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 zone_id, x, y, z, heading FROM graveyard WHERE id=%i", graveyard_id), errbuf, &result)) if (RunQuery(query, MakeAnyLenString(&query, "SELECT zone_id, x, y, z, heading FROM graveyard WHERE id=%i", graveyard_id), errbuf, &result))
{ {
@ -1313,9 +1313,9 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon
bool Database::LoadZoneNames() { bool Database::LoadZoneNames() {
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(zoneidnumber) FROM zone"); strcpy(query, "SELECT MAX(zoneidnumber) FROM zone");
@ -1381,15 +1381,15 @@ const char* Database::GetZoneName(uint32 zoneID, bool ErrorUnknown) {
} }
if (zoneID <= max_zonename) { if (zoneID <= max_zonename) {
if (zonename_array[zoneID]) if (zonename_array[zoneID])
return zonename_array[zoneID]; return zonename_array[zoneID];
else { else {
if (ErrorUnknown) if (ErrorUnknown)
return "UNKNOWN"; return "UNKNOWN";
else else
return 0; return 0;
} }
} }
else { else {
if (ErrorUnknown) if (ErrorUnknown)
return "UNKNOWN"; return "UNKNOWN";
@ -1401,8 +1401,8 @@ const char* Database::GetZoneName(uint32 zoneID, bool ErrorUnknown) {
uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
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;
int peqzone = 0; int peqzone = 0;
@ -1512,7 +1512,7 @@ bool Database::CheckNameFilter(const char* name, bool surname)
bool Database::AddToNameFilter(const char* name) { bool Database::AddToNameFilter(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;
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO name_filter (name) values ('%s')", name), errbuf, 0, &affected_rows)) { if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO name_filter (name) values ('%s')", name), errbuf, 0, &affected_rows)) {
@ -1532,9 +1532,9 @@ bool Database::AddToNameFilter(const char* name) {
uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* oStatus) { uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* oStatus) {
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, name, status FROM account WHERE lsaccount_id=%i", iLSID), errbuf, &result)) if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, name, status FROM account WHERE lsaccount_id=%i", iLSID), errbuf, &result))
{ {
@ -1567,9 +1567,9 @@ uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* o
void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) { void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
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, status FROM account WHERE id=%i", id), errbuf, &result)) if (RunQuery(query, MakeAnyLenString(&query, "SELECT name, status FROM account WHERE id=%i", id), errbuf, &result))
{ {
@ -1589,7 +1589,7 @@ void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
void Database::ClearMerchantTemp(){ void Database::ClearMerchantTemp(){
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "delete from merchantlist_temp"), errbuf)) { if (!RunQuery(query, MakeAnyLenString(&query, "delete from merchantlist_temp"), errbuf)) {
cerr << "Error in ClearMerchantTemp query '" << query << "' " << errbuf << endl; cerr << "Error in ClearMerchantTemp query '" << query << "' " << errbuf << endl;
@ -1599,7 +1599,7 @@ void Database::ClearMerchantTemp(){
bool Database::UpdateName(const char* oldname, const char* newname) { bool Database::UpdateName(const char* oldname, const char* newname) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
uint32 affected_rows = 0; uint32 affected_rows = 0;
cout << "Renaming " << oldname << " to " << newname << "..." << endl; cout << "Renaming " << oldname << " to " << newname << "..." << endl;
@ -1622,7 +1622,7 @@ bool Database::CheckUsedName(const char* name)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
//if (strlen(name) > 15) //if (strlen(name) > 15)
// return false; // return false;
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM character_ where name='%s'", name), errbuf, &result)) { if (!RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM character_ where name='%s'", name), errbuf, &result)) {
@ -1634,7 +1634,7 @@ bool Database::CheckUsedName(const char* name)
safe_delete_array(query); safe_delete_array(query);
uint32 tmp = mysql_num_rows(result); uint32 tmp = mysql_num_rows(result);
mysql_free_result(result); mysql_free_result(result);
if (tmp > 0) // There is a Name! No change (Return False) if (tmp > 0) // There is a Name! No change (Return False)
return false; return false;
else // Everything is okay, so we go and do this. else // Everything is okay, so we go and do this.
return true; return true;
@ -1749,15 +1749,15 @@ uint8 Database::CopyCharacter(const char* oldname, const char* newname, uint32 a
char* end=query2; char* end=query2;
end += sprintf(end, "INSERT INTO character_ SET zonename=\'%s\', x = %f, y = %f, z = %f, profile=\'", GetZoneName(pp->zone_id), pp->x, pp->y, pp->z); end += sprintf(end, "INSERT INTO character_ SET zonename=\'%s\', x = %f, y = %f, z = %f, profile=\'", GetZoneName(pp->zone_id), pp->x, pp->y, pp->z);
end += DoEscapeString(end, (char*) pp, sizeof(PlayerProfile_Struct)); end += DoEscapeString(end, (char*) pp, sizeof(PlayerProfile_Struct));
end += sprintf(end,"\', extprofile=\'"); end += sprintf(end,"\', extprofile=\'");
end += DoEscapeString(end, (char*) ext, sizeof(ExtendedProfile_Struct)); end += DoEscapeString(end, (char*) ext, sizeof(ExtendedProfile_Struct));
end += sprintf(end, "\', account_id=%d, name='%s'", acctid, newname); end += sprintf(end, "\', account_id=%d, name='%s'", acctid, newname);
if (!RunQuery(query2, (uint32) (end - query2), errbuf, 0, &affected_rows)) { if (!RunQuery(query2, (uint32) (end - query2), errbuf, 0, &affected_rows)) {
cerr << "Error in CopyCharacter query '" << query << "' " << errbuf << endl; cerr << "Error in CopyCharacter query '" << query << "' " << errbuf << endl;
return 0; return 0;
} }
// @merth: Need to copy inventory as well (and shared bank?) // @merth: Need to copy inventory as well (and shared bank?)
if (affected_rows == 0) { if (affected_rows == 0) {
@ -1884,9 +1884,9 @@ uint8 Database::GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16
uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZoneID, uint32* oInstanceID, float* oX, float* oY, float* oZ) { uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZoneID, uint32* oInstanceID, float* oX, float* oY, float* oZ) {
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, account_id, zonename, instanceid, x, y, z FROM character_ WHERE name='%s'", iName), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, account_id, zonename, instanceid, x, y, z FROM character_ WHERE name='%s'", iName), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
@ -1919,7 +1919,7 @@ uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZo
bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) { bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id), errbuf)) { if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id), errbuf)) {
cerr << "Error in UpdateLiveChar query '" << query << "' " << errbuf << endl; cerr << "Error in UpdateLiveChar query '" << query << "' " << errbuf << endl;
safe_delete_array(query); safe_delete_array(query);
@ -1932,9 +1932,9 @@ bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) {
bool Database::GetLiveChar(uint32 account_id, char* cname) { bool Database::GetLiveChar(uint32 account_id, char* cname) {
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 charname FROM account WHERE id=%i", account_id), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT charname FROM account WHERE id=%i", account_id), errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
if (mysql_num_rows(result) == 1) { if (mysql_num_rows(result) == 1) {
@ -2015,9 +2015,9 @@ void Database::AddReport(std::string who, std::string against, std::string lines
safe_delete_array(escape_str); safe_delete_array(escape_str);
} }
void Database::SetGroupID(const char* name,uint32 id, uint32 charid, uint32 ismerc){ void Database::SetGroupID(const char* name,uint32 id, uint32 charid, uint32 ismerc){
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if(id == 0){ //removing you from table if(id == 0){ //removing you from table
if (!RunQuery(query, MakeAnyLenString(&query, "delete from group_id where charid=%i and name='%s' and ismerc=%i",charid, name, ismerc), errbuf)) if (!RunQuery(query, MakeAnyLenString(&query, "delete from group_id where charid=%i and name='%s' and ismerc=%i",charid, name, ismerc), errbuf))
LogFile->write(EQEMuLog::Error, "Error deleting character from group id: %s", errbuf); LogFile->write(EQEMuLog::Error, "Error deleting character from group id: %s", errbuf);
@ -2032,8 +2032,8 @@ void Database::SetGroupID(const char* name,uint32 id, uint32 charid, uint32 ism
void Database::ClearGroup(uint32 gid) { void Database::ClearGroup(uint32 gid) {
ClearGroupLeader(gid); ClearGroupLeader(gid);
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if(gid == 0) { //clear all groups if(gid == 0) { //clear all groups
//if (!RunQuery(query, MakeAnyLenString(&query, "update group_id set groupid=0 where groupid!=0"), errbuf)) //if (!RunQuery(query, MakeAnyLenString(&query, "update group_id set groupid=0 where groupid!=0"), errbuf))
if (!RunQuery(query, MakeAnyLenString(&query, "delete from group_id"), errbuf)) if (!RunQuery(query, MakeAnyLenString(&query, "delete from group_id"), errbuf))
printf("Unable to clear groups: %s\n",errbuf); printf("Unable to clear groups: %s\n",errbuf);
@ -2047,8 +2047,8 @@ void Database::ClearGroup(uint32 gid) {
uint32 Database::GetGroupID(const char* name){ uint32 Database::GetGroupID(const char* name){
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
uint32 groupid=0; uint32 groupid=0;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT groupid from group_id where name='%s'", name), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT groupid from group_id where name='%s'", name), errbuf, &result)) {
@ -2069,8 +2069,8 @@ uint32 Database::GetGroupID(const char* name){
char* Database::GetGroupLeaderForLogin(const char* name,char* leaderbuf){ char* Database::GetGroupLeaderForLogin(const char* name,char* leaderbuf){
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;
PlayerProfile_Struct pp; PlayerProfile_Struct pp;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT profile from character_ where name='%s'", name), errbuf, &result)) { if (RunQuery(query, MakeAnyLenString(&query, "SELECT profile from character_ where name='%s'", name), errbuf, &result)) {
@ -2091,7 +2091,7 @@ char* Database::GetGroupLeaderForLogin(const char* name,char* leaderbuf){
void Database::SetGroupLeaderName(uint32 gid, const char* name) { void Database::SetGroupLeaderName(uint32 gid, const char* name) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "Replace into group_leaders set gid=%lu, leadername='%s'",(unsigned long)gid,name), errbuf)) if (!RunQuery(query, MakeAnyLenString(&query, "Replace into group_leaders set gid=%lu, leadername='%s'",(unsigned long)gid,name), errbuf))
printf("Unable to set group leader: %s\n",errbuf); printf("Unable to set group leader: %s\n",errbuf);
@ -2106,7 +2106,7 @@ char *Database::GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* mainta
MYSQL_ROW row; MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT leadername, maintank, assist, puller, marknpc, leadershipaa FROM group_leaders WHERE gid=%lu",(unsigned long)gid), if (RunQuery(query, MakeAnyLenString(&query, "SELECT leadername, maintank, assist, puller, marknpc, leadershipaa FROM group_leaders WHERE gid=%lu",(unsigned long)gid),
errbuf, &result)) { errbuf, &result)) {
safe_delete_array(query); safe_delete_array(query);
@ -2160,8 +2160,8 @@ char *Database::GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* mainta
void Database::ClearGroupLeader(uint32 gid){ void Database::ClearGroupLeader(uint32 gid){
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if(gid == 0) { //clear all group leaders if(gid == 0) { //clear all group leaders
if (!RunQuery(query, MakeAnyLenString(&query, "DELETE from group_leaders"), errbuf)) if (!RunQuery(query, MakeAnyLenString(&query, "DELETE from group_leaders"), errbuf))
printf("Unable to clear group leaders: %s\n",errbuf); printf("Unable to clear group leaders: %s\n",errbuf);
} else { //clear a specific group leader } else { //clear a specific group leader
@ -2176,7 +2176,7 @@ bool FetchRowMap(MYSQL_RES *result, map<string,string> &rowmap)
MYSQL_FIELD *fields; MYSQL_FIELD *fields;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long num_fields,i; unsigned long num_fields,i;
bool retval=false; bool retval=false;
rowmap.clear(); rowmap.clear();
if (result && (num_fields=mysql_num_fields(result)) && (row = mysql_fetch_row(result))!=nullptr && (fields = mysql_fetch_fields(result))!=nullptr) { if (result && (num_fields=mysql_num_fields(result)) && (row = mysql_fetch_row(result))!=nullptr && (fields = mysql_fetch_fields(result))!=nullptr) {
retval=true; retval=true;
@ -2227,8 +2227,8 @@ void Database::SetAgreementFlag(uint32 acctid)
void Database::ClearRaid(uint32 rid) { void Database::ClearRaid(uint32 rid) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if(rid == 0) { //clear all raids if(rid == 0) { //clear all raids
if (!RunQuery(query, MakeAnyLenString(&query, "delete from raid_members"), errbuf)) if (!RunQuery(query, MakeAnyLenString(&query, "delete from raid_members"), errbuf))
printf("Unable to clear raids: %s\n",errbuf); printf("Unable to clear raids: %s\n",errbuf);
} else { //clear a specific group } else { //clear a specific group
@ -2240,8 +2240,8 @@ void Database::ClearRaid(uint32 rid) {
void Database::ClearRaidDetails(uint32 rid) { void Database::ClearRaidDetails(uint32 rid) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
if(rid == 0) { //clear all raids if(rid == 0) { //clear all raids
if (!RunQuery(query, MakeAnyLenString(&query, "delete from raid_details"), errbuf)) if (!RunQuery(query, MakeAnyLenString(&query, "delete from raid_details"), errbuf))
printf("Unable to clear raid details: %s\n",errbuf); printf("Unable to clear raid details: %s\n",errbuf);
} else { //clear a specific group } else { //clear a specific group
@ -2253,8 +2253,8 @@ void Database::ClearRaidDetails(uint32 rid) {
uint32 Database::GetRaidID(const char* name){ uint32 Database::GetRaidID(const char* name){
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
uint32 raidid=0; uint32 raidid=0;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT raidid from raid_members where name='%s'", name), if (RunQuery(query, MakeAnyLenString(&query, "SELECT raidid from raid_members where name='%s'", name),
@ -2279,8 +2279,8 @@ const char *Database::GetRaidLeaderName(uint32 rid)
static char name[128]; static char name[128];
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 raid_members WHERE raidid=%u AND israidleader=1", if (RunQuery(query, MakeAnyLenString(&query, "SELECT name FROM raid_members WHERE raidid=%u AND israidleader=1",
@ -3126,7 +3126,7 @@ void Database::UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win)
} }
bool Database::GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w, bool Database::GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w,
uint32 &tak_w, uint32 &guk_l, uint32 &mir_l, uint32 &mmc_l, uint32 &ruj_l, uint32 &tak_l) uint32 &tak_w, uint32 &guk_l, uint32 &mir_l, uint32 &mmc_l, uint32 &ruj_l, uint32 &tak_l)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
@ -3175,7 +3175,7 @@ uint32 Database::GetGuildDBIDByCharID(uint32 char_id) {
mysql_free_result(result); mysql_free_result(result);
} }
else { else {
cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << endl; cerr << "Error in GetAccountIDByChar query '" << query << "' " << errbuf << endl;
} }
safe_delete_array(query); safe_delete_array(query);
return retVal; return retVal;

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
@ -79,7 +79,7 @@ EventLogDetails_Struct eld[255];
// Added By Hogie // Added By Hogie
// INSERT into variables (varname,value) values('decaytime [minlevel] [maxlevel]','[number of seconds]'); // INSERT into variables (varname,value) values('decaytime [minlevel] [maxlevel]','[number of seconds]');
// IE: decaytime 1 54 = Levels 1 through 54 // IE: decaytime 1 54 = Levels 1 through 54
// decaytime 55 100 = Levels 55 through 100 // decaytime 55 100 = Levels 55 through 100
// 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;
@ -108,8 +108,8 @@ public:
~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,22 +172,22 @@ 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);
@ -196,8 +196,8 @@ public:
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);
@ -205,20 +205,20 @@ public:
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();
@ -226,14 +226,14 @@ public:
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);

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,7 +184,7 @@ 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;
/* /*

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)) {
@ -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 */ time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */ newtime = localtime( &aclock ); /* Convert time to struct */
if (dofile) 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 */ time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */ newtime = localtime( &aclock ); /* Convert time to struct */
if (dofile) 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)
@ -352,7 +352,7 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
// 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, " ");
@ -388,8 +388,8 @@ void EQEMuLog::SetCallback(LogIDs id, msgCallbackFmt proc) {
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,7 +103,7 @@ public:
Debug, Debug,
Quest, Quest,
Commands, Commands,
Crash, Crash,
MaxLogID MaxLogID
}; };

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 DEITY_H #ifndef DEITY_H
#define DEITY_H #define DEITY_H

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"
@ -25,7 +25,7 @@ const char *OpcodeNames[_maxEmuOpcode+1] = {
//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

@ -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 EQ_CONSTANTS_H #ifndef EQ_CONSTANTS_H
#define EQ_CONSTANTS_H #define EQ_CONSTANTS_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
}; };
@ -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

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) { void Exception::operator=(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_;
} }
const std::string& Exception::full_description() const { const std::string& Exception::full_description() const {
if(full_desc_.empty()) { if(full_desc_.empty()) {
std::stringstream ss; std::stringstream ss;
ss << "EQEmu Exception (" << name_ << ") in " << file_; ss << "EQEmu Exception (" << name_ << ") in " << file_;
ss << " at line (" << line_ << "): " << desc_; ss << " at line (" << line_ << "): " << desc_;
full_desc_ = ss.str(); full_desc_ = ss.str();
} }
return full_desc_; 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 //! Detailed Constructor
/*! /*!
\param name The name given for this exception. \param name The name given for this exception.
\param description The description for this exception. \param description The description for this exception.
\param file The file name for this exception. \param file The file name for this exception.
\param line The line number for this exception. \param line The line number for this exception.
*/ */
Exception(const char* name, const std::string& description, const char* file, long line); Exception(const char* name, const std::string& description, const char* file, long line);
//! Copy Constructor //! Copy Constructor
Exception(const Exception& e); Exception(const Exception& e);
//! Move Constructor //! Move Constructor
#ifdef EQEMU_RVALUE_MOVE #ifdef EQEMU_RVALUE_MOVE
Exception(const Exception&& e); Exception(const Exception&& e);
#endif #endif
//! Destructor //! Destructor
~Exception() throw() { } ~Exception() throw() { }
//! Assignment Operator //! Assignment Operator
void operator=(const Exception& e); void operator=(const Exception& e);
//! Get Name //! Get Name
/*! /*!
Gets the name of the exception as it was when it was created. Gets the name of the exception as it was when it was created.
These are typically descriptive categories that the exception would fall under. These are typically descriptive categories that the exception would fall under.
*/ */
virtual const std::string& name() const { return name_; } virtual const std::string& name() const { return name_; }
//! Get Basic Description //! Get Basic Description
/*! /*!
Gets the description of the exception as it was when it was created. Gets the description of the exception as it was when it was created.
This tends to explain the circumstances of why the exception was thrown. This tends to explain the circumstances of why the exception was thrown.
*/ */
virtual const std::string& description() const { return desc_; } virtual const std::string& description() const { return desc_; }
//! Get Full Description //! Get Full Description
/*! /*!
Gets a full description for this exception. Gets a full description for this exception.
This is a string containing the name, description, file and line number in a custom format. This is a string containing the name, description, file and line number in a custom format.
This string is created the first time the full_description is accessed. This string is created the first time the full_description is accessed.
*/ */
virtual const std::string& full_description() const; virtual const std::string& full_description() const;
//! Get File Name //! Get File Name
/*! /*!
Gets the name of the file this exception was thrown from. Gets the name of the file this exception was thrown from.
*/ */
virtual const std::string& file() const { return file_; } virtual const std::string& file() const { return file_; }
//! Get File Line //! Get File Line
/*! /*!
Gets the file line this exception was thrown from. Gets the file line this exception was thrown from.
*/ */
virtual const long& line() const { return line_; } virtual const long& line() const { return line_; }
//! std::exception overload //! std::exception overload
/*! /*!
Overload from std::exception Overload from std::exception
Allows it to be caught as a std::exception without casting which is nice, returns the full description. 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(); } const char* what() const throw() { return full_description().c_str(); }
protected: protected:
std::string name_; //!< Exception name std::string name_; //!< Exception name
std::string desc_; //!< Exception Description std::string desc_; //!< Exception Description
mutable std::string full_desc_; //!< Full Exception Description mutable std::string full_desc_; //!< Full Exception Description
std::string file_; //!< File Name std::string file_; //!< File Name
long line_; //<! File Line 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
@ -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;
@ -273,8 +273,3 @@ void EQTime::ToString(TimeOfDay_Struct *t, string &str) {
str = buf; str = buf;
} }

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

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 EXTENDED_PROFILE_H #ifndef EXTENDED_PROFILE_H
#define EXTENDED_PROFILE_H #define EXTENDED_PROFILE_H

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
@ -29,12 +29,12 @@ enum FACTION_VALUE {
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,7 +57,7 @@ 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];
}; };
@ -65,10 +65,10 @@ struct Faction {
typedef std::map<uint32, int16> faction_map; typedef std::map<uint32, int16> faction_map;
struct NPCFaction struct NPCFaction
{ {
uint32 factionID; uint32 factionID;
int32 value_mod; int32 value_mod;
int8 npc_value; int8 npc_value;
uint8 temp; uint8 temp;
}; };
const char *FactionValueToString(FACTION_VALUE fv); const char *FactionValueToString(FACTION_VALUE fv);

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
@ -228,7 +228,7 @@ enum { //some random constants
#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 //! Returns whether the set is empty (has 0 elements) or not
bool empty() const { bool empty() const {
return current_elements_ == 0; return current_elements_ == 0;
} }
//! Returns the number of unique elements in the set currently //! Returns the number of unique elements in the set currently
size_type size() const { size_type size() const {
return current_elements_; return current_elements_;
} }
//! Returns the maximum number of elements one can insert into the set. //! Returns the maximum number of elements one can insert into the set.
size_type max_size() const { size_type max_size() const {
return max_elements_; return max_elements_;
} }
//! Returns the maximum key one can use with the set. //! Returns the maximum key one can use with the set.
key_type max_key() const { key_type max_key() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0; return offset_count_ > 0 ? (offset_count_ - 1) : 0;
} }
/*! /*!
Retrieve value operator Retrieve value operator
\param i Index to retrieve the value from \param i Index to retrieve the value from
*/ */
reference operator[](const key_type& i) { reference operator[](const key_type& i) {
if(i >= offset_count_) { if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range"); EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range");
} }
if(offsets_[i] == 0xFFFFFFFFU) { if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Hash Set", "Element not found."); EQ_EXCEPT("Fixed Memory Hash Set", "Element not found.");
} }
return elements_[offsets_[i]]; return elements_[offsets_[i]];
} }
/*! /*!
Retrieve value function Retrieve value function
\param i Index to retrieve the value from \param i Index to retrieve the value from
*/ */
reference at(const key_type& i) { reference at(const key_type& i) {
if(i >= offset_count_) { if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range."); EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
} }
if(offsets_[i] == 0xFFFFFFFFU) { if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Hash Set", "Element not found."); EQ_EXCEPT("Fixed Memory Hash Set", "Element not found.");
} }
return elements_[offsets_[i]]; return elements_[offsets_[i]];
} }
/*! /*!
Checks if there is a value at a certain index Checks if there is a value at a certain index
\param i Index to check for a value \param i Index to check for a value
*/ */
bool exists(const key_type& i) const { bool exists(const key_type& i) const {
if(i >= offset_count_) { if(i >= offset_count_) {
return false; return false;
} }
if(offsets_[i] == 0xFFFFFFFFU) { if(offsets_[i] == 0xFFFFFFFFU) {
return false; return false;
} }
return true; return true;
} }
/*! /*!
Inserts a value into the set at a specific index Inserts a value into the set at a specific index
\param i Index to insert the value at \param i Index to insert the value at
\param v Value to insert \param v Value to insert
*/ */
void insert(const key_type& i, const_reference v) { void insert(const key_type& i, const_reference v) {
if(i >= offset_count_) { if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range."); EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
} }
if(offsets_[i] != 0xFFFFFFFFU) { if(offsets_[i] != 0xFFFFFFFFU) {
elements_[offsets_[i]] = v; elements_[offsets_[i]] = v;
} else { } else {
if(current_elements_ >= max_elements_) { if(current_elements_ >= max_elements_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Insert pointer out of range."); EQ_EXCEPT("Fixed Memory Hash Set", "Insert pointer out of range.");
} }
offsets_[i] = current_elements_; offsets_[i] = current_elements_;
memcpy(&elements_[current_elements_], &v, sizeof(value_type)); memcpy(&elements_[current_elements_], &v, sizeof(value_type));
++current_elements_; ++current_elements_;
*reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_elements_; *reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_elements_;
} }
} }
//! Calculates how much memory we should allocate based on element size and count //! Calculates how much memory we should allocate based on element size and count
static size_type estimated_size(key_type element_count, key_type max_elements) { static size_type estimated_size(key_type element_count, key_type max_elements) {
size_type total_size = 3 * sizeof(key_type); size_type total_size = 3 * sizeof(key_type);
total_size += sizeof(key_type) * (max_elements + 1); total_size += sizeof(key_type) * (max_elements + 1);
total_size += sizeof(T) * element_count; total_size += sizeof(T) * element_count;
return total_size; return total_size;
} }
private: private:
unsigned char *data_; unsigned char *data_;
size_type size_; size_type size_;
key_type offset_count_; key_type offset_count_;
key_type max_elements_; key_type max_elements_;
key_type current_elements_; key_type current_elements_;
key_type *offsets_; key_type *offsets_;
value_type *elements_; 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; *reinterpret_cast<key_type*>(ptr) = 0;
current_offset_ = 0; current_offset_ = 0;
ptr += sizeof(key_type); ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr); offsets_ = reinterpret_cast<key_type*>(ptr);
memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1)); memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1));
ptr += sizeof(key_type) * (max_element_id + 1); ptr += sizeof(key_type) * (max_element_id + 1);
elements_ = reinterpret_cast<byte*>(ptr); elements_ = reinterpret_cast<byte*>(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
*/ */
FixedMemoryVariableHashSet(byte *data, size_type size) { FixedMemoryVariableHashSet(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);
remaining_size_ = *reinterpret_cast<key_type*>(ptr); remaining_size_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type); ptr += sizeof(key_type);
current_offset_ = *reinterpret_cast<key_type*>(ptr); current_offset_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type); ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr); offsets_ = reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type) * offset_count_; ptr += sizeof(key_type) * offset_count_;
elements_ = reinterpret_cast<byte*>(ptr); elements_ = reinterpret_cast<byte*>(ptr);
} }
//! Copy Constructor //! Copy Constructor
FixedMemoryVariableHashSet(const FixedMemoryVariableHashSet& other) : FixedMemoryVariableHashSet(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_)
{ {
} }
//! RValue-Move Constructor //! 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 //! Returns the number of bytes in the set currently
size_type size() const { size_type size() const {
return size_ - remaining_size_; return size_ - remaining_size_;
} }
//! Returns the maximum number of bytes one can insert into the set. //! Returns the maximum number of bytes one can insert into the set.
size_type max_size() const { size_type max_size() const {
return size_ - (sizeof(key_type) * 2); return size_ - (sizeof(key_type) * 2);
} }
//! Returns the maximum key one can use with the set. //! Returns the maximum key one can use with the set.
key_type max_key() const { key_type max_key() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0; return offset_count_ > 0 ? (offset_count_ - 1) : 0;
} }
/*! /*!
Retrieve value operator Retrieve value operator
\param i Index to retrieve the value from \param i Index to retrieve the value from
*/ */
reference operator[](const key_type& i) { reference operator[](const key_type& i) {
if(i >= offset_count_) { if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range"); EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
} }
if(offsets_[i] == 0xFFFFFFFFU) { if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found."); EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found.");
} }
return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]); return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]);
} }
/*! /*!
Retrieve value function Retrieve value function
\param i Index to retrieve the value from \param i Index to retrieve the value from
*/ */
reference at(const key_type& i) { reference at(const key_type& i) {
if(i >= offset_count_) { if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range"); EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
} }
if(offsets_[i] == 0xFFFFFFFFU) { if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found."); EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found.");
} }
return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]); return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]);
} }
/*! /*!
Checks if there is a value at a certain index Checks if there is a value at a certain index
\param i Index to check for a value \param i Index to check for a value
*/ */
bool exists(const key_type& i) const { bool exists(const key_type& i) const {
if(i >= offset_count_) { if(i >= offset_count_) {
return false; return false;
} }
if(offsets_[i] == 0xFFFFFFFFU) { if(offsets_[i] == 0xFFFFFFFFU) {
return false; return false;
} }
return true; return true;
} }
/*! /*!
Inserts a value into the set at a specific index Inserts a value into the set at a specific index
\param i Index to insert the value at \param i Index to insert the value at
\param v Value to insert \param v Value to insert
*/ */
void insert(const key_type& i, byte *data, size_type size) { void insert(const key_type& i, byte *data, size_type size) {
if(i >= offset_count_) { if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range."); EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range.");
} }
if(size > remaining_size_) { if(size > remaining_size_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Not enough room in hash set to insert this value."); EQ_EXCEPT("Fixed Memory Hash Set", "Not enough room in hash set to insert this value.");
} }
if(offsets_[i] != 0xFFFFFFFFU) { if(offsets_[i] != 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Hash Set", "Could not insert a repeat value at this index."); EQ_EXCEPT("Fixed Memory Hash Set", "Could not insert a repeat value at this index.");
} else { } else {
offsets_[i] = current_offset_; offsets_[i] = current_offset_;
memcpy(&elements_[current_offset_], data, size); memcpy(&elements_[current_offset_], data, size);
remaining_size_ -= size; remaining_size_ -= size;
*reinterpret_cast<key_type*>(data_ + sizeof(key_type)) = remaining_size_; *reinterpret_cast<key_type*>(data_ + sizeof(key_type)) = remaining_size_;
current_offset_ += size; current_offset_ += size;
*reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_offset_; *reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_offset_;
} }
} }
private: private:
unsigned char *data_; unsigned char *data_;
size_type size_; size_type size_;
size_type remaining_size_; size_type remaining_size_;
key_type current_offset_; key_type current_offset_;
key_type offset_count_; key_type offset_count_;
key_type *offsets_; key_type *offsets_;
byte *elements_; byte *elements_;
}; };
} // EQEmu } // EQEmu
#endif #endif

View File

@ -1,5 +1,5 @@
/* 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
@ -9,11 +9,11 @@
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"
@ -316,8 +316,8 @@ uint32 BaseGuildManager::_GetFreeGuildID() {
} }
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char query[100]; char query[100];
MYSQL_RES *result; MYSQL_RES *result;
//this has got to be one of the more retarded things I have seen. //this has got to be one of the more retarded things I have seen.
//none the less, im too lazy to rewrite it right now. //none the less, im too lazy to rewrite it right now.
@ -953,22 +953,22 @@ bool BaseGuildManager::_RunQuery(char *&query, int len, const char *errmsg) {
#endif #endif
static void ProcessGuildMember(MYSQL_ROW &row, CharGuildInfo &into) { static void ProcessGuildMember(MYSQL_ROW &row, CharGuildInfo &into) {
//fields from `characer_` //fields from `characer_`
into.char_id = atoi(row[0]); into.char_id = atoi(row[0]);
into.char_name = row[1]; into.char_name = row[1];
into.class_ = atoi(row[2]); into.class_ = atoi(row[2]);
into.level = atoi(row[3]); into.level = atoi(row[3]);
into.time_last_on = atoul(row[4]); into.time_last_on = atoul(row[4]);
into.zone_id = atoi(row[5]); into.zone_id = atoi(row[5]);
//fields from `guild_members`, leave at defaults if missing //fields from `guild_members`, leave at defaults if missing
into.guild_id = row[6] ? atoi(row[6]) : GUILD_NONE; into.guild_id = row[6] ? atoi(row[6]) : GUILD_NONE;
into.rank = row[7] ? atoi(row[7]) : (GUILD_MAX_RANK+1); into.rank = row[7] ? atoi(row[7]) : (GUILD_MAX_RANK+1);
into.tribute_enable = row[8] ? (row[8][0] == '0'?false:true) : false; into.tribute_enable = row[8] ? (row[8][0] == '0'?false:true) : false;
into.total_tribute = row[9] ? atoi(row[9]) : 0; into.total_tribute = row[9] ? atoi(row[9]) : 0;
into.last_tribute = row[10]? atoul(row[10]) : 0; //timestamp into.last_tribute = row[10]? atoul(row[10]) : 0; //timestamp
into.banker = row[11]? (row[11][0] == '0'?false:true) : false; into.banker = row[11]? (row[11][0] == '0'?false:true) : false;
into.public_note = row[12]? row[12] : ""; into.public_note = row[12]? row[12] : "";
into.alt = row[13]? (row[13][0] == '0'?false:true) : false; into.alt = row[13]? (row[13][0] == '0'?false:true) : false;
//a little sanity checking/cleanup //a little sanity checking/cleanup
if(into.guild_id == 0) if(into.guild_id == 0)
@ -1320,9 +1320,9 @@ uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
MYSQL_RES *result; MYSQL_RES *result;
if (!m_db->RunQuery(query, if (!m_db->RunQuery(query,
MakeAnyLenString(&query, MakeAnyLenString(&query,
"select guild_id from guild_members where char_id in (select id from character_ where account_id = %i) and rank = 2", "select guild_id from guild_members where char_id in (select id from character_ where account_id = %i) and rank = 2",
AccountID), errbuf, &result)) AccountID), errbuf, &result))
{ {
_log(GUILDS__ERROR, "Error executing query '%s': %s", query, errbuf); _log(GUILDS__ERROR, "Error executing query '%s': %s", query, errbuf);
safe_delete_array(query); safe_delete_array(query);
@ -1341,10 +1341,10 @@ uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
bool Database::LoadGuilds(GuildRanks_Struct* guilds) { bool Database::LoadGuilds(GuildRanks_Struct* guilds) {
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
// int i; // int i;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
for (int a = 0; a < 512; a++) { for (int a = 0; a < 512; a++) {
guilds[a].leader = 0; guilds[a].leader = 0;
@ -1445,7 +1445,7 @@ bool Database::LoadGuilds(GuildRanks_Struct* guilds) {
void Database::SetPublicNote(uint32 guild_id,char* charname, char* note){ void Database::SetPublicNote(uint32 guild_id,char* charname, char* note){
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
char* notebuf = new char[(strlen(note)*2)+3]; char* notebuf = new char[(strlen(note)*2)+3];
DoEscapeString(notebuf, note, strlen(note)) ; DoEscapeString(notebuf, note, strlen(note)) ;
if (!RunQuery(query, MakeAnyLenString(&query, "update character_ set publicnote='%s' where name='%s' and guild=%i", notebuf,charname,guild_id), errbuf)) { if (!RunQuery(query, MakeAnyLenString(&query, "update character_ set publicnote='%s' where name='%s' and guild=%i", notebuf,charname,guild_id), errbuf)) {
@ -1459,9 +1459,9 @@ void Database::SetPublicNote(uint32 guild_id,char* charname, char* note){
bool Database::GetGuildRanks(uint32 guildeqid, GuildRanks_Struct* gr) { bool Database::GetGuildRanks(uint32 guildeqid, GuildRanks_Struct* gr) {
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, eqid, name, leader, minstatus, rank0title, rank1, rank1title, rank2, rank2title, rank3, rank3title, rank4, rank4title, rank5, rank5title from guilds where eqid=%i;", guildeqid), errbuf, &result)) if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, eqid, name, leader, minstatus, rank0title, rank1, rank1title, rank2, rank2title, rank3, rank3title, rank4, rank4title, rank5, rank5title from guilds where eqid=%i;", guildeqid), errbuf, &result))
{ {

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,8 +59,8 @@ 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;
@ -83,7 +83,7 @@ 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)) {
@ -103,7 +103,7 @@ 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)) {
@ -126,7 +126,7 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
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;
@ -152,7 +152,7 @@ bool Database::DeleteGuild(uint32 guild_id)
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)) ;
@ -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];
@ -217,9 +217,9 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
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);
@ -241,9 +241,9 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
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);
@ -267,7 +267,7 @@ uint32 Database::GetGuildIDbyLeader(uint32 leader)
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)) {
@ -288,7 +288,7 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
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;
@ -318,9 +318,9 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
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_
@ -23,43 +23,43 @@
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
@ -29,84 +29,84 @@ 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: public:
LinkedListIterator(LinkedList<TYPE>& l,direction d = FORWARD) : list(l), dir(d) {}; LinkedListIterator(LinkedList<TYPE>& l,direction d = FORWARD) : list(l), dir(d) {};
void Advance(); void Advance();
const TYPE& GetData(); const TYPE& GetData();
bool IsFirst() bool IsFirst()
{ {
if (current_element->GetPrev() == 0) if (current_element->GetPrev() == 0)
@ -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,8 +280,8 @@ void LinkedListIterator<TYPE>::Reset()
{ {
if (!(&list)) if (!(&list))
{ {
current_element=0; current_element=0;
return; return;
} }
if (dir == FORWARD) if (dir == FORWARD)
@ -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"
@ -109,7 +109,7 @@ bool load_log_settings(const char *filename) {
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);
@ -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"
@ -37,7 +37,3 @@ void log_messageVA(LogType type, const char *fmt, va_list args) {
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
@ -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;
} }

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 "memory_mapped_file.h" #include "memory_mapped_file.h"
@ -32,160 +32,160 @@
namespace EQEmu { namespace EQEmu {
struct MemoryMappedFile::Implementation { struct MemoryMappedFile::Implementation {
#ifdef _WINDOWS #ifdef _WINDOWS
HANDLE mapped_object_; HANDLE mapped_object_;
#else #else
int fd_; int fd_;
#endif #endif
}; };
MemoryMappedFile::MemoryMappedFile(std::string filename, uint32 size) MemoryMappedFile::MemoryMappedFile(std::string filename, uint32 size)
: filename_(filename), size_(size) { : filename_(filename), size_(size) {
imp_ = new Implementation; imp_ = new Implementation;
#ifdef _WINDOWS #ifdef _WINDOWS
DWORD total_size = size + sizeof(shared_memory_struct); DWORD total_size = size + sizeof(shared_memory_struct);
HANDLE file = CreateFile(filename.c_str(), HANDLE file = CreateFile(filename.c_str(),
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr, nullptr,
OPEN_ALWAYS, OPEN_ALWAYS,
0, 0,
nullptr); nullptr);
if(file == INVALID_HANDLE_VALUE) { if(file == INVALID_HANDLE_VALUE) {
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
} }
imp_->mapped_object_ = CreateFileMapping(file, imp_->mapped_object_ = CreateFileMapping(file,
nullptr, nullptr,
PAGE_READWRITE, PAGE_READWRITE,
0, 0,
total_size, total_size,
filename.c_str()); filename.c_str());
if(!imp_->mapped_object_) { if(!imp_->mapped_object_) {
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file."); EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");
} }
memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_, memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_,
FILE_MAP_ALL_ACCESS, FILE_MAP_ALL_ACCESS,
0, 0,
0, 0,
total_size)); total_size));
if(!memory_) { if(!memory_) {
EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file."); EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file.");
} }
#else #else
size_t total_size = size + sizeof(shared_memory_struct); size_t total_size = size + sizeof(shared_memory_struct);
imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if(imp_->fd_ == -1) { if(imp_->fd_ == -1) {
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
} }
if(ftruncate(imp_->fd_, total_size) == -1) { if(ftruncate(imp_->fd_, total_size) == -1) {
EQ_EXCEPT("Shared Memory", "Could not set file size for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not set file size for this shared memory segment.");
} }
memory_ = reinterpret_cast<shared_memory_struct*>( memory_ = reinterpret_cast<shared_memory_struct*>(
mmap(nullptr, total_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, imp_->fd_, 0)); mmap(nullptr, total_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, imp_->fd_, 0));
if(memory_ == MAP_FAILED) { if(memory_ == MAP_FAILED) {
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file."); EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");
} }
#endif #endif
} }
MemoryMappedFile::MemoryMappedFile(std::string filename) MemoryMappedFile::MemoryMappedFile(std::string filename)
: filename_(filename) { : filename_(filename) {
imp_ = new Implementation; imp_ = new Implementation;
//get existing size //get existing size
FILE *f = fopen(filename.c_str(), "rb"); FILE *f = fopen(filename.c_str(), "rb");
if(!f) { if(!f) {
EQ_EXCEPT("Shared Memory", "Could not open the file to find the existing file size."); EQ_EXCEPT("Shared Memory", "Could not open the file to find the existing file size.");
} }
fseek(f, 0U, SEEK_END); fseek(f, 0U, SEEK_END);
uint32 size = static_cast<uint32>(ftell(f)) - sizeof(shared_memory_struct); uint32 size = static_cast<uint32>(ftell(f)) - sizeof(shared_memory_struct);
size_ = size; size_ = size;
fclose(f); fclose(f);
#ifdef _WINDOWS #ifdef _WINDOWS
DWORD total_size = size + sizeof(shared_memory_struct); DWORD total_size = size + sizeof(shared_memory_struct);
HANDLE file = CreateFile(filename.c_str(), HANDLE file = CreateFile(filename.c_str(),
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr, nullptr,
OPEN_ALWAYS, OPEN_ALWAYS,
0, 0,
nullptr); nullptr);
if(file == INVALID_HANDLE_VALUE) { if(file == INVALID_HANDLE_VALUE) {
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
} }
imp_->mapped_object_ = CreateFileMapping(file, imp_->mapped_object_ = CreateFileMapping(file,
nullptr, nullptr,
PAGE_READWRITE, PAGE_READWRITE,
0, 0,
total_size, total_size,
filename.c_str()); filename.c_str());
if(!imp_->mapped_object_) { if(!imp_->mapped_object_) {
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file."); EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");
} }
memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_, memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_,
FILE_MAP_ALL_ACCESS, FILE_MAP_ALL_ACCESS,
0, 0,
0, 0,
total_size)); total_size));
if(!memory_) { if(!memory_) {
EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file."); EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file.");
} }
#else #else
size_t total_size = size + sizeof(shared_memory_struct); size_t total_size = size + sizeof(shared_memory_struct);
imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if(imp_->fd_ == -1) { if(imp_->fd_ == -1) {
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
} }
if(ftruncate(imp_->fd_, total_size) == -1) { if(ftruncate(imp_->fd_, total_size) == -1) {
EQ_EXCEPT("Shared Memory", "Could not set file size for this shared memory segment."); EQ_EXCEPT("Shared Memory", "Could not set file size for this shared memory segment.");
} }
memory_ = reinterpret_cast<shared_memory_struct*>( memory_ = reinterpret_cast<shared_memory_struct*>(
mmap(nullptr, total_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, imp_->fd_, 0)); mmap(nullptr, total_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, imp_->fd_, 0));
if(memory_ == MAP_FAILED) { if(memory_ == MAP_FAILED) {
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file."); EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");
} }
#endif #endif
} }
MemoryMappedFile::~MemoryMappedFile() { MemoryMappedFile::~MemoryMappedFile() {
#ifdef _WINDOWS #ifdef _WINDOWS
if(imp_->mapped_object_) { if(imp_->mapped_object_) {
CloseHandle(imp_->mapped_object_); CloseHandle(imp_->mapped_object_);
} }
#else #else
if(memory_) { if(memory_) {
size_t total_size = size_ + sizeof(shared_memory_struct); size_t total_size = size_ + sizeof(shared_memory_struct);
munmap(reinterpret_cast<void*>(memory_), total_size); munmap(reinterpret_cast<void*>(memory_), total_size);
close(imp_->fd_); close(imp_->fd_);
} }
#endif #endif
delete imp_; delete imp_;
} }
void MemoryMappedFile::ZeroFile() { void MemoryMappedFile::ZeroFile() {
memset(reinterpret_cast<void*>(memory_), 0, sizeof(shared_memory_struct)); memset(reinterpret_cast<void*>(memory_), 0, sizeof(shared_memory_struct));
memset(memory_->data, 0, size_); memset(memory_->data, 0, size_);
memory_->size = size_; memory_->size = size_;
} }
} // 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_MEMORYMAPPEDFILE_H_ #ifndef _EQEMU_MEMORYMAPPEDFILE_H_
@ -24,63 +24,63 @@
namespace EQEmu { namespace EQEmu {
//! Memory Backed Shared Memory //! Memory Backed Shared Memory
/*! /*!
Allows us to create shared memory that is backed by a file on both windows and unix platforms that Allows us to create shared memory that is backed by a file on both windows and unix platforms that
works in a consistent manner. Non-copyable. works in a consistent manner. Non-copyable.
*/ */
class MemoryMappedFile { class MemoryMappedFile {
struct Implementation; struct Implementation;
struct shared_memory_struct; struct shared_memory_struct;
//! Underlying data structure. //! Underlying data structure.
struct shared_memory_struct { struct shared_memory_struct {
uint32 size; uint32 size;
unsigned char data[1]; unsigned char data[1];
}; };
public: public:
//! Constructor //! Constructor
/*! /*!
Creates a mmf for the given filename and of size. Creates a mmf for the given filename and of size.
\param filename Actual filename of the mmf. \param filename Actual filename of the mmf.
\param size Size in bytes of the mmf. \param size Size in bytes of the mmf.
*/ */
MemoryMappedFile(std::string filename, uint32 size); MemoryMappedFile(std::string filename, uint32 size);
//! Constructor //! Constructor
/*! /*!
Creates a mmf for the given filename and gets the size based on the existing size. Creates a mmf for the given filename and gets the size based on the existing size.
\param filename Actual filename of the mmf. \param filename Actual filename of the mmf.
*/ */
MemoryMappedFile(std::string filename); MemoryMappedFile(std::string filename);
//! Destructor //! Destructor
~MemoryMappedFile(); ~MemoryMappedFile();
//! Get Data Operator //! Get Data Operator
inline void *operator->() const { return memory_->data; } inline void *operator->() const { return memory_->data; }
//! Get Data Function //! Get Data Function
inline void *Get() const { return memory_->data; } inline void *Get() const { return memory_->data; }
//! Get Size Function //! Get Size Function
inline uint32 Size() const { return memory_->size; } inline uint32 Size() const { return memory_->size; }
//! Zeros all the memory in the file, and set it to be unloaded //! Zeros all the memory in the file, and set it to be unloaded
void ZeroFile(); void ZeroFile();
private: private:
//! Copy Constructor //! Copy Constructor
MemoryMappedFile(const MemoryMappedFile&); MemoryMappedFile(const MemoryMappedFile&);
//! Assignment Operator //! Assignment Operator
const MemoryMappedFile& operator=(const MemoryMappedFile&); const MemoryMappedFile& operator=(const MemoryMappedFile&);
std::string filename_; //!< Filename of this shared memory object std::string filename_; //!< Filename of this shared memory object
uint32 size_; //!< Size in bytes of this shared memory object uint32 size_; //!< Size in bytes of this shared memory object
shared_memory_struct *memory_; //!< Underlying data of the shared memory object. shared_memory_struct *memory_; //!< Underlying data of the shared memory object.
Implementation *imp_; //!< Underlying implementation. Implementation *imp_; //!< Underlying implementation.
}; };
} // EQEmu } // EQEmu
#endif #endif

View File

@ -36,20 +36,20 @@ int print_stacktrace()
#include <execinfo.h> #include <execinfo.h>
int print_stacktrace() int print_stacktrace()
{ {
void *ba[20]; void *ba[20];
int n = backtrace (ba, 20); int n = backtrace (ba, 20);
if (n != 0) if (n != 0)
{ {
char **names = backtrace_symbols (ba, n); char **names = backtrace_symbols (ba, n);
if (names != nullptr) if (names != nullptr)
{ {
int i; int i;
cerr << "called from " << (char*)names[0] << endl; cerr << "called from " << (char*)names[0] << endl;
for (i = 1; i < n; ++i) for (i = 1; i < n; ++i)
cerr << " " << (char*)names[i] << endl; cerr << " " << (char*)names[i] << endl;
free (names); free (names);
} }
} }
return(0); return(0);
} }
#endif //!FREEBSD #endif //!FREEBSD
@ -387,9 +387,9 @@ void encode_chunk(char *in, int len, char *out)
void decode_chunk(char *in, char *out) void decode_chunk(char *in, char *out)
{ {
*out = DEC(*in) << 2 | DEC(in[1]) >> 4; *out = DEC(*in) << 2 | DEC(in[1]) >> 4;
*(out+1) = DEC(in[1]) << 4 | DEC(in[2]) >> 2; *(out+1) = DEC(in[1]) << 4 | DEC(in[2]) >> 2;
*(out+2) = DEC(in[2]) << 6 | DEC(in[3]); *(out+2) = DEC(in[2]) << 6 | DEC(in[3]);
} }
void dump_message_column(unsigned char *buffer, unsigned long length, string leader, FILE *to) void dump_message_column(unsigned char *buffer, unsigned long length, string leader, FILE *to)

View File

@ -21,7 +21,7 @@ void LoadItemDBFieldNames();
void encode_length(unsigned long length, char *out); void encode_length(unsigned long length, char *out);
unsigned long decode_length(char *in); unsigned long decode_length(char *in);
unsigned long encode(char *in, unsigned long length, char *out); unsigned long encode(char *in, unsigned long length, char *out);
void decode(char *in, char *out); void decode(char *in, char *out);
void encode_chunk(char *in, int len, char *out); void encode_chunk(char *in, int len, char *out);
void decode_chunk(char *in, char *out); void decode_chunk(char *in, char *out);
@ -41,3 +41,4 @@ void build_hex_line(const char *buffer, unsigned long length, unsigned long offs
void print_hex(const char *buffer, unsigned long length); void print_hex(const char *buffer, unsigned long length);
#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
*/ */
#include "../common/debug.h" #include "../common/debug.h"

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 MOREMATH_H #ifndef MOREMATH_H
#define MOREMATH_H #define MOREMATH_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 <stdio.h> #include <stdio.h>
@ -180,7 +180,6 @@ bool RegularOpcodeManager::ReloadOpcodes(const char *filename, bool report_error
return(ret); return(ret);
} }
uint16 RegularOpcodeManager::EmuToEQ(const EmuOpcode emu_op) { uint16 RegularOpcodeManager::EmuToEQ(const EmuOpcode emu_op) {
//opcode is checked for validity in GetEQOpcode //opcode is checked for validity in GetEQOpcode
uint16 res; uint16 res;
@ -221,7 +220,6 @@ void RegularOpcodeManager::SetOpcode(EmuOpcode emu_op, uint16 eq_op) {
s.Set(emu_op, eq_op); s.Set(emu_op, eq_op);
} }
void RegularOpcodeManager::NormalMemStrategy::Set(EmuOpcode emu_op, uint16 eq_op) { void RegularOpcodeManager::NormalMemStrategy::Set(EmuOpcode emu_op, uint16 eq_op) {
if(uint32(emu_op) >= it->EmuOpcodeCount || eq_op >= it->EQOpcodeCount) if(uint32(emu_op) >= it->EmuOpcodeCount || eq_op >= it->EQOpcodeCount)
return; return;
@ -233,7 +231,6 @@ NullOpcodeManager::NullOpcodeManager()
: MutableOpcodeManager() { : MutableOpcodeManager() {
} }
bool NullOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) { bool NullOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
return(true); return(true);
} }
@ -254,7 +251,6 @@ EmptyOpcodeManager::EmptyOpcodeManager()
: MutableOpcodeManager() { : MutableOpcodeManager() {
} }
bool EmptyOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) { bool EmptyOpcodeManager::LoadOpcodes(const char *filename, bool report_errors) {
return(true); return(true);
} }
@ -280,9 +276,3 @@ void EmptyOpcodeManager::SetOpcode(EmuOpcode emu_op, uint16 eq_op) {
eq_to_emu[eq_op] = emu_op; eq_to_emu[eq_op] = emu_op;
} }

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 OPCODE_MANAGER_H #ifndef OPCODE_MANAGER_H
@ -58,8 +58,8 @@ public:
}; };
protected: protected:
bool loaded; //true if all opcodes loaded bool loaded; //true if all opcodes loaded
Mutex MOpcodes; //this only protects the local machine Mutex MOpcodes; //this only protects the local machine
//in a shared manager, this dosent protect others //in a shared manager, this dosent protect others
static bool LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors); static bool LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors);
@ -162,15 +162,3 @@ protected:
#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
*/ */
#include "../common/debug.h" #include "../common/debug.h"
#include <iostream> #include <iostream>
@ -59,8 +59,8 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
char* ascii = new char[cols+1]; char* ascii = new char[cols+1];
memset(ascii, 0, cols+1); memset(ascii, 0, cols+1);
uint32 i; uint32 i;
for(i=skip; i<size; i++) for(i=skip; i<size; i++)
{ {
if ((i-skip)%cols==0) { if ((i-skip)%cols==0) {
if (i != skip) if (i != skip)
cout << " | " << ascii << endl; cout << " | " << ascii << endl;
@ -81,7 +81,7 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
ascii[j++] = '.'; ascii[j++] = '.';
} }
// cout << setfill(0) << setw(2) << hex << (int)buf[i] << " "; // cout << setfill(0) << setw(2) << hex << (int)buf[i] << " ";
} }
uint32 k = ((i-skip)-1)%cols; uint32 k = ((i-skip)-1)%cols;
if (k < 8) if (k < 8)
cout << " "; cout << " ";
@ -193,3 +193,4 @@ void DumpPacketBin(const void* iData, uint32 len) {
cout << " " << hex << setw(2) << setfill('0') << (int) data[k-1] << dec; cout << " " << hex << setw(2) << setfill('0') << (int) data[k-1] << dec;
cout << endl; cout << endl;
} }

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 PACKET_DUMP_H #ifndef PACKET_DUMP_H
#define PACKET_DUMP_H #define PACKET_DUMP_H
@ -33,3 +33,4 @@ void DumpPacketBin(uint16 data);
void DumpPacketBin(uint8 data); void DumpPacketBin(uint8 data);
#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
*/ */
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -33,7 +33,7 @@
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else
#include <stdarg.h> #include <stdarg.h>
#endif #endif
@ -73,8 +73,8 @@ void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, u
ofstream logfile(filename, ios::app); ofstream logfile(filename, ios::app);
// Output as HEX // Output as HEX
char output[4]; char output[4];
for(uint32 i=skip; i<size; i++) for(uint32 i=skip; i<size; i++)
{ {
if ((i-skip)%cols==0) if ((i-skip)%cols==0)
{ {
logfile << endl << setw(3) << setfill(' ') << i-skip << ": "; logfile << endl << setw(3) << setfill(' ') << i-skip << ": ";
@ -86,7 +86,7 @@ void oldFileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, u
sprintf(output, "%02X ",(unsigned char)buf[i]); sprintf(output, "%02X ",(unsigned char)buf[i]);
logfile << output; logfile << output;
// logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " "; // logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " ";
} }
logfile << endl << endl; logfile << endl << endl;
} }
@ -99,8 +99,8 @@ void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint
char output[4]; char output[4];
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1); int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
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)
logfile << " | " << ascii << endl; logfile << " | " << ascii << endl;
@ -121,7 +121,7 @@ void FileDumpPacketHex(const char* filename, const uchar* buf, uint32 size, uint
ascii[j++] = '.'; ascii[j++] = '.';
} }
// logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " "; // logfile << setfill(0) << setw(2) << hex << (int)buf[i] << " ";
} }
uint32 k = ((i-skip)-1)%cols; uint32 k = ((i-skip)-1)%cols;
if (k < 8) if (k < 8)
logfile << " "; logfile << " ";

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