Merge conflicts

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

View File

@ -15,73 +15,73 @@ PROJECT(EQEmu)
#Default build type is set to RelWithDebInfo for generators that honor that like makefiles
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)
#Add our various windows definitions
IF(MSVC OR MINGW)
ADD_DEFINITIONS(-D_WINDOWS)
IF(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN64)
ELSE(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN32)
ENDIF(CMAKE_CL_64)
ADD_DEFINITIONS(-D_WINDOWS)
IF(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN64)
ELSE(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN32)
ENDIF(CMAKE_CL_64)
ENDIF(MSVC OR MINGW)
IF(MSVC)
#Set our default locations for zlib/mysql based on x86/x64
IF(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64")
ELSE(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86")
ENDIF(CMAKE_CL_64)
#disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere
OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON)
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
#fast FP if you'd like it
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
IF(EQEMU_FAST_FLOATINGPOINT)
#Set our default locations for zlib/mysql based on x86/x64
IF(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64")
ELSE(CMAKE_CL_64)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86")
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86")
ENDIF(CMAKE_CL_64)
#disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere
OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON)
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
#fast FP if you'd like it
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
IF(EQEMU_FAST_FLOATINGPOINT)
ADD_DEFINITIONS(/fp:fast)
ENDIF(EQEMU_FAST_FLOATINGPOINT)
#crash logging currently only works on windows x86/x64
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
IF(EQEMU_ENABLE_CRASH_LOGGING)
ADD_DEFINITIONS(-DCRASH_LOGGING)
ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
#Disable safe SEH or not?
OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF)
IF(EQEMU_DISABLE_SAFESEH)
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_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /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_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_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_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_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
ENDIF(EQEMU_DISABLE_SAFESEH)
#We want to compile /MT not /MD so we change that
FOREACH(flag_var CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
IF(${flag_var} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MD")
ENDFOREACH(flag_var)
#crash logging currently only works on windows x86/x64
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
IF(EQEMU_ENABLE_CRASH_LOGGING)
ADD_DEFINITIONS(-DCRASH_LOGGING)
ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
#Disable safe SEH or not?
OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF)
IF(EQEMU_DISABLE_SAFESEH)
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_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /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_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_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_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_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
ENDIF(EQEMU_DISABLE_SAFESEH)
#We want to compile /MT not /MD so we change that
FOREACH(flag_var CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
IF(${flag_var} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MD")
ENDFOREACH(flag_var)
ELSE(MSVC)
#Normally set by perl but we don't use the perl flags anymore so we set it.
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
#Normally set by perl but we don't use the perl flags anymore so we set it.
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
ENDIF(MSVC)
#FreeBSD support
@ -95,24 +95,24 @@ ENDIF(UNIX)
#use stdint.h types if they exist for this platform (we have to guess otherwise)
CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
IF(HAVE_STDINT_H)
ADD_DEFINITIONS(-DEQEMU_USE_STDINT)
ADD_DEFINITIONS(-DEQEMU_USE_STDINT)
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:
0 - Quiet mode Errors to file Status and Normal ignored
1 - Status and Normal to console, Errors to logfile
2 - Status, Normal, and Error to console and logfile
3 - Light debug release errors and status
4 - Moderate debug release errors and status
5 - Maximum debug release errors and status
10 - More errors than you ever wanted to see"
0 - Quiet mode Errors to file Status and Normal ignored
1 - Status and Normal to console, Errors to logfile
2 - Status, Normal, and Error to console and logfile
3 - Light debug release errors and status
4 - Moderate debug release errors and status
5 - Maximum debug release errors and status
10 - More errors than you ever wanted to see"
)
#Bots are a compile time option so on/off
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
IF(EQEMU_ENABLE_BOTS)
ADD_DEFINITIONS(-DBOTS)
ADD_DEFINITIONS(-DBOTS)
ENDIF(EQEMU_ENABLE_BOTS)
#What to build
@ -124,22 +124,22 @@ OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
#C++11 stuff
IF(NOT MSVC)
ADD_DEFINITIONS(-std=c++0x)
#Rvalue-Move - todo: auto set this based on gcc version
OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if GCC 4.3 or higher)" OFF)
ADD_DEFINITIONS(-std=c++0x)
#Rvalue-Move - todo: auto set this based on gcc version
OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if GCC 4.3 or higher)" OFF)
ELSE(NOT MSVC)
#Rvalue-Move - todo: auto set this based on msvc version
OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if Visual Studio 2010 or higher)" OFF)
#Rvalue-Move - todo: auto set this based on msvc version
OPTION(EQEMU_ENABLE_RVALUE_MOVE "Enable EQEmu RValue References (Enable if Visual Studio 2010 or higher)" OFF)
ENDIF(NOT MSVC)
IF(EQEMU_ENABLE_RVALUE_MOVE)
ADD_DEFINITIONS(-DEQEMU_RVALUE_MOVE)
ADD_DEFINITIONS(-DEQEMU_RVALUE_MOVE)
ENDIF(EQEMU_ENABLE_RVALUE_MOVE)
#Various definitions
IF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEMBPERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
ADD_DEFINITIONS(-DEMBPERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
ENDIF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL})
ADD_DEFINITIONS(-DINVERSEXY)
@ -150,30 +150,30 @@ ADD_DEFINITIONS(-DMAP_DIR="./Maps")
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(MySQL REQUIRED)
IF(EQEMU_BUILD_PERL)
FIND_PACKAGE(PerlLibs REQUIRED)
INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}")
FIND_PACKAGE(PerlLibs REQUIRED)
INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}")
ENDIF(EQEMU_BUILD_PERL)
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}")
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)
IF(EQEMU_BUILD_SERVER)
ADD_SUBDIRECTORY(shared_memory)
ADD_SUBDIRECTORY(world)
ADD_SUBDIRECTORY(zone)
ADD_SUBDIRECTORY(ucs)
ADD_SUBDIRECTORY(queryserv)
ADD_SUBDIRECTORY(eqlaunch)
ADD_SUBDIRECTORY(shared_memory)
ADD_SUBDIRECTORY(world)
ADD_SUBDIRECTORY(zone)
ADD_SUBDIRECTORY(ucs)
ADD_SUBDIRECTORY(queryserv)
ADD_SUBDIRECTORY(eqlaunch)
ENDIF(EQEMU_BUILD_SERVER)
IF(EQEMU_BUILD_LOGIN)
ADD_SUBDIRECTORY(loginserver)
ADD_SUBDIRECTORY(loginserver)
ENDIF(EQEMU_BUILD_LOGIN)
IF(EQEMU_BUILD_AZONE)
ADD_SUBDIRECTORY(utils)
ADD_SUBDIRECTORY(utils)
ENDIF(EQEMU_BUILD_AZONE)
IF(EQEMU_BUILD_TESTS)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(tests)
ENDIF(EQEMU_BUILD_TESTS)

View File

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

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
#include "BasePacket.h"
@ -34,7 +34,7 @@ BasePacket::BasePacket(const unsigned char *buf, uint32 len)
pBuffer= new unsigned char[len];
if (buf) {
memcpy(this->pBuffer,buf,len);
} else {
} else {
memset(this->pBuffer,0,len);
}
}
@ -108,7 +108,7 @@ void BasePacket::ReadString(char *str, uint32 Offset, uint32 MaxLength) const
while((j < size) && (i < MaxLength) && (str[i - 1] != 0));
str[i - 1] = '\0';
}
}
void DumpPacketHex(const BasePacket* app)
{
@ -124,24 +124,3 @@ void DumpPacketBin(const BasePacket* app) {
DumpPacketBin(app->pBuffer, app->size);
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef BASEPACKET_H_
#define BASEPACKET_H_
@ -50,7 +50,7 @@ public:
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 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) {
return (timestamp.tv_sec < rhs.timestamp.tv_sec || (timestamp.tv_sec==rhs.timestamp.tv_sec && timestamp.tv_usec < rhs.timestamp.tv_usec));
@ -71,7 +71,7 @@ public:
uint32 ReadUInt32(uint32 Offset) const { uint32 value = *(uint32 *)(pBuffer + Offset); return value; }
void ReadString(char *str) { uint32 len = static_cast<uint32>(strlen((char *)(pBuffer + _rpos))) + 1; memcpy(str, pBuffer + _rpos, len); _rpos += len; }
void ReadString(char *str, uint32 Offset, uint32 MaxLength) const;
uint32 GetWritePosition() { return _wpos; }
uint32 GetReadPosition() { return _rpos; }
void SetWritePosition(uint32 Newwpos) { _wpos = Newwpos; }
@ -89,5 +89,3 @@ extern void DumpPacketBin(const BasePacket* app);
#endif /*BASEPACKET_H_*/

View File

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

View File

@ -1,14 +1,15 @@
#include "crc32.h"
uint16 CRC16(const unsigned char *buf, int size, int key)
uint16 CRC16(const unsigned char *buf, int size, int key)
{
// This is computed as the lowest 16 bits of an Ethernet CRC32 checksum
// where the key is prepended to the data in little endian order.
uint8 keyBuf[] = {(uint8)((key >> 0) & 0xff),
(uint8)((key >> 8) & 0xff),
(uint8)((key >> 16) & 0xff),
(uint8)((key >> 24) & 0xff)};
uint32 crc = CRC32::Update(keyBuf, sizeof(uint32));
crc = CRC32::Update(buf, size, crc);
return CRC32::Finish(crc) & 0xffff;
// 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.
uint8 keyBuf[] = {(uint8)((key >> 0) & 0xff),
(uint8)((key >> 8) & 0xff),
(uint8)((key >> 16) & 0xff),
(uint8)((key >> 24) & 0xff)};
uint32 crc = CRC32::Update(keyBuf, sizeof(uint32));
crc = CRC32::Update(buf, size, crc);
return CRC32::Finish(crc) & 0xffff;
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
@ -29,16 +29,16 @@
#ifdef _WINDOWS
Condition::Condition()
Condition::Condition()
{
m_events[SignalEvent] = CreateEvent (nullptr, // security
FALSE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_events[BroadcastEvent] = CreateEvent (nullptr, // security
TRUE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_events[SignalEvent] = CreateEvent (nullptr, // security
FALSE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_events[BroadcastEvent] = CreateEvent (nullptr, // security
TRUE, // is auto-reset event?
FALSE, // is signaled initially?
nullptr); // name
m_waiters = 0;
InitializeCriticalSection(&CSMutex);
}
@ -69,28 +69,28 @@ void Condition::SignalAll()
void Condition::Wait()
{
EnterCriticalSection(&CSMutex);
m_waiters++;
LeaveCriticalSection(&CSMutex);
int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE);
EnterCriticalSection(&CSMutex);
m_waiters--;
//see if we are the last person waiting on the condition, and there was a broadcast
//if so, we need to reset the broadcast event.
if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent))
ResetEvent(m_events[BroadcastEvent]);
LeaveCriticalSection(&CSMutex);
}
#else //!WIN32
Condition::Condition()
Condition::Condition()
{
pthread_cond_init(&cond,nullptr);
pthread_mutex_init(&mutex,nullptr);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __CONDITION_H
#define __CONDITION_H

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
#include "EQDB.h"
@ -64,15 +64,12 @@ EQDBRes * EQDB::query(Const_char *q) {
Const_char *EQDB::escape_string(Const_char *from) {
int len = strlen(from);
char *res = new char[len*2+1];
mysql_real_escape_string(mysql_ref,res,from,len);
res[len*2] = '\0';
m_escapeBuffer = res;
delete[] res;
return(m_escapeBuffer.c_str());
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EQDB_H_
#define EQDB_H_
@ -32,10 +32,10 @@ public:
static EQDB *Singleton() { return(&s_EQDB); }
static void SetMySQL(MYSQL *m) { s_EQDB.mysql_ref=m; }
//BEGIN PERL EXPORT
//NOTE: you must have a space after the * of a return value
unsigned int field_count();
unsigned long affected_rows();
unsigned long insert_id();

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
#include "EQDBRes.h"
@ -23,7 +23,7 @@ vector<string> EQDBRes::fetch_row_array() {
vector<string> array;
if(res == nullptr)
return(array);
int count=mysql_num_fields(res);
MYSQL_ROW row=mysql_fetch_row(res);
for (int i=0;i<count;i++)
@ -36,7 +36,7 @@ map<string,string> EQDBRes::fetch_row_hash() {
map<string,string> rowhash;
if(res == nullptr)
return(rowhash);
MYSQL_FIELD *fields;
MYSQL_ROW row;
unsigned long num_fields,i;
@ -49,3 +49,4 @@ map<string,string> EQDBRes::fetch_row_hash() {
return rowhash;
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EQDBRes_H_
#define EQDBRes_H_
@ -30,7 +30,7 @@ class EQDBRes {
public:
EQDBRes(MYSQL_RES *r) { res=r; }
~EQDBRes() { finish(); }
//BEGIN PERL EXPORT
unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; }
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef _WINDOWS
#include <windows.h>
@ -71,7 +71,7 @@ void AddEQEMuError(eEQEMuError iError, bool iExitNow) {
}
iterator.Advance();
}
char* tmp = new char[6];
tmp[0] = 1;
tmp[5] = 0;

View File

@ -1,26 +1,26 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EQEMuError_H
#define EQEMuError_H
#include "../common/types.h"
enum eEQEMuError { EQEMuError_NoError,
enum eEQEMuError { EQEMuError_NoError,
EQEMuError_Mysql_1405,
EQEMuError_Mysql_2003,
EQEMuError_Mysql_2005,

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "EQEmuConfig.h"
@ -63,7 +63,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
text=ParseTextBlock(sub_ele,"port",true);
if (text)
LoginPort=atoi(text);
text=ParseTextBlock(sub_ele,"account",true);
if (text)
LoginAccount=text;
@ -97,7 +97,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
}
} while(sub_ele);
}
// Check for locked
sub_ele = ele->FirstChildElement("locked");
if (sub_ele != nullptr)
@ -140,7 +140,7 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
text = sub_ele->Attribute("enabled");
if (text && !strcasecmp(text,"true"))
WorldHTTPEnabled=true;
}
}
@ -155,7 +155,7 @@ void EQEmuConfig::do_chatserver(TiXmlElement *ele) {
if (text)
ChatPort=atoi(text);
}
void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
const char *text;
@ -167,7 +167,7 @@ void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
if (text)
MailPort=atoi(text);
}
void EQEmuConfig::do_database(TiXmlElement *ele) {
const char *text;
@ -192,7 +192,7 @@ void EQEmuConfig::do_database(TiXmlElement *ele) {
DatabaseDB=text;
}
void EQEmuConfig::do_qsdatabase(TiXmlElement *ele) {
const char *text;
@ -446,27 +446,3 @@ void EQEmuConfig::Dump() const
// cout << "DynamicCount = " << DynamicCount << endl;
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __EQEmuConfig_H
#define __EQEmuConfig_H
@ -52,11 +52,11 @@ public:
uint16 WorldHTTPPort;
string WorldHTTPMimeFile;
string SharedKey;
// From <chatserver/>
string ChatHost;
uint16 ChatPort;
// From <mailserver/>
string MailHost;
uint16 MailPort;
@ -85,7 +85,7 @@ public:
string MapDir;
string QuestDir;
string PluginDir;
// From <launcher/>
string LogPrefix;
string LogSuffix;
@ -103,7 +103,7 @@ public:
// uint16 DynamicCount;
// map<string,uint16> StaticZones;
protected:
static EQEmuConfig *_config;
@ -168,7 +168,7 @@ protected:
MapDir="Maps";
QuestDir="quests";
PluginDir="plugins";
// Launcher
LogPrefix = "logs/zone-";
LogSuffix = ".log";
@ -181,22 +181,22 @@ protected:
#else
ZoneExe = "./zone";
#endif
// Zones
ZonePortLow=7000;
ZonePortHigh=7999;
DefaultStatus=0;
// For where zones need to connect to.
WorldIP="127.0.0.1";
// Dynamics to start
//DynamicCount=5;
MaxClients=-1;
LoginCount=0;
}
virtual ~EQEmuConfig() {}
@ -204,7 +204,7 @@ public:
// Produce a const singleton
static const EQEmuConfig *get() {
if (_config == nullptr)
if (_config == nullptr)
LoadConfig();
return(_config);
}

View File

@ -1,21 +1,21 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
/*
* EQStream classes, by Quagmire
*/
@ -60,18 +60,18 @@ using namespace std;
#define LOG_RAW_PACKETS_IN 0
//#define PRIORITYTEST
template <typename type> // LO_BYTE
type LO_BYTE (type a) {return (a&=0xff);}
template <typename type> // HI_BYTE
type HI_BYTE (type a) {return (a&=0xff00);}
template <typename type> // LO_WORD
type LO_WORD (type a) {return (a&=0xffff);}
template <typename type> // HI_WORD
type HI_WORD (type a) {return (a&=0xffff0000);}
template <typename type> // HI_LOSWAPshort
type HI_LOSWAPshort (type a) {return (LO_BYTE(a)<<8) | (HI_BYTE(a)>>8);}
template <typename type> // HI_LOSWAPlong
type HI_LOSWAPlong (type x) {return (LO_WORD(a)<<16) | (HIWORD(a)>>16);}
template <typename type> // LO_BYTE
type LO_BYTE (type a) {return (a&=0xff);}
template <typename type> // HI_BYTE
type HI_BYTE (type a) {return (a&=0xff00);}
template <typename type> // LO_WORD
type LO_WORD (type a) {return (a&=0xffff);}
template <typename type> // HI_WORD
type HI_WORD (type a) {return (a&=0xffff0000);}
template <typename type> // HI_LOSWAPshort
type HI_LOSWAPshort (type a) {return (LO_BYTE(a)<<8) | (HI_BYTE(a)>>8);}
template <typename type> // HI_LOSWAPlong
type HI_LOSWAPlong (type x) {return (LO_WORD(a)<<16) | (HIWORD(a)>>16);}
EQStreamServer::EQStreamServer(uint16 iPort) {
RunLoop = false;
@ -125,8 +125,8 @@ bool EQStreamServer::Open(uint16 iPort) {
unsigned long nonblocking = 1;
#endif
/* Setup internet address information.
This is used with the bind() call */
/* Setup internet address information.
This is used with the bind() call */
memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_port = htons(pPort);
@ -206,14 +206,14 @@ void EQStreamServer::Process() {
return;
}
uchar buffer[1518];
int status;
struct sockaddr_in from;
unsigned int fromlen;
uchar buffer[1518];
from.sin_family = AF_INET;
fromlen = sizeof(from);
int status;
struct sockaddr_in from;
unsigned int fromlen;
from.sin_family = AF_INET;
fromlen = sizeof(from);
while (1) {
#ifdef WIN32
@ -240,13 +240,13 @@ void EQStreamServer::Process() {
connection_list.erase(tmp);
continue;
}
EQStream* eqs_data = connection->second;
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
EQStream* eqs_data = connection->second;
if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) {
map <string, EQStream*>::iterator tmp=connection;
connection++;
safe_delete(eqs_data);
connection_list.erase(tmp);
}
}
else if(!eqs_data->RunLoop) {
eqs_data->Process(sock);
connection++;
@ -285,13 +285,13 @@ void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPo
tmp->RecvData(data, size);
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());
return;
}
if (data[1]==0x01) {
if (data[1]==0x01) {
cout << "New EQStream Connection." << endl;
EQStream* tmp = new EQStream(irIP, irPort);
tmp->RecvData(data, size);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EQNETWORK_H
#define EQNETWORK_H

View File

@ -1,19 +1,19 @@
/*
/*
Copyright (C) 2005 Michael S. Finger
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
#include <stdio.h>
@ -35,15 +35,15 @@
using namespace std;
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
: BasePacket(buf, len),
emu_opcode(op)
: BasePacket(buf, len),
emu_opcode(op)
{
}
void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer);
buffer += sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]\n", emu_opcode, size);
}
@ -68,7 +68,7 @@ void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
}
if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq);
fprintf(to, "[EmuOpCode 0x%04x Size=%lu]\n",emu_opcode,(unsigned long)size);
}
@ -76,7 +76,7 @@ void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
{
BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer);
buffer += sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]\n",opcode,size);
}
@ -102,7 +102,7 @@ void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
}
if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq);
fprintf(to, "[ProtoOpCode 0x%04x Size=%lu]\n",opcode,(unsigned long)size);
}
@ -110,7 +110,7 @@ void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
{
BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer);
#ifdef STATIC_OPCODE
buffer += sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
#else
@ -144,7 +144,7 @@ void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
}
if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq);
#ifdef STATIC_OPCODE
fprintf(to, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
#else
@ -156,7 +156,7 @@ void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) con
{
BasePacket::build_raw_header_dump(buffer, seq);
buffer += strlen(buffer);
#ifdef STATIC_OPCODE
buffer += sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
#else
@ -190,7 +190,7 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
}
if (seq != 0xffff)
fprintf(to, "[Seq=%u] ",seq);
#ifdef STATIC_OPCODE
fprintf(to, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
#else
@ -200,7 +200,7 @@ void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
uint32 EQProtocolPacket::serialize(unsigned char *dest) const
{
if (opcode>0xff) {
if (opcode>0xff) {
*(uint16 *)dest=opcode;
} else {
*(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)
: BasePacket(buf, len),
opcode(op)
: BasePacket(buf, len),
opcode(op)
{
uint32 offset;
@ -364,7 +364,7 @@ uint32 flag_offset=0;
} else
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;
newbuf[newlen++]=buffer[length-2];
newbuf[newlen++]=buffer[length-1];
@ -409,7 +409,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
buffer+=2;
size-=2;
int i;
int i;
for (i = 0 ; i+4 <= size ; i+=4)
{
int pt = (*(int*)&buffer[i])^(Key);
@ -421,7 +421,7 @@ void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey
{
test[i]=buffer[i]^KC;
}
memcpy(buffer,test,size);
memcpy(buffer,test,size);
free(test);
}
}
@ -445,7 +445,7 @@ void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey
{
test[i]=buffer[i]^KC;
}
memcpy(buffer,test,size);
memcpy(buffer,test,size);
free(test);
}
}
@ -461,43 +461,43 @@ EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
}
EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len)
: EQApplicationPacket(OP_Unknown, buf, len),
opcode(opcode)
: EQApplicationPacket(OP_Unknown, buf, len),
opcode(opcode)
{
}
EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len)
: EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16))
{
if(GetExecutablePlatform() != ExePlatformUCS) {
opcode = *((const uint16 *) buf);
if(opcode == 0x0000)
{
if(len >= 3)
{
opcode = *((const uint16 *) (buf + 1));
const unsigned char *packet_start = (buf + 3);
const int32 packet_length = len - 3;
safe_delete_array(pBuffer);
if(len >= 0)
{
size = packet_length;
pBuffer = new unsigned char[size];
memcpy(pBuffer, packet_start, size);
}
else
{
size = 0;
}
}
else
{
safe_delete_array(pBuffer);
size = 0;
}
}
} else {
opcode = *((const uint8 *) buf);
}
if(GetExecutablePlatform() != ExePlatformUCS) {
opcode = *((const uint16 *) buf);
if(opcode == 0x0000)
{
if(len >= 3)
{
opcode = *((const uint16 *) (buf + 1));
const unsigned char *packet_start = (buf + 3);
const int32 packet_length = len - 3;
safe_delete_array(pBuffer);
if(len >= 0)
{
size = packet_length;
pBuffer = new unsigned char[size];
memcpy(pBuffer, packet_start, size);
}
else
{
size = 0;
}
}
else
{
safe_delete_array(pBuffer);
size = 0;
}
}
} else {
opcode = *((const uint8 *) buf);
}
}
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {

View File

@ -1,19 +1,19 @@
/*
/*
Copyright (C) 2005 Michael S. Finger
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EQPACKET_H
#define _EQPACKET_H
@ -39,9 +39,9 @@ class EQPacket : public BasePacket {
friend class EQStream;
public:
virtual ~EQPacket() {}
uint32 Size() const { return size+2; }
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
@ -50,7 +50,7 @@ public:
void SetOpcode(EmuOpcode op) { emu_opcode = op; }
const EmuOpcode GetOpcode() const { return(emu_opcode); }
// const char *GetOpcodeName() const;
protected:
//this is just a cache so we dont look it up several times on Get()
//and it is mutable so we can store the cached copy even on a const object
@ -68,32 +68,32 @@ class EQProtocolPacket : public BasePacket {
friend class EQStream;
friend class EQStreamPair;
public:
EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) : BasePacket(buf,len), opcode(op) { acked = false; }
EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) : BasePacket(buf,len), opcode(op) { acked = false; }
// EQProtocolPacket(const unsigned char *buf, uint32 len);
bool combine(const EQProtocolPacket *rhs);
uint32 serialize (unsigned char *dest) const;
EQProtocolPacket *Copy() { return new EQProtocolPacket(opcode,pBuffer,size); }
EQRawApplicationPacket *MakeAppPacket() const;
bool acked;
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
protected:
static bool ValidateCRC(const unsigned char *buffer, int length, uint32 Key);
static uint32 Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize);
static uint32 Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize);
static void ChatDecode(unsigned char *buffer, int size, int DecodeKey);
static void ChatEncode(unsigned char *buffer, int size, int EncodeKey);
uint16 GetRawOpcode() const { return(opcode); }
uint32 Size() const { return size+2; }
//the actual raw EQ opcode
uint16 opcode;
};
@ -102,25 +102,25 @@ class EQApplicationPacket : public EQPacket {
// friend class EQProtocolPacket;
friend class EQStream;
public:
EQApplicationPacket() : EQPacket(OP_Unknown,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op) : EQPacket(op,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,nullptr,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket() : EQPacket(OP_Unknown,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op) : EQPacket(op,nullptr,0)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op,nullptr,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op,buf,len)
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
bool combine(const EQApplicationPacket *rhs);
uint32 serialize (uint16 opcode, unsigned char *dest) const;
uint32 Size() const { return size+app_opcode_size; }
virtual EQApplicationPacket *Copy() const;
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
protected:
uint8 app_opcode_size;
@ -135,17 +135,17 @@ class EQRawApplicationPacket : public EQApplicationPacket {
public:
EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len);
uint16 GetRawOpcode() const { return(opcode); }
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
virtual void build_header_dump(char *buffer) const;
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
protected:
//the actual raw EQ opcode
uint16 opcode;
EQRawApplicationPacket(const unsigned char *buf, const uint32 len);
};

View File

@ -1,19 +1,19 @@
/*
/*
Copyright (C) 2005 Michael S. Finger
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
#include <string>
@ -106,11 +106,11 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf
EQProtocolPacket *EQStream::MakeProtocolPacket(const unsigned char *buf, uint32 len) {
uint16 proto_opcode = ntohs(*(const uint16 *)buf);
//advance over opcode.
buf += 2;
len -= 2;
return(new EQProtocolPacket(proto_opcode, buf, len));
}
@ -121,7 +121,7 @@ uint32 processed=0,subpacket_length=0;
return;
// Raw Application packet
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);
if (ap)
InboundQueuePush(ap);
@ -149,7 +149,7 @@ uint32 processed=0,subpacket_length=0;
}
}
break;
case OP_AppCombined: {
processed=0;
while(processed<p->size) {
@ -171,7 +171,7 @@ uint32 processed=0,subpacket_length=0;
}
}
break;
case OP_Packet: {
if(!p->pBuffer || (p->Size() < 4))
{
@ -192,7 +192,7 @@ uint32 processed=0,subpacket_length=0;
} else if (check == SeqPast) {
_log(NET__DEBUG, _L "Duplicate OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
_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 {
// In case we did queue one before as well.
EQProtocolPacket *qp=RemoveQueue(seq);
@ -221,7 +221,7 @@ uint32 processed=0,subpacket_length=0;
}
}
break;
case OP_Fragment: {
if(!p->pBuffer || (p->Size() < 4))
{
@ -317,10 +317,10 @@ uint32 processed=0,subpacket_length=0;
#ifndef COLLECTOR
if (GetState()==ESTABLISHED) {
_log(NET__ERROR, _L "Received OP_SessionRequest in ESTABLISHED state (%d)" __L, GetState());
/*RemoveData();
init();
State=UNESTABLISHED;*/
init();
State=UNESTABLISHED;*/
_SendDisconnect();
SetState(CLOSED);
break;
@ -360,7 +360,7 @@ uint32 processed=0,subpacket_length=0;
encoded=(Response->Format&FLAG_ENCODED);
_log(NET__NET_TRACE, _L "Received OP_SessionResponse: session %lu, maxlen %d, key %lu, compressed? %s, encoded? %s" __L, (unsigned long)Session, MaxLen, (unsigned long)Key, compressed?"yes":"no", encoded?"yes":"no");
// Kinda kludgy, but trie for now
if (StreamType==UnknownStream) {
if (compressed) {
@ -406,7 +406,7 @@ uint32 processed=0,subpacket_length=0;
#ifndef COLLECTOR
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
MOutboundQueue.lock();
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
_log(NET__ERROR, _L "Pre-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
}
@ -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,
seq, SequencedBase, SequencedBase+NextSequencedSend);
#ifdef RETRANSMITS
if (!RuleB(EQStream, RetransmitAckedPackets)) {
if (!RuleB(EQStream, RetransmitAckedPackets)) {
#endif
uint16 sqsize = SequencedQueue.size();
uint16 index = seq - SequencedBase;
@ -431,7 +431,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
}
#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();
}
#endif
@ -457,9 +457,9 @@ if(NextSequencedSend > SequencedQueue.size()) {
}
#ifndef COLLECTOR
SessionStats *Stats=(SessionStats *)p->pBuffer;
_log(NET__NET_TRACE, _L "Received Stats: %lu packets received, %lu packets sent, Deltas: local %lu, (%lu <- %lu -> %lu) remote %lu" __L,
(unsigned long)ntohl(Stats->packets_received), (unsigned long)ntohl(Stats->packets_sent), (unsigned long)ntohl(Stats->last_local_delta),
(unsigned long)ntohl(Stats->low_delta), (unsigned long)ntohl(Stats->average_delta),
_log(NET__NET_TRACE, _L "Received Stats: %lu packets received, %lu packets sent, Deltas: local %lu, (%lu <- %lu -> %lu) remote %lu" __L,
(unsigned long)ntohl(Stats->packets_received), (unsigned long)ntohl(Stats->packets_sent), (unsigned long)ntohl(Stats->last_local_delta),
(unsigned long)ntohl(Stats->low_delta), (unsigned long)ntohl(Stats->average_delta),
(unsigned long)ntohl(Stats->high_delta), (unsigned long)ntohl(Stats->last_remote_delta));
uint64 x=Stats->packets_received;
Stats->packets_received=Stats->packets_sent;
@ -502,7 +502,7 @@ void EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
{
if(p == nullptr)
return;
EQApplicationPacket *newp = p->Copy();
if (newp != nullptr)
@ -513,18 +513,18 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
{
EQApplicationPacket *pack=*p;
*p = nullptr; //clear caller's pointer.. effectively takes ownership
if(pack == nullptr)
return;
if(OpMgr == nullptr || *OpMgr == nullptr) {
_log(NET__DEBUG, _L "Packet enqueued into a stream with no opcode manager, dropping." __L);
delete pack;
return;
}
uint16 opcode = (*OpMgr)->EmuToEQ(pack->emu_opcode);
//make sure this packet is compatible with this stream
/* if(StreamType == UnknownStream || StreamType == ChatOrMailStream) {
_log(NET__DEBUG, _L "Stream type undetermined (%s), packet ignored" __L, StreamTypeString(StreamType));
@ -534,9 +534,9 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
_log(NET__ERROR, _L "Trying to queue a packet of type %s into a stream of type %s, dropping it." __L, StreamTypeString(pack->GetPacketType()), StreamTypeString(StreamType));
return;
}*/
_log(NET__APP_TRACE, "Queueing %sacked packet with opcode 0x%x (%s) and length %d", ack_req?"":"non-", opcode, OpcodeManager::EmuToName(pack->emu_opcode), pack->size);
if (!ack_req) {
NonSequencedPush(new EQProtocolPacket(opcode, pack->pBuffer, pack->size));
delete pack;
@ -556,15 +556,15 @@ uint32 length;
unsigned char *tmpbuff=new unsigned char[p->size+3];
length=p->serialize(opcode, tmpbuff);
EQProtocolPacket *out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
*(uint32 *)(out->pBuffer+2)=htonl(p->Size());
used=MaxLen-10;
memcpy(out->pBuffer+6,tmpbuff,used);
_log(NET__FRAGMENT, _L "First fragment: used %d/%d. Put size %d in the packet" __L, used, p->size, p->Size());
SequencedPush(out);
while (used<length) {
out=new EQProtocolPacket(OP_Fragment,nullptr,MaxLen-4);
chunksize=min(length-used,MaxLen-6);
@ -684,9 +684,9 @@ deque<EQProtocolPacket *>::iterator sitr;
sitr = SequencedQueue.begin();
if (sitr!=SequencedQueue.end())
sitr += NextSequencedSend;
// Loop until both are empty or MaxSends is reached
while(!SeqEmpty || !NonSeqEmpty) {
while(!SeqEmpty || !NonSeqEmpty) {
// See if there are more non-sequenced packets left
if (!NonSequencedQueue.empty()) {
@ -703,7 +703,7 @@ deque<EQProtocolPacket *>::iterator sitr;
ReadyToSend.push(p);
BytesWritten+=p->size;
p=nullptr;
if (BytesWritten > threshold) {
// Sent enough this round, lets stop to be fair
_log(NET__RATES, _L "Exceeded write threshold in nonseq (%d > %d)" __L, BytesWritten, threshold);
@ -721,7 +721,7 @@ deque<EQProtocolPacket *>::iterator sitr;
}
if (sitr!=SequencedQueue.end()) {
//_log(NET__NET_COMBINE, _L "Send Seq with %d seq packets starting at seq %d, next send %d, and %d non-seq packets." __L,
//_log(NET__NET_COMBINE, _L "Send Seq with %d seq packets starting at seq %d, next send %d, and %d non-seq packets." __L,
// SequencedQueue.size(), SequencedBase, NextSequencedSend, NonSequencedQueue.size());
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
_log(NET__ERROR, _L "Pre-Send Seq NSS=%d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, NextSequencedSend, SequencedBase, SequencedQueue.size(), NextOutSeq);
@ -802,7 +802,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
delete p;
ReadyToSend.pop();
}
//see if we need to send our disconnect and finish our close
if(SeqEmpty && NonSeqEmpty) {
//no more data to send
@ -825,7 +825,7 @@ sockaddr_in address;
address.sin_port=remote_port;
#ifdef NOWAY
uint32 ip=address.sin_addr.s_addr;
cout << "Sending to: "
cout << "Sending to: "
<< (int)*(unsigned char *)&ip
<< "." << (int)*((unsigned char *)&ip+1)
<< "." << (int)*((unsigned char *)&ip+2)
@ -886,7 +886,7 @@ char temp[15];
ntohs(from->sin_port));
//cout << timestamp() << "Data from: " << temp << " OpCode 0x" << hex << setw(2) << setfill('0') << (int)p->opcode << dec << endl;
//dump_message(p->pBuffer,p->size,timestamp());
}
return p;
}*/
@ -904,12 +904,12 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(Ses
if (encoded)
Response->Format|=FLAG_ENCODED;
Response->Key=htonl(Key);
out->size=sizeof(SessionResponse);
_log(NET__NET_TRACE, _L "Sending OP_SessionResponse: session %lu, maxlen=%d, key=0x%x, compressed? %s, encoded? %s" __L,
(unsigned long)Session, MaxLen, Key, compressed?"yes":"no", encoded?"yes":"no");
NonSequencedPush(out);
}
@ -920,9 +920,9 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(Sess
memset(Request,0,sizeof(SessionRequest));
Request->Session=htonl(time(nullptr));
Request->MaxLength=htonl(512);
_log(NET__NET_TRACE, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength));
NonSequencedPush(out);
}
@ -930,11 +930,11 @@ void EQStream::_SendDisconnect()
{
if(GetState() == CLOSED)
return;
EQProtocolPacket *out=new EQProtocolPacket(OP_SessionDisconnect,nullptr,sizeof(uint32));
*(uint32 *)out->pBuffer=htonl(Session);
NonSequencedPush(out);
_log(NET__NET_TRACE, _L "Sending OP_SessionDisconnect: session %lu" __L, (unsigned long)Session);
}
@ -956,7 +956,7 @@ EQRawApplicationPacket *p=nullptr;
InboundQueue.erase(itr);
}
MInboundQueue.unlock();
//resolve the opcode if we can.
if(p) {
if(OpMgr != nullptr && *OpMgr != nullptr) {
@ -969,7 +969,7 @@ EQRawApplicationPacket *p=nullptr;
p->SetOpcode(emu_op);
}
}
return p;
}
@ -984,7 +984,7 @@ EQRawApplicationPacket *p=nullptr;
InboundQueue.erase(itr);
}
MInboundQueue.unlock();
//resolve the opcode if we can.
if(p) {
if(OpMgr != nullptr && *OpMgr != nullptr) {
@ -1018,9 +1018,9 @@ EQRawApplicationPacket *p=nullptr;
void EQStream::InboundQueueClear()
{
EQApplicationPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing inbound queue" __L);
MInboundQueue.lock();
if (!InboundQueue.empty()) {
vector<EQRawApplicationPacket *>::iterator itr;
@ -1036,11 +1036,11 @@ EQApplicationPacket *p=nullptr;
bool EQStream::HasOutgoingData()
{
bool flag;
//once closed, we have nothing more to say
if(CheckClosed())
return(false);
MOutboundQueue.lock();
flag=(!NonSequencedQueue.empty());
if (!flag) {
@ -1063,7 +1063,7 @@ void EQStream::OutboundQueueClear()
EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing outbound queue" __L);
MOutboundQueue.lock();
while(!NonSequencedQueue.empty()) {
delete NonSequencedQueue.front();
@ -1078,7 +1078,7 @@ EQProtocolPacket *p=nullptr;
SequencedQueue.clear();
}
MOutboundQueue.unlock();
/*if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
_log(NET__ERROR, _L "Out-bound Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
}
@ -1093,7 +1093,7 @@ void EQStream::PacketQueueClear()
EQProtocolPacket *p=nullptr;
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
if(!PacketQueue.empty()) {
map<unsigned short,EQProtocolPacket *>::iterator itr;
for(itr=PacketQueue.begin();itr!=PacketQueue.end();itr++) {
@ -1150,7 +1150,7 @@ long EQStream::GetLastAckSent()
void EQStream::AckPackets(uint16 seq)
{
deque<EQProtocolPacket *>::iterator itr, tmp;
MOutboundQueue.lock();
//do a bit of sanity checking.
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
@ -1159,7 +1159,7 @@ if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
if(NextSequencedSend > SequencedQueue.size()) {
_log(NET__ERROR, _L "Pre-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
}
SeqOrder ord = CompareSequence(SequencedBase, seq);
if(ord == SeqInOrder) {
//they are not acking anything new...
@ -1197,7 +1197,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
_log(NET__ERROR, _L "Post-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
}
}
MOutboundQueue.unlock();
}
@ -1222,7 +1222,7 @@ void EQStream::ProcessQueue()
if(PacketQueue.empty()) {
return;
}
EQProtocolPacket *qp=nullptr;
while((qp=RemoveQueue(NextInSeq))!=nullptr) {
_log(NET__DEBUG, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq);
@ -1308,7 +1308,7 @@ EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
if (expected_seq==seq) {
// Curent
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
return SeqFuture;
} else {
@ -1326,9 +1326,9 @@ void EQStream::SetState(EQStreamState state) {
void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
bool outgoing_data = HasOutgoingData(); //up here to avoid recursive locking
EQStreamState orig_state = GetState();
if (orig_state == CLOSING && !outgoing_data) {
_log(NET__NET_TRACE, _L "Out of data in closing state, disconnecting." __L);
@ -1410,7 +1410,7 @@ void EQStream::Close() {
EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
EQRawApplicationPacket *p = nullptr;
MatchState res = MatchNotReady;
MInboundQueue.lock();
if (!InboundQueue.empty()) {
//this is already getting hackish...
@ -1444,10 +1444,7 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
}
}
MInboundQueue.unlock();
return(res);
}

View File

@ -55,10 +55,10 @@ struct SessionStats {
/*030*/ uint64 packets_received;
/*038*/
};
#pragma pack()
class OpcodeManager;
class OpcodeManager;
//extern OpcodeManager *EQNetworkOpcodeManager;
//class EQStreamFactory;
@ -73,7 +73,7 @@ class EQStream : public EQStreamInterface {
SeqInOrder,
SeqFuture
} SeqOrder;
uint32 remote_ip;
uint16 remote_port;
uint8 buffer[8192];
@ -89,7 +89,7 @@ class EQStream : public EQStreamInterface {
uint32 Session, Key;
uint16 NextInSeq;
uint32 MaxLen;
uint32 MaxLen;
uint16 MaxSends;
uint8 active_users; //how many things are actively using this
@ -119,10 +119,10 @@ class EQStream : public EQStreamInterface {
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
long NextSequencedSend; //index into SequencedQueue
Mutex MOutboundQueue;
//a buffer we use for compression/decompression
unsigned char _tempBuffer[2048];
// Packets waiting to be processed
vector<EQRawApplicationPacket *> InboundQueue;
map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
@ -136,18 +136,18 @@ class EQStream : public EQStreamInterface {
int32 RateThreshold;
int32 DecayRate;
OpcodeManager **OpMgr;
// EQStreamFactory *const Factory;
EQRawApplicationPacket *MakeApplicationPacket(EQProtocolPacket *p);
EQRawApplicationPacket *MakeApplicationPacket(const unsigned char *buf, uint32 len);
EQProtocolPacket *MakeProtocolPacket(const unsigned char *buf, uint32 len);
void SendPacket(uint16 opcode, EQApplicationPacket *p);
void SetState(EQStreamState state);
void SendSessionResponse();
void SendSessionRequest();
void SendAck(uint16 seq);
@ -157,7 +157,7 @@ class EQStream : public EQStreamInterface {
void NonSequencedPush(EQProtocolPacket *p);
void SequencedPush(EQProtocolPacket *p);
void WritePacket(int fd,EQProtocolPacket *p);
uint32 GetKey() { return Key; }
void SetKey(uint32 k) { Key=k; }
@ -167,21 +167,21 @@ class EQStream : public EQStreamInterface {
// 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);
EQRawApplicationPacket *PeekPacket(); //for collector.
EQRawApplicationPacket *PopRawPacket(); //for collector.
void InboundQueueClear();
void OutboundQueueClear();
void PacketQueueClear();
void ProcessQueue();
EQProtocolPacket *RemoveQueue(uint16 seq);
void _SendDisconnect();
void init();
public:
EQStream() { init(); remote_ip = 0; remote_port = 0; State=UNESTABLISHED; StreamType=UnknownStream; compressed=true; encoded=false; app_opcode_size=2; bytes_sent=0; bytes_recv=0; create_time=Timer::GetTimeSeconds(); }
@ -201,21 +201,21 @@ class EQStream : public EQStreamInterface {
virtual void RemoveData() { InboundQueueClear(); OutboundQueueClear(); PacketQueueClear(); /*if (CombinedAppPacket) delete CombinedAppPacket;*/ }
virtual bool CheckState(EQStreamState state) { return GetState() == state; }
virtual std::string Describe() const { return("Direct EQStream"); }
void SetOpcodeManager(OpcodeManager **opm) { OpMgr = opm; }
void CheckTimeout(uint32 now, uint32 timeout=30);
bool HasOutgoingData();
void Process(const unsigned char *data, const uint32 length);
void SetLastPacketTime(uint32 t) {LastPacket=t;}
void Write(int eq_fd);
//
inline bool IsInUse() { bool flag; MInUse.lock(); flag=(active_users>0); MInUse.unlock(); return flag; }
inline void PutInUse() { MInUse.lock(); active_users++; MInUse.unlock(); }
inline EQStreamState GetState() { EQStreamState s; MState.lock(); s=State; MState.unlock(); return s; }
// static EQProtocolPacket *Read(int eq_fd, sockaddr_in *from);
static SeqOrder CompareSequence(uint16 expected_seq , uint16 seq);
@ -259,14 +259,14 @@ class EQStream : public EQStreamInterface {
return 0;
return bytes_recv / (Timer::GetTimeSeconds() - create_time);
}
//used for dynamic stream identification
class Signature {
public:
//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;
uint32 first_length; //0=dont check length
uint32 first_length; //0=dont check length
};
typedef enum {
MatchNotReady,
@ -274,8 +274,8 @@ class EQStream : public EQStreamInterface {
MatchFailed
} MatchState;
MatchState CheckSignature(const Signature *sig);
};
#endif

View File

@ -24,28 +24,28 @@ using namespace std;
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
{
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
#ifndef WIN32
_log(COMMON__THREADS, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
#endif
fs->ReaderLoop();
#ifndef WIN32
_log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
#endif
THREAD_RETURN(nullptr);
}
ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
{
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
#ifndef WIN32
_log(COMMON__THREADS, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
#endif
fs->WriterLoop();
#ifndef WIN32
@ -55,8 +55,8 @@ ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
THREAD_RETURN(nullptr);
}
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
: Timeoutable(5000), stream_timeout(timeout)
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
: Timeoutable(5000), stream_timeout(timeout)
{
StreamType=type;
Port=port;
@ -81,7 +81,7 @@ struct sockaddr_in address;
#ifndef WIN32
pthread_t t1,t2;
#endif
/* Setup internet address information.
/* Setup internet address information.
This is used with the bind() call */
memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET;
@ -172,10 +172,10 @@ timeval sleep_time;
continue;
} else if (num==0)
continue;
if(sock == -1)
break; //somebody closed us while we were sleeping.
if (FD_ISSET(sock,&readset)) {
#ifdef _WINDOWS
if ((length=recvfrom(sock,(char*)buffer,sizeof(buffer),0,(struct sockaddr*)&from,(int *)&socklen)) < 2)
@ -208,7 +208,7 @@ timeval sleep_time;
else
curstream->PutInUse();
MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it.
if(curstream) {
curstream->AddBytesRecv(length);
curstream->Process(buffer,length);
@ -225,17 +225,17 @@ void EQStreamFactory::CheckTimeout()
{
//lock streams the entire time were checking timeouts, it should be fast.
MStreams.lock();
unsigned long now=Timer::GetCurrentTime();
map<string,EQStream *>::iterator stream_itr;
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
EQStream *s = stream_itr->second;
s->CheckTimeout(now, stream_timeout);
EQStreamState state = s->GetState();
//not part of the else so we check it right away on state change
if (state==CLOSED) {
if (s->IsInUse()) {
@ -267,7 +267,7 @@ bool decay=false;
uint32 stream_count;
Timer DecayTimer(20);
WriterRunning=true;
DecayTimer.Enable();
while(sock!=-1) {
@ -278,12 +278,12 @@ Timer DecayTimer(20);
if (!WriterRunning)
break;
MWriterRunning.unlock();
havework = false;
wants_write.clear();
decay=DecayTimer.Check();
//copy streams into a seperate list so we dont have to keep
//MStreams locked while we are writting
MStreams.lock();
@ -291,13 +291,13 @@ Timer DecayTimer(20);
// If it's time to decay the bytes sent, then let's do it before we try to write
if (decay)
stream_itr->second->Decay();
//bullshit checking, to see if this is really happening, GDB seems to think so...
if(stream_itr->second == nullptr) {
fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %s", stream_itr->first.c_str());
continue;
}
if (stream_itr->second->HasOutgoingData()) {
havework=true;
stream_itr->second->PutInUse();
@ -305,7 +305,7 @@ Timer DecayTimer(20);
}
}
MStreams.unlock();
//do the actual writes
cur = wants_write.begin();
end = wants_write.end();
@ -313,7 +313,6 @@ Timer DecayTimer(20);
(*cur)->Write(sock);
(*cur)->ReleaseFromUse();
}
Sleep(10);
@ -328,20 +327,3 @@ Timer DecayTimer(20);
}
}

View File

@ -23,7 +23,7 @@ class EQStreamFactory : private Timeoutable {
Condition WriterWork;
EQStreamType StreamType;
queue<EQStream *> NewStreams;
Mutex MNewStreams;
@ -34,7 +34,7 @@ class EQStreamFactory : private Timeoutable {
Timer *DecayTimer;
uint32 stream_timeout;
uint32 stream_timeout;
public:
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 "EQStreamIdent.h"
#include "EQStreamProxy.h"
@ -39,12 +38,12 @@ void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const cha
void EQStreamIdentifier::Process() {
vector<Record *>::iterator cur;
vector<Patch *>::iterator curp, endp;
//foreach pending stream.
cur = m_streams.begin();
while(cur != m_streams.end()) {
Record *r = *cur;
//first see if this stream has expired
if(r->expire.Check(false)) {
//this stream has failed to match any pattern in our timeframe.
@ -54,7 +53,7 @@ void EQStreamIdentifier::Process() {
cur = m_streams.erase(cur);
continue;
}
//then make sure the stream is still active
//if stream hasn't finished initializing then continue;
if(r->stream->GetState() == UNESTABLISHED)
@ -87,18 +86,18 @@ void EQStreamIdentifier::Process() {
cur = m_streams.erase(cur);
continue;
}
//not expired, check against all patch signatures
bool found_one = false; //"we found a matching patch for this stream"
bool all_ready = true; //"all signatures were ready to check the stream"
//foreach possbile patch...
curp = m_patches.begin();
endp = m_patches.end();
for(; !found_one && curp != endp; curp++) {
Patch *p = *curp;
//ask the stream to see if it matches the supplied signature
EQStream::MatchState res = r->stream->CheckSignature(&p->signature);
switch(res) {
@ -109,13 +108,13 @@ void EQStreamIdentifier::Process() {
break;
case EQStream::MatchSuccessful: {
//yay, a match.
_log(NET__IDENTIFY, "Identified stream %s:%d with signature %s", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
//might want to do something less-specific here... some day..
EQStreamInterface *s = new EQStreamProxy(r->stream, p->structs, p->opcodes);
m_identified.push(s);
found_one = true;
break;
}
@ -125,14 +124,14 @@ void EQStreamIdentifier::Process() {
break;
}
}
//if we checked all patches and did not find a match.
if(all_ready && !found_one) {
//the stream cannot be identified.
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d, no match found.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
r->stream->ReleaseFromUse();
}
//if we found a match, or were not able to identify it
if(found_one || all_ready) {
//cannot print ip/port here. r->stream is invalid.
@ -156,44 +155,10 @@ EQStreamInterface *EQStreamIdentifier::PopIdentified() {
m_identified.pop();
return(res);
}
EQStreamIdentifier::Record::Record(EQStream *s)
: stream(s),
expire(STREAM_IDENT_WAIT_MS)
: stream(s),
expire(STREAM_IDENT_WAIT_MS)
{
}

View File

@ -15,27 +15,27 @@ class StructStrategy;
class EQStreamIdentifier {
public:
~EQStreamIdentifier();
//registration interface.
void RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs);
//main processing interface
void Process();
void AddStream(EQStream *& eqs);
EQStreamInterface *PopIdentified();
protected:
//registered patches..
class Patch {
public:
std::string name;
EQStream::Signature signature;
EQStream::Signature signature;
OpcodeManager ** opcodes;
const StructStrategy *structs;
};
std::vector<Patch *> m_patches; //we own these objects.
//pending streams..
class Record {
public:

View File

@ -19,7 +19,7 @@ class EQApplicationPacket;
class EQStreamInterface {
public:
virtual ~EQStreamInterface() {}
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) = 0;
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true) = 0;
virtual EQApplicationPacket *PopPacket() = 0;

View File

@ -1,19 +1,19 @@
/*
/*
Copyright (C) 2005 EQEmulator Team
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EQSTREAM_LOCATOR_H
#define _EQSTREAM_LOCATOR_H
@ -66,7 +66,7 @@ if(res)
else
printf(": False\n");*/
if(l.src_ip != r.src_ip)
return(l.src_ip < r.src_ip);
if(l.dst_ip != r.dst_ip)
@ -74,7 +74,7 @@ else
if(l.src_port != r.src_port)
return(l.src_port < r.src_port);
return(l.dst_port < r.dst_port);
/* //so, this turned out uglier than I had hoped
if(l.src_ip < r.src_ip)
return(true);
@ -105,35 +105,35 @@ class EQStreamLocator {
protected:
typedef typename map<const EQStreamInfo, T *>::iterator iterator;
public:
void Clear() {
streams.clear();
}
void AddStream(const EQStreamInfo &i, T *o) {
//do we care to check if it exists?
//add this stream, and its inverse
streams[i] = o;
EQStreamInfo inv;
i.invert(inv);
streams[inv] = o;
}
//deletes this stream, and its inverse
void RemoveStream(const EQStreamInfo &i) {
iterator res;
res = streams.find(i);
if(res != streams.end())
streams.erase(res);
EQStreamInfo inv;
i.invert(inv);
res = streams.find(inv);
if(res != streams.end())
streams.erase(res);
}
//removes every occurance of this stream from the list
void RemoveStream(T *it) {
iterator cur, end;
@ -142,14 +142,14 @@ public:
for(; cur != end; cur++) {
if(cur->second == it) {
streams.erase(cur);
//lazy recursive delete for now, since we have to redo
//lazy recursive delete for now, since we have to redo
//our iterators anyways
RemoveStream(it);
return;
}
}
}
T *GetStream(const EQStreamInfo &i) {
iterator res;
res = streams.find(i);
@ -160,16 +160,14 @@ public:
return(nullptr);
return(res->second);
}
//allow people to iterate over the const struct
// typedef map<const EQStreamInfo, T *>::const_iterator iterator;
// inline iterator begin() const { return(streams.begin()); }
// inline iterator end() const { return(streams.end()); }
protected:
map<const EQStreamInfo, T *> streams;
};
#endif

View File

@ -6,9 +6,9 @@
EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes)
: m_stream(stream),
m_structs(structs),
m_opcodes(opcodes)
: m_stream(stream),
m_structs(structs),
m_opcodes(opcodes)
{
stream = nullptr; //take the stream.
m_stream->SetOpcodeManager(m_opcodes);
@ -30,7 +30,7 @@ const EQClientVersion EQStreamProxy::ClientVersion() const
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
if(p == nullptr)
return;
EQApplicationPacket *newp = p->Copy();
FastQueuePacket(&newp, ack_req);
}
@ -45,7 +45,7 @@ EQApplicationPacket *EQStreamProxy::PopPacket() {
EQApplicationPacket *pack = m_stream->PopPacket();
if(pack == nullptr)
return(nullptr);
//pass this packet through the struct strategy.
m_structs->Decode(pack);
return(pack);

View File

@ -15,7 +15,7 @@ public:
//takes ownership of the stream.
EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes);
virtual ~EQStreamProxy();
//EQStreamInterface:
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true);
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true);
@ -28,28 +28,19 @@ public:
virtual bool CheckState(EQStreamState state);
virtual std::string Describe() const;
virtual const EQClientVersion ClientVersion() const;
virtual const uint32 GetBytesSent() const;
virtual const uint32 GetBytesRecieved() const;
virtual const uint32 GetBytesSentPerSecond() const;
virtual const uint32 GetBytesRecvPerSecond() const;
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.
//this is a pointer to a pointer to make it less likely that a packet will
//reference an invalid opcode manager when they are being reloaded.
OpcodeManager **const m_opcodes; //we do not own this object.
OpcodeManager **const m_opcodes; //we do not own this object.
};
#endif /*EQSTREAMPROXY_H_*/

View File

@ -1,47 +1,27 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
*
*
*
*
* 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"
@ -71,9 +51,9 @@ using namespace std;
//server side case
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_socket, uint32 irIP, uint16 irPort, bool iOldFormat)
: TCPConnection(ID, in_socket, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
: TCPConnection(ID, in_socket, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
{
id = 0;
Server = nullptr;
@ -92,14 +72,14 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_s
RelayServer = false;
RelayCount = 0;
RemoteID = 0;
}
//client outgoing connection case (and client side relay)
EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer, eTCPMode iMode)
: TCPConnection(),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
: TCPConnection(),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
{
Server = iRelayServer;
if (Server)
@ -119,9 +99,9 @@ EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer,
//server side relay case
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort)
: TCPConnection(ID, 0, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
: TCPConnection(ID, 0, irIP, irPort),
keepalive_timer(SERVER_TIMEOUT),
timeout_timer(SERVER_TIMEOUT * 2)
{
Server = iServer;
RelayLink = iRelayLink;
@ -141,7 +121,6 @@ EmuTCPConnection::~EmuTCPConnection() {
//the queues free their content right now I believe.
}
EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32 iDestination) {
int32 size = sizeof(EmuTCPNetPacket_Struct) + pack->size;
if (pack->compressed) {
@ -246,7 +225,7 @@ bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
return false;
if (GetMode() != modePacket)
return false;
LockMutex lock(&MState);
eTCPMode tmp = GetMode();
if (tmp == modeTransition) {
@ -391,13 +370,13 @@ bool EmuTCPConnection::LineOutQueuePush(char* line) {
}
}
return(TCPConnection::LineOutQueuePush(line));
}
void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
TCPConnection::Disconnect();
if (RelayLink) {
RelayLink->RemoveRelay(this, iSendRelayDisconnect);
RelayLink = 0;
@ -407,7 +386,7 @@ void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
if(!TCPConnection::ConnectIP(irIP, irPort, errbuf))
return(false);
MSendQueue.lock();
#ifdef MINILOGIN
TCPMode = modePacket;
@ -453,27 +432,26 @@ bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
}
#endif
MSendQueue.unlock();
return(true);
}
void EmuTCPConnection::ClearBuffers() {
TCPConnection::ClearBuffers();
LockMutex lock2(&MOutQueueLock);
ServerPacket* pack = 0;
while ((pack = OutQueue.pop()))
safe_delete(pack);
EmuTCPNetPacket_Struct* tnps = 0;
while ((tnps = InModeQueue.pop()))
safe_delete(tnps);
keepalive_timer.Start();
timeout_timer.Start();
}
void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
#if TCPC_DEBUG >= 1
struct in_addr in;
@ -810,7 +788,7 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
sent_something = false;
if(!TCPConnection::SendData(sent_something, errbuf))
return(false);
if(sent_something)
keepalive_timer.Start();
else if (TCPMode == modePacket && keepalive_timer.Check()) {
@ -820,9 +798,9 @@ bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
#if TCPN_DEBUG >= 5
cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << endl;
#endif
}
return(true);
}
return(true);
}
bool EmuTCPConnection::RecvData(char* errbuf) {
@ -832,24 +810,13 @@ bool EmuTCPConnection::RecvData(char* errbuf) {
else
return(false);
}
if ((TCPMode == modePacket || TCPMode == modeTransition) && timeout_timer.Check()) {
if (errbuf)
snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Connection timeout");
return false;
}
return(true);
}

View File

@ -31,67 +31,67 @@ class EmuTCPConnection : public TCPConnection {
public:
enum eTCPMode { modeConsole, modeTransition, modePacket };
enum ePacketMode { packetModeZone, packetModeLauncher, packetModeLogin, packetModeUCS, packetModeQueryServ };
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET iSock, uint32 irIP, uint16 irPort, bool iOldFormat = false);
EmuTCPConnection(bool iOldFormat = false, EmuTCPServer* iRelayServer = 0, eTCPMode iMode = modePacket); // for outgoing connections
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort); // for relay connections
virtual ~EmuTCPConnection();
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
virtual void Disconnect(bool iSendRelayDisconnect = true);
static EmuTCPNetPacket_Struct* MakePacket(ServerPacket* pack, uint32 iDestination = 0);
static SPackSendQueue* MakeOldPacket(ServerPacket* pack);
virtual bool SendPacket(ServerPacket* pack, uint32 iDestination = 0);
virtual bool SendPacket(EmuTCPNetPacket_Struct* tnps);
ServerPacket* PopPacket(); // OutQueuePop()
void SetPacketMode(ePacketMode mode) { PacketMode = mode; }
eTCPMode GetMode() const { return TCPMode; }
ePacketMode GetPacketMode() const { return(PacketMode); }
ePacketMode GetPacketMode() const { return(PacketMode); }
//relay crap:
inline bool IsRelayServer() const { return RelayServer; }
inline TCPConnection* GetRelayLink() const { return RelayLink; }
inline uint32 GetRemoteID() const { return RemoteID; }
protected:
void OutQueuePush(ServerPacket* pack);
void RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect);
void SendNetErrorPacket(const char* reason = 0);
virtual bool SendData(bool &sent_something, char* errbuf = 0);
virtual bool RecvData(char* errbuf = 0);
virtual bool ProcessReceivedData(char* errbuf = 0);
bool ProcessReceivedDataAsPackets(char* errbuf = 0);
bool ProcessReceivedDataAsOldPackets(char* errbuf = 0);
void ProcessNetworkLayerPacket(ServerPacket* pack);
virtual bool LineOutQueuePush(char* line);
virtual void ClearBuffers();
EmuTCPServer* Server;
eTCPMode TCPMode;
ePacketMode PacketMode;
bool pOldFormat;
Timer keepalive_timer;
Timer timeout_timer;
//relay crap:
EmuTCPConnection* RelayLink;
int32 RelayCount;
bool RelayServer;
uint32 RemoteID;
//input queue...
void InModeQueuePush(EmuTCPNetPacket_Struct* tnps);
MyQueue<EmuTCPNetPacket_Struct> InModeQueue;
//output queue...
MyQueue<ServerPacket> OutQueue;
Mutex MOutQueueLock;

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// @merth notes:
@ -86,7 +86,7 @@ typedef enum {
//FatherNitwit: location bits for searching specific
//places with HasItem() and HasItemByUse()
enum {
invWhereWorn = 0x01,
invWhereWorn = 0x01,
invWherePersonal = 0x02, //in the character's inventory
invWhereBank = 0x04,
invWhereSharedBank = 0x08,
@ -105,23 +105,23 @@ public:
/////////////////////////
// Public Methods
/////////////////////////
inline iter_queue begin() { return m_list.begin(); }
inline iter_queue end() { return m_list.end(); }
void push(ItemInst* inst);
void push_front(ItemInst* inst);
ItemInst* pop();
ItemInst* peek_front() const;
inline int size() { return static_cast<int>(m_list.size()); }
inline int size() { return static_cast<int>(m_list.size()); }
protected:
/////////////////////////
// Protected Members
/////////////////////////
list<ItemInst*> m_list;
};
// ########################################
@ -134,9 +134,9 @@ public:
///////////////////////////////
// Public Methods
///////////////////////////////
virtual ~Inventory();
// Retrieve a writeable item at specified slot
ItemInst* GetItem(int16 slot_id) const;
ItemInst* GetItem(int16 slot_id, uint8 bagidx) const;
@ -144,16 +144,16 @@ public:
inline iter_queue cursor_begin() { return m_cursor.begin(); }
inline iter_queue cursor_end() { return m_cursor.end(); }
inline bool CursorEmpty() { return (m_cursor.size() == 0); }
// Retrieve a read-only item from inventory
inline const ItemInst* operator[](int16 slot_id) const { return GetItem(slot_id); }
// Add item to inventory
int16 PutItem(int16 slot_id, const ItemInst& inst);
// Add item to cursor queue
int16 PushCursor(const ItemInst& inst);
// Swap items in inventory
bool SwapItem(int16 slot_a, int16 slot_b);
@ -162,17 +162,17 @@ public:
// Checks All items in a bag for No Drop
bool CheckNoDrop(int16 slot_id);
// Remove item from inventory (and take control of memory)
ItemInst* PopItem(int16 slot_id);
// Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look
int16 HasItem(uint32 item_id, uint8 quantity=0, uint8 where=0xFF);
// Check whether there is space for the specified number of the specified item.
bool HasSpaceForItem(const Item_Struct *ItemToTry, int16 Quantity);
// Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look
int16 HasItemByUse(uint8 use, uint8 quantity=0, uint8 where=0xFF);
@ -180,10 +180,10 @@ public:
// Check whether item exists in inventory
// where argument specifies OR'd list of invWhere constants to look
int16 HasItemByLoreGroup(uint32 loregroup, uint8 where=0xFF);
// Locate an available inventory slot
int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false);
// Calculate slot_id for an item within a bag
static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id
static int16 CalcSlotId(int16 bagslot_id, uint8 bagidx); // Calc slot_id for item inside bag
@ -195,25 +195,25 @@ public:
// Test whether a given slot can support a container item
static bool SupportsContainers(int16 slot_id);
void dumpInventory();
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value);
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, bool value);
std::string GetCustomItemData(int16 slot_id, std::string identifier);
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, bool value);
std::string GetCustomItemData(int16 slot_id, std::string identifier);
protected:
///////////////////////////////
// Protected Methods
///////////////////////////////
// Retrieves item within an inventory bucket
ItemInst* _GetItem(const map<int16, ItemInst*>& bucket, int16 slot_id) const;
// Private "put" item into bucket, without regard for what is currently in bucket
int16 _PutItem(int16 slot_id, ItemInst* inst);
// Checks an inventory bucket for a particular item
int16 _HasItem(map<int16, ItemInst*>& bucket, uint32 item_id, uint8 quantity);
int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity);
@ -221,8 +221,8 @@ protected:
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
int16 _HasItemByLoreGroup(map<int16, ItemInst*>& bucket, uint32 loregroup);
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
// Player inventory
map<int16, ItemInst*> m_worn; // Items worn by character
map<int16, ItemInst*> m_inv; // Items in character personal inventory
@ -245,12 +245,12 @@ public:
/////////////////////////
// Methods
/////////////////////////
// Constructors/Destructor
ItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
ItemInst(SharedDatabase *db, uint32 item_id, int16 charges = 0);
ItemInst(ItemUseType use_type) {
m_use_type = use_type;
m_item = nullptr;
@ -262,19 +262,19 @@ public:
}
ItemInst(const ItemInst& copy);
virtual ~ItemInst();
// Query item type
virtual bool IsType(ItemClass item_class) const;
// Can item be stacked?
virtual bool IsStackable() const;
// Can item be equipped by/at?
virtual bool IsEquipable(uint16 race, uint16 class_) const;
virtual bool IsEquipable(int16 slot_id) const;
//
// Augements
//
@ -322,13 +322,13 @@ public:
const uint32 GetItemScriptID() const { return m_item->ScriptFileID; }
virtual const Item_Struct* GetItem() const { return m_item; }
void SetItem(const Item_Struct* item) { m_item = item; }
int16 GetCharges() const { return m_charges; }
void SetCharges(int16 charges) { m_charges = charges; }
uint32 GetPrice() const { return m_price; }
void SetPrice(uint32 price) { m_price = price; }
void SetColor(uint32 color) { m_color = color; }
uint32 GetColor() const { return m_color; }
@ -339,7 +339,7 @@ public:
void SetMerchantCount(int32 count) { m_merchantcount = count; }
int16 GetCurrentSlot() const { return m_currentslot; }
void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; }
void SetCurrentSlot(int16 curr_slot) { m_currentslot = curr_slot; }
@ -348,24 +348,24 @@ public:
bool IsInstNoDrop() const { return m_instnodrop; }
void SetInstNoDrop(bool flag) { m_instnodrop=flag; }
std::string GetCustomDataString() const;
void SetCustomData(std::string identifier, std::string value);
void SetCustomData(std::string identifier, int value);
void SetCustomData(std::string identifier, float value);
void SetCustomData(std::string identifier, bool value);
std::string GetCustomData(std::string identifier);
void DeleteCustomData(std::string identifier);
std::string GetCustomDataString() const;
void SetCustomData(std::string identifier, std::string value);
void SetCustomData(std::string identifier, int value);
void SetCustomData(std::string identifier, float value);
void SetCustomData(std::string identifier, bool value);
std::string GetCustomData(std::string identifier);
void DeleteCustomData(std::string identifier);
// Allows treatment of this object as though it were a pointer to m_item
operator bool() const { return (m_item != nullptr); }
// Compare inner Item_Struct of two ItemInst objects
bool operator==(const ItemInst& right) const { return (this->m_item == right.m_item); }
bool operator!=(const ItemInst& right) const { return (this->m_item != right.m_item); }
// Clone current item
virtual ItemInst* Clone() const;
bool IsSlotAllowed(int16 slot_id) const;
virtual bool IsScaling() const { return false; }
@ -379,14 +379,14 @@ protected:
//////////////////////////
// Protected Members
//////////////////////////
iter_contents _begin() { return m_contents.begin(); }
iter_contents _end() { return m_contents.end(); }
iter_contents _begin() { return m_contents.begin(); }
iter_contents _end() { return m_contents.end(); }
friend class Inventory;
void _PutItem(uint8 index, ItemInst* inst) { m_contents[index] = inst; }
ItemUseType m_use_type; // Usage type for item
const Item_Struct* m_item; // Ptr to item data
int16 m_charges; // # of charges for chargeable items
@ -394,13 +394,13 @@ protected:
uint32 m_color;
uint32 m_merchantslot;
int16 m_currentslot;
bool m_instnodrop;
bool m_instnodrop;
int32 m_merchantcount; //number avaliable on the merchant, -1=unlimited
int32 m_SerialNumber; // Unique identifier for this instance of an item. Needed for Bazaar.
//
// Items inside of this item (augs or contents);
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 {
@ -410,7 +410,7 @@ public:
EvoItemInst(const ItemInst& copy);
EvoItemInst(const Item_Struct* item = nullptr, int16 charges = 0);
~EvoItemInst();
// accessors... a lot of these are for evolving items (not complete yet)
bool IsScaling() const { return (m_evolveLvl == -1); }
bool IsEvolving() const { return (m_evolveLvl >= 1); }
@ -420,16 +420,16 @@ public:
bool IsActivated() { return m_activated; }
void SetActivated(bool activated) { m_activated = activated; }
int8 GetEvolveLvl() const { return m_evolveLvl; }
EvoItemInst* Clone() const;
const Item_Struct* GetItem() const;
const Item_Struct* GetUnscaledItem() const;
void Initialize(SharedDatabase *db = nullptr);
void ScaleItem();
bool EvolveOnAllKills() const;
bool EvolveOnAllKills() const;
int8 GetMaxEvolveLvl() const;
uint32 GetKillsNeeded(uint8 currentlevel);
private:
uint32 m_exp;
@ -447,7 +447,7 @@ public:
uint32 FirstItem;
uint8 MaxLvl;
bool AllKills;
EvolveInfo();
EvolveInfo(uint32 first, uint8 max, bool allkills, uint32 L2, uint32 L3, uint32 L4, uint32 L5, uint32 L6, uint32 L7, uint32 L8, uint32 L9, uint32 L10);
~EvolveInfo();

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "MiscFunctions.h"
@ -42,7 +42,7 @@ using namespace std;
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define strcasecmp _stricmp
#else
#include <stdlib.h>
#include <ctype.h>
@ -50,9 +50,9 @@ using namespace std;
#include <sys/types.h>
#include <sys/time.h>
#ifdef FREEBSD //Timothy Whitman - January 7, 2003
#include <sys/socket.h>
#include <netinet/in.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#endif
#include <sys/stat.h>
#include <unistd.h>
#include <netdb.h>
@ -83,8 +83,8 @@ void CoutTimestamp(bool ms) {
time(&rawtime);
gmt_t = gmtime(&rawtime);
struct timeval read_time;
gettimeofday(&read_time,0);
struct timeval read_time;
gettimeofday(&read_time,0);
cout << (gmt_t->tm_year + 1900) << "/" << setw(2) << setfill('0') << (gmt_t->tm_mon + 1) << "/" << setw(2) << setfill('0') << gmt_t->tm_mday << " " << setw(2) << setfill('0') << gmt_t->tm_hour << ":" << setw(2) << setfill('0') << gmt_t->tm_min << ":" << setw(2) << setfill('0') << gmt_t->tm_sec;
if (ms)
@ -121,50 +121,50 @@ bool strn0cpyt(char* dest, const char* source, uint32 size) {
}
const char *MakeUpperString(const char *source) {
static char str[128];
if (!source)
return nullptr;
MakeUpperString(source, str);
return str;
static char str[128];
if (!source)
return nullptr;
MakeUpperString(source, str);
return str;
}
void MakeUpperString(const char *source, char *target) {
if (!source || !target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = toupper(*source);
target++;source++;
}
*target = 0;
return;
}
while (*source)
{
*target = toupper(*source);
target++;source++;
}
*target = 0;
}
const char *MakeLowerString(const char *source) {
static char str[128];
if (!source)
return nullptr;
MakeLowerString(source, str);
return str;
static char str[128];
if (!source)
return nullptr;
MakeLowerString(source, str);
return str;
}
void MakeLowerString(const char *source, char *target) {
if (!source || !target) {
if (!source || !target) {
*target=0;
return;
}
while (*source)
{
*target = tolower(*source);
target++;source++;
}
*target = 0;
return;
}
while (*source)
{
*target = tolower(*source);
target++;source++;
}
*target = 0;
}
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
int chars = -1;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= buf_len) {
@ -186,7 +186,7 @@ uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const cha
*bufsize = 256;
if (*ret == 0)
*strlen = 0;
int chars = -1;
int chars = -1;
char* oldret = 0;
va_list argptr, tmpargptr;
va_start(argptr, format);
@ -314,7 +314,7 @@ uint32 ResolveIP(const char* hostname, char* errbuf) {
snprintf(errbuf, ERRBUF_SIZE, "ResolveIP(): hostname == 0");
return 0;
}
struct sockaddr_in server_sin;
struct sockaddr_in server_sin;
#ifdef _WINDOWS
PHOSTENT phostent = nullptr;
#else
@ -383,7 +383,7 @@ const char * itoa(int num, char* a,int b) {
}
#endif
/*
/*
* generate a random integer in the range low-high this
* should be used instead of the rand()%limit method
*/
@ -394,7 +394,7 @@ int MakeRandomInt(int low, int high)
return(low);
//return (rand()%(high-low+1) + (low));
if(!WELLRNG_init) {
if(!WELLRNG_init) {
WELLRNG_init = true;
oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1;
@ -412,7 +412,7 @@ double MakeRandomFloat(double low, double high)
return(low);
//return (rand() / (double)RAND_MAX * (high - low) + low);
if(!WELLRNG_init) {
if(!WELLRNG_init) {
WELLRNG_init = true;
oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1;
@ -422,41 +422,41 @@ double MakeRandomFloat(double low, double high)
uint32 rnd_hash( time_t t, clock_t c )
{
// Get a uint32 from t and c
// Better than uint32(x) in case x is floating point in [0,1]
// Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
static uint32 differ = 0; // guarantee time-based seeds will change
uint32 h1 = 0;
unsigned char *p = (unsigned char *) &t;
for( size_t i = 0; i < sizeof(t); ++i )
{
h1 *= 255 + 2U;
h1 += p[i];
}
uint32 h2 = 0;
p = (unsigned char *) &c;
for( size_t j = 0; j < sizeof(c); ++j )
{
h2 *= 255 + 2U;
h2 += p[j];
}
return ( h1 + differ++ ) ^ h2;
// Get a uint32 from t and c
// Better than uint32(x) in case x is floating point in [0,1]
// Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
static uint32 differ = 0; // guarantee time-based seeds will change
uint32 h1 = 0;
unsigned char *p = (unsigned char *) &t;
for( size_t i = 0; i < sizeof(t); ++i )
{
h1 *= 255 + 2U;
h1 += p[i];
}
uint32 h2 = 0;
p = (unsigned char *) &c;
for( size_t j = 0; j < sizeof(c); ++j )
{
h2 *= 255 + 2U;
h2 += p[j];
}
return ( h1 + differ++ ) ^ h2;
}
void oneseed( const uint32 seed )
{
// Initialize generator state with seed
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register int j = 0;
STATE[j] = seed & 0xffffffffUL;
// Initialize generator state with seed
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register int j = 0;
STATE[j] = seed & 0xffffffffUL;
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
@ -472,79 +472,79 @@ void oneseed( const uint32 seed )
/* ***************************************************************************** */
unsigned int case_1 (void){
// state_i == 0
z0 = (VRm1Under & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0Under = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = R - 1;
WELLRNG19937 = case_3;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
// state_i == 0
z0 = (VRm1Under & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0Under = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = R - 1;
WELLRNG19937 = case_3;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
}
static unsigned int case_2 (void){
// state_i == 1
z0 = (VRm1 & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = 0;
WELLRNG19937 = case_1;
return (STATE[state_i] ^ (newVM2 & BITMASK));
// state_i == 1
z0 = (VRm1 & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = 0;
WELLRNG19937 = case_1;
return (STATE[state_i] ^ (newVM2 & BITMASK));
}
static unsigned int case_3 (void){
// state_i+M1 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1Over);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M1 < R)
WELLRNG19937 = case_5;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
// state_i+M1 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1Over);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M1 < R)
WELLRNG19937 = case_5;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
}
static unsigned int case_4 (void){
// state_i+M3 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M3 < R)
WELLRNG19937 = case_6;
return (STATE[state_i] ^ (newVM2 & BITMASK));
// state_i+M3 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M3 < R)
WELLRNG19937 = case_6;
return (STATE[state_i] ^ (newVM2 & BITMASK));
}
static unsigned int case_5 (void){
// state_i+M2 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M2 < R)
WELLRNG19937 = case_4;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
// state_i+M2 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M2 < R)
WELLRNG19937 = case_4;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
}
static unsigned int case_6 (void){
// 2 <= state_i <= (R - M3 - 1)
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i == 1)
WELLRNG19937 = case_2;
return (STATE[state_i] ^ (newVM2 & BITMASK));
// 2 <= state_i <= (R - M3 - 1)
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i == 1)
WELLRNG19937 = case_2;
return (STATE[state_i] ^ (newVM2 & BITMASK));
}
// end WELL RNG code
@ -553,10 +553,10 @@ static unsigned int case_6 (void){
char *CleanMobName(const char *in, char *out)
{
unsigned i, j;
for(i = j = 0; i < strlen(in); i++)
{
// convert _ to space.. any other conversions like this? I *think* this
// convert _ to space.. any other conversions like this? I *think* this
// is the only non alpha char that's not stripped but converted.
if(in[i] == '_')
{
@ -632,7 +632,7 @@ void RemoveApostrophes(std::string &s)
{
for(unsigned int i = 0; i < s.length(); ++i)
if(s[i] == '\'')
s[i] = '_';
s[i] = '_';
}
char *RemoveApostrophes(const char *s)
@ -643,7 +643,7 @@ char *RemoveApostrophes(const char *s)
for(unsigned int i = 0 ; i < strlen(NewString); ++i)
if(NewString[i] == '\'')
NewString[i] = '_';
NewString[i] = '_';
return NewString;
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MISCFUNCTIONS_H
#define MISCFUNCTIONS_H
@ -32,8 +32,8 @@
// These are helper macros for dealing with packets of variable length, typically those that contain
// variable length strings where it is not convenient to use a fixed length struct.
//
#define VARSTRUCT_DECODE_TYPE(Type, Buffer) *(Type *)Buffer; Buffer += sizeof(Type);
#define VARSTRUCT_DECODE_STRING(String, Buffer) strcpy(String, Buffer); Buffer += strlen(String)+1;
#define VARSTRUCT_DECODE_TYPE(Type, Buffer) *(Type *)Buffer; Buffer += sizeof(Type);
#define VARSTRUCT_DECODE_STRING(String, Buffer) strcpy(String, Buffer); Buffer += strlen(String)+1;
#define VARSTRUCT_ENCODE_STRING(Buffer, String) { sprintf(Buffer, String); Buffer += strlen(String) + 1; }
#define VARSTRUCT_ENCODE_INTSTRING(Buffer, Number) { sprintf(Buffer, "%i", Number); Buffer += strlen(Buffer) + 1; }
#define VARSTRUCT_ENCODE_TYPE(Type, Buffer, Value) { *(Type *)Buffer = Value; Buffer += sizeof(Type); }
@ -63,41 +63,41 @@
#define MAT1(v) v
#define MAT3POS(t,v) (v>>t)
#define V0 STATE[state_i]
#define VM1Over STATE[state_i+M1-R]
#define VM1 STATE[state_i+M1]
#define VM2Over STATE[state_i+M2-R]
#define VM2 STATE[state_i+M2]
#define VM3Over STATE[state_i+M3-R]
#define VM3 STATE[state_i+M3]
#define VRm1 STATE[state_i-1]
#define VRm1Under STATE[state_i+R-1]
#define VRm2 STATE[state_i-2]
#define VRm2Under STATE[state_i+R-2]
#define V0 STATE[state_i]
#define VM1Over STATE[state_i+M1-R]
#define VM1 STATE[state_i+M1]
#define VM2Over STATE[state_i+M2-R]
#define VM2 STATE[state_i+M2]
#define VM3Over STATE[state_i+M3-R]
#define VM3 STATE[state_i+M3]
#define VRm1 STATE[state_i-1]
#define VRm1Under STATE[state_i+R-1]
#define VRm2 STATE[state_i-2]
#define VRm2Under STATE[state_i+R-2]
#define newV0 STATE[state_i-1]
#define newV0Under STATE[state_i-1+R]
#define newV1 STATE[state_i]
#define newVRm1 STATE[state_i-2]
#define newVRm1Under STATE[state_i-2+R]
#define newV0 STATE[state_i-1]
#define newV0Under STATE[state_i-1+R]
#define newV1 STATE[state_i]
#define newVRm1 STATE[state_i-2]
#define newVRm1Under STATE[state_i-2+R]
#define newVM2Over STATE[state_i+M2-R+1]
#define newVM2 STATE[state_i+M2+1]
#define newVM2Over STATE[state_i+M2-R+1]
#define newVM2 STATE[state_i+M2+1]
#define BITMASK 0x41180000
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i : source - allocated null-terminated string
// return: pointer to static buffer with the target string
// MakeUpperString
// i: source - allocated null-terminated string
// return: pointer to static buffer with the target string
const char *MakeUpperString(const char *source);
const char *MakeLowerString(const char *source);
//////////////////////////////////////////////////////////////////////
//
// MakeUpperString
// i : source - allocated null-terminated string
// io: target - allocated buffer, at least of size strlen(source)+1
// MakeUpperString
// i : source - allocated null-terminated string
// io: target - allocated buffer, at least of size strlen(source)+1
void MakeUpperString(const char *source, char *target);
void MakeLowerString(const char *source, char *target);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "../common/Mutex.h"
@ -23,7 +23,7 @@ using namespace std;
#define DEBUG_MUTEX_CLASS 0
#if DEBUG_MUTEX_CLASS >= 1
#endif
#ifdef _WINDOWS

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MYMUTEX_H
#define MYMUTEX_H

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
#include "ProcLauncher.h"
@ -71,7 +71,7 @@ void ProcLauncher::Process() {
//GetLastError();
TerminateProcess(cur->second->proc_info.hProcess, 1);
}
//if we get here, the current process died.
tmp = cur;
tmp++;
@ -85,7 +85,7 @@ void ProcLauncher::Process() {
ProcRef died = waitpid(-1, &status, WNOHANG);
if(died == -1) {
//error waiting... shouldent really happen...
} else if(died == 0) {
//nothing pending...
break;
@ -102,14 +102,14 @@ void ProcLauncher::Process() {
}
}
#endif //!WIN32
}
void ProcLauncher::ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it) {
if(it->second->handler != nullptr)
it->second->handler->OnTerminate(it->first, it->second);
#ifdef _WINDOWS
CloseHandle(it->second->proc_info.hProcess);
#else //!WIN32
@ -125,18 +125,18 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
#ifdef _WINDOWS
STARTUPINFO siStartInfo;
BOOL bFuncRetn = FALSE;
// Set up members of the PROCESS_INFORMATION structure.
BOOL bFuncRetn = FALSE;
// Set up members of the PROCESS_INFORMATION structure.
ZeroMemory( &it->proc_info, sizeof(PROCESS_INFORMATION) );
// Set up members of the STARTUPINFO structure.
// Set up members of the STARTUPINFO structure.
ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.dwFlags = 0;
//handle output redirection.
HANDLE logOut = nullptr;
BOOL inherit_handles = FALSE;
@ -144,9 +144,9 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
inherit_handles = TRUE;
// Set up our log file to redirect output into.
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE; //we want this handle to be inherited by the child.
saAttr.lpSecurityDescriptor = nullptr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE; //we want this handle to be inherited by the child.
saAttr.lpSecurityDescriptor = nullptr;
logOut = CreateFile(
it->logFile.c_str(), //lpFileName
FILE_WRITE_DATA, //dwDesiredAccess
@ -155,7 +155,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
CREATE_ALWAYS, //dwCreationDisposition
FILE_FLAG_NO_BUFFERING, //dwFlagsAndAttributes
nullptr ); //hTemplateFile
//configure the startup info to redirect output appropriately.
siStartInfo.hStdError = logOut;
siStartInfo.hStdOutput = logOut;
@ -164,9 +164,9 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
}
siStartInfo.dwFlags |= CREATE_NEW_CONSOLE;
// Create the child process.
// Create the child process.
//glue together all the nice command line arguments
string args(it->program);
vector<string>::iterator cur, end;
@ -176,39 +176,39 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
args += " ";
args += *cur;
}
bFuncRetn = CreateProcess(it->program.c_str(),
const_cast<char *>(args.c_str()), // command line
nullptr, // process security attributes
nullptr, // primary thread security attributes
inherit_handles, // handles are not inherited
0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe)
nullptr, // use parent's environment
nullptr, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&it->proc_info); // receives PROCESS_INFORMATION
bFuncRetn = CreateProcess(it->program.c_str(),
const_cast<char *>(args.c_str()), // command line
nullptr, // process security attributes
nullptr, // primary thread security attributes
inherit_handles, // handles are not inherited
0, // creation flags (CREATE_NEW_PROCESS_GROUP maybe)
nullptr, // use parent's environment
nullptr, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&it->proc_info); // receives PROCESS_INFORMATION
if (bFuncRetn == 0) {
safe_delete(it);
//GetLastError()
return(ProcError);
}
//keep process handle open to get exit code
CloseHandle(it->proc_info.hThread); //we dont need their thread handle
if(logOut != nullptr)
CloseHandle(logOut); //we dont want their output handle either.
ProcRef res = it->proc_info.dwProcessId;
//record this entry..
m_running[res] = it;
return(res);
#else //!WIN32
//build argv
char **argv = new char *[it->args.size()+2];
unsigned int r;
@ -217,7 +217,7 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
argv[r] = const_cast<char *>(it->args[r-1].c_str());
}
argv[r] = nullptr;
ProcRef res = fork(); //cant use vfork since we are opening the log file.
if(res == -1) {
//error forking... errno
@ -225,10 +225,10 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
safe_delete_array(argv);
return(ProcError);
}
if(res == 0) {
//child... exec this bitch
//handle output redirection if requested.
if(it->logFile.length() > 0) {
//we will put their output directly into a file.
@ -252,20 +252,20 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) {
write(outfd, err, strlen(err));
}
close(STDIN_FILENO);
close(outfd); //dont need this one, we have two more copies...
}
}
//call it...
execv(argv[0], argv);
_exit(1);
}
safe_delete_array(argv);
//record this entry..
m_running[res] = it;
return(res);
#endif //!WIN32
}
@ -277,10 +277,10 @@ bool ProcLauncher::Terminate(const ProcRef &proc, bool graceful) {
std::map<ProcRef, Spec *>::iterator res = m_running.find(proc);
if(res == m_running.end())
return(false);
//we do not remove it from the list until we have been notified
//that they have been terminated.
#ifdef _WINDOWS
if(!TerminateProcess(res->second->proc_info.hProcess, 0)) {
return(false);
@ -311,7 +311,7 @@ void ProcLauncher::TerminateAll(bool final) {
//kill each process and remove it from the list
std::map<ProcRef, Spec *> running(m_running);
m_running.clear();
std::map<ProcRef, Spec *>::iterator cur, end;
cur = running.begin();
end = running.end();
@ -352,17 +352,3 @@ ProcLauncher::Spec &ProcLauncher::Spec::operator=(const Spec &other) {
return(*this);
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PROCLAUNCHER_H_
#define PROCLAUNCHER_H_
@ -32,7 +32,7 @@ public:
//Singleton method
static ProcLauncher *get() { return(&s_launcher); }
static void ProcessInThisThread();
#ifdef WIN32
typedef DWORD ProcRef;
static const ProcRef ProcError;
@ -47,7 +47,7 @@ public:
Spec();
Spec(const Spec &other);
Spec &operator=(const Spec &other);
std::string program;
std::vector<std::string> args;
//std::map<std::string,std::string> environment;
@ -64,30 +64,23 @@ public:
virtual ~EventHandler() {}
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
/*
* The terminate method
*/
/* The terminate method */
bool Terminate(const ProcRef &proc, bool graceful = true);
void TerminateAll(bool final = true);
/*
* The main processing method. Call regularly to check for terminated
* background processes.
*/
/* The main processing method. Call regularly to check for terminated background processes. */
void Process();
protected:
// std::vector<Spec *> m_specs;
//std::vector<Spec *> m_specs;
std::map<ProcRef, Spec *> m_running; //we own the pointers in this map
void ProcessTerminated(std::map<ProcRef, Spec *>::iterator &it);
private:
static ProcLauncher s_launcher;
#ifndef WIN32
@ -96,29 +89,5 @@ private:
#endif
};
#endif /*PROCLAUNCHER_H_*/

View File

@ -28,13 +28,13 @@ void StructStrategy::Decode(EQApplicationPacket *p) const {
proc(p);
}
void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bool ack_req) {
EQApplicationPacket *p = *in_p;
*in_p = nullptr;
_log(NET__STRUCTS, "Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode()));
delete p;
}
@ -56,13 +56,13 @@ void StructStrategy::PassDecoder(EQApplicationPacket *p) {
//effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory {
static map<EmuOpcode, const StructStrategy *> strategies;
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs) {
strategies[first_opcode] = structs;
}
const StructStrategy *FindPatch(EmuOpcode first_opcode) {
map<EmuOpcode, const StructStrategy *>::const_iterator res;
res = strategies.find(first_opcode);
@ -70,7 +70,7 @@ namespace StructStrategyFactory {
return(nullptr);
return(res->second);
}
};

View File

@ -14,18 +14,18 @@ public:
typedef void (*Encoder)(EQApplicationPacket **p, EQStream *dest, bool ack_req);
//the decoder may only edit the supplied packet, producing a single packet for eqemu to consume.
typedef void (*Decoder)(EQApplicationPacket *p);
StructStrategy();
virtual ~StructStrategy() {}
//this method takes an eqemu struct, and enqueues the produced structs into the stream.
void Encode(EQApplicationPacket **p, EQStream *dest, bool ack_req) const;
//this method takes an EQ wire struct, and converts it into an eqemu struct
void Decode(EQApplicationPacket *p) const;
virtual std::string Describe() const = 0;
virtual const EQClientVersion ClientVersion() const = 0;
protected:
//some common coders:
//Print an error saying unknown struct/opcode and drop it
@ -34,7 +34,7 @@ protected:
//pass the packet through without modification (emu == EQ) (default)
static void PassEncoder(EQApplicationPacket **p, EQStream *dest, bool ack_req);
static void PassDecoder(EQApplicationPacket *p);
Encoder encoders[_maxEmuOpcode];
Decoder decoders[_maxEmuOpcode];
};
@ -42,7 +42,7 @@ protected:
//effectively a singleton, but I decided to do it this way for no apparent reason.
namespace StructStrategyFactory {
void RegisterPatch(EmuOpcode first_opcode, const StructStrategy *structs);
//does NOT return ownership of the strategy.
const StructStrategy *FindPatch(EmuOpcode first_opcode);
};

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
@ -47,11 +47,11 @@ InitWinsock winsock;
//client version
TCPConnection::TCPConnection()
: ConnectionType(Outgoing),
connection_socket(0),
id(0),
rIP(0),
rPort(0)
: ConnectionType(Outgoing),
connection_socket(0),
id(0),
rIP(0),
rPort(0)
{
pState = TCPS_Ready;
pFree = false;
@ -69,11 +69,11 @@ TCPConnection::TCPConnection()
//server version
TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
: ConnectionType(Incomming),
connection_socket(in_socket),
id(ID),
rIP(irIP),
rPort(irPort)
: ConnectionType(Incomming),
connection_socket(in_socket),
id(ID),
rIP(irIP),
rPort(irPort)
{
pState = TCPS_Connected;
pFree = false;
@ -438,8 +438,8 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
}
connection_socket = INVALID_SOCKET;
struct sockaddr_in server_sin;
// struct in_addr in;
struct sockaddr_in server_sin;
//struct in_addr in;
if ((connection_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET || connection_socket == 0) {
#ifdef _WINDOWS
@ -490,7 +490,7 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
SetEcho(false);
ClearBuffers();
rIP = in_ip;
rPort = in_port;
SetState(TCPS_Connected);
@ -504,7 +504,7 @@ void TCPConnection::ClearBuffers() {
LockMutex lock4(&MState);
safe_delete_array(recvbuf);
safe_delete_array(sendbuf);
char* line = 0;
while ((line = LineOutQueue.pop()))
safe_delete_array(line);
@ -520,7 +520,7 @@ bool TCPConnection::CheckNetActive() {
return false;
}
/* This is always called from an IO thread. Either the server socket's thread, or a
/* This is always called from an IO thread. Either the server socket's thread, or a
* special thread we create when we make an outbound connection. */
bool TCPConnection::Process() {
char errbuf[TCPConnection_ErrorBufferSize];
@ -535,18 +535,18 @@ bool TCPConnection::Process() {
}
}
return(true);
case TCPS_Connected:
// only receive data in the connected state, no others...
if (!RecvData(errbuf)) {
struct in_addr in;
struct in_addr in;
in.s_addr = GetrIP();
//cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
return false;
}
/* we break to do the send */
break;
case TCPS_Disconnecting: {
//waiting for any sending data to go out...
MSendQueue.lock();
@ -562,7 +562,7 @@ bool TCPConnection::Process() {
MSendQueue.unlock();
}
/* Fallthrough */
case TCPS_Disconnected:
FinishDisconnect();
MRunLoop.lock();
@ -570,27 +570,27 @@ bool TCPConnection::Process() {
MRunLoop.unlock();
// SetState(TCPS_Ready); //reset the state in case they want to use it again...
return(false);
case TCPS_Closing:
//I dont understand this state...
case TCPS_Error:
MRunLoop.lock();
pRunLoop = false;
MRunLoop.unlock();
return(false);
}
/* we get here in connected or disconnecting with more data to send */
bool sent_something = false;
if (!SendData(sent_something, errbuf)) {
struct in_addr in;
struct in_addr in;
in.s_addr = GetrIP();
cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << endl;
return false;
}
return true;
}
@ -621,9 +621,9 @@ bool TCPConnection::RecvData(char* errbuf) {
}
}
status = recv(connection_socket, (char *) &recvbuf[recvbuf_used], (recvbuf_size - recvbuf_used), 0);
status = recv(connection_socket, (char *) &recvbuf[recvbuf_used], (recvbuf_size - recvbuf_used), 0);
if (status >= 1) {
if (status >= 1) {
#if TCPN_LOG_RAW_DATA_IN >= 1
struct in_addr in;
in.s_addr = GetrIP();
@ -642,7 +642,7 @@ bool TCPConnection::RecvData(char* errbuf) {
recvbuf_used += status;
if (!ProcessReceivedData(errbuf))
return false;
}
}
else if (status == SOCKET_ERROR) {
#ifdef _WINDOWS
if (!(WSAGetLastError() == WSAEWOULDBLOCK)) {
@ -770,15 +770,15 @@ bool TCPConnection::ProcessReceivedData(char* errbuf) {
i = -1;
m_previousLineEnd = true;
}
if(line != nullptr) {
bool finish_proc = false;
finish_proc = LineOutQueuePush(line);
if(finish_proc)
return(true); //break early as requested by LineOutQueuePush
}
break;
}
case 8: // backspace
@ -877,13 +877,13 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::SendData(): send(): Errorcode: %s", strerror(errno));
#endif
}
//if we get an error while disconnecting, just jump to disconnected
MState.lock();
if(pState == TCPS_Disconnecting)
pState = TCPS_Disconnected;
MState.unlock();
return false;
}
}
@ -908,7 +908,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
if (!tcpc->ConnectReady()) {
_CP(TCPConnectionLoop);
if (!tcpc->Process()) {
//the processing loop has detecting an error..
//the processing loop has detecting an error..
//we want to drop the link immediately, so we clear buffers too.
tcpc->ClearBuffers();
tcpc->Disconnect();
@ -927,11 +927,11 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
Sleep(10); //nothing to do.
}
tcpc->MLoopRunning.unlock();
#ifndef WIN32
_log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self());
#endif
THREAD_RETURN(nullptr);
}
@ -943,7 +943,3 @@ bool TCPConnection::RunLoop() {
return ret;
}

View File

@ -1,25 +1,25 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TCP_CONNECTION_H
#define TCP_CONNECTION_H
/*
Parent classes for interserver TCP Communication.
-Quagmire
Parent classes for interserver TCP Communication.
-Quagmire
*/
#ifdef _WINDOWS
@ -28,7 +28,7 @@
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define strcasecmp _stricmp
#include <process.h>
#else
@ -75,15 +75,15 @@ protected:
TCPS_Closing = 250,
TCPS_Error = 255
} State_t;
public:
//socket created by a server (incoming)
TCPConnection(uint32 ID, SOCKET iSock, uint32 irIP, uint16 irPort);
//socket created to connect to a server (outgoing)
TCPConnection(); // for outgoing connections
virtual ~TCPConnection();
// Functions for outgoing connections
bool Connect(const char* irAddress, uint16 irPort, char* errbuf = 0);
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
@ -92,7 +92,7 @@ public:
virtual void Disconnect();
bool Send(const uchar* data, int32 size);
char* PopLine(); //returns ownership of allocated byte array
inline uint32 GetrIP() const { return rIP; }
inline uint16 GetrPort() const { return rPort; }
@ -106,7 +106,7 @@ public:
bool GetEcho();
void SetEcho(bool iValue);
bool GetSockName(char *host, uint16 *port);
//should only be used by TCPServer<T>:
bool CheckNetActive();
inline bool IsFree() const { return pFree; }
@ -129,10 +129,10 @@ protected:
virtual bool ProcessReceivedData(char* errbuf = 0);
virtual bool SendData(bool &sent_something, char* errbuf = 0);
virtual bool RecvData(char* errbuf = 0);
virtual void ClearBuffers();
bool m_previousLineEnd;
eConnectionType ConnectionType;
@ -144,22 +144,22 @@ protected:
uint32 rIP;
uint16 rPort; // host byte order
bool pFree;
mutable Mutex MState;
State_t pState;
//text based line out queue.
Mutex MLineOutQueue;
virtual bool LineOutQueuePush(char* line); //this is really kinda a hack for the transition to packet mode. Returns true to stop processing the output.
MyQueue<char> LineOutQueue;
uchar* recvbuf;
int32 recvbuf_size;
int32 recvbuf_used;
int32 recvbuf_echo;
volatile bool pEcho;
Mutex MSendQueue;
uchar* sendbuf;
int32 sendbuf_size;
@ -169,7 +169,7 @@ protected:
void ServerSendQueuePushEnd(const uchar* data, int32 size);
void ServerSendQueuePushEnd(uchar** data, int32 size);
void ServerSendQueuePushFront(uchar* data, int32 size);
private:
void FinishDisconnect();
};
@ -177,5 +177,3 @@ private:
#endif

View File

@ -1,5 +1,3 @@
#include "debug.h"
#include "TCPServer.h"
#include <stdio.h>
@ -18,12 +16,8 @@
#define SOCKET_ERROR -1
#endif
#define SERVER_LOOP_GRANULARITY 3 //# of ms between checking our socket/queues
BaseTCPServer::BaseTCPServer(uint16 in_port) {
NextID = 1;
pPort = in_port;
@ -70,11 +64,11 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
THREAD_RETURN(nullptr);
}
BaseTCPServer* tcps = (BaseTCPServer*) tmp;
#ifndef WIN32
_log(COMMON__THREADS, "Starting TCPServerLoop with thread ID %d", pthread_self());
#endif
tcps->MLoopRunning.lock();
while (tcps->RunLoop()) {
_CP(BaseTCPServerLoop);
@ -82,11 +76,11 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
tcps->Process();
}
tcps->MLoopRunning.unlock();
#ifndef WIN32
_log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self());
#endif
THREAD_RETURN(nullptr);
}
@ -95,14 +89,14 @@ void BaseTCPServer::Process() {
}
void BaseTCPServer::ListenNewConnections() {
SOCKET tmpsock;
struct sockaddr_in from;
struct in_addr in;
unsigned int fromlen;
unsigned short port;
from.sin_family = AF_INET;
fromlen = sizeof(from);
SOCKET tmpsock;
struct sockaddr_in from;
struct in_addr in;
unsigned int fromlen;
unsigned short port;
from.sin_family = AF_INET;
fromlen = sizeof(from);
LockMutex lock(&MSock);
if (!sock)
return;
@ -124,7 +118,7 @@ void BaseTCPServer::ListenNewConnections() {
setsockopt(tmpsock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize));
port = from.sin_port;
in.s_addr = from.sin_addr.s_addr;
// New TCP connection, this must consume the socket.
CreateNewConnection(GetNextID(), tmpsock, in.s_addr, ntohs(from.sin_port));
}
@ -151,7 +145,7 @@ bool BaseTCPServer::Open(uint16 in_port, char* errbuf) {
#endif
int reuse_addr = 1;
// Setup internet address information.
// Setup internet address information.
// This is used with the bind() call
memset((char *) &address, 0, sizeof(address));
address.sin_family = AF_INET;
@ -211,7 +205,7 @@ bool BaseTCPServer::Open(uint16 in_port, char* errbuf) {
void BaseTCPServer::Close() {
StopLoopAndWait();
LockMutex lock(&MSock);
if (sock) {
#ifdef _WINDOWS
@ -230,4 +224,3 @@ bool BaseTCPServer::IsOpen() {
return ret;
}

View File

@ -22,17 +22,17 @@ public:
protected:
static ThreadReturnType TCPServerLoop(void* tmp);
//factory method:
virtual void CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) = 0;
virtual void Process();
bool RunLoop();
Mutex MLoopRunning;
void StopLoopAndWait();
void ListenNewConnections();
uint32 NextID;
@ -55,10 +55,10 @@ public:
TCPServer(uint16 iPort = 0)
: BaseTCPServer(iPort) {
}
virtual ~TCPServer() {
StopLoopAndWait();
//im not sure what the right thing to do here is...
//we are freeing a connection which somebody likely has a pointer to..
//but, we really shouldent ever get called anyhow..
@ -69,7 +69,7 @@ public:
delete *cur;
}
}
T * NewQueuePop() {
T * ret = nullptr;
MNewQueue.lock();
@ -80,11 +80,11 @@ public:
MNewQueue.unlock();
return ret;
}
protected:
virtual void Process() {
BaseTCPServer::Process();
vitr cur;
cur = m_list.begin();
while(cur != m_list.end()) {
@ -102,18 +102,18 @@ protected:
}
}
}
void AddConnection(T *con) {
m_list.push_back(con);
MNewQueue.lock();
m_NewQueue.push(con);
MNewQueue.unlock();
}
//queue of new connections, for the app to pull from
Mutex MNewQueue;
std::queue<T *> m_NewQueue;
vstore m_list;
};

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
#include "XMLParser.h"
@ -29,7 +29,7 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
printf("Unable to load '%s': %s\n", file, doc.ErrorDesc());
return(false);
}
TiXmlElement *root = doc.FirstChildElement( root_ele );
if(root == nullptr) {
printf("Unable to find root '%s' in %s\n",root_ele, file);
@ -37,7 +37,7 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
}
ParseOkay=true;
TiXmlNode *main_element = nullptr;
while( (main_element = root->IterateChildren( main_element )) ) {
if(main_element->Type() != TiXmlNode::ELEMENT)
@ -47,25 +47,25 @@ bool XMLParser::ParseFile(const char *file, const char *root_ele) {
handler=Handlers.find(ele->Value());
if (handler!=Handlers.end() && handler->second) {
ElementHandler h=handler->second;
/*
*
* This is kinda a sketchy operation here, since all of these
* element handler methods will be functions in child classes.
* This essentially causes us to do an un-checkable (and hence
* un-handle-properly-able) cast down to the child class. This
* WILL BREAK if any children classes do multiple inheritance.
*
*
*/
*
* This is kinda a sketchy operation here, since all of these
* element handler methods will be functions in child classes.
* This essentially causes us to do an un-checkable (and hence
* un-handle-properly-able) cast down to the child class. This
* WILL BREAK if any children classes do multiple inheritance.
*
*
*/
(this->*h)(ele);
} else {
//unhandled element.... do nothing for now
}
}
return(ParseOkay);
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef XMLParser_H
#define XMLParser_H
@ -29,18 +29,18 @@ using namespace std;
/*
* See note in XMLParser::ParseFile() before inheriting this class.
*/
* See note in XMLParser::ParseFile() before inheriting this class.
*/
class XMLParser {
public:
typedef void (XMLParser::*ElementHandler)(TiXmlElement *ele);
XMLParser();
virtual ~XMLParser() {}
bool ParseFile(const char *file, const char *root_ele);
bool ParseStatus() const { return ParseOkay; }
protected:
const char *ParseTextBlock(TiXmlNode *within, const char *name, bool optional = false);
const char *GetText(TiXmlNode *within, bool optional = false);
@ -48,12 +48,9 @@ protected:
map<string,ElementHandler> Handlers;
bool ParseOkay;
};
#endif

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef BODYTYPES_H
#define BODYTYPES_H
@ -25,7 +25,7 @@ typedef enum {
BT_Giant = 4,
BT_Construct = 5,
BT_Extraplanar = 6,
BT_Magical = 7, //this name might be a bit off,
BT_Magical = 7, //this name might be a bit off,
BT_SummonedUndead = 8,
BT_RaidGiant = 9,
// ...
@ -45,7 +45,7 @@ typedef enum {
BT_Dragon = 26,
BT_Summoned2 = 27,
BT_Summoned3 = 28,
// 29
//29
BT_VeliousDragon = 30, //might not be a tight set
// ...
BT_Dragon3 = 32,

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef BREAKDOWNS_H_
#define BREAKDOWNS_H_

View File

@ -1,279 +1,279 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "../common/classes.h"
const char* GetEQClassName(uint8 class_, uint8 level) {
switch(class_) {
case WARRIOR:
if (level >= 70)
return "Vanquisher";
else if (level >= 65)
return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE.
else if (level >= 60)
return "Warlord";
else if (level >= 55)
return "Myrmidon";
else if (level >= 51)
return "Champion";
else
return "Warrior";
case CLERIC:
if (level >= 70)
return "Prelate";
else if (level >= 65)
return "Archon";
else if (level >= 60)
return "High Priest";
else if (level >= 55)
return "Templar";
else if (level >= 51)
return "Vicar";
else
return "Cleric";
case PALADIN:
if (level >= 70)
return "Lord";
else if (level >= 65)
return "Lord Protector";
else if (level >= 60)
return "Crusader";
else if (level >= 55)
return "Knight";
else if (level >= 51)
return "Cavalier";
else
return "Paladin";
case RANGER:
if (level >= 70)
return "Plainswalker";
else if (level >= 65)
return "Forest Stalker";
else if (level >= 60)
return "Warder";
else if (level >= 55)
return "Outrider";
else if (level >= 51)
return "Pathfinder";
else
return "Ranger";
case SHADOWKNIGHT:
if (level >= 70)
return "Scourge Knight";
else if (level >= 65)
return "Dread Lord";
else if (level >= 60)
return "Grave Lord";
else if (level >= 55)
return "Revenant";
else if (level >= 51)
return "Reaver";
else
return "Shadowknight";
case DRUID:
if (level >= 70)
return "Natureguard";
else if (level >= 65)
return "Storm Warden";
else if (level >= 60)
return "Hierophant";
else if (level >= 55)
return "Preserver";
else if (level >= 51)
return "Wanderer";
else
return "Druid";
case MONK:
if (level >= 70)
return "Stone Fist";
else if (level >= 65)
return "Transcendent";
else if (level >= 60)
return "Grandmaster";
else if (level >= 55)
return "Master";
else if (level >= 51)
return "Disciple";
else
return "Monk";
case BARD:
if (level >= 70)
return "Performer";
else if (level >= 65)
return "Maestro";
else if (level >= 60)
return "Virtuoso";
else if (level >= 55)
return "Troubadour";
else if (level >= 51)
return "Minstrel";
else
return "Bard";
case ROGUE:
if (level >= 70)
return "Nemesis";
else if (level >= 65)
return "Deceiver";
else if (level >= 60)
return "Assassin";
else if (level >= 55)
return "Blackguard";
else if (level >= 51)
return "Rake";
else
return "Rogue";
case SHAMAN:
if (level >= 70)
return "Soothsayer";
else if (level >= 65)
return "Prophet";
else if (level >= 60)
return "Oracle";
else if (level >= 55)
return "Luminary";
else if (level >= 51)
return "Mystic";
else
return "Shaman";
case NECROMANCER:
if (level >= 70)
return "Wraith";
else if (level >= 65)
return "Arch Lich";
else if (level >= 60)
return "Warlock";
else if (level >= 55)
return "Defiler";
else if (level >= 51)
return "Heretic";
else
return "Necromancer";
case WIZARD:
if (level >= 70)
return "Grand Arcanist";
else if (level >= 65)
return "Arcanist";
else if (level >= 60)
return "Sorcerer";
else if (level >= 55)
return "Evoker";
else if (level >= 51)
return "Channeler";
else
return "Wizard";
case MAGICIAN:
if (level >= 70)
return "Arch Magus";
else if (level >= 65)
return "Arch Convoker";
else if (level >= 60)
return "Arch Mage";
else if (level >= 55)
return "Conjurer";
if (level >= 51)
return "Elementalist";
else
return "Magician";
case ENCHANTER:
if (level >= 70)
return "Bedazzler";
else if (level >= 65)
return "Coercer";
else if (level >= 60)
return "Phantasmist";
else if (level >= 55)
return "Beguiler";
else if (level >= 51)
return "Illusionist";
else
return "Enchanter";
case BEASTLORD:
if (level >= 70)
return "Wildblood";
else if (level >= 65)
return "Feral Lord";
else if (level >= 60)
return "Savage Lord";
else if (level >= 55)
return "Animist";
else if (level >= 51)
return "Primalist";
else
return "Beastlord";
case BERSERKER:
if (level >= 70)
return "Ravager";
else if (level >= 65)
return "Fury";
else if (level >= 60)
return "Rager";
else if (level >= 55)
return "Vehement";
else if (level >= 51)
return "Brawler";
else
return "Berserker";
case BANKER:
if (level >= 70)
return "Master Banker";
else if (level >= 65)
return "Elder Banker";
else if (level >= 60)
return "Oldest Banker";
else if (level >= 55)
return "Older Banker";
else if (level >= 51)
return "Old Banker";
else
return "Banker";
case WARRIORGM:
case WARRIOR:
if (level >= 70)
return "Vanquisher";
else if (level >= 65)
return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE.
else if (level >= 60)
return "Warlord";
else if (level >= 55)
return "Myrmidon";
else if (level >= 51)
return "Champion";
else
return "Warrior";
case CLERIC:
if (level >= 70)
return "Prelate";
else if (level >= 65)
return "Archon";
else if (level >= 60)
return "High Priest";
else if (level >= 55)
return "Templar";
else if (level >= 51)
return "Vicar";
else
return "Cleric";
case PALADIN:
if (level >= 70)
return "Lord";
else if (level >= 65)
return "Lord Protector";
else if (level >= 60)
return "Crusader";
else if (level >= 55)
return "Knight";
else if (level >= 51)
return "Cavalier";
else
return "Paladin";
case RANGER:
if (level >= 70)
return "Plainswalker";
else if (level >= 65)
return "Forest Stalker";
else if (level >= 60)
return "Warder";
else if (level >= 55)
return "Outrider";
else if (level >= 51)
return "Pathfinder";
else
return "Ranger";
case SHADOWKNIGHT:
if (level >= 70)
return "Scourge Knight";
else if (level >= 65)
return "Dread Lord";
else if (level >= 60)
return "Grave Lord";
else if (level >= 55)
return "Revenant";
else if (level >= 51)
return "Reaver";
else
return "Shadowknight";
case DRUID:
if (level >= 70)
return "Natureguard";
else if (level >= 65)
return "Storm Warden";
else if (level >= 60)
return "Hierophant";
else if (level >= 55)
return "Preserver";
else if (level >= 51)
return "Wanderer";
else
return "Druid";
case MONK:
if (level >= 70)
return "Stone Fist";
else if (level >= 65)
return "Transcendent";
else if (level >= 60)
return "Grandmaster";
else if (level >= 55)
return "Master";
else if (level >= 51)
return "Disciple";
else
return "Monk";
case BARD:
if (level >= 70)
return "Performer";
else if (level >= 65)
return "Maestro";
else if (level >= 60)
return "Virtuoso";
else if (level >= 55)
return "Troubadour";
else if (level >= 51)
return "Minstrel";
else
return "Bard";
case ROGUE:
if (level >= 70)
return "Nemesis";
else if (level >= 65)
return "Deceiver";
else if (level >= 60)
return "Assassin";
else if (level >= 55)
return "Blackguard";
else if (level >= 51)
return "Rake";
else
return "Rogue";
case SHAMAN:
if (level >= 70)
return "Soothsayer";
else if (level >= 65)
return "Prophet";
else if (level >= 60)
return "Oracle";
else if (level >= 55)
return "Luminary";
else if (level >= 51)
return "Mystic";
else
return "Shaman";
case NECROMANCER:
if (level >= 70)
return "Wraith";
else if (level >= 65)
return "Arch Lich";
else if (level >= 60)
return "Warlock";
else if (level >= 55)
return "Defiler";
else if (level >= 51)
return "Heretic";
else
return "Necromancer";
case WIZARD:
if (level >= 70)
return "Grand Arcanist";
else if (level >= 65)
return "Arcanist";
else if (level >= 60)
return "Sorcerer";
else if (level >= 55)
return "Evoker";
else if (level >= 51)
return "Channeler";
else
return "Wizard";
case MAGICIAN:
if (level >= 70)
return "Arch Magus";
else if (level >= 65)
return "Arch Convoker";
else if (level >= 60)
return "Arch Mage";
else if (level >= 55)
return "Conjurer";
if (level >= 51)
return "Elementalist";
else
return "Magician";
case ENCHANTER:
if (level >= 70)
return "Bedazzler";
else if (level >= 65)
return "Coercer";
else if (level >= 60)
return "Phantasmist";
else if (level >= 55)
return "Beguiler";
else if (level >= 51)
return "Illusionist";
else
return "Enchanter";
case BEASTLORD:
if (level >= 70)
return "Wildblood";
else if (level >= 65)
return "Feral Lord";
else if (level >= 60)
return "Savage Lord";
else if (level >= 55)
return "Animist";
else if (level >= 51)
return "Primalist";
else
return "Beastlord";
case BERSERKER:
if (level >= 70)
return "Ravager";
else if (level >= 65)
return "Fury";
else if (level >= 60)
return "Rager";
else if (level >= 55)
return "Vehement";
else if (level >= 51)
return "Brawler";
else
return "Berserker";
case BANKER:
if (level >= 70)
return "Master Banker";
else if (level >= 65)
return "Elder Banker";
else if (level >= 60)
return "Oldest Banker";
else if (level >= 55)
return "Older Banker";
else if (level >= 51)
return "Old Banker";
else
return "Banker";
case WARRIORGM:
return "Warrior Guildmaster";
case CLERICGM:
case CLERICGM:
return "Cleric Guildmaster";
case PALADINGM:
case PALADINGM:
return "Paladin Guildmaster";
case RANGERGM:
case RANGERGM:
return "Ranger Guildmaster";
case SHADOWKNIGHTGM:
case SHADOWKNIGHTGM:
return "Shadowknight Guildmaster";
case DRUIDGM:
return "Druid Guildmaster";
case MONKGM:
case DRUIDGM:
return "Druid Guildmaster";
case MONKGM:
return "Monk Guildmaster";
case BARDGM:
case BARDGM:
return "Bard Guildmaster";
case ROGUEGM:
case ROGUEGM:
return "Rogue Guildmaster";
case SHAMANGM:
case SHAMANGM:
return "Shaman Guildmaster";
case NECROMANCERGM:
case NECROMANCERGM:
return "Necromancer Guildmaster";
case WIZARDGM:
case WIZARDGM:
return "Wizard Guildmaster";
case MAGICIANGM:
case MAGICIANGM:
return "Magician Guildmaster";
case ENCHANTERGM:
case ENCHANTERGM:
return "Enchanter Guildmaster";
case BEASTLORDGM:
case BEASTLORDGM:
return "Beastlord Guildmaster";
case BERSERKERGM:
case BERSERKERGM:
return "Berserker Guildmaster";
case MERCHANT:
case MERCHANT:
return "Merchant";
case ADVENTURERECRUITER:
return "Adventure Recruiter";
@ -285,7 +285,7 @@ const char* GetEQClassName(uint8 class_, uint8 level) {
return "Tribute Master";
case GUILD_TRIBUTE_MASTER:
return "Guild Tribute Master";
default:
default:
return "Unknown";
}
}

View File

@ -1,59 +1,59 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef CLASSES_CH
#define CLASSES_CH
#include "../common/types.h"
#define Array_Class_UNKNOWN 0
#define WARRIOR 1
#define CLERIC 2
#define PALADIN 3
#define RANGER 4
#define SHADOWKNIGHT 5
#define DRUID 6
#define MONK 7
#define BARD 8
#define ROGUE 9
#define SHAMAN 10
#define NECROMANCER 11
#define WIZARD 12
#define MAGICIAN 13
#define ENCHANTER 14
#define BEASTLORD 15
#define BERSERKER 16
#define WARRIOR 1
#define CLERIC 2
#define PALADIN 3
#define RANGER 4
#define SHADOWKNIGHT 5
#define DRUID 6
#define MONK 7
#define BARD 8
#define ROGUE 9
#define SHAMAN 10
#define NECROMANCER 11
#define WIZARD 12
#define MAGICIAN 13
#define ENCHANTER 14
#define BEASTLORD 15
#define BERSERKER 16
#define PLAYER_CLASS_COUNT 16 // used for array defines, must be the count of playable classes
#define WARRIORGM 20
#define CLERICGM 21
#define PALADINGM 22
#define RANGERGM 23
#define SHADOWKNIGHTGM 24
#define DRUIDGM 25
#define MONKGM 26
#define BARDGM 27
#define ROGUEGM 28
#define SHAMANGM 29
#define NECROMANCERGM 30
#define WIZARDGM 31
#define MAGICIANGM 32
#define ENCHANTERGM 33
#define WARRIORGM 20
#define CLERICGM 21
#define PALADINGM 22
#define RANGERGM 23
#define SHADOWKNIGHTGM 24
#define DRUIDGM 25
#define MONKGM 26
#define BARDGM 27
#define ROGUEGM 28
#define SHAMANGM 29
#define NECROMANCERGM 30
#define WIZARDGM 31
#define MAGICIANGM 32
#define ENCHANTERGM 33
#define BEASTLORDGM 34
#define BERSERKERGM 35
#define BANKER 40
#define BANKER 40
#define MERCHANT 41
#define DISCORD_MERCHANT 59
#define ADVENTURERECRUITER 60

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef COMMON_PROFILE_H
#define COMMON_PROFILE_H
@ -45,41 +45,41 @@ public:
Database_DBLoadItems,
Database_GetWaypoints,
Database_DBLoadNPCFactionLists,
DBcore_RunQuery,
DBAsync_ProcessWork,
DBAsync_DispatchWork,
DBAsyncLoop_loop,
EQStreamServer_Process,
EQStream_Process,
EQStreamServerLoop,
EQStreamInLoop,
EQStreamOutLoop,
TCPServerLoop,
TCPConnectionLoop,
Inventory_GetItem,
Inventory_HasItem,
BaseTCPServerLoop,
MakeRandomInt,
MakeRandomFloat,
Mutex_lock,
Timer_Check,
WorldConnection_Process,
MaxCommonProfilerId
};
inline CommonProfiler() : GeneralProfiler(MaxCommonProfilerId) { }
};
extern CommonProfiler _cp;

View File

@ -7,107 +7,107 @@
class EQEmuStackWalker : public StackWalker
{
public:
EQEmuStackWalker() : StackWalker() { }
EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { }
virtual void OnOutput(LPCSTR szText) {
char buffer[4096];
for(int i = 0; i < 4096; ++i) {
if(szText[i] == 0) {
buffer[i] = '\0';
break;
}
EQEmuStackWalker() : StackWalker() { }
EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { }
virtual void OnOutput(LPCSTR szText) {
char buffer[4096];
for(int i = 0; i < 4096; ++i) {
if(szText[i] == 0) {
buffer[i] = '\0';
break;
}
if(szText[i] == '\n' || szText[i] == '\r') {
buffer[i] = ' ';
} else {
buffer[i] = szText[i];
}
}
if(szText[i] == '\n' || szText[i] == '\r') {
buffer[i] = ' ';
} else {
buffer[i] = szText[i];
}
}
LogFile->write(EQEMuLog::Crash, buffer);
StackWalker::OnOutput(szText);
}
LogFile->write(EQEMuLog::Crash, buffer);
StackWalker::OnOutput(szText);
}
};
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
{
switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ACCESS_VIOLATION");
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
break;
case EXCEPTION_BREAKPOINT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_BREAKPOINT");
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
break;
case EXCEPTION_FLT_INEXACT_RESULT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
break;
case EXCEPTION_FLT_INVALID_OPERATION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
break;
case EXCEPTION_FLT_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_OVERFLOW");
break;
case EXCEPTION_FLT_STACK_CHECK:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_STACK_CHECK");
break;
case EXCEPTION_FLT_UNDERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_UNDERFLOW");
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
break;
case EXCEPTION_IN_PAGE_ERROR:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_IN_PAGE_ERROR");
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
break;
case EXCEPTION_INT_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_OVERFLOW");
break;
case EXCEPTION_INVALID_DISPOSITION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INVALID_DISPOSITION");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
break;
case EXCEPTION_PRIV_INSTRUCTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_PRIV_INSTRUCTION");
break;
case EXCEPTION_SINGLE_STEP:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_SINGLE_STEP");
break;
case EXCEPTION_STACK_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_STACK_OVERFLOW");
break;
default:
LogFile->write(EQEMuLog::Crash, "Unknown Exception");
break;
}
if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
{
EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
}
return EXCEPTION_EXECUTE_HANDLER;
switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ACCESS_VIOLATION");
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
break;
case EXCEPTION_BREAKPOINT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_BREAKPOINT");
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
break;
case EXCEPTION_FLT_INEXACT_RESULT:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
break;
case EXCEPTION_FLT_INVALID_OPERATION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
break;
case EXCEPTION_FLT_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_OVERFLOW");
break;
case EXCEPTION_FLT_STACK_CHECK:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_STACK_CHECK");
break;
case EXCEPTION_FLT_UNDERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_UNDERFLOW");
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
break;
case EXCEPTION_IN_PAGE_ERROR:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_IN_PAGE_ERROR");
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
break;
case EXCEPTION_INT_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_OVERFLOW");
break;
case EXCEPTION_INVALID_DISPOSITION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INVALID_DISPOSITION");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
break;
case EXCEPTION_PRIV_INSTRUCTION:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_PRIV_INSTRUCTION");
break;
case EXCEPTION_SINGLE_STEP:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_SINGLE_STEP");
break;
case EXCEPTION_STACK_OVERFLOW:
LogFile->write(EQEMuLog::Crash, "EXCEPTION_STACK_OVERFLOW");
break;
default:
LogFile->write(EQEMuLog::Crash, "Unknown Exception");
break;
}
if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
{
EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
}
return EXCEPTION_EXECUTE_HANDLER;
}
void set_exception_handler() {
SetUnhandledExceptionFilter(windows_exception_handler);
SetUnhandledExceptionFilter(windows_exception_handler);
}
#else
// 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)
{
unsigned long data;
unsigned long check = 0xffffffff;
unsigned long check = 0xffffffff;
assert(in_length >= start_at && in_data);
for(uint32 i=start_at; i<in_length; i++)
{
data = in_data[i];
data = data ^ (check);
data = data & 0x000000ff;
check = check >> 8;
data = CRC32Table[data];
check = check ^ data;
}
memcpy(in_data, (char*)&check, 4);
for(uint32 i=start_at; i<in_length; i++)
{
data = in_data[i];
data = data ^ (check);
data = data & 0x000000ff;
check = check >> 8;
data = CRC32Table[data];
check = check ^ data;
}
memcpy(in_data, (char*)&check, 4);
}
uint32 CRC32::Update(const uint8* buf, uint32 bufsize, uint32 crc32var) {

View File

@ -8,12 +8,12 @@ public:
static uint32 Generate(const uint8* buf, uint32 bufsize);
static uint32 GenerateNoFlip(const uint8* buf, uint32 bufsize); // Same as Generate(), but without the ~
static void SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at=4);
// Multiple buffer CRC32
static uint32 Update(const uint8* buf, uint32 bufsize, uint32 crc32 = 0xFFFFFFFF);
static inline uint32 Finish(uint32 crc32) { return ~crc32; }
static inline void Finish(uint32* crc32) { *crc32 = ~(*crc32); }
private:
static inline void Calc(const uint8 byte, uint32& crc32);
};

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EQEMU_DATABASE_H
#define EQEMU_DATABASE_H
@ -76,10 +76,10 @@ EventLogDetails_Struct eld[255];
};
// Added By Hogie
// Added By Hogie
// INSERT into variables (varname,value) values('decaytime [minlevel] [maxlevel]','[number of seconds]');
// 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
struct npcDecayTimes_Struct {
uint16 minlvl;
@ -106,10 +106,10 @@ public:
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
~Database();
/*
* General Character Related Stuff
*/
* General Character Related Stuff
*/
bool MoveCharacterToZone(const char* charname, const char* zonename);
bool MoveCharacterToZone(const char* charname, const char* zonename,uint32 zoneid);
bool MoveCharacterToZone(uint32 iCharID, const char* iZonename);
@ -124,8 +124,8 @@ public:
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 CheckUsedName(const char* name);
uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0);
@ -136,15 +136,15 @@ public:
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 GetCharacterID(const char *name);
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 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 CheckGMIPs(const char* loginIP, uint32 account_id);
bool AddGMIP(char* ip_address, char* name);
void LoginIP(uint32 AccountID, const char* LoginIP);
/*
* Instancing Stuff
*/
* Instancing Stuff
*/
bool VerifyZoneInstance(uint32 zone_id, uint16 instance_id);
bool VerifyInstanceAlive(uint16 instance_id, uint32 char_id);
bool CharacterInInstanceGroup(uint16 instance_id, uint32 char_id);
@ -172,68 +172,68 @@ public:
bool GlobalInstance(uint16 instance_id);
/*
* Adventure related.
*/
* Adventure related.
*/
void UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win);
bool GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w, uint32 &tak_w,
bool GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w, uint32 &tak_w,
uint32 &guk_l, uint32 &mir_l, uint32 &mmc_l, uint32 &ruj_l, uint32 &tak_l);
/*
* Account Related
*/
* Account Related
*/
uint32 GetMiniLoginAccount(char* ip);
void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus);
uint32 CheckLogin(const char* name, const char* password, int16* oStatus = 0);
int16 CheckStatus(uint32 account_id);
uint32 CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id = 0);
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);
uint32 GetAccountIDFromLSID(uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0);
bool UpdateLiveChar(char* charname,uint32 lsaccount_id);
bool GetLiveChar(uint32 account_id, char* cname);
uint8 GetAgreementFlag(uint32 acctid);
void SetAgreementFlag(uint32 acctid);
/*
* Groups
*/
* Groups
*/
uint32 GetGroupID(const char* name);
void SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ismerc = false);
void ClearGroup(uint32 gid = 0);
char* GetGroupLeaderForLogin(const char* name,char* leaderbuf);
void SetGroupLeaderName(uint32 gid, const char* name);
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr,
GroupLeadershipAA_Struct* GLAA = nullptr);
GroupLeadershipAA_Struct* GLAA = nullptr);
void ClearGroupLeader(uint32 gid = 0);
/*
* Raids
*/
* Raids
*/
void ClearRaid(uint32 rid = 0);
void ClearRaidDetails(uint32 rid = 0);
uint32 GetRaidID(const char* name);
const char *GetRaidLeaderName(uint32 rid);
/*
* Database Varaibles
*/
* Database Varaibles
*/
bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len);
bool SetVariable(const char* varname, const char* varvalue);
bool LoadVariables();
uint32 LoadVariables_MQ(char** query);
bool LoadVariables_result(MYSQL_RES* result);
/*
* General Queries
*/
* General Queries
*/
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 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 GetZoneID(const char* zonename);
uint8 GetPEQZone(uint32 zoneID, uint32 version);
uint8 GetPEQZone(uint32 zoneID, uint32 version);
const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false);
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);
@ -243,22 +243,22 @@ public:
bool LoadPTimers(uint32 charid, PTimerList &into);
void ClearPTimers(uint32 charid);
void ClearMerchantTemp();
void SetLFP(uint32 CharID, bool LFP);
void SetLFP(uint32 CharID, bool LFP);
void SetLFG(uint32 CharID, bool LFG);
void SetFirstLogon(uint32 CharID, uint8 firstlogon);
void SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon);
void SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon);
void AddReport(std::string who, std::string against, std::string lines);
protected:
void HandleMysqlError(uint32 errnum);
private:
void DBInitVars();
uint32 max_zonename;
char** zonename_array;
Mutex Mvarcache;
uint32 varcache_max;
VarCache_Struct** varcache_array;

View File

@ -41,11 +41,11 @@ void AsyncLoadVariables(DBAsync *dba, Database *db) {
//which will get signaled when somebody puts something on the queue
ThreadReturnType DBAsyncLoop(void* tmp) {
DBAsync* dba = (DBAsync*) tmp;
#ifndef WIN32
_log(COMMON__THREADS, "Starting DBAsyncLoop with thread ID %d", pthread_self());
#endif
dba->MLoopRunning.lock();
while (dba->RunLoop()) {
//wait before working so we check the loop condition
@ -60,11 +60,11 @@ ThreadReturnType DBAsyncLoop(void* tmp) {
// Sleep(ASYNC_LOOP_GRANULARITY);
}
dba->MLoopRunning.unlock();
#ifndef WIN32
_log(COMMON__THREADS, "Ending DBAsyncLoop with thread ID %d", pthread_self());
#endif
THREAD_RETURN(nullptr);
}
@ -92,14 +92,14 @@ bool DBAsync::StopThread() {
ret = pRunLoop;
pRunLoop = false;
MRunLoop.unlock();
//signal the condition so we exit the loop if were waiting
CInList.Signal();
//this effectively waits for the processing thread to finish
MLoopRunning.lock();
MLoopRunning.unlock();
return ret;
}
@ -120,10 +120,10 @@ uint32 DBAsync::AddWork(DBAsyncWork** iWork, uint32 iDelay) {
#endif
*iWork = 0;
MInList.unlock();
//wake up the processing thread and tell it to get to work.
CInList.Signal();
return ret;
}
@ -268,7 +268,7 @@ void DBAsync::CheckTimeout() {
MFQList.unlock();
}
catch(...){
}
}

View File

@ -31,10 +31,10 @@ protected:
Condition CInList;
bool RunLoop();
void Process();
private:
virtual void CheckTimeout();
void ProcessWork(DBAsyncWork* iWork, bool iSleep = true);
void DispatchWork(DBAsyncWork* iWork);
inline uint32 GetNextID() { return pNextID++; }
@ -64,7 +64,7 @@ private:
/*
DB Work Complete Callback:
This will be called under the DBAsync thread! Never access any non-threadsafe
This will be called under the DBAsync thread! Never access any non-threadsafe
data/functions/classes. (ie: zone, entitylist, client, etc are not threadsafe)
Function prototype:
return value: true if we should delete the data, false if we should keep it
@ -103,7 +103,7 @@ public:
// Pops finished queries off the work
DBAsyncQuery* PopAnswer();
uint32 QueryCount();
Database *GetDB() const { return(m_db); }
bool CheckTimeout(uint32 iFQTimeout);

View File

@ -38,7 +38,7 @@ DBcore::DBcore() {
pDatabase = 0;
pCompress = false;
pSSL = false;
pStatus = Closed;
pStatus = Closed;
}
DBcore::~DBcore() {
@ -184,13 +184,13 @@ bool DBcore::Open(uint32* errnum, char* errbuf) {
if (GetStatus() == Error) {
mysql_close(&mysql);
mysql_init(&mysql); // Initialize structure again
}
}
if (!pHost)
return false;
/*
Added CLIENT_FOUND_ROWS flag to the connect
otherwise DB update calls would say 0 rows affected when the value already equalled
what the function was tring to set it to, therefore the function would think it failed
what the function was tring to set it to, therefore the function would think it failed
*/
uint32 flags = CLIENT_FOUND_ROWS;
if (pCompress)

View File

@ -26,7 +26,7 @@ public:
uint32 DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen);
void ping();
MYSQL* getMySQL(){ return &mysql; }
protected:
bool Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase, uint32 iPort, uint32* errnum = 0, char* errbuf = 0, bool iCompress = false, bool iSSL = false);
private:

View File

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

View File

@ -12,7 +12,7 @@ using namespace std;
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define strcasecmp _stricmp
#else
#include <sys/types.h>
#include <unistd.h>
@ -75,34 +75,34 @@ EQEMuLog::~EQEMuLog() {
bool EQEMuLog::open(LogIDs id) {
if (!logFileValid) {
return false;
}
}
if (id >= MaxLogID) {
return false;
}
}
LockMutex lock(&MOpen);
if (pLogStatus[id] & 4) {
return false;
}
if (fp[id]) {
//cerr<<"Warning: LogFile already open"<<endl;
return true;
}
}
if (fp[id]) {
//cerr<<"Warning: LogFile already open"<<endl;
return true;
}
char exename[200] = "";
const EQEmuExePlatform &platform = GetExecutablePlatform();
if(platform == ExePlatformWorld) {
snprintf(exename, sizeof(exename), "_world");
} else if(platform == ExePlatformZone) {
snprintf(exename, sizeof(exename), "_zone");
} else if(platform == ExePlatformLaunch) {
snprintf(exename, sizeof(exename), "_launch");
} else if(platform == ExePlatformUCS) {
snprintf(exename, sizeof(exename), "_ucs");
} else if(platform == ExePlatformQueryServ) {
snprintf(exename, sizeof(exename), "_queryserv");
} else if(platform == ExePlatformSharedMemory) {
snprintf(exename, sizeof(exename), "_shared_memory");
}
const EQEmuExePlatform &platform = GetExecutablePlatform();
if(platform == ExePlatformWorld) {
snprintf(exename, sizeof(exename), "_world");
} else if(platform == ExePlatformZone) {
snprintf(exename, sizeof(exename), "_zone");
} else if(platform == ExePlatformLaunch) {
snprintf(exename, sizeof(exename), "_launch");
} else if(platform == ExePlatformUCS) {
snprintf(exename, sizeof(exename), "_ucs");
} else if(platform == ExePlatformQueryServ) {
snprintf(exename, sizeof(exename), "_queryserv");
} else if(platform == ExePlatformSharedMemory) {
snprintf(exename, sizeof(exename), "_shared_memory");
}
char filename[200];
#ifndef NO_PIDLOG
@ -110,24 +110,24 @@ bool EQEMuLog::open(LogIDs id) {
#else
snprintf(filename, sizeof(filename), "%s%s.log", FileNames[id], exename);
#endif
fp[id] = fopen(filename, "a");
if (!fp[id]) {
fp[id] = fopen(filename, "a");
if (!fp[id]) {
cerr << "Failed to open log file: " << filename << endl;
pLogStatus[id] |= 4; // set file state to error
return false;
}
fputs("---------------------------------------------\n",fp[id]);
write(id, "Starting Log: %s", filename);
return true;
return false;
}
fputs("---------------------------------------------\n",fp[id]);
write(id, "Starting Log: %s", filename);
return true;
}
bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
if (!logFileValid) {
return false;
}
}
if (id >= MaxLogID) {
return false;
}
}
bool dofile = false;
if (pLogStatus[id] & 1) {
dofile = open(id);
@ -138,13 +138,13 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
if (!logFileValid)
return false; //check again for threading race reasons (to avoid two mutexes)
time_t aclock;
struct tm *newtime;
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
time_t aclock;
struct tm *newtime;
if (dofile)
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
if (dofile)
#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);
#else
@ -162,7 +162,7 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
va_copy(tmpargptr, argptr);
p(id, fmt, tmpargptr );
}
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] ", LogNames[id]);
vfprintf( stderr, fmt, argptr );
@ -173,9 +173,9 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
}
}
va_end(argptr);
if (dofile)
if (dofile)
fprintf(fp[id], "\n");
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) {
fprintf(stderr, "\n");
fflush(stderr);
@ -184,19 +184,19 @@ bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
fflush(stdout);
}
}
if(dofile)
fflush(fp[id]);
return true;
if(dofile)
fflush(fp[id]);
return true;
}
//write with Prefix and a VA_list
bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list argptr) {
if (!logFileValid) {
return false;
}
}
if (id >= MaxLogID) {
return false;
}
}
bool dofile = false;
if (pLogStatus[id] & 1) {
dofile = open(id);
@ -208,15 +208,15 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
if (!logFileValid)
return false; //check again for threading race reasons (to avoid two mutexes)
time_t aclock;
struct tm *newtime;
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
time_t aclock;
struct tm *newtime;
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
va_list tmpargptr;
if (dofile) {
if (dofile) {
#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);
#else
@ -224,13 +224,13 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
#endif
va_copy(tmpargptr, argptr);
vfprintf( fp[id], fmt, tmpargptr );
}
}
if(logCallbackPva[id]) {
msgCallbackPva p = logCallbackPva[id];
va_copy(tmpargptr, argptr);
p(id, prefix, fmt, tmpargptr );
}
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] %s", LogNames[id], prefix);
vfprintf( stderr, fmt, argptr );
@ -241,26 +241,26 @@ bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list
}
}
va_end(argptr);
if (dofile)
if (dofile)
fprintf(fp[id], "\n");
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8)
fprintf(stderr, "\n");
else
fprintf(stdout, "\n");
}
if(dofile)
fflush(fp[id]);
return true;
if(dofile)
fflush(fp[id]);
return true;
}
bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
if (!logFileValid) {
return false;
}
}
if (id >= MaxLogID) {
return false;
}
}
bool dofile = false;
if (pLogStatus[id] & 1) {
dofile = open(id);
@ -271,13 +271,13 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
if (!logFileValid)
return false; //check again for threading race reasons (to avoid two mutexes)
time_t aclock;
struct tm *newtime;
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
time_t aclock;
struct tm *newtime;
if (dofile)
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
if (dofile)
#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);
#else
@ -292,7 +292,7 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
msgCallbackBuf p = logCallbackBuf[id];
p(id, buf, size, count);
}
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] ", LogNames[id]);
fwrite(buf, size, count, stderr);
@ -303,9 +303,9 @@ bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
fprintf(stdout, "\n");
}
}
if(dofile)
fflush(fp[id]);
return true;
if(dofile)
fflush(fp[id]);
return true;
}
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);
vfprintf( fp[id], fmt, tmpargptr );
}
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8)
vfprintf( stderr, fmt, argptr );
else
vfprintf( stdout, fmt, argptr );
}
va_end(argptr);
return true;
return true;
};
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
if (!logFileValid) {
#if EQDEBUG >= 10
cerr << "Error: Dump() from null pointer"<<endl;
cerr << "Error: Dump() from null pointer"<<endl;
#endif
return false;
}
}
if (size == 0)
return true;
if (!LogFile)
@ -347,12 +347,12 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
LockMutex lock(&MLog[id]);
if (!logFileValid)
return false; //check again for threading race reasons (to avoid two mutexes)
write(id, "Dumping Packet: %i", size);
// Output as HEX
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
uint32 i;
for(i=skip; i<size; i++) {
for(i=skip; i<size; i++) {
if ((i-skip)%cols==0) {
if (i != skip)
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];
else
ascii[j++] = '.';
}
}
uint32 k = ((i-skip)-1)%cols;
if (k < 8)
writeNTS(id, dofile, " ");
@ -382,14 +382,14 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
safe_delete_array(ascii);
return true;
}
void EQEMuLog::SetCallback(LogIDs id, msgCallbackFmt proc) {
if (!logFileValid)
return;
if (id >= MaxLogID) {
return;
}
logCallbackFmt[id] = proc;
}
logCallbackFmt[id] = proc;
}
void EQEMuLog::SetCallback(LogIDs id, msgCallbackBuf proc) {
@ -397,8 +397,8 @@ void EQEMuLog::SetCallback(LogIDs id, msgCallbackBuf proc) {
return;
if (id >= MaxLogID) {
return;
}
logCallbackBuf[id] = proc;
}
logCallbackBuf[id] = proc;
}
void EQEMuLog::SetCallback(LogIDs id, msgCallbackPva proc) {
@ -406,8 +406,8 @@ void EQEMuLog::SetCallback(LogIDs id, msgCallbackPva proc) {
return;
if (id >= MaxLogID) {
return;
}
logCallbackPva[id] = proc;
}
logCallbackPva[id] = 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
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Debug Levels
@ -23,11 +23,11 @@
////// File/Console options
// 0 <= Quiet mode Errors to file Status and Normal ignored
// 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
// 4 >= Medium debug
// 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
// 8 == (Reserved for special builds) World opcode debug All packets dumped
// 9 == (Reserved for special builds) Zone Opcode debug All packets dumped
@ -103,22 +103,22 @@ public:
Debug,
Quest,
Commands,
Crash,
Crash,
MaxLogID
};
//these are callbacks called for each
typedef void (* msgCallbackBuf)(LogIDs id, const char *buf, uint8 size, uint32 count);
typedef void (* msgCallbackFmt)(LogIDs id, const char *fmt, va_list ap);
typedef void (* msgCallbackPva)(LogIDs id, const char *prefix, const char *fmt, va_list ap);
void SetAllCallbacks(msgCallbackFmt proc);
void SetAllCallbacks(msgCallbackBuf proc);
void SetAllCallbacks(msgCallbackPva proc);
void SetCallback(LogIDs id, msgCallbackFmt proc);
void SetCallback(LogIDs id, msgCallbackBuf proc);
void SetCallback(LogIDs id, msgCallbackPva proc);
bool writebuf(LogIDs id, const char *buf, uint8 size, uint32 count);
bool write(LogIDs id, const char *fmt, ...);
bool writePVA(LogIDs id, const char *prefix, const char *fmt, va_list args);
@ -137,7 +137,7 @@ private:
8 = use stderr instead (2 must be set)
*/
uint8 pLogStatus[MaxLogID];
msgCallbackFmt logCallbackFmt[MaxLogID];
msgCallbackBuf logCallbackBuf[MaxLogID];
msgCallbackPva logCallbackPva[MaxLogID];

View File

@ -1,24 +1,24 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DEITY_H
#define DEITY_H
/*
/*
** Diety List
*/
#define DEITY_AGNOSTIC 396 //drop the high bit for 140
@ -37,7 +37,7 @@
#define DEITY_TUNARE 215
//Guessed:
#define DEITY_BERTOX 201
#define DEITY_BERTOX 201
#define DEITY_RODCET 212
#define DEITY_VEESHAN 216

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
*/
#include "debug.h"
@ -21,13 +21,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
const char *OpcodeNames[_maxEmuOpcode+1] = {
"OP_Unknown",
//a preprocessor hack so we dont have to maintain two lists
#define N(x) #x
#include "emu_oplist.h"
#include "mail_oplist.h"
#include "mail_oplist.h"
#undef N
""
};

View File

@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
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
@ -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
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
*/
#ifndef EMU_OPCODES_H
#define EMU_OPCODES_H
@ -49,5 +49,3 @@ extern const char *OpcodeNames[_maxEmuOpcode+1];
#endif

View File

@ -413,7 +413,7 @@ N(OP_PetBuffWindow),
N(OP_RaidJoin),
N(OP_Translocate),
N(OP_Sacrifice),
N(OP_KeyRing),
N(OP_KeyRing),
N(OP_PopupResponse),
N(OP_DeleteCharge),
N(OP_PotionBelt),

View File

@ -1,22 +1,22 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EQ_CONSTANTS_H
#define EQ_CONSTANTS_H
#define EQ_CONSTANTS_H
#include "skills.h"
@ -53,49 +53,49 @@ enum ItemClass
*/
enum ItemTypes
{
ItemType1HS = 0,
ItemType2HS = 1,
ItemTypePierce = 2,
ItemType1HB = 3,
ItemType2HB = 4,
ItemTypeBow = 5,
ItemType1HS = 0,
ItemType2HS = 1,
ItemTypePierce = 2,
ItemType1HB = 3,
ItemType2HB = 4,
ItemTypeBow = 5,
//6
ItemTypeThrowing = 7,
ItemTypeShield = 8,
ItemTypeShield = 8,
//9
ItemTypeArmor = 10,
ItemTypeUnknon = 11, //A lot of random crap has this item use.
ItemTypeArmor = 10,
ItemTypeUnknon = 11, //A lot of random crap has this item use.
ItemTypeLockPick = 12,
ItemTypeFood = 14,
ItemTypeDrink = 15,
ItemTypeLightSource = 16,
ItemTypeStackable = 17, //Not all stackable items are this use...
ItemTypeBandage = 18,
ItemTypeThrowingv2 = 19,
ItemTypeSpell = 20, //spells and tomes
ItemTypePotion = 21,
ItemTypeWindInstr = 23,
ItemTypeStringInstr = 24,
ItemTypeBrassInstr = 25,
ItemTypeDrumInstr = 26,
ItemTypeArrow = 27,
ItemTypeJewlery = 29,
ItemTypeSkull = 30,
ItemTypeDrink = 15,
ItemTypeLightSource = 16,
ItemTypeStackable = 17, //Not all stackable items are this use...
ItemTypeBandage = 18,
ItemTypeThrowingv2 = 19,
ItemTypeSpell = 20, //spells and tomes
ItemTypePotion = 21,
ItemTypeWindInstr = 23,
ItemTypeStringInstr = 24,
ItemTypeBrassInstr = 25,
ItemTypeDrumInstr = 26,
ItemTypeArrow = 27,
ItemTypeJewlery = 29,
ItemTypeSkull = 30,
ItemTypeTome = 31,
ItemTypeNote = 32,
ItemTypeKey = 33,
ItemTypeKey = 33,
ItemTypeCoin = 34,
ItemType2HPierce = 35,
ItemTypeFishingPole = 36,
ItemTypeFishingBait = 37,
ItemTypeAlcohol = 38,
ItemTypeCompass = 40,
ItemTypePoison = 42, //might be wrong, but includes poisons
ItemTypeHand2Hand = 45,
ItemUseSinging = 50,
ItemTypeFishingPole = 36,
ItemTypeFishingBait = 37,
ItemTypeAlcohol = 38,
ItemTypeCompass = 40,
ItemTypePoison = 42, //might be wrong, but includes poisons
ItemTypeHand2Hand = 45,
ItemUseSinging = 50,
ItemUseAllInstruments = 51,
ItemTypeCharm = 52,
ItemTypeAugment = 54,
ItemTypeCharm = 52,
ItemTypeAugment = 54,
ItemTypeAugmentSolvent = 55,
ItemTypeAugmentDistill = 56
};
@ -170,7 +170,7 @@ typedef enum {
_eaMaxAppearance
} EmuAppearance;
/*
/*
** Diety List
*/
#define DEITY_UNKNOWN 0
@ -190,11 +190,11 @@ typedef enum {
#define DEITY_TUNARE 215
//Guessed:
#define DEITY_BERT 201
#define DEITY_BERT 201
#define DEITY_RODCET 212
#define DEITY_VEESHAN 216
// msg_type's for custom usercolors
// msg_type's for custom usercolors
#define MT_Say 256
#define MT_Tell 257
#define MT_Group 258
@ -284,84 +284,84 @@ typedef enum {
//from showeq
enum ChatColor
{
CC_Default = 0,
CC_DarkGrey = 1,
CC_DarkGreen = 2,
CC_DarkBlue = 3,
CC_Purple = 5,
CC_LightGrey = 6,
CC_User_Say = 256,
CC_User_Tell = 257,
CC_User_Group = 258,
CC_User_Guild = 259,
CC_User_OOC = 260,
CC_User_Auction = 261,
CC_User_Shout = 262,
CC_User_Emote = 263,
CC_User_Spells = 264,
CC_User_YouHitOther = 265,
CC_User_OtherHitYou = 266,
CC_User_YouMissOther = 267,
CC_User_OtherMissYou = 268,
CC_User_Duels = 269,
CC_User_Skills = 270,
CC_User_Disciplines = 271,
CC_User_Default = 273,
CC_User_MerchantOffer = 275,
CC_User_MerchantExchange = 276,
CC_User_YourDeath = 277,
CC_User_OtherDeath = 278,
CC_User_OtherHitOther = 279,
CC_User_OtherMissOther = 280,
CC_User_Who = 281,
CC_User_Yell = 282,
CC_User_NonMelee = 283,
CC_User_SpellWornOff = 284,
CC_User_MoneySplit = 285,
CC_User_Loot = 286,
CC_User_Random = 287,
CC_User_OtherSpells = 288,
CC_User_SpellFailure = 289,
CC_User_ChatChannel = 290,
CC_User_Chat1 = 291,
CC_User_Chat2 = 292,
CC_User_Chat3 = 293,
CC_User_Chat4 = 294,
CC_User_Chat5 = 295,
CC_User_Chat6 = 296,
CC_User_Chat7 = 297,
CC_User_Chat8 = 298,
CC_User_Chat9 = 299,
CC_User_Chat10 = 300,
CC_User_MeleeCrit = 301,
CC_User_SpellCrit = 302,
CC_User_TooFarAway = 303,
CC_User_NPCRampage = 304,
CC_User_NPCFurry = 305,
CC_User_NPCEnrage = 306,
CC_User_EchoSay = 307,
CC_User_EchoTell = 308,
CC_User_EchoGroup = 309,
CC_User_EchoGuild = 310,
CC_User_EchoOOC = 311,
CC_User_EchoAuction = 312,
CC_User_EchoShout = 313,
CC_User_EchoEmote = 314,
CC_User_EchoChat1 = 315,
CC_User_EchoChat2 = 316,
CC_User_EchoChat3 = 317,
CC_User_EchoChat4 = 318,
CC_User_EchoChat5 = 319,
CC_User_EchoChat6 = 320,
CC_User_EchoChat7 = 321,
CC_User_EchoChat8 = 322,
CC_User_EchoChat9 = 323,
CC_User_EchoChat10 = 324,
CC_User_UnusedAtThisTime = 325,
CC_User_ItemTags = 326,
CC_User_RaidSay = 327,
CC_User_MyPet = 328,
CC_User_DamageShield = 329,
CC_Default = 0,
CC_DarkGrey = 1,
CC_DarkGreen = 2,
CC_DarkBlue = 3,
CC_Purple = 5,
CC_LightGrey = 6,
CC_User_Say = 256,
CC_User_Tell = 257,
CC_User_Group = 258,
CC_User_Guild = 259,
CC_User_OOC = 260,
CC_User_Auction = 261,
CC_User_Shout = 262,
CC_User_Emote = 263,
CC_User_Spells = 264,
CC_User_YouHitOther = 265,
CC_User_OtherHitYou = 266,
CC_User_YouMissOther = 267,
CC_User_OtherMissYou = 268,
CC_User_Duels = 269,
CC_User_Skills = 270,
CC_User_Disciplines = 271,
CC_User_Default = 273,
CC_User_MerchantOffer = 275,
CC_User_MerchantExchange = 276,
CC_User_YourDeath = 277,
CC_User_OtherDeath = 278,
CC_User_OtherHitOther = 279,
CC_User_OtherMissOther = 280,
CC_User_Who = 281,
CC_User_Yell = 282,
CC_User_NonMelee = 283,
CC_User_SpellWornOff = 284,
CC_User_MoneySplit = 285,
CC_User_Loot = 286,
CC_User_Random = 287,
CC_User_OtherSpells = 288,
CC_User_SpellFailure = 289,
CC_User_ChatChannel = 290,
CC_User_Chat1 = 291,
CC_User_Chat2 = 292,
CC_User_Chat3 = 293,
CC_User_Chat4 = 294,
CC_User_Chat5 = 295,
CC_User_Chat6 = 296,
CC_User_Chat7 = 297,
CC_User_Chat8 = 298,
CC_User_Chat9 = 299,
CC_User_Chat10 = 300,
CC_User_MeleeCrit = 301,
CC_User_SpellCrit = 302,
CC_User_TooFarAway = 303,
CC_User_NPCRampage = 304,
CC_User_NPCFurry = 305,
CC_User_NPCEnrage = 306,
CC_User_EchoSay = 307,
CC_User_EchoTell = 308,
CC_User_EchoGroup = 309,
CC_User_EchoGuild = 310,
CC_User_EchoOOC = 311,
CC_User_EchoAuction = 312,
CC_User_EchoShout = 313,
CC_User_EchoEmote = 314,
CC_User_EchoChat1 = 315,
CC_User_EchoChat2 = 316,
CC_User_EchoChat3 = 317,
CC_User_EchoChat4 = 318,
CC_User_EchoChat5 = 319,
CC_User_EchoChat6 = 320,
CC_User_EchoChat7 = 321,
CC_User_EchoChat8 = 322,
CC_User_EchoChat9 = 323,
CC_User_EchoChat10 = 324,
CC_User_UnusedAtThisTime = 325,
CC_User_ItemTags = 326,
CC_User_RaidSay = 327,
CC_User_MyPet = 328,
CC_User_DamageShield = 329,
};
//ZoneChange_Struct->success values
@ -435,41 +435,41 @@ typedef enum {
#define STAT_HASTE 19
#define STAT_DAMAGE_SHIELD 20
/**
* Recast timer types. Used as an off set to charProfileStruct timers.
*/
enum RecastTypes
{
RecastTimer0 = 0,
RecastTimer1,
WeaponHealClickTimer, // 2
MuramiteBaneNukeClickTimer, // 3
RecastTimer4,
DispellClickTimer, // 5 (also click heal orbs?)
EpicTimer, // 6
OoWBPClickTimer, // 7
VishQuestClassItemTimer, // 8
HealPotionTimer, // 9
RecastTimer10,
RecastTimer11,
RecastTimer12,
RecastTimer13,
RecastTimer14,
RecastTimer15,
RecastTimer16,
RecastTimer17,
RecastTimer18,
ModRodTimer // 19
};
enum GroupUpdateAction
/**
* Recast timer types. Used as an off set to charProfileStruct timers.
*/
enum RecastTypes
{
GUA_Joined = 0,
GUA_Left = 1,
GUA_LastLeft = 6,
GUA_FullGroupInfo = 7,
GUA_MakeLeader = 8,
GUA_Started = 9
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,
GUA_Left = 1,
GUA_LastLeft = 6,
GUA_FullGroupInfo = 7,
GUA_MakeLeader = 8,
GUA_Started = 9
};
//0x1c is something...
@ -479,81 +479,81 @@ static const uint8 DamageTypeUnknown = 0xFF;
//indexed by 'SkillType'
static const uint8 SkillDamageTypes[HIGHEST_SKILL+1] = {
/* _1H_BLUNT */ 0,
/* _1H_SLASHING */ 1,
/* _2H_BLUNT */ 0,
/* _2H_SLASHING */ 1,
/* ABJURE */ SpellDamageType,
/* ALTERATION */ SpellDamageType,
/* APPLY_POISON */ DamageTypeUnknown,
/* ARCHERY */ 7,
/* BACKSTAB */ 8,
/* BIND_WOUND */ DamageTypeUnknown,
/* BASH */ 10,
/* BLOCKSKILL */ DamageTypeUnknown,
/* BRASS_INSTRUMENTS */ SpellDamageType,
/* CHANNELING */ DamageTypeUnknown,
/* CONJURATION */ SpellDamageType,
/* DEFENSE */ DamageTypeUnknown,
/* DISARM */ DamageTypeUnknown,
/* DISARM_TRAPS */ DamageTypeUnknown,
/* DIVINATION */ SpellDamageType,
/* DODGE */ DamageTypeUnknown,
/* DOUBLE_ATTACK */ DamageTypeUnknown,
/* DRAGON_PUNCH */ 21,
/* DUAL_WIELD */ DamageTypeUnknown,
/* EAGLE_STRIKE */ 23,
/* EVOCATION */ SpellDamageType,
/* FEIGN_DEATH */ 4,
/* FLYING_KICK */ 30,
/* FORAGE */ DamageTypeUnknown,
/* HAND_TO_HAND */ 4,
/* HIDE */ DamageTypeUnknown,
/* KICK */ 30,
/* MEDITATE */ DamageTypeUnknown,
/* MEND */ DamageTypeUnknown,
/* OFFENSE */ DamageTypeUnknown,
/* PARRY */ DamageTypeUnknown,
/* PICK_LOCK */ DamageTypeUnknown,
/* PIERCING */ 36,
/* RIPOSTE */ DamageTypeUnknown,
/* ROUND_KICK */ 30,
/* SAFE_FALL */ DamageTypeUnknown,
/* SENSE_HEADING */ DamageTypeUnknown,
/* SINGING */ SpellDamageType,
/* SNEAK */ DamageTypeUnknown,
/* SPECIALIZE_ABJURE */ DamageTypeUnknown,
/* SPECIALIZE_ALTERATION */ DamageTypeUnknown,
/* SPECIALIZE_CONJURATION */ DamageTypeUnknown,
/* SPECIALIZE_DIVINATION */ DamageTypeUnknown,
/* SPECIALIZE_EVOCATION */ DamageTypeUnknown,
/* PICK_POCKETS */ DamageTypeUnknown,
/* STRINGED_INSTRUMENTS */ SpellDamageType,
/* SWIMMING */ DamageTypeUnknown,
/* THROWING */ 51,
/* TIGER_CLAW */ 23,
/* TRACKING */ DamageTypeUnknown,
/* WIND_INSTRUMENTS */ SpellDamageType,
/* FISHING */ DamageTypeUnknown,
/* MAKE_POISON */ DamageTypeUnknown,
/* TINKERING */ DamageTypeUnknown,
/* RESEARCH */ DamageTypeUnknown,
/* ALCHEMY */ DamageTypeUnknown,
/* BAKING */ DamageTypeUnknown,
/* TAILORING */ DamageTypeUnknown,
/* SENSE_TRAPS */ DamageTypeUnknown,
/* BLACKSMITHING */ DamageTypeUnknown,
/* FLETCHING */ DamageTypeUnknown,
/* BREWING */ DamageTypeUnknown,
/* ALCOHOL_TOLERANCE */ DamageTypeUnknown,
/* BEGGING */ DamageTypeUnknown,
/* JEWELRY_MAKING */ DamageTypeUnknown,
/* POTTERY */ DamageTypeUnknown,
/* PERCUSSION_INSTRUMENTS */ SpellDamageType,
/* INTIMIDATION */ DamageTypeUnknown,
/* BERSERKING */ DamageTypeUnknown,
/* TAUNT */ DamageTypeUnknown,
/* FRENZY */ 74
/* _1H_BLUNT */ 0,
/* _1H_SLASHING */ 1,
/* _2H_BLUNT */ 0,
/* _2H_SLASHING */ 1,
/* ABJURE */ SpellDamageType,
/* ALTERATION */ SpellDamageType,
/* APPLY_POISON */ DamageTypeUnknown,
/* ARCHERY */ 7,
/* BACKSTAB */ 8,
/* BIND_WOUND */ DamageTypeUnknown,
/* BASH */ 10,
/* BLOCKSKILL */ DamageTypeUnknown,
/* BRASS_INSTRUMENTS */ SpellDamageType,
/* CHANNELING */ DamageTypeUnknown,
/* CONJURATION */ SpellDamageType,
/* DEFENSE */ DamageTypeUnknown,
/* DISARM */ DamageTypeUnknown,
/* DISARM_TRAPS */ DamageTypeUnknown,
/* DIVINATION */ SpellDamageType,
/* DODGE */ DamageTypeUnknown,
/* DOUBLE_ATTACK */ DamageTypeUnknown,
/* DRAGON_PUNCH */ 21,
/* DUAL_WIELD */ DamageTypeUnknown,
/* EAGLE_STRIKE */ 23,
/* EVOCATION */ SpellDamageType,
/* FEIGN_DEATH */ 4,
/* FLYING_KICK */ 30,
/* FORAGE */ DamageTypeUnknown,
/* HAND_TO_HAND */ 4,
/* HIDE */ DamageTypeUnknown,
/* KICK */ 30,
/* MEDITATE */ DamageTypeUnknown,
/* MEND */ DamageTypeUnknown,
/* OFFENSE */ DamageTypeUnknown,
/* PARRY */ DamageTypeUnknown,
/* PICK_LOCK */ DamageTypeUnknown,
/* PIERCING */ 36,
/* RIPOSTE */ DamageTypeUnknown,
/* ROUND_KICK */ 30,
/* SAFE_FALL */ DamageTypeUnknown,
/* SENSE_HEADING */ DamageTypeUnknown,
/* SINGING */ SpellDamageType,
/* SNEAK */ DamageTypeUnknown,
/* SPECIALIZE_ABJURE */ DamageTypeUnknown,
/* SPECIALIZE_ALTERATION */ DamageTypeUnknown,
/* SPECIALIZE_CONJURATION */ DamageTypeUnknown,
/* SPECIALIZE_DIVINATION */ DamageTypeUnknown,
/* SPECIALIZE_EVOCATION */ DamageTypeUnknown,
/* PICK_POCKETS */ DamageTypeUnknown,
/* STRINGED_INSTRUMENTS */ SpellDamageType,
/* SWIMMING */ DamageTypeUnknown,
/* THROWING */ 51,
/* TIGER_CLAW */ 23,
/* TRACKING */ DamageTypeUnknown,
/* WIND_INSTRUMENTS */ SpellDamageType,
/* FISHING */ DamageTypeUnknown,
/* MAKE_POISON */ DamageTypeUnknown,
/* TINKERING */ DamageTypeUnknown,
/* RESEARCH */ DamageTypeUnknown,
/* ALCHEMY */ DamageTypeUnknown,
/* BAKING */ DamageTypeUnknown,
/* TAILORING */ DamageTypeUnknown,
/* SENSE_TRAPS */ DamageTypeUnknown,
/* BLACKSMITHING */ DamageTypeUnknown,
/* FLETCHING */ DamageTypeUnknown,
/* BREWING */ DamageTypeUnknown,
/* ALCOHOL_TOLERANCE */ DamageTypeUnknown,
/* BEGGING */ DamageTypeUnknown,
/* JEWELRY_MAKING */ DamageTypeUnknown,
/* POTTERY */ DamageTypeUnknown,
/* PERCUSSION_INSTRUMENTS */ SpellDamageType,
/* INTIMIDATION */ DamageTypeUnknown,
/* BERSERKING */ DamageTypeUnknown,
/* TAUNT */ DamageTypeUnknown,
/* FRENZY */ 74
};
// Indexing positions into item material arrays
@ -593,7 +593,7 @@ enum InventorySlot
////////////////////////
// Equip slots
////////////////////////
SLOT_CHARM = 0,
SLOT_EAR01 = 1,
SLOT_HEAD = 2,
@ -616,38 +616,38 @@ enum InventorySlot
SLOT_FEET = 19,
SLOT_WAIST = 20,
SLOT_AMMO = 21,
////////////////////////
// All other slots
////////////////////////
SLOT_PERSONAL_BEGIN = 22,
SLOT_PERSONAL_END = 29,
SLOT_CURSOR = 30,
SLOT_CURSOR_END = (int16)0xFFFE, // Last item on cursor queue
// Cursor bag slots are 331->340 (10 slots)
// Personal Inventory Slots
// Slots 1 through 8 are slots 22->29
// Inventory bag slots are 251->330 (10 slots per bag)
// Tribute slots are 400-404? (upper bound unknown)
// storing these in worn item's map
// Bank slots
// Bank slots 1 through 16 are slots 2000->2015
// Bank bag slots are 2031->2190
// Shared bank slots
// Shared bank slots 1 through 2 are slots 2500->2501
// Shared bank bag slots are 2531->2550
// Trade session slots
// Trade slots 1 through 8 are slots 3000->3007
// Trade bag slots are technically 0->79 when passed to client,
// but in our code, we treat them as slots 3100->3179
// Slot used in OP_TradeSkillCombine for world tradeskill containers
SLOT_TRADESKILL = 1000,
SLOT_AUGMENT = 1001,

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,65 @@
/* EQEmu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEmu Development Team (http://www.eqemulator.net)
/* EQEmu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEmu Development Team (http://www.eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "eqemu_exception.h"
namespace EQEmu
namespace EQEmu
{
Exception::Exception(const char* name, const std::string& description, const char* file, long line)
: line_(line),
file_(file),
desc_(description),
name_(name)
{
}
Exception::Exception(const Exception& e)
: line_(e.line_),
file_(e.file_),
desc_(e.desc_),
name_(e.name_)
{
}
Exception::Exception(const char* name, const std::string& description, const char* file, long line)
: line_(line),
file_(file),
desc_(description),
name_(name)
{
}
Exception::Exception(const Exception& e)
: line_(e.line_),
file_(e.file_),
desc_(e.desc_),
name_(e.name_)
{
}
#ifdef EQEMU_RVALUE_MOVE
Exception::Exception(const Exception&& e)
: line_(e.line_),
file_(e.file_),
desc_(e.desc_),
name_(e.name_)
{
}
Exception::Exception(const Exception&& e)
: line_(e.line_),
file_(e.file_),
desc_(e.desc_),
name_(e.name_)
{
}
#endif
void Exception::operator=(const Exception& e) {
line_ = e.line_;
file_ = e.file_;
desc_ = e.desc_;
name_ = e.name_;
}
const std::string& Exception::full_description() const {
if(full_desc_.empty()) {
std::stringstream ss;
ss << "EQEmu Exception (" << name_ << ") in " << file_;
ss << " at line (" << line_ << "): " << desc_;
full_desc_ = ss.str();
}
return full_desc_;
}
void Exception::operator=(const Exception& e) {
line_ = e.line_;
file_ = e.file_;
desc_ = e.desc_;
name_ = e.name_;
}
const std::string& Exception::full_description() const {
if(full_desc_.empty()) {
std::stringstream ss;
ss << "EQEmu Exception (" << name_ << ") in " << file_;
ss << " at line (" << line_ << "): " << desc_;
full_desc_ = ss.str();
}
return full_desc_;
}
} // EQEmu

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EQEMU_EQEMUEXCEPTION_H
@ -24,83 +24,83 @@
namespace EQEmu
{
//! EQEmu Exception Class
/*!
A custom exception class for things EQEmu throws.
*/
class Exception : public std::exception {
public:
//! Detailed Constructor
/*!
\param name The name given for this exception.
\param description The description for this exception.
\param file The file name for this exception.
\param line The line number for this exception.
*/
Exception(const char* name, const std::string& description, const char* file, long line);
//! Copy Constructor
Exception(const Exception& e);
//! Move Constructor
#ifdef EQEMU_RVALUE_MOVE
Exception(const Exception&& e);
#endif
//! Destructor
~Exception() throw() { }
//! Assignment Operator
void operator=(const Exception& e);
//! EQEmu Exception Class
/*!
A custom exception class for things EQEmu throws.
*/
class Exception : public std::exception {
public:
//! Get Name
/*!
Gets the name of the exception as it was when it was created.
These are typically descriptive categories that the exception would fall under.
*/
virtual const std::string& name() const { return name_; }
//! Get Basic Description
/*!
Gets the description of the exception as it was when it was created.
This tends to explain the circumstances of why the exception was thrown.
*/
virtual const std::string& description() const { return desc_; }
//! Get Full Description
/*!
Gets a full description for this exception.
This is a string containing the name, description, file and line number in a custom format.
This string is created the first time the full_description is accessed.
*/
virtual const std::string& full_description() const;
//! Get File Name
/*!
Gets the name of the file this exception was thrown from.
*/
virtual const std::string& file() const { return file_; }
//! Get File Line
/*!
Gets the file line this exception was thrown from.
*/
virtual const long& line() const { return line_; }
//! std::exception overload
/*!
Overload from std::exception
Allows it to be caught as a std::exception without casting which is nice, returns the full description.
*/
const char* what() const throw() { return full_description().c_str(); }
protected:
std::string name_; //!< Exception name
std::string desc_; //!< Exception Description
mutable std::string full_desc_; //!< Full Exception Description
std::string file_; //!< File Name
long line_; //<! File Line
};
//! Detailed Constructor
/*!
\param name The name given for this exception.
\param description The description for this exception.
\param file The file name for this exception.
\param line The line number for this exception.
*/
Exception(const char* name, const std::string& description, const char* file, long line);
//! Copy Constructor
Exception(const Exception& e);
//! Move Constructor
#ifdef EQEMU_RVALUE_MOVE
Exception(const Exception&& e);
#endif
//! Destructor
~Exception() throw() { }
//! Assignment Operator
void operator=(const Exception& e);
//! Get Name
/*!
Gets the name of the exception as it was when it was created.
These are typically descriptive categories that the exception would fall under.
*/
virtual const std::string& name() const { return name_; }
//! Get Basic Description
/*!
Gets the description of the exception as it was when it was created.
This tends to explain the circumstances of why the exception was thrown.
*/
virtual const std::string& description() const { return desc_; }
//! Get Full Description
/*!
Gets a full description for this exception.
This is a string containing the name, description, file and line number in a custom format.
This string is created the first time the full_description is accessed.
*/
virtual const std::string& full_description() const;
//! Get File Name
/*!
Gets the name of the file this exception was thrown from.
*/
virtual const std::string& file() const { return file_; }
//! Get File Line
/*!
Gets the file line this exception was thrown from.
*/
virtual const long& line() const { return line_; }
//! std::exception overload
/*!
Overload from std::exception
Allows it to be caught as a std::exception without casting which is nice, returns the full description.
*/
const char* what() const throw() { return full_description().c_str(); }
protected:
std::string name_; //!< Exception name
std::string desc_; //!< Exception Description
mutable std::string full_desc_; //!< Full Exception Description
std::string file_; //!< File Name
long line_; //<! File Line
};
} // EQEmu
#ifndef EQ_EXCEPT

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <fstream>
@ -69,58 +69,58 @@ EQTime::~EQTime()
int EQTime::getEQTimeOfDay( time_t timeConvert, struct TimeOfDay_Struct *eqTimeOfDay )
{
/* check to see if we have a reference time to go by. */
if( eqTime.start_realtime == 0 )
return 0;
/* check to see if we have a reference time to go by. */
if( eqTime.start_realtime == 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 */
diff /= 3;
/* There are 3 seconds per 1 EQ Minute */
diff /= 3;
/* Start off timezone offset */
/* Start off timezone offset */
int32 ntz = timezone;
int32 ntz = timezone;
/* The minutes range from 0 - 59 */
diff += eqTime.start_eqtime.minute + (ntz%60);
eqTimeOfDay->minute = diff % 60;
diff /= 60;
ntz /= 60;
/* The minutes range from 0 - 59 */
diff += eqTime.start_eqtime.minute + (ntz%60);
eqTimeOfDay->minute = diff % 60;
diff /= 60;
ntz /= 60;
// The hours range from 1-24
// 1 = 1am
// 2 = 2am
// ...
// 23 = 11 pm
// 24 = 12 am
//
// Modify it so that it works from
// 0-23 for our calculations
diff += ( eqTime.start_eqtime.hour - 1) + (ntz%24);
eqTimeOfDay->hour = (diff%24) + 1;
diff /= 24;
ntz /= 24;
// The hours range from 1-24
// 1 = 1am
// 2 = 2am
// ...
// 23 = 11 pm
// 24 = 12 am
//
// Modify it so that it works from
// 0-23 for our calculations
diff += ( eqTime.start_eqtime.hour - 1) + (ntz%24);
eqTimeOfDay->hour = (diff%24) + 1;
diff /= 24;
ntz /= 24;
// The days range from 1-28
// Modify it so that it works from
// 0-27 for our calculations
diff += ( eqTime.start_eqtime.day - 1 ) + (ntz%28);
eqTimeOfDay->day = (diff%28) + 1;
diff /= 28;
ntz /= 28;
// The days range from 1-28
// Modify it so that it works from
// 0-27 for our calculations
diff += ( eqTime.start_eqtime.day - 1 ) + (ntz%28);
eqTimeOfDay->day = (diff%28) + 1;
diff /= 28;
ntz /= 28;
// The months range from 1-12
// Modify it so that it works from
// 0-11 for our calculations
diff += ( eqTime.start_eqtime.month - 1 ) + (ntz%12);
eqTimeOfDay->month = (diff%12) + 1;
diff /= 12;
ntz /= 12;
// The months range from 1-12
// Modify it so that it works from
// 0-11 for our calculations
diff += ( eqTime.start_eqtime.month - 1 ) + (ntz%12);
eqTimeOfDay->month = (diff%12) + 1;
diff /= 12;
ntz /= 12;
eqTimeOfDay->year = eqTime.start_eqtime.year + diff + ntz;
eqTimeOfDay->year = eqTime.start_eqtime.year + diff + ntz;
return 1;
return 1;
}
//setEQTimeOfDay
@ -145,7 +145,7 @@ bool EQTime::saveFile(const char *filename)
return false;
}
//Enable for debugging
//cout << "SAVE: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << endl;
//cout << "SAVE: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << endl;
of << EQT_VERSION << endl;
of << (long)eqTime.start_eqtime.day << endl;
of << (long)eqTime.start_eqtime.hour << endl;
@ -172,7 +172,7 @@ bool EQTime::loadFile(const char *filename)
in.ignore(80, '\n');
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;
}
//in >> eqTime.start_eqtime.day;
@ -182,7 +182,7 @@ bool EQTime::loadFile(const char *filename)
//in >> eqTime.start_eqtime.hour;
in >> in_data;
eqTime.start_eqtime.hour = in_data;
in.ignore(80, '\n');
in.ignore(80, '\n');
//in >> eqTime.start_eqtime.minute;
in >> in_data;
in.ignore(80, '\n');
@ -195,7 +195,7 @@ bool EQTime::loadFile(const char *filename)
in.ignore(80, '\n');
in >> eqTime.start_realtime;
//Enable for debugging...
//cout << "LOAD: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << endl;
//cout << "LOAD: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << endl;
in.close();
return true;
}
@ -228,7 +228,7 @@ bool EQTime::IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test) {
void EQTime::AddMinutes(uint32 minutes, TimeOfDay_Struct *to) {
uint32 cur;
//minutes start at 0, everything else starts at 1
cur = to->minute;
cur += minutes;
@ -273,8 +273,3 @@ void EQTime::ToString(TimeOfDay_Struct *t, string &str) {
str = buf;
}

View File

@ -34,13 +34,13 @@ public:
//Set functions
int setEQTimeOfDay(TimeOfDay_Struct start_eq, time_t start_real);
void setEQTimeZone(int32 in_timezone) { timezone=in_timezone; }
//Time math/logic functions
static bool IsTimeBefore(TimeOfDay_Struct *base, TimeOfDay_Struct *test); //is test before base
static void AddMinutes(uint32 minutes, TimeOfDay_Struct *to);
static void ToString(TimeOfDay_Struct *t, string &str);
//Database functions
//bool loadDB(Database q);
//bool setDB(Database q);

View File

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

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
@ -35,10 +35,10 @@ bool SetExtendedProfile(ExtendedProfile_Struct *to, char *old, unsigned int len)
memcpy(to, old, sizeof(ExtendedProfile_Struct));
return(true);
}
//convert an old block of memory of size old to the new struct
//and store the new results in 'to'
//generic converter that will work as long as the structre
//only grows, and nothign gets re-arranged
if(len < sizeof(ExtendedProfile_Struct)) {
@ -46,12 +46,7 @@ bool SetExtendedProfile(ExtendedProfile_Struct *to, char *old, unsigned int len)
memcpy(to, old, len);
return(true);
}
return(false);
}

View File

@ -1,22 +1,22 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EXTENDED_PROFILE_H
#define EXTENDED_PROFILE_H
#define EXTENDED_PROFILE_H
#include "eq_packet_structs.h"
#include "Item.h"
@ -27,11 +27,11 @@
/*
This is a place to store data that dosent have a home in the
official player profile.
Try not to expand or re-arrange thing in this struct
to make conversion between sizes easier.
if something gets removed from here, just turn it into an unused
item, so conversion is not needed. Then reuse old unused values if
item, so conversion is not needed. Then reuse old unused values if
possible later instead of adding more, so long as old values left
over would not be extrememly unpleasent side effects.
*/
@ -43,7 +43,7 @@ struct ExtendedProfile_Struct {
SpellBuff_Struct pet_buffs[BUFF_COUNT];
uint32 pet_items[MAX_MATERIALS];
char merc_name[64];
uint32 aa_effects;
uint32 perAA; //% of exp going to AAs
uint32 expended_aa; // Total of expended AA

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
#include "faction.h"
@ -29,20 +29,20 @@ const char *FactionValueToString(FACTION_VALUE fv) {
return("Kindly");
case FACTION_AMIABLE:
return("Amiable");
case FACTION_INDIFFERENT:
return("Indifferent");
case FACTION_APPREHENSIVE:
return("Apprehensive");
case FACTION_DUBIOUS:
return("Dubious");
case FACTION_THREATENLY:
return("Threatenly");
case FACTION_SCOWLS:
return("Scowls, ready to attack.");
default:
break;
}
return("Unknown Faction Con");
case FACTION_INDIFFERENT:
return("Indifferent");
case FACTION_APPREHENSIVE:
return("Apprehensive");
case FACTION_DUBIOUS:
return("Dubious");
case FACTION_THREATENLY:
return("Threatenly");
case FACTION_SCOWLS:
return("Scowls, ready to attack.");
default:
break;
}
return("Unknown Faction Con");
}
@ -50,21 +50,21 @@ const char *FactionValueToString(FACTION_VALUE fv) {
//| Name: CalculateFaction; rembrant, Dec. 16, 2001
//o--------------------------------------------------------------
//| Notes: Returns the faction message value.
//| Modify these values to taste.
//| Modify these values to taste.
//o--------------------------------------------------------------
FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value)
{
int32 character_value = tmpCharacter_value;
if (fm)
character_value += fm->base + fm->class_mod + fm->race_mod + fm->deity_mod;
if(character_value >= 1101) return FACTION_ALLY;
if(character_value >= 701 && character_value <= 1100) return FACTION_WARMLY;
if(character_value >= 401 && character_value <= 700) return FACTION_KINDLY;
if(character_value >= 101 && character_value <= 400) return FACTION_AMIABLE;
if(character_value >= 0 && character_value <= 100) return FACTION_INDIFFERENT;
if(character_value >= -100 && character_value <= -1) return FACTION_APPREHENSIVE;
if(character_value >= -700 && character_value <= -101) return FACTION_DUBIOUS;
if(character_value >= -999 && character_value <= -701) return FACTION_THREATENLY;
if(character_value >= 1101) return FACTION_ALLY;
if(character_value >= 701 && character_value <= 1100) return FACTION_WARMLY;
if(character_value >= 401 && character_value <= 700) return FACTION_KINDLY;
if(character_value >= 101 && character_value <= 400) return FACTION_AMIABLE;
if(character_value >= 0 && character_value <= 100) return FACTION_INDIFFERENT;
if(character_value >= -100 && character_value <= -1) return FACTION_APPREHENSIVE;
if(character_value >= -700 && character_value <= -101) return FACTION_DUBIOUS;
if(character_value >= -999 && character_value <= -701) return FACTION_THREATENLY;
if(character_value <= -1000) return FACTION_SCOWLS;
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
bool IsOfEqualRace(int r1, int r2)
{
if (r1 == r2)
return true;
// TODO: add more values
switch(r1)
{
case DARK_ELF:
if (r2 == 77)
return true;
break;
case BARBARIAN:
if (r2 == 90)
return true;
}
return false;
if (r1 == r2)
return true;
// TODO: add more values
switch(r1)
{
case DARK_ELF:
if (r2 == 77)
return true;
break;
case BARBARIAN:
if (r2 == 90)
return true;
}
return false;
}
// neotokyo: trolls endure ogres, dark elves, ...
bool IsOfIndiffRace(int r1, int r2)
{
if (r1 == r2)
return true;
// TODO: add more values
switch(r1)
{
case DARK_ELF:
case OGRE:
case TROLL:
if (r2 == OGRE || r2 == TROLL || r2 == DARK_ELF)
return true;
break;
case HUMAN:
case BARBARIAN:
case HALF_ELF:
case GNOME:
case HALFLING:
case WOOD_ELF:
if (r2 == HUMAN ||
r2 == BARBARIAN ||
r2 == ERUDITE ||
r2 == HALF_ELF ||
r2 == GNOME ||
r2 == HALFLING ||
r2 == DWARF ||
r2 == HIGH_ELF ||
r2 == WOOD_ELF)
return true;
break;
case ERUDITE:
if (r2 == HUMAN || r2 == HALF_ELF)
return true;
break;
case DWARF:
if (r2 == HALFLING || r2 == GNOME)
return true;
break;
case HIGH_ELF:
if (r2 == WOOD_ELF)
return true;
break;
case VAHSHIR:
return true;
case IKSAR:
return false;
}
return false;
if (r1 == r2)
return true;
// TODO: add more values
switch(r1)
{
case DARK_ELF:
case OGRE:
case TROLL:
if (r2 == OGRE || r2 == TROLL || r2 == DARK_ELF)
return true;
break;
case HUMAN:
case BARBARIAN:
case HALF_ELF:
case GNOME:
case HALFLING:
case WOOD_ELF:
if (r2 == HUMAN ||
r2 == BARBARIAN ||
r2 == ERUDITE ||
r2 == HALF_ELF ||
r2 == GNOME ||
r2 == HALFLING ||
r2 == DWARF ||
r2 == HIGH_ELF ||
r2 == WOOD_ELF)
return true;
break;
case ERUDITE:
if (r2 == HUMAN || r2 == HALF_ELF)
return true;
break;
case DWARF:
if (r2 == HALFLING || r2 == GNOME)
return true;
break;
case HIGH_ELF:
if (r2 == WOOD_ELF)
return true;
break;
case VAHSHIR:
return true;
case IKSAR:
return false;
}
return false;
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EQEMU_FACTION_H
#define _EQEMU_FACTION_H
@ -28,13 +28,13 @@ enum FACTION_VALUE {
FACTION_WARMLY = 2,
FACTION_KINDLY = 3,
FACTION_AMIABLE = 4,
FACTION_INDIFFERENT = 5,
FACTION_APPREHENSIVE = 6,
FACTION_DUBIOUS = 7,
FACTION_THREATENLY = 8,
FACTION_SCOWLS = 9
FACTION_INDIFFERENT = 5,
FACTION_APPREHENSIVE = 6,
FACTION_DUBIOUS = 7,
FACTION_THREATENLY = 8,
FACTION_SCOWLS = 9
};
struct NPCFactionList {
@ -57,19 +57,19 @@ struct FactionMods
struct Faction {
int32 id;
std::map<std::string, int16> mods;
std::map<std::string, int16> mods;
int16 base;
char name[50];
};
typedef std::map<uint32, int16> faction_map;
struct NPCFaction
{
uint32 factionID;
int32 value_mod;
int8 npc_value;
uint8 temp;
};
struct NPCFaction
{
uint32 factionID;
int32 value_mod;
int8 npc_value;
uint8 temp;
};
const char *FactionValueToString(FACTION_VALUE fv);
FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef FEATURES_H
#define FEATURES_H
@ -22,7 +22,7 @@
This file defines many optional features for the emu
as well as various parameters used by the emu.
If ambitious, most of these could prolly be turned into
database variables, but the really frequently run pieces
of code, should not be done that way for speed reasons IMO
@ -185,7 +185,7 @@ enum { //timer settings, all in milliseconds
};
enum { //some random constants
//each of these attack modifiers are added to the NPC's level to determine their
//each of these attack modifiers are added to the NPC's level to determine their
//probability of executing such an attack (which may or may not hit)
NPCDualAttackModifier = 20,
NPCTripleAttackModifier = 0,
@ -200,7 +200,7 @@ enum { //some random constants
//an npc can be and still let the theif PP them
#define THIEF_PICKPOCKET_OVER 5
//this is the % chance that an NPC will dual wield a 2nd weapon
//this is the % chance that an NPC will dual wield a 2nd weapon
//in its loot table, if it is able to.
//Aug 2007: was 5% chance.. changed to 100% by default since that seems more normal
//Kept it intact codewise incase someone wants to or is already using it.
@ -221,14 +221,14 @@ enum { //some random constants
//minimum level to do alchemy
#define MIN_LEVEL_ALCHEMY 25
//chance ratio that a
//chance ratio that a
#define THREATENLY_ARRGO_CHANCE 32 // 32/128 (25%) chance that a mob will arrgo on con Threatenly
// max factions per npc faction list
#define MAX_NPC_FACTIONS 20
//value caps
#define MAX_FACTION 1500
#define MAX_FACTION 1500
#define MIN_FACTION -1500
//The Level Cap:

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EQEMU_FIXED_MEMORY_HASHSET_H
@ -25,227 +25,228 @@
namespace EQEmu {
/*! Simple HashSet designed to be used in fixed memory that may be difficult to use an
allocator for (shared memory), we assume all keys are unsigned int
*/
template<class T>
class FixedMemoryHashSet {
typedef uint32 key_type;
typedef T value_type;
typedef uint8 byte;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
public:
/*!
Constructor which initializes the hash set
\param data Raw data
\param size Raw data size
\param element_count Max number of possible unique elements that can be inserted.
\param 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) {
data_ = data;
size_ = size;
/*! Simple HashSet designed to be used in fixed memory that may be difficult to use an
allocator for (shared memory), we assume all keys are unsigned int
*/
template<class T>
class FixedMemoryHashSet {
typedef uint32 key_type;
typedef T value_type;
typedef uint8 byte;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
public:
/*!
Constructor which initializes the hash set
\param data Raw data
\param size Raw data size
\param element_count Max number of possible unique elements that can be inserted.
\param 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) {
data_ = data;
size_ = size;
byte *ptr = data;
*reinterpret_cast<key_type*>(ptr) = max_element_id + 1;
offset_count_ = max_element_id + 1;
ptr += sizeof(key_type);
byte *ptr = data;
*reinterpret_cast<key_type*>(ptr) = max_element_id + 1;
offset_count_ = max_element_id + 1;
ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = element_count;
max_elements_ = element_count;
ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = element_count;
max_elements_ = element_count;
ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = 0;
current_elements_ = 0;
ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = 0;
current_elements_ = 0;
ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr);
memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1));
ptr += sizeof(key_type) * (max_element_id + 1);
offsets_ = reinterpret_cast<key_type*>(ptr);
memset(ptr, 0xFFFFFFFFU, 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
stored in the data pointer passed.
\param data Raw data
\param size Raw data size
*/
FixedMemoryHashSet(byte *data, size_type size) {
data_ = data;
size_ = size;
/*!
Constructor which does not initialize the hash set. Builds the hash set from what data is
stored in the data pointer passed.
\param data Raw data
\param size Raw data size
*/
FixedMemoryHashSet(byte *data, size_type size) {
data_ = data;
size_ = size;
byte *ptr = data;
byte *ptr = data;
offset_count_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
offset_count_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
max_elements_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
max_elements_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
current_elements_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
current_elements_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type) * offset_count_;
offsets_ = reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type) * offset_count_;
elements_ = reinterpret_cast<value_type*>(ptr);
}
elements_ = reinterpret_cast<value_type*>(ptr);
}
//! Copy Constructor
FixedMemoryHashSet(const FixedMemoryHashSet& other) :
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
max_elements_(other.max_elements_),
current_elements_(other.current_elements_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
//! Copy Constructor
FixedMemoryHashSet(const FixedMemoryHashSet& other) :
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
max_elements_(other.max_elements_),
current_elements_(other.current_elements_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
//! RValue-Move Constructor
//! RValue-Move Constructor
#ifdef EQEMU_RVALUE_MOVE
FixedMemoryHashSet(FixedMemoryHashSet&& other) :
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
max_elements_(other.max_elements_),
current_elements_(other.current_elements_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
FixedMemoryHashSet(FixedMemoryHashSet&& other) :
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
max_elements_(other.max_elements_),
current_elements_(other.current_elements_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
#endif
//! Destructor
~FixedMemoryHashSet() {
}
//! Destructor
~FixedMemoryHashSet() {
}
//! Assignment operator
const FixedMemoryHashSet& operator=(const FixedMemoryHashSet& other) {
data_ = other.data_;
size_ = other.size_;
offset_count_ = other.offset_count_;
max_elements_ = other.max_elements_;
current_elements_ = other.current_elements_;
offsets_ = other.offsets_;
elements_ = other.elements_;
return *this;
}
//! Returns whether the set is empty (has 0 elements) or not
bool empty() const {
return current_elements_ == 0;
}
//! Assignment operator
const FixedMemoryHashSet& operator=(const FixedMemoryHashSet& other) {
data_ = other.data_;
size_ = other.size_;
offset_count_ = other.offset_count_;
max_elements_ = other.max_elements_;
current_elements_ = other.current_elements_;
offsets_ = other.offsets_;
elements_ = other.elements_;
return *this;
}
//! Returns the number of unique elements in the set currently
size_type size() const {
return current_elements_;
}
//! Returns whether the set is empty (has 0 elements) or not
bool empty() const {
return current_elements_ == 0;
}
//! Returns the maximum number of elements one can insert into the set.
size_type max_size() const {
return max_elements_;
}
//! Returns the number of unique elements in the set currently
size_type size() const {
return current_elements_;
}
//! Returns the maximum key one can use with the set.
key_type max_key() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0;
}
/*!
Retrieve value operator
\param i Index to retrieve the value from
*/
reference operator[](const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range");
}
//! Returns the maximum number of elements one can insert into the set.
size_type max_size() const {
return max_elements_;
}
if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Hash Set", "Element not found.");
}
//! Returns the maximum key one can use with the set.
key_type max_key() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0;
}
return elements_[offsets_[i]];
}
/*!
Retrieve value operator
\param i Index to retrieve the value from
*/
reference operator[](const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range");
}
/*!
Retrieve value function
\param i Index to retrieve the value from
*/
reference at(const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
}
if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Hash Set", "Element not found.");
}
if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Hash Set", "Element not found.");
}
return elements_[offsets_[i]];
}
return elements_[offsets_[i]];
}
/*!
Retrieve value function
\param i Index to retrieve the value from
*/
reference at(const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
}
/*!
Checks if there is a value at a certain index
\param i Index to check for a value
*/
bool exists(const key_type& i) const {
if(i >= offset_count_) {
return false;
}
if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Hash Set", "Element not found.");
}
if(offsets_[i] == 0xFFFFFFFFU) {
return false;
}
return elements_[offsets_[i]];
}
return true;
}
/*!
Checks if there is a value at a certain index
\param i Index to check for a value
*/
bool exists(const key_type& i) const {
if(i >= offset_count_) {
return false;
}
/*!
Inserts a value into the set at a specific index
\param i Index to insert the value at
\param v Value to insert
*/
void insert(const key_type& i, const_reference v) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
}
if(offsets_[i] == 0xFFFFFFFFU) {
return false;
}
if(offsets_[i] != 0xFFFFFFFFU) {
elements_[offsets_[i]] = v;
} else {
if(current_elements_ >= max_elements_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Insert pointer out of range.");
}
return true;
}
offsets_[i] = current_elements_;
memcpy(&elements_[current_elements_], &v, sizeof(value_type));
++current_elements_;
*reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_elements_;
}
}
/*!
Inserts a value into the set at a specific index
\param i Index to insert the value at
\param v Value to insert
*/
void insert(const key_type& i, const_reference v) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Index out of range.");
}
//! Calculates how much memory we should allocate based on element size and count
static size_type estimated_size(key_type element_count, key_type max_elements) {
size_type total_size = 3 * sizeof(key_type);
total_size += sizeof(key_type) * (max_elements + 1);
total_size += sizeof(T) * element_count;
return total_size;
}
if(offsets_[i] != 0xFFFFFFFFU) {
elements_[offsets_[i]] = v;
} else {
if(current_elements_ >= max_elements_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Insert pointer out of range.");
}
private:
unsigned char *data_;
size_type size_;
key_type offset_count_;
key_type max_elements_;
key_type current_elements_;
key_type *offsets_;
value_type *elements_;
};
offsets_[i] = current_elements_;
memcpy(&elements_[current_elements_], &v, sizeof(value_type));
++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
static size_type estimated_size(key_type element_count, key_type max_elements) {
size_type total_size = 3 * sizeof(key_type);
total_size += sizeof(key_type) * (max_elements + 1);
total_size += sizeof(T) * element_count;
return total_size;
}
private:
unsigned char *data_;
size_type size_;
key_type offset_count_;
key_type max_elements_;
key_type current_elements_;
key_type *offsets_;
value_type *elements_;
};
} // EQEmu
#endif

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EQEMU_FIXED_MEMORY_VARIABLE_HASHSET_H
@ -25,217 +25,217 @@
namespace EQEmu {
/*! Simple HashSet designed to be used in fixed memory that may be difficult to use an
allocator for (shared memory), we assume all keys are unsigned int, values are a pointer and size
*/
template<class T>
class FixedMemoryVariableHashSet {
typedef uint32 key_type;
typedef T value_type;
typedef uint8 byte;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef uint32 size_type;
public:
/*!
Constructor which initializes the hash set
\param data Raw data
\param size Raw data size
\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) {
data_ = data;
size_ = size;
remaining_size_ = size_ - (sizeof(key_type) * 3) - (sizeof(key_type) * (max_element_id + 1));
/*! Simple HashSet designed to be used in fixed memory that may be difficult to use an
allocator for (shared memory), we assume all keys are unsigned int, values are a pointer and size
*/
template<class T>
class FixedMemoryVariableHashSet {
typedef uint32 key_type;
typedef T value_type;
typedef uint8 byte;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef uint32 size_type;
public:
/*!
Constructor which initializes the hash set
\param data Raw data
\param size Raw data size
\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) {
data_ = data;
size_ = size;
remaining_size_ = size_ - (sizeof(key_type) * 3) - (sizeof(key_type) * (max_element_id + 1));
byte *ptr = data;
*reinterpret_cast<key_type*>(ptr) = max_element_id + 1;
offset_count_ = max_element_id + 1;
ptr += sizeof(key_type);
byte *ptr = data;
*reinterpret_cast<key_type*>(ptr) = max_element_id + 1;
offset_count_ = max_element_id + 1;
ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = remaining_size_;
ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = 0;
current_offset_ = 0;
ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = remaining_size_;
ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr);
memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1));
ptr += sizeof(key_type) * (max_element_id + 1);
*reinterpret_cast<key_type*>(ptr) = 0;
current_offset_ = 0;
ptr += sizeof(key_type);
elements_ = reinterpret_cast<byte*>(ptr);
}
/*!
Constructor which does not initialize the hash set. Builds the hash set from what data is
stored in the data pointer passed.
\param data Raw data
\param size Raw data size
*/
FixedMemoryVariableHashSet(byte *data, size_type size) {
data_ = data;
size_ = size;
offsets_ = reinterpret_cast<key_type*>(ptr);
memset(ptr, 0xFFFFFFFFU, sizeof(key_type) * (max_element_id + 1));
ptr += sizeof(key_type) * (max_element_id + 1);
byte *ptr = data;
offset_count_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
elements_ = reinterpret_cast<byte*>(ptr);
}
remaining_size_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
/*!
Constructor which does not initialize the hash set. Builds the hash set from what data is
stored in the data pointer passed.
\param data Raw data
\param size Raw data size
*/
FixedMemoryVariableHashSet(byte *data, size_type size) {
data_ = data;
size_ = size;
current_offset_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
offsets_ = reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type) * offset_count_;
byte *ptr = data;
offset_count_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
elements_ = reinterpret_cast<byte*>(ptr);
}
remaining_size_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
//! Copy Constructor
FixedMemoryVariableHashSet(const FixedMemoryVariableHashSet& other) :
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
remaining_size_(other.remaining_size_),
current_offset_(other.current_offset_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
current_offset_ = *reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type);
//! RValue-Move Constructor
offsets_ = reinterpret_cast<key_type*>(ptr);
ptr += sizeof(key_type) * offset_count_;
elements_ = reinterpret_cast<byte*>(ptr);
}
//! Copy Constructor
FixedMemoryVariableHashSet(const FixedMemoryVariableHashSet& other) :
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
remaining_size_(other.remaining_size_),
current_offset_(other.current_offset_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
//! RValue-Move Constructor
#ifdef EQEMU_RVALUE_MOVE
FixedMemoryVariableHashSet(FixedMemoryVariableHashSet&& other) :
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
remaining_size_(other.remaining_size_),
current_offset_(other.current_offset_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
FixedMemoryVariableHashSet(FixedMemoryVariableHashSet&& other) :
data_(other.data_),
size_(other.size_),
offset_count_(other.offset_count_),
remaining_size_(other.remaining_size_),
current_offset_(other.current_offset_),
offsets_(other.offsets_),
elements_(other.elements_)
{
}
#endif
//! Destructor
~FixedMemoryVariableHashSet() {
}
//! Destructor
~FixedMemoryVariableHashSet() {
}
//! Assignment operator
const FixedMemoryVariableHashSet& operator=(const FixedMemoryVariableHashSet& other) {
data_ = other.data_;
size_ = other.size_;
offset_count_ = other.offset_count_;
remaining_size_ = other.remaining_size_;
current_offset_ = other.current_offset_;
offsets_ = other.offsets_;
elements_ = other.elements_;
return *this;
}
//! Returns the number of bytes in the set currently
size_type size() const {
return size_ - remaining_size_;
}
//! Assignment operator
const FixedMemoryVariableHashSet& operator=(const FixedMemoryVariableHashSet& other) {
data_ = other.data_;
size_ = other.size_;
offset_count_ = other.offset_count_;
remaining_size_ = other.remaining_size_;
current_offset_ = other.current_offset_;
offsets_ = other.offsets_;
elements_ = other.elements_;
return *this;
}
//! Returns the maximum number of bytes one can insert into the set.
size_type max_size() const {
return size_ - (sizeof(key_type) * 2);
}
//! Returns the number of bytes in the set currently
size_type size() const {
return size_ - remaining_size_;
}
//! Returns the maximum key one can use with the set.
key_type max_key() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0;
}
/*!
Retrieve value operator
\param i Index to retrieve the value from
*/
reference operator[](const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
}
//! Returns the maximum number of bytes one can insert into the set.
size_type max_size() const {
return size_ - (sizeof(key_type) * 2);
}
if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found.");
}
//! Returns the maximum key one can use with the set.
key_type max_key() const {
return offset_count_ > 0 ? (offset_count_ - 1) : 0;
}
return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]);
}
/*!
Retrieve value operator
\param i Index to retrieve the value from
*/
reference operator[](const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
}
/*!
Retrieve value function
\param i Index to retrieve the value from
*/
reference at(const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
}
if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found.");
}
if(offsets_[i] == 0xFFFFFFFFU) {
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
\param i Index to retrieve the value from
*/
reference at(const key_type& i) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range");
}
/*!
Checks if there is a value at a certain index
\param i Index to check for a value
*/
bool exists(const key_type& i) const {
if(i >= offset_count_) {
return false;
}
if(offsets_[i] == 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Element not found.");
}
if(offsets_[i] == 0xFFFFFFFFU) {
return false;
}
return *reinterpret_cast<value_type*>(&elements_[offsets_[i]]);
}
return true;
}
/*!
Checks if there is a value at a certain index
\param i Index to check for a value
*/
bool exists(const key_type& i) const {
if(i >= offset_count_) {
return false;
}
/*!
Inserts a value into the set at a specific index
\param i Index to insert the value at
\param v Value to insert
*/
void insert(const key_type& i, byte *data, size_type size) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range.");
}
if(size > remaining_size_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Not enough room in hash set to insert this value.");
}
if(offsets_[i] == 0xFFFFFFFFU) {
return false;
}
if(offsets_[i] != 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Hash Set", "Could not insert a repeat value at this index.");
} else {
offsets_[i] = current_offset_;
memcpy(&elements_[current_offset_], data, size);
return true;
}
remaining_size_ -= size;
*reinterpret_cast<key_type*>(data_ + sizeof(key_type)) = remaining_size_;
/*!
Inserts a value into the set at a specific index
\param i Index to insert the value at
\param v Value to insert
*/
void insert(const key_type& i, byte *data, size_type size) {
if(i >= offset_count_) {
EQ_EXCEPT("Fixed Memory Variable Hash Set", "Index out of range.");
}
current_offset_ += size;
*reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_offset_;
}
}
if(size > remaining_size_) {
EQ_EXCEPT("Fixed Memory Hash Set", "Not enough room in hash set to insert this value.");
}
private:
unsigned char *data_;
size_type size_;
size_type remaining_size_;
key_type current_offset_;
key_type offset_count_;
key_type *offsets_;
byte *elements_;
};
if(offsets_[i] != 0xFFFFFFFFU) {
EQ_EXCEPT("Fixed Memory Hash Set", "Could not insert a repeat value at this index.");
} else {
offsets_[i] = current_offset_;
memcpy(&elements_[current_offset_], data, size);
remaining_size_ -= size;
*reinterpret_cast<key_type*>(data_ + sizeof(key_type)) = remaining_size_;
current_offset_ += size;
*reinterpret_cast<key_type*>(data_ + (sizeof(key_type) * 2)) = current_offset_;
}
}
private:
unsigned char *data_;
size_type size_;
size_type remaining_size_;
key_type current_offset_;
key_type offset_count_;
key_type *offsets_;
byte *elements_;
};
} // EQEmu
#endif

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@ public:
uint16 level;
uint32 time_last_on;
uint32 zone_id;
//fields from `guild_members`
uint32 guild_id;
uint8 rank;
@ -34,13 +34,13 @@ class BaseGuildManager {
public:
BaseGuildManager();
virtual ~BaseGuildManager();
//this must be called before doing anything else with this object
void SetDatabase(Database *db) { m_db = db; }
bool LoadGuilds();
bool RefreshGuild(uint32 guild_id);
//guild edit actions.
uint32 CreateGuild(const char* name, uint32 leader_char_id);
bool DeleteGuild(uint32 guild_id);
@ -48,7 +48,7 @@ public:
bool SetGuildMOTD(uint32 guild_id, const char* motd, const char *setter);
bool SetGuildURL(uint32 GuildID, const char* URL);
bool SetGuildChannel(uint32 GuildID, const char* Channel);
//character edit actions
bool SetGuildLeader(uint32 guild_id, uint32 leader_char_id);
bool SetGuild(uint32 charid, uint32 guild_id, uint8 rank);
@ -59,7 +59,7 @@ public:
bool GetBankerFlag(uint32 CharID);
bool SetTributeFlag(uint32 charid, bool enabled);
bool SetPublicNote(uint32 charid, const char *note);
//queries
bool GetCharInfo(const char *char_name, CharGuildInfo &into);
bool GetCharInfo(uint32 char_id, CharGuildInfo &into);
@ -82,19 +82,19 @@ public:
uint32 NumberInGuild(uint32 guild_id);
// bool GetGuildRanks(uint32 guildeqid, GuildRanks_Struct* gr);
// bool EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct* grl);
uint8 *MakeGuildList(const char *head_name, uint32 &length) const; //make a guild list packet, returns ownership of the buffer.
static const char *const GuildActionNames[_MaxGuildAction];
uint32 DoesAccountContainAGuildLeader(uint32 AccountID);
protected:
//the methods which must be defined by base classes.
virtual void SendGuildRefresh(uint32 guild_id, bool name, bool motd, bool rank, bool relation) = 0;
virtual void SendCharRefresh(uint32 old_guild_id, uint32 guild_id, uint32 charid) = 0;
virtual void SendRankUpdate(uint32 CharID) = 0;
virtual void SendGuildDelete(uint32 guild_id) = 0;
uint32 DBCreateGuild(const char* name, uint32 leader_char_id);
bool DBDeleteGuild(uint32 guild_id);
bool DBRenameGuild(uint32 guild_id, const char* name);
@ -110,9 +110,9 @@ protected:
bool DBSetPublicNote(uint32 charid, const char *note);
bool _RunQuery(char *&query, int len, const char *errmsg);
// void DBSetPublicNote(uint32 guild_id,char* charname, char* note);
bool LocalDeleteGuild(uint32 guild_id);
class RankInfo {
public:
RankInfo();
@ -133,12 +133,12 @@ protected:
//tribute is not in here on purpose, since it is only valid in world!
RankInfo ranks[GUILD_MAX_RANK+1];
};
std::map<uint32, GuildInfo *> m_guilds; //we own the pointers in this map
void ClearGuilds(); //clears internal structure
Database *m_db; //we do not own this
bool _StoreGuildDB(uint32 guild_id);
GuildInfo *_CreateGuild(uint32 guild_id, const char *guild_name, uint32 account_id, uint8 minstatus, const char *guild_motd, const char *motd_setter, const char *Channel, const char *URL);
uint32 _GetFreeGuildID();

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "MiscFunctions.h"
@ -29,7 +29,7 @@
/*
void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
uint32 count=0;
@ -59,11 +59,11 @@ void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
}
uint32 Database::NumberInGuild(uint32 guild_id) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "Select count(id) from character_ where guild=%i", guild_id), errbuf, &result)) {
safe_delete_array(query);
if (mysql_num_rows(result) == 1) {
@ -83,9 +83,9 @@ uint32 Database::NumberInGuild(uint32 guild_id) {
}
bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char *query = 0;
uint32 affected_rows = 0;
if (RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET guild=%i, guildrank=%i WHERE name='%s'", guild_id, guildrank, name), errbuf, 0, &affected_rows)) {
safe_delete_array(query);
if (affected_rows == 1)
@ -103,9 +103,9 @@ bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char *query = 0;
uint32 affected_rows = 0;
if (RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET guild=%i, guildrank=%i WHERE id=%i", guild_id, guildrank, charid), errbuf, 0, &affected_rows)) {
safe_delete_array(query);
if (affected_rows == 1)
@ -119,17 +119,17 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
safe_delete_array(query);
return false;
}
return false;
}
bool Database::DeleteGuild(uint32 guild_id)
{
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char *query = 0;
char *query2 = 0;
uint32 affected_rows = 0;
if (RunQuery(query, MakeAnyLenString(&query, "DELETE FROM guilds WHERE id=%i;", guild_id), errbuf, 0, &affected_rows)) {
safe_delete_array(query);
if (affected_rows == 1) {
@ -146,17 +146,17 @@ bool Database::DeleteGuild(uint32 guild_id)
safe_delete_array(query);
return false;
}
return false;
}
bool Database::RenameGuild(uint32 guild_id, const char* name) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char *query = 0;
uint32 affected_rows = 0;
char buf[65];
DoEscapeString(buf, name, strlen(name)) ;
if (RunQuery(query, MakeAnyLenString(&query, "Update guilds set name='%s' WHERE id=%i;", buf, guild_id), errbuf, 0, &affected_rows)) {
safe_delete_array(query);
if (affected_rows == 1)
@ -169,7 +169,7 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
safe_delete_array(query);
return false;
}
return false;
}
@ -178,8 +178,8 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct* grl)
{
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
int chars = 0;
char *query = 0;
int chars = 0;
uint32 affected_rows = 0;
char buf[203];
char buf2[8];
@ -192,12 +192,12 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
buf2[GUILD_DEMOTE] = grl->demote + '0';
buf2[GUILD_MOTD] = grl->motd + '0';
buf2[GUILD_WARPEACE] = grl->warpeace + '0';
if (ranknum == 0)
chars = MakeAnyLenString(&query, "Update guilds set rank%ititle='%s' WHERE id=%i;", ranknum, buf, guild_id);
else
chars = MakeAnyLenString(&query, "Update guilds set rank%ititle='%s', rank%i='%s' WHERE id=%i;", ranknum, buf, ranknum, buf2, guild_id);
if (RunQuery(query, chars, errbuf, 0, &affected_rows)) {
safe_delete_array(query);
if (affected_rows == 1)
@ -210,17 +210,17 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
safe_delete_array(query);
return false;
}
return false;
}
bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
if (!name || !guild_id) return false;
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "select name from guilds where id='%i'", guild_id), errbuf, &result)) {
safe_delete_array(query);
row = mysql_fetch_row(result);
@ -234,17 +234,17 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
safe_delete_array(query);
return false;
}
return false;
}
uint32 Database::GetGuildIDbyLeader(uint32 leader)
{
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM guilds WHERE leader=%i", leader), errbuf, &result)) {
safe_delete_array(query);
if (mysql_num_rows(result) == 1)
@ -260,16 +260,16 @@ uint32 Database::GetGuildIDbyLeader(uint32 leader)
LogFile->write(EQEMuLog::Error, "Error in Getguild_idbyLeader query '%s': %s", query, errbuf);
safe_delete_array(query);
}
return 0;
}
bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
{
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char *query = 0;
uint32 affected_rows = 0;
if (RunQuery(query, MakeAnyLenString(&query, "UPDATE guilds SET leader=%i WHERE id=%i", leader, guild_id), errbuf, 0, &affected_rows)) {
safe_delete_array(query);
if (affected_rows == 1)
@ -282,20 +282,20 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
safe_delete_array(query);
return false;
}
return false;
}
bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char *query = 0;
char* motdbuf = 0;
uint32 affected_rows = 0;
motdbuf = new char[(strlen(motd)*2)+3];
DoEscapeString(motdbuf, motd, strlen(motd)) ;
if (RunQuery(query, MakeAnyLenString(&query, "Update guilds set motd='%s' WHERE id=%i;", motdbuf, guild_id), errbuf, 0, &affected_rows)) {
safe_delete_array(query);
delete motdbuf;
@ -311,16 +311,16 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
delete motdbuf;
return false;
}
return false;
}
string Database::GetGuildMOTD(uint32 guild_id)
{
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
string motd_str;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT motd FROM guilds WHERE id=%i", guild_id), errbuf, &result)) {
safe_delete_array(query);

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GUILD_H
@ -23,7 +23,7 @@
#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
#define GUILD_MEMBER 0

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ipc_mutex.h"
@ -30,91 +30,91 @@
namespace EQEmu {
struct IPCMutex::Implementation {
struct IPCMutex::Implementation {
#ifdef _WINDOWS
HANDLE mut_;
HANDLE mut_;
#else
int fd_;
int fd_;
#endif
};
};
IPCMutex::IPCMutex(std::string name) : locked_(false) {
imp_ = new Implementation;
IPCMutex::IPCMutex(std::string name) : locked_(false) {
imp_ = new Implementation;
#ifdef _WINDOWS
std::string final_name = "EQEmuMutex_";
final_name += name;
std::string final_name = "EQEmuMutex_";
final_name += name;
imp_->mut_ = CreateMutex(nullptr,
FALSE,
final_name.c_str());
imp_->mut_ = CreateMutex(nullptr,
FALSE,
final_name.c_str());
if(!imp_->mut_) {
EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
}
if(!imp_->mut_) {
EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
}
#else
std::string final_name = name;
final_name += ".lock";
std::string final_name = name;
final_name += ".lock";
imp_->fd_ = open(final_name.c_str(),
O_RDWR | O_CREAT | O_CLOEXEC,
S_IRUSR | S_IWUSR);
imp_->fd_ = open(final_name.c_str(),
O_RDWR | O_CREAT | O_CLOEXEC,
S_IRUSR | S_IWUSR);
if(imp_->fd_ == -1) {
EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
}
if(imp_->fd_ == -1) {
EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
}
#endif
}
}
IPCMutex::~IPCMutex() {
IPCMutex::~IPCMutex() {
#ifdef _WINDOWS
if(locked_) {
ReleaseMutex(imp_->mut_);
}
CloseHandle(imp_->mut_);
if(locked_) {
ReleaseMutex(imp_->mut_);
}
CloseHandle(imp_->mut_);
#else
if(locked_) {
lockf(imp_->fd_, F_ULOCK, 0);
}
close(imp_->fd_);
if(locked_) {
lockf(imp_->fd_, F_ULOCK, 0);
}
close(imp_->fd_);
#endif
delete imp_;
}
delete imp_;
}
bool IPCMutex::Lock() {
if(locked_) {
return false;
}
bool IPCMutex::Lock() {
if(locked_) {
return false;
}
#ifdef _WINDOWS
DWORD wait_result = WaitForSingleObject(imp_->mut_, INFINITE);
if(wait_result != WAIT_OBJECT_0) {
return false;
}
DWORD wait_result = WaitForSingleObject(imp_->mut_, INFINITE);
if(wait_result != WAIT_OBJECT_0) {
return false;
}
#else
if(lockf(imp_->fd_, F_LOCK, 0) != 0) {
return false;
}
if(lockf(imp_->fd_, F_LOCK, 0) != 0) {
return false;
}
#endif
locked_ = true;
return true;
}
locked_ = true;
return true;
}
bool IPCMutex::Unlock() {
if(!locked_) {
return false;
}
bool IPCMutex::Unlock() {
if(!locked_) {
return false;
}
#ifdef _WINDOWS
if(!ReleaseMutex(imp_->mut_)) {
return false;
}
if(!ReleaseMutex(imp_->mut_)) {
return false;
}
#else
if(lockf(imp_->fd_, F_ULOCK, 0) != 0) {
return false;
}
if(lockf(imp_->fd_, F_ULOCK, 0) != 0) {
return false;
}
#endif
locked_ = false;
return true;
}
locked_ = false;
return true;
}
}

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _MUTEX_H_
@ -22,44 +22,44 @@
#include <string>
namespace EQEmu {
//! Interprocess Named Binary Semaphore (Mutex)
/*!
Important to note: while this can be used to synchronize processes, it is not in itself re-entrant or thread-safe
and thus should be used from one thread and non-recursively. It was intended to be a simple synchronization method
for our MemoryMappedFile loading.
*/
class IPCMutex {
struct Implementation;
public:
//! Constructor
/*!
Creates a named binary semaphore, basically a semaphore that is init S <- 1
\param name The name of this mutex.
*/
IPCMutex(std::string name);
//! Destructor
~IPCMutex();
//! Lock the mutex
/*!
Same basic function as P(): for(;;) { if(S > 0) { S -= 1; break; } }
*/
bool Lock();
//! Unlocks the mutex
/*!
Same basic function as V(): S += 1;
*/
bool Unlock();
private:
IPCMutex(const IPCMutex&);
const IPCMutex& operator=(const IPCMutex&);
bool locked_; //!< Whether this mutex is locked or not
Implementation *imp_;
};
//! 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
and thus should be used from one thread and non-recursively. It was intended to be a simple synchronization method
for our MemoryMappedFile loading.
*/
class IPCMutex {
struct Implementation;
public:
//! Constructor
/*!
Creates a named binary semaphore, basically a semaphore that is init S <- 1
\param name The name of this mutex.
*/
IPCMutex(std::string name);
//! Destructor
~IPCMutex();
//! Lock the mutex
/*!
Same basic function as P(): for(;;) { if(S > 0) { S -= 1; break; } }
*/
bool Lock();
//! Unlocks the mutex
/*!
Same basic function as V(): S += 1;
*/
bool Unlock();
private:
IPCMutex(const IPCMutex&);
const IPCMutex& operator=(const IPCMutex&);
bool locked_; //!< Whether this mutex is locked or not
Implementation *imp_;
};
}
#endif

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
*/
#ifndef ITEM_STRUCT_H
@ -21,25 +21,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
/*
* Note: (Doodman)
* This structure has field names that match the DB name exactly.
* Please take care as to not mess this up as it should make
* everyones life (i.e. mine) much easier. And the DB names
* match the field name from the 13th floor (SEQ) item collectors,
* so please maintain that as well.
* This structure has field names that match the DB name exactly.
* Please take care as to not mess this up as it should make
* everyones life (i.e. mine) much easier. And the DB names
* match the field name from the 13th floor (SEQ) item collectors,
* so please maintain that as well.
*
* Note #2: (Doodman)
* UnkXXX fields are left in here for completeness but commented
* out since they are really unknown and since the items are now
* preserialized they should not be needed. Conversly if they
* -are- needed, then they shouldn't be unkown.
* UnkXXX fields are left in here for completeness but commented
* out since they are really unknown and since the items are now
* preserialized they should not be needed. Conversly if they
* -are- needed, then they shouldn't be unkown.
*
* Note #3: (Doodman)
* Please take care when adding new found data fields to add them
* to the appropriate structure. Item_Struct has elements that are
* global to all types of items only.
* Please take care when adding new found data fields to add them
* to the appropriate structure. Item_Struct has elements that are
* global to all types of items only.
*
* Note #4: (Doodman)
* Made ya look! Ha!
* Made ya look! Ha!
*/
#include "eq_constants.h"
@ -93,7 +93,7 @@ struct Item_Struct {
bool PendingLoreFlag;
bool ArtifactFlag;
bool SummonedFlag;
uint8 FVNoDrop; // Firiona Vie nodrop flag
uint8 FVNoDrop; // Firiona Vie nodrop flag
uint32 Favor; // Individual favor
uint32 GuildFavor; // Guild favor
uint32 PointType;
@ -155,8 +155,8 @@ struct Item_Struct {
float SellRate; // Sell rate
//uint32 Unk059;
union {
uint32 Fulfilment; // Food fulfilment (How long it lasts)
int16 CastTime; // Cast Time for clicky effects, in milliseconds
uint32 Fulfilment; // Food fulfilment (How long it lasts)
int16 CastTime; // Cast Time for clicky effects, in milliseconds
};
uint32 EliteMaterial;
int32 ProcRate;
@ -205,7 +205,7 @@ struct Item_Struct {
bool Stackable;
bool NoTransfer;
bool QuestItemFlag;
int16 StackSize;
int16 StackSize;
uint8 PotionBeltSlots;
ItemEffect_Struct Click, Proc, Worn, Focus, Scroll, Bard;

View File

@ -1,52 +1,52 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemulator.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemulator.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LANGUAGES_H
#define LANGUAGES_H
#include "../common/types.h"
#define LANG_COMMON_TONGUE 0
#define LANG_BARBARIAN 1
#define LANG_ERUDIAN 2
#define LANG_ELVISH 3
#define LANG_DARK_ELVISH 4
#define LANG_DWARVISH 5
#define LANG_TROLL 6
#define LANG_OGRE 7
#define LANG_GNOMISH 8
#define LANG_HALFLING 9
#define LANG_THIEVES_CANT 10
#define LANG_OLD_ERUDIAN 11
#define LANG_ELDER_ELVISH 12
#define LANG_FROGLOK 13
#define LANG_GOBLIN 14
#define LANG_GNOLL 15
#define LANG_COMBINE_TONGUE 16
#define LANG_ELDER_TEIRDAL 17
#define LANG_LIZARDMAN 18
#define LANG_ORCISH 19
#define LANG_FAERIE 20
#define LANG_DRAGON 21
#define LANG_ELDER_DRAGON 22
#define LANG_DARK_SPEECH 23
#define LANG_VAH_SHIR 24
#define LANG_ALARAN 25
#define LANG_HADAL 26
#define LANG_UNKNOWN 27
#define LANG_COMMON_TONGUE 0
#define LANG_BARBARIAN 1
#define LANG_ERUDIAN 2
#define LANG_ELVISH 3
#define LANG_DARK_ELVISH 4
#define LANG_DWARVISH 5
#define LANG_TROLL 6
#define LANG_OGRE 7
#define LANG_GNOMISH 8
#define LANG_HALFLING 9
#define LANG_THIEVES_CANT 10
#define LANG_OLD_ERUDIAN 11
#define LANG_ELDER_ELVISH 12
#define LANG_FROGLOK 13
#define LANG_GOBLIN 14
#define LANG_GNOLL 15
#define LANG_COMBINE_TONGUE 16
#define LANG_ELDER_TEIRDAL 17
#define LANG_LIZARDMAN 18
#define LANG_ORCISH 19
#define LANG_FAERIE 20
#define LANG_DRAGON 21
#define LANG_ELDER_DRAGON 22
#define LANG_DARK_SPEECH 23
#define LANG_VAH_SHIR 24
#define LANG_ALARAN 25
#define LANG_HADAL 26
#define LANG_UNKNOWN 27
#endif

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
@ -24,90 +24,90 @@ enum direction{FORWARD,BACKWARD};
template<class TYPE> class LinkedListIterator;
template<class TYPE>
template<class TYPE>
class ListElement
{
private:
TYPE data;
ListElement<TYPE>* next;
ListElement<TYPE>* prev;
TYPE data;
ListElement<TYPE>* next;
ListElement<TYPE>* prev;
public:
ListElement ();
ListElement (const TYPE&);
ListElement (const ListElement<TYPE>&);
ListElement ();
ListElement (const TYPE&);
ListElement (const ListElement<TYPE>&);
~ListElement ();
~ListElement ();
ListElement<TYPE>& operator= (const ListElement<TYPE>&);
ListElement<TYPE>& operator= (const ListElement<TYPE>&);
ListElement<TYPE>* GetLast ()
{
ListElement<TYPE>* tmp = this;
while (tmp->GetNext()) {
tmp = tmp->GetNext();
ListElement<TYPE>* GetLast ()
{
ListElement<TYPE>* tmp = this;
while (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 const TYPE& GetData () const { return data ; }
inline TYPE& GetData () { 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 SetLastNext ( ListElement<TYPE>* p )
{
GetLast()->SetNext(p);
}
void SetNext (ListElement<TYPE>* n) { next = n ; }
void SetPrev (ListElement<TYPE>* p) { prev = p ; }
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 )
{
GetLast()->SetNext(p);
}
void SetNext (ListElement<TYPE>* n) { next = n ; }
void SetPrev (ListElement<TYPE>* p) { prev = p ; }
void ReplaceData(const TYPE&);
void ReplaceData(const TYPE&);
};
template<class TYPE>
template<class TYPE>
class LinkedList
{
private:
uint32 count;
uint32 count;
ListElement<TYPE>* first;
bool list_destructor_invoked;
public:
LinkedList();
~LinkedList();
bool dont_delete;
LinkedList<TYPE>& operator= (const LinkedList<TYPE>&);
LinkedList();
~LinkedList();
bool dont_delete;
LinkedList<TYPE>& operator= (const LinkedList<TYPE>&);
void Append (const TYPE&);
void Insert (const TYPE&);
TYPE Pop();
TYPE PeekTop();
void Clear();
void LCount() { count--; }
void ResetCount() { count=0; }
uint32 Count() { return count; }
ListElement<TYPE>* GetFirst() { return first; }
void Append (const TYPE&);
void Insert (const TYPE&);
TYPE Pop();
TYPE PeekTop();
void Clear();
void LCount() { count--; }
void ResetCount() { count=0; }
uint32 Count() { return count; }
ListElement<TYPE>* GetFirst() { return first; }
friend class LinkedListIterator<TYPE>;
friend class LinkedListIterator<TYPE>;
};
template<class TYPE>
template<class TYPE>
class LinkedListIterator
{
private:
LinkedList<TYPE>& list;
ListElement<TYPE>* current_element;
direction dir;
public:
LinkedListIterator(LinkedList<TYPE>& l,direction d = FORWARD) : list(l), dir(d) {};
LinkedList<TYPE>& list;
ListElement<TYPE>* current_element;
direction dir;
void Advance();
const TYPE& GetData();
bool IsFirst()
public:
LinkedListIterator(LinkedList<TYPE>& l,direction d = FORWARD) : list(l), dir(d) {};
void Advance();
const TYPE& GetData();
bool IsFirst()
{
if (current_element->GetPrev() == 0)
return true;
@ -121,13 +121,13 @@ public:
else
return false;
}
bool MoreElements();
void MoveFirst();
void MoveLast();
void RemoveCurrent(bool DeleteData = true);
void Replace(const TYPE& new_data);
void Reset();
void SetDir(direction);
bool MoreElements();
void MoveFirst();
void MoveLast();
void RemoveCurrent(bool DeleteData = true);
void Replace(const TYPE& new_data);
void Reset();
void SetDir(direction);
};
template<class TYPE>
@ -169,110 +169,110 @@ void LinkedListIterator<TYPE>::Advance()
template<class TYPE>
bool LinkedListIterator<TYPE>::MoreElements()
{
if (current_element == 0)
return false;
return true;
if (current_element == 0)
return false;
return true;
}
template<class TYPE>
const TYPE& LinkedListIterator<TYPE>::GetData()
{
return current_element->GetData();
return current_element->GetData();
}
template<class TYPE>
void LinkedListIterator<TYPE>::MoveFirst()
{
ListElement<TYPE>* prev = current_element->GetPrev();
ListElement<TYPE>* next = current_element->GetNext();
ListElement<TYPE>* prev = current_element->GetPrev();
ListElement<TYPE>* next = current_element->GetNext();
if (prev == 0)
if (prev == 0)
{
return;
}
// if (prev != 0)
// {
prev->SetNext(next);
// }
if (next != 0)
{
next->SetPrev(prev);
}
current_element->SetPrev(0);
current_element->SetNext(list.first);
list.first->SetPrev(current_element);
list.first = current_element;
//if (prev != 0)
//{
prev->SetNext(next);
//}
if (next != 0)
{
next->SetPrev(prev);
}
current_element->SetPrev(0);
current_element->SetNext(list.first);
list.first->SetPrev(current_element);
list.first = current_element;
}
template<class TYPE>
void LinkedListIterator<TYPE>::MoveLast()
{
ListElement<TYPE>* prev = current_element->GetPrev();
ListElement<TYPE>* next = current_element->GetNext();
ListElement<TYPE>* prev = current_element->GetPrev();
ListElement<TYPE>* next = current_element->GetNext();
if (next == 0)
if (next == 0)
{
return;
}
if (prev != 0)
{
prev->SetNext(next);
}
if (prev != 0)
{
prev->SetNext(next);
}
else
{
list.first = next;
list.first = next;
}
// if (next != 0)
// {
next->SetPrev(prev);
// }
current_element->SetNext(0);
current_element->SetPrev(next->GetLast());
next->GetLast()->SetNext(current_element);
//if (next != 0)
//{
next->SetPrev(prev);
//}
current_element->SetNext(0);
current_element->SetPrev(next->GetLast());
next->GetLast()->SetNext(current_element);
}
template<class TYPE>
void LinkedListIterator<TYPE>::RemoveCurrent(bool DeleteData)
{
ListElement<TYPE>* save;
ListElement<TYPE>* save;
if (list.first == current_element)
{
list.first = current_element->GetNext();
}
if (list.first == current_element)
{
list.first = current_element->GetNext();
}
if (current_element->GetPrev() != 0)
{
current_element->GetPrev()->SetNext(current_element->GetNext());
}
if (current_element->GetNext() != 0)
{
current_element->GetNext()->SetPrev(current_element->GetPrev());
}
if (dir == FORWARD)
{
save = current_element->GetNext();
}
else
{
save = current_element->GetPrev();
}
current_element->SetNext(0);
current_element->SetPrev(0);
if (!DeleteData)
current_element->SetData(0);
safe_delete(current_element);
current_element = save;
list.LCount();
if (current_element->GetPrev() != 0)
{
current_element->GetPrev()->SetNext(current_element->GetNext());
}
if (current_element->GetNext() != 0)
{
current_element->GetNext()->SetPrev(current_element->GetPrev());
}
if (dir == FORWARD)
{
save = current_element->GetNext();
}
else
{
save = current_element->GetPrev();
}
current_element->SetNext(0);
current_element->SetPrev(0);
if (!DeleteData)
current_element->SetData(0);
safe_delete(current_element);
current_element = save;
list.LCount();
}
template<class TYPE>
void LinkedListIterator<TYPE>::Replace(const TYPE& new_data)
{
current_element->ReplaceData(new_data);
current_element->ReplaceData(new_data);
}
template<class TYPE>
@ -280,10 +280,10 @@ void LinkedListIterator<TYPE>::Reset()
{
if (!(&list))
{
current_element=0;
return;
current_element=0;
return;
}
if (dir == FORWARD)
{
current_element = list.first;
@ -323,15 +323,15 @@ void LinkedListIterator<TYPE>::Reset()
template<class TYPE>
void LinkedListIterator<TYPE>::SetDir(direction d)
{
dir = d;
dir = d;
}
template<class TYPE>
ListElement<TYPE>::ListElement(const TYPE& d)
{
data = d;
next = 0;
prev = 0;
data = d;
next = 0;
prev = 0;
}
template<class TYPE>
@ -353,7 +353,7 @@ template<class TYPE>
void ListElement<TYPE>::ReplaceData(const TYPE& new_data)
{
if (data != 0)
safe_delete(data);
safe_delete(data);
data = new_data;
}
@ -388,32 +388,32 @@ void LinkedList<TYPE>::Clear() {
template<class TYPE>
void LinkedList<TYPE>::Append(const TYPE& data)
{
ListElement<TYPE>* new_element = new ListElement<TYPE>(data);
if (first == 0)
{
first = new_element;
}
else
{
new_element->SetPrev(first->GetLast());
first->SetLastNext(new_element);
}
count++;
ListElement<TYPE>* new_element = new ListElement<TYPE>(data);
if (first == 0)
{
first = new_element;
}
else
{
new_element->SetPrev(first->GetLast());
first->SetLastNext(new_element);
}
count++;
}
template<class TYPE>
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);
if (first != 0)
{
first->SetPrev(new_element);
}
first = new_element;
count++;
new_element->SetNext(first);
if (first != 0)
{
first->SetPrev(new_element);
}
first = new_element;
count++;
}
template<class TYPE>

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "logsys.h"
@ -33,7 +33,7 @@ const char *log_category_names[NUMBER_OF_LOG_CATEGORIES] = {
//this array is private to this file, only a const version of it is exposed
#define LOG_TYPE(category, type, enabled) { enabled, LOG_ ##category, #category "__" #type },
static LogTypeStatus real_log_type_info[NUMBER_OF_LOG_TYPES+1] =
static LogTypeStatus real_log_type_info[NUMBER_OF_LOG_TYPES+1] =
{
#include "logtypes.h"
{ false, NUMBER_OF_LOG_CATEGORIES, "BAD TYPE" } /* dummy trailing record */
@ -97,25 +97,25 @@ bool load_log_settings(const char *filename) {
#ifdef _WINDOWS
if (sscanf(linebuf, "%[^=]=%[^\n]\n", type_name, value) != 2)
continue;
#else
#else
if (sscanf(linebuf, "%[^=]=%[^\r\n]\n", type_name, value) != 2)
continue;
#endif
if(type_name[0] == '\0' || type_name[0] == '#')
continue;
//first make sure we understand the value
bool enabled;
if(!strcasecmp(value, "on") || !strcasecmp(value, "true") || !strcasecmp(value, "yes") || !strcasecmp(value, "enabled") || !strcmp(value, "1"))
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;
else {
printf("Unable to parse value '%s' from %s. Skipping line.", value, filename);
continue;
}
int r;
//first see if it is a category name
for(r = 0; r < NUMBER_OF_LOG_CATEGORIES; r++) {
@ -135,7 +135,7 @@ bool load_log_settings(const char *filename) {
}
continue;
}
for(r = 0; r < NUMBER_OF_LOG_TYPES; r++) {
if(!strcasecmp(log_type_info[r].name, type_name))
break;
@ -144,7 +144,7 @@ bool load_log_settings(const char *filename) {
printf("Unable to locate log type %s from file %s. Skipping line.", type_name, filename);
continue;
}
//got it all figured out, do something now...
if(enabled)
log_enable(LogType(r));
@ -155,6 +155,3 @@ bool load_log_settings(const char *filename) {
return(true);
}

View File

@ -1,46 +1,40 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LOGSYS_H_
#define LOGSYS_H_
/*
*
* Usage:
*
* These are the main functions provided by logsys:
* - _log(TYPE, fmt, ...) - Log a message in any context
* - mlog(TYPE, fmt, ...) - Zone only. Log a message from a Mob:: context, prefixing it with the mob's name.
* - 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.
* - _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
* - _pkt(TYPE, BasePacket *) - Log a packet hex dump with header in any context.
* - mhex(TYPE, data, length) - Zone only. Log a packet hex dump from a Mob:: context, prefixing it with the mob's name
* Types are defined in logtypes.h
*
*
*
*
* this is very C-ish, not C++ish, but thats how I felt like writting it
*
*
*
*/
*
* Usage:
*
* These are the main functions provided by logsys:
* - _log(TYPE, fmt, ...) - Log a message in any context
* - mlog(TYPE, fmt, ...) - Zone only. Log a message from a Mob:: context, prefixing it with the mob's name.
* - 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.
* - _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
* - _pkt(TYPE, BasePacket *) - Log a packet hex dump with header in any context.
* - mhex(TYPE, data, length) - Zone only. Log a packet hex dump from a Mob:: context, prefixing it with the mob's name
* Types are defined in logtypes.h
*
* this is very C-ish, not C++ish, but thats how I felt like writting it
*/
#include <stdarg.h>
#include "types.h"
@ -175,13 +169,5 @@ extern void log_toggle(LogType t);
extern bool load_log_settings(const char *filename);
#endif /*LOGSYS_H_*/

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debug.h"
@ -33,11 +33,7 @@ void log_messageVA(LogType type, const char *fmt, va_list args) {
char prefix_buffer[256];
snprintf(prefix_buffer, 255, "[%s] ", log_type_info[type].name);
prefix_buffer[255] = '\0';
LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args);
}

View File

@ -1,23 +1,21 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LOG_CATEGORY
#define LOG_CATEGORY(name)
#endif
@ -32,8 +30,6 @@
#endif
LOG_CATEGORY( CHAT )
LOG_TYPE( CHAT, SAY, DISABLED )
LOG_TYPE( CHAT, EMOTE, DISABLED )
@ -189,10 +185,10 @@ LOG_TYPE( CLIENT, NET_IN_TRACE, DISABLED )
LOG_TYPE( CLIENT, EXP, DISABLED )
LOG_CATEGORY( SKILLS )
LOG_TYPE( SKILLS, GAIN, DISABLED )
LOG_TYPE( SKILLS, GAIN, DISABLED )
LOG_CATEGORY( RULES )
LOG_TYPE( RULES, ERROR, DISABLED )
LOG_TYPE( RULES, ERROR, DISABLED )
LOG_TYPE( RULES, CHANGE, DISABLED )
LOG_CATEGORY( NET )
@ -260,6 +256,3 @@ LOG_TYPE( WORLD, LAUNCH_TRACE, ENABLED )
#undef LOG_TYPE
#undef LOG_CATEGORY

View File

@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemu.org)
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EQEMU_LOOTTABLE_H
@ -26,7 +26,7 @@ struct LootTableEntries_Struct {
uint8 droplimit;
uint8 mindrop;
uint8 multiplier;
float probability;
float probability;
};
struct LootTable_Struct {

View File

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

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