mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-22 20:33:01 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 808a86525f |
@@ -1,23 +0,0 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
# Matches multiple files with brace expansion notation
|
||||
# Set default charset
|
||||
[*.{js,py}]
|
||||
charset = utf-8
|
||||
|
||||
[*.cpp]
|
||||
indent_style = tab
|
||||
[*.h]
|
||||
indent_style = tab
|
||||
|
||||
# Tab indentation (no size specified)
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
@@ -1,26 +0,0 @@
|
||||
# automatic eol conversions
|
||||
* text=auto
|
||||
|
||||
*.c text
|
||||
*.cc text
|
||||
*.cpp text
|
||||
*.h text
|
||||
*.hpp text
|
||||
*.txt text
|
||||
*.pl text
|
||||
*.sql text
|
||||
*.xml text
|
||||
*.yaml text
|
||||
*.conf text
|
||||
*.resx text
|
||||
*.cs text
|
||||
*.ini text
|
||||
*.settings text
|
||||
*.html text
|
||||
*.css text
|
||||
*.js text
|
||||
*.types text
|
||||
|
||||
*.vcproj text merge=union
|
||||
*.csproj text merge=union
|
||||
*.sln text merge=union eol=crlf
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
# Object files
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# CMake
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
[Bb]uild*/
|
||||
log/
|
||||
logs/
|
||||
vcpkg/
|
||||
|
||||
.idea/*
|
||||
*cbp
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
[submodule "submodules/glm"]
|
||||
path = submodules/glm
|
||||
url = https://github.com/g-truc/glm.git
|
||||
[submodule "submodules/fmt"]
|
||||
path = submodules/fmt
|
||||
url = https://github.com/fmtlib/fmt.git
|
||||
[submodule "submodules/libuv"]
|
||||
path = submodules/libuv
|
||||
url = https://github.com/libuv/libuv.git
|
||||
[submodule "submodules/cereal"]
|
||||
path = submodules/cereal
|
||||
url = https://github.com/USCiLab/cereal.git
|
||||
[submodule "submodules/websocketpp"]
|
||||
path = submodules/websocketpp
|
||||
url = https://github.com/zaphoyd/websocketpp.git
|
||||
[submodule "submodules/recastnavigation"]
|
||||
path = submodules/recastnavigation
|
||||
url = https://github.com/EQEmu/recastnavigation.git
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
language: cpp
|
||||
compiler: gcc
|
||||
dist: trusty
|
||||
|
||||
before_install:
|
||||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
- sudo apt-get update -qq
|
||||
- mkdir $HOME/usr
|
||||
- export PATH="$HOME/usr/bin:$PATH"
|
||||
- wget https://cmake.org/files/v3.11/cmake-3.11.2-Linux-x86_64.sh
|
||||
- chmod +x cmake-3.11.2-Linux-x86_64.sh
|
||||
- ./cmake-3.11.2-Linux-x86_64.sh --prefix=$HOME/usr --exclude-subdir --skip-license
|
||||
|
||||
install:
|
||||
- sudo apt-get install -qq g++-7
|
||||
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
|
||||
- sudo apt-get install libmysqlclient-dev
|
||||
- sudo apt-get install libperl-dev
|
||||
- sudo apt-get install libboost-dev
|
||||
- sudo apt-get install liblua5.1-0-dev
|
||||
- sudo apt-get install zlib1g-dev
|
||||
- sudo apt-get install uuid-dev
|
||||
- sudo apt-get install libssl-dev
|
||||
script:
|
||||
- cmake -G "Unix Makefiles" -DEQEMU_BUILD_TESTS=ON -DEQEMU_ENABLE_BOTS=ON -DEQEMU_BUILD_LOGIN=ON
|
||||
- make -j2
|
||||
- ./bin/tests
|
||||
-415
@@ -1,415 +0,0 @@
|
||||
#EQEmu CMake
|
||||
#Variables used:
|
||||
#EQEMU_DISABLE_CRT_SECURE_WARNINGS
|
||||
#EQEMU_FAST_FLOATINGPOINT
|
||||
#EQEMU_ENABLE_CRASH_LOGGING
|
||||
#EQEMU_DISABLE_SAFESEH
|
||||
#EQEMU_BUILD_MSVC_MP
|
||||
#EQEMU_DEBUG_LEVEL
|
||||
#EQEMU_LOG_LEVEL_STATUS
|
||||
#EQEMU_LOG_LEVEL_NORMAL
|
||||
#EQEMU_LOG_LEVEL_ERROR
|
||||
#EQEMU_LOG_LEVEL_DEBUG
|
||||
#EQEMU_LOG_LEVEL_QUEST
|
||||
#EQEMU_LOG_LEVEL_COMMANDS
|
||||
#EQEMU_LOG_LEVEL_CRASH
|
||||
#EQEMU_DEPOP_INVALIDATES_CACHE
|
||||
#EQEMU_ENABLE_BOTS
|
||||
#EQEMU_DISABLE_LOGSYS
|
||||
#EQEMU_COMMANDS_LOGGING
|
||||
#EQEMU_BUILD_SERVER
|
||||
#EQEMU_BUILD_LOGIN
|
||||
#EQEMU_BUILD_TESTS
|
||||
#EQEMU_BUILD_PERL
|
||||
#EQEMU_BUILD_LUA
|
||||
#EQEMU_SANITIZE_LUA_LIBS
|
||||
#EQEMU_BUILD_CLIENT_FILES
|
||||
#EQEMU_USE_MAP_MMFS
|
||||
#EQEMU_MAP_DIR
|
||||
#EQEMU_ARCH
|
||||
#EQEMU_ARCH_ALT
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
IF(POLICY CMP0074)
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
ENDIF()
|
||||
|
||||
#FindMySQL is located here so lets make it so CMake can find it
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
|
||||
|
||||
#Our project name is EQEmu
|
||||
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)
|
||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
SET(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dependencies" "${CMAKE_PREFIX_PATH}")
|
||||
|
||||
#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)
|
||||
ENDIF(MSVC OR MINGW)
|
||||
|
||||
IF(MSVC)
|
||||
IF(CMAKE_CL_64)
|
||||
SET(EQEMU_ARCH "x64")
|
||||
SET(EQEMU_ARCH_ALT "x64")
|
||||
ELSE(CMAKE_CL_64)
|
||||
SET(EQEMU_ARCH "x86")
|
||||
SET(EQEMU_ARCH_ALT "Win32")
|
||||
ENDIF(CMAKE_CL_64)
|
||||
|
||||
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_${EQEMU_ARCH}")
|
||||
|
||||
IF(VCPKG_TOOLCHAIN)
|
||||
IF(NOT MSVC_VERSION GREATER 1800)
|
||||
SET(SODIUM_INCLUDE_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/include")
|
||||
ENDIF()
|
||||
ELSE(VCPKG_TOOLCHAIN)
|
||||
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_${EQEMU_ARCH}")
|
||||
SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_${EQEMU_ARCH}")
|
||||
SET(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/openssl_${EQEMU_ARCH}")
|
||||
|
||||
SET(SODIUM_INCLUDE_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/include")
|
||||
ENDIF(VCPKG_TOOLCHAIN)
|
||||
|
||||
IF(SODIUM_INCLUDE_HINTS)
|
||||
IF(MSVC_VERSION GREATER 1800)
|
||||
SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/${EQEMU_ARCH_ALT}/Release/v140/dynamic")
|
||||
ELSEIF(MSVC_VERSION EQUAL 1800)
|
||||
SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/${EQEMU_ARCH_ALT}/Release/v120/dynamic")
|
||||
ELSE()
|
||||
SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/${EQEMU_ARCH_ALT}/Release/v110/dynamic")
|
||||
ENDIF()
|
||||
ENDIF(SODIUM_INCLUDE_HINTS)
|
||||
|
||||
#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)
|
||||
|
||||
OPTION(EQEMU_BUILD_MSVC_MP "Enable build with multiple processes." ON)
|
||||
IF(EQEMU_BUILD_MSVC_MP)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
ENDIF(EQEMU_BUILD_MSVC_MP)
|
||||
|
||||
#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)
|
||||
|
||||
ADD_DEFINITIONS(-DNOMINMAX)
|
||||
ELSE(MSVC)
|
||||
#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
|
||||
IF(UNIX)
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
ADD_DEFINITIONS(-DFREEBSD)
|
||||
ADD_DEFINITIONS(-D_GLIBCXX_USE_C99)
|
||||
SET(FREEBSD TRUE)
|
||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
ADD_DEFINITIONS(-DDARWIN)
|
||||
SET(DARWIN TRUE)
|
||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
ENDIF(UNIX)
|
||||
|
||||
#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"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_STATUS 2 CACHE STRING "EQEmu logging level for [Status]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_NORMAL 3 CACHE STRING "EQEmu logging level for [Normal]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_ERROR 2 CACHE STRING "EQEmu logging level for [Error]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_DEBUG 3 CACHE STRING "EQEmu logging level for [Debug]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_QUEST 2 CACHE STRING "EQEmu logging level for [Quest]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_COMMANDS 1 CACHE STRING "EQEmu logging level for [Commands]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_CRASH 3 CACHE STRING "EQEmu logging level for [Crash]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
MARK_AS_ADVANCED(EQEMU_LOG_LEVEL_STATUS EQEMU_LOG_LEVEL_NORMAL EQEMU_LOG_LEVEL_ERROR EQEMU_LOG_LEVEL_DEBUG EQEMU_LOG_LEVEL_QUEST EQEMU_LOG_LEVEL_COMMANDS EQEMU_LOG_LEVEL_CRASH)
|
||||
|
||||
#NPC Types Cache Behavior
|
||||
OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (will cause a larger database hit on #repop but is more convienent)." ON)
|
||||
|
||||
#Bots are a compile time option so on/off
|
||||
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
|
||||
|
||||
#Disable entire _mlog system (excludes trade/command logs)
|
||||
OPTION(EQEMU_DISABLE_LOGSYS "Disable Logging INI System" ON)
|
||||
|
||||
#Enable GM Command log system
|
||||
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
|
||||
|
||||
IF(EQEMU_COMMANDS_LOGGING)
|
||||
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
|
||||
ENDIF(EQEMU_COMMANDS_LOGGING)
|
||||
|
||||
IF(EQEMU_DISABLE_LOGSYS)
|
||||
ADD_DEFINITIONS(-DDISABLE_LOGSYS)
|
||||
ENDIF(EQEMU_DISABLE_LOGSYS)
|
||||
|
||||
IF(EQEMU_ENABLE_BOTS)
|
||||
ADD_DEFINITIONS(-DBOTS)
|
||||
ENDIF(EQEMU_ENABLE_BOTS)
|
||||
|
||||
#What to build
|
||||
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
|
||||
OPTION(EQEMU_BUILD_LOGIN "Build the login server." OFF)
|
||||
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
|
||||
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
||||
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
||||
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
||||
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
||||
|
||||
#C++11 stuff
|
||||
IF(NOT MSVC)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-user-defined-literal")
|
||||
ENDIF()
|
||||
ENDIF(NOT MSVC)
|
||||
|
||||
#Various definitions
|
||||
IF(EQEMU_BUILD_PERL)
|
||||
ADD_DEFINITIONS(-DEMBPERL)
|
||||
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
|
||||
ENDIF(EQEMU_BUILD_PERL)
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
ADD_DEFINITIONS(-DLUA_EQEMU)
|
||||
ENDIF(EQEMU_BUILD_LUA)
|
||||
|
||||
#Disabled until reevaluation performed
|
||||
#OPTION(EQEMU_USE_MAP_MMFS "Create and use Zone Map MMF files." OFF)
|
||||
#IF(EQEMU_USE_MAP_MMFS)
|
||||
# ADD_DEFINITIONS(-DUSE_MAP_MMFS)
|
||||
#ENDIF(EQEMU_USE_MAP_MMFS)
|
||||
|
||||
SET(EQEMU_MAP_DIR "./Maps" CACHE STRING "The dir that maps, water maps, and paths are located in.")
|
||||
|
||||
ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL})
|
||||
ADD_DEFINITIONS(-DINVERSEXY)
|
||||
ADD_DEFINITIONS(-DFIELD_ITEMS)
|
||||
ADD_DEFINITIONS(-DMAP_DIR="${EQEMU_MAP_DIR}")
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_STATUS=${EQEMU_LOG_LEVEL_STATUS})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_NORMAL=${EQEMU_LOG_LEVEL_NORMAL})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_ERROR=${EQEMU_LOG_LEVEL_ERROR})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_DEBUG=${EQEMU_LOG_LEVEL_DEBUG})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_QUEST=${EQEMU_LOG_LEVEL_QUEST})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_COMMANDS=${EQEMU_LOG_LEVEL_COMMANDS})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_CRASH=${EQEMU_LOG_LEVEL_CRASH})
|
||||
ADD_DEFINITIONS(-DGLM_FORCE_RADIANS)
|
||||
ADD_DEFINITIONS(-DGLM_FORCE_CTOR_INIT)
|
||||
ADD_DEFINITIONS(-DGLM_ENABLE_EXPERIMENTAL)
|
||||
|
||||
#Find everything we need
|
||||
FIND_PACKAGE(ZLIB)
|
||||
FIND_PACKAGE(MySQL REQUIRED)
|
||||
IF(EQEMU_BUILD_PERL)
|
||||
FIND_PACKAGE(PerlLibs REQUIRED)
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${PERL_INCLUDE_PATH}")
|
||||
ENDIF(EQEMU_BUILD_PERL)
|
||||
|
||||
SET(SERVER_LIBS common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} uv_a fmt RecastNavigation::Detour)
|
||||
|
||||
FIND_PACKAGE(Sodium REQUIRED)
|
||||
IF(SODIUM_FOUND)
|
||||
OPTION(EQEMU_ENABLE_SECURITY "Use Encryption For TCP Connections" ON)
|
||||
IF(EQEMU_ENABLE_SECURITY)
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${SODIUM_INCLUDE_DIRS}")
|
||||
ADD_DEFINITIONS(-DENABLE_SECURITY)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} ${SODIUM_LIBRARIES})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(ZLIB_FOUND)
|
||||
OPTION(EQEMU_BUILD_ZLIB "Build internal version of zlib." OFF)
|
||||
|
||||
IF(EQEMU_BUILD_ZLIB)
|
||||
INCLUDE_DIRECTORIES(BEFORE SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng" "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} "zlibstatic")
|
||||
ELSE()
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_INCLUDE_DIRS}")
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} ${ZLIB_LIBRARY})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Could NOT find ZLIB - using ZLIBSTATIC package.")
|
||||
SET(EQEMU_BUILD_ZLIB ON)
|
||||
INCLUDE_DIRECTORIES(BEFORE SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng" "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} "zlibstatic")
|
||||
ENDIF()
|
||||
|
||||
IF(WIN32)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} "ws2_32" "psapi" "iphlpapi" "userenv")
|
||||
ENDIF()
|
||||
|
||||
IF(UNIX)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} ${CMAKE_DL_LIBS} "z" "m" "pthread")
|
||||
IF(NOT DARWIN)
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} "rt")
|
||||
ENDIF()
|
||||
SET(SERVER_LIBS ${SERVER_LIBS} "uuid")
|
||||
ENDIF()
|
||||
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
FIND_PACKAGE(EQLua51 REQUIRED)
|
||||
SET(Boost_USE_STATIC_LIBS OFF)
|
||||
SET(Boost_USE_MULTITHREADED ON)
|
||||
SET(Boost_USE_STATIC_RUNTIME OFF)
|
||||
SET(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/boost")
|
||||
|
||||
FIND_PACKAGE(Boost REQUIRED)
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${LUA_INCLUDE_DIR}" "${Boost_INCLUDE_DIRS}")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
||||
|
||||
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
|
||||
IF(EQEMU_SANITIZE_LUA_LIBS)
|
||||
ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
|
||||
ENDIF(EQEMU_SANITIZE_LUA_LIBS)
|
||||
ENDIF(EQEMU_BUILD_LUA)
|
||||
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${MySQL_INCLUDE_DIR}")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/glm")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/cereal/include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/fmt/include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/libuv/include" )
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DebugUtils/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Detour/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourCrowd/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourTileCache/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Recast/Include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/websocketpp")
|
||||
|
||||
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
||||
ADD_SUBDIRECTORY(common)
|
||||
ADD_SUBDIRECTORY(libs)
|
||||
ADD_SUBDIRECTORY(submodules/fmt)
|
||||
ADD_SUBDIRECTORY(submodules/libuv)
|
||||
|
||||
SET(RECASTNAVIGATION_DEMO OFF CACHE BOOL "Build demo")
|
||||
SET(RECASTNAVIGATION_TESTS OFF CACHE BOOL "Build tests")
|
||||
SET(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "Build examples")
|
||||
ADD_SUBDIRECTORY(submodules/recastnavigation)
|
||||
|
||||
IF(EQEMU_BUILD_ZLIB)
|
||||
SET(ZLIB_COMPAT ON CACHE BOOL "Compile with zlib compatible API")
|
||||
SET(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Build test binaries")
|
||||
ADD_SUBDIRECTORY(libs/zlibng)
|
||||
ENDIF()
|
||||
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
||||
IF(EQEMU_BUILD_SERVER)
|
||||
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)
|
||||
ENDIF(EQEMU_BUILD_LOGIN)
|
||||
|
||||
IF(EQEMU_BUILD_HC)
|
||||
ADD_SUBDIRECTORY(hc)
|
||||
ENDIF(EQEMU_BUILD_HC)
|
||||
|
||||
IF(EQEMU_BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ENDIF(EQEMU_BUILD_TESTS)
|
||||
|
||||
IF(EQEMU_BUILD_CLIENT_FILES)
|
||||
ADD_SUBDIRECTORY(client_files)
|
||||
ENDIF(EQEMU_BUILD_CLIENT_FILES)
|
||||
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This 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, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,78 +0,0 @@
|
||||
# EQEmulator Core Server
|
||||
|Travis CI (Linux)|Appveyor w/ Bots (Windows) |Appveyor w/o Bots (Windows) |
|
||||
|:---:|:---:|:---:|
|
||||
|[](https://travis-ci.org/EQEmu/Server) |[](https://ci.appveyor.com/project/KimLS/server-87crp/branch/master) |[](https://ci.appveyor.com/project/KimLS/server-w0pq2/branch/master) |
|
||||
|
||||
***
|
||||
|
||||
**EQEmulator is a custom completely from-scratch open source server implementation for EverQuest built mostly on C++**
|
||||
* MySQL/MariaDB is used as the database engine (over 200+ tables)
|
||||
* Perl and LUA are both supported scripting languages for NPC/Player/Quest oriented events
|
||||
* Open source database (Project EQ) has content up to expansion OoW (included in server installs)
|
||||
* Game server environments and databases can be heavily customized to create all new experiences
|
||||
* Hundreds of Quests/events created and maintained by Project EQ
|
||||
|
||||
## Server Installs
|
||||
| |Windows|Linux|
|
||||
|:---:|:---:|:---:|
|
||||
|**Install Count**|||
|
||||
### > Windows
|
||||
* [Install](https://github.com/EQEmu/Server/wiki/Windows-Server)
|
||||
|
||||
### > Debian/Ubuntu/CentOS/Fedora
|
||||
* You can use curl or wget to kick off the installer (whichever your OS has)
|
||||
> curl -O https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/linux_installer/install.sh install.sh && chmod 755 install.sh && ./install.sh
|
||||
|
||||
> wget --no-check-certificate https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/linux_installer/install.sh -O install.sh && chmod 755 install.sh && ./install.sh
|
||||
|
||||
## Supported Clients
|
||||
|
||||
|Titanium Edition|Secrets of Faydwer|Seeds of Destruction|Underfoot|Rain of Fear|
|
||||
|:---:|:---:|:---:|:---:|:---:|
|
||||
|<img src="http://i.imgur.com/hrwDxoM.jpg" height="150">|<img src="http://i.imgur.com/cRDW5tn.png" height="150">|<img src="http://i.imgur.com/V48kuVn.jpg" height="150">|<img src="http://i.imgur.com/IJQ0XMa.jpg" height="150">|<img src="http://i.imgur.com/OMpHkKa.png" height="100">|
|
||||
|
||||
## Bug Reports <img src="http://i.imgur.com/daf1Vjw.png" height="20">
|
||||
* Please use the [issue tracker](https://github.com/EQEmu/Server/issues) provided by GitHub to send us bug
|
||||
reports or feature requests.
|
||||
* The [EQEmu Forums](http://www.eqemulator.org/forums/) are also a place to submit and get help with bugs.
|
||||
|
||||
## Contributions <img src="http://image.flaticon.com/icons/png/512/25/25231.png" width="20">
|
||||
|
||||
* The preferred way to contribute is to fork the repo and submit a pull request on
|
||||
GitHub. If you need help with your changes, you can always post on the forums or
|
||||
try Discord. You can also post unified diffs (`git diff` should do the trick) on the
|
||||
[Server Code Submissions](http://www.eqemulator.org/forums/forumdisplay.php?f=669)
|
||||
forum, although pull requests will be much quicker and easier on all parties.
|
||||
|
||||
## Contact <img src="http://gamerescape.com/wp-content/uploads/2015/06/discord.png" height="20">
|
||||
|
||||
- Discord Channel: https://discord.gg/QHsm7CD
|
||||
- **User Discord Channel**: `#general`
|
||||
- **Developer Discord Channel**: `#eqemucoders`
|
||||
|
||||
## Resources
|
||||
- [EQEmulator Forums](http://www.eqemulator.org/forums)
|
||||
- [EQEmulator Wiki](https://github.com/EQEmu/Server/wiki)
|
||||
|
||||
## Related Repositories
|
||||
* [ProjectEQ Quests](https://github.com/ProjectEQ/projecteqquests)
|
||||
* [Maps](https://github.com/Akkadius/EQEmuMaps)
|
||||
* [Installer Resources](https://github.com/Akkadius/EQEmuInstall)
|
||||
* [Zone Utilities](https://github.com/EQEmu/zone-utilities) - Various utilities and libraries for parsing, rendering and manipulating EQ Zone files.
|
||||
|
||||
## Other License Info
|
||||
|
||||
* The server code and utilities are released under **GPLv3**
|
||||
* We also include some small libraries for convienence that may be under different licensing
|
||||
* SocketLib - GPL LibXML
|
||||
* zlib - zlib license
|
||||
* MariaDB/MySQL - GPL
|
||||
* GPL Perl - GPL / ActiveState (under the assumption that this is a free project)
|
||||
* CPPUnit - GLP StringUtilities - Apache
|
||||
* LUA - MIT
|
||||
|
||||
## Contributors
|
||||
|
||||
<a href="https://github.com/EQEmu/server/graphs/contributors">
|
||||
<img src="https://contributors-img.firebaseapp.com/image?repo=EQEmu/server" />
|
||||
</a>
|
||||
@@ -1,21 +0,0 @@
|
||||
version: 1.0.{build}
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
image: Visual Studio 2017
|
||||
configuration: RelWithDebInfo
|
||||
clone_folder: c:\projects\eqemu
|
||||
init:
|
||||
- ps: git config --global core.autocrlf input
|
||||
cache: c:\tools\vcpkg\installed\
|
||||
before_build:
|
||||
- ps: "$wc = New-Object System.Net.WebClient\n$wc.DownloadFile(\"http://strawberryperl.com/download/5.26.2.1/strawberry-perl-5.26.2.1-64bit-portable.zip\", \"c:\\projects\\eqemu\\strawberry-perl-5.26.2.1-64bit-portable.zip\")\ncd c:\\projects\\eqemu\n7z x c:/projects/eqemu/strawberry-perl-5.26.2.1-64bit-portable.zip -oc:/projects/eqemu/strawberry-perl-portable -y\n(Get-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h).replace('#define PERL_STATIC_INLINE static __inline__', '#define PERL_STATIC_INLINE static __inline') | Set-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h\nvcpkg install boost-geometry:x64-windows boost-dynamic-bitset:x64-windows luajit:x64-windows libsodium:x64-windows libmysql:x64-windows openssl:x64-windows zlib:x64-windows \nmkdir build\ncd build\ncmake -G \"Visual Studio 15 2017 Win64\" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -EQEMU_ENABLE_BOTS=ON -DPERL_EXECUTABLE=\"C:/projects/eqemu/strawberry-perl-portable/perl/bin/perl.exe\" -DPERL_INCLUDE_PATH=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE\" -DPERL_LIBRARY=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/libperl526.a\" -DCMAKE_TOOLCHAIN_FILE=\"c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake\" .."
|
||||
build:
|
||||
project: C:\projects\eqemu\build\EQEmu.sln
|
||||
parallel: true
|
||||
verbosity: minimal
|
||||
after_build:
|
||||
- cmd: >-
|
||||
7z a build_x64-bots.zip C:\projects\eqemu\build\bin\RelWithDebInfo\*.exe C:\projects\eqemu\build\bin\RelWithDebInfo\*.dll C:\projects\eqemu\build\bin\RelWithDebInfo\*.pdb
|
||||
|
||||
appveyor PushArtifact build_x64-bots.zip
|
||||
@@ -1,21 +0,0 @@
|
||||
version: 1.0.{build}
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
image: Visual Studio 2017
|
||||
configuration: RelWithDebInfo
|
||||
clone_folder: c:\projects\eqemu
|
||||
init:
|
||||
- ps: git config --global core.autocrlf input
|
||||
cache: c:\tools\vcpkg\installed\
|
||||
before_build:
|
||||
- ps: "$wc = New-Object System.Net.WebClient\n$wc.DownloadFile(\"http://strawberryperl.com/download/5.26.2.1/strawberry-perl-5.26.2.1-64bit-portable.zip\", \"c:\\projects\\eqemu\\strawberry-perl-5.26.2.1-64bit-portable.zip\")\ncd c:\\projects\\eqemu\n7z x c:/projects/eqemu/strawberry-perl-5.26.2.1-64bit-portable.zip -oc:/projects/eqemu/strawberry-perl-portable -y\n(Get-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h).replace('#define PERL_STATIC_INLINE static __inline__', '#define PERL_STATIC_INLINE static __inline') | Set-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h\nvcpkg install boost-geometry:x64-windows boost-dynamic-bitset:x64-windows luajit:x64-windows libsodium:x64-windows libmysql:x64-windows openssl:x64-windows zlib:x64-windows \nmkdir build\ncd build\ncmake -G \"Visual Studio 15 2017 Win64\" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -EQEMU_ENABLE_BOTS=OFF -DPERL_EXECUTABLE=\"C:/projects/eqemu/strawberry-perl-portable/perl/bin/perl.exe\" -DPERL_INCLUDE_PATH=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE\" -DPERL_LIBRARY=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/libperl526.a\" -DCMAKE_TOOLCHAIN_FILE=\"c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake\" .."
|
||||
build:
|
||||
project: C:\projects\eqemu\build\EQEmu.sln
|
||||
parallel: true
|
||||
verbosity: minimal
|
||||
after_build:
|
||||
- cmd: >-
|
||||
7z a build_x64-no-bots.zip C:\projects\eqemu\build\bin\RelWithDebInfo\*.exe C:\projects\eqemu\build\bin\RelWithDebInfo\*.dll C:\projects\eqemu\build\bin\RelWithDebInfo\*.pdb
|
||||
|
||||
appveyor PushArtifact build_x64-no-bots.zip
|
||||
-11138
File diff suppressed because it is too large
Load Diff
@@ -1,4 +0,0 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
add_subdirectory(import)
|
||||
add_subdirectory(export)
|
||||
@@ -1,16 +0,0 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
SET(export_sources
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(export_headers
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(export_client_files ${export_sources} ${export_headers})
|
||||
|
||||
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
TARGET_LINK_LIBRARIES(export_client_files ${SERVER_LIBS})
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
@@ -1,258 +0,0 @@
|
||||
/* 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
|
||||
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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../common/eqemu_logsys.h"
|
||||
#include "../../common/global_define.h"
|
||||
#include "../../common/shareddb.h"
|
||||
#include "../../common/eqemu_config.h"
|
||||
#include "../../common/platform.h"
|
||||
#include "../../common/crash.h"
|
||||
#include "../../common/rulesys.h"
|
||||
#include "../../common/string_util.h"
|
||||
|
||||
EQEmuLogSys LogSys;
|
||||
|
||||
void ExportSpells(SharedDatabase *db);
|
||||
void ExportSkillCaps(SharedDatabase *db);
|
||||
void ExportBaseData(SharedDatabase *db);
|
||||
void ExportDBStrings(SharedDatabase *db);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
RegisterExecutablePlatform(ExePlatformClientExport);
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
set_exception_handler();
|
||||
|
||||
Log(Logs::General, Logs::Status, "Client Files Export Utility");
|
||||
if(!EQEmuConfig::LoadConfig()) {
|
||||
Log(Logs::General, Logs::Error, "Unable to load configuration file.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto Config = EQEmuConfig::get();
|
||||
|
||||
SharedDatabase database;
|
||||
Log(Logs::General, Logs::Status, "Connecting to database...");
|
||||
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
|
||||
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) {
|
||||
Log(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a "
|
||||
"database connection");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Register Log System and Settings */
|
||||
database.LoadLogSettings(LogSys.log_settings);
|
||||
LogSys.StartFileLogs();
|
||||
|
||||
std::string arg_1;
|
||||
|
||||
if (argv[1]) {
|
||||
arg_1 = argv[1];
|
||||
}
|
||||
|
||||
if (arg_1 == "spells") {
|
||||
ExportSpells(&database);
|
||||
return 0;
|
||||
}
|
||||
if (arg_1 == "skills") {
|
||||
ExportSkillCaps(&database);
|
||||
return 0;
|
||||
}
|
||||
if (arg_1 == "basedata") {
|
||||
ExportBaseData(&database);
|
||||
return 0;
|
||||
}
|
||||
if (arg_1 == "dbstring") {
|
||||
ExportDBStrings(&database);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ExportSpells(&database);
|
||||
ExportSkillCaps(&database);
|
||||
ExportBaseData(&database);
|
||||
ExportDBStrings(&database);
|
||||
|
||||
LogSys.CloseFileLogs();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ExportSpells(SharedDatabase *db) {
|
||||
Log(Logs::General, Logs::Status, "Exporting Spells...");
|
||||
|
||||
FILE *f = fopen("export/spells_us.txt", "w");
|
||||
if(!f) {
|
||||
Log(Logs::General, Logs::Error, "Unable to open export/spells_us.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string query = "SELECT * FROM spells_new ORDER BY id";
|
||||
auto results = db->QueryDatabase(query);
|
||||
|
||||
if(results.Success()) {
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
std::string line;
|
||||
unsigned int fields = results.ColumnCount();
|
||||
for(unsigned int i = 0; i < fields; ++i) {
|
||||
if(i != 0) {
|
||||
line.push_back('^');
|
||||
}
|
||||
|
||||
if(row[i] != nullptr) {
|
||||
line += row[i];
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(f, "%s\n", line.c_str());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) {
|
||||
|
||||
bool res = false;
|
||||
|
||||
std::string query = StringFormat("SELECT max(cap) FROM skill_caps WHERE class=%d AND skillID=%d",
|
||||
class_id, skill_id);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return false;
|
||||
|
||||
auto row = results.begin();
|
||||
if(row[0] && atoi(row[0]) > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
|
||||
|
||||
std::string query = StringFormat("SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d",
|
||||
class_id, skill_id, level);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
void ExportSkillCaps(SharedDatabase *db) {
|
||||
Log(Logs::General, Logs::Status, "Exporting Skill Caps...");
|
||||
|
||||
FILE *f = fopen("export/SkillCaps.txt", "w");
|
||||
if(!f) {
|
||||
Log(Logs::General, Logs::Error, "Unable to open export/SkillCaps.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
for(int cl = 1; cl <= 16; ++cl) {
|
||||
for(int skill = 0; skill <= 77; ++skill) {
|
||||
if(SkillUsable(db, skill, cl)) {
|
||||
int previous_cap = 0;
|
||||
for(int level = 1; level <= 100; ++level) {
|
||||
int cap = GetSkill(db, skill, cl, level);
|
||||
if(cap < previous_cap) {
|
||||
cap = previous_cap;
|
||||
}
|
||||
|
||||
fprintf(f, "%d^%d^%d^%d^0\n", cl, skill, level, cap);
|
||||
previous_cap = cap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void ExportBaseData(SharedDatabase *db) {
|
||||
Log(Logs::General, Logs::Status, "Exporting Base Data...");
|
||||
|
||||
FILE *f = fopen("export/BaseData.txt", "w");
|
||||
if(!f) {
|
||||
Log(Logs::General, Logs::Error, "Unable to open export/BaseData.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string query = "SELECT * FROM base_data ORDER BY level, class";
|
||||
auto results = db->QueryDatabase(query);
|
||||
if(results.Success()) {
|
||||
for (auto row = results.begin();row != results.end();++row) {
|
||||
std::string line;
|
||||
unsigned int fields = results.ColumnCount();
|
||||
for(unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
||||
if(rowIndex != 0)
|
||||
line.push_back('^');
|
||||
|
||||
if(row[rowIndex] != nullptr) {
|
||||
line += row[rowIndex];
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(f, "%s\n", line.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void ExportDBStrings(SharedDatabase *db) {
|
||||
Log(Logs::General, Logs::Status, "Exporting DB Strings...");
|
||||
|
||||
FILE *f = fopen("export/dbstr_us.txt", "w");
|
||||
if(!f) {
|
||||
Log(Logs::General, Logs::Error, "Unable to open export/dbstr_us.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(f, "Major^Minor^String(New)\n");
|
||||
const std::string query = "SELECT * FROM db_str ORDER BY id, type";
|
||||
auto results = db->QueryDatabase(query);
|
||||
if(results.Success()) {
|
||||
for(auto row = results.begin(); row != results.end(); ++row) {
|
||||
std::string line;
|
||||
unsigned int fields = results.ColumnCount();
|
||||
for(unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
||||
if(rowIndex != 0)
|
||||
line.push_back('^');
|
||||
|
||||
if(row[rowIndex] != nullptr) {
|
||||
line += row[rowIndex];
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(f, "%s\n", line.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
SET(import_sources
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(import_headers
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(import_client_files ${import_sources} ${import_headers})
|
||||
|
||||
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
TARGET_LINK_LIBRARIES(import_client_files ${SERVER_LIBS})
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
@@ -1,318 +0,0 @@
|
||||
/* 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
|
||||
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
|
||||
*/
|
||||
|
||||
#include "../../common/eqemu_logsys.h"
|
||||
#include "../../common/global_define.h"
|
||||
#include "../../common/shareddb.h"
|
||||
#include "../../common/eqemu_config.h"
|
||||
#include "../../common/platform.h"
|
||||
#include "../../common/crash.h"
|
||||
#include "../../common/rulesys.h"
|
||||
#include "../../common/string_util.h"
|
||||
|
||||
EQEmuLogSys LogSys;
|
||||
|
||||
void ImportSpells(SharedDatabase *db);
|
||||
void ImportSkillCaps(SharedDatabase *db);
|
||||
void ImportBaseData(SharedDatabase *db);
|
||||
void ImportDBStrings(SharedDatabase *db);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
RegisterExecutablePlatform(ExePlatformClientImport);
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
set_exception_handler();
|
||||
|
||||
Log(Logs::General, Logs::Status, "Client Files Import Utility");
|
||||
if(!EQEmuConfig::LoadConfig()) {
|
||||
Log(Logs::General, Logs::Error, "Unable to load configuration file.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto Config = EQEmuConfig::get();
|
||||
|
||||
SharedDatabase database;
|
||||
Log(Logs::General, Logs::Status, "Connecting to database...");
|
||||
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
|
||||
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) {
|
||||
Log(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a "
|
||||
"database connection");
|
||||
return 1;
|
||||
}
|
||||
|
||||
database.LoadLogSettings(LogSys.log_settings);
|
||||
LogSys.StartFileLogs();
|
||||
|
||||
ImportSpells(&database);
|
||||
ImportSkillCaps(&database);
|
||||
ImportBaseData(&database);
|
||||
ImportDBStrings(&database);
|
||||
|
||||
LogSys.CloseFileLogs();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetSpellColumns(SharedDatabase *db) {
|
||||
|
||||
const std::string query = "DESCRIBE spells_new";
|
||||
auto results = db->QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return results.RowCount();
|
||||
}
|
||||
|
||||
bool IsStringField(int i) {
|
||||
switch(i)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ImportSpells(SharedDatabase *db) {
|
||||
Log(Logs::General, Logs::Status, "Importing Spells...");
|
||||
FILE *f = fopen("import/spells_us.txt", "r");
|
||||
if(!f) {
|
||||
Log(Logs::General, Logs::Error, "Unable to open import/spells_us.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string query = "DELETE FROM spells_new";
|
||||
db->QueryDatabase(query);
|
||||
|
||||
int columns = GetSpellColumns(db);
|
||||
int spells_imported = 0;
|
||||
|
||||
char buffer[2048];
|
||||
while(fgets(buffer, 2048, f)) {
|
||||
for(int i = 0; i < 2048; ++i) {
|
||||
if(buffer[i] == '\n') {
|
||||
buffer[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string escaped = ::EscapeString(buffer);
|
||||
auto split = SplitString(escaped, '^');
|
||||
int line_columns = (int)split.size();
|
||||
|
||||
std::string sql;
|
||||
if(line_columns >= columns) {
|
||||
sql = "INSERT INTO spells_new VALUES(";
|
||||
for(int i = 0; i < columns; ++i) {
|
||||
if(i != 0) {
|
||||
sql += ", '";
|
||||
} else {
|
||||
sql += "'";
|
||||
}
|
||||
|
||||
if(split[i].compare("") == 0 && !IsStringField(i)) {
|
||||
sql += "0";
|
||||
}
|
||||
else {
|
||||
sql += split[i];
|
||||
}
|
||||
sql += "'";
|
||||
}
|
||||
|
||||
sql += ");";
|
||||
} else {
|
||||
int i = 0;
|
||||
sql = "INSERT INTO spells_new VALUES(";
|
||||
for(; i < line_columns; ++i) {
|
||||
if(i != 0) {
|
||||
sql += ", '";
|
||||
} else {
|
||||
sql += "'";
|
||||
}
|
||||
|
||||
if(split[i].compare("") == 0 && !IsStringField(i)) {
|
||||
sql += "0";
|
||||
} else {
|
||||
sql += split[i];
|
||||
}
|
||||
|
||||
sql += "'";
|
||||
}
|
||||
|
||||
for(; i < columns; ++i) {
|
||||
sql += ", '0'";
|
||||
}
|
||||
|
||||
sql += ");";
|
||||
}
|
||||
|
||||
db->QueryDatabase(sql);
|
||||
|
||||
spells_imported++;
|
||||
if(spells_imported % 1000 == 0) {
|
||||
Log(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
|
||||
}
|
||||
}
|
||||
|
||||
if(spells_imported % 1000 != 0) {
|
||||
Log(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void ImportSkillCaps(SharedDatabase *db) {
|
||||
Log(Logs::General, Logs::Status, "Importing Skill Caps...");
|
||||
|
||||
FILE *f = fopen("import/SkillCaps.txt", "r");
|
||||
if(!f) {
|
||||
Log(Logs::General, Logs::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string delete_sql = "DELETE FROM skill_caps";
|
||||
db->QueryDatabase(delete_sql);
|
||||
|
||||
char buffer[2048];
|
||||
while(fgets(buffer, 2048, f)) {
|
||||
auto split = SplitString(buffer, '^');
|
||||
|
||||
if(split.size() < 4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int class_id, skill_id, level, cap;
|
||||
class_id = atoi(split[0].c_str());
|
||||
skill_id = atoi(split[1].c_str());
|
||||
level = atoi(split[2].c_str());
|
||||
cap = atoi(split[3].c_str());
|
||||
|
||||
std::string sql = StringFormat("INSERT INTO skill_caps(class, skillID, level, cap) VALUES(%d, %d, %d, %d)",
|
||||
class_id, skill_id, level, cap);
|
||||
|
||||
db->QueryDatabase(sql);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void ImportBaseData(SharedDatabase *db) {
|
||||
Log(Logs::General, Logs::Status, "Importing Base Data...");
|
||||
|
||||
FILE *f = fopen("import/BaseData.txt", "r");
|
||||
if(!f) {
|
||||
Log(Logs::General, Logs::Error, "Unable to open import/BaseData.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string delete_sql = "DELETE FROM base_data";
|
||||
db->QueryDatabase(delete_sql);
|
||||
|
||||
char buffer[2048];
|
||||
while(fgets(buffer, 2048, f)) {
|
||||
auto split = SplitString(buffer, '^');
|
||||
|
||||
if(split.size() < 10) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string sql;
|
||||
int level, class_id;
|
||||
double hp, mana, end, unk1, unk2, hp_fac, mana_fac, end_fac;
|
||||
|
||||
level = atoi(split[0].c_str());
|
||||
class_id = atoi(split[1].c_str());
|
||||
hp = atof(split[2].c_str());
|
||||
mana = atof(split[3].c_str());
|
||||
end = atof(split[4].c_str());
|
||||
unk1 = atof(split[5].c_str());
|
||||
unk2 = atof(split[6].c_str());
|
||||
hp_fac = atof(split[7].c_str());
|
||||
mana_fac = atof(split[8].c_str());
|
||||
end_fac = atof(split[9].c_str());
|
||||
|
||||
sql = StringFormat("INSERT INTO base_data(level, class, hp, mana, end, unk1, unk2, hp_fac, "
|
||||
"mana_fac, end_fac) VALUES(%d, %d, %f, %f, %f, %f, %f, %f, %f, %f)",
|
||||
level, class_id, hp, mana, end, unk1, unk2, hp_fac, mana_fac, end_fac);
|
||||
|
||||
db->QueryDatabase(sql);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void ImportDBStrings(SharedDatabase *db) {
|
||||
Log(Logs::General, Logs::Status, "Importing DB Strings...");
|
||||
|
||||
FILE *f = fopen("import/dbstr_us.txt", "r");
|
||||
if(!f) {
|
||||
Log(Logs::General, Logs::Error, "Unable to open import/dbstr_us.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string delete_sql = "DELETE FROM db_str";
|
||||
db->QueryDatabase(delete_sql);
|
||||
|
||||
char buffer[2048];
|
||||
bool first = true;
|
||||
while(fgets(buffer, 2048, f)) {
|
||||
if(first) {
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 2048; ++i) {
|
||||
if(buffer[i] == '\n') {
|
||||
buffer[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto split = SplitString(buffer, '^');
|
||||
|
||||
if(split.size() < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string sql;
|
||||
int id, type;
|
||||
std::string value;
|
||||
|
||||
id = atoi(split[0].c_str());
|
||||
type = atoi(split[1].c_str());
|
||||
|
||||
if(split.size() >= 3) {
|
||||
value = ::EscapeString(split[2]);
|
||||
}
|
||||
|
||||
sql = StringFormat("INSERT INTO db_str(id, type, value) VALUES(%u, %u, '%s')",
|
||||
id, type, value.c_str());
|
||||
|
||||
db->QueryDatabase(sql);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
#CMake - Cross Platform Makefile Generator
|
||||
#Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions
|
||||
#are met:
|
||||
#
|
||||
#* Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
#* Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
#* Neither the names of Kitware, Inc., the Insight Software Consortium,
|
||||
# nor the names of their contributors may be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
#HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# This module defines
|
||||
# LUA51_FOUND, if false, do not try to link to Lua
|
||||
# LUA_LIBRARIES
|
||||
# LUA_INCLUDE_DIR, where to find lua.h
|
||||
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||
|
||||
IF(LUA_ROOT)
|
||||
FIND_PATH(LUA_INCLUDE_DIR
|
||||
NAMES lua.h
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATHS
|
||||
${LUA_ROOT}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include src
|
||||
)
|
||||
|
||||
FIND_LIBRARY(LUA_LIBRARY
|
||||
NAMES lua51 lua5.1 lua-5.1 lua
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATHS
|
||||
${LUA_ROOT}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
PATH_SUFFIXES lib bin
|
||||
)
|
||||
ELSE(LUA_ROOT)
|
||||
FIND_PATH(LUA_INCLUDE_DIR
|
||||
NAMES lua.h
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(LUA_LIBRARY
|
||||
NAMES lua51 lua5.1 lua-5.1 lua
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
PATH_SUFFIXES lib bin
|
||||
)
|
||||
ENDIF(LUA_ROOT)
|
||||
|
||||
IF(LUA_LIBRARY)
|
||||
# include the math library for Unix
|
||||
IF(UNIX AND NOT APPLE)
|
||||
FIND_LIBRARY(LUA_MATH_LIBRARY m)
|
||||
SET(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
# For Windows and Mac, don't need to explicitly include the math library
|
||||
ELSE()
|
||||
SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
||||
FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
|
||||
|
||||
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
|
||||
UNSET(lua_version_str)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
|
||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
||||
VERSION_VAR LUA_VERSION_STRING)
|
||||
|
||||
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
||||
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
# - Find mysqlclient
|
||||
#
|
||||
# -*- cmake -*-
|
||||
#
|
||||
# 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
|
||||
|
||||
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
|
||||
# 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
|
||||
NO_DEFAULT_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
FIND_PATH(MySQL_INCLUDE_DIR
|
||||
NAMES mysql.h
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ELSE(MYSQL_ROOT)
|
||||
FIND_PATH(MySQL_INCLUDE_DIR
|
||||
NAMES mysql.h
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ENDIF(MYSQL_ROOT)
|
||||
|
||||
# Library
|
||||
SET(MySQL_NAMES libmysql)
|
||||
IF(MYSQL_ROOT)
|
||||
FIND_LIBRARY(MySQL_LIBRARY
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATHS ${MYSQL_ROOT}/lib
|
||||
PATH_SUFFIXES mysql
|
||||
NO_DEFAULT_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
|
||||
FIND_LIBRARY(MySQL_LIBRARY
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ELSE(MYSQL_ROOT)
|
||||
FIND_LIBRARY(MySQL_LIBRARY
|
||||
NAMES ${MySQL_NAMES} mysqlclient_r mysqlclient
|
||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ENDIF(MYSQL_ROOT)
|
||||
|
||||
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
||||
SET(MySQL_FOUND TRUE)
|
||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY} )
|
||||
ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
||||
SET(MySQL_FOUND FALSE)
|
||||
SET( MySQL_LIBRARIES )
|
||||
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
||||
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set MySQL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY MySQL_INCLUDE_DIR)
|
||||
|
||||
IF(MySQL_FOUND)
|
||||
SET( MySQL_LIBRARY_RELEASE ${MySQL_LIBRARY} )
|
||||
SET( MySQL_LIBRARY_DEBUG ${MySQL_LIBRARY} )
|
||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_RELEASE} ${MySQL_LIBRARY_DEBUG} )
|
||||
ELSE(MySQL_FOUND)
|
||||
SET( MySQL_LIBRARIES )
|
||||
ENDIF(MySQL_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MySQL_LIBRARY_DEBUG
|
||||
MySQL_LIBRARY_RELEASE
|
||||
MySQL_INCLUDE_DIR
|
||||
)
|
||||
@@ -1,30 +0,0 @@
|
||||
if (NOT MSVC)
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(PC_SODIUM "libsodium")
|
||||
if (NOT PC_SODIUM_FOUND)
|
||||
pkg_check_modules(PC_SODIUM "sodium")
|
||||
endif (NOT PC_SODIUM_FOUND)
|
||||
if (PC_SODIUM_FOUND)
|
||||
set(SODIUM_INCLUDE_HINTS ${PC_SODIUM_INCLUDE_DIRS} ${PC_SODIUM_INCLUDE_DIRS}/*)
|
||||
set(SODIUM_LIBRARY_HINTS ${PC_SODIUM_LIBRARY_DIRS} ${PC_SODIUM_LIBRARY_DIRS}/*)
|
||||
endif()
|
||||
endif (NOT MSVC)
|
||||
|
||||
# some libraries install the headers is a subdirectory of the include dir
|
||||
# returned by pkg-config, so use a wildcard match to improve chances of finding
|
||||
# headers and libraries.
|
||||
find_path(
|
||||
SODIUM_INCLUDE_DIRS
|
||||
NAMES sodium.h
|
||||
HINTS ${SODIUM_INCLUDE_HINTS}
|
||||
)
|
||||
|
||||
find_library(
|
||||
SODIUM_LIBRARIES
|
||||
NAMES libsodium sodium
|
||||
HINTS ${SODIUM_LIBRARY_HINTS}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SODIUM DEFAULT_MSG SODIUM_LIBRARIES SODIUM_INCLUDE_DIRS)
|
||||
mark_as_advanced(SODIUM_FOUND SODIUM_LIBRARIES SODIUM_INCLUDE_DIRS)
|
||||
@@ -1,399 +0,0 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
SET(common_sources
|
||||
base_packet.cpp
|
||||
classes.cpp
|
||||
compression.cpp
|
||||
condition.cpp
|
||||
crash.cpp
|
||||
crc16.cpp
|
||||
crc32.cpp
|
||||
database.cpp
|
||||
database_conversions.cpp
|
||||
database_instances.cpp
|
||||
dbcore.cpp
|
||||
deity.cpp
|
||||
emu_constants.cpp
|
||||
emu_limits.cpp
|
||||
emu_opcodes.cpp
|
||||
emu_versions.cpp
|
||||
eqdb.cpp
|
||||
eqdb_res.cpp
|
||||
eqemu_exception.cpp
|
||||
eqemu_config.cpp
|
||||
eqemu_logsys.cpp
|
||||
eq_limits.cpp
|
||||
eq_packet.cpp
|
||||
eq_stream_ident.cpp
|
||||
eq_stream_proxy.cpp
|
||||
eqtime.cpp
|
||||
event_sub.cpp
|
||||
extprofile.cpp
|
||||
faction.cpp
|
||||
guild_base.cpp
|
||||
guilds.cpp
|
||||
inventory_profile.cpp
|
||||
inventory_slot.cpp
|
||||
ipc_mutex.cpp
|
||||
item_data.cpp
|
||||
item_instance.cpp
|
||||
json_config.cpp
|
||||
light_source.cpp
|
||||
md5.cpp
|
||||
memory_buffer.cpp
|
||||
memory_mapped_file.cpp
|
||||
misc.cpp
|
||||
misc_functions.cpp
|
||||
mutex.cpp
|
||||
mysql_request_result.cpp
|
||||
mysql_request_row.cpp
|
||||
opcode_map.cpp
|
||||
opcodemgr.cpp
|
||||
packet_dump.cpp
|
||||
packet_dump_file.cpp
|
||||
packet_functions.cpp
|
||||
perl_eqdb.cpp
|
||||
perl_eqdb_res.cpp
|
||||
proc_launcher.cpp
|
||||
profanity_manager.cpp
|
||||
ptimer.cpp
|
||||
races.cpp
|
||||
rdtsc.cpp
|
||||
rulesys.cpp
|
||||
say_link.cpp
|
||||
serialize_buffer.cpp
|
||||
serverinfo.cpp
|
||||
shareddb.cpp
|
||||
skills.cpp
|
||||
spdat.cpp
|
||||
string_util.cpp
|
||||
struct_strategy.cpp
|
||||
textures.cpp
|
||||
timer.cpp
|
||||
unix.cpp
|
||||
xml_parser.cpp
|
||||
platform.cpp
|
||||
json/jsoncpp.cpp
|
||||
net/console_server.cpp
|
||||
net/console_server_connection.cpp
|
||||
net/crc32.cpp
|
||||
net/daybreak_connection.cpp
|
||||
net/eqstream.cpp
|
||||
net/packet.cpp
|
||||
net/servertalk_client_connection.cpp
|
||||
net/servertalk_legacy_client_connection.cpp
|
||||
net/servertalk_server.cpp
|
||||
net/servertalk_server_connection.cpp
|
||||
net/tcp_connection.cpp
|
||||
net/tcp_server.cpp
|
||||
net/websocket_server.cpp
|
||||
net/websocket_server_connection.cpp
|
||||
patches/patches.cpp
|
||||
patches/sod.cpp
|
||||
patches/sod_limits.cpp
|
||||
patches/sof.cpp
|
||||
patches/sof_limits.cpp
|
||||
patches/rof.cpp
|
||||
patches/rof_limits.cpp
|
||||
patches/rof2.cpp
|
||||
patches/rof2_limits.cpp
|
||||
patches/titanium.cpp
|
||||
patches/titanium_limits.cpp
|
||||
patches/uf.cpp
|
||||
patches/uf_limits.cpp
|
||||
StackWalker/StackWalker.cpp
|
||||
tinyxml/tinystr.cpp
|
||||
tinyxml/tinyxml.cpp
|
||||
tinyxml/tinyxmlerror.cpp
|
||||
tinyxml/tinyxmlparser.cpp
|
||||
util/directory.cpp
|
||||
util/uuid.cpp
|
||||
)
|
||||
|
||||
SET(common_headers
|
||||
any.h
|
||||
base_packet.h
|
||||
base_data.h
|
||||
bodytypes.h
|
||||
classes.h
|
||||
compression.h
|
||||
condition.h
|
||||
crash.h
|
||||
crc16.h
|
||||
crc32.h
|
||||
data_verification.h
|
||||
database.h
|
||||
dbcore.h
|
||||
deity.h
|
||||
emu_constants.h
|
||||
emu_limits.h
|
||||
emu_opcodes.h
|
||||
emu_oplist.h
|
||||
emu_versions.h
|
||||
eq_constants.h
|
||||
eq_packet_structs.h
|
||||
eqdb.h
|
||||
eqdb_res.h
|
||||
eqemu_exception.h
|
||||
eqemu_config.h
|
||||
eqemu_config_elements.h
|
||||
eqemu_logsys.h
|
||||
eqemu_logsys_fmt.h
|
||||
eq_limits.h
|
||||
eq_packet.h
|
||||
eq_stream_ident.h
|
||||
eq_stream_intf.h
|
||||
eq_stream_locator.h
|
||||
eq_stream_proxy.h
|
||||
eqtime.h
|
||||
errmsg.h
|
||||
event_sub.h
|
||||
extprofile.h
|
||||
faction.h
|
||||
features.h
|
||||
fixed_memory_hash_set.h
|
||||
fixed_memory_variable_hash_set.h
|
||||
global_define.h
|
||||
guild_base.h
|
||||
guilds.h
|
||||
inventory_profile.h
|
||||
inventory_slot.h
|
||||
ipc_mutex.h
|
||||
item_data.h
|
||||
item_fieldlist.h
|
||||
item_instance.h
|
||||
json_config.h
|
||||
languages.h
|
||||
light_source.h
|
||||
linked_list.h
|
||||
loottable.h
|
||||
mail_oplist.h
|
||||
md5.h
|
||||
memory_buffer.h
|
||||
memory_mapped_file.h
|
||||
misc.h
|
||||
misc_functions.h
|
||||
mutex.h
|
||||
mysql_request_result.h
|
||||
mysql_request_row.h
|
||||
op_codes.h
|
||||
opcode_dispatch.h
|
||||
opcodemgr.h
|
||||
packet_dump.h
|
||||
packet_dump_file.h
|
||||
packet_functions.h
|
||||
platform.h
|
||||
proc_launcher.h
|
||||
profanity_manager.h
|
||||
profiler.h
|
||||
ptimer.h
|
||||
queue.h
|
||||
races.h
|
||||
random.h
|
||||
rdtsc.h
|
||||
rulesys.h
|
||||
ruletypes.h
|
||||
say_link.h
|
||||
seperator.h
|
||||
serialize_buffer.h
|
||||
serverinfo.h
|
||||
servertalk.h
|
||||
shareddb.h
|
||||
skills.h
|
||||
spdat.h
|
||||
string_util.h
|
||||
struct_strategy.h
|
||||
textures.h
|
||||
timer.h
|
||||
types.h
|
||||
unix.h
|
||||
useperl.h
|
||||
version.h
|
||||
xml_parser.h
|
||||
zone_numbers.h
|
||||
event/event_loop.h
|
||||
event/task.h
|
||||
event/task_scheduler.h
|
||||
event/timer.h
|
||||
json/json.h
|
||||
json/json-forwards.h
|
||||
net/console_server.h
|
||||
net/console_server_connection.h
|
||||
net/crc32.h
|
||||
net/daybreak_connection.h
|
||||
net/daybreak_structs.h
|
||||
net/dns.h
|
||||
net/endian.h
|
||||
net/eqstream.h
|
||||
net/packet.h
|
||||
net/servertalk_client_connection.h
|
||||
net/servertalk_legacy_client_connection.h
|
||||
net/servertalk_common.h
|
||||
net/servertalk_server.h
|
||||
net/servertalk_server_connection.h
|
||||
net/tcp_connection.h
|
||||
net/tcp_server.h
|
||||
net/websocket_server.h
|
||||
net/websocket_server_connection.h
|
||||
patches/patches.h
|
||||
patches/sod.h
|
||||
patches/sod_limits.h
|
||||
patches/sod_ops.h
|
||||
patches/sod_structs.h
|
||||
patches/sof.h
|
||||
patches/sof_limits.h
|
||||
patches/sof_ops.h
|
||||
patches/sof_structs.h
|
||||
patches/ss_declare.h
|
||||
patches/ss_define.h
|
||||
patches/ss_register.h
|
||||
patches/rof.h
|
||||
patches/rof_limits.h
|
||||
patches/rof_ops.h
|
||||
patches/rof_structs.h
|
||||
patches/rof2.h
|
||||
patches/rof2_limits.h
|
||||
patches/rof2_ops.h
|
||||
patches/rof2_structs.h
|
||||
patches/titanium.h
|
||||
patches/titanium_limits.h
|
||||
patches/titanium_ops.h
|
||||
patches/titanium_structs.h
|
||||
patches/uf.h
|
||||
patches/uf_limits.h
|
||||
patches/uf_ops.h
|
||||
patches/uf_structs.h
|
||||
StackWalker/StackWalker.h
|
||||
tinyxml/tinystr.h
|
||||
tinyxml/tinyxml.h
|
||||
util/memory_stream.h
|
||||
util/directory.h
|
||||
util/uuid.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Event FILES
|
||||
event/event_loop.h
|
||||
event/timer.h
|
||||
event/task.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Json FILES
|
||||
json/json.h
|
||||
json/jsoncpp.cpp
|
||||
json/json-forwards.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Net FILES
|
||||
net/console_server.cpp
|
||||
net/console_server.h
|
||||
net/console_server_connection.cpp
|
||||
net/console_server_connection.h
|
||||
net/crc32.cpp
|
||||
net/crc32.h
|
||||
net/daybreak_connection.cpp
|
||||
net/daybreak_connection.h
|
||||
net/daybreak_structs.h
|
||||
net/dns.h
|
||||
net/endian.h
|
||||
net/eqmq.cpp
|
||||
net/eqmq.h
|
||||
net/eqstream.cpp
|
||||
net/eqstream.h
|
||||
net/packet.cpp
|
||||
net/packet.h
|
||||
net/servertalk_client_connection.cpp
|
||||
net/servertalk_client_connection.h
|
||||
net/servertalk_legacy_client_connection.cpp
|
||||
net/servertalk_legacy_client_connection.h
|
||||
net/servertalk_common.h
|
||||
net/servertalk_server.cpp
|
||||
net/servertalk_server.h
|
||||
net/servertalk_server_connection.cpp
|
||||
net/servertalk_server_connection.h
|
||||
net/tcp_connection.cpp
|
||||
net/tcp_connection.h
|
||||
net/tcp_server.cpp
|
||||
net/tcp_server.h
|
||||
net/websocket_server.cpp
|
||||
net/websocket_server.h
|
||||
net/websocket_server_connection.cpp
|
||||
net/websocket_server_connection.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Patches FILES
|
||||
patches/patches.h
|
||||
patches/sod.h
|
||||
patches/sod_limits.h
|
||||
patches/sod_ops.h
|
||||
patches/sod_structs.h
|
||||
patches/sof.h
|
||||
patches/sof_limits.h
|
||||
patches/sof_ops.h
|
||||
patches/sof_structs.h
|
||||
patches/ss_declare.h
|
||||
patches/ss_define.h
|
||||
patches/ss_register.h
|
||||
patches/rof.h
|
||||
patches/rof_limits.h
|
||||
patches/rof_ops.h
|
||||
patches/rof_structs.h
|
||||
patches/rof2.h
|
||||
patches/rof2_limits.h
|
||||
patches/rof2_ops.h
|
||||
patches/rof2_structs.h
|
||||
patches/titanium.h
|
||||
patches/titanium_limits.h
|
||||
patches/titanium_ops.h
|
||||
patches/titanium_structs.h
|
||||
patches/uf.h
|
||||
patches/uf_limits.h
|
||||
patches/uf_ops.h
|
||||
patches/uf_structs.h
|
||||
patches/patches.cpp
|
||||
patches/sod.cpp
|
||||
patches/sod_limits.cpp
|
||||
patches/sof.cpp
|
||||
patches/sof_limits.cpp
|
||||
patches/rof.cpp
|
||||
patches/rof_limits.cpp
|
||||
patches/rof2.cpp
|
||||
patches/rof2_limits.cpp
|
||||
patches/titanium.cpp
|
||||
patches/titanium_limits.cpp
|
||||
patches/uf.cpp
|
||||
patches/uf_limits.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP(StackWalker FILES
|
||||
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
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Util FILES
|
||||
util/memory_stream.h
|
||||
util/directory.cpp
|
||||
util/directory.h
|
||||
util/uuid.cpp
|
||||
util/uuid.h
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML)
|
||||
|
||||
ADD_LIBRARY(common ${common_sources} ${common_headers})
|
||||
|
||||
IF(UNIX)
|
||||
SET_SOURCE_FILES_PROPERTIES("SocketLib/Mime.cpp" PROPERTY COMPILE_FLAGS -Wno-unused-result)
|
||||
SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES COMPILE_FLAGS -O0)
|
||||
ENDIF(UNIX)
|
||||
|
||||
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
@@ -1,266 +0,0 @@
|
||||
/** \file Base64.cpp
|
||||
** \date 2004-02-13
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 "Base64.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
const char *Base64::bstr =
|
||||
"ABCDEFGHIJKLMNOPQ"
|
||||
"RSTUVWXYZabcdefgh"
|
||||
"ijklmnopqrstuvwxy"
|
||||
"z0123456789+/";
|
||||
|
||||
const char Base64::rstr[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
|
||||
0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0};
|
||||
|
||||
|
||||
void Base64::encode(FILE *fil, std::string& output, bool add_crlf)
|
||||
{
|
||||
size_t remain;
|
||||
size_t i = 0;
|
||||
size_t o = 0;
|
||||
char input[4];
|
||||
|
||||
output = "";
|
||||
remain = fread(input,1,3,fil);
|
||||
while (remain > 0)
|
||||
{
|
||||
if (add_crlf && o && o % 76 == 0)
|
||||
output += "\n";
|
||||
switch (remain)
|
||||
{
|
||||
case 1:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) ];
|
||||
output += "==";
|
||||
break;
|
||||
case 2:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) ];
|
||||
output += "=";
|
||||
break;
|
||||
default:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) + ((input[i + 2] >> 6) & 0x03) ];
|
||||
output += bstr[ (input[i + 2] & 0x3f) ];
|
||||
}
|
||||
o += 4;
|
||||
//
|
||||
remain = fread(input,1,3,fil);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Base64::encode(const std::string& str_in, std::string& str_out, bool add_crlf)
|
||||
{
|
||||
encode(str_in.c_str(), str_in.size(), str_out, add_crlf);
|
||||
}
|
||||
|
||||
|
||||
void Base64::encode(const char* input,size_t l,std::string& output, bool add_crlf)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t o = 0;
|
||||
|
||||
output = "";
|
||||
while (i < l)
|
||||
{
|
||||
size_t remain = l - i;
|
||||
if (add_crlf && o && o % 76 == 0)
|
||||
output += "\n";
|
||||
switch (remain)
|
||||
{
|
||||
case 1:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) ];
|
||||
output += "==";
|
||||
break;
|
||||
case 2:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) ];
|
||||
output += "=";
|
||||
break;
|
||||
default:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) + ((input[i + 2] >> 6) & 0x03) ];
|
||||
output += bstr[ (input[i + 2] & 0x3f) ];
|
||||
}
|
||||
o += 4;
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Base64::encode(unsigned char* input,size_t l,std::string& output,bool add_crlf)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t o = 0;
|
||||
|
||||
output = "";
|
||||
while (i < l)
|
||||
{
|
||||
size_t remain = l - i;
|
||||
if (add_crlf && o && o % 76 == 0)
|
||||
output += "\n";
|
||||
switch (remain)
|
||||
{
|
||||
case 1:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) ];
|
||||
output += "==";
|
||||
break;
|
||||
case 2:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) ];
|
||||
output += "=";
|
||||
break;
|
||||
default:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) + ((input[i + 2] >> 6) & 0x03) ];
|
||||
output += bstr[ (input[i + 2] & 0x3f) ];
|
||||
}
|
||||
o += 4;
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Base64::decode(const std::string& input,std::string& output)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t l = input.size();
|
||||
|
||||
output = "";
|
||||
while (i < l)
|
||||
{
|
||||
while (i < l && (input[i] == 13 || input[i] == 10))
|
||||
i++;
|
||||
if (i < l)
|
||||
{
|
||||
char b1 = (char)((rstr[(int)input[i]] << 2 & 0xfc) +
|
||||
(rstr[(int)input[i + 1]] >> 4 & 0x03));
|
||||
output += b1;
|
||||
if (input[i + 2] != '=')
|
||||
{
|
||||
char b2 = (char)((rstr[(int)input[i + 1]] << 4 & 0xf0) +
|
||||
(rstr[(int)input[i + 2]] >> 2 & 0x0f));
|
||||
output += b2;
|
||||
}
|
||||
if (input[i + 3] != '=')
|
||||
{
|
||||
char b3 = (char)((rstr[(int)input[i + 2]] << 6 & 0xc0) +
|
||||
rstr[(int)input[i + 3]]);
|
||||
output += b3;
|
||||
}
|
||||
i += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Base64::decode(const std::string& input, unsigned char *output, size_t& sz)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t l = input.size();
|
||||
size_t j = 0;
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
while (i < l && (input[i] == 13 || input[i] == 10))
|
||||
i++;
|
||||
if (i < l)
|
||||
{
|
||||
unsigned char b1 = (unsigned char)((rstr[(int)input[i]] << 2 & 0xfc) +
|
||||
(rstr[(int)input[i + 1]] >> 4 & 0x03));
|
||||
if (output)
|
||||
{
|
||||
output[j] = b1;
|
||||
}
|
||||
j++;
|
||||
if (input[i + 2] != '=')
|
||||
{
|
||||
unsigned char b2 = (unsigned char)((rstr[(int)input[i + 1]] << 4 & 0xf0) +
|
||||
(rstr[(int)input[i + 2]] >> 2 & 0x0f));
|
||||
if (output)
|
||||
{
|
||||
output[j] = b2;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (input[i + 3] != '=')
|
||||
{
|
||||
unsigned char b3 = (unsigned char)((rstr[(int)input[i + 2]] << 6 & 0xc0) +
|
||||
rstr[(int)input[i + 3]]);
|
||||
if (output)
|
||||
{
|
||||
output[j] = b3;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
i += 4;
|
||||
}
|
||||
}
|
||||
sz = j;
|
||||
}
|
||||
|
||||
|
||||
size_t Base64::decode_length(const std::string& str64)
|
||||
{
|
||||
if (!str64.size() || str64.size() % 4)
|
||||
return 0;
|
||||
size_t l = 3 * (str64.size() / 4 - 1) + 1;
|
||||
if (str64[str64.size() - 2] != '=')
|
||||
l++;
|
||||
if (str64[str64.size() - 1] != '=')
|
||||
l++;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/** \file Base64.h
|
||||
** \date 2004-02-13
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _BASE64_H
|
||||
#define _BASE64_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
/** \defgroup util Utilities */
|
||||
|
||||
/** Base64 encode/decode.
|
||||
\ingroup util */
|
||||
class Base64 {
|
||||
public:
|
||||
|
||||
static void encode(FILE *, std::string& , bool add_crlf = true);
|
||||
static void encode(const std::string&, std::string& , bool add_crlf = true);
|
||||
static void encode(const char *, size_t, std::string& , bool add_crlf = true);
|
||||
static void encode(unsigned char *, size_t, std::string& , bool add_crlf = true);
|
||||
|
||||
static void decode(const std::string&, std::string& );
|
||||
static void decode(const std::string& in, unsigned char *out, size_t&);
|
||||
|
||||
static size_t decode_length(const std::string& );
|
||||
|
||||
private:
|
||||
static const char *bstr;
|
||||
static const char rstr[128];
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _BASE64_H
|
||||
@@ -1,126 +0,0 @@
|
||||
/** \file File.cpp
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "File.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
File::File()
|
||||
:m_fil(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
File::~File()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool File::fopen(const std::string& path, const std::string& mode)
|
||||
{
|
||||
m_path = path;
|
||||
m_mode = mode;
|
||||
m_fil = ::fopen(path.c_str(), mode.c_str());
|
||||
return m_fil ? true : false;
|
||||
}
|
||||
|
||||
|
||||
void File::fclose()
|
||||
{
|
||||
if (m_fil)
|
||||
::fclose(m_fil);
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t File::fread(char *ptr, size_t size, size_t nmemb)
|
||||
{
|
||||
return m_fil ? ::fread(ptr, size, nmemb, m_fil) : 0;
|
||||
}
|
||||
|
||||
|
||||
size_t File::fwrite(const char *ptr, size_t size, size_t nmemb)
|
||||
{
|
||||
return m_fil ? ::fwrite(ptr, size, nmemb, m_fil) : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *File::fgets(char *s, int size)
|
||||
{
|
||||
return m_fil ? ::fgets(s, size, m_fil) : nullptr;
|
||||
}
|
||||
|
||||
|
||||
void File::fprintf(char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(m_fil, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
off_t File::size()
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(m_path.c_str(), &st) == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return st.st_size;
|
||||
}
|
||||
|
||||
|
||||
bool File::eof()
|
||||
{
|
||||
if (m_fil)
|
||||
{
|
||||
if (feof(m_fil))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/** \file File.h
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _FILE_H
|
||||
#define _FILE_H
|
||||
|
||||
#include "IFile.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
/** IFile implementation of a disk file.
|
||||
\ingroup file */
|
||||
class File : public IFile
|
||||
{
|
||||
public:
|
||||
File();
|
||||
~File();
|
||||
|
||||
bool fopen(const std::string&, const std::string&);
|
||||
void fclose();
|
||||
|
||||
size_t fread(char *, size_t, size_t);
|
||||
size_t fwrite(const char *, size_t, size_t);
|
||||
|
||||
char *fgets(char *, int);
|
||||
void fprintf(char *format, ...);
|
||||
|
||||
off_t size();
|
||||
bool eof();
|
||||
|
||||
private:
|
||||
File(const File& ) {} // copy constructor
|
||||
File& operator=(const File& ) { return *this; } // assignment operator
|
||||
|
||||
std::string m_path;
|
||||
std::string m_mode;
|
||||
FILE *m_fil;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _FILE_H
|
||||
@@ -1,366 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
*
|
||||
* This code originated from `C++ Sockets Library` referenced below.
|
||||
* Taken and stripped/modified to remove dependancies on parts of
|
||||
* the library which we are not using, and to suit other needs.
|
||||
* 2006 - EQEMu Development Team (http://eqemulator.net)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file HTTPSocket.cpp
|
||||
** \date 2004-04-06
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include "../global_define.h"
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <stdarg.h>
|
||||
#include "Parse.h"
|
||||
#include "HTTPSocket.h"
|
||||
#include "../tcp_connection.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
HTTPSocket::HTTPSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
|
||||
:TCPConnection(ID,in_socket,irIP,irPort)
|
||||
,m_first(true)
|
||||
,m_header(true)
|
||||
,m_http_version("HTTP/1.0")
|
||||
,m_request(false)
|
||||
,m_response(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
HTTPSocket::~HTTPSocket()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* eqemu stuff
|
||||
*/
|
||||
|
||||
bool HTTPSocket::ProcessReceivedData(char *errbuf)
|
||||
{
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
if (!recvbuf)
|
||||
return true;
|
||||
|
||||
char *buff=(char *)recvbuf;
|
||||
unsigned long bufflen=recvbuf_used;
|
||||
|
||||
while(1) {
|
||||
if (m_header) {
|
||||
char *ptr=(char *)memchr(buff,'\n',bufflen);
|
||||
if (!ptr)
|
||||
break;
|
||||
int length=(ptr-buff)+1;
|
||||
std::string line;
|
||||
line.append(buff,length-2);
|
||||
OnLine(line);
|
||||
|
||||
buff+=length;
|
||||
bufflen-=length;
|
||||
} else {
|
||||
OnData(buff,bufflen);
|
||||
buff+=bufflen;
|
||||
bufflen=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bufflen) {
|
||||
memmove(recvbuf,buff,bufflen);
|
||||
recvbuf_used=bufflen;
|
||||
} else {
|
||||
safe_delete_array(recvbuf);
|
||||
}
|
||||
}
|
||||
|
||||
bool HTTPSocket::SendString(const char *str) {
|
||||
return(TCPConnection::Send((const uchar *) str, strlen(str)));
|
||||
}
|
||||
|
||||
bool HTTPSocket::SendBuf(const char *dat, unsigned int len) {
|
||||
return(TCPConnection::Send((const uchar *) dat, len));
|
||||
}
|
||||
|
||||
/*
|
||||
* /eqemu stuff
|
||||
*/
|
||||
|
||||
void HTTPSocket::OnLine(const std::string& line)
|
||||
{
|
||||
if (m_first)
|
||||
{
|
||||
Parse pa(line);
|
||||
std::string str = pa.getword();
|
||||
if (str.substr(0,4) == "HTTP") // response
|
||||
{
|
||||
m_http_version = str;
|
||||
m_status = pa.getword();
|
||||
m_status_text = pa.getrest();
|
||||
m_response = true;
|
||||
}
|
||||
else // request
|
||||
{
|
||||
m_method = str;
|
||||
m_url = pa.getword();
|
||||
size_t spl = m_url.find("?");
|
||||
if (spl != std::string::npos)
|
||||
{
|
||||
m_uri = m_url.substr(0,spl);
|
||||
m_query_string = m_url.substr(spl + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_uri = m_url;
|
||||
}
|
||||
m_http_version = pa.getword();
|
||||
m_request = true;
|
||||
}
|
||||
m_first = false;
|
||||
OnFirst();
|
||||
return;
|
||||
}
|
||||
if (!line.size())
|
||||
{
|
||||
// SetLineProtocol(false);
|
||||
m_header = false;
|
||||
OnHeaderComplete();
|
||||
return;
|
||||
}
|
||||
Parse pa(line,":");
|
||||
std::string key = pa.getword();
|
||||
std::string value = pa.getrest();
|
||||
OnHeader(key,value);
|
||||
/* If remote end tells us to keep connection alive, and we're operating
|
||||
in http/1.1 mode (not http/1.0 mode), then we mark the socket to be
|
||||
retained. */
|
||||
/* if (!strcasecmp(key.c_str(), "connection") &&
|
||||
!strcasecmp(value.c_str(), "keep-alive") )
|
||||
{
|
||||
SetRetain();
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SendResponse()
|
||||
{
|
||||
std::string msg;
|
||||
msg = m_http_version + " " + m_status + " " + m_status_text + "\r\n";
|
||||
for (string_m::iterator it = m_response_header.begin(); it != m_response_header.end(); it++)
|
||||
{
|
||||
std::string key = (*it).first;
|
||||
std::string val = (*it).second;
|
||||
msg += key + ": " + val + "\r\n";
|
||||
}
|
||||
msg += "\r\n";
|
||||
SendString( msg.c_str() );
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::AddResponseHeader(const std::string& header, const char *format, ...)
|
||||
{
|
||||
static char slask[5000];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
#ifdef _WIN32
|
||||
vsprintf(slask, format, ap);
|
||||
#else
|
||||
vsnprintf(slask, 5000, format, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
|
||||
m_response_header[header] = slask;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SendRequest()
|
||||
{
|
||||
std::string msg;
|
||||
msg = m_method + " " + m_url + " " + m_http_version + "\r\n";
|
||||
for (string_m::iterator it = m_response_header.begin(); it != m_response_header.end(); it++)
|
||||
{
|
||||
std::string key = (*it).first;
|
||||
std::string val = (*it).second;
|
||||
msg += key + ": " + val + "\r\n";
|
||||
}
|
||||
msg += "\r\n";
|
||||
SendString( msg.c_str() );
|
||||
}
|
||||
|
||||
|
||||
std::string HTTPSocket::MyUseragent()
|
||||
{
|
||||
std::string version = "C++Sockets/";
|
||||
#ifdef _VERSION
|
||||
version += _VERSION;
|
||||
#endif
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::Reset()
|
||||
{
|
||||
m_first = true;
|
||||
m_header = true;
|
||||
m_request = false;
|
||||
m_response = false;
|
||||
// SetLineProtocol(true);
|
||||
while (m_response_header.size())
|
||||
{
|
||||
string_m::iterator it = m_response_header.begin();
|
||||
m_response_header.erase(it);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetMethod()
|
||||
{
|
||||
return m_method;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetMethod(const std::string& x)
|
||||
{
|
||||
m_method = x;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetUrl()
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetUrl(const std::string& x)
|
||||
{
|
||||
m_url = x;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetUri()
|
||||
{
|
||||
return m_uri;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetQueryString()
|
||||
{
|
||||
return m_query_string;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetHttpVersion()
|
||||
{
|
||||
return m_http_version;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetStatus()
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetStatusText()
|
||||
{
|
||||
return m_status_text;
|
||||
}
|
||||
|
||||
|
||||
bool HTTPSocket::IsRequest()
|
||||
{
|
||||
return m_request;
|
||||
}
|
||||
|
||||
|
||||
bool HTTPSocket::IsResponse()
|
||||
{
|
||||
return m_response;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetHttpVersion(const std::string& x)
|
||||
{
|
||||
m_http_version = x;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetStatus(const std::string& num, const std::string& text) {
|
||||
m_status = num;
|
||||
m_status_text = text;
|
||||
}
|
||||
|
||||
void HTTPSocket::SetStatus(const std::string& x)
|
||||
{
|
||||
m_status = x;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetStatusText(const std::string& x)
|
||||
{
|
||||
m_status_text = x;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::AddResponseHeader(const std::string& x,const std::string& y)
|
||||
{
|
||||
m_response_header[x] = y;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetUri(const std::string& x)
|
||||
{
|
||||
m_uri = x;
|
||||
}
|
||||
|
||||
void HTTPSocket::SendResponse(const std::string& status_num, const std::string& status_text) {
|
||||
SetStatus(status_num, status_text);
|
||||
SendResponse();
|
||||
}
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
*
|
||||
* This code originated from `C++ Sockets Library` referenced below.
|
||||
* Taken and stripped/modified to remove dependancies on parts of
|
||||
* the library which we are not using, and to suit other needs.
|
||||
* 2006 - EQEMu Development Team (http://eqemulator.net)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file HTTPSocket.h Class HTTPSocket definition.
|
||||
** \date 2004-04-06
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _HTTPSOCKET_H
|
||||
#define _HTTPSOCKET_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "../tcp_connection.h"
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
/** \defgroup http HTTP Sockets */
|
||||
/** HTTP request/response base class.
|
||||
\ingroup http */
|
||||
class HTTPSocket : public TCPConnection
|
||||
{
|
||||
/** map to hold http header values. */
|
||||
typedef std::map<std::string,std::string> string_m;
|
||||
public:
|
||||
HTTPSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort);
|
||||
virtual ~HTTPSocket();
|
||||
|
||||
void OnLine(const std::string& line);
|
||||
|
||||
/** Callback executes when first line has been received.
|
||||
GetMethod, GetUrl/GetUri, and GetHttpVersion are valid when this callback is executed. */
|
||||
virtual void OnFirst() = 0;
|
||||
/** For each header line this callback is executed.
|
||||
\param key Http header name
|
||||
\param value Http header value */
|
||||
virtual void OnHeader(const std::string& key,const std::string& value) = 0;
|
||||
/** Callback fires when all http headers have been received. */
|
||||
virtual void OnHeaderComplete() = 0;
|
||||
/** Chunk of http body data recevied. */
|
||||
virtual void OnData(const char *,size_t) = 0;
|
||||
|
||||
const std::string& GetMethod();
|
||||
void SetMethod(const std::string& x);
|
||||
const std::string& GetUrl();
|
||||
void SetUrl(const std::string& x);
|
||||
const std::string& GetUri();
|
||||
void SetUri(const std::string& x);
|
||||
const std::string& GetQueryString();
|
||||
const std::string& GetHttpVersion();
|
||||
const std::string& GetStatus();
|
||||
const std::string& GetStatusText();
|
||||
bool IsRequest();
|
||||
bool IsResponse();
|
||||
|
||||
void SetHttpVersion(const std::string& x);
|
||||
void SetStatus(const std::string& x);
|
||||
void SetStatus(const std::string& num, const std::string& text);
|
||||
void SetStatusText(const std::string& x);
|
||||
void AddResponseHeader(const std::string& x,const std::string& y);
|
||||
void AddResponseHeader(const std::string& x,const char *format, ...);
|
||||
void SendResponse();
|
||||
void SendResponse(const std::string& status_num, const std::string& status_text);
|
||||
void SendRequest();
|
||||
|
||||
/** Implement this to return your own User-agent string. */
|
||||
virtual std::string MyUseragent();
|
||||
|
||||
protected:
|
||||
/** Reset state of socket to sucessfully implement keep-alive. */
|
||||
virtual void Reset();
|
||||
|
||||
//stubs for crap which used to be in our parent class (TcpSocket)
|
||||
bool SendString(const char *str);
|
||||
bool SendBuf(const char *dat, unsigned int len);
|
||||
|
||||
virtual bool ProcessReceivedData(char* errbuf = 0);
|
||||
|
||||
private:
|
||||
// HTTPSocket& operator=(const HTTPSocket& ) { return *this; }
|
||||
bool m_first;
|
||||
bool m_header;
|
||||
std::string m_line;
|
||||
std::string m_method;
|
||||
std::string m_url;
|
||||
std::string m_uri;
|
||||
std::string m_query_string;
|
||||
std::string m_http_version;
|
||||
std::string m_status;
|
||||
std::string m_status_text;
|
||||
bool m_request;
|
||||
bool m_response;
|
||||
string_m m_response_header;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _HTTPSOCKET_H
|
||||
@@ -1,250 +0,0 @@
|
||||
/** \file HttpdCookies.cpp
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2003-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 "../global_define.h"
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include "Parse.h"
|
||||
#include "Utility.h"
|
||||
#include "HTTPSocket.h"
|
||||
#include "HttpdCookies.h"
|
||||
#include "../types.h"
|
||||
#include <time.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
HttpdCookies::HttpdCookies()
|
||||
{
|
||||
}
|
||||
|
||||
HttpdCookies::HttpdCookies(const std::string& s)
|
||||
{
|
||||
Parse *pa = new Parse(s,";");
|
||||
|
||||
std::string slask = pa -> getword();
|
||||
while (slask.size())
|
||||
{
|
||||
Parse *pa2 = new Parse(slask,"=");
|
||||
std::string name = pa2 -> getword();
|
||||
std::string value = pa2 -> getword();
|
||||
delete pa2;
|
||||
COOKIE *c = new COOKIE(name,value);
|
||||
m_cookies.push_back(c);
|
||||
//
|
||||
slask = pa -> getword();
|
||||
}
|
||||
delete pa;
|
||||
}
|
||||
|
||||
HttpdCookies::~HttpdCookies()
|
||||
{
|
||||
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
|
||||
{
|
||||
COOKIE *c = *it;
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
bool HttpdCookies::getvalue(const std::string& name,std::string& buffer) //char *buffer,size_t length)
|
||||
{
|
||||
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
|
||||
{
|
||||
COOKIE *c = *it;
|
||||
if (!strcasecmp(c -> name.c_str(),name.c_str()))
|
||||
{
|
||||
buffer = c -> value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
buffer = "";
|
||||
return false;
|
||||
}
|
||||
|
||||
void HttpdCookies::replacevalue(const std::string& name,const std::string& value)
|
||||
{
|
||||
COOKIE *c = nullptr;
|
||||
|
||||
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
|
||||
{
|
||||
c = *it;
|
||||
if (!strcasecmp(c -> name.c_str(),name.c_str()))
|
||||
break;
|
||||
c = nullptr;
|
||||
}
|
||||
|
||||
if (c)
|
||||
{
|
||||
c -> value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = new COOKIE(name,value);
|
||||
m_cookies.push_back(c);
|
||||
}
|
||||
}
|
||||
|
||||
void HttpdCookies::replacevalue(const std::string& name,long l)
|
||||
{
|
||||
replacevalue(name, Utility::l2string(l));
|
||||
}
|
||||
|
||||
void HttpdCookies::replacevalue(const std::string& name,int i)
|
||||
{
|
||||
replacevalue(name, Utility::l2string(i));
|
||||
}
|
||||
|
||||
size_t HttpdCookies::getlength(const std::string& name)
|
||||
{
|
||||
COOKIE *c = nullptr;
|
||||
|
||||
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
|
||||
{
|
||||
c = *it;
|
||||
if (!strcasecmp(c -> name.c_str(),name.c_str()))
|
||||
break;
|
||||
c = nullptr;
|
||||
}
|
||||
return c ? c -> value.size() : 0;
|
||||
}
|
||||
|
||||
void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, const std::string& value)
|
||||
{
|
||||
char *str = new char[name.size() + value.size() + domain.size() + path.size() + 100];
|
||||
|
||||
// set-cookie response
|
||||
if (domain.size())
|
||||
{
|
||||
sprintf(str, "%s=%s; domain=%s; path=%s; expires=%s",
|
||||
name.c_str(), value.c_str(),
|
||||
domain.c_str(),
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str, "%s=%s; path=%s; expires=%s",
|
||||
name.c_str(), value.c_str(),
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
sock -> AddResponseHeader("Set-cookie", str);
|
||||
delete[] str;
|
||||
|
||||
replacevalue(name, value);
|
||||
}
|
||||
|
||||
void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, long value)
|
||||
{
|
||||
char *str = new char[name.size() + domain.size() + path.size() + 100];
|
||||
char dt[80];
|
||||
|
||||
// set-cookie response
|
||||
if (domain.size())
|
||||
{
|
||||
sprintf(str, "%s=%ld; domain=%s; path=%s; expires=%s",
|
||||
name.c_str(), value,
|
||||
domain.c_str(),
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str, "%s=%ld; path=%s; expires=%s",
|
||||
name.c_str(), value,
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
sock -> AddResponseHeader("Set-cookie", str);
|
||||
delete[] str;
|
||||
|
||||
sprintf(dt, "%ld", value);
|
||||
replacevalue(name, dt);
|
||||
}
|
||||
|
||||
void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, int value)
|
||||
{
|
||||
char *str = new char[name.size() + domain.size() + path.size() + 100];
|
||||
char dt[80];
|
||||
|
||||
// set-cookie response
|
||||
if (domain.size())
|
||||
{
|
||||
sprintf(str, "%s=%d; domain=%s; path=%s; expires=%s",
|
||||
name.c_str(), value,
|
||||
domain.c_str(),
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str, "%s=%d; path=%s; expires=%s",
|
||||
name.c_str(), value,
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
sock -> AddResponseHeader("Set-cookie", str);
|
||||
delete[] str;
|
||||
|
||||
sprintf(dt, "%d", value);
|
||||
replacevalue(name, dt);
|
||||
}
|
||||
|
||||
|
||||
const std::string& HttpdCookies::expiredatetime()
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
struct tm * tp = gmtime(&t);
|
||||
const char *days[7] = {"Sunday", "Monday",
|
||||
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
|
||||
const char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May",
|
||||
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
char dt[100];
|
||||
|
||||
sprintf(dt, "%s, %02d-%s-%04d %02d:%02d:%02d GMT",
|
||||
days[tp -> tm_wday],
|
||||
tp -> tm_mday,
|
||||
months[tp -> tm_mon],
|
||||
tp -> tm_year + 1910,
|
||||
tp -> tm_hour,
|
||||
tp -> tm_min,
|
||||
tp -> tm_sec);
|
||||
m_date = dt;
|
||||
return m_date;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/** \file HttpdCookies.h
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2003-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _COOKIES_H
|
||||
#define _COOKIES_H
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
//! Store the cookies name/value pairs.
|
||||
|
||||
|
||||
|
||||
//! Retrieve and manage cookies during a cgi call.
|
||||
class HTTPSocket;
|
||||
|
||||
/** HTTP Cookie parse/container class.
|
||||
\sa HttpdSocket
|
||||
\sa HttpdForm
|
||||
\ingroup webserver */
|
||||
class HttpdCookies
|
||||
{
|
||||
/** Name/value pair store struct.
|
||||
\ingroup webserver */
|
||||
struct COOKIE
|
||||
{
|
||||
COOKIE(const std::string& n,const std::string& v) : name(n),value(v) {}
|
||||
std::string name;
|
||||
std::string value;
|
||||
};
|
||||
/** list of key/value structs. */
|
||||
typedef std::list<COOKIE *> cookie_v;
|
||||
public:
|
||||
HttpdCookies();
|
||||
HttpdCookies(const std::string& query_string);
|
||||
~HttpdCookies();
|
||||
|
||||
// int getvalue(const std::string& ,char *,size_t); // (name, buffer, length)
|
||||
bool getvalue(const std::string&,std::string&);
|
||||
void replacevalue(const std::string& ,const std::string& );
|
||||
void replacevalue(const std::string& ,long);
|
||||
void replacevalue(const std::string& ,int);
|
||||
size_t getlength(const std::string& );
|
||||
void setcookie(HTTPSocket *,const std::string& d,const std::string& p,const std::string& c,const std::string& v);
|
||||
void setcookie(HTTPSocket *,const std::string& d,const std::string& p,const std::string& c,long v);
|
||||
void setcookie(HTTPSocket *,const std::string& d,const std::string& p,const std::string& c,int v);
|
||||
const std::string& expiredatetime();
|
||||
|
||||
cookie_v& GetHttpdCookies() { return m_cookies; }
|
||||
|
||||
private:
|
||||
cookie_v m_cookies;
|
||||
std::string m_date;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _COOKIES_H
|
||||
@@ -1,621 +0,0 @@
|
||||
/** \file HttpdForm.cpp - read stdin, parse cgi input
|
||||
**
|
||||
** Written: 1999-Feb-10 grymse@alhem.net
|
||||
**/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "socket_include.h"
|
||||
#include "Parse.h"
|
||||
#include "IFile.h"
|
||||
#include "HttpdForm.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
HttpdForm::HttpdForm(IFile *infil) : raw(false)
|
||||
{
|
||||
CGI *cgi = nullptr;
|
||||
char *c_t = getenv("CONTENT_TYPE");
|
||||
char *c_l = getenv("CONTENT_LENGTH");
|
||||
size_t extra = 2;
|
||||
char name[200];
|
||||
|
||||
m_current = m_cgi.end();
|
||||
*name = 0;
|
||||
|
||||
if (c_t && !strncmp(c_t, "multipart/form-data",19))
|
||||
{
|
||||
Parse pa(c_t,";=");
|
||||
char *tempcmp = nullptr;
|
||||
size_t tc = 0;
|
||||
size_t l = 0;
|
||||
std::string str = pa.getword();
|
||||
m_strBoundary = "";
|
||||
while (str.size())
|
||||
{
|
||||
if (!strcmp(str.c_str(),"boundary"))
|
||||
{
|
||||
m_strBoundary = pa.getword();
|
||||
l = m_strBoundary.size();
|
||||
tempcmp = new char[l + extra];
|
||||
}
|
||||
//
|
||||
str = pa.getword();
|
||||
}
|
||||
if (m_strBoundary.size())
|
||||
{
|
||||
std::string content_type;
|
||||
std::string current_name;
|
||||
std::string current_filename;
|
||||
char slask[2000];
|
||||
infil -> fgets(slask, 200);
|
||||
while (!infil -> eof())
|
||||
{
|
||||
while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10))
|
||||
{
|
||||
slask[strlen(slask) - 1] = 0;
|
||||
}
|
||||
content_type = "";
|
||||
current_name = "";
|
||||
current_filename = "";
|
||||
if ((strstr(slask,m_strBoundary.c_str()) || strstr(m_strBoundary.c_str(),slask)) && strcmp(slask, m_strBoundary.c_str()))
|
||||
{
|
||||
m_strBoundary = slask;
|
||||
l = m_strBoundary.size();
|
||||
delete[] tempcmp;
|
||||
tempcmp = new char[l + extra];
|
||||
}
|
||||
if (!strcmp(slask, m_strBoundary.c_str()))
|
||||
{
|
||||
// Get headers until empty line
|
||||
infil -> fgets(slask, 200);
|
||||
while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10))
|
||||
{
|
||||
slask[strlen(slask) - 1] = 0;
|
||||
}
|
||||
while (!infil -> eof() && *slask)
|
||||
{
|
||||
Parse pa(slask,";");
|
||||
std::string h = pa.getword();
|
||||
if (!strcasecmp(h.c_str(),"Content-type:"))
|
||||
{
|
||||
content_type = pa.getword();
|
||||
}
|
||||
else
|
||||
if (!strcasecmp(h.c_str(),"Content-Disposition:"))
|
||||
{
|
||||
h = pa.getword();
|
||||
if (!strcmp(h.c_str(),"form-data"))
|
||||
{
|
||||
pa.EnableQuote(true);
|
||||
h = pa.getword();
|
||||
while (h.size())
|
||||
{
|
||||
Parse pa2(slask,"=");
|
||||
std::string name = pa2.getword();
|
||||
std::string h = pa2.getrest();
|
||||
if (!strcmp(name.c_str(),"name"))
|
||||
{
|
||||
if (h.size() && h[0] == '"')
|
||||
{
|
||||
current_name = h.substr(1, h.size() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
current_name = h;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!strcmp(name.c_str(),"filename"))
|
||||
{
|
||||
if (h.size() && h[0] == '"')
|
||||
{
|
||||
current_filename = h.substr(1, h.size() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
current_filename = h;
|
||||
}
|
||||
size_t x = 0;
|
||||
for (size_t i = 0; i < current_filename.size(); i++)
|
||||
{
|
||||
if (current_filename[i] == '/' || current_filename[i] == '\\')
|
||||
x = i + 1;
|
||||
}
|
||||
if (x)
|
||||
{
|
||||
current_filename = current_filename.substr(x);
|
||||
}
|
||||
}
|
||||
h = pa.getword();
|
||||
}
|
||||
}
|
||||
}
|
||||
// get next header value
|
||||
infil -> fgets(slask, 200);
|
||||
while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10))
|
||||
{
|
||||
slask[strlen(slask) - 1] = 0;
|
||||
}
|
||||
}
|
||||
// Read content, save...?
|
||||
if (!current_filename.size()) // not a file
|
||||
{
|
||||
std::string val;
|
||||
infil -> fgets(slask,1000);
|
||||
while (!infil -> eof() && strncmp(slask,m_strBoundary.c_str(),m_strBoundary.size() ))
|
||||
{
|
||||
val += slask;
|
||||
infil -> fgets(slask,1000);
|
||||
}
|
||||
// remove trailing cr/linefeed
|
||||
while (val.size() && (val[val.size() - 1] == 13 || val[val.size() - 1] == 10))
|
||||
{
|
||||
val = val.substr(0,val.size() - 1);
|
||||
}
|
||||
cgi = new CGI(current_name, val);
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
else // current_filename.size() > 0
|
||||
{
|
||||
// read until m_strBoundary...
|
||||
FILE *fil;
|
||||
int out = 0;
|
||||
char c;
|
||||
char fn[1000]; // where post'd file will be saved
|
||||
#ifdef _WIN32
|
||||
{
|
||||
char tmp_path[1000];
|
||||
::GetTempPath(1000, tmp_path);
|
||||
if (tmp_path[strlen(tmp_path) - 1] != '\\')
|
||||
{
|
||||
strcat(tmp_path, "\\");
|
||||
}
|
||||
sprintf(fn,"%s%s",tmp_path,current_filename.c_str());
|
||||
}
|
||||
#else
|
||||
sprintf(fn,"/tmp/%s",current_filename.c_str());
|
||||
#endif
|
||||
if ((fil = fopen(fn, "wb")) != nullptr)
|
||||
{
|
||||
infil -> fread(&c,1,1);
|
||||
while (!infil -> eof())
|
||||
{
|
||||
if (out)
|
||||
{
|
||||
fwrite(&tempcmp[tc],1,1,fil);
|
||||
}
|
||||
tempcmp[tc] = c;
|
||||
tc++;
|
||||
if (tc >= l + extra)
|
||||
{
|
||||
tc = 0;
|
||||
out = 1;
|
||||
}
|
||||
if (tc)
|
||||
{
|
||||
if (!strncmp(tempcmp + tc + extra, m_strBoundary.c_str(), l - tc) &&
|
||||
!strncmp(tempcmp, m_strBoundary.c_str() + l - tc, tc))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strncmp(tempcmp + extra, m_strBoundary.c_str(), l))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
infil -> fread(&c,1,1);
|
||||
}
|
||||
fclose(fil);
|
||||
|
||||
cgi = new CGI(current_name,fn,fn);
|
||||
m_cgi.push_back(cgi);
|
||||
|
||||
strcpy(slask, m_strBoundary.c_str());
|
||||
infil -> fgets(slask + strlen(slask), 200); // next line
|
||||
}
|
||||
else
|
||||
{
|
||||
// couldn't open file
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Probably '<m_strBoundary>--'
|
||||
break;
|
||||
}
|
||||
} // while (!infil -> eof())
|
||||
} // if (m_strBoundary)
|
||||
if (tempcmp)
|
||||
{
|
||||
delete[] tempcmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
int cl = c_l ? atoi(c_l) : -1;
|
||||
char c,chigh,clow;
|
||||
char *slask = new char[8888];
|
||||
bool got_name = false;
|
||||
m_current = m_cgi.end();
|
||||
|
||||
*name = 0;
|
||||
|
||||
infil -> fread(&c,1,1);
|
||||
cl--;
|
||||
while (cl >= 0)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '=': /* end of name */
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
strcpy(name,slask);
|
||||
got_name = true;
|
||||
break;
|
||||
case '&': /* end of value */
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
if(got_name) {
|
||||
got_name = false;
|
||||
cgi = new CGI(name,slask);
|
||||
m_cgi.push_back(cgi);
|
||||
} else {
|
||||
cgi = new CGI(slask,"");
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
break;
|
||||
case '+': /* space */
|
||||
slask[i++] = ' ';
|
||||
break;
|
||||
case '%': /* hex value */
|
||||
infil -> fread(&chigh,1,1);
|
||||
cl--;
|
||||
chigh -= 48;
|
||||
chigh &= 0xff - 32;
|
||||
if (chigh > 9)
|
||||
chigh -= 7;
|
||||
infil -> fread(&clow,1,1);
|
||||
cl--;
|
||||
clow -= 48;
|
||||
clow &= 0xff - 32;
|
||||
if (clow > 9)
|
||||
clow -= 7;
|
||||
slask[i++] = (char)(chigh * 16 + clow);
|
||||
break;
|
||||
default: /* just another char */
|
||||
slask[i++] = c;
|
||||
break;
|
||||
}
|
||||
if(infil -> eof())
|
||||
break;
|
||||
//
|
||||
if (cl > 0)
|
||||
{
|
||||
infil -> fread(&c,1,1);
|
||||
}
|
||||
cl--;
|
||||
}
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
if(got_name) {
|
||||
cgi = new CGI(name,slask);
|
||||
m_cgi.push_back(cgi);
|
||||
} else {
|
||||
cgi = new CGI(slask,"");
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
delete[] slask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// HttpdForm(buffer,l) -- request_method GET
|
||||
|
||||
HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false)
|
||||
{
|
||||
CGI *cgi = nullptr;
|
||||
char slask[8888];
|
||||
char name[200];
|
||||
int i = 0;
|
||||
char c,chigh,clow;
|
||||
bool got_name = false;
|
||||
size_t ptr = 0;
|
||||
|
||||
m_current = m_cgi.end();
|
||||
|
||||
*name = 0;
|
||||
|
||||
ptr = 0;
|
||||
while (ptr < l)
|
||||
{
|
||||
c = buffer[ptr++];
|
||||
switch (c)
|
||||
{
|
||||
case '=': /* end of name */
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
got_name = true;
|
||||
strcpy(name,slask);
|
||||
break;
|
||||
case '&': /* end of value */
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
if(got_name) {
|
||||
got_name = false;
|
||||
cgi = new CGI(name,slask);
|
||||
m_cgi.push_back(cgi);
|
||||
} else {
|
||||
cgi = new CGI(slask, "");
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
break;
|
||||
case '+': /* space */
|
||||
slask[i++] = ' ';
|
||||
break;
|
||||
case '%': /* hex value */
|
||||
chigh = buffer[ptr++];
|
||||
chigh -= 48;
|
||||
chigh &= 0xff - 32;
|
||||
if (chigh > 9)
|
||||
chigh -= 7;
|
||||
clow = buffer[ptr++];
|
||||
clow -= 48;
|
||||
clow &= 0xff - 32;
|
||||
if (clow > 9)
|
||||
clow -= 7;
|
||||
slask[i++] = (char)(chigh * 16 + clow);
|
||||
break;
|
||||
default: /* just another char */
|
||||
slask[i++] = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
if(got_name) {
|
||||
cgi = new CGI(name,slask);
|
||||
m_cgi.push_back(cgi);
|
||||
} else {
|
||||
cgi = new CGI(slask, "");
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HttpdForm::~HttpdForm()
|
||||
{
|
||||
CGI *cgi = nullptr; //,*tmp;
|
||||
|
||||
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
|
||||
{
|
||||
cgi = *it;
|
||||
delete cgi;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HttpdForm::EnableRaw(bool b)
|
||||
{
|
||||
raw = b;
|
||||
}
|
||||
|
||||
|
||||
void HttpdForm::strcpyval(std::string& v,const char *value) //,size_t len)
|
||||
{
|
||||
v = "";
|
||||
for (size_t i = 0; i < strlen(value); i++)
|
||||
{
|
||||
if (value[i] == '<')
|
||||
{
|
||||
v += "<";
|
||||
}
|
||||
else
|
||||
if (value[i] == '>')
|
||||
{
|
||||
v += ">";
|
||||
}
|
||||
else
|
||||
if (value[i] == '&')
|
||||
{
|
||||
v += "&";
|
||||
}
|
||||
else
|
||||
{
|
||||
v += value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool HttpdForm::getfirst(std::string& n) //char *n,size_t len)
|
||||
{
|
||||
m_current = m_cgi.begin();
|
||||
return getnext(n);
|
||||
}
|
||||
|
||||
|
||||
bool HttpdForm::getnext(std::string& n) //char *n,size_t len)
|
||||
{
|
||||
if (m_current != m_cgi.end() )
|
||||
{
|
||||
CGI *current = *m_current;
|
||||
n = current -> name;
|
||||
m_current++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = "";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool HttpdForm::getfirst(std::string& n,std::string& v) //char *n,size_t len,char *v,size_t vlen)
|
||||
{
|
||||
m_current = m_cgi.begin();
|
||||
return getnext(n,v);
|
||||
}
|
||||
|
||||
|
||||
bool HttpdForm::getnext(std::string& n,std::string& v) //char *n,size_t len,char *v,size_t vlen)
|
||||
{
|
||||
if (m_current != m_cgi.end() )
|
||||
{
|
||||
CGI *current = *m_current;
|
||||
n = current -> name;
|
||||
if (raw)
|
||||
{
|
||||
v = current -> value;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpyval(v,current -> value.c_str());
|
||||
}
|
||||
m_current++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = "";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int HttpdForm::getvalue(const std::string& n,std::string& v) //char *v,size_t len)
|
||||
{
|
||||
CGI *cgi = nullptr;
|
||||
int r = 0;
|
||||
|
||||
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
|
||||
{
|
||||
cgi = *it;
|
||||
if (cgi -> name == n)
|
||||
break;
|
||||
cgi = nullptr;
|
||||
}
|
||||
if (cgi)
|
||||
{
|
||||
if (raw)
|
||||
{
|
||||
v = cgi -> value;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpyval(v,cgi -> value.c_str());
|
||||
}
|
||||
r++;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = "";
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
std::string HttpdForm::getvalue(const std::string& n)
|
||||
{
|
||||
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
|
||||
{
|
||||
CGI *cgi = *it;
|
||||
if (cgi -> name == n)
|
||||
{
|
||||
return cgi -> value;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
size_t HttpdForm::getlength(const std::string& n)
|
||||
{
|
||||
CGI *cgi = nullptr;
|
||||
size_t l;
|
||||
|
||||
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
|
||||
{
|
||||
cgi = *it;
|
||||
if (cgi -> name == n)
|
||||
break;
|
||||
cgi = nullptr;
|
||||
}
|
||||
l = cgi ? cgi -> value.size() : 0;
|
||||
if (cgi && !raw)
|
||||
{
|
||||
for (size_t i = 0; i < cgi -> value.size(); i++)
|
||||
{
|
||||
switch (cgi -> value[i])
|
||||
{
|
||||
case '<': // <
|
||||
case '>': // >
|
||||
l += 4;
|
||||
break;
|
||||
case '&': // &
|
||||
l += 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
HttpdForm::cgi_v& HttpdForm::getbase()
|
||||
{
|
||||
return m_cgi;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HttpdForm::GetBoundary()
|
||||
{
|
||||
return m_strBoundary;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
/** \file HttpdForm.h - read stdin, parse cgi input
|
||||
**
|
||||
** Written: 1999-Feb-10 grymse@alhem.net
|
||||
**/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _FORM_H
|
||||
#define _FORM_H
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
class IFile;
|
||||
|
||||
/** Parse/store a http query_string/form-data body.
|
||||
\ingroup webserver */
|
||||
class HttpdForm
|
||||
{
|
||||
/**
|
||||
* Store the name/value pairs from a GET/POST operation.
|
||||
* "name" does not have to be unique.
|
||||
\ingroup webserver
|
||||
*/
|
||||
struct CGI
|
||||
{
|
||||
CGI(const std::string& n,const std::string& v) : name(n),value(v) {}
|
||||
CGI(const std::string& n,const std::string& v,const std::string& p) : name(n),value(v),path(p) {}
|
||||
std::string name;
|
||||
std::string value;
|
||||
std::string path;
|
||||
};
|
||||
/** list of key/value pairs. */
|
||||
typedef std::list<CGI *> cgi_v;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor (used in POST operations).
|
||||
* Input is read from stdin. Number of characters to read
|
||||
* can be found in the environment variable CONTENT_LENGTH.
|
||||
*/
|
||||
HttpdForm(IFile *);
|
||||
/**
|
||||
* Another constructor (used in GET operations).
|
||||
* Input is read from the environment variable QUERY_STRING.
|
||||
* @param query_string The httpd server provided QUERY_STRING
|
||||
* @param length Query string length.
|
||||
*/
|
||||
HttpdForm(const std::string& query_string,size_t length);
|
||||
~HttpdForm();
|
||||
|
||||
void EnableRaw(bool);
|
||||
|
||||
void strcpyval(std::string&,const char *); //,size_t);
|
||||
|
||||
/* get names */
|
||||
bool getfirst(std::string& n); //char *,size_t);
|
||||
bool getnext(std::string& n); //char *,size_t);
|
||||
|
||||
/* get names and values */
|
||||
bool getfirst(std::string& n,std::string& v); //char *,size_t,char *,size_t);
|
||||
bool getnext(std::string& n,std::string& v); //char *,size_t,char *,size_t);
|
||||
|
||||
/* get value */
|
||||
int getvalue(const std::string& ,std::string& ); //char *,size_t);
|
||||
std::string getvalue(const std::string& );
|
||||
size_t getlength(const std::string& );
|
||||
cgi_v& getbase();
|
||||
|
||||
const std::string& GetBoundary();
|
||||
|
||||
private:
|
||||
HttpdForm(const HttpdForm& ) {}
|
||||
HttpdForm& operator=(const HttpdForm& ) { return *this; }
|
||||
cgi_v m_cgi;
|
||||
cgi_v::iterator m_current;
|
||||
std::string m_strBoundary;
|
||||
bool raw;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _FORM_H
|
||||
@@ -1,352 +0,0 @@
|
||||
/** \file HttpdSocket.cpp
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2001-2004,2005 Anders Hedstrom (grymse@alhem.net)
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include "../global_define.h"
|
||||
#include "Utility.h"
|
||||
#include "HttpdCookies.h"
|
||||
#include "HttpdForm.h"
|
||||
#include "MemFile.h"
|
||||
#include "HttpdSocket.h"
|
||||
#include "../types.h"
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#define DEB(x)
|
||||
/*
|
||||
#define DEB(x) { \
|
||||
FILE *fil = fopen("httpdlog","at"); \
|
||||
if (!fil) \
|
||||
fil = fopen("httpdlog","wt"); \
|
||||
if (fil) { x; fclose(fil); } \
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// statics
|
||||
int HttpdSocket::m_request_count = 0;
|
||||
std::string HttpdSocket::m_start = "";
|
||||
|
||||
|
||||
HttpdSocket::HttpdSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
|
||||
: HTTPSocket(ID,in_socket,irIP,irPort)
|
||||
,m_content_length(0)
|
||||
,m_file(nullptr)
|
||||
,m_received(0)
|
||||
,m_request_id(++m_request_count)
|
||||
,m_cookies(nullptr)
|
||||
,m_form(nullptr)
|
||||
{
|
||||
m_http_date = datetime2httpdate(GetDate());
|
||||
if (!m_start.size())
|
||||
m_start = m_http_date;
|
||||
}
|
||||
|
||||
|
||||
HttpdSocket::~HttpdSocket()
|
||||
{
|
||||
if (m_file)
|
||||
{
|
||||
delete m_file;
|
||||
}
|
||||
if (m_cookies)
|
||||
delete m_cookies;
|
||||
if (m_form)
|
||||
delete m_form;
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::OnFirst()
|
||||
{
|
||||
// printf("Request: %s %s %s\n",GetMethod().c_str(),GetUrl().c_str(),GetHttpVersion().c_str());
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::OnHeader(const std::string& key,const std::string& value)
|
||||
{
|
||||
if (!strcasecmp(key.c_str(),"content-length"))
|
||||
{
|
||||
m_content_length = atoi(value.c_str());
|
||||
m_content_length_str = value;
|
||||
}
|
||||
else
|
||||
if (!strcasecmp(key.c_str(),"cookie"))
|
||||
{
|
||||
m_http_cookie = value;
|
||||
}
|
||||
else
|
||||
if (!strcasecmp(key.c_str(),"content-type"))
|
||||
{
|
||||
m_content_type = value;
|
||||
}
|
||||
else
|
||||
if (!strcasecmp(key.c_str(),"if-modified-since"))
|
||||
{
|
||||
m_if_modified_since = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::OnHeaderComplete()
|
||||
{
|
||||
m_cookies = new HttpdCookies(m_http_cookie);
|
||||
|
||||
#if (defined(SOLARIS8) || defined(SOLARIS))
|
||||
{
|
||||
char slask[1000];
|
||||
if (GetMethod() == "GET")
|
||||
{
|
||||
sprintf(slask,"QUERY_STRING=%s", GetQueryString().c_str());
|
||||
putenv(slask);
|
||||
}
|
||||
sprintf(slask,"REQUEST_METHOD=%s", GetMethod().c_str());
|
||||
putenv(slask);
|
||||
sprintf(slask,"HTTP_COOKIE=%s", m_http_cookie.c_str());
|
||||
putenv(slask);
|
||||
sprintf(slask,"CONTENT_TYPE=%s", m_content_type.c_str());
|
||||
putenv(slask);
|
||||
sprintf(slask,"CONTENT_LENGTH=%s", m_content_length_str.c_str());
|
||||
putenv(slask);
|
||||
}
|
||||
#elif defined _WIN32
|
||||
{
|
||||
char slask[1000];
|
||||
if (GetMethod() == "GET")
|
||||
{
|
||||
sprintf(slask,"QUERY_STRING=%s", GetQueryString().c_str());
|
||||
_putenv(slask);
|
||||
}
|
||||
sprintf(slask,"REQUEST_METHOD=%s", GetMethod().c_str());
|
||||
_putenv(slask);
|
||||
sprintf(slask,"HTTP_COOKIE=%s", m_http_cookie.c_str());
|
||||
_putenv(slask);
|
||||
sprintf(slask,"CONTENT_TYPE=%s", m_content_type.c_str());
|
||||
_putenv(slask);
|
||||
sprintf(slask,"CONTENT_LENGTH=%s", m_content_length_str.c_str());
|
||||
_putenv(slask);
|
||||
}
|
||||
#else
|
||||
if (GetMethod() == "GET")
|
||||
{
|
||||
setenv("QUERY_STRING", GetQueryString().c_str(), 1);
|
||||
}
|
||||
setenv("REQUEST_METHOD", GetMethod().c_str(), 1);
|
||||
setenv("HTTP_COOKIE", m_http_cookie.c_str(), 1);
|
||||
setenv("CONTENT_TYPE", m_content_type.c_str(), 1);
|
||||
setenv("CONTENT_LENGTH", m_content_length_str.c_str(), 1);
|
||||
#endif
|
||||
|
||||
if (GetMethod() == "POST")
|
||||
{
|
||||
m_file = new MemFile;
|
||||
}
|
||||
else
|
||||
if (GetMethod() == "GET")
|
||||
{
|
||||
m_form = new HttpdForm(GetQueryString(), GetQueryString().size() );
|
||||
AddResponseHeader("Date", datetime2httpdate(GetDate()) );
|
||||
Exec();
|
||||
Reset(); // prepare for next request
|
||||
}
|
||||
else
|
||||
{
|
||||
AddResponseHeader("Date", GetHttpDate());
|
||||
AddResponseHeader("Connection", "close");
|
||||
SetStatus("405");
|
||||
SetStatusText("Method not allowed");
|
||||
SendResponse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::OnData(const char *p,size_t l)
|
||||
{
|
||||
if (m_file)
|
||||
{
|
||||
m_file -> fwrite(p,1,l);
|
||||
}
|
||||
m_received += l;
|
||||
if (m_received >= m_content_length && m_content_length)
|
||||
{
|
||||
// all done
|
||||
if (m_file && !m_form)
|
||||
{
|
||||
m_form = new HttpdForm(m_file);
|
||||
AddResponseHeader("Date", datetime2httpdate(GetDate()) );
|
||||
Exec();
|
||||
Reset(); // prepare for next request
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::Send64(const std::string& str64, const std::string& type)
|
||||
{
|
||||
if (!strcasecmp(m_start.c_str(), m_if_modified_since.c_str()))
|
||||
{
|
||||
SetStatus("304");
|
||||
SetStatusText("Not Modified");
|
||||
SendResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t len = Base64::decode_length(str64);
|
||||
unsigned char *buf = new unsigned char[len];
|
||||
|
||||
SetStatus("200");
|
||||
SetStatusText("OK");
|
||||
|
||||
AddResponseHeader("Content-length", Utility::l2string( (long)len) );
|
||||
AddResponseHeader("Content-type", type );
|
||||
AddResponseHeader("Last-modified", m_start);
|
||||
SendResponse();
|
||||
|
||||
Base64::decode(str64, buf, len);
|
||||
SendBuf( (char *)buf, len);
|
||||
delete[] buf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string HttpdSocket::datetime2httpdate(const std::string& dt)
|
||||
{
|
||||
struct tm tp;
|
||||
time_t t;
|
||||
const char *days[] = { "Sun","Mon","Tue","Wed","Thu","Fri","Sat" };
|
||||
const char *months[] = { "Jan","Feb","Mar","Apr","May","Jun",
|
||||
"Jul","Aug","Sep","Oct","Nov","Dec" };
|
||||
int i;
|
||||
char s[40];
|
||||
|
||||
/* 1997-12-16 09:50:40 */
|
||||
|
||||
if (dt.size() == 19)
|
||||
{
|
||||
tp.tm_year = atoi(dt.substr(0,4).c_str()) - 1900;
|
||||
i = atoi(dt.substr(5,2).c_str()) - 1;
|
||||
tp.tm_mon = i >= 0 ? i : 0;
|
||||
tp.tm_mday = atoi(dt.substr(8,2).c_str());
|
||||
tp.tm_hour = atoi(dt.substr(11,2).c_str());
|
||||
tp.tm_min = atoi(dt.substr(14,2).c_str());
|
||||
tp.tm_sec = atoi(dt.substr(17,2).c_str());
|
||||
tp.tm_wday = 0;
|
||||
tp.tm_yday = 0;
|
||||
tp.tm_isdst = 0;
|
||||
t = mktime(&tp);
|
||||
/*if (t == -1)
|
||||
{
|
||||
Handler().LogError(this, "datetime2httpdate", 0, "mktime() failed");
|
||||
}*/
|
||||
|
||||
sprintf(s,"%s, %02d %s %d %02d:%02d:%02d GMT",
|
||||
days[tp.tm_wday],
|
||||
tp.tm_mday,
|
||||
months[tp.tm_mon],
|
||||
tp.tm_year + 1900,
|
||||
tp.tm_hour,tp.tm_min,tp.tm_sec);
|
||||
}
|
||||
else
|
||||
{
|
||||
*s = 0;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
std::string HttpdSocket::GetDate()
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
struct tm* tp = localtime(&t);
|
||||
char slask[40];
|
||||
if (tp)
|
||||
{
|
||||
sprintf(slask,"%d-%02d-%02d %02d:%02d:%02d",
|
||||
tp -> tm_year + 1900,
|
||||
tp -> tm_mon + 1,
|
||||
tp -> tm_mday,
|
||||
tp -> tm_hour,tp -> tm_min,tp -> tm_sec);
|
||||
}
|
||||
else
|
||||
{
|
||||
*slask = 0;
|
||||
}
|
||||
return slask;
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::Reset()
|
||||
{
|
||||
HTTPSocket::Reset();
|
||||
m_content_length = 0;
|
||||
if (m_file)
|
||||
{
|
||||
delete m_file;
|
||||
m_file = nullptr;
|
||||
}
|
||||
m_received = 0;
|
||||
m_request_id = ++m_request_count;
|
||||
if (m_cookies)
|
||||
delete m_cookies;
|
||||
m_cookies = nullptr;
|
||||
if (m_form)
|
||||
delete m_form;
|
||||
m_form = nullptr;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HttpdSocket::GetHttpDate()
|
||||
{
|
||||
return m_http_date;
|
||||
}
|
||||
|
||||
|
||||
HttpdCookies *HttpdSocket::GetCookies()
|
||||
{
|
||||
return m_cookies;
|
||||
}
|
||||
|
||||
|
||||
HttpdForm *HttpdSocket::GetHttpForm()
|
||||
{
|
||||
return m_form;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/** \file HttpdSocket.h
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2001-2004,2005 Anders Hedstrom (grymse@alhem.net)
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _HTTPDSOCKET_H
|
||||
#define _HTTPDSOCKET_H
|
||||
|
||||
#include "HTTPSocket.h"
|
||||
|
||||
class TCPConnection;
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
class HttpdCookies;
|
||||
class HttpdForm;
|
||||
class IFile;
|
||||
|
||||
/** \defgroup webserver Webserver framework */
|
||||
/** Web server socket framework.
|
||||
\ingroup webserver */
|
||||
class HttpdSocket : public HTTPSocket
|
||||
{
|
||||
public:
|
||||
HttpdSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort);
|
||||
~HttpdSocket();
|
||||
|
||||
void OnFirst();
|
||||
void OnHeader(const std::string& key,const std::string& value);
|
||||
void OnHeaderComplete();
|
||||
void OnData(const char *,size_t);
|
||||
|
||||
/** This method needs to be implemented with logic to produce
|
||||
a response to an incoming request. */
|
||||
virtual void Exec() = 0;
|
||||
/** Get current date in http rfc format. */
|
||||
const std::string& GetHttpDate();
|
||||
/** Get pointer to cookie class. */
|
||||
HttpdCookies *GetCookies();
|
||||
/** Get pointer to query string/form data class. */
|
||||
HttpdForm *GetHttpForm();
|
||||
|
||||
protected:
|
||||
/** Decode and send a base64-encoded string.
|
||||
\param str64 Base64-encoded string
|
||||
\param type Mime type of content (content-type header) */
|
||||
void Send64(const std::string& str64, const std::string& type);
|
||||
std::string datetime2httpdate(const std::string& dt);
|
||||
std::string GetDate();
|
||||
void Reset();
|
||||
// headers
|
||||
std::string m_http_cookie;
|
||||
std::string m_content_type;
|
||||
std::string m_content_length_str;
|
||||
std::string m_if_modified_since;
|
||||
|
||||
private:
|
||||
static int m_request_count;
|
||||
static std::string m_start;
|
||||
size_t m_content_length;
|
||||
IFile *m_file;
|
||||
size_t m_received;
|
||||
int m_request_id;
|
||||
std::string m_http_date;
|
||||
HttpdCookies *m_cookies;
|
||||
HttpdForm *m_form;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _HTTPDSOCKET_H
|
||||
@@ -1,65 +0,0 @@
|
||||
/** \file IFile.h
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _IFILE_H
|
||||
#define _IFILE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
/** \defgroup file File handling */
|
||||
/** Pure virtual file I/O interface.
|
||||
\ingroup file */
|
||||
class IFile
|
||||
{
|
||||
public:
|
||||
virtual ~IFile() {}
|
||||
|
||||
virtual bool fopen(const std::string&, const std::string&) = 0;
|
||||
virtual void fclose() = 0;
|
||||
|
||||
virtual size_t fread(char *, size_t, size_t) = 0;
|
||||
virtual size_t fwrite(const char *, size_t, size_t) = 0;
|
||||
|
||||
virtual char *fgets(char *, int) = 0;
|
||||
virtual void fprintf(char *format, ...) = 0;
|
||||
|
||||
virtual off_t size() = 0;
|
||||
virtual bool eof() = 0;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _IFILE_H
|
||||
@@ -1,212 +0,0 @@
|
||||
/** \file MemFile.cpp
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "MemFile.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEB(x) x
|
||||
#else
|
||||
#define DEB(x)
|
||||
#endif
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
std::map<std::string,MemFile::block_t *> MemFile::m_files;
|
||||
|
||||
|
||||
MemFile::MemFile()
|
||||
:m_temporary(true)
|
||||
,m_base(new block_t)
|
||||
,m_current_read(m_base)
|
||||
,m_current_write(m_base)
|
||||
,m_read_ptr(0)
|
||||
,m_write_ptr(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MemFile::MemFile(const std::string& path)
|
||||
:m_path(path)
|
||||
,m_temporary(false)
|
||||
,m_base(m_files[path])
|
||||
,m_current_read(nullptr)
|
||||
,m_current_write(nullptr)
|
||||
,m_read_ptr(0)
|
||||
,m_write_ptr(0)
|
||||
{
|
||||
if (!m_base)
|
||||
{
|
||||
m_base = new block_t;
|
||||
m_files[path] = m_base;
|
||||
}
|
||||
m_current_read = m_base;
|
||||
m_current_write = m_base;
|
||||
}
|
||||
|
||||
|
||||
MemFile::~MemFile()
|
||||
{
|
||||
while (m_base && m_temporary)
|
||||
{
|
||||
block_t *p = m_base;
|
||||
m_base = p -> next;
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MemFile::fopen(const std::string& path, const std::string& mode)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MemFile::fclose()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t MemFile::fread(char *ptr, size_t size, size_t nmemb)
|
||||
{
|
||||
size_t p = m_read_ptr % BLOCKSIZE;
|
||||
size_t sz = size * nmemb;
|
||||
if (p + sz < BLOCKSIZE)
|
||||
{
|
||||
memcpy(ptr, m_current_read -> data + p, sz);
|
||||
m_read_ptr += sz;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t sz1 = BLOCKSIZE - p;
|
||||
size_t sz2 = size - sz1;
|
||||
memcpy(ptr, m_current_read -> data + p, sz1);
|
||||
m_read_ptr += sz1;
|
||||
if (m_current_read -> next)
|
||||
{
|
||||
m_current_read = m_current_read -> next;
|
||||
memcpy(ptr + sz1, m_current_read -> data, sz2);
|
||||
m_read_ptr += sz2;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEB(printf("Read beyond available data\n");)
|
||||
return sz1;
|
||||
}
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
size_t MemFile::fwrite(const char *ptr, size_t size, size_t nmemb)
|
||||
{
|
||||
size_t p = m_write_ptr % BLOCKSIZE;
|
||||
size_t sz = size * nmemb;
|
||||
if (p + sz < BLOCKSIZE)
|
||||
{
|
||||
memcpy(m_current_write -> data + p, ptr, sz);
|
||||
m_write_ptr += sz;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t sz1 = BLOCKSIZE - p;
|
||||
size_t sz2 = size - sz1;
|
||||
memcpy(m_current_write -> data + p, ptr, sz1);
|
||||
block_t *next = new block_t;
|
||||
m_current_write -> next = next;
|
||||
m_current_write = next;
|
||||
memcpy(m_current_write -> data, ptr + sz1, sz2);
|
||||
m_write_ptr += sz;
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *MemFile::fgets(char *s, int size)
|
||||
{
|
||||
int n = 0;
|
||||
while (n < size - 1 && !eof())
|
||||
{
|
||||
char c;
|
||||
fread(&c, 1, 1);
|
||||
if (c == 10)
|
||||
{
|
||||
s[n] = 0;
|
||||
return s;
|
||||
}
|
||||
s[n++] = c;
|
||||
}
|
||||
s[n] = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void MemFile::fprintf(char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char tmp[BLOCKSIZE];
|
||||
va_start(ap, format);
|
||||
#ifdef _WIN32
|
||||
vsprintf(tmp, format, ap);
|
||||
#else
|
||||
vsnprintf(tmp, BLOCKSIZE - 1, format, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
fwrite(tmp, 1, strlen(tmp));
|
||||
}
|
||||
|
||||
|
||||
off_t MemFile::size()
|
||||
{
|
||||
return (off_t)m_write_ptr;
|
||||
}
|
||||
|
||||
|
||||
bool MemFile::eof()
|
||||
{
|
||||
return (m_read_ptr < m_write_ptr) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/** \file MemFile.h
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _MEMFILE_H
|
||||
#define _MEMFILE_H
|
||||
|
||||
#include <map>
|
||||
#include "IFile.h"
|
||||
|
||||
#define BLOCKSIZE 32768
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
/** Implements a memory file.
|
||||
\ingroup file */
|
||||
class MemFile : public IFile
|
||||
{
|
||||
public:
|
||||
/** File block structure.
|
||||
\ingroup file */
|
||||
struct block_t {
|
||||
block_t() : next(nullptr) {}
|
||||
struct block_t *next;
|
||||
char data[BLOCKSIZE];
|
||||
};
|
||||
public:
|
||||
MemFile();
|
||||
MemFile(const std::string& path);
|
||||
~MemFile();
|
||||
|
||||
bool fopen(const std::string& path, const std::string& mode);
|
||||
void fclose();
|
||||
|
||||
size_t fread(char *ptr, size_t size, size_t nmemb);
|
||||
size_t fwrite(const char *ptr, size_t size, size_t nmemb);
|
||||
|
||||
char *fgets(char *s, int size);
|
||||
void fprintf(char *format, ...);
|
||||
|
||||
off_t size();
|
||||
bool eof();
|
||||
|
||||
private:
|
||||
MemFile(const MemFile& ) {} // copy constructor
|
||||
MemFile& operator=(const MemFile& ) { return *this; } // assignment operator
|
||||
|
||||
static std::map<std::string,block_t *> m_files;
|
||||
std::string m_path;
|
||||
bool m_temporary;
|
||||
block_t *m_base;
|
||||
block_t *m_current_read;
|
||||
block_t *m_current_write;
|
||||
size_t m_read_ptr;
|
||||
size_t m_write_ptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _MEMFILE_H
|
||||
@@ -1,92 +0,0 @@
|
||||
/**
|
||||
** File ......... Mime.cpp
|
||||
** Published .... 2004-07-13
|
||||
** Author ....... grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004 Anders Hedstrom
|
||||
|
||||
This 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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 <stdio.h>
|
||||
|
||||
#include "Parse.h"
|
||||
#include "Mime.h"
|
||||
#include <cstring>
|
||||
|
||||
|
||||
|
||||
Mime::Mime() {
|
||||
}
|
||||
|
||||
Mime::Mime(const std::string& filename) {
|
||||
LoadMimeFile(filename);
|
||||
}
|
||||
|
||||
bool Mime::LoadMimeFile(const std::string& filename) {
|
||||
FILE *fil;
|
||||
if ((fil = fopen(filename.c_str(),"rt")) != nullptr) {
|
||||
char * slask = new char[1000];
|
||||
fgets(slask,1000,fil);
|
||||
while (!feof(fil))
|
||||
{
|
||||
while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10))
|
||||
{
|
||||
slask[strlen(slask) - 1] = 0;
|
||||
}
|
||||
Parse pa(slask);
|
||||
std::string mime_type = pa.getword();
|
||||
std::string ext = pa.getword();
|
||||
while (ext.size())
|
||||
{
|
||||
m_mime[ext] = mime_type;
|
||||
ext = pa.getword();
|
||||
}
|
||||
//
|
||||
fgets(slask,1000,fil);
|
||||
}
|
||||
delete[] slask;
|
||||
fclose(fil);
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
Mime::~Mime()
|
||||
{
|
||||
}
|
||||
|
||||
void Mime::Clear() {
|
||||
m_mime.clear();
|
||||
}
|
||||
|
||||
std::string Mime::GetMimeFromFilename(const std::string &filename) const {
|
||||
std::string::size_type pos = filename.find_last_of('.');
|
||||
if(pos == std::string::npos)
|
||||
return(std::string("text/plain"));
|
||||
return(GetMimeFromExtension(filename.substr(pos+1)));
|
||||
}
|
||||
|
||||
std::string Mime::GetMimeFromExtension(const std::string& ext) const {
|
||||
mime_m::const_iterator res;
|
||||
res = m_mime.find(ext);
|
||||
if(res == m_mime.end())
|
||||
return(std::string("text/plain"));
|
||||
|
||||
return res->second;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
** File ......... Mime.h
|
||||
** Published .... 2004-07-13
|
||||
** Author ....... grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004 Anders Hedstrom
|
||||
|
||||
This 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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _MIME_H
|
||||
#define _MIME_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
class Mime {
|
||||
typedef std::map<std::string,std::string> mime_m;
|
||||
public:
|
||||
Mime();
|
||||
Mime(const std::string& mime_file);
|
||||
~Mime();
|
||||
|
||||
void Clear();
|
||||
bool LoadMimeFile(const std::string& mime_file);
|
||||
|
||||
std::string GetMimeFromFilename(const std::string &filename) const;
|
||||
std::string GetMimeFromExtension(const std::string &ext) const;
|
||||
|
||||
private:
|
||||
mime_m m_mime;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _MIME_H
|
||||
@@ -1,327 +0,0 @@
|
||||
/** \file Parse.cpp - parse a string
|
||||
**
|
||||
** Written: 1999-Feb-10 grymse@alhem.net
|
||||
**/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Parse.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEB(x)
|
||||
#else
|
||||
#define DEB(x)
|
||||
#endif
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
/* implementation of class Parse */
|
||||
|
||||
Parse::Parse()
|
||||
:pa_the_str("")
|
||||
,pa_splits("")
|
||||
,pa_ord("")
|
||||
,pa_the_ptr(0)
|
||||
,pa_breakchar(0)
|
||||
,pa_enable(0)
|
||||
,pa_disable(0)
|
||||
,pa_nospace(0)
|
||||
,pa_quote(false)
|
||||
{
|
||||
}
|
||||
|
||||
Parse::Parse(const std::string&s)
|
||||
:pa_the_str(s)
|
||||
,pa_splits("")
|
||||
,pa_ord("")
|
||||
,pa_the_ptr(0)
|
||||
,pa_breakchar(0)
|
||||
,pa_enable(0)
|
||||
,pa_disable(0)
|
||||
,pa_nospace(0)
|
||||
,pa_quote(false)
|
||||
{
|
||||
}
|
||||
|
||||
Parse::Parse(const std::string&s,const std::string&sp)
|
||||
:pa_the_str(s)
|
||||
,pa_splits(sp)
|
||||
,pa_ord("")
|
||||
,pa_the_ptr(0)
|
||||
,pa_breakchar(0)
|
||||
,pa_enable(0)
|
||||
,pa_disable(0)
|
||||
,pa_nospace(0)
|
||||
,pa_quote(false)
|
||||
{
|
||||
}
|
||||
|
||||
Parse::Parse(const std::string&s,const std::string&sp,short nospace)
|
||||
:pa_the_str(s)
|
||||
,pa_splits(sp)
|
||||
,pa_ord("")
|
||||
,pa_the_ptr(0)
|
||||
,pa_breakchar(0)
|
||||
,pa_enable(0)
|
||||
,pa_disable(0)
|
||||
,pa_nospace(1)
|
||||
,pa_quote(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Parse::~Parse()
|
||||
{
|
||||
}
|
||||
|
||||
#define C ((pa_the_ptr<pa_the_str.size()) ? pa_the_str[pa_the_ptr] : 0)
|
||||
|
||||
short Parse::issplit(char c)
|
||||
{
|
||||
for (size_t i = 0; i < pa_splits.size(); i++)
|
||||
if (pa_splits[i] == c)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Parse::getsplit(void)
|
||||
{
|
||||
size_t x;
|
||||
|
||||
if (C == '=')
|
||||
{
|
||||
x = pa_the_ptr++;
|
||||
} else
|
||||
{
|
||||
while (C && (issplit(C)))
|
||||
pa_the_ptr++;
|
||||
x = pa_the_ptr;
|
||||
while (C && !issplit(C) && C != '=')
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (x == pa_the_ptr && C == '=')
|
||||
pa_the_ptr++;
|
||||
pa_ord = (x < pa_the_str.size()) ? pa_the_str.substr(x,pa_the_ptr - x) : "";
|
||||
}
|
||||
|
||||
std::string Parse::getword(void)
|
||||
{
|
||||
size_t x;
|
||||
int disabled = 0;
|
||||
int quote = 0;
|
||||
int rem = 0;
|
||||
|
||||
if (pa_nospace)
|
||||
{
|
||||
while (C && issplit(C))
|
||||
pa_the_ptr++;
|
||||
x = pa_the_ptr;
|
||||
while (C && !issplit(C) && (C != pa_breakchar || !pa_breakchar || disabled))
|
||||
{
|
||||
if (pa_breakchar && C == pa_disable)
|
||||
disabled = 1;
|
||||
if (pa_breakchar && C == pa_enable)
|
||||
disabled = 0;
|
||||
if (pa_quote && C == '"')
|
||||
quote = 1;
|
||||
pa_the_ptr++;
|
||||
while (quote && C && C != '"')
|
||||
{
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (pa_quote && C == '"')
|
||||
{
|
||||
pa_the_ptr++;
|
||||
}
|
||||
quote = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (C == pa_breakchar && pa_breakchar)
|
||||
{
|
||||
x = pa_the_ptr++;
|
||||
rem = 1;
|
||||
} else
|
||||
{
|
||||
while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
x = pa_the_ptr;
|
||||
while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) &&
|
||||
(C != pa_breakchar || !pa_breakchar || disabled))
|
||||
{
|
||||
if (pa_breakchar && C == pa_disable)
|
||||
disabled = 1;
|
||||
if (pa_breakchar && C == pa_enable)
|
||||
disabled = 0;
|
||||
if (pa_quote && C == '"')
|
||||
{
|
||||
quote = 1;
|
||||
pa_the_ptr++;
|
||||
while (quote && C && C != '"')
|
||||
{
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (pa_quote && C == '"')
|
||||
{
|
||||
pa_the_ptr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
pa_the_ptr++;
|
||||
quote = 0;
|
||||
}
|
||||
pa_the_ptr++;
|
||||
rem = 1;
|
||||
}
|
||||
if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar)
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (x < pa_the_str.size())
|
||||
{
|
||||
pa_ord = pa_the_str.substr(x,pa_the_ptr - x - rem);
|
||||
}
|
||||
else
|
||||
{
|
||||
pa_ord = "";
|
||||
}
|
||||
return pa_ord;
|
||||
}
|
||||
|
||||
void Parse::getword(std::string&s)
|
||||
{
|
||||
s = Parse::getword();
|
||||
}
|
||||
|
||||
void Parse::getsplit(std::string&s)
|
||||
{
|
||||
Parse::getsplit();
|
||||
s = pa_ord;
|
||||
}
|
||||
|
||||
void Parse::getword(std::string&s,std::string&fill,int l)
|
||||
{
|
||||
Parse::getword();
|
||||
s = "";
|
||||
while (s.size() + pa_ord.size() < (size_t)l)
|
||||
s += fill;
|
||||
s += pa_ord;
|
||||
}
|
||||
|
||||
std::string Parse::getrest()
|
||||
{
|
||||
std::string s;
|
||||
while (C && (C == ' ' || C == 9 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
s = (pa_the_ptr < pa_the_str.size()) ? pa_the_str.substr(pa_the_ptr) : "";
|
||||
return s;
|
||||
}
|
||||
|
||||
void Parse::getrest(std::string&s)
|
||||
{
|
||||
while (C && (C == ' ' || C == 9 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
s = (pa_the_ptr < pa_the_str.size()) ? pa_the_str.substr(pa_the_ptr) : "";
|
||||
}
|
||||
|
||||
long Parse::getvalue(void)
|
||||
{
|
||||
Parse::getword();
|
||||
return atol(pa_ord.c_str());
|
||||
}
|
||||
|
||||
void Parse::setbreak(char c)
|
||||
{
|
||||
pa_breakchar = c;
|
||||
}
|
||||
|
||||
int Parse::getwordlen(void)
|
||||
{
|
||||
size_t x,y = pa_the_ptr,len;
|
||||
|
||||
if (C == pa_breakchar && pa_breakchar)
|
||||
{
|
||||
x = pa_the_ptr++;
|
||||
} else
|
||||
{
|
||||
while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
x = pa_the_ptr;
|
||||
while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) && (C != pa_breakchar || !pa_breakchar))
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar)
|
||||
pa_the_ptr++;
|
||||
len = pa_the_ptr - x;
|
||||
pa_the_ptr = y;
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
int Parse::getrestlen(void)
|
||||
{
|
||||
size_t y = pa_the_ptr;
|
||||
size_t len;
|
||||
|
||||
while (C && (C == ' ' || C == 9 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
len = strlen(pa_the_str.c_str() + pa_the_ptr);
|
||||
pa_the_ptr = y;
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
void Parse::getline(void)
|
||||
{
|
||||
size_t x;
|
||||
|
||||
x = pa_the_ptr;
|
||||
while (C && C != 13 && C != 10)
|
||||
pa_the_ptr++;
|
||||
pa_ord = (x < pa_the_str.size()) ? pa_the_str.substr(x,pa_the_ptr - x) : "";
|
||||
if (C == 13)
|
||||
pa_the_ptr++;
|
||||
if (C == 10)
|
||||
pa_the_ptr++;
|
||||
}
|
||||
|
||||
void Parse::getline(std::string&s)
|
||||
{
|
||||
getline();
|
||||
s = pa_ord;
|
||||
}
|
||||
|
||||
/* end of implementation of class Parse */
|
||||
/***************************************************/
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/** \file Parse.h - parse a string
|
||||
**
|
||||
** Written: 1999-Feb-10 grymse@alhem.net
|
||||
**/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _PARSE_H
|
||||
#define _PARSE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************/
|
||||
/* interface of class Parse */
|
||||
|
||||
/** Splits a string whatever way you want.
|
||||
\ingroup util */
|
||||
class Parse
|
||||
{
|
||||
public:
|
||||
Parse();
|
||||
Parse(const std::string&);
|
||||
Parse(const std::string&,const std::string&);
|
||||
Parse(const std::string&,const std::string&,short);
|
||||
~Parse();
|
||||
short issplit(char);
|
||||
void getsplit(void);
|
||||
void getsplit(std::string&);
|
||||
std::string getword(void);
|
||||
void getword(std::string&);
|
||||
void getword(std::string&,std::string&,int);
|
||||
std::string getrest();
|
||||
void getrest(std::string&);
|
||||
long getvalue(void);
|
||||
void setbreak(char);
|
||||
int getwordlen(void);
|
||||
int getrestlen(void);
|
||||
void enablebreak(char c) {
|
||||
pa_enable = c;
|
||||
}
|
||||
void disablebreak(char c) {
|
||||
pa_disable = c;
|
||||
}
|
||||
void getline(void);
|
||||
void getline(std::string&);
|
||||
size_t getptr(void) { return pa_the_ptr; }
|
||||
void EnableQuote(bool b) { pa_quote = b; }
|
||||
|
||||
private:
|
||||
std::string pa_the_str;
|
||||
std::string pa_splits;
|
||||
std::string pa_ord;
|
||||
size_t pa_the_ptr;
|
||||
char pa_breakchar;
|
||||
char pa_enable;
|
||||
char pa_disable;
|
||||
short pa_nospace;
|
||||
bool pa_quote;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _PARSE_H
|
||||
@@ -1,5 +0,0 @@
|
||||
EQEmu took this code from `C++ Sockets Library`
|
||||
http://www.alhem.net/Sockets/
|
||||
and integrated it into our world server. We did not care for the actual
|
||||
socket code (didnt work on windows) so we scrapped all of it, and just
|
||||
used the HTTP framework code.
|
||||
@@ -1,5 +0,0 @@
|
||||
Find uuid.h here
|
||||
http://www.die.net/doc/linux/include/uuid/uuid.h
|
||||
or here
|
||||
http://www.thedna.net/uuid.h
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
/** \file Utility.cpp
|
||||
** \date 2004-02-13
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 "Utility.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
std::string Utility::base64(const std::string& str_in)
|
||||
{
|
||||
std::string str;
|
||||
Base64::encode(str_in, str, false); // , false == do not add cr/lf
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string Utility::base64d(const std::string& str_in)
|
||||
{
|
||||
std::string str;
|
||||
Base64::decode(str_in, str);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string Utility::l2string(long l)
|
||||
{
|
||||
std::string str;
|
||||
char tmp[100];
|
||||
sprintf(tmp,"%ld",l);
|
||||
str = tmp;
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string Utility::bigint2string(uint64_t l)
|
||||
{
|
||||
std::string str;
|
||||
uint64_t tmp = l;
|
||||
while (tmp)
|
||||
{
|
||||
uint64_t a = tmp % 10;
|
||||
str = (char)(a + 48) + str;
|
||||
tmp /= 10;
|
||||
}
|
||||
if (!str.size())
|
||||
{
|
||||
str = "0";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
uint64_t Utility::atoi64(const std::string& str)
|
||||
{
|
||||
uint64_t l = 0;
|
||||
for (size_t i = 0; i < str.size(); i++)
|
||||
{
|
||||
l = l * 10 + str[i] - 48;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
unsigned int Utility::hex2unsigned(const std::string& str)
|
||||
{
|
||||
unsigned int r = 0;
|
||||
for (size_t i = 0; i < str.size(); i++)
|
||||
{
|
||||
r = r * 16 + str[i] - 48 - ((str[i] >= 'A') ? 7 : 0) - ((str[i] >= 'a') ? 32 : 0);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Encode string per RFC1738 URL encoding rules
|
||||
* tnx rstaveley
|
||||
*/
|
||||
std::string Utility::rfc1738_encode(const std::string& src)
|
||||
{
|
||||
static char hex[] = "0123456789ABCDEF";
|
||||
std::string dst;
|
||||
for (size_t i = 0; i < src.size(); i++)
|
||||
{
|
||||
if (isalnum(src[i]))
|
||||
{
|
||||
dst += src[i];
|
||||
}
|
||||
else
|
||||
if (src[i] == ' ')
|
||||
{
|
||||
dst += '+';
|
||||
}
|
||||
else
|
||||
{
|
||||
dst += '%';
|
||||
dst += hex[src[i] / 16];
|
||||
dst += hex[src[i] % 16];
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
} // rfc1738_encode
|
||||
|
||||
|
||||
/*
|
||||
* Decode string per RFC1738 URL encoding rules
|
||||
* tnx rstaveley
|
||||
*/
|
||||
std::string Utility::rfc1738_decode(const std::string& src)
|
||||
{
|
||||
std::string dst;
|
||||
for (size_t i = 0; i < src.size(); i++)
|
||||
{
|
||||
if (src[i] == '%' && isxdigit(src[i + 1]) && isxdigit(src[i + 2]))
|
||||
{
|
||||
char c1 = src[++i];
|
||||
char c2 = src[++i];
|
||||
c1 = c1 - 48 - ((c1 >= 'A') ? 7 : 0) - ((c1 >= 'a') ? 32 : 0);
|
||||
c2 = c2 - 48 - ((c2 >= 'A') ? 7 : 0) - ((c2 >= 'a') ? 32 : 0);
|
||||
dst += (char)(c1 * 16 + c2);
|
||||
}
|
||||
else
|
||||
if (src[i] == '+')
|
||||
{
|
||||
dst += ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
dst += src[i];
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
} // rfc1738_decode
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/** \file Utility.h
|
||||
** \date 2004-02-13
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _UTILITY_H
|
||||
#define _UTILITY_H
|
||||
|
||||
#include <ctype.h>
|
||||
#ifdef _WIN32
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#ifdef SOLARIS
|
||||
# include <sys/types.h>
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "Base64.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
/** Conversion utilities.
|
||||
\ingroup util */
|
||||
class Utility
|
||||
{
|
||||
public:
|
||||
static std::string base64(const std::string& str_in);
|
||||
static std::string base64d(const std::string& str_in);
|
||||
static std::string l2string(long l);
|
||||
static std::string bigint2string(uint64_t l);
|
||||
static uint64_t atoi64(const std::string& str);
|
||||
static unsigned int hex2unsigned(const std::string& str);
|
||||
static std::string rfc1738_encode(const std::string& src);
|
||||
static std::string rfc1738_decode(const std::string& src);
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _UTILITY_H
|
||||
@@ -1,340 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This 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; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 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
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
@@ -1,87 +0,0 @@
|
||||
/** \file socket_include.cpp
|
||||
** \date 2004-11-28
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 <stdio.h>
|
||||
|
||||
// only to be included in win32 projects
|
||||
const char *StrError(int x)
|
||||
{
|
||||
static char tmp[100];
|
||||
switch (x)
|
||||
{
|
||||
case 10004: return "Interrupted function call.";
|
||||
case 10013: return "Permission denied.";
|
||||
case 10014: return "Bad address.";
|
||||
case 10022: return "Invalid argument.";
|
||||
case 10024: return "Too many open files.";
|
||||
case 10035: return "Resource temporarily unavailable.";
|
||||
case 10036: return "Operation now in progress.";
|
||||
case 10037: return "Operation already in progress.";
|
||||
case 10038: return "Socket operation on nonsocket.";
|
||||
case 10039: return "Destination address required.";
|
||||
case 10040: return "Message too long.";
|
||||
case 10041: return "Protocol wrong type for socket.";
|
||||
case 10042: return "Bad protocol option.";
|
||||
case 10043: return "Protocol not supported.";
|
||||
case 10044: return "Socket type not supported.";
|
||||
case 10045: return "Operation not supported.";
|
||||
case 10046: return "Protocol family not supported.";
|
||||
case 10047: return "Address family not supported by protocol family.";
|
||||
case 10048: return "Address already in use.";
|
||||
case 10049: return "Cannot assign requested address.";
|
||||
case 10050: return "Network is down.";
|
||||
case 10051: return "Network is unreachable.";
|
||||
case 10052: return "Network dropped connection on reset.";
|
||||
case 10053: return "Software caused connection abort.";
|
||||
case 10054: return "Connection reset by peer.";
|
||||
case 10055: return "No buffer space available.";
|
||||
case 10056: return "Socket is already connected.";
|
||||
case 10057: return "Socket is not connected.";
|
||||
case 10058: return "Cannot send after socket shutdown.";
|
||||
case 10060: return "Connection timed out.";
|
||||
case 10061: return "Connection refused.";
|
||||
case 10064: return "Host is down.";
|
||||
case 10065: return "No route to host.";
|
||||
case 10067: return "Too many processes.";
|
||||
case 10091: return "Network subsystem is unavailable.";
|
||||
case 10092: return "Winsock.dll version out of range.";
|
||||
case 10093: return "Successful WSAStartup not yet performed.";
|
||||
case 10101: return "Graceful shutdown in progress.";
|
||||
case 10109: return "Class type not found.";
|
||||
case 11001: return "Host not found.";
|
||||
case 11002: return "Nonauthoritative host not found.";
|
||||
case 11003: return "This is a nonrecoverable error.";
|
||||
case 11004: return "Valid name, no data record of requested type.";
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sprintf(tmp, "Winsock error code: %d", x);
|
||||
return tmp;
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
/** \file socket_include.h
|
||||
** \date 2005-04-12
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.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; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 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 _SOCKET_INCLUDE_H
|
||||
#define _SOCKET_INCLUDE_H
|
||||
|
||||
#if (defined(__unix__) || defined(unix)) && !defined(USG)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
// ----------------------------------------
|
||||
// common unix includes / defines
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
#define Errno errno
|
||||
#define StrError strerror
|
||||
|
||||
// WIN32 adapt
|
||||
#define closesocket close
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKET_ERROR -1
|
||||
typedef int SOCKET;
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE ((unsigned long) -1)
|
||||
#endif // INADDR_NONE
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // !_WIN32
|
||||
|
||||
|
||||
// ----------------------------------------
|
||||
// Generic
|
||||
#ifndef SOL_IP
|
||||
#define SOL_IP IPPROTO_IP
|
||||
#endif
|
||||
|
||||
|
||||
// ----------------------------------------
|
||||
// OS specific adaptions
|
||||
|
||||
#ifdef SOLARIS
|
||||
// ----------------------------------------
|
||||
// Solaris
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef unsigned short port_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#define s6_addr16 _S6_un._S6_u8
|
||||
#define MSG_NOSIGNAL 0
|
||||
|
||||
#elif defined __FreeBSD__
|
||||
// ----------------------------------------
|
||||
// FreeBSD
|
||||
# if __FreeBSD_version >= 400014
|
||||
# define s6_addr16 __u6_addr.__u6_addr16
|
||||
# if !defined(MSG_NOSIGNAL)
|
||||
# define MSG_NOSIGNAL 0
|
||||
# endif
|
||||
# include <netinet/in.h>
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef in_addr_t ipaddr_t;
|
||||
typedef in_port_t port_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
|
||||
# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
|
||||
# else
|
||||
# error FreeBSD versions prior to 400014 does not support ipv6
|
||||
# endif
|
||||
|
||||
#elif defined MACOSX
|
||||
// ----------------------------------------
|
||||
// Mac OS X
|
||||
#include <string.h>
|
||||
#include <mach/port.h>
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef unsigned long ipaddr_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#define s6_addr16 __u6_addr.__u6_addr16
|
||||
#define MSG_NOSIGNAL 0 // oops - thanks Derek
|
||||
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
|
||||
#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
|
||||
|
||||
#elif defined _WIN32
|
||||
// ----------------------------------------
|
||||
// Win32
|
||||
#pragma comment(lib, "wsock32.lib")
|
||||
#define strcasecmp _stricmp
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef unsigned long ipaddr_t;
|
||||
typedef unsigned short port_t;
|
||||
typedef int socklen_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MSG_NOSIGNAL 0
|
||||
#define SHUT_RDWR 2
|
||||
|
||||
// 1.8.6: define FD_SETSIZE to something bigger than 64 if there are a lot of
|
||||
// simultaneous connections (must be done before including winsock.h)
|
||||
//#define FD_SETSIZE 1024
|
||||
#include <winsock.h>
|
||||
|
||||
#define Errno WSAGetLastError()
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
const char *StrError(int x);
|
||||
|
||||
// class WSAInitializer is a part of the Socket class (on win32)
|
||||
// as a static instance - so whenever an application uses a Socket,
|
||||
// winsock is initialized
|
||||
class WSAInitializer // Winsock Initializer
|
||||
{
|
||||
public:
|
||||
WSAInitializer() {
|
||||
if (WSAStartup(0x101,&m_wsadata))
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
~WSAInitializer() {
|
||||
WSACleanup();
|
||||
}
|
||||
private:
|
||||
WSADATA m_wsadata;
|
||||
};
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
// ----------------------------------------
|
||||
// LINUX
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef unsigned long ipaddr_t;
|
||||
typedef unsigned short port_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _THREADSAFE_SOCKETS
|
||||
#include "mutex.h"
|
||||
#include "Lock.h"
|
||||
#endif
|
||||
|
||||
#endif // _SOCKET_INCLUDE_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,192 +0,0 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* StackWalker.h
|
||||
*
|
||||
*
|
||||
* History:
|
||||
* 2005-07-27 v1 - First public release on http://www.codeproject.com/
|
||||
* (for additional changes see History in 'StackWalker.cpp'!
|
||||
* 2013-01-26 - Modified by KimLS(KLS) for EQEmu's purposes
|
||||
*
|
||||
**********************************************************************/
|
||||
#ifdef _WINDOWS
|
||||
// #pragma once is supported starting with _MCS_VER 1000,
|
||||
// so we need not to check the version (because we only support _MSC_VER >= 1100)!
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// special defines for VC5/6 (if no actual PSDK is installed):
|
||||
#if _MSC_VER < 1300
|
||||
typedef unsigned __int64 DWORD64, *PDWORD64;
|
||||
#if defined(_WIN64)
|
||||
typedef unsigned __int64 SIZE_T, *PSIZE_T;
|
||||
#else
|
||||
typedef unsigned long SIZE_T, *PSIZE_T;
|
||||
#endif
|
||||
#endif // _MSC_VER < 1300
|
||||
|
||||
class StackWalkerInternal; // forward
|
||||
class StackWalker
|
||||
{
|
||||
public:
|
||||
typedef enum StackWalkOptions
|
||||
{
|
||||
// No addition info will be retrived
|
||||
// (only the address is available)
|
||||
RetrieveNone = 0,
|
||||
|
||||
// Try to get the symbol-name
|
||||
RetrieveSymbol = 1,
|
||||
|
||||
// Try to get the line for this symbol
|
||||
RetrieveLine = 2,
|
||||
|
||||
// Try to retrieve the module-infos
|
||||
RetrieveModuleInfo = 4,
|
||||
|
||||
// Also retrieve the version for the DLL/EXE
|
||||
RetrieveFileVersion = 8,
|
||||
|
||||
// Contains all the abouve
|
||||
RetrieveVerbose = 0xF,
|
||||
|
||||
// Generate a "good" symbol-search-path
|
||||
SymBuildPath = 0x10,
|
||||
|
||||
// Also use the public Microsoft-Symbol-Server
|
||||
SymUseSymSrv = 0x20,
|
||||
|
||||
// Contains all the abouve "Sym"-options
|
||||
SymAll = 0x30,
|
||||
|
||||
// Contains all options (default)
|
||||
OptionsAll = 0x3F
|
||||
} StackWalkOptions;
|
||||
|
||||
StackWalker(
|
||||
int options = OptionsAll, // 'int' is by design, to combine the enum-flags
|
||||
LPCSTR szSymPath = nullptr,
|
||||
DWORD dwProcessId = GetCurrentProcessId(),
|
||||
HANDLE hProcess = GetCurrentProcess()
|
||||
);
|
||||
StackWalker(DWORD dwProcessId, HANDLE hProcess);
|
||||
virtual ~StackWalker();
|
||||
|
||||
typedef BOOL (__stdcall *PReadProcessMemoryRoutine)(
|
||||
HANDLE hProcess,
|
||||
DWORD64 qwBaseAddress,
|
||||
PVOID lpBuffer,
|
||||
DWORD nSize,
|
||||
LPDWORD lpNumberOfBytesRead,
|
||||
LPVOID pUserData // optional data, which was passed in "ShowCallstack"
|
||||
);
|
||||
|
||||
BOOL LoadModules();
|
||||
|
||||
BOOL ShowCallstack(
|
||||
HANDLE hThread = GetCurrentThread(),
|
||||
const CONTEXT *context = nullptr,
|
||||
PReadProcessMemoryRoutine readMemoryFunction = nullptr,
|
||||
LPVOID pUserData = nullptr // optional to identify some data in the 'readMemoryFunction'-callback
|
||||
);
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
// due to some reasons, the "STACKWALK_MAX_NAMELEN" must be declared as "public"
|
||||
// in older compilers in order to use it... starting with VC7 we can declare it as "protected"
|
||||
protected:
|
||||
#endif
|
||||
enum { STACKWALK_MAX_NAMELEN = 1024 }; // max name length for found symbols
|
||||
|
||||
protected:
|
||||
// Entry for each Callstack-Entry
|
||||
typedef struct CallstackEntry
|
||||
{
|
||||
DWORD64 offset; // if 0, we have no valid entry
|
||||
CHAR name[STACKWALK_MAX_NAMELEN];
|
||||
CHAR undName[STACKWALK_MAX_NAMELEN];
|
||||
CHAR undFullName[STACKWALK_MAX_NAMELEN];
|
||||
DWORD64 offsetFromSmybol;
|
||||
DWORD offsetFromLine;
|
||||
DWORD lineNumber;
|
||||
CHAR lineFileName[STACKWALK_MAX_NAMELEN];
|
||||
DWORD symType;
|
||||
LPCSTR symTypeString;
|
||||
CHAR moduleName[STACKWALK_MAX_NAMELEN];
|
||||
DWORD64 baseOfImage;
|
||||
CHAR loadedImageName[STACKWALK_MAX_NAMELEN];
|
||||
} CallstackEntry;
|
||||
|
||||
typedef enum CallstackEntryType {firstEntry, nextEntry, lastEntry};
|
||||
|
||||
virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName);
|
||||
virtual void OnLoadModule(LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size, DWORD result, LPCSTR symType, LPCSTR pdbName, ULONGLONG fileVersion);
|
||||
virtual void OnCallstackEntry(CallstackEntryType eType, CallstackEntry &entry);
|
||||
virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr);
|
||||
virtual void OnOutput(LPCSTR szText);
|
||||
|
||||
StackWalkerInternal *m_sw;
|
||||
HANDLE m_hProcess;
|
||||
DWORD m_dwProcessId;
|
||||
BOOL m_modulesLoaded;
|
||||
LPSTR m_szSymPath;
|
||||
|
||||
int m_options;
|
||||
|
||||
static BOOL __stdcall myReadProcMem(HANDLE hProcess, DWORD64 qwBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead);
|
||||
|
||||
friend StackWalkerInternal;
|
||||
};
|
||||
|
||||
|
||||
// The "ugly" assembler-implementation is needed for systems before XP
|
||||
// If you have a new PSDK and you only compile for XP and later, then you can use
|
||||
// the "RtlCaptureContext"
|
||||
// Currently there is no define which determines the PSDK-Version...
|
||||
// So we just use the compiler-version (and assumes that the PSDK is
|
||||
// the one which was installed by the VS-IDE)
|
||||
|
||||
// INFO: If you want, you can use the RtlCaptureContext if you only target XP and later...
|
||||
// But I currently use it in x64/IA64 environments...
|
||||
//#if defined(_M_IX86) && (_WIN32_WINNT <= 0x0500) && (_MSC_VER < 1400)
|
||||
|
||||
#if defined(_M_IX86)
|
||||
#ifdef CURRENT_THREAD_VIA_EXCEPTION
|
||||
// TODO: The following is not a "good" implementation,
|
||||
// because the callstack is only valid in the "__except" block...
|
||||
#define GET_CURRENT_CONTEXT(c, contextFlags) \
|
||||
do { \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
EXCEPTION_POINTERS *pExp = nullptr; \
|
||||
__try { \
|
||||
throw 0; \
|
||||
} __except( ( (pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_EXECUTE_HANDLER)) {} \
|
||||
if (pExp != nullptr) \
|
||||
memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
} while(0);
|
||||
#else
|
||||
// The following should be enough for walking the callstack...
|
||||
#define GET_CURRENT_CONTEXT(c, contextFlags) \
|
||||
do { \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
__asm call x \
|
||||
__asm x: pop eax \
|
||||
__asm mov c.Eip, eax \
|
||||
__asm mov c.Ebp, ebp \
|
||||
__asm mov c.Esp, esp \
|
||||
} while(0);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// The following is defined for x86 (XP and higher), x64 and IA64:
|
||||
#define GET_CURRENT_CONTEXT(c, contextFlags) \
|
||||
do { \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
RtlCaptureContext(&c); \
|
||||
} while(0);
|
||||
#endif
|
||||
#endif
|
||||
-190
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
* Boost Software License - Version 1.0 - August 17th, 2003
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person or organization
|
||||
* obtaining a copy of the software and accompanying documentation covered by
|
||||
* this license (the "Software") to use, reproduce, display, distribute,
|
||||
* execute, and transmit the Software, and to prepare derivative works of the
|
||||
* Software, and to permit third-parties to whom the Software is furnished to
|
||||
* do so, all subject to the following:
|
||||
*
|
||||
* The copyright notices in the Software and this entire statement, including
|
||||
* the above license grant, this restriction and the following disclaimer,
|
||||
* must be included in all copies of the Software, in whole or in part, and
|
||||
* all derivative works of the Software, unless such copies or derivative
|
||||
* works are solely in the form of machine-executable object code generated by
|
||||
* a source language processor.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// EQEmu::Any is a modified version of Boost::Any and as such retains the Boost licensing.
|
||||
|
||||
#ifndef EQEMU_COMMON_ANY_H
|
||||
#define EQEMU_COMMON_ANY_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
class Any
|
||||
{
|
||||
public:
|
||||
Any()
|
||||
: content(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
Any(const ValueType &value)
|
||||
: content(new Holder<ValueType>(value))
|
||||
{
|
||||
}
|
||||
|
||||
Any(const Any &other)
|
||||
: content(other.content ? other.content->clone() : 0)
|
||||
{
|
||||
}
|
||||
|
||||
~Any()
|
||||
{
|
||||
if(content)
|
||||
delete content;
|
||||
}
|
||||
|
||||
Any& swap(Any &rhs)
|
||||
{
|
||||
std::swap(content, rhs.content);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
Any& operator=(const ValueType &rhs)
|
||||
{
|
||||
Any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Any& operator=(Any rhs)
|
||||
{
|
||||
rhs.swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return !content;
|
||||
}
|
||||
|
||||
const std::type_info& type() const
|
||||
{
|
||||
return content ? content->type() : typeid(void);
|
||||
}
|
||||
|
||||
class Placeholder
|
||||
{
|
||||
public:
|
||||
virtual ~Placeholder()
|
||||
{
|
||||
}
|
||||
|
||||
virtual const std::type_info& type() const = 0;
|
||||
virtual Placeholder* clone() const = 0;
|
||||
};
|
||||
|
||||
|
||||
template<typename ValueType>
|
||||
class Holder : public Placeholder
|
||||
{
|
||||
public:
|
||||
Holder(const ValueType &value)
|
||||
: held(value)
|
||||
{
|
||||
}
|
||||
|
||||
virtual const std::type_info& type() const
|
||||
{
|
||||
return typeid(ValueType);
|
||||
}
|
||||
|
||||
virtual Placeholder* clone() const
|
||||
{
|
||||
return new Holder(held);
|
||||
}
|
||||
|
||||
ValueType held;
|
||||
|
||||
private:
|
||||
Holder& operator=(const Holder&);
|
||||
};
|
||||
|
||||
private:
|
||||
template<typename ValueType>
|
||||
friend ValueType* any_cast(Any*);
|
||||
|
||||
template<typename ValueType>
|
||||
friend ValueType* unsafe_any_cast(Any*);
|
||||
|
||||
Placeholder* content;
|
||||
};
|
||||
|
||||
class bad_any_cast : public std::bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char * what() const throw()
|
||||
{
|
||||
return "DBI::bad_any_cast: failed conversion using DBI::any_cast";
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ValueType>
|
||||
ValueType* any_cast(Any* operand)
|
||||
{
|
||||
return operand &&
|
||||
operand->type() == typeid(ValueType) ? &static_cast<Any::Holder<ValueType>*>(operand->content)->held : nullptr;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline const ValueType* any_cast(const Any* operand)
|
||||
{
|
||||
return any_cast<ValueType>(const_cast<Any*>(operand));
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
ValueType any_cast(Any& operand)
|
||||
{
|
||||
typedef typename std::remove_reference<ValueType>::type nonref;
|
||||
nonref* result = any_cast<nonref>(&operand);
|
||||
if(!result)
|
||||
throw bad_any_cast();
|
||||
return *result;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline ValueType any_cast(const Any& operand)
|
||||
{
|
||||
typedef typename std::remove_reference<ValueType>::type nonref;
|
||||
return any_cast<const nonref&>(const_cast<Any&>(operand));
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline ValueType* unsafe_any_cast(Any* operand)
|
||||
{
|
||||
return &static_cast<Any::Holder<ValueType>*>(operand->content)->held;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline const ValueType* unsafe_any_cast(const Any* operand)
|
||||
{
|
||||
return unsafe_any_cast<ValueType>(const_cast<Any*>(operand));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
/* 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
|
||||
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
|
||||
*/
|
||||
|
||||
#ifndef __EQEMU_COMMON_BASE_DATA_H
|
||||
#define __EQEMU_COMMON_BASE_DATA_H
|
||||
|
||||
struct BaseDataStruct
|
||||
{
|
||||
double base_hp;
|
||||
double base_mana;
|
||||
double base_end;
|
||||
double hp_regen;
|
||||
double end_regen;
|
||||
double hp_factor;
|
||||
double mana_factor;
|
||||
double endurance_factor;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,137 +0,0 @@
|
||||
/* 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
|
||||
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
|
||||
*/
|
||||
|
||||
#include "global_define.h"
|
||||
#include "base_packet.h"
|
||||
#include "misc.h"
|
||||
#include "packet_dump.h"
|
||||
|
||||
BasePacket::BasePacket(const unsigned char *buf, uint32 len)
|
||||
{
|
||||
this->pBuffer=nullptr;
|
||||
this->size=0;
|
||||
this->_wpos = 0;
|
||||
this->_rpos = 0;
|
||||
this->timestamp.tv_sec = 0;
|
||||
if (len>0) {
|
||||
this->size=len;
|
||||
pBuffer= new unsigned char[len];
|
||||
if (buf) {
|
||||
memcpy(this->pBuffer,buf,len);
|
||||
} else {
|
||||
memset(this->pBuffer,0,len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BasePacket::BasePacket(SerializeBuffer &buf)
|
||||
{
|
||||
pBuffer = buf.m_buffer;
|
||||
buf.m_buffer = nullptr;
|
||||
size = buf.m_pos;
|
||||
buf.m_pos = 0;
|
||||
buf.m_capacity = 0;
|
||||
_wpos = 0;
|
||||
_rpos = 0;
|
||||
timestamp.tv_sec = 0;
|
||||
}
|
||||
|
||||
BasePacket::~BasePacket()
|
||||
{
|
||||
if (pBuffer)
|
||||
delete[] pBuffer;
|
||||
pBuffer=nullptr;
|
||||
}
|
||||
|
||||
|
||||
void BasePacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
if (timestamp.tv_sec) {
|
||||
char temp[20];
|
||||
strftime(temp,20,"%F %T",localtime((const time_t *)×tamp.tv_sec));
|
||||
buffer += sprintf(buffer, "%s.%06lu ",temp,timestamp.tv_usec);
|
||||
}
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
buffer += sprintf(buffer, "[%s:%d->%s:%d]\n",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
buffer += sprintf(buffer, "[Seq=%u] ",seq);
|
||||
}
|
||||
|
||||
void BasePacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[128];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void BasePacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
sprintf(buffer, "[packet]\n");
|
||||
}
|
||||
|
||||
void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
}
|
||||
|
||||
void BasePacket::DumpRaw(FILE *to) const
|
||||
{
|
||||
DumpRawHeader();
|
||||
if (pBuffer && size)
|
||||
dump_message_column(pBuffer, size, " ", to);
|
||||
fprintf(to, "\n");
|
||||
}
|
||||
|
||||
void BasePacket::ReadString(char *str, uint32 Offset, uint32 MaxLength) const
|
||||
{
|
||||
uint32 i = 0, j = Offset;
|
||||
|
||||
do
|
||||
{
|
||||
str[i++] = pBuffer[j++];
|
||||
}
|
||||
while((j < size) && (i < MaxLength) && (str[i - 1] != 0));
|
||||
|
||||
str[i - 1] = '\0';
|
||||
}
|
||||
|
||||
void DumpPacketHex(const BasePacket* app)
|
||||
{
|
||||
DumpPacketHex(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
void DumpPacketAscii(const BasePacket* app)
|
||||
{
|
||||
DumpPacketAscii(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
void DumpPacketBin(const BasePacket* app) {
|
||||
DumpPacketBin(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/* 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
|
||||
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
|
||||
*/
|
||||
#ifndef BASEPACKET_H_
|
||||
#define BASEPACKET_H_
|
||||
|
||||
#include "types.h"
|
||||
#include "serialize_buffer.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <time.h>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
class BasePacket {
|
||||
public:
|
||||
unsigned char *pBuffer;
|
||||
uint32 size, _wpos, _rpos;
|
||||
uint32 src_ip,dst_ip;
|
||||
uint16 src_port,dst_port;
|
||||
uint32 priority;
|
||||
timeval timestamp;
|
||||
|
||||
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;
|
||||
void DumpRaw(FILE *to = stdout) const;
|
||||
|
||||
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; }
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void WriteUInt8(uint8 value) { *(uint8 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint8); }
|
||||
void WriteUInt32(uint32 value) { *(uint32 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint32); }
|
||||
void WriteUInt64(uint64 value) { *(uint64 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint64); }
|
||||
void WriteUInt16(uint32 value) { *(uint16 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint16); }
|
||||
void WriteSInt32(int32 value) { *(int32 *)(pBuffer + _wpos) = value; _wpos += sizeof(int32); }
|
||||
void WriteFloat(float value) { *(float *)(pBuffer + _wpos) = value; _wpos += sizeof(float); }
|
||||
void WriteDouble(double value) { *(double *)(pBuffer + _wpos) = value; _wpos += sizeof(double); }
|
||||
void WriteString(const char * str) { uint32 len = static_cast<uint32>(strlen(str)) + 1; memcpy(pBuffer + _wpos, str, len); _wpos += len; }
|
||||
// this is used in task system a lot, it is NOT null-termed
|
||||
void WriteLengthString(uint32 len, const char *str) { *(uint32 *)(pBuffer + _wpos) = len; _wpos += sizeof(uint32); memcpy(pBuffer + _wpos, str, len); _wpos += len; }
|
||||
void WriteData(const void *ptr, size_t n) { memcpy(pBuffer + _wpos, ptr, n); _wpos += n; }
|
||||
|
||||
uint8 ReadUInt8() { uint8 value = *(uint8 *)(pBuffer + _rpos); _rpos += sizeof(uint8); return value; }
|
||||
uint8 ReadUInt8(uint32 Offset) const { uint8 value = *(uint8 *)(pBuffer + Offset); return value; }
|
||||
uint16 ReadUInt16() { uint16 value = *(uint16 *)(pBuffer + _rpos); _rpos += sizeof(uint16); return value; }
|
||||
uint16 ReadUInt16(uint32 Offset) const { uint16 value = *(uint16 *)(pBuffer + Offset); return value; }
|
||||
uint32 ReadUInt32() { uint32 value = *(uint32 *)(pBuffer + _rpos); _rpos += sizeof(uint32); return value; }
|
||||
uint32 ReadUInt32(uint32 Offset) const { uint32 value = *(uint32 *)(pBuffer + Offset); return value; }
|
||||
void ReadString(char *str) { uint32 len = static_cast<uint32>(strlen((char *)(pBuffer + _rpos))) + 1; memcpy(str, pBuffer + _rpos, len); _rpos += len; }
|
||||
void ReadString(std::string &str) { str = reinterpret_cast<char *>(pBuffer + _rpos); _rpos += str.length() + 1; }
|
||||
void ReadString(char *str, uint32 Offset, uint32 MaxLength) const;
|
||||
|
||||
uint32 GetWritePosition() { return _wpos; }
|
||||
uint32 GetReadPosition() { return _rpos; }
|
||||
void SetWritePosition(uint32 Newwpos) { _wpos = Newwpos; }
|
||||
void SetReadPosition(uint32 Newrpos) { _rpos = Newrpos; }
|
||||
|
||||
protected:
|
||||
virtual ~BasePacket();
|
||||
BasePacket() { pBuffer=nullptr; size=0; _wpos = 0; _rpos = 0; }
|
||||
BasePacket(const unsigned char *buf, const uint32 len);
|
||||
BasePacket(SerializeBuffer &buf);
|
||||
};
|
||||
|
||||
extern void DumpPacketHex(const BasePacket* app);
|
||||
extern void DumpPacketAscii(const BasePacket* app);
|
||||
extern void DumpPacketBin(const BasePacket* app);
|
||||
|
||||
#endif /*BASEPACKET_H_*/
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/* 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 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
|
||||
*/
|
||||
#ifndef BODYTYPES_H
|
||||
#define BODYTYPES_H
|
||||
|
||||
typedef enum {
|
||||
BT_Humanoid = 1,
|
||||
BT_Lycanthrope = 2,
|
||||
BT_Undead = 3,
|
||||
BT_Giant = 4,
|
||||
BT_Construct = 5,
|
||||
BT_Extraplanar = 6,
|
||||
BT_Magical = 7, //this name might be a bit off,
|
||||
BT_SummonedUndead = 8,
|
||||
BT_RaidGiant = 9,
|
||||
// ...
|
||||
BT_NoTarget = 11, //no name, can't target this bodytype
|
||||
BT_Vampire = 12,
|
||||
BT_Atenha_Ra = 13,
|
||||
BT_Greater_Akheva = 14,
|
||||
BT_Khati_Sha = 15,
|
||||
BT_Seru = 16, //not confirmed....
|
||||
BT_Draz_Nurakk = 18,
|
||||
BT_Zek = 19,
|
||||
BT_Luggald = 20,
|
||||
BT_Animal = 21,
|
||||
BT_Insect = 22,
|
||||
BT_Monster = 23,
|
||||
BT_Summoned = 24, //Elemental?
|
||||
BT_Plant = 25,
|
||||
BT_Dragon = 26,
|
||||
BT_Summoned2 = 27,
|
||||
BT_Summoned3 = 28,
|
||||
//29
|
||||
BT_VeliousDragon = 30, //might not be a tight set
|
||||
// ...
|
||||
BT_Dragon3 = 32,
|
||||
BT_Boxes = 33,
|
||||
BT_Muramite = 34, //tribal dudes
|
||||
// ...
|
||||
BT_NoTarget2 = 60,
|
||||
// ...
|
||||
BT_SwarmPet = 63, //is this valid, or made up?
|
||||
// ...
|
||||
BT_InvisMan = 66, //no name, seen on 'InvisMan', can be /targeted
|
||||
BT_Special = 67
|
||||
} bodyType;
|
||||
/* bodytypes above 64 make the mob not show up */
|
||||
|
||||
#endif
|
||||
@@ -1,695 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2016 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 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
|
||||
*/
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/classes.h"
|
||||
|
||||
const char *GetClassIDName(uint8 class_id, uint8 level)
|
||||
{
|
||||
switch (class_id) {
|
||||
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:
|
||||
return "Cleric Guildmaster";
|
||||
case PALADINGM:
|
||||
return "Paladin Guildmaster";
|
||||
case RANGERGM:
|
||||
return "Ranger Guildmaster";
|
||||
case SHADOWKNIGHTGM:
|
||||
return "Shadowknight Guildmaster";
|
||||
case DRUIDGM:
|
||||
return "Druid Guildmaster";
|
||||
case MONKGM:
|
||||
return "Monk Guildmaster";
|
||||
case BARDGM:
|
||||
return "Bard Guildmaster";
|
||||
case ROGUEGM:
|
||||
return "Rogue Guildmaster";
|
||||
case SHAMANGM:
|
||||
return "Shaman Guildmaster";
|
||||
case NECROMANCERGM:
|
||||
return "Necromancer Guildmaster";
|
||||
case WIZARDGM:
|
||||
return "Wizard Guildmaster";
|
||||
case MAGICIANGM:
|
||||
return "Magician Guildmaster";
|
||||
case ENCHANTERGM:
|
||||
return "Enchanter Guildmaster";
|
||||
case BEASTLORDGM:
|
||||
return "Beastlord Guildmaster";
|
||||
case BERSERKERGM:
|
||||
return "Berserker Guildmaster";
|
||||
case MERCHANT:
|
||||
return "Merchant";
|
||||
case ADVENTURERECRUITER:
|
||||
return "Adventure Recruiter";
|
||||
case ADVENTUREMERCHANT:
|
||||
return "Adventure Merchant";
|
||||
case CORPSE_CLASS:
|
||||
return "Corpse Class";
|
||||
case TRIBUTE_MASTER:
|
||||
return "Tribute Master";
|
||||
case GUILD_TRIBUTE_MASTER:
|
||||
return "Guild Tribute Master";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char *GetPlayerClassName(uint32 player_class_value, uint8 level)
|
||||
{
|
||||
return GetClassIDName(GetClassIDFromPlayerClassValue(player_class_value), level);
|
||||
}
|
||||
|
||||
uint32 GetPlayerClassValue(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case WARRIOR:
|
||||
case CLERIC:
|
||||
case PALADIN:
|
||||
case RANGER:
|
||||
case SHADOWKNIGHT:
|
||||
case DRUID:
|
||||
case MONK:
|
||||
case BARD:
|
||||
case ROGUE:
|
||||
case SHAMAN:
|
||||
case NECROMANCER:
|
||||
case WIZARD:
|
||||
case MAGICIAN:
|
||||
case ENCHANTER:
|
||||
case BEASTLORD:
|
||||
case BERSERKER:
|
||||
return class_id;
|
||||
default:
|
||||
return PLAYER_CLASS_UNKNOWN; // watch
|
||||
}
|
||||
}
|
||||
|
||||
uint32 GetPlayerClassBit(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case WARRIOR:
|
||||
return PLAYER_CLASS_WARRIOR_BIT;
|
||||
case CLERIC:
|
||||
return PLAYER_CLASS_CLERIC_BIT;
|
||||
case PALADIN:
|
||||
return PLAYER_CLASS_PALADIN_BIT;
|
||||
case RANGER:
|
||||
return PLAYER_CLASS_RANGER_BIT;
|
||||
case SHADOWKNIGHT:
|
||||
return PLAYER_CLASS_SHADOWKNIGHT_BIT;
|
||||
case DRUID:
|
||||
return PLAYER_CLASS_DRUID_BIT;
|
||||
case MONK:
|
||||
return PLAYER_CLASS_MONK_BIT;
|
||||
case BARD:
|
||||
return PLAYER_CLASS_BARD_BIT;
|
||||
case ROGUE:
|
||||
return PLAYER_CLASS_ROGUE_BIT;
|
||||
case SHAMAN:
|
||||
return PLAYER_CLASS_SHAMAN_BIT;
|
||||
case NECROMANCER:
|
||||
return PLAYER_CLASS_NECROMANCER_BIT;
|
||||
case WIZARD:
|
||||
return PLAYER_CLASS_WIZARD_BIT;
|
||||
case MAGICIAN:
|
||||
return PLAYER_CLASS_MAGICIAN_BIT;
|
||||
case ENCHANTER:
|
||||
return PLAYER_CLASS_ENCHANTER_BIT;
|
||||
case BEASTLORD:
|
||||
return PLAYER_CLASS_BEASTLORD_BIT;
|
||||
case BERSERKER:
|
||||
return PLAYER_CLASS_BERSERKER_BIT;
|
||||
default:
|
||||
return PLAYER_CLASS_UNKNOWN_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
uint8 GetClassIDFromPlayerClassValue(uint32 player_class_value)
|
||||
{
|
||||
switch (player_class_value) {
|
||||
case PLAYER_CLASS_WARRIOR:
|
||||
case PLAYER_CLASS_CLERIC:
|
||||
case PLAYER_CLASS_PALADIN:
|
||||
case PLAYER_CLASS_RANGER:
|
||||
case PLAYER_CLASS_SHADOWKNIGHT:
|
||||
case PLAYER_CLASS_DRUID:
|
||||
case PLAYER_CLASS_MONK:
|
||||
case PLAYER_CLASS_BARD:
|
||||
case PLAYER_CLASS_ROGUE:
|
||||
case PLAYER_CLASS_SHAMAN:
|
||||
case PLAYER_CLASS_NECROMANCER:
|
||||
case PLAYER_CLASS_WIZARD:
|
||||
case PLAYER_CLASS_MAGICIAN:
|
||||
case PLAYER_CLASS_ENCHANTER:
|
||||
case PLAYER_CLASS_BEASTLORD:
|
||||
case PLAYER_CLASS_BERSERKER:
|
||||
return player_class_value;
|
||||
default:
|
||||
return PLAYER_CLASS_UNKNOWN; // watch
|
||||
}
|
||||
}
|
||||
|
||||
uint8 GetClassIDFromPlayerClassBit(uint32 player_class_bit)
|
||||
{
|
||||
switch (player_class_bit) {
|
||||
case PLAYER_CLASS_WARRIOR_BIT:
|
||||
return WARRIOR;
|
||||
case PLAYER_CLASS_CLERIC_BIT:
|
||||
return CLERIC;
|
||||
case PLAYER_CLASS_PALADIN_BIT:
|
||||
return PALADIN;
|
||||
case PLAYER_CLASS_RANGER_BIT:
|
||||
return RANGER;
|
||||
case PLAYER_CLASS_SHADOWKNIGHT_BIT:
|
||||
return SHADOWKNIGHT;
|
||||
case PLAYER_CLASS_DRUID_BIT:
|
||||
return DRUID;
|
||||
case PLAYER_CLASS_MONK_BIT:
|
||||
return MONK;
|
||||
case PLAYER_CLASS_BARD_BIT:
|
||||
return BARD;
|
||||
case PLAYER_CLASS_ROGUE_BIT:
|
||||
return ROGUE;
|
||||
case PLAYER_CLASS_SHAMAN_BIT:
|
||||
return SHAMAN;
|
||||
case PLAYER_CLASS_NECROMANCER_BIT:
|
||||
return NECROMANCER;
|
||||
case PLAYER_CLASS_WIZARD_BIT:
|
||||
return WIZARD;
|
||||
case PLAYER_CLASS_MAGICIAN_BIT:
|
||||
return MAGICIAN;
|
||||
case PLAYER_CLASS_ENCHANTER_BIT:
|
||||
return ENCHANTER;
|
||||
case PLAYER_CLASS_BEASTLORD_BIT:
|
||||
return BEASTLORD;
|
||||
case PLAYER_CLASS_BERSERKER_BIT:
|
||||
return BERSERKER;
|
||||
default:
|
||||
return PLAYER_CLASS_UNKNOWN; // watch
|
||||
}
|
||||
}
|
||||
|
||||
bool IsFighterClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case WARRIOR:
|
||||
case PALADIN:
|
||||
case RANGER:
|
||||
case SHADOWKNIGHT:
|
||||
case MONK:
|
||||
case BARD:
|
||||
case ROGUE:
|
||||
case BEASTLORD:
|
||||
case BERSERKER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsSpellFighterClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case PALADIN:
|
||||
case RANGER:
|
||||
case SHADOWKNIGHT:
|
||||
case BEASTLORD:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNonSpellFighterClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case WARRIOR:
|
||||
case MONK:
|
||||
case BARD:
|
||||
case ROGUE:
|
||||
case BERSERKER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsCasterClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case CLERIC:
|
||||
case DRUID:
|
||||
case SHAMAN:
|
||||
case NECROMANCER:
|
||||
case WIZARD:
|
||||
case MAGICIAN:
|
||||
case ENCHANTER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsINTCasterClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case NECROMANCER:
|
||||
case WIZARD:
|
||||
case MAGICIAN:
|
||||
case ENCHANTER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsWISCasterClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case CLERIC:
|
||||
case DRUID:
|
||||
case SHAMAN:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsPlateClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case WARRIOR:
|
||||
case CLERIC:
|
||||
case PALADIN:
|
||||
case SHADOWKNIGHT:
|
||||
case BARD:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsChainClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case RANGER:
|
||||
case ROGUE:
|
||||
case SHAMAN:
|
||||
case BERSERKER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsLeatherClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case DRUID:
|
||||
case MONK:
|
||||
case BEASTLORD:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsClothClass(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case NECROMANCER:
|
||||
case WIZARD:
|
||||
case MAGICIAN:
|
||||
case ENCHANTER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint8 ClassArmorType(uint8 class_id)
|
||||
{
|
||||
switch (class_id) {
|
||||
case WARRIOR:
|
||||
case CLERIC:
|
||||
case PALADIN:
|
||||
case SHADOWKNIGHT:
|
||||
case BARD:
|
||||
return ARMOR_TYPE_PLATE;
|
||||
case RANGER:
|
||||
case ROGUE:
|
||||
case SHAMAN:
|
||||
case BERSERKER:
|
||||
return ARMOR_TYPE_CHAIN;
|
||||
case DRUID:
|
||||
case MONK:
|
||||
case BEASTLORD:
|
||||
return ARMOR_TYPE_LEATHER;
|
||||
case NECROMANCER:
|
||||
case WIZARD:
|
||||
case MAGICIAN:
|
||||
case ENCHANTER:
|
||||
return ARMOR_TYPE_CLOTH;
|
||||
default:
|
||||
return ARMOR_TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2016 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 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
|
||||
*/
|
||||
#ifndef CLASSES_CH
|
||||
#define CLASSES_CH
|
||||
|
||||
#include "../common/types.h"
|
||||
|
||||
#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 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 MERCHANT 41
|
||||
#define DISCORD_MERCHANT 59
|
||||
#define ADVENTURERECRUITER 60
|
||||
#define ADVENTUREMERCHANT 61
|
||||
#define LDON_TREASURE 62 // objects you can use /open on first seen in LDONs
|
||||
#define CORPSE_CLASS 62 // only seen on Danvi's Corpse in Akheva so far..
|
||||
#define TRIBUTE_MASTER 63
|
||||
#define GUILD_TRIBUTE_MASTER 64 // not sure
|
||||
#define NORRATHS_KEEPERS_MERCHANT 67
|
||||
#define DARK_REIGN_MERCHANT 68
|
||||
#define FELLOWSHIP_MASTER 69
|
||||
#define ALT_CURRENCY_MERCHANT 70
|
||||
#define MERCERNARY_MASTER 71
|
||||
|
||||
|
||||
// player class values
|
||||
#define PLAYER_CLASS_UNKNOWN 0
|
||||
#define PLAYER_CLASS_WARRIOR 1
|
||||
#define PLAYER_CLASS_CLERIC 2
|
||||
#define PLAYER_CLASS_PALADIN 3
|
||||
#define PLAYER_CLASS_RANGER 4
|
||||
#define PLAYER_CLASS_SHADOWKNIGHT 5
|
||||
#define PLAYER_CLASS_DRUID 6
|
||||
#define PLAYER_CLASS_MONK 7
|
||||
#define PLAYER_CLASS_BARD 8
|
||||
#define PLAYER_CLASS_ROGUE 9
|
||||
#define PLAYER_CLASS_SHAMAN 10
|
||||
#define PLAYER_CLASS_NECROMANCER 11
|
||||
#define PLAYER_CLASS_WIZARD 12
|
||||
#define PLAYER_CLASS_MAGICIAN 13
|
||||
#define PLAYER_CLASS_ENCHANTER 14
|
||||
#define PLAYER_CLASS_BEASTLORD 15
|
||||
#define PLAYER_CLASS_BERSERKER 16
|
||||
|
||||
#define PLAYER_CLASS_COUNT 16
|
||||
|
||||
|
||||
// player class bits
|
||||
#define PLAYER_CLASS_UNKNOWN_BIT 0
|
||||
#define PLAYER_CLASS_WARRIOR_BIT 1
|
||||
#define PLAYER_CLASS_CLERIC_BIT 2
|
||||
#define PLAYER_CLASS_PALADIN_BIT 4
|
||||
#define PLAYER_CLASS_RANGER_BIT 8
|
||||
#define PLAYER_CLASS_SHADOWKNIGHT_BIT 16
|
||||
#define PLAYER_CLASS_DRUID_BIT 32
|
||||
#define PLAYER_CLASS_MONK_BIT 64
|
||||
#define PLAYER_CLASS_BARD_BIT 128
|
||||
#define PLAYER_CLASS_ROGUE_BIT 256
|
||||
#define PLAYER_CLASS_SHAMAN_BIT 512
|
||||
#define PLAYER_CLASS_NECROMANCER_BIT 1024
|
||||
#define PLAYER_CLASS_WIZARD_BIT 2048
|
||||
#define PLAYER_CLASS_MAGICIAN_BIT 4096
|
||||
#define PLAYER_CLASS_ENCHANTER_BIT 8192
|
||||
#define PLAYER_CLASS_BEASTLORD_BIT 16384
|
||||
#define PLAYER_CLASS_BERSERKER_BIT 32768
|
||||
|
||||
#define PLAYER_CLASS_ALL_MASK 65535 // was 65536
|
||||
|
||||
|
||||
#define ARMOR_TYPE_UNKNOWN 0
|
||||
#define ARMOR_TYPE_CLOTH 1
|
||||
#define ARMOR_TYPE_LEATHER 2
|
||||
#define ARMOR_TYPE_CHAIN 3
|
||||
#define ARMOR_TYPE_PLATE 4
|
||||
|
||||
#define ARMOR_TYPE_FIRST ARMOR_TYPE_UNKNOWN
|
||||
#define ARMOR_TYPE_LAST ARMOR_TYPE_PLATE
|
||||
#define ARMOR_TYPE_COUNT 5
|
||||
|
||||
|
||||
const char* GetClassIDName(uint8 class_id, uint8 level = 0);
|
||||
const char* GetPlayerClassName(uint32 player_class_value, uint8 level = 0);
|
||||
|
||||
uint32 GetPlayerClassValue(uint8 class_id);
|
||||
uint32 GetPlayerClassBit(uint8 class_id);
|
||||
|
||||
uint8 GetClassIDFromPlayerClassValue(uint32 player_class_value);
|
||||
uint8 GetClassIDFromPlayerClassBit(uint32 player_class_bit);
|
||||
|
||||
bool IsFighterClass(uint8 class_id);
|
||||
bool IsSpellFighterClass(uint8 class_id);
|
||||
bool IsNonSpellFighterClass(uint8 class_id);
|
||||
bool IsCasterClass(uint8 class_id);
|
||||
bool IsINTCasterClass(uint8 class_id);
|
||||
bool IsWISCasterClass(uint8 class_id);
|
||||
|
||||
bool IsPlateClass(uint8 class_id);
|
||||
bool IsChainClass(uint8 class_id);
|
||||
bool IsLeatherClass(uint8 class_id);
|
||||
bool IsClothClass(uint8 class_id);
|
||||
uint8 ClassArmorType(uint8 class_id);
|
||||
|
||||
#endif
|
||||
@@ -1,82 +0,0 @@
|
||||
#include "global_define.h"
|
||||
#include "types.h"
|
||||
#include <string.h>
|
||||
#include <zlib.h>
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
uint32 EstimateDeflateBuffer(uint32 len) {
|
||||
z_stream zstream;
|
||||
memset(&zstream, 0, sizeof(zstream));
|
||||
|
||||
zstream.zalloc = Z_NULL;
|
||||
zstream.zfree = Z_NULL;
|
||||
zstream.opaque = Z_NULL;
|
||||
if (deflateInit(&zstream, Z_FINISH) != Z_OK)
|
||||
return 0;
|
||||
|
||||
return deflateBound(&zstream, len);
|
||||
}
|
||||
|
||||
uint32 DeflateData(const char *buffer, uint32 len, char *out_buffer, uint32 out_len_max) {
|
||||
z_stream zstream;
|
||||
memset(&zstream, 0, sizeof(zstream));
|
||||
int zerror;
|
||||
|
||||
zstream.next_in = const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(buffer));
|
||||
zstream.avail_in = len;
|
||||
zstream.zalloc = Z_NULL;
|
||||
zstream.zfree = Z_NULL;
|
||||
zstream.opaque = Z_NULL;
|
||||
deflateInit(&zstream, Z_FINISH);
|
||||
|
||||
zstream.next_out = reinterpret_cast<unsigned char*>(out_buffer);
|
||||
zstream.avail_out = out_len_max;
|
||||
zerror = deflate(&zstream, Z_FINISH);
|
||||
|
||||
if (zerror == Z_STREAM_END)
|
||||
{
|
||||
deflateEnd(&zstream);
|
||||
return (uint32)zstream.total_out;
|
||||
}
|
||||
else
|
||||
{
|
||||
zerror = deflateEnd(&zstream);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 InflateData(const char* buffer, uint32 len, char* out_buffer, uint32 out_len_max) {
|
||||
z_stream zstream;
|
||||
int zerror = 0;
|
||||
int i;
|
||||
|
||||
zstream.next_in = const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(buffer));
|
||||
zstream.avail_in = len;
|
||||
zstream.next_out = reinterpret_cast<unsigned char*>(out_buffer);;
|
||||
zstream.avail_out = out_len_max;
|
||||
zstream.zalloc = Z_NULL;
|
||||
zstream.zfree = Z_NULL;
|
||||
zstream.opaque = Z_NULL;
|
||||
|
||||
i = inflateInit2(&zstream, 15);
|
||||
if (i != Z_OK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
zerror = inflate(&zstream, Z_FINISH);
|
||||
if (zerror == Z_STREAM_END) {
|
||||
inflateEnd(&zstream);
|
||||
return zstream.total_out;
|
||||
}
|
||||
else {
|
||||
if (zerror == -4 && zstream.msg == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
zerror = inflateEnd(&zstream);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
uint32 EstimateDeflateBuffer(uint32 len);
|
||||
uint32 DeflateData(const char *buffer, uint32 len, char *out_buffer, uint32 out_len_max);
|
||||
uint32 InflateData(const char* buffer, uint32 len, char* out_buffer, uint32 out_len_max);
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
/* 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
|
||||
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
|
||||
*/
|
||||
|
||||
#include "condition.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
|
||||
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_waiters = 0;
|
||||
InitializeCriticalSection(&CSMutex);
|
||||
}
|
||||
|
||||
Condition::~Condition()
|
||||
{
|
||||
DeleteCriticalSection(&CSMutex);
|
||||
CloseHandle(m_events[SignalEvent]);
|
||||
CloseHandle(m_events[BroadcastEvent]);
|
||||
}
|
||||
|
||||
void Condition::Signal()
|
||||
{
|
||||
EnterCriticalSection(&CSMutex);
|
||||
if(m_waiters > 0)
|
||||
SetEvent(m_events[SignalEvent]);
|
||||
LeaveCriticalSection(&CSMutex);
|
||||
}
|
||||
|
||||
void Condition::SignalAll()
|
||||
{
|
||||
EnterCriticalSection(&CSMutex);
|
||||
if(m_waiters > 0)
|
||||
SetEvent(m_events[BroadcastEvent]);
|
||||
LeaveCriticalSection(&CSMutex);
|
||||
}
|
||||
|
||||
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
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
||||
Condition::Condition()
|
||||
{
|
||||
pthread_cond_init(&cond,nullptr);
|
||||
pthread_mutex_init(&mutex,nullptr);
|
||||
}
|
||||
|
||||
void Condition::Signal()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
void Condition::SignalAll()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
pthread_cond_broadcast(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
void Condition::Wait()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
pthread_cond_wait(&cond,&mutex);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
I commented this specifically because I think it might be very
|
||||
difficult to write a windows counterpart to it, so I would like
|
||||
to discourage its use until we can confirm that it can be reasonably
|
||||
implemented on windows.
|
||||
|
||||
bool Condition::TimedWait(unsigned long usec)
|
||||
{
|
||||
struct timeval now;
|
||||
struct timespec timeout;
|
||||
int retcode=0;
|
||||
pthread_mutex_lock(&mutex);
|
||||
gettimeofday(&now,nullptr);
|
||||
now.tv_usec+=usec;
|
||||
timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000);
|
||||
timeout.tv_nsec = (now.tv_usec%1000000) *1000;
|
||||
//cout << "now=" << now.tv_sec << "."<<now.tv_usec << endl;
|
||||
//cout << "timeout=" << timeout.tv_sec << "."<<timeout.tv_nsec << endl;
|
||||
retcode=pthread_cond_timedwait(&cond,&mutex,&timeout);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return retcode!=ETIMEDOUT;
|
||||
}
|
||||
*/
|
||||
|
||||
Condition::~Condition()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
pthread_cond_destroy(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
pthread_mutex_destroy(&mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/* 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
|
||||
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
|
||||
*/
|
||||
#ifndef __CONDITION_H
|
||||
#define __CONDITION_H
|
||||
|
||||
#include "global_define.h"
|
||||
#include "mutex.h"
|
||||
#ifndef WIN32
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
//Sombody, someday needs to figure out how to implement a condition
|
||||
//system on windows...
|
||||
|
||||
|
||||
class Condition {
|
||||
private:
|
||||
#ifdef WIN32
|
||||
enum {
|
||||
SignalEvent = 0,
|
||||
BroadcastEvent,
|
||||
_eventCount
|
||||
};
|
||||
|
||||
HANDLE m_events[_eventCount];
|
||||
uint32 m_waiters;
|
||||
CRITICAL_SECTION CSMutex;
|
||||
#else
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
#endif
|
||||
public:
|
||||
Condition();
|
||||
void Signal();
|
||||
void SignalAll();
|
||||
void Wait();
|
||||
// bool TimedWait(unsigned long usec);
|
||||
~Condition();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "crash.h"
|
||||
|
||||
#if defined(_WINDOWS) && defined(CRASH_LOGGING)
|
||||
#include "StackWalker.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if(szText[i] == '\n' || szText[i] == '\r') {
|
||||
buffer[i] = ' ';
|
||||
} else {
|
||||
buffer[i] = szText[i];
|
||||
}
|
||||
}
|
||||
|
||||
Log(Logs::General, Logs::Crash, buffer);
|
||||
StackWalker::OnOutput(szText);
|
||||
}
|
||||
};
|
||||
|
||||
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
||||
{
|
||||
switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
|
||||
{
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_ACCESS_VIOLATION");
|
||||
break;
|
||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
|
||||
break;
|
||||
case EXCEPTION_BREAKPOINT:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_BREAKPOINT");
|
||||
break;
|
||||
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
|
||||
break;
|
||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
|
||||
break;
|
||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
|
||||
break;
|
||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
|
||||
break;
|
||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
|
||||
break;
|
||||
case EXCEPTION_FLT_OVERFLOW:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_OVERFLOW");
|
||||
break;
|
||||
case EXCEPTION_FLT_STACK_CHECK:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_STACK_CHECK");
|
||||
break;
|
||||
case EXCEPTION_FLT_UNDERFLOW:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_UNDERFLOW");
|
||||
break;
|
||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
|
||||
break;
|
||||
case EXCEPTION_IN_PAGE_ERROR:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_IN_PAGE_ERROR");
|
||||
break;
|
||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
|
||||
break;
|
||||
case EXCEPTION_INT_OVERFLOW:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_INT_OVERFLOW");
|
||||
break;
|
||||
case EXCEPTION_INVALID_DISPOSITION:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_INVALID_DISPOSITION");
|
||||
break;
|
||||
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
|
||||
break;
|
||||
case EXCEPTION_PRIV_INSTRUCTION:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_PRIV_INSTRUCTION");
|
||||
break;
|
||||
case EXCEPTION_SINGLE_STEP:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_SINGLE_STEP");
|
||||
break;
|
||||
case EXCEPTION_STACK_OVERFLOW:
|
||||
Log(Logs::General, Logs::Crash, "EXCEPTION_STACK_OVERFLOW");
|
||||
break;
|
||||
default:
|
||||
Log(Logs::General, Logs::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);
|
||||
}
|
||||
#else
|
||||
// crash is off or an unhandled platform
|
||||
void set_exception_handler() {
|
||||
}
|
||||
#endif
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef __EQEMU_CRASH_H
|
||||
#define __EQEMU_CRASH_H
|
||||
|
||||
void set_exception_handler();
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "crc32.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#ifndef _CRC16_H
|
||||
#define _CRC16_H
|
||||
#include "types.h"
|
||||
|
||||
uint16 CRC16(const unsigned char *buf, int size, int key);
|
||||
|
||||
#endif
|
||||
@@ -1,112 +0,0 @@
|
||||
#include "crc32.h"
|
||||
#include <assert.h>
|
||||
#include <memory.h>
|
||||
|
||||
uint32 CRC32Table[256] =
|
||||
{
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
|
||||
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
||||
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
||||
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
||||
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
|
||||
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
|
||||
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
||||
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
||||
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
|
||||
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
|
||||
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
||||
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
||||
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
|
||||
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
|
||||
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
||||
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
||||
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
|
||||
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
|
||||
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
||||
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
||||
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
||||
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
|
||||
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
|
||||
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
||||
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
||||
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
||||
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
|
||||
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
||||
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
||||
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
|
||||
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
|
||||
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
||||
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
||||
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
||||
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
|
||||
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
|
||||
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
||||
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
||||
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
|
||||
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
|
||||
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
||||
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
||||
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
|
||||
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
|
||||
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
};
|
||||
|
||||
uint32 CRC32::Generate(const uint8* buf, uint32 bufsize) {
|
||||
return Finish(Update(buf, bufsize));
|
||||
}
|
||||
|
||||
uint32 CRC32::GenerateNoFlip(const uint8* buf, uint32 bufsize) {
|
||||
return Update(buf, bufsize);
|
||||
}
|
||||
|
||||
void CRC32::SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at)
|
||||
{
|
||||
unsigned long data;
|
||||
unsigned long check = 0xffffffff;
|
||||
|
||||
assert(in_length >= start_at && in_data);
|
||||
|
||||
for(uint32 i=start_at; i<in_length; i++)
|
||||
{
|
||||
data = in_data[i];
|
||||
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) {
|
||||
for(uint32 i=0; i < bufsize; i++)
|
||||
Calc(buf[i], crc32var);
|
||||
return crc32var;
|
||||
}
|
||||
|
||||
inline void CRC32::Calc(const uint8 byte, uint32& crc32var) {
|
||||
crc32var = ((crc32var) >> 8) ^ CRC32Table[(byte) ^ ((crc32var) & 0x000000FF)];
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef CRC32_H
|
||||
#define CRC32_H
|
||||
#include "types.h"
|
||||
|
||||
class CRC32 {
|
||||
public:
|
||||
// one buffer CRC32
|
||||
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);
|
||||
};
|
||||
#endif
|
||||
@@ -1,53 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
template <typename T>
|
||||
T Clamp(const T& value, const T& lower, const T& upper) {
|
||||
return std::max(lower, std::min(value, upper));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T ClampLower(const T& value, const T& lower) {
|
||||
return std::max(lower, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T ClampUpper(const T& value, const T& upper) {
|
||||
return std::min(value, upper);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool ValueWithin(const T& value, const T& lower, const T& upper) {
|
||||
return value >= lower && value <= upper;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
bool ValueWithin(const T1& value, const T2& lower, const T3& upper) {
|
||||
return value >= (T1)lower && value <= (T1)upper;
|
||||
}
|
||||
|
||||
} /*EQEmu*/
|
||||
|
||||
-2251
File diff suppressed because it is too large
Load Diff
@@ -1,289 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
#ifndef EQEMU_DATABASE_H
|
||||
#define EQEMU_DATABASE_H
|
||||
|
||||
#define AUTHENTICATION_TIMEOUT 60
|
||||
#define INVALID_ID 0xFFFFFFFF
|
||||
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
|
||||
#include "types.h"
|
||||
#include "dbcore.h"
|
||||
#include "linked_list.h"
|
||||
#include "eq_packet_structs.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
//atoi is not uint32 or uint32 safe!!!!
|
||||
#define atoul(str) strtoul(str, nullptr, 10)
|
||||
|
||||
class MySQLRequestResult;
|
||||
class Client;
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
class InventoryProfile;
|
||||
}
|
||||
|
||||
struct EventLogDetails_Struct {
|
||||
uint32 id;
|
||||
char accountname[64];
|
||||
uint32 account_id;
|
||||
int16 status;
|
||||
char charactername[64];
|
||||
char targetname[64];
|
||||
char timestamp[64];
|
||||
char descriptiontype[64];
|
||||
char details[128];
|
||||
};
|
||||
|
||||
struct CharacterEventLog_Struct {
|
||||
uint32 count;
|
||||
uint8 eventid;
|
||||
EventLogDetails_Struct eld[255];
|
||||
};
|
||||
|
||||
struct npcDecayTimes_Struct {
|
||||
uint16 minlvl;
|
||||
uint16 maxlvl;
|
||||
uint32 seconds;
|
||||
};
|
||||
|
||||
|
||||
struct VarCache_Struct {
|
||||
std::map<std::string, std::string> m_cache;
|
||||
uint32 last_update;
|
||||
VarCache_Struct() : last_update(0) { }
|
||||
void Add(const std::string &key, const std::string &value) { m_cache[key] = value; }
|
||||
const std::string *Get(const std::string &key) {
|
||||
auto it = m_cache.find(key);
|
||||
return (it != m_cache.end() ? &it->second : nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
class PTimerList;
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#if _MSC_VER > 1700 // greater than 2012 (2013+)
|
||||
# define _ISNAN_(a) std::isnan(a)
|
||||
#else
|
||||
# include <float.h>
|
||||
# define _ISNAN_(a) _isnan(a)
|
||||
#endif
|
||||
#else
|
||||
# define _ISNAN_(a) std::isnan(a)
|
||||
#endif
|
||||
|
||||
class Database : public DBcore {
|
||||
public:
|
||||
Database();
|
||||
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();
|
||||
|
||||
/* Character Creation */
|
||||
|
||||
bool AddToNameFilter(const char* name);
|
||||
bool CreateCharacter(uint32 account_id, char* name, uint16 gender, uint16 race, uint16 class_, uint8 str, uint8 sta, uint8 cha, uint8 dex, uint8 int_, uint8 agi, uint8 wis, uint8 face);
|
||||
bool DeleteCharacter(char* name);
|
||||
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);
|
||||
bool ReserveName(uint32 account_id, char* name);
|
||||
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
|
||||
bool SetHackerFlag(const char* accountname, const char* charactername, const char* hacked);
|
||||
bool SetMQDetectionFlag(const char* accountname, const char* charactername, const char* hacked, const char* zone);
|
||||
bool StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv);
|
||||
bool UpdateName(const char* oldname, const char* newname);
|
||||
|
||||
/* General Information Queries */
|
||||
|
||||
bool AddBannedIP(char* bannedIP, const char* notes); //Add IP address to the Banned_IPs table.
|
||||
bool AddGMIP(char* ip_address, char* name);
|
||||
bool CheckBannedIPs(const char* loginIP); //Check incoming connection against banned IP table.
|
||||
bool CheckGMIPs(const char* loginIP, uint32 account_id);
|
||||
bool CheckNameFilter(const char* name, bool surname = false);
|
||||
bool CheckUsedName(const char* name);
|
||||
|
||||
uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0);
|
||||
uint32 GetAccountIDByChar(uint32 char_id);
|
||||
uint32 GetAccountIDByName(const char* accname, int16* status = 0, uint32* lsid = 0);
|
||||
uint32 GetCharacterID(const 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 GetGuildIDByCharID(uint32 char_id);
|
||||
|
||||
void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0);
|
||||
void GetCharName(uint32 char_id, char* name);
|
||||
void LoginIP(uint32 AccountID, const char* LoginIP);
|
||||
|
||||
/* Instancing */
|
||||
|
||||
bool AddClientToInstance(uint16 instance_id, uint32 char_id);
|
||||
bool CharacterInInstanceGroup(uint16 instance_id, uint32 char_id);
|
||||
bool CheckInstanceExists(uint16 instance_id);
|
||||
bool CheckInstanceExpired(uint16 instance_id);
|
||||
bool CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration);
|
||||
bool GetUnusedInstanceID(uint16 &instance_id);
|
||||
bool GlobalInstance(uint16 instance_id);
|
||||
bool RemoveClientFromInstance(uint16 instance_id, uint32 char_id);
|
||||
bool RemoveClientsFromInstance(uint16 instance_id);
|
||||
bool VerifyInstanceAlive(uint16 instance_id, uint32 char_id);
|
||||
bool VerifyZoneInstance(uint32 zone_id, uint16 instance_id);
|
||||
|
||||
uint16 GetInstanceID(const char* zone, uint32 charid, int16 version);
|
||||
uint16 GetInstanceID(uint32 zone, uint32 charid, int16 version);
|
||||
uint16 GetInstanceVersion(uint16 instance_id);
|
||||
uint32 GetTimeRemainingInstance(uint16 instance_id, bool &is_perma);
|
||||
uint32 VersionFromInstanceID(uint16 instance_id);
|
||||
uint32 ZoneIDFromInstanceID(uint16 instance_id);
|
||||
|
||||
void AssignGroupToInstance(uint32 gid, uint32 instance_id);
|
||||
void AssignRaidToInstance(uint32 rid, uint32 instance_id);
|
||||
void BuryCorpsesInInstance(uint16 instance_id);
|
||||
void DeleteInstance(uint16 instance_id);
|
||||
void FlagInstanceByGroupLeader(uint32 zone, int16 version, uint32 charid, uint32 gid);
|
||||
void FlagInstanceByRaidLeader(uint32 zone, int16 version, uint32 charid, uint32 rid);
|
||||
void GetCharactersInInstance(uint16 instance_id, std::list<uint32> &charid_list);
|
||||
void PurgeExpiredInstances();
|
||||
void SetInstanceDuration(uint16 instance_id, uint32 new_duration);
|
||||
|
||||
/* Adventure related. */
|
||||
|
||||
void UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win);
|
||||
bool GetAdventureStats(uint32 char_id, AdventureStats_Struct *as);
|
||||
|
||||
/* Account Related */
|
||||
|
||||
bool DeleteAccount(const char* name);
|
||||
bool GetLiveChar(uint32 account_id, char* cname);
|
||||
bool SetAccountStatus(const char* name, int16 status);
|
||||
bool SetLocalPassword(uint32 accid, const char* password);
|
||||
bool UpdateLiveChar(char* charname, uint32 lsaccount_id);
|
||||
|
||||
int16 CheckStatus(uint32 account_id);
|
||||
|
||||
uint32 CheckLogin(const char* name, const char* password, int16* oStatus = 0);
|
||||
uint32 CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id = 0);
|
||||
uint32 GetAccountIDFromLSID(uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0);
|
||||
uint32 GetMiniLoginAccount(char* ip);
|
||||
uint8 GetAgreementFlag(uint32 acctid);
|
||||
|
||||
void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus);
|
||||
void SetAgreementFlag(uint32 acctid);
|
||||
|
||||
int GetIPExemption(std::string account_ip);
|
||||
|
||||
int GetInstanceID(uint32 char_id, uint32 zone_id);
|
||||
|
||||
|
||||
/* Groups */
|
||||
|
||||
char* GetGroupLeaderForLogin(const char* name,char* leaderbuf);
|
||||
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr, char *mentoree = nullptr, int *mentor_percent = nullptr, GroupLeadershipAA_Struct* GLAA = nullptr);
|
||||
|
||||
uint32 GetGroupID(const char* name);
|
||||
|
||||
void ClearGroup(uint32 gid = 0);
|
||||
void ClearGroupLeader(uint32 gid = 0);
|
||||
void SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ismerc = false);
|
||||
void SetGroupLeaderName(uint32 gid, const char* name);
|
||||
|
||||
/* Raids */
|
||||
|
||||
const char *GetRaidLeaderName(uint32 rid);
|
||||
|
||||
uint32 GetRaidID(const char* name);
|
||||
|
||||
void ClearRaid(uint32 rid = 0);
|
||||
void ClearRaidDetails(uint32 rid = 0);
|
||||
void ClearRaidLeader(uint32 gid = 0xFFFFFFFF, uint32 rid = 0);
|
||||
void GetGroupLeadershipInfo(uint32 gid, uint32 rid, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr, char *mentoree = nullptr, int *mentor_percent = nullptr, GroupLeadershipAA_Struct* GLAA = nullptr);
|
||||
void GetRaidLeadershipInfo(uint32 rid, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr, RaidLeadershipAA_Struct* RLAA = nullptr);
|
||||
void SetRaidGroupLeaderInfo(uint32 gid, uint32 rid);
|
||||
|
||||
void PurgeAllDeletedDataBuckets();
|
||||
|
||||
/* Database Conversions 'database_conversions.cpp' */
|
||||
|
||||
bool CheckDatabaseConversions();
|
||||
bool CheckDatabaseConvertCorpseDeblob();
|
||||
bool CheckDatabaseConvertPPDeblob();
|
||||
|
||||
/* Database Variables */
|
||||
|
||||
bool GetVariable(std::string varname, std::string &varvalue);
|
||||
bool SetVariable(const std::string varname, const std::string &varvalue);
|
||||
bool LoadVariables();
|
||||
|
||||
/* General Queries */
|
||||
|
||||
bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr);
|
||||
bool GetSafePoints(uint32 zoneID, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr) { return GetSafePoints(GetZoneName(zoneID), version, safe_x, safe_y, safe_z, minstatus, minlevel, flag_needed); }
|
||||
bool GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid = 0, float* graveyard_x = 0, float* graveyard_y = 0, float* graveyard_z = 0, float* graveyard_heading = 0);
|
||||
bool 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 LoadPTimers(uint32 charid, PTimerList &into);
|
||||
bool LoadZoneNames();
|
||||
|
||||
const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false);
|
||||
|
||||
uint32 GetZoneGraveyardID(uint32 zone_id, uint32 version);
|
||||
uint32 GetZoneID(const char* zonename);
|
||||
|
||||
uint8 GetPEQZone(uint32 zoneID, uint32 version);
|
||||
uint8 GetRaceSkill(uint8 skillid, uint8 in_race);
|
||||
uint8 GetServerType();
|
||||
uint8 GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level);
|
||||
|
||||
void AddReport(std::string who, std::string against, std::string lines);
|
||||
struct TimeOfDay_Struct LoadTime(time_t &realtime);
|
||||
bool SaveTime(int8 minute, int8 hour, int8 day, int8 month, int16 year);
|
||||
void ClearMerchantTemp();
|
||||
void ClearPTimers(uint32 charid);
|
||||
void SetFirstLogon(uint32 CharID, uint8 firstlogon);
|
||||
void SetLFG(uint32 CharID, bool LFG);
|
||||
void SetLFP(uint32 CharID, bool LFP);
|
||||
void SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon);
|
||||
|
||||
int CountInvSnapshots();
|
||||
void ClearInvSnapshots(bool from_now = false);
|
||||
|
||||
/* EQEmuLogSys */
|
||||
void LoadLogSettings(EQEmuLogSys::LogSettings* log_settings);
|
||||
|
||||
private:
|
||||
std::map<uint32,std::string> zonename_array;
|
||||
|
||||
Mutex Mvarcache;
|
||||
VarCache_Struct varcache;
|
||||
|
||||
/* Groups, utility methods. */
|
||||
void ClearAllGroupLeaders();
|
||||
void ClearAllGroups();
|
||||
|
||||
/* Raid, utility methods. */
|
||||
void ClearAllRaids();
|
||||
void ClearAllRaidDetails();
|
||||
void ClearAllRaidLeaders();
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,569 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2015 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
|
||||
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
|
||||
*/
|
||||
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/timer.h"
|
||||
|
||||
#include "database.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
// Disgrace: for windows compile
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#define snprintf _snprintf
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#else
|
||||
#include "unix.h"
|
||||
#include <netinet/in.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @param instance_id
|
||||
* @param char_id
|
||||
* @return
|
||||
*/
|
||||
bool Database::AddClientToInstance(uint16 instance_id, uint32 char_id)
|
||||
{
|
||||
std::string query = StringFormat(
|
||||
"REPLACE INTO `instance_list_player` (id, charid) "
|
||||
"VALUES "
|
||||
"(%lu, %lu)",
|
||||
(unsigned long) instance_id,
|
||||
(unsigned long) char_id
|
||||
);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
return results.Success();
|
||||
}
|
||||
|
||||
bool Database::CharacterInInstanceGroup(uint16 instance_id, uint32 char_id)
|
||||
{
|
||||
|
||||
std::string query = StringFormat("SELECT charid FROM instance_list_player where id=%u AND charid=%u", instance_id, char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return false;
|
||||
|
||||
if (results.RowCount() != 1)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database::CheckInstanceExists(uint16 instance_id) {
|
||||
std::string query = StringFormat(
|
||||
"SELECT "
|
||||
"`id` "
|
||||
"FROM "
|
||||
"`instance_list` "
|
||||
"WHERE "
|
||||
"`id` = %u",
|
||||
instance_id
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return false;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database::CheckInstanceExpired(uint16 instance_id)
|
||||
{
|
||||
|
||||
int32 start_time = 0;
|
||||
int32 duration = 0;
|
||||
uint32 never_expires = 0;
|
||||
|
||||
std::string query = StringFormat("SELECT start_time, duration, never_expires FROM instance_list WHERE id=%u", instance_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return true;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return true;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
start_time = atoi(row[0]);
|
||||
duration = atoi(row[1]);
|
||||
never_expires = atoi(row[2]);
|
||||
|
||||
if (never_expires == 1)
|
||||
return false;
|
||||
|
||||
timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
|
||||
if ((start_time + duration) <= tv.tv_sec)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Database::CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration)
|
||||
{
|
||||
std::string query = StringFormat("INSERT INTO instance_list (id, zone, version, start_time, duration)"
|
||||
" values(%lu, %lu, %lu, UNIX_TIMESTAMP(), %lu)",
|
||||
(unsigned long)instance_id, (unsigned long)zone_id, (unsigned long)version, (unsigned long)duration);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
return results.Success();
|
||||
}
|
||||
|
||||
bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
||||
{
|
||||
uint32 count = RuleI(Zone, ReservedInstances);
|
||||
uint32 max = 65535;
|
||||
|
||||
std::string query = StringFormat("SELECT IFNULL(MAX(id),%u)+1 FROM instance_list WHERE id > %u", count, count);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
instance_id = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
{
|
||||
instance_id = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
if (atoi(row[0]) <= max)
|
||||
{
|
||||
instance_id = atoi(row[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
query = StringFormat("SELECT id FROM instance_list where id > %u ORDER BY id", count);
|
||||
results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
instance_id = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
{
|
||||
instance_id = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
count++;
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
{
|
||||
if (count < atoi(row[0]))
|
||||
{
|
||||
instance_id = count;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (count > max)
|
||||
{
|
||||
instance_id = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
instance_id = count;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database::GlobalInstance(uint16 instance_id)
|
||||
{
|
||||
std::string query = StringFormat(
|
||||
"SELECT "
|
||||
"is_global "
|
||||
"FROM "
|
||||
"instance_list "
|
||||
"WHERE "
|
||||
"id = %u "
|
||||
"LIMIT 1 ",
|
||||
instance_id
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return false;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return false;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return (atoi(row[0]) == 1) ? true : false;
|
||||
}
|
||||
|
||||
bool Database::RemoveClientFromInstance(uint16 instance_id, uint32 char_id)
|
||||
{
|
||||
std::string query = StringFormat("DELETE FROM instance_list_player WHERE id=%lu AND charid=%lu",
|
||||
(unsigned long)instance_id, (unsigned long)char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
return results.Success();
|
||||
}
|
||||
|
||||
|
||||
bool Database::RemoveClientsFromInstance(uint16 instance_id)
|
||||
{
|
||||
std::string query = StringFormat("DELETE FROM instance_list_player WHERE id=%lu", (unsigned long)instance_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
return results.Success();
|
||||
}
|
||||
|
||||
bool Database::VerifyInstanceAlive(uint16 instance_id, uint32 char_id)
|
||||
{
|
||||
//we are not saved to this instance so set our instance to 0
|
||||
if (!GlobalInstance(instance_id) && !CharacterInInstanceGroup(instance_id, char_id))
|
||||
return false;
|
||||
|
||||
if (CheckInstanceExpired(instance_id))
|
||||
{
|
||||
DeleteInstance(instance_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database::VerifyZoneInstance(uint32 zone_id, uint16 instance_id)
|
||||
{
|
||||
|
||||
std::string query = StringFormat("SELECT id FROM instance_list where id=%u AND zone=%u", instance_id, zone_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return false;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16 Database::GetInstanceID(const char* zone, uint32 character_id, int16 version) {
|
||||
|
||||
std::string query = StringFormat(
|
||||
"SELECT "
|
||||
"instance_list.id "
|
||||
"FROM "
|
||||
"instance_list, "
|
||||
"instance_list_player "
|
||||
"WHERE "
|
||||
"instance_list.zone = %u "
|
||||
"AND instance_list.version = %u "
|
||||
"AND instance_list.id = instance_list_player.id "
|
||||
"AND instance_list_player.charid = %u "
|
||||
"LIMIT 1 ",
|
||||
GetZoneID(zone),
|
||||
version,
|
||||
character_id
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
uint16 Database::GetInstanceID(uint32 zone, uint32 character_id, int16 version)
|
||||
{
|
||||
if (!zone)
|
||||
return 0;
|
||||
|
||||
std::string query = StringFormat(
|
||||
"SELECT "
|
||||
"instance_list.id "
|
||||
"FROM "
|
||||
"instance_list, "
|
||||
"instance_list_player "
|
||||
"WHERE "
|
||||
"instance_list.zone = %u "
|
||||
"AND instance_list.version = %u "
|
||||
"AND instance_list.id = instance_list_player.id "
|
||||
"AND instance_list_player.charid = %u "
|
||||
"LIMIT 1; ",
|
||||
zone,
|
||||
version,
|
||||
character_id
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
uint16 Database::GetInstanceVersion(uint16 instance_id) {
|
||||
if (instance_id == 0)
|
||||
return 0;
|
||||
|
||||
std::string query = StringFormat("SELECT version FROM instance_list where id=%u", instance_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
uint32 Database::GetTimeRemainingInstance(uint16 instance_id, bool &is_perma)
|
||||
{
|
||||
uint32 start_time = 0;
|
||||
uint32 duration = 0;
|
||||
uint32 never_expires = 0;
|
||||
|
||||
std::string query = StringFormat("SELECT start_time, duration, never_expires FROM instance_list WHERE id=%u", instance_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
is_perma = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
{
|
||||
is_perma = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
start_time = atoi(row[0]);
|
||||
duration = atoi(row[1]);
|
||||
never_expires = atoi(row[2]);
|
||||
|
||||
if (never_expires == 1)
|
||||
{
|
||||
is_perma = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
is_perma = false;
|
||||
|
||||
timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
return ((start_time + duration) - tv.tv_sec);
|
||||
}
|
||||
|
||||
uint32 Database::VersionFromInstanceID(uint16 instance_id)
|
||||
{
|
||||
|
||||
std::string query = StringFormat("SELECT version FROM instance_list where id=%u", instance_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
uint32 Database::ZoneIDFromInstanceID(uint16 instance_id)
|
||||
{
|
||||
|
||||
std::string query = StringFormat("SELECT zone FROM instance_list where id=%u", instance_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
void Database::AssignGroupToInstance(uint32 group_id, uint32 instance_id)
|
||||
{
|
||||
|
||||
uint32 zone_id = ZoneIDFromInstanceID(instance_id);
|
||||
uint16 version = VersionFromInstanceID(instance_id);
|
||||
|
||||
std::string query = StringFormat("SELECT `charid` FROM `group_id` WHERE `groupid` = %u", group_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return;
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
{
|
||||
uint32 charid = atoi(row[0]);
|
||||
if (GetInstanceID(zone_id, charid, version) == 0)
|
||||
AddClientToInstance(instance_id, charid);
|
||||
}
|
||||
}
|
||||
|
||||
void Database::AssignRaidToInstance(uint32 raid_id, uint32 instance_id)
|
||||
{
|
||||
|
||||
uint32 zone_id = ZoneIDFromInstanceID(instance_id);
|
||||
uint16 version = VersionFromInstanceID(instance_id);
|
||||
|
||||
std::string query = StringFormat("SELECT `charid` FROM `raid_members` WHERE `raidid` = %u", raid_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return;
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
{
|
||||
uint32 charid = atoi(row[0]);
|
||||
if (GetInstanceID(zone_id, charid, version) == 0)
|
||||
AddClientToInstance(instance_id, charid);
|
||||
}
|
||||
}
|
||||
|
||||
void Database::BuryCorpsesInInstance(uint16 instance_id) {
|
||||
std::string query = StringFormat(
|
||||
"UPDATE `character_corpses` "
|
||||
"SET `is_buried` = 1, "
|
||||
"`instance_id` = 0 "
|
||||
"WHERE "
|
||||
"`instance_id` = %u ",
|
||||
instance_id
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::DeleteInstance(uint16 instance_id)
|
||||
{
|
||||
|
||||
std::string query = StringFormat("DELETE FROM instance_list WHERE id=%u", instance_id);
|
||||
QueryDatabase(query);
|
||||
|
||||
query = StringFormat("DELETE FROM instance_list_player WHERE id=%u", instance_id);
|
||||
QueryDatabase(query);
|
||||
|
||||
query = StringFormat("DELETE FROM respawn_times WHERE instance_id=%u", instance_id);
|
||||
QueryDatabase(query);
|
||||
|
||||
query = StringFormat("DELETE FROM spawn_condition_values WHERE instance_id=%u", instance_id);
|
||||
QueryDatabase(query);
|
||||
|
||||
BuryCorpsesInInstance(instance_id);
|
||||
}
|
||||
|
||||
void Database::FlagInstanceByGroupLeader(uint32 zone, int16 version, uint32 charid, uint32 gid)
|
||||
{
|
||||
uint16 id = GetInstanceID(zone, charid, version);
|
||||
if (id != 0)
|
||||
return;
|
||||
|
||||
char ln[128];
|
||||
memset(ln, 0, 128);
|
||||
strcpy(ln, GetGroupLeadershipInfo(gid, ln));
|
||||
uint32 l_charid = GetCharacterID((const char*)ln);
|
||||
uint16 l_id = GetInstanceID(zone, l_charid, version);
|
||||
|
||||
if (l_id == 0)
|
||||
return;
|
||||
|
||||
AddClientToInstance(l_id, charid);
|
||||
}
|
||||
|
||||
void Database::FlagInstanceByRaidLeader(uint32 zone, int16 version, uint32 charid, uint32 rid)
|
||||
{
|
||||
uint16 id = GetInstanceID(zone, charid, version);
|
||||
if (id != 0)
|
||||
return;
|
||||
|
||||
uint32 l_charid = GetCharacterID(GetRaidLeaderName(rid));
|
||||
uint16 l_id = GetInstanceID(zone, l_charid, version);
|
||||
|
||||
if (l_id == 0)
|
||||
return;
|
||||
|
||||
AddClientToInstance(l_id, charid);
|
||||
}
|
||||
|
||||
void Database::GetCharactersInInstance(uint16 instance_id, std::list<uint32> &charid_list) {
|
||||
|
||||
std::string query = StringFormat("SELECT `charid` FROM `instance_list_player` WHERE `id` = %u", instance_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return;
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
charid_list.push_back(atoi(row[0]));
|
||||
}
|
||||
|
||||
void Database::PurgeExpiredInstances()
|
||||
{
|
||||
std::string query("SELECT id FROM instance_list where (start_time+duration) <= UNIX_TIMESTAMP() and never_expires = 0");
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
return;
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return;
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
DeleteInstance(atoi(row[0]));
|
||||
}
|
||||
|
||||
void Database::SetInstanceDuration(uint16 instance_id, uint32 new_duration)
|
||||
{
|
||||
std::string query = StringFormat("UPDATE `instance_list` SET start_time=UNIX_TIMESTAMP(), "
|
||||
"duration=%u WHERE id=%u", new_duration, instance_id);
|
||||
auto results = QueryDatabase(query);
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
#ifdef _WINDOWS
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include "../common/misc_functions.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
#include "dbcore.h"
|
||||
|
||||
#include <errmsg.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <mysqld_error.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define snprintf _snprintf
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#include <process.h>
|
||||
#else
|
||||
#include "unix.h"
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
#define DEBUG_MYSQL_QUERIES 0
|
||||
#else
|
||||
#define DEBUG_MYSQL_QUERIES 0
|
||||
#endif
|
||||
|
||||
DBcore::DBcore() {
|
||||
mysql_init(&mysql);
|
||||
pHost = 0;
|
||||
pUser = 0;
|
||||
pPassword = 0;
|
||||
pDatabase = 0;
|
||||
pCompress = false;
|
||||
pSSL = false;
|
||||
pStatus = Closed;
|
||||
}
|
||||
|
||||
DBcore::~DBcore() {
|
||||
mysql_close(&mysql);
|
||||
safe_delete_array(pHost);
|
||||
safe_delete_array(pUser);
|
||||
safe_delete_array(pPassword);
|
||||
safe_delete_array(pDatabase);
|
||||
}
|
||||
|
||||
// Sends the MySQL server a keepalive
|
||||
void DBcore::ping() {
|
||||
if (!MDatabase.trylock()) {
|
||||
// well, if's it's locked, someone's using it. If someone's using it, it doesnt need a keepalive
|
||||
return;
|
||||
}
|
||||
mysql_ping(&mysql);
|
||||
MDatabase.unlock();
|
||||
}
|
||||
|
||||
MySQLRequestResult DBcore::QueryDatabase(std::string query, bool retryOnFailureOnce)
|
||||
{
|
||||
return QueryDatabase(query.c_str(), query.length(), retryOnFailureOnce);
|
||||
}
|
||||
|
||||
MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce)
|
||||
{
|
||||
LockMutex lock(&MDatabase);
|
||||
|
||||
// Reconnect if we are not connected before hand.
|
||||
if (pStatus != Connected)
|
||||
Open();
|
||||
|
||||
// request query. != 0 indicates some kind of error.
|
||||
if (mysql_real_query(&mysql, query, querylen) != 0)
|
||||
{
|
||||
unsigned int errorNumber = mysql_errno(&mysql);
|
||||
|
||||
if (errorNumber == CR_SERVER_GONE_ERROR)
|
||||
pStatus = Error;
|
||||
|
||||
// error appears to be a disconnect error, may need to try again.
|
||||
if (errorNumber == CR_SERVER_LOST || errorNumber == CR_SERVER_GONE_ERROR)
|
||||
{
|
||||
|
||||
if (retryOnFailureOnce)
|
||||
{
|
||||
std::cout << "Database Error: Lost connection, attempting to recover...." << std::endl;
|
||||
MySQLRequestResult requestResult = QueryDatabase(query, querylen, false);
|
||||
|
||||
if (requestResult.Success())
|
||||
{
|
||||
std::cout << "Reconnection to database successful." << std::endl;
|
||||
return requestResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pStatus = Error;
|
||||
|
||||
auto errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
||||
|
||||
snprintf(errorBuffer, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
|
||||
return MySQLRequestResult(nullptr, 0, 0, 0, 0, (uint32)mysql_errno(&mysql), errorBuffer);
|
||||
}
|
||||
|
||||
auto errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
||||
snprintf(errorBuffer, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
|
||||
/* Implement Logging at the Root */
|
||||
if (mysql_errno(&mysql) > 0 && strlen(query) > 0){
|
||||
if (LogSys.log_settings[Logs::MySQLError].is_category_enabled == 1)
|
||||
Log(Logs::General, Logs::MySQLError, "%i: %s \n %s", mysql_errno(&mysql), mysql_error(&mysql), query);
|
||||
}
|
||||
|
||||
return MySQLRequestResult(nullptr, 0, 0, 0, 0, mysql_errno(&mysql),errorBuffer);
|
||||
|
||||
}
|
||||
|
||||
// successful query. get results.
|
||||
MYSQL_RES* res = mysql_store_result(&mysql);
|
||||
uint32 rowCount = 0;
|
||||
|
||||
if (res != nullptr)
|
||||
rowCount = (uint32)mysql_num_rows(res);
|
||||
|
||||
MySQLRequestResult requestResult(res, (uint32)mysql_affected_rows(&mysql), rowCount, (uint32)mysql_field_count(&mysql), (uint32)mysql_insert_id(&mysql));
|
||||
|
||||
if (LogSys.log_settings[Logs::MySQLQuery].is_category_enabled == 1)
|
||||
{
|
||||
if ((strncasecmp(query, "select", 6) == 0)) {
|
||||
Log(Logs::General, Logs::MySQLQuery, "%s (%u row%s returned)", query, requestResult.RowCount(), requestResult.RowCount() == 1 ? "" : "s");
|
||||
}
|
||||
else {
|
||||
Log(Logs::General, Logs::MySQLQuery, "%s (%u row%s affected)", query, requestResult.RowsAffected(), requestResult.RowsAffected() == 1 ? "" : "s");
|
||||
}
|
||||
}
|
||||
|
||||
return requestResult;
|
||||
}
|
||||
|
||||
void DBcore::TransactionBegin() {
|
||||
QueryDatabase("START TRANSACTION");
|
||||
}
|
||||
|
||||
void DBcore::TransactionCommit() {
|
||||
QueryDatabase("COMMIT");
|
||||
}
|
||||
|
||||
void DBcore::TransactionRollback() {
|
||||
QueryDatabase("ROLLBACK");
|
||||
}
|
||||
|
||||
uint32 DBcore::DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen) {
|
||||
// No good reason to lock the DB, we only need it in the first place to check char encoding.
|
||||
// LockMutex lock(&MDatabase);
|
||||
return mysql_real_escape_string(&mysql, tobuf, frombuf, fromlen);
|
||||
}
|
||||
|
||||
bool DBcore::Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase,uint32 iPort, uint32* errnum, char* errbuf, bool iCompress, bool iSSL) {
|
||||
LockMutex lock(&MDatabase);
|
||||
safe_delete(pHost);
|
||||
safe_delete(pUser);
|
||||
safe_delete(pPassword);
|
||||
safe_delete(pDatabase);
|
||||
pHost = strcpy(new char[strlen(iHost) + 1], iHost);
|
||||
pUser = strcpy(new char[strlen(iUser) + 1], iUser);
|
||||
pPassword = strcpy(new char[strlen(iPassword) + 1], iPassword);
|
||||
pDatabase = strcpy(new char[strlen(iDatabase) + 1], iDatabase);
|
||||
pCompress = iCompress;
|
||||
pPort = iPort;
|
||||
pSSL = iSSL;
|
||||
return Open(errnum, errbuf);
|
||||
}
|
||||
|
||||
bool DBcore::Open(uint32* errnum, char* errbuf) {
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
LockMutex lock(&MDatabase);
|
||||
if (GetStatus() == Connected)
|
||||
return true;
|
||||
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
|
||||
*/
|
||||
uint32 flags = CLIENT_FOUND_ROWS;
|
||||
if (pCompress)
|
||||
flags |= CLIENT_COMPRESS;
|
||||
if (pSSL)
|
||||
flags |= CLIENT_SSL;
|
||||
if (mysql_real_connect(&mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
|
||||
pStatus = Connected;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (errnum)
|
||||
*errnum = mysql_errno(&mysql);
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
pStatus = Error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
#ifndef DBCORE_H
|
||||
#define DBCORE_H
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "../common/mutex.h"
|
||||
#include "../common/mysql_request_result.h"
|
||||
#include "../common/types.h"
|
||||
|
||||
#include <mysql.h>
|
||||
#include <string.h>
|
||||
|
||||
class DBcore {
|
||||
public:
|
||||
enum eStatus { Closed, Connected, Error };
|
||||
|
||||
DBcore();
|
||||
~DBcore();
|
||||
eStatus GetStatus() { return pStatus; }
|
||||
MySQLRequestResult QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce = true);
|
||||
MySQLRequestResult QueryDatabase(std::string query, bool retryOnFailureOnce = true);
|
||||
void TransactionBegin();
|
||||
void TransactionCommit();
|
||||
void TransactionRollback();
|
||||
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:
|
||||
bool Open(uint32* errnum = 0, char* errbuf = 0);
|
||||
|
||||
MYSQL mysql;
|
||||
Mutex MDatabase;
|
||||
eStatus pStatus;
|
||||
|
||||
char* pHost;
|
||||
char* pUser;
|
||||
char* pPassword;
|
||||
char* pDatabase;
|
||||
bool pCompress;
|
||||
uint32 pPort;
|
||||
bool pSSL;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
|
||||
#include "deity.h"
|
||||
|
||||
|
||||
EQEmu::deity::DeityTypeBit EQEmu::deity::ConvertDeityTypeToDeityTypeBit(DeityType deity_type)
|
||||
{
|
||||
switch (deity_type) {
|
||||
case DeityBertoxxulous:
|
||||
return bit_DeityBertoxxulous;
|
||||
case DeityBrellSirilis:
|
||||
return bit_DeityBrellSirilis;
|
||||
case DeityCazicThule:
|
||||
return bit_DeityCazicThule;
|
||||
case DeityErollisiMarr:
|
||||
return bit_DeityErollisiMarr;
|
||||
case DeityBristlebane:
|
||||
return bit_DeityBristlebane;
|
||||
case DeityInnoruuk:
|
||||
return bit_DeityInnoruuk;
|
||||
case DeityKarana:
|
||||
return bit_DeityKarana;
|
||||
case DeityMithanielMarr:
|
||||
return bit_DeityMithanielMarr;
|
||||
case DeityPrexus:
|
||||
return bit_DeityPrexus;
|
||||
case DeityQuellious:
|
||||
return bit_DeityQuellious;
|
||||
case DeityRallosZek:
|
||||
return bit_DeityRallosZek;
|
||||
case DeityRodcetNife:
|
||||
return bit_DeityRodcetNife;
|
||||
case DeitySolusekRo:
|
||||
return bit_DeitySolusekRo;
|
||||
case DeityTheTribunal:
|
||||
return bit_DeityTheTribunal;
|
||||
case DeityTunare:
|
||||
return bit_DeityTunare;
|
||||
case DeityVeeshan:
|
||||
return bit_DeityVeeshan;
|
||||
case DeityAgnostic_LB:
|
||||
case DeityAgnostic:
|
||||
return bit_DeityAgnostic;
|
||||
default:
|
||||
return bit_DeityAll;
|
||||
};
|
||||
}
|
||||
|
||||
EQEmu::deity::DeityType EQEmu::deity::ConvertDeityTypeBitToDeityType(DeityTypeBit deity_type_bit)
|
||||
{
|
||||
switch (deity_type_bit) {
|
||||
case bit_DeityAgnostic:
|
||||
return DeityAgnostic;
|
||||
case bit_DeityBertoxxulous:
|
||||
return DeityBertoxxulous;
|
||||
case bit_DeityBrellSirilis:
|
||||
return DeityBrellSirilis;
|
||||
case bit_DeityCazicThule:
|
||||
return DeityCazicThule;
|
||||
case bit_DeityErollisiMarr:
|
||||
return DeityErollisiMarr;
|
||||
case bit_DeityBristlebane:
|
||||
return DeityBristlebane;
|
||||
case bit_DeityInnoruuk:
|
||||
return DeityInnoruuk;
|
||||
case bit_DeityKarana:
|
||||
return DeityKarana;
|
||||
case bit_DeityMithanielMarr:
|
||||
return DeityMithanielMarr;
|
||||
case bit_DeityPrexus:
|
||||
return DeityPrexus;
|
||||
case bit_DeityQuellious:
|
||||
return DeityQuellious;
|
||||
case bit_DeityRallosZek:
|
||||
return DeityRallosZek;
|
||||
case bit_DeityRodcetNife:
|
||||
return DeityRodcetNife;
|
||||
case bit_DeitySolusekRo:
|
||||
return DeitySolusekRo;
|
||||
case bit_DeityTheTribunal:
|
||||
return DeityTheTribunal;
|
||||
case bit_DeityTunare:
|
||||
return DeityTunare;
|
||||
case bit_DeityVeeshan:
|
||||
return DeityVeeshan;
|
||||
default:
|
||||
return DeityUnknown;
|
||||
};
|
||||
}
|
||||
|
||||
const char* EQEmu::deity::DeityName(DeityType deity_type)
|
||||
{
|
||||
switch (deity_type) {
|
||||
case DeityBertoxxulous:
|
||||
return "Bertoxxulous";
|
||||
case DeityBrellSirilis:
|
||||
return "Brell Serilis";
|
||||
case DeityCazicThule:
|
||||
return "Cazic-Thule";
|
||||
case DeityErollisiMarr:
|
||||
return "Erollisi Marr";
|
||||
case DeityBristlebane:
|
||||
return "Bristlebane";
|
||||
case DeityInnoruuk:
|
||||
return "Innoruuk";
|
||||
case DeityKarana:
|
||||
return "Karana";
|
||||
case DeityMithanielMarr:
|
||||
return "Mithaniel Marr";
|
||||
case DeityPrexus:
|
||||
return "Prexus";
|
||||
case DeityQuellious:
|
||||
return "Quellious";
|
||||
case DeityRallosZek:
|
||||
return "Rallos Zek";
|
||||
case DeityRodcetNife:
|
||||
return "Rodcet Nife";
|
||||
case DeitySolusekRo:
|
||||
return "Solusek Ro";
|
||||
case DeityTheTribunal:
|
||||
return "The Tribunal";
|
||||
case DeityTunare:
|
||||
return "Tunare";
|
||||
case DeityVeeshan:
|
||||
return "Veeshan";
|
||||
case DeityAgnostic_LB:
|
||||
case DeityAgnostic:
|
||||
return "Agnostic";
|
||||
default:
|
||||
return "Unknown";
|
||||
};
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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 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
|
||||
*/
|
||||
|
||||
#ifndef COMMON_DEITY_H
|
||||
#define COMMON_DEITY_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
namespace deity {
|
||||
enum DeityType {
|
||||
DeityUnknown = 0,
|
||||
DeityAgnostic_LB = 140,
|
||||
DeityBertoxxulous = 201,
|
||||
DeityBrellSirilis,
|
||||
DeityCazicThule,
|
||||
DeityErollisiMarr,
|
||||
DeityBristlebane,
|
||||
DeityInnoruuk,
|
||||
DeityKarana,
|
||||
DeityMithanielMarr,
|
||||
DeityPrexus,
|
||||
DeityQuellious,
|
||||
DeityRallosZek,
|
||||
DeityRodcetNife,
|
||||
DeitySolusekRo,
|
||||
DeityTheTribunal,
|
||||
DeityTunare,
|
||||
DeityVeeshan,
|
||||
DeityAgnostic = 396
|
||||
};
|
||||
|
||||
enum DeityTypeBit : uint32 {
|
||||
bit_DeityNone = 0x00000000,
|
||||
bit_DeityAgnostic = 0x00000001,
|
||||
bit_DeityBertoxxulous = 0x00000002,
|
||||
bit_DeityBrellSirilis = 0x00000004,
|
||||
bit_DeityCazicThule = 0x00000008,
|
||||
bit_DeityErollisiMarr = 0x00000010,
|
||||
bit_DeityBristlebane = 0x00000020,
|
||||
bit_DeityInnoruuk = 0x00000040,
|
||||
bit_DeityKarana = 0x00000080,
|
||||
bit_DeityMithanielMarr = 0x00000100,
|
||||
bit_DeityPrexus = 0x00000200,
|
||||
bit_DeityQuellious = 0x00000400,
|
||||
bit_DeityRallosZek = 0x00000800,
|
||||
bit_DeityRodcetNife = 0x00001000,
|
||||
bit_DeitySolusekRo = 0x00002000,
|
||||
bit_DeityTheTribunal = 0x00004000,
|
||||
bit_DeityTunare = 0x00008000,
|
||||
bit_DeityVeeshan = 0x00010000,
|
||||
bit_DeityAll = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
extern DeityTypeBit ConvertDeityTypeToDeityTypeBit(DeityType deity_type);
|
||||
extern DeityType ConvertDeityTypeBitToDeityType(DeityTypeBit deity_type_bit);
|
||||
extern const char* DeityName(DeityType deity_type);
|
||||
|
||||
} /*deity*/
|
||||
|
||||
} /*EQEmu*/
|
||||
|
||||
#endif /* COMMON_DEITY_H */
|
||||
@@ -1,154 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
|
||||
#include "emu_constants.h"
|
||||
|
||||
|
||||
int16 EQEmu::invtype::GetInvTypeSize(int16 inv_type) {
|
||||
static const int16 local_array[] = {
|
||||
POSSESSIONS_SIZE,
|
||||
BANK_SIZE,
|
||||
SHARED_BANK_SIZE,
|
||||
TRADE_SIZE,
|
||||
WORLD_SIZE,
|
||||
LIMBO_SIZE,
|
||||
TRIBUTE_SIZE,
|
||||
TROPHY_TRIBUTE_SIZE,
|
||||
GUILD_TRIBUTE_SIZE,
|
||||
MERCHANT_SIZE,
|
||||
DELETED_SIZE,
|
||||
CORPSE_SIZE,
|
||||
BAZAAR_SIZE,
|
||||
INSPECT_SIZE,
|
||||
REAL_ESTATE_SIZE,
|
||||
VIEW_MOD_PC_SIZE,
|
||||
VIEW_MOD_BANK_SIZE,
|
||||
VIEW_MOD_SHARED_BANK_SIZE,
|
||||
VIEW_MOD_LIMBO_SIZE,
|
||||
ALT_STORAGE_SIZE,
|
||||
ARCHIVED_SIZE,
|
||||
MAIL_SIZE,
|
||||
GUILD_TROPHY_TRIBUTE_SIZE,
|
||||
KRONO_SIZE,
|
||||
OTHER_SIZE,
|
||||
};
|
||||
|
||||
if (inv_type < TYPE_BEGIN || inv_type > TYPE_END)
|
||||
return INULL;
|
||||
|
||||
return local_array[inv_type];
|
||||
}
|
||||
|
||||
const char* EQEmu::bug::CategoryIDToCategoryName(CategoryID category_id) {
|
||||
switch (category_id) {
|
||||
case catVideo:
|
||||
return "Video";
|
||||
case catAudio:
|
||||
return "Audio";
|
||||
case catPathing:
|
||||
return "Pathing";
|
||||
case catQuest:
|
||||
return "Quest";
|
||||
case catTradeskills:
|
||||
return "Tradeskills";
|
||||
case catSpellStacking:
|
||||
return "Spell stacking";
|
||||
case catDoorsPortals:
|
||||
return "Doors/Portals";
|
||||
case catItems:
|
||||
return "Items";
|
||||
case catNPC:
|
||||
return "NPC";
|
||||
case catDialogs:
|
||||
return "Dialogs";
|
||||
case catLoNTCG:
|
||||
return "LoN - TCG";
|
||||
case catMercenaries:
|
||||
return "Mercenaries";
|
||||
case catOther:
|
||||
default:
|
||||
return "Other";
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::bug::CategoryID EQEmu::bug::CategoryNameToCategoryID(const char* category_name) {
|
||||
if (!category_name)
|
||||
return catOther;
|
||||
|
||||
if (!strcmp(category_name, "Video"))
|
||||
return catVideo;
|
||||
if (!strcmp(category_name, "Audio"))
|
||||
return catAudio;
|
||||
if (!strcmp(category_name, "Pathing"))
|
||||
return catPathing;
|
||||
if (!strcmp(category_name, "Quest"))
|
||||
return catQuest;
|
||||
if (!strcmp(category_name, "Tradeskills"))
|
||||
return catTradeskills;
|
||||
if (!strcmp(category_name, "Spell stacking"))
|
||||
return catSpellStacking;
|
||||
if (!strcmp(category_name, "Doors/Portals"))
|
||||
return catDoorsPortals;
|
||||
if (!strcmp(category_name, "Items"))
|
||||
return catItems;
|
||||
if (!strcmp(category_name, "NPC"))
|
||||
return catNPC;
|
||||
if (!strcmp(category_name, "Dialogs"))
|
||||
return catDialogs;
|
||||
if (!strcmp(category_name, "LoN - TCG"))
|
||||
return catLoNTCG;
|
||||
if (!strcmp(category_name, "Mercenaries"))
|
||||
return catMercenaries;
|
||||
|
||||
return catOther;
|
||||
}
|
||||
|
||||
const char *EQEmu::constants::GetStanceName(StanceType stance_type) {
|
||||
switch (stance_type) {
|
||||
case stanceUnknown:
|
||||
return "Unknown";
|
||||
case stancePassive:
|
||||
return "Passive";
|
||||
case stanceBalanced:
|
||||
return "Balanced";
|
||||
case stanceEfficient:
|
||||
return "Efficient";
|
||||
case stanceReactive:
|
||||
return "Reactive";
|
||||
case stanceAggressive:
|
||||
return "Aggressive";
|
||||
case stanceAssist:
|
||||
return "Assist";
|
||||
case stanceBurn:
|
||||
return "Burn";
|
||||
case stanceEfficient2:
|
||||
return "Efficient2";
|
||||
case stanceBurnAE:
|
||||
return "BurnAE";
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
}
|
||||
|
||||
int EQEmu::constants::ConvertStanceTypeToIndex(StanceType stance_type) {
|
||||
if (stance_type >= EQEmu::constants::stancePassive && stance_type <= EQEmu::constants::stanceBurnAE)
|
||||
return (stance_type - EQEmu::constants::stancePassive);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,324 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
|
||||
#ifndef COMMON_EMU_CONSTANTS_H
|
||||
#define COMMON_EMU_CONSTANTS_H
|
||||
|
||||
#include "eq_limits.h"
|
||||
#include "emu_versions.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// local definitions are the result of using hybrid-client or server-only values and methods
|
||||
namespace EQEmu
|
||||
{
|
||||
using RoF2::IINVALID;
|
||||
using RoF2::INULL;
|
||||
|
||||
namespace inventory {
|
||||
|
||||
} /*inventory*/
|
||||
|
||||
namespace invtype {
|
||||
using namespace RoF2::invtype::enum_;
|
||||
|
||||
using RoF2::invtype::POSSESSIONS_SIZE;
|
||||
using RoF2::invtype::BANK_SIZE;
|
||||
using RoF2::invtype::SHARED_BANK_SIZE;
|
||||
using RoF2::invtype::TRADE_SIZE;
|
||||
using RoF2::invtype::WORLD_SIZE;
|
||||
using RoF2::invtype::LIMBO_SIZE;
|
||||
using RoF2::invtype::TRIBUTE_SIZE;
|
||||
using RoF2::invtype::TROPHY_TRIBUTE_SIZE;
|
||||
using RoF2::invtype::GUILD_TRIBUTE_SIZE;
|
||||
using RoF2::invtype::MERCHANT_SIZE;
|
||||
using RoF2::invtype::DELETED_SIZE;
|
||||
using RoF2::invtype::CORPSE_SIZE;
|
||||
using RoF2::invtype::BAZAAR_SIZE;
|
||||
using RoF2::invtype::INSPECT_SIZE;
|
||||
using RoF2::invtype::REAL_ESTATE_SIZE;
|
||||
using RoF2::invtype::VIEW_MOD_PC_SIZE;
|
||||
using RoF2::invtype::VIEW_MOD_BANK_SIZE;
|
||||
using RoF2::invtype::VIEW_MOD_SHARED_BANK_SIZE;
|
||||
using RoF2::invtype::VIEW_MOD_LIMBO_SIZE;
|
||||
using RoF2::invtype::ALT_STORAGE_SIZE;
|
||||
using RoF2::invtype::ARCHIVED_SIZE;
|
||||
using RoF2::invtype::MAIL_SIZE;
|
||||
using RoF2::invtype::GUILD_TROPHY_TRIBUTE_SIZE;
|
||||
using RoF2::invtype::KRONO_SIZE;
|
||||
using RoF2::invtype::OTHER_SIZE;
|
||||
|
||||
using Titanium::invtype::TRADE_NPC_SIZE;
|
||||
|
||||
using RoF2::invtype::TYPE_INVALID;
|
||||
using RoF2::invtype::TYPE_BEGIN;
|
||||
using RoF2::invtype::TYPE_END;
|
||||
using RoF2::invtype::TYPE_COUNT;
|
||||
|
||||
int16 GetInvTypeSize(int16 inv_type);
|
||||
using RoF2::invtype::GetInvTypeName;
|
||||
|
||||
} // namespace invtype
|
||||
|
||||
namespace popupresponse {
|
||||
const int32 SERVER_INTERNAL_USE_BASE = 2000000000;
|
||||
const int32 MOB_INFO_DISMISS = 2000000001;
|
||||
}
|
||||
|
||||
namespace invslot {
|
||||
using namespace RoF2::invslot::enum_;
|
||||
|
||||
using RoF2::invslot::SLOT_INVALID;
|
||||
using RoF2::invslot::SLOT_BEGIN;
|
||||
|
||||
using Titanium::invslot::SLOT_TRADESKILL_EXPERIMENT_COMBINE;
|
||||
|
||||
const int16 SLOT_AUGMENT_GENERIC_RETURN = 1001; // clients don't appear to use this method... (internal inventory return value)
|
||||
|
||||
using RoF2::invslot::POSSESSIONS_BEGIN;
|
||||
using RoF2::invslot::POSSESSIONS_END;
|
||||
using RoF2::invslot::POSSESSIONS_COUNT;
|
||||
|
||||
using RoF2::invslot::EQUIPMENT_BEGIN;
|
||||
using RoF2::invslot::EQUIPMENT_END;
|
||||
using RoF2::invslot::EQUIPMENT_COUNT;
|
||||
|
||||
using RoF2::invslot::GENERAL_BEGIN;
|
||||
using RoF2::invslot::GENERAL_END;
|
||||
using RoF2::invslot::GENERAL_COUNT;
|
||||
|
||||
using RoF2::invslot::BONUS_BEGIN;
|
||||
using RoF2::invslot::BONUS_STAT_END;
|
||||
using RoF2::invslot::BONUS_SKILL_END;
|
||||
|
||||
using Titanium::invslot::BANK_BEGIN;
|
||||
using SoF::invslot::BANK_END;
|
||||
|
||||
using Titanium::invslot::SHARED_BANK_BEGIN;
|
||||
using Titanium::invslot::SHARED_BANK_END;
|
||||
|
||||
using Titanium::invslot::TRADE_BEGIN;
|
||||
using Titanium::invslot::TRADE_END;
|
||||
|
||||
using Titanium::invslot::TRADE_NPC_END;
|
||||
|
||||
using Titanium::invslot::WORLD_BEGIN;
|
||||
using Titanium::invslot::WORLD_END;
|
||||
|
||||
using Titanium::invslot::TRIBUTE_BEGIN;
|
||||
using Titanium::invslot::TRIBUTE_END;
|
||||
|
||||
using Titanium::invslot::GUILD_TRIBUTE_BEGIN;
|
||||
using Titanium::invslot::GUILD_TRIBUTE_END;
|
||||
|
||||
const int16 CORPSE_BEGIN = invslot::slotGeneral1;
|
||||
const int16 CORPSE_END = CORPSE_BEGIN + invslot::slotCursor;
|
||||
|
||||
using RoF2::invslot::EQUIPMENT_BITMASK;
|
||||
using RoF2::invslot::GENERAL_BITMASK;
|
||||
using RoF2::invslot::CURSOR_BITMASK;
|
||||
using RoF2::invslot::POSSESSIONS_BITMASK;
|
||||
using RoF2::invslot::CORPSE_BITMASK;
|
||||
|
||||
using RoF2::invslot::GetInvPossessionsSlotName;
|
||||
using RoF2::invslot::GetInvSlotName;
|
||||
|
||||
} // namespace invslot
|
||||
|
||||
namespace invbag {
|
||||
using Titanium::invbag::SLOT_INVALID;
|
||||
using Titanium::invbag::SLOT_BEGIN;
|
||||
using Titanium::invbag::SLOT_END;
|
||||
using Titanium::invbag::SLOT_COUNT;
|
||||
|
||||
using Titanium::invbag::GENERAL_BAGS_BEGIN;
|
||||
const int16 GENERAL_BAGS_COUNT = invslot::GENERAL_COUNT * SLOT_COUNT;
|
||||
const int16 GENERAL_BAGS_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_COUNT) - 1;
|
||||
|
||||
const int16 GENERAL_BAGS_8_COUNT = 8 * SLOT_COUNT;
|
||||
const int16 GENERAL_BAGS_8_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_8_COUNT) - 1;
|
||||
|
||||
const int16 CURSOR_BAG_BEGIN = 351;
|
||||
const int16 CURSOR_BAG_COUNT = SLOT_COUNT;
|
||||
const int16 CURSOR_BAG_END = (CURSOR_BAG_BEGIN + CURSOR_BAG_COUNT) - 1;
|
||||
|
||||
using Titanium::invbag::BANK_BAGS_BEGIN;
|
||||
const int16 BANK_BAGS_COUNT = (invtype::BANK_SIZE * SLOT_COUNT);
|
||||
const int16 BANK_BAGS_END = (BANK_BAGS_BEGIN + BANK_BAGS_COUNT) - 1;
|
||||
|
||||
const int16 BANK_BAGS_16_COUNT = 16 * SLOT_COUNT;
|
||||
const int16 BANK_BAGS_16_END = (BANK_BAGS_BEGIN + BANK_BAGS_16_COUNT) - 1;
|
||||
|
||||
using Titanium::invbag::SHARED_BANK_BAGS_BEGIN;
|
||||
const int16 SHARED_BANK_BAGS_COUNT = invtype::SHARED_BANK_SIZE * SLOT_COUNT;
|
||||
const int16 SHARED_BANK_BAGS_END = (SHARED_BANK_BAGS_BEGIN + SHARED_BANK_BAGS_COUNT) - 1;
|
||||
|
||||
using Titanium::invbag::TRADE_BAGS_BEGIN;
|
||||
const int16 TRADE_BAGS_COUNT = invtype::TRADE_SIZE * SLOT_COUNT;
|
||||
const int16 TRADE_BAGS_END = (TRADE_BAGS_BEGIN + TRADE_BAGS_COUNT) - 1;
|
||||
|
||||
using Titanium::invbag::GetInvBagIndexName;
|
||||
|
||||
} // namespace invbag
|
||||
|
||||
namespace invaug {
|
||||
using RoF2::invaug::SOCKET_INVALID;
|
||||
using RoF2::invaug::SOCKET_BEGIN;
|
||||
using RoF2::invaug::SOCKET_END;
|
||||
using RoF2::invaug::SOCKET_COUNT;
|
||||
|
||||
using RoF2::invaug::GetInvAugIndexName;
|
||||
|
||||
} // namespace invaug
|
||||
|
||||
namespace constants {
|
||||
const EQEmu::versions::ClientVersion CHARACTER_CREATION_CLIENT = EQEmu::versions::ClientVersion::Titanium;
|
||||
|
||||
using RoF2::constants::EXPANSION;
|
||||
using RoF2::constants::EXPANSION_BIT;
|
||||
using RoF2::constants::EXPANSIONS_MASK;
|
||||
|
||||
using RoF2::constants::CHARACTER_CREATION_LIMIT;
|
||||
|
||||
const size_t SAY_LINK_OPENER_SIZE = 1;
|
||||
using RoF2::constants::SAY_LINK_BODY_SIZE;
|
||||
const size_t SAY_LINK_TEXT_SIZE = 256; // this may be varied until it breaks something (tested:374) - the others are constant
|
||||
const size_t SAY_LINK_CLOSER_SIZE = 1;
|
||||
const size_t SAY_LINK_MAXIMUM_SIZE = (SAY_LINK_OPENER_SIZE + SAY_LINK_BODY_SIZE + SAY_LINK_TEXT_SIZE + SAY_LINK_CLOSER_SIZE);
|
||||
|
||||
enum StanceType : int {
|
||||
stanceUnknown = 0,
|
||||
stancePassive,
|
||||
stanceBalanced,
|
||||
stanceEfficient,
|
||||
stanceReactive,
|
||||
stanceAggressive,
|
||||
stanceAssist,
|
||||
stanceBurn,
|
||||
stanceEfficient2,
|
||||
stanceBurnAE
|
||||
};
|
||||
|
||||
const char *GetStanceName(StanceType stance_type);
|
||||
int ConvertStanceTypeToIndex(StanceType stance_type);
|
||||
|
||||
const int STANCE_TYPE_FIRST = stancePassive;
|
||||
const int STANCE_TYPE_LAST = stanceBurnAE;
|
||||
const int STANCE_TYPE_COUNT = stanceBurnAE;
|
||||
|
||||
} /*constants*/
|
||||
|
||||
namespace profile {
|
||||
using RoF2::profile::BANDOLIERS_SIZE;
|
||||
using RoF2::profile::BANDOLIER_ITEM_COUNT;
|
||||
|
||||
using RoF2::profile::POTION_BELT_SIZE;
|
||||
|
||||
using RoF2::profile::SKILL_ARRAY_SIZE;
|
||||
|
||||
} // namespace profile
|
||||
|
||||
namespace behavior {
|
||||
using RoF2::behavior::CoinHasWeight;
|
||||
|
||||
} // namespace behavior
|
||||
|
||||
namespace spells {
|
||||
enum class CastingSlot : uint32 { // hybrid declaration
|
||||
Gem1 = 0,
|
||||
Gem2 = 1,
|
||||
Gem3 = 2,
|
||||
Gem4 = 3,
|
||||
Gem5 = 4,
|
||||
Gem6 = 5,
|
||||
Gem7 = 6,
|
||||
Gem8 = 7,
|
||||
Gem9 = 8,
|
||||
Gem10 = 9,
|
||||
Gem11 = 10,
|
||||
Gem12 = 11,
|
||||
MaxGems = 12,
|
||||
Ability = 20, // HT/LoH for Tit
|
||||
PotionBelt = 21, // Tit uses a different slot for PB
|
||||
Item = 22,
|
||||
Discipline = 23,
|
||||
AltAbility = 0xFF
|
||||
};
|
||||
|
||||
using RoF2::spells::SPELL_ID_MAX;
|
||||
using RoF2::spells::SPELLBOOK_SIZE;
|
||||
using UF::spells::SPELL_GEM_COUNT; // RoF+ clients define more than UF client..but, they are not valid beyond UF
|
||||
|
||||
using RoF2::spells::LONG_BUFFS;
|
||||
using RoF2::spells::SHORT_BUFFS;
|
||||
using RoF2::spells::DISC_BUFFS;
|
||||
using RoF2::spells::TOTAL_BUFFS;
|
||||
using RoF2::spells::NPC_BUFFS;
|
||||
using RoF2::spells::PET_BUFFS;
|
||||
using RoF2::spells::MERC_BUFFS;
|
||||
|
||||
} // namespace spells
|
||||
|
||||
namespace bug {
|
||||
enum CategoryID : uint32 {
|
||||
catOther = 0,
|
||||
catVideo,
|
||||
catAudio,
|
||||
catPathing,
|
||||
catQuest,
|
||||
catTradeskills,
|
||||
catSpellStacking,
|
||||
catDoorsPortals,
|
||||
catItems,
|
||||
catNPC,
|
||||
catDialogs,
|
||||
catLoNTCG,
|
||||
catMercenaries
|
||||
};
|
||||
|
||||
enum OptionalInfoFlag : uint32 {
|
||||
infoNoOptionalInfo = 0x0,
|
||||
infoCanDuplicate = 0x1,
|
||||
infoCrashBug = 0x2,
|
||||
infoTargetInfo = 0x4,
|
||||
infoCharacterFlags = 0x8,
|
||||
infoUnknownValue = 0xFFFFFFF0
|
||||
};
|
||||
|
||||
const char* CategoryIDToCategoryName(CategoryID category_id);
|
||||
CategoryID CategoryNameToCategoryID(const char* category_name);
|
||||
|
||||
} // namespace bug
|
||||
|
||||
enum WaypointStatus : int {
|
||||
RoamBoxPauseInProgress = -3,
|
||||
QuestControlNoGrid = -2,
|
||||
QuestControlGrid = -1
|
||||
};
|
||||
|
||||
} /*EQEmu*/
|
||||
|
||||
#endif /*COMMON_EMU_CONSTANTS_H*/
|
||||
|
||||
/* hack list to prevent circular references
|
||||
|
||||
eq_limits.h:EQEmu::inventory::LookupEntry::InventoryTypeSize[n];
|
||||
|
||||
*/
|
||||
@@ -1,18 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
@@ -1,128 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
|
||||
#ifndef COMMON_EMU_LIMITS_H
|
||||
#define COMMON_EMU_LIMITS_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
namespace EntityLimits
|
||||
{
|
||||
namespace NPC {
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace invtype {
|
||||
const int16 TRADE_SIZE = 4;
|
||||
|
||||
} // namespace invtype
|
||||
|
||||
} /*NPC*/
|
||||
|
||||
namespace NPCMerchant {
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace invtype {
|
||||
const int16 TRADE_SIZE = 4;
|
||||
|
||||
} // namespace invtype
|
||||
|
||||
} /*NPCMerchant*/
|
||||
|
||||
namespace Merc {
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace invtype {
|
||||
const int16 TRADE_SIZE = 4;
|
||||
|
||||
} // namespace invtype
|
||||
|
||||
} /*Merc*/
|
||||
|
||||
namespace Bot {
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace invtype {
|
||||
const int16 TRADE_SIZE = 8;
|
||||
|
||||
} // namespace invtype
|
||||
|
||||
namespace invslot {
|
||||
const uint64 EQUIPMENT_BITMASK = 0x00000000007FFFFF;
|
||||
const uint64 GENERAL_BITMASK = 0x0000000000000000;
|
||||
const uint64 CURSOR_BITMASK = 0x0000000000000000;
|
||||
const uint64 POSSESSIONS_BITMASK = (EQUIPMENT_BITMASK | GENERAL_BITMASK | CURSOR_BITMASK); // based on 34-slot count (RoF+)
|
||||
|
||||
} // namespace invslot
|
||||
|
||||
} /*Bot*/
|
||||
|
||||
namespace ClientPet {
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace invtype {
|
||||
const int16 TRADE_SIZE = 4;
|
||||
|
||||
} // namespace invtype
|
||||
|
||||
} /*Pet*/
|
||||
|
||||
namespace NPCPet {
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace invtype {
|
||||
const int16 TRADE_SIZE = 4;
|
||||
|
||||
} // namespace invtype
|
||||
|
||||
} /*Pet*/
|
||||
|
||||
namespace MercPet {
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace invtype {
|
||||
const int16 TRADE_SIZE = 4;
|
||||
|
||||
} // namespace invtype
|
||||
|
||||
} /*Pet*/
|
||||
|
||||
namespace BotPet {
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace invtype {
|
||||
const int16 TRADE_SIZE = 4;
|
||||
|
||||
} // namespace invtype
|
||||
|
||||
} /*Pet*/
|
||||
|
||||
}; /*EntityLimits*/
|
||||
|
||||
#endif /*COMMON_EMU_LIMITS_H*/
|
||||
@@ -1,38 +0,0 @@
|
||||
/* 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 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
|
||||
*/
|
||||
|
||||
#include "global_define.h"
|
||||
#include "emu_opcodes.h"
|
||||
|
||||
const char *OpcodeNames[_maxEmuOpcode+1] = {
|
||||
"OP_Unknown",
|
||||
|
||||
//a preprocessor hack so we dont have to maintain two lists
|
||||
#define N(x) #x
|
||||
#include "emu_oplist.h"
|
||||
#include "mail_oplist.h"
|
||||
#undef N
|
||||
|
||||
""
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/* 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 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
|
||||
*/
|
||||
#ifndef EMU_OPCODES_H
|
||||
#define EMU_OPCODES_H
|
||||
|
||||
//this is the highest opcode possibly used in the regular EQ protocol
|
||||
#define MAX_EQ_OPCODE 0xFFFF
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
the list of opcodes is in emu_oplist.h
|
||||
|
||||
we somewhat rely on the fact that we have more than 255 opcodes,
|
||||
so we know the enum type for the opcode defines must be at least
|
||||
16 bits, so we can use the protocol flags on them.
|
||||
|
||||
*/
|
||||
|
||||
typedef enum { //EQEmu internal opcodes list
|
||||
OP_Unknown=0,
|
||||
|
||||
//a preprocessor hack so we dont have to maintain two lists
|
||||
#define N(x) x
|
||||
#include "emu_oplist.h"
|
||||
#include "mail_oplist.h"
|
||||
#undef N
|
||||
|
||||
_maxEmuOpcode
|
||||
} EmuOpcode;
|
||||
|
||||
extern const char *OpcodeNames[_maxEmuOpcode+1];
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,567 +0,0 @@
|
||||
// system use
|
||||
N(OP_ExploreUnknown),
|
||||
// start (please add new opcodes in descending order and re-order any name changes where applicable)
|
||||
N(OP_0x0193),
|
||||
N(OP_0x0347),
|
||||
N(OP_AAAction),
|
||||
N(OP_AAExpUpdate),
|
||||
N(OP_AcceptNewTask),
|
||||
N(OP_AckPacket),
|
||||
N(OP_Action),
|
||||
N(OP_Action2),
|
||||
N(OP_AddNimbusEffect),
|
||||
N(OP_AdventureData),
|
||||
N(OP_AdventureDetails),
|
||||
N(OP_AdventureFinish),
|
||||
N(OP_AdventureInfo),
|
||||
N(OP_AdventureInfoRequest),
|
||||
N(OP_AdventureLeaderboardReply),
|
||||
N(OP_AdventureLeaderboardRequest),
|
||||
N(OP_AdventureMerchantPurchase),
|
||||
N(OP_AdventureMerchantRequest),
|
||||
N(OP_AdventureMerchantResponse),
|
||||
N(OP_AdventureMerchantSell),
|
||||
N(OP_AdventurePointsUpdate),
|
||||
N(OP_AdventureRequest),
|
||||
N(OP_AdventureStatsReply),
|
||||
N(OP_AdventureStatsRequest),
|
||||
N(OP_AdventureUpdate),
|
||||
N(OP_AggroMeterLockTarget),
|
||||
N(OP_AggroMeterTargetInfo),
|
||||
N(OP_AggroMeterUpdate),
|
||||
N(OP_AltCurrency),
|
||||
N(OP_AltCurrencyMerchantReply),
|
||||
N(OP_AltCurrencyMerchantRequest),
|
||||
N(OP_AltCurrencyPurchase),
|
||||
N(OP_AltCurrencyReclaim),
|
||||
N(OP_AltCurrencySell),
|
||||
N(OP_AltCurrencySellSelection),
|
||||
N(OP_Animation),
|
||||
N(OP_AnnoyingZoneUnknown),
|
||||
N(OP_ApplyPoison),
|
||||
N(OP_ApproveName),
|
||||
N(OP_ApproveWorld),
|
||||
N(OP_ApproveZone),
|
||||
N(OP_Assist),
|
||||
N(OP_AssistGroup),
|
||||
N(OP_AugmentInfo),
|
||||
N(OP_AugmentItem),
|
||||
N(OP_AutoAttack),
|
||||
N(OP_AutoAttack2),
|
||||
N(OP_AutoFire),
|
||||
N(OP_Bandolier),
|
||||
N(OP_BankerChange),
|
||||
N(OP_Barter),
|
||||
N(OP_Bazaar),
|
||||
N(OP_BazaarInspect),
|
||||
N(OP_BazaarSearch),
|
||||
N(OP_BecomeCorpse),
|
||||
N(OP_BecomeTrader),
|
||||
N(OP_Begging),
|
||||
N(OP_BeginCast),
|
||||
N(OP_Bind_Wound),
|
||||
N(OP_BlockedBuffs),
|
||||
N(OP_BoardBoat),
|
||||
N(OP_Buff),
|
||||
N(OP_BuffCreate),
|
||||
N(OP_BuffRemoveRequest),
|
||||
N(OP_Bug),
|
||||
N(OP_CameraEffect),
|
||||
N(OP_Camp),
|
||||
N(OP_CancelSneakHide),
|
||||
N(OP_CancelTask),
|
||||
N(OP_CancelTrade),
|
||||
N(OP_CastSpell),
|
||||
N(OP_ChangeSize),
|
||||
N(OP_ChannelMessage),
|
||||
N(OP_CharacterCreate),
|
||||
N(OP_CharacterCreateRequest),
|
||||
N(OP_CharInventory),
|
||||
N(OP_Charm),
|
||||
N(OP_ChatMessage),
|
||||
N(OP_ClearAA),
|
||||
N(OP_ClearBlockedBuffs),
|
||||
N(OP_ClearLeadershipAbilities),
|
||||
N(OP_ClearNPCMarks),
|
||||
N(OP_ClearObject),
|
||||
N(OP_ClearSurname),
|
||||
N(OP_ClickDoor),
|
||||
N(OP_ClickObject),
|
||||
N(OP_ClickObjectAction),
|
||||
N(OP_ClientError),
|
||||
N(OP_ClientReady),
|
||||
N(OP_ClientTimeStamp),
|
||||
N(OP_ClientUpdate),
|
||||
N(OP_CloseContainer),
|
||||
N(OP_CloseTributeMaster),
|
||||
N(OP_ColoredText),
|
||||
N(OP_CombatAbility),
|
||||
N(OP_Command),
|
||||
N(OP_CompletedTasks),
|
||||
N(OP_ConfirmDelete),
|
||||
N(OP_Consent),
|
||||
N(OP_ConsentDeny),
|
||||
N(OP_ConsentResponse),
|
||||
N(OP_Consider),
|
||||
N(OP_ConsiderCorpse),
|
||||
N(OP_Consume),
|
||||
N(OP_ControlBoat),
|
||||
N(OP_CorpseDrag),
|
||||
N(OP_CorpseDrop),
|
||||
N(OP_CrashDump),
|
||||
N(OP_CrystalCountUpdate),
|
||||
N(OP_CrystalCreate),
|
||||
N(OP_CrystalReclaim),
|
||||
N(OP_CustomTitles),
|
||||
N(OP_Damage),
|
||||
N(OP_Death),
|
||||
N(OP_DelegateAbility),
|
||||
N(OP_DeleteCharacter),
|
||||
N(OP_DeleteCharge),
|
||||
N(OP_DeleteItem),
|
||||
N(OP_DeletePetition),
|
||||
N(OP_DeleteSpawn),
|
||||
N(OP_DeleteSpell),
|
||||
N(OP_DenyResponse),
|
||||
N(OP_Disarm),
|
||||
N(OP_DisarmTraps),
|
||||
N(OP_DisciplineTimer),
|
||||
N(OP_DisciplineUpdate),
|
||||
N(OP_DiscordMerchantInventory),
|
||||
N(OP_DoGroupLeadershipAbility),
|
||||
N(OP_DuelResponse),
|
||||
N(OP_DuelResponse2),
|
||||
N(OP_DumpName),
|
||||
N(OP_Dye),
|
||||
N(OP_DynamicWall),
|
||||
N(OP_DzAddPlayer),
|
||||
N(OP_DzChooseZone),
|
||||
N(OP_DzCompass),
|
||||
N(OP_DzExpeditionEndsWarning),
|
||||
N(OP_DzExpeditionInfo),
|
||||
N(OP_DzExpeditionList),
|
||||
N(OP_DzJoinExpeditionConfirm),
|
||||
N(OP_DzJoinExpeditionReply),
|
||||
N(OP_DzLeaderStatus),
|
||||
N(OP_DzListTimers),
|
||||
N(OP_DzMakeLeader),
|
||||
N(OP_DzMemberList),
|
||||
N(OP_DzMemberStatus),
|
||||
N(OP_DzPlayerList),
|
||||
N(OP_DzQuit),
|
||||
N(OP_DzRemovePlayer),
|
||||
N(OP_DzSwapPlayer),
|
||||
N(OP_Emote),
|
||||
N(OP_EndLootRequest),
|
||||
N(OP_EnduranceUpdate),
|
||||
N(OP_EnterChat),
|
||||
N(OP_EnterWorld),
|
||||
N(OP_EnvDamage),
|
||||
N(OP_ExpansionInfo),
|
||||
N(OP_ExpUpdate),
|
||||
N(OP_FaceChange),
|
||||
N(OP_Feedback),
|
||||
N(OP_FeignDeath),
|
||||
N(OP_FellowshipUpdate),
|
||||
N(OP_FindPersonReply),
|
||||
N(OP_FindPersonRequest),
|
||||
N(OP_FinishTrade),
|
||||
N(OP_FinishWindow),
|
||||
N(OP_FinishWindow2),
|
||||
N(OP_Fishing),
|
||||
N(OP_Fling),
|
||||
N(OP_FloatListThing),
|
||||
N(OP_Forage),
|
||||
N(OP_ForceFindPerson),
|
||||
N(OP_FormattedMessage),
|
||||
N(OP_FriendsWho),
|
||||
N(OP_GetGuildMOTD),
|
||||
N(OP_GetGuildMOTDReply),
|
||||
N(OP_GetGuildsList),
|
||||
N(OP_GiveMoney),
|
||||
N(OP_GMApproval),
|
||||
N(OP_GMBecomeNPC),
|
||||
N(OP_GMDelCorpse),
|
||||
N(OP_GMEmoteZone),
|
||||
N(OP_GMEndTraining),
|
||||
N(OP_GMEndTrainingResponse),
|
||||
N(OP_GMFind),
|
||||
N(OP_GMGoto),
|
||||
N(OP_GMHideMe),
|
||||
N(OP_GMKick),
|
||||
N(OP_GMKill),
|
||||
N(OP_GMLastName),
|
||||
N(OP_GMNameChange),
|
||||
N(OP_GMSearchCorpse),
|
||||
N(OP_GMServers),
|
||||
N(OP_GMSummon),
|
||||
N(OP_GMToggle),
|
||||
N(OP_GMTraining),
|
||||
N(OP_GMTrainSkill),
|
||||
N(OP_GMTrainSkillConfirm),
|
||||
N(OP_GMZoneRequest),
|
||||
N(OP_GMZoneRequest2),
|
||||
N(OP_GroundSpawn),
|
||||
N(OP_GroupAcknowledge),
|
||||
N(OP_GroupCancelInvite),
|
||||
N(OP_GroupDelete),
|
||||
N(OP_GroupDisband),
|
||||
N(OP_GroupDisbandOther),
|
||||
N(OP_GroupDisbandYou),
|
||||
N(OP_GroupFollow),
|
||||
N(OP_GroupFollow2),
|
||||
N(OP_GroupInvite),
|
||||
N(OP_GroupInvite2),
|
||||
N(OP_GroupLeaderChange),
|
||||
N(OP_GroupLeadershipAAUpdate),
|
||||
N(OP_GroupMakeLeader),
|
||||
N(OP_GroupMentor),
|
||||
N(OP_GroupRoles),
|
||||
N(OP_GroupUpdate),
|
||||
N(OP_GroupUpdateB),
|
||||
N(OP_GroupUpdateLeaderAA),
|
||||
N(OP_GuildBank),
|
||||
N(OP_GuildBankItemList),
|
||||
N(OP_GuildCreate),
|
||||
N(OP_GuildDelete),
|
||||
N(OP_GuildDemote),
|
||||
N(OP_GuildInvite),
|
||||
N(OP_GuildInviteAccept),
|
||||
N(OP_GuildLeader),
|
||||
N(OP_GuildManageAdd),
|
||||
N(OP_GuildManageBanker),
|
||||
N(OP_GuildManageRemove),
|
||||
N(OP_GuildManageStatus),
|
||||
N(OP_GuildMemberLevelUpdate),
|
||||
N(OP_GuildMemberList),
|
||||
N(OP_GuildMemberUpdate),
|
||||
N(OP_GuildMOTD),
|
||||
N(OP_GuildPeace),
|
||||
N(OP_GuildPromote),
|
||||
N(OP_GuildPublicNote),
|
||||
N(OP_GuildRemove),
|
||||
N(OP_GuildsList),
|
||||
N(OP_GuildStatus),
|
||||
N(OP_GuildTributeInfo),
|
||||
N(OP_GuildUpdateURLAndChannel),
|
||||
N(OP_GuildWar),
|
||||
N(OP_Heartbeat),
|
||||
N(OP_Hide),
|
||||
N(OP_HideCorpse),
|
||||
N(OP_HPUpdate),
|
||||
N(OP_Illusion),
|
||||
N(OP_IncreaseStats),
|
||||
N(OP_InitialHPUpdate),
|
||||
N(OP_InitialMobHealth),
|
||||
N(OP_InspectAnswer),
|
||||
N(OP_InspectBuffs),
|
||||
N(OP_InspectMessageUpdate),
|
||||
N(OP_InspectRequest),
|
||||
N(OP_InstillDoubt),
|
||||
N(OP_InterruptCast),
|
||||
N(OP_ItemLinkClick),
|
||||
N(OP_ItemLinkResponse),
|
||||
N(OP_ItemLinkText),
|
||||
N(OP_ItemName),
|
||||
N(OP_ItemPacket),
|
||||
N(OP_ItemPreview),
|
||||
N(OP_ItemRecastDelay),
|
||||
N(OP_ItemVerifyReply),
|
||||
N(OP_ItemVerifyRequest),
|
||||
N(OP_ItemViewUnknown),
|
||||
N(OP_Jump),
|
||||
N(OP_KeyRing),
|
||||
N(OP_KnowledgeBase),
|
||||
N(OP_LDoNButton),
|
||||
N(OP_LDoNDisarmTraps),
|
||||
N(OP_LDoNInspect),
|
||||
N(OP_LDoNOpen),
|
||||
N(OP_LDoNPickLock),
|
||||
N(OP_LDoNSenseTraps),
|
||||
N(OP_LeadershipExpToggle),
|
||||
N(OP_LeadershipExpUpdate),
|
||||
N(OP_LeaveAdventure),
|
||||
N(OP_LeaveBoat),
|
||||
N(OP_LevelAppearance),
|
||||
N(OP_LevelUpdate),
|
||||
N(OP_LFGAppearance),
|
||||
N(OP_LFGCommand),
|
||||
N(OP_LFGGetMatchesRequest),
|
||||
N(OP_LFGGetMatchesResponse),
|
||||
N(OP_LFGResponse),
|
||||
N(OP_LFGuild),
|
||||
N(OP_LFPCommand),
|
||||
N(OP_LFPGetMatchesRequest),
|
||||
N(OP_LFPGetMatchesResponse),
|
||||
N(OP_LinkedReuse),
|
||||
N(OP_LoadSpellSet),
|
||||
N(OP_LocInfo),
|
||||
N(OP_LockoutTimerInfo),
|
||||
N(OP_Login),
|
||||
N(OP_LoginAccepted),
|
||||
N(OP_LoginComplete),
|
||||
N(OP_LoginUnknown1),
|
||||
N(OP_LoginUnknown2),
|
||||
N(OP_Logout),
|
||||
N(OP_LogoutReply),
|
||||
N(OP_LogServer),
|
||||
N(OP_LootComplete),
|
||||
N(OP_LootItem),
|
||||
N(OP_LootRequest),
|
||||
N(OP_ManaChange),
|
||||
N(OP_ManaUpdate),
|
||||
N(OP_MarkNPC),
|
||||
N(OP_Marquee),
|
||||
N(OP_MemorizeSpell),
|
||||
N(OP_Mend),
|
||||
N(OP_MendHPUpdate),
|
||||
N(OP_MercenaryAssign),
|
||||
N(OP_MercenaryCommand),
|
||||
N(OP_MercenaryDataRequest),
|
||||
N(OP_MercenaryDataResponse),
|
||||
N(OP_MercenaryDataUpdate),
|
||||
N(OP_MercenaryDataUpdateRequest),
|
||||
N(OP_MercenaryDismiss),
|
||||
N(OP_MercenaryHire),
|
||||
N(OP_MercenarySuspendRequest),
|
||||
N(OP_MercenarySuspendResponse),
|
||||
N(OP_MercenaryTimer),
|
||||
N(OP_MercenaryTimerRequest),
|
||||
N(OP_MercenaryUnknown1),
|
||||
N(OP_MercenaryUnsuspendResponse),
|
||||
N(OP_MobEnduranceUpdate),
|
||||
N(OP_MobHealth),
|
||||
N(OP_MobManaUpdate),
|
||||
N(OP_MobRename),
|
||||
N(OP_MobUpdate), // not used anymore, here for lecacy reasons (eqextractor)
|
||||
N(OP_MoneyOnCorpse),
|
||||
N(OP_MoneyUpdate),
|
||||
N(OP_MOTD),
|
||||
N(OP_MoveCoin),
|
||||
N(OP_MoveDoor),
|
||||
N(OP_MoveItem),
|
||||
N(OP_MoveMultipleItems),
|
||||
N(OP_MoveLogDisregard),
|
||||
N(OP_MoveLogRequest),
|
||||
N(OP_MultiLineMsg),
|
||||
N(OP_NewSpawn),
|
||||
N(OP_NewTitlesAvailable),
|
||||
N(OP_NewZone),
|
||||
N(OP_OnLevelMessage),
|
||||
N(OP_OpenContainer),
|
||||
N(OP_OpenDiscordMerchant),
|
||||
N(OP_OpenGuildTributeMaster),
|
||||
N(OP_OpenInventory),
|
||||
N(OP_OpenNewTasksWindow),
|
||||
N(OP_OpenTributeMaster),
|
||||
N(OP_PDeletePetition),
|
||||
N(OP_PetBuffWindow),
|
||||
N(OP_PetCommands),
|
||||
N(OP_PetCommandState),
|
||||
N(OP_PetHoTT),
|
||||
N(OP_Petition),
|
||||
N(OP_PetitionBug),
|
||||
N(OP_PetitionCheckIn),
|
||||
N(OP_PetitionCheckout),
|
||||
N(OP_PetitionCheckout2),
|
||||
N(OP_PetitionDelete),
|
||||
N(OP_PetitionQue),
|
||||
N(OP_PetitionRefresh),
|
||||
N(OP_PetitionResolve),
|
||||
N(OP_PetitionSearch),
|
||||
N(OP_PetitionSearchResults),
|
||||
N(OP_PetitionSearchText),
|
||||
N(OP_PetitionUnCheckout),
|
||||
N(OP_PetitionUpdate),
|
||||
N(OP_PickPocket),
|
||||
N(OP_PlayerProfile),
|
||||
N(OP_PlayerStateAdd),
|
||||
N(OP_PlayerStateRemove),
|
||||
N(OP_PlayEverquestRequest),
|
||||
N(OP_PlayEverquestResponse),
|
||||
N(OP_PlayMP3),
|
||||
N(OP_Poll),
|
||||
N(OP_PollResponse),
|
||||
N(OP_PopupResponse),
|
||||
N(OP_PostEnterWorld), //this is really OP_WorldAccessGranted
|
||||
N(OP_PotionBelt),
|
||||
N(OP_PreLogoutReply),
|
||||
N(OP_PurchaseLeadershipAA),
|
||||
N(OP_PVPLeaderBoardDetailsReply),
|
||||
N(OP_PVPLeaderBoardDetailsRequest),
|
||||
N(OP_PVPLeaderBoardReply),
|
||||
N(OP_PVPLeaderBoardRequest),
|
||||
N(OP_PVPStats),
|
||||
N(OP_QueryResponseThing),
|
||||
N(OP_QueryUCSServerStatus),
|
||||
N(OP_RaidInvite),
|
||||
N(OP_RaidJoin),
|
||||
N(OP_RaidUpdate),
|
||||
N(OP_RandomNameGenerator),
|
||||
N(OP_RandomReply),
|
||||
N(OP_RandomReq),
|
||||
N(OP_ReadBook),
|
||||
N(OP_RecipeAutoCombine),
|
||||
N(OP_RecipeDetails),
|
||||
N(OP_RecipeReply),
|
||||
N(OP_RecipesFavorite),
|
||||
N(OP_RecipesSearch),
|
||||
N(OP_ReclaimCrystals),
|
||||
N(OP_ReloadUI),
|
||||
N(OP_RemoveAllDoors),
|
||||
N(OP_RemoveBlockedBuffs),
|
||||
N(OP_RemoveNimbusEffect),
|
||||
N(OP_RemoveTrap),
|
||||
N(OP_Report),
|
||||
N(OP_ReqClientSpawn),
|
||||
N(OP_ReqNewZone),
|
||||
N(OP_RequestClientZoneChange),
|
||||
N(OP_RequestDuel),
|
||||
N(OP_RequestKnowledgeBase),
|
||||
N(OP_RequestTitles),
|
||||
N(OP_RespawnWindow),
|
||||
N(OP_RespondAA),
|
||||
N(OP_RestState),
|
||||
N(OP_Rewind),
|
||||
N(OP_RezzAnswer),
|
||||
N(OP_RezzComplete),
|
||||
N(OP_RezzRequest),
|
||||
N(OP_Sacrifice),
|
||||
N(OP_SafeFallSuccess),
|
||||
N(OP_SafePoint),
|
||||
N(OP_Save),
|
||||
N(OP_SaveOnZoneReq),
|
||||
N(OP_SelectTribute),
|
||||
N(OP_SendAAStats),
|
||||
N(OP_SendAATable),
|
||||
N(OP_SendCharInfo),
|
||||
N(OP_SendExpZonein),
|
||||
N(OP_SendFindableNPCs),
|
||||
N(OP_SendGuildTributes),
|
||||
N(OP_SendLoginInfo),
|
||||
N(OP_SendMaxCharacters),
|
||||
N(OP_SendMembership),
|
||||
N(OP_SendMembershipDetails),
|
||||
N(OP_SendSystemStats),
|
||||
N(OP_SendTitleList),
|
||||
N(OP_SendTributes),
|
||||
N(OP_SendZonepoints),
|
||||
N(OP_SenseHeading),
|
||||
N(OP_SenseTraps),
|
||||
N(OP_ServerListRequest),
|
||||
N(OP_ServerListResponse),
|
||||
N(OP_SessionReady),
|
||||
N(OP_SetChatServer),
|
||||
N(OP_SetChatServer2),
|
||||
N(OP_SetGroupTarget),
|
||||
N(OP_SetGuildMOTD),
|
||||
N(OP_SetGuildRank),
|
||||
N(OP_SetRunMode),
|
||||
N(OP_SetServerFilter),
|
||||
N(OP_SetStartCity),
|
||||
N(OP_SetTitle),
|
||||
N(OP_SetTitleReply),
|
||||
N(OP_Shielding),
|
||||
N(OP_ShopDelItem),
|
||||
N(OP_ShopEnd),
|
||||
N(OP_ShopEndConfirm),
|
||||
N(OP_ShopItem),
|
||||
N(OP_ShopPlayerBuy),
|
||||
N(OP_ShopPlayerSell),
|
||||
N(OP_ShopRequest),
|
||||
N(OP_SimpleMessage),
|
||||
N(OP_SkillUpdate),
|
||||
N(OP_Sneak),
|
||||
N(OP_Some3ByteHPUpdate),
|
||||
N(OP_Some6ByteHPUpdate),
|
||||
N(OP_SomeItemPacketMaybe),
|
||||
N(OP_Sound),
|
||||
N(OP_SpawnAppearance),
|
||||
N(OP_SpawnDoor),
|
||||
N(OP_SpawnPositionUpdate),
|
||||
N(OP_SpecialMesg),
|
||||
N(OP_SpellEffect),
|
||||
N(OP_Split),
|
||||
N(OP_Stamina),
|
||||
N(OP_Stun),
|
||||
N(OP_Surname),
|
||||
N(OP_SwapSpell),
|
||||
N(OP_TargetBuffs),
|
||||
N(OP_TargetCommand),
|
||||
N(OP_TargetHoTT),
|
||||
N(OP_TargetMouse),
|
||||
N(OP_TargetReject),
|
||||
N(OP_TaskActivity),
|
||||
N(OP_TaskActivityComplete),
|
||||
N(OP_TaskDescription),
|
||||
N(OP_TaskHistoryReply),
|
||||
N(OP_TaskHistoryRequest),
|
||||
N(OP_TaskMemberList),
|
||||
N(OP_Taunt),
|
||||
N(OP_TestBuff),
|
||||
N(OP_TGB),
|
||||
N(OP_TimeOfDay),
|
||||
N(OP_Track),
|
||||
N(OP_TrackTarget),
|
||||
N(OP_TrackUnknown),
|
||||
N(OP_TradeAcceptClick),
|
||||
N(OP_TradeBusy),
|
||||
N(OP_TradeCoins),
|
||||
N(OP_TradeMoneyUpdate),
|
||||
N(OP_Trader),
|
||||
N(OP_TraderBuy),
|
||||
N(OP_TraderDelItem),
|
||||
N(OP_TradeRequest),
|
||||
N(OP_TradeRequestAck),
|
||||
N(OP_TraderItemUpdate),
|
||||
N(OP_TraderShop),
|
||||
N(OP_TradeSkillCombine),
|
||||
N(OP_Translocate),
|
||||
N(OP_TributeInfo),
|
||||
N(OP_TributeItem),
|
||||
N(OP_TributeMoney),
|
||||
N(OP_TributeNPC),
|
||||
N(OP_TributePointUpdate),
|
||||
N(OP_TributeTimer),
|
||||
N(OP_TributeToggle),
|
||||
N(OP_TributeUpdate),
|
||||
N(OP_Untargetable),
|
||||
N(OP_UpdateAA),
|
||||
N(OP_UpdateAura),
|
||||
N(OP_UpdateLeadershipAA),
|
||||
N(OP_VetClaimReply),
|
||||
N(OP_VetClaimRequest),
|
||||
N(OP_VetRewardsAvaliable),
|
||||
N(OP_VoiceMacroIn),
|
||||
N(OP_VoiceMacroOut),
|
||||
N(OP_WeaponEquip1),
|
||||
N(OP_WearChange),
|
||||
N(OP_Weather),
|
||||
N(OP_Weblink),
|
||||
N(OP_WhoAllRequest),
|
||||
N(OP_WhoAllResponse),
|
||||
N(OP_World_Client_CRC1),
|
||||
N(OP_World_Client_CRC2),
|
||||
N(OP_WorldClientReady),
|
||||
N(OP_WorldComplete),
|
||||
N(OP_WorldLogout),
|
||||
N(OP_WorldObjectsSent),
|
||||
N(OP_WorldUnknown001),
|
||||
N(OP_XTargetAutoAddHaters),
|
||||
N(OP_XTargetOpen),
|
||||
N(OP_XTargetOpenResponse),
|
||||
N(OP_XTargetRequest),
|
||||
N(OP_XTargetResponse),
|
||||
N(OP_YellForHelp),
|
||||
N(OP_ZoneChange),
|
||||
N(OP_ZoneComplete),
|
||||
N(OP_ZoneEntry),
|
||||
N(OP_ZoneGuildList),
|
||||
N(OP_ZoneInUnknown),
|
||||
N(OP_ZonePlayerToBind),
|
||||
N(OP_ZoneServerInfo),
|
||||
N(OP_ZoneServerReady),
|
||||
N(OP_ZoneSpawns),
|
||||
N(OP_ZoneUnavail),
|
||||
N(OP_ResetAA),
|
||||
// mail and chat opcodes located in ../mail_oplist.h
|
||||
@@ -1,558 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
|
||||
#include "emu_versions.h"
|
||||
#include "emu_constants.h"
|
||||
|
||||
|
||||
bool EQEmu::versions::IsValidClientVersion(ClientVersion client_version)
|
||||
{
|
||||
if (client_version <= ClientVersion::Unknown || client_version > LastClientVersion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EQEmu::versions::ClientVersion EQEmu::versions::ValidateClientVersion(ClientVersion client_version)
|
||||
{
|
||||
if (client_version <= ClientVersion::Unknown || client_version > LastClientVersion)
|
||||
return ClientVersion::Unknown;
|
||||
|
||||
return client_version;
|
||||
}
|
||||
|
||||
const char* EQEmu::versions::ClientVersionName(ClientVersion client_version)
|
||||
{
|
||||
switch (client_version) {
|
||||
case ClientVersion::Unknown:
|
||||
return "Unknown Version";
|
||||
case ClientVersion::Client62:
|
||||
return "Client 6.2";
|
||||
case ClientVersion::Titanium:
|
||||
return "Titanium";
|
||||
case ClientVersion::SoF:
|
||||
return "SoF";
|
||||
case ClientVersion::SoD:
|
||||
return "SoD";
|
||||
case ClientVersion::UF:
|
||||
return "UF";
|
||||
case ClientVersion::RoF:
|
||||
return "RoF";
|
||||
case ClientVersion::RoF2:
|
||||
return "RoF2";
|
||||
default:
|
||||
return "Invalid Version";
|
||||
};
|
||||
}
|
||||
|
||||
uint32 EQEmu::versions::ConvertClientVersionToClientVersionBit(ClientVersion client_version)
|
||||
{
|
||||
switch (client_version) {
|
||||
case ClientVersion::Titanium:
|
||||
return bitTitanium;
|
||||
case ClientVersion::SoF:
|
||||
return bitSoF;
|
||||
case ClientVersion::SoD:
|
||||
return bitSoD;
|
||||
case ClientVersion::UF:
|
||||
return bitUF;
|
||||
case ClientVersion::RoF:
|
||||
return bitRoF;
|
||||
case ClientVersion::RoF2:
|
||||
return bitRoF2;
|
||||
default:
|
||||
return bitUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::ClientVersion EQEmu::versions::ConvertClientVersionBitToClientVersion(uint32 client_version_bit)
|
||||
{
|
||||
switch (client_version_bit) {
|
||||
case ((uint32)1 << (static_cast<unsigned int>(ClientVersion::Titanium) - 1)) :
|
||||
return ClientVersion::Titanium;
|
||||
case ((uint32)1 << (static_cast<unsigned int>(ClientVersion::SoF) - 1)) :
|
||||
return ClientVersion::SoF;
|
||||
case ((uint32)1 << (static_cast<unsigned int>(ClientVersion::SoD) - 1)) :
|
||||
return ClientVersion::SoD;
|
||||
case ((uint32)1 << (static_cast<unsigned int>(ClientVersion::UF) - 1)) :
|
||||
return ClientVersion::UF;
|
||||
case ((uint32)1 << (static_cast<unsigned int>(ClientVersion::RoF) - 1)) :
|
||||
return ClientVersion::RoF;
|
||||
case ((uint32)1 << (static_cast<unsigned int>(ClientVersion::RoF2) - 1)) :
|
||||
return ClientVersion::RoF2;
|
||||
default:
|
||||
return ClientVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
bool EQEmu::versions::IsValidMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (mob_version <= MobVersion::Unknown || mob_version > LastMobVersion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::versions::IsValidPCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (mob_version <= MobVersion::Unknown || mob_version > LastPCMobVersion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::versions::IsValidNonPCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (mob_version <= LastPCMobVersion || mob_version > LastNonPCMobVersion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmu::versions::IsValidOfflinePCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (mob_version <= LastNonPCMobVersion || mob_version > LastOfflinePCMobVersion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ValidateMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (mob_version <= MobVersion::Unknown || mob_version > LastMobVersion)
|
||||
return MobVersion::Unknown;
|
||||
|
||||
return mob_version;
|
||||
}
|
||||
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ValidatePCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (mob_version <= MobVersion::Unknown || mob_version > LastPCMobVersion)
|
||||
return MobVersion::Unknown;
|
||||
|
||||
return mob_version;
|
||||
}
|
||||
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ValidateNonPCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (mob_version <= LastPCMobVersion || mob_version > LastNonPCMobVersion)
|
||||
return MobVersion::Unknown;
|
||||
|
||||
return mob_version;
|
||||
}
|
||||
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ValidateOfflinePCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
if (mob_version <= LastNonPCMobVersion || mob_version > LastOfflinePCMobVersion)
|
||||
return MobVersion::Unknown;
|
||||
|
||||
return mob_version;
|
||||
}
|
||||
|
||||
const char* EQEmu::versions::MobVersionName(MobVersion mob_version)
|
||||
{
|
||||
switch (mob_version) {
|
||||
case MobVersion::Unknown:
|
||||
return "Unknown Version";
|
||||
case MobVersion::Client62:
|
||||
return "Client 6.2";
|
||||
case MobVersion::Titanium:
|
||||
return "Titanium";
|
||||
case MobVersion::SoF:
|
||||
return "SoF";
|
||||
case MobVersion::SoD:
|
||||
return "SoD";
|
||||
case MobVersion::UF:
|
||||
return "UF";
|
||||
case MobVersion::RoF:
|
||||
return "RoF";
|
||||
case MobVersion::RoF2:
|
||||
return "RoF2";
|
||||
case MobVersion::NPC:
|
||||
return "NPC";
|
||||
case MobVersion::NPCMerchant:
|
||||
return "NPC Merchant";
|
||||
case MobVersion::Merc:
|
||||
return "Merc";
|
||||
case MobVersion::Bot:
|
||||
return "Bot";
|
||||
case MobVersion::ClientPet:
|
||||
return "Client Pet";
|
||||
case MobVersion::NPCPet:
|
||||
return "NPC Pet";
|
||||
case MobVersion::MercPet:
|
||||
return "Merc Pet";
|
||||
case MobVersion::BotPet:
|
||||
return "Bot Pet";
|
||||
case MobVersion::OfflineTitanium:
|
||||
return "Offline Titanium";
|
||||
case MobVersion::OfflineSoF:
|
||||
return "Offline SoF";
|
||||
case MobVersion::OfflineSoD:
|
||||
return "Offline SoD";
|
||||
case MobVersion::OfflineUF:
|
||||
return "Offline UF";
|
||||
case MobVersion::OfflineRoF:
|
||||
return "Offline RoF";
|
||||
case MobVersion::OfflineRoF2:
|
||||
return "Offline RoF2";
|
||||
default:
|
||||
return "Invalid Version";
|
||||
};
|
||||
}
|
||||
|
||||
EQEmu::versions::ClientVersion EQEmu::versions::ConvertMobVersionToClientVersion(MobVersion mob_version)
|
||||
{
|
||||
switch (mob_version) {
|
||||
case MobVersion::Unknown:
|
||||
case MobVersion::Client62:
|
||||
return ClientVersion::Unknown;
|
||||
case MobVersion::Titanium:
|
||||
return ClientVersion::Titanium;
|
||||
case MobVersion::SoF:
|
||||
return ClientVersion::SoF;
|
||||
case MobVersion::SoD:
|
||||
return ClientVersion::SoD;
|
||||
case MobVersion::UF:
|
||||
return ClientVersion::UF;
|
||||
case MobVersion::RoF:
|
||||
return ClientVersion::RoF;
|
||||
case MobVersion::RoF2:
|
||||
return ClientVersion::RoF2;
|
||||
default:
|
||||
return ClientVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ConvertClientVersionToMobVersion(ClientVersion client_version)
|
||||
{
|
||||
switch (client_version) {
|
||||
case ClientVersion::Unknown:
|
||||
case ClientVersion::Client62:
|
||||
return MobVersion::Unknown;
|
||||
case ClientVersion::Titanium:
|
||||
return MobVersion::Titanium;
|
||||
case ClientVersion::SoF:
|
||||
return MobVersion::SoF;
|
||||
case ClientVersion::SoD:
|
||||
return MobVersion::SoD;
|
||||
case ClientVersion::UF:
|
||||
return MobVersion::UF;
|
||||
case ClientVersion::RoF:
|
||||
return MobVersion::RoF;
|
||||
case ClientVersion::RoF2:
|
||||
return MobVersion::RoF2;
|
||||
default:
|
||||
return MobVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ConvertPCMobVersionToOfflinePCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
switch (mob_version) {
|
||||
case MobVersion::Titanium:
|
||||
return MobVersion::OfflineTitanium;
|
||||
case MobVersion::SoF:
|
||||
return MobVersion::OfflineSoF;
|
||||
case MobVersion::SoD:
|
||||
return MobVersion::OfflineSoD;
|
||||
case MobVersion::UF:
|
||||
return MobVersion::OfflineUF;
|
||||
case MobVersion::RoF:
|
||||
return MobVersion::OfflineRoF;
|
||||
case MobVersion::RoF2:
|
||||
return MobVersion::OfflineRoF2;
|
||||
default:
|
||||
return MobVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ConvertOfflinePCMobVersionToPCMobVersion(MobVersion mob_version)
|
||||
{
|
||||
switch (mob_version) {
|
||||
case MobVersion::OfflineTitanium:
|
||||
return MobVersion::Titanium;
|
||||
case MobVersion::OfflineSoF:
|
||||
return MobVersion::SoF;
|
||||
case MobVersion::OfflineSoD:
|
||||
return MobVersion::SoD;
|
||||
case MobVersion::OfflineUF:
|
||||
return MobVersion::UF;
|
||||
case MobVersion::OfflineRoF:
|
||||
return MobVersion::RoF;
|
||||
case MobVersion::OfflineRoF2:
|
||||
return MobVersion::RoF2;
|
||||
default:
|
||||
return MobVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::ClientVersion EQEmu::versions::ConvertOfflinePCMobVersionToClientVersion(MobVersion mob_version)
|
||||
{
|
||||
switch (mob_version) {
|
||||
case MobVersion::OfflineTitanium:
|
||||
return ClientVersion::Titanium;
|
||||
case MobVersion::OfflineSoF:
|
||||
return ClientVersion::SoF;
|
||||
case MobVersion::OfflineSoD:
|
||||
return ClientVersion::SoD;
|
||||
case MobVersion::OfflineUF:
|
||||
return ClientVersion::UF;
|
||||
case MobVersion::OfflineRoF:
|
||||
return ClientVersion::RoF;
|
||||
case MobVersion::OfflineRoF2:
|
||||
return ClientVersion::RoF2;
|
||||
default:
|
||||
return ClientVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::versions::MobVersion EQEmu::versions::ConvertClientVersionToOfflinePCMobVersion(ClientVersion client_version)
|
||||
{
|
||||
switch (client_version) {
|
||||
case ClientVersion::Titanium:
|
||||
return MobVersion::OfflineTitanium;
|
||||
case ClientVersion::SoF:
|
||||
return MobVersion::OfflineSoF;
|
||||
case ClientVersion::SoD:
|
||||
return MobVersion::OfflineSoD;
|
||||
case ClientVersion::UF:
|
||||
return MobVersion::OfflineUF;
|
||||
case ClientVersion::RoF:
|
||||
return MobVersion::OfflineRoF;
|
||||
case ClientVersion::RoF2:
|
||||
return MobVersion::OfflineRoF2;
|
||||
default:
|
||||
return MobVersion::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
const char* EQEmu::expansions::ExpansionName(Expansion expansion)
|
||||
{
|
||||
switch (expansion) {
|
||||
case Expansion::EverQuest:
|
||||
return "EverQuest";
|
||||
case Expansion::RoK:
|
||||
return "The Ruins of Kunark";
|
||||
case Expansion::SoV:
|
||||
return "The Scars of Velious";
|
||||
case Expansion::SoL:
|
||||
return "The Shadows of Luclin";
|
||||
case Expansion::PoP:
|
||||
return "The Planes of Power";
|
||||
case Expansion::LoY:
|
||||
return "The Legacy of Ykesha";
|
||||
case Expansion::LDoN:
|
||||
return "Lost Dungeons of Norrath";
|
||||
case Expansion::GoD:
|
||||
return "Gates of Discord";
|
||||
case Expansion::OoW:
|
||||
return "Omens of War";
|
||||
case Expansion::DoN:
|
||||
return "Dragons of Norrath";
|
||||
case Expansion::DoD:
|
||||
return "Depths of Darkhollow";
|
||||
case Expansion::PoR:
|
||||
return "Prophecy of Ro";
|
||||
case Expansion::TSS:
|
||||
return "The Serpent's Spine";
|
||||
case Expansion::TBS:
|
||||
return "The Buried Sea";
|
||||
case Expansion::SoF:
|
||||
return "Secrets of Faydwer";
|
||||
case Expansion::SoD:
|
||||
return "Seeds of Destruction";
|
||||
case Expansion::UF:
|
||||
return "Underfoot";
|
||||
case Expansion::HoT:
|
||||
return "House of Thule";
|
||||
case Expansion::VoA:
|
||||
return "Veil of Alaris";
|
||||
case Expansion::RoF:
|
||||
return "Rain of Fear";
|
||||
case Expansion::CotF:
|
||||
return "Call of the Forsaken";
|
||||
default:
|
||||
return "Invalid Expansion";
|
||||
}
|
||||
}
|
||||
|
||||
const char* EQEmu::expansions::ExpansionName(uint32 expansion_bit)
|
||||
{
|
||||
return ExpansionName(ConvertExpansionBitToExpansion(expansion_bit));
|
||||
}
|
||||
|
||||
uint32 EQEmu::expansions::ConvertExpansionToExpansionBit(Expansion expansion)
|
||||
{
|
||||
switch (expansion) {
|
||||
case Expansion::RoK:
|
||||
return bitRoK;
|
||||
case Expansion::SoV:
|
||||
return bitSoV;
|
||||
case Expansion::SoL:
|
||||
return bitSoL;
|
||||
case Expansion::PoP:
|
||||
return bitPoP;
|
||||
case Expansion::LoY:
|
||||
return bitLoY;
|
||||
case Expansion::LDoN:
|
||||
return bitLDoN;
|
||||
case Expansion::GoD:
|
||||
return bitGoD;
|
||||
case Expansion::OoW:
|
||||
return bitOoW;
|
||||
case Expansion::DoN:
|
||||
return bitDoN;
|
||||
case Expansion::DoD:
|
||||
return bitDoD;
|
||||
case Expansion::PoR:
|
||||
return bitPoR;
|
||||
case Expansion::TSS:
|
||||
return bitTSS;
|
||||
case Expansion::TBS:
|
||||
return bitTBS;
|
||||
case Expansion::SoF:
|
||||
return bitSoF;
|
||||
case Expansion::SoD:
|
||||
return bitSoD;
|
||||
case Expansion::UF:
|
||||
return bitUF;
|
||||
case Expansion::HoT:
|
||||
return bitHoT;
|
||||
case Expansion::VoA:
|
||||
return bitVoA;
|
||||
case Expansion::RoF:
|
||||
return bitRoF;
|
||||
case Expansion::CotF:
|
||||
return bitCotF;
|
||||
default:
|
||||
return bitEverQuest;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::expansions::Expansion EQEmu::expansions::ConvertExpansionBitToExpansion(uint32 expansion_bit)
|
||||
{
|
||||
switch (expansion_bit) {
|
||||
case bitRoK:
|
||||
return Expansion::RoK;
|
||||
case bitSoV:
|
||||
return Expansion::SoV;
|
||||
case bitSoL:
|
||||
return Expansion::SoL;
|
||||
case bitPoP:
|
||||
return Expansion::PoP;
|
||||
case bitLoY:
|
||||
return Expansion::LoY;
|
||||
case bitLDoN:
|
||||
return Expansion::LDoN;
|
||||
case bitGoD:
|
||||
return Expansion::GoD;
|
||||
case bitOoW:
|
||||
return Expansion::OoW;
|
||||
case bitDoN:
|
||||
return Expansion::DoN;
|
||||
case bitDoD:
|
||||
return Expansion::DoD;
|
||||
case bitPoR:
|
||||
return Expansion::PoR;
|
||||
case bitTSS:
|
||||
return Expansion::TSS;
|
||||
case bitTBS:
|
||||
return Expansion::TBS;
|
||||
case bitSoF:
|
||||
return Expansion::SoF;
|
||||
case bitSoD:
|
||||
return Expansion::SoD;
|
||||
case bitUF:
|
||||
return Expansion::UF;
|
||||
case bitHoT:
|
||||
return Expansion::HoT;
|
||||
case bitVoA:
|
||||
return Expansion::VoA;
|
||||
case bitRoF:
|
||||
return Expansion::RoF;
|
||||
case bitCotF:
|
||||
return Expansion::CotF;
|
||||
default:
|
||||
return Expansion::EverQuest;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 EQEmu::expansions::ConvertExpansionToExpansionsMask(Expansion expansion)
|
||||
{
|
||||
switch (expansion) {
|
||||
case Expansion::RoK:
|
||||
return maskRoK;
|
||||
case Expansion::SoV:
|
||||
return maskSoV;
|
||||
case Expansion::SoL:
|
||||
return maskSoL;
|
||||
case Expansion::PoP:
|
||||
return maskPoP;
|
||||
case Expansion::LoY:
|
||||
return maskLoY;
|
||||
case Expansion::LDoN:
|
||||
return maskLDoN;
|
||||
case Expansion::GoD:
|
||||
return maskGoD;
|
||||
case Expansion::OoW:
|
||||
return maskOoW;
|
||||
case Expansion::DoN:
|
||||
return maskDoN;
|
||||
case Expansion::DoD:
|
||||
return maskDoD;
|
||||
case Expansion::PoR:
|
||||
return maskPoR;
|
||||
case Expansion::TSS:
|
||||
return maskTSS;
|
||||
case Expansion::TBS:
|
||||
return maskTBS;
|
||||
case Expansion::SoF:
|
||||
return maskSoF;
|
||||
case Expansion::SoD:
|
||||
return maskSoD;
|
||||
case Expansion::UF:
|
||||
return maskUF;
|
||||
case Expansion::HoT:
|
||||
return maskHoT;
|
||||
case Expansion::VoA:
|
||||
return maskVoA;
|
||||
case Expansion::RoF:
|
||||
return maskRoF;
|
||||
case Expansion::CotF:
|
||||
return maskCotF;
|
||||
default:
|
||||
return maskEverQuest;
|
||||
}
|
||||
}
|
||||
|
||||
EQEmu::expansions::Expansion EQEmu::expansions::ConvertClientVersionToExpansion(versions::ClientVersion client_version)
|
||||
{
|
||||
return EQEmu::constants::StaticLookup(client_version)->Expansion;
|
||||
}
|
||||
|
||||
uint32 EQEmu::expansions::ConvertClientVersionToExpansionBit(versions::ClientVersion client_version)
|
||||
{
|
||||
return EQEmu::constants::StaticLookup(client_version)->ExpansionBit;
|
||||
}
|
||||
|
||||
uint32 EQEmu::expansions::ConvertClientVersionToExpansionsMask(versions::ClientVersion client_version)
|
||||
{
|
||||
return EQEmu::constants::StaticLookup(client_version)->ExpansionsMask;
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
|
||||
#ifndef COMMON_EMU_VERSIONS_H
|
||||
#define COMMON_EMU_VERSIONS_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
namespace versions {
|
||||
enum class ClientVersion : uint32 {
|
||||
Unknown = 0,
|
||||
Client62, // Build: 'Aug 4 2005 15:40:59'
|
||||
Titanium, // Build: 'Oct 31 2005 10:33:37'
|
||||
SoF, // Build: 'Sep 7 2007 09:11:49'
|
||||
SoD, // Build: 'Dec 19 2008 15:22:49'
|
||||
UF, // Build: 'Jun 8 2010 16:44:32'
|
||||
RoF, // Build: 'Dec 10 2012 17:35:44'
|
||||
RoF2 // Build: 'May 10 2013 23:30:08'
|
||||
};
|
||||
|
||||
enum ClientVersionBitmask : uint32 {
|
||||
bitUnknown = 0x00000000,
|
||||
bitClient62 = 0x00000001, // unsupported (placeholder for scripts)
|
||||
bitTitanium = 0x00000002,
|
||||
bitSoF = 0x00000004,
|
||||
bitSoD = 0x00000008,
|
||||
bitUF = 0x00000010,
|
||||
bitRoF = 0x00000020,
|
||||
bitRoF2 = 0x00000040,
|
||||
maskUnknown = 0x00000000,
|
||||
maskTitaniumAndEarlier = 0x00000003,
|
||||
maskSoFAndEarlier = 0x00000007,
|
||||
maskSoDAndEarlier = 0x0000000F,
|
||||
maskUFAndEarlier = 0x0000001F,
|
||||
maskRoFAndEarlier = 0x0000003F,
|
||||
maskSoFAndLater = 0xFFFFFFFC,
|
||||
maskSoDAndLater = 0xFFFFFFF8,
|
||||
maskUFAndLater = 0xFFFFFFF0,
|
||||
maskRoFAndLater = 0xFFFFFFE0,
|
||||
maskRoF2AndLater = 0xFFFFFFC0,
|
||||
maskAllClients = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
const ClientVersion LastClientVersion = ClientVersion::RoF2;
|
||||
const size_t ClientVersionCount = (static_cast<size_t>(LastClientVersion) + 1);
|
||||
|
||||
bool IsValidClientVersion(ClientVersion client_version);
|
||||
ClientVersion ValidateClientVersion(ClientVersion client_version);
|
||||
const char* ClientVersionName(ClientVersion client_version);
|
||||
uint32 ConvertClientVersionToClientVersionBit(ClientVersion client_version);
|
||||
ClientVersion ConvertClientVersionBitToClientVersion(uint32 client_version_bit);
|
||||
|
||||
enum class MobVersion : uint32 {
|
||||
Unknown = 0,
|
||||
Client62,
|
||||
Titanium,
|
||||
SoF,
|
||||
SoD,
|
||||
UF,
|
||||
RoF,
|
||||
RoF2,
|
||||
NPC,
|
||||
NPCMerchant,
|
||||
Merc,
|
||||
Bot,
|
||||
ClientPet,
|
||||
NPCPet,
|
||||
MercPet,
|
||||
BotPet,
|
||||
OfflineTitanium,
|
||||
OfflineSoF,
|
||||
OfflineSoD,
|
||||
OfflineUF,
|
||||
OfflineRoF,
|
||||
OfflineRoF2
|
||||
};
|
||||
|
||||
const MobVersion LastMobVersion = MobVersion::OfflineRoF2;
|
||||
const MobVersion LastPCMobVersion = MobVersion::RoF2;
|
||||
const MobVersion LastNonPCMobVersion = MobVersion::BotPet;
|
||||
const MobVersion LastOfflinePCMobVersion = MobVersion::OfflineRoF2;
|
||||
const size_t MobVersionCount = (static_cast<size_t>(LastMobVersion) + 1);
|
||||
|
||||
bool IsValidMobVersion(MobVersion mob_version);
|
||||
bool IsValidPCMobVersion(MobVersion mob_version);
|
||||
bool IsValidNonPCMobVersion(MobVersion mob_version);
|
||||
bool IsValidOfflinePCMobVersion(MobVersion mob_version);
|
||||
|
||||
MobVersion ValidateMobVersion(MobVersion mob_version);
|
||||
MobVersion ValidatePCMobVersion(MobVersion mob_version);
|
||||
MobVersion ValidateNonPCMobVersion(MobVersion mob_version);
|
||||
MobVersion ValidateOfflinePCMobVersion(MobVersion mob_version);
|
||||
|
||||
const char* MobVersionName(MobVersion mob_version);
|
||||
ClientVersion ConvertMobVersionToClientVersion(MobVersion mob_version);
|
||||
MobVersion ConvertClientVersionToMobVersion(ClientVersion client_version);
|
||||
MobVersion ConvertPCMobVersionToOfflinePCMobVersion(MobVersion mob_version);
|
||||
MobVersion ConvertOfflinePCMobVersionToPCMobVersion(MobVersion mob_version);
|
||||
ClientVersion ConvertOfflinePCMobVersionToClientVersion(MobVersion mob_version);
|
||||
MobVersion ConvertClientVersionToOfflinePCMobVersion(ClientVersion client_version);
|
||||
|
||||
|
||||
enum UCSVersion : char {
|
||||
ucsUnknown = '\0',
|
||||
ucsClient62Chat = 'A',
|
||||
ucsClient62Mail = 'a',
|
||||
ucsTitaniumChat = 'B',
|
||||
ucsTitaniumMail = 'b',
|
||||
ucsSoFCombined = 'C',
|
||||
ucsSoDCombined = 'D',
|
||||
ucsUFCombined = 'E',
|
||||
ucsRoFCombined = 'F',
|
||||
ucsRoF2Combined = 'G'
|
||||
};
|
||||
|
||||
} /*versions*/
|
||||
|
||||
namespace expansions {
|
||||
enum class Expansion : uint32 {
|
||||
EverQuest = 0,
|
||||
RoK,
|
||||
SoV,
|
||||
SoL,
|
||||
PoP,
|
||||
LoY,
|
||||
LDoN,
|
||||
GoD,
|
||||
OoW,
|
||||
DoN,
|
||||
DoD,
|
||||
PoR,
|
||||
TSS,
|
||||
TBS,
|
||||
SoF,
|
||||
SoD,
|
||||
UF,
|
||||
HoT,
|
||||
VoA,
|
||||
RoF,
|
||||
CotF
|
||||
};
|
||||
|
||||
enum ExpansionBitmask : uint32 {
|
||||
bitEverQuest = 0x00000000,
|
||||
bitRoK = 0x00000001,
|
||||
bitSoV = 0x00000002,
|
||||
bitSoL = 0x00000004,
|
||||
bitPoP = 0x00000008,
|
||||
bitLoY = 0x00000010,
|
||||
bitLDoN = 0x00000020,
|
||||
bitGoD = 0x00000040,
|
||||
bitOoW = 0x00000080,
|
||||
bitDoN = 0x00000100,
|
||||
bitDoD = 0x00000200,
|
||||
bitPoR = 0x00000400,
|
||||
bitTSS = 0x00000800,
|
||||
bitTBS = 0x00001000,
|
||||
bitSoF = 0x00002000,
|
||||
bitSoD = 0x00004000,
|
||||
bitUF = 0x00008000,
|
||||
bitHoT = 0x00010000,
|
||||
bitVoA = 0x00020000,
|
||||
bitRoF = 0x00040000,
|
||||
bitCotF = 0x00080000,
|
||||
maskEverQuest = 0x00000000,
|
||||
maskRoK = 0x00000001,
|
||||
maskSoV = 0x00000003,
|
||||
maskSoL = 0x00000007,
|
||||
maskPoP = 0x0000000F,
|
||||
maskLoY = 0x0000001F,
|
||||
maskLDoN = 0x0000003F,
|
||||
maskGoD = 0x0000007F,
|
||||
maskOoW = 0x000000FF,
|
||||
maskDoN = 0x000001FF,
|
||||
maskDoD = 0x000003FF,
|
||||
maskPoR = 0x000007FF,
|
||||
maskTSS = 0x00000FFF,
|
||||
maskTBS = 0x00001FFF,
|
||||
maskSoF = 0x00003FFF,
|
||||
maskSoD = 0x00007FFF,
|
||||
maskUF = 0x0000FFFF,
|
||||
maskHoT = 0x0001FFFF,
|
||||
maskVoA = 0x0003FFFF,
|
||||
maskRoF = 0x0007FFFF,
|
||||
maskCotF = 0x000FFFFF
|
||||
};
|
||||
|
||||
const char* ExpansionName(Expansion expansion);
|
||||
const char* ExpansionName(uint32 expansion_bit);
|
||||
uint32 ConvertExpansionToExpansionBit(Expansion expansion);
|
||||
Expansion ConvertExpansionBitToExpansion(uint32 expansion_bit);
|
||||
uint32 ConvertExpansionToExpansionsMask(Expansion expansion);
|
||||
Expansion ConvertClientVersionToExpansion(versions::ClientVersion client_version);
|
||||
uint32 ConvertClientVersionToExpansionBit(versions::ClientVersion client_version);
|
||||
uint32 ConvertClientVersionToExpansionsMask(versions::ClientVersion client_version);
|
||||
|
||||
} /*expansions*/
|
||||
|
||||
} /*EQEmu*/
|
||||
|
||||
#endif /*COMMON_EMU_VERSIONS_H*/
|
||||
@@ -1,548 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
|
||||
#ifndef COMMON_EQ_CONSTANTS_H
|
||||
#define COMMON_EQ_CONSTANTS_H
|
||||
|
||||
#include "skills.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
//SpawnAppearance types: (compared two clients for server-originating types: SoF & RoF2)
|
||||
#define AT_Die 0 // this causes the client to keel over and zone to bind point (default action)
|
||||
#define AT_WhoLevel 1 // the level that shows up on /who
|
||||
#define AT_HPMax 2 // idk
|
||||
#define AT_Invis 3 // 0 = visible, 1 = invisible
|
||||
#define AT_PVP 4 // 0 = blue, 1 = pvp (red)
|
||||
#define AT_Light 5 // light type emitted by player (lightstone, shiny shield)
|
||||
#define AT_Anim 14 // 100=standing, 110=sitting, 111=ducking, 115=feigned, 105=looting
|
||||
#define AT_Sneak 15 // 0 = normal, 1 = sneaking
|
||||
#define AT_SpawnID 16 // server to client, sets player spawn id
|
||||
#define AT_HP 17 // Client->Server, my HP has changed (like regen tic)
|
||||
#define AT_Linkdead 18 // 0 = normal, 1 = linkdead
|
||||
#define AT_Levitate 19 // 0=off, 1=flymode, 2=levitate max 5, see GravityBehavior enum
|
||||
#define AT_GM 20 // 0 = normal, 1 = GM - all odd numbers seem to make it GM
|
||||
#define AT_Anon 21 // 0 = normal, 1 = anon, 2 = roleplay
|
||||
#define AT_GuildID 22
|
||||
#define AT_GuildRank 23 // 0=member, 1=officer, 2=leader
|
||||
#define AT_AFK 24 // 0 = normal, 1 = afk
|
||||
#define AT_Pet 25 // Param is EntityID of owner, or 0 for when charm breaks
|
||||
#define AT_Summoned 27 // Unsure
|
||||
#define AT_Split 28 // 0 = normal, 1 = autosplit on (not showing in SoF+) (client-to-server only)
|
||||
#define AT_Size 29 // spawn's size (present: SoF, absent: RoF2)
|
||||
#define AT_SetType 30 // 0 = PC, 1 = NPC, 2 <= = corpse
|
||||
#define AT_NPCName 31 // change PC's name's color to NPC color 0 = normal, 1 = npc name, Trader on RoF2?
|
||||
#define AT_AARank 32 // AA Rank Title ID thingy, does is this the title in /who?
|
||||
#define AT_CancelSneakHide 33 // Turns off Hide and Sneak
|
||||
//#define AT_34 34 // unknown (present: SoF, absent: RoF2)
|
||||
#define AT_AreaHPRegen 35 // guild hall regen pool sets to value * 0.001
|
||||
#define AT_AreaManaRegen 36 // guild hall regen pool sets to value * 0.001
|
||||
#define AT_AreaEndRegen 37 // guild hall regen pool sets to value * 0.001
|
||||
#define AT_FreezeBuffs 38 // Freezes beneficial buff timers
|
||||
#define AT_NpcTintIndex 39 // not 100% sure
|
||||
#define AT_GroupConsent 40 // auto consent group
|
||||
#define AT_RaidConsent 41 // auto consent raid
|
||||
#define AT_GuildConsent 42 // auto consent guild
|
||||
#define AT_ShowHelm 43 // 0 = hide graphic, 1 = show graphic
|
||||
#define AT_DamageState 44 // The damage state of a destructible object (0 through 10) plays soundids most only have 2 or 4 states though
|
||||
#define AT_EQPlayers 45 // /eqplayersupdate
|
||||
#define AT_FindBits 46 // set FindBits, whatever those are!
|
||||
#define AT_TextureType 48 // TextureType
|
||||
#define AT_FacePick 49 // Turns off face pick window? maybe ...
|
||||
#define AT_GuildShow 52 // this is what MQ2 call sit, not sure
|
||||
#define AT_Offline 53 // Offline mode
|
||||
|
||||
//#define AT_Trader 300 // Bazaar Trader Mode (not present in SoF or RoF2)
|
||||
|
||||
// animations for AT_Anim
|
||||
#define ANIM_FREEZE 102
|
||||
#define ANIM_STAND 0x64
|
||||
#define ANIM_SIT 0x6e
|
||||
#define ANIM_CROUCH 0x6f
|
||||
#define ANIM_DEATH 0x73
|
||||
#define ANIM_LOOT 0x69
|
||||
|
||||
typedef enum {
|
||||
eaStanding = 0,
|
||||
eaSitting, //1
|
||||
eaCrouching, //2
|
||||
eaDead, //3
|
||||
eaLooting, //4
|
||||
_eaMaxAppearance
|
||||
} EmuAppearance;
|
||||
|
||||
#define MT_NPCQuestSay 10
|
||||
// msg_type's for custom usercolors
|
||||
#define MT_Say 256
|
||||
#define MT_Tell 257
|
||||
#define MT_Group 258
|
||||
#define MT_Guild 259
|
||||
#define MT_OOC 260
|
||||
#define MT_Auction 261
|
||||
#define MT_Shout 262
|
||||
#define MT_Emote 263
|
||||
#define MT_Spells 264
|
||||
#define MT_YouHitOther 265
|
||||
#define MT_OtherHitsYou 266
|
||||
#define MT_YouMissOther 267
|
||||
#define MT_OtherMissesYou 268
|
||||
#define MT_Broadcasts 269
|
||||
#define MT_Skills 270
|
||||
#define MT_Disciplines 271
|
||||
#define MT_Unused1 272
|
||||
#define MT_DefaultText 273
|
||||
#define MT_Unused2 274
|
||||
#define MT_MerchantOffer 275
|
||||
#define MT_MerchantBuySell 276
|
||||
#define MT_YourDeath 277
|
||||
#define MT_OtherDeath 278
|
||||
#define MT_OtherHits 279
|
||||
#define MT_OtherMisses 280
|
||||
#define MT_Who 281
|
||||
#define MT_YellForHelp 282
|
||||
#define MT_NonMelee 283
|
||||
#define MT_WornOff 284
|
||||
#define MT_MoneySplit 285
|
||||
#define MT_LootMessages 286
|
||||
#define MT_DiceRoll 287
|
||||
#define MT_OtherSpells 288
|
||||
#define MT_SpellFailure 289
|
||||
#define MT_Chat 290
|
||||
#define MT_Channel1 291
|
||||
#define MT_Channel2 292
|
||||
#define MT_Channel3 293
|
||||
#define MT_Channel4 294
|
||||
#define MT_Channel5 295
|
||||
#define MT_Channel6 296
|
||||
#define MT_Channel7 297
|
||||
#define MT_Channel8 298
|
||||
#define MT_Channel9 299
|
||||
#define MT_Channel10 300
|
||||
#define MT_CritMelee 301
|
||||
#define MT_SpellCrits 302
|
||||
#define MT_TooFarAway 303
|
||||
#define MT_NPCRampage 304
|
||||
#define MT_NPCFlurry 305
|
||||
#define MT_NPCEnrage 306
|
||||
#define MT_SayEcho 307
|
||||
#define MT_TellEcho 308
|
||||
#define MT_GroupEcho 309
|
||||
#define MT_GuildEcho 310
|
||||
#define MT_OOCEcho 311
|
||||
#define MT_AuctionEcho 312
|
||||
#define MT_ShoutECho 313
|
||||
#define MT_EmoteEcho 314
|
||||
#define MT_Chat1Echo 315
|
||||
#define MT_Chat2Echo 316
|
||||
#define MT_Chat3Echo 317
|
||||
#define MT_Chat4Echo 318
|
||||
#define MT_Chat5Echo 319
|
||||
#define MT_Chat6Echo 320
|
||||
#define MT_Chat7Echo 321
|
||||
#define MT_Chat8Echo 322
|
||||
#define MT_Chat9Echo 323
|
||||
#define MT_Chat10Echo 324
|
||||
#define MT_DoTDamage 325
|
||||
#define MT_ItemLink 326
|
||||
#define MT_RaidSay 327
|
||||
#define MT_MyPet 328
|
||||
#define MT_DS 329
|
||||
#define MT_Leadership 330
|
||||
#define MT_PetFlurry 331
|
||||
#define MT_PetCrit 332
|
||||
#define MT_FocusEffect 333
|
||||
#define MT_Experience 334
|
||||
#define MT_System 335
|
||||
#define MT_PetSpell 336
|
||||
#define MT_PetResponse 337
|
||||
#define MT_ItemSpeech 338
|
||||
#define MT_StrikeThrough 339
|
||||
#define MT_Stun 340
|
||||
|
||||
// TODO: Really should combine above and below into one
|
||||
|
||||
//from showeq
|
||||
enum ChatColor
|
||||
{
|
||||
/*
|
||||
CC_Default = 0,
|
||||
CC_DarkGrey = 1,
|
||||
CC_DarkGreen = 2,
|
||||
CC_DarkBlue = 3,
|
||||
CC_Purple = 5,
|
||||
CC_LightGrey = 6,
|
||||
*/
|
||||
|
||||
CC_WhiteSmoke = 0, // FF|F0F0F0
|
||||
CC_Green = 2, // FF|008000
|
||||
CC_BrightBlue = 3, // FF|0040FF
|
||||
CC_Magenta = 5, // FF|F000F0
|
||||
CC_Gray = 6, // FF|808080
|
||||
CC_LightGray = 7, // FF|E0E0E0
|
||||
//CC_WhiteSmoke2 = 10, // FF|F0F0F0
|
||||
CC_DarkGray = 12, // FF|A0A0A0
|
||||
CC_Red = 13, // FF|F00000
|
||||
CC_Lime = 14, // FF|00F000
|
||||
CC_Yellow = 15, // FF|F0F000
|
||||
CC_Blue = 16, // FF|0000F0
|
||||
CC_LightNavy = 17, // FF|0000AF
|
||||
CC_Cyan = 18, // FF|00F0F0
|
||||
CC_Black = 20, // FF|000000
|
||||
|
||||
// any index <= 255 that is not defined above
|
||||
CC_DimGray = 1, // FF|606060
|
||||
CC_Default = 1,
|
||||
|
||||
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
|
||||
#define ZONE_ERROR_NOMSG 0
|
||||
#define ZONE_ERROR_NOTREADY -1
|
||||
#define ZONE_ERROR_VALIDPC -2
|
||||
#define ZONE_ERROR_STORYZONE -3
|
||||
#define ZONE_ERROR_NOEXPANSION -6
|
||||
#define ZONE_ERROR_NOEXPERIENCE -7
|
||||
|
||||
|
||||
typedef enum {
|
||||
FilterNone = 0,
|
||||
FilterGuildChat = 1, //0=hide, 1=show
|
||||
FilterSocials = 2, //0=hide, 1=show
|
||||
FilterGroupChat = 3, //0=hide, 1=show
|
||||
FilterShouts = 4, //0=hide, 1=show
|
||||
FilterAuctions = 5, //0=hide, 1=show
|
||||
FilterOOC = 6, //0=hide, 1=show
|
||||
FilterBadWords = 7, //0=hide, 1=show
|
||||
FilterPCSpells = 8, //0=show, 1=hide, 2=group only
|
||||
FilterNPCSpells = 9, //0=show, 1=hide
|
||||
FilterBardSongs = 10, //0=show, 1=mine only, 2=group only, 3=hide
|
||||
FilterSpellCrits = 11, //0=show, 1=mine only, 2=hide
|
||||
FilterMeleeCrits = 12, //0=show, 1=hide
|
||||
FilterSpellDamage = 13, //0=show, 1=mine only, 2=hide
|
||||
FilterMyMisses = 14, //0=hide, 1=show
|
||||
FilterOthersMiss = 15, //0=hide, 1=show
|
||||
FilterOthersHit = 16, //0=hide, 1=show
|
||||
FilterMissedMe = 17, //0=hide, 1=show
|
||||
FilterDamageShields = 18, //0=show, 1=hide
|
||||
FilterDOT = 19, //0=show, 1=hide
|
||||
FilterPetHits = 20, //0=show, 1=hide
|
||||
FilterPetMisses = 21, //0=show, 1=hide
|
||||
FilterFocusEffects = 22, //0=show, 1=hide
|
||||
FilterPetSpells = 23, //0=show, 1=hide
|
||||
FilterHealOverTime = 24, //0=show, 1=hide
|
||||
FilterUnknown25 = 25,
|
||||
FilterUnknown26 = 26,
|
||||
FilterUnknown27 = 27,
|
||||
FilterUnknown28 = 28,
|
||||
_FilterCount
|
||||
} eqFilterType;
|
||||
|
||||
typedef enum {
|
||||
FilterHide,
|
||||
FilterShow,
|
||||
FilterShowGroupOnly,
|
||||
FilterShowSelfOnly
|
||||
} eqFilterMode;
|
||||
|
||||
#define STAT_STR 0
|
||||
#define STAT_STA 1
|
||||
#define STAT_AGI 2
|
||||
#define STAT_DEX 3
|
||||
#define STAT_INT 4
|
||||
#define STAT_WIS 5
|
||||
#define STAT_CHA 6
|
||||
#define STAT_MAGIC 7
|
||||
#define STAT_COLD 8
|
||||
#define STAT_FIRE 9
|
||||
#define STAT_POISON 10
|
||||
#define STAT_DISEASE 11
|
||||
#define STAT_MANA 12
|
||||
#define STAT_HP 13
|
||||
#define STAT_AC 14
|
||||
#define STAT_ENDURANCE 15
|
||||
#define STAT_ATTACK 16
|
||||
#define STAT_HP_REGEN 17
|
||||
#define STAT_MANA_REGEN 18
|
||||
#define STAT_HASTE 19
|
||||
#define STAT_DAMAGE_SHIELD 20
|
||||
|
||||
/*
|
||||
** Recast timer types. Used as an off set to charProfileStruct timers.
|
||||
**
|
||||
** (Another orphaned enumeration...)
|
||||
*/
|
||||
enum RecastTimerTypes
|
||||
{
|
||||
RecTimer_0 = 0,
|
||||
RecTimer_1,
|
||||
RecTimer_WeaponHealClick, // 2
|
||||
RecTimer_MuramiteBaneNukeClick, // 3
|
||||
RecTimer_4,
|
||||
RecTimer_DispellClick, // 5 (also click heal orbs?)
|
||||
RecTimer_Epic, // 6
|
||||
RecTimer_OoWBPClick, // 7
|
||||
RecTimer_VishQuestClassItem, // 8
|
||||
RecTimer_HealPotion, // 9
|
||||
RecTimer_10,
|
||||
RecTimer_11,
|
||||
RecTimer_12,
|
||||
RecTimer_13,
|
||||
RecTimer_14,
|
||||
RecTimer_15,
|
||||
RecTimer_16,
|
||||
RecTimer_17,
|
||||
RecTimer_18,
|
||||
RecTimer_ModRod, // 19
|
||||
_RecTimerCount
|
||||
};
|
||||
|
||||
enum GroupUpdateAction
|
||||
{
|
||||
GUA_Joined = 0,
|
||||
GUA_Left = 1,
|
||||
GUA_LastLeft = 6,
|
||||
GUA_FullGroupInfo = 7,
|
||||
GUA_MakeLeader = 8,
|
||||
GUA_Started = 9
|
||||
};
|
||||
|
||||
static const uint8 DamageTypeSomething = 0x1C; //0x1c is something...
|
||||
static const uint8 DamageTypeFalling = 0xFC;
|
||||
static const uint8 DamageTypeSpell = 0xE7;
|
||||
static const uint8 DamageTypeUnknown = 0xFF;
|
||||
|
||||
/*
|
||||
** Skill damage types
|
||||
**
|
||||
** (indexed by 'Skill' of SkillUseTypes)
|
||||
*/
|
||||
static const uint8 SkillDamageTypes[EQEmu::skills::HIGHEST_SKILL + 1] = // change to _SkillServerArraySize once activated
|
||||
{
|
||||
/*1HBlunt*/ 0,
|
||||
/*1HSlashing*/ 1,
|
||||
/*2HBlunt*/ 0,
|
||||
/*2HSlashing*/ 1,
|
||||
/*Abjuration*/ DamageTypeSpell,
|
||||
/*Alteration*/ DamageTypeSpell,
|
||||
/*ApplyPoison*/ DamageTypeUnknown,
|
||||
/*Archery*/ 7,
|
||||
/*Backstab*/ 8,
|
||||
/*BindWound*/ DamageTypeUnknown,
|
||||
/*Bash*/ 10,
|
||||
/*Block*/ DamageTypeUnknown,
|
||||
/*BrassInstruments*/ DamageTypeSpell,
|
||||
/*Channeling*/ DamageTypeUnknown,
|
||||
/*Conjuration*/ DamageTypeSpell,
|
||||
/*Defense*/ DamageTypeUnknown,
|
||||
/*Disarm*/ DamageTypeUnknown,
|
||||
/*DisarmTraps*/ DamageTypeUnknown,
|
||||
/*Divination*/ DamageTypeSpell,
|
||||
/*Dodge*/ DamageTypeUnknown,
|
||||
/*DoubleAttack*/ DamageTypeUnknown,
|
||||
/*DragonPunch*/ 21,
|
||||
/*DualWield*/ DamageTypeUnknown,
|
||||
/*EagleStrike*/ 23,
|
||||
/*Evocation*/ DamageTypeSpell,
|
||||
/*FeignDeath*/ 4,
|
||||
/*FlyingKick*/ 30,
|
||||
/*Forage*/ DamageTypeUnknown,
|
||||
/*HandtoHand*/ 4,
|
||||
/*Hide*/ DamageTypeUnknown,
|
||||
/*Kick*/ 30,
|
||||
/*Meditate*/ DamageTypeUnknown,
|
||||
/*Mend*/ DamageTypeUnknown,
|
||||
/*Offense*/ DamageTypeUnknown,
|
||||
/*Parry*/ DamageTypeUnknown,
|
||||
/*PickLock*/ DamageTypeUnknown,
|
||||
/*1HPiercing*/ 36,
|
||||
/*Riposte*/ DamageTypeUnknown,
|
||||
/*RoundKick*/ 30,
|
||||
/*SafeFall*/ DamageTypeUnknown,
|
||||
/*SsenseHeading*/ DamageTypeUnknown,
|
||||
/*Singing*/ DamageTypeSpell,
|
||||
/*Sneak*/ DamageTypeUnknown,
|
||||
/*SpecializeAbjure*/ DamageTypeUnknown,
|
||||
/*SpecializeAlteration*/ DamageTypeUnknown,
|
||||
/*SpecializeConjuration*/ DamageTypeUnknown,
|
||||
/*SpecializeDivination*/ DamageTypeUnknown,
|
||||
/*SpecializeEvocation*/ DamageTypeUnknown,
|
||||
/*PickPockets*/ DamageTypeUnknown,
|
||||
/*StringedInstruments*/ DamageTypeSpell,
|
||||
/*Swimming*/ DamageTypeUnknown,
|
||||
/*Throwing*/ 51,
|
||||
/*TigerClaw*/ 23,
|
||||
/*Tracking*/ DamageTypeUnknown,
|
||||
/*WindInstruments*/ DamageTypeSpell,
|
||||
/*Fishing*/ DamageTypeUnknown,
|
||||
/*MakePoison*/ DamageTypeUnknown,
|
||||
/*Tinkering*/ DamageTypeUnknown,
|
||||
/*Research*/ DamageTypeUnknown,
|
||||
/*Alchemy*/ DamageTypeUnknown,
|
||||
/*Baking*/ DamageTypeUnknown,
|
||||
/*Tailoring*/ DamageTypeUnknown,
|
||||
/*SenseTraps*/ DamageTypeUnknown,
|
||||
/*Blacksmithing*/ DamageTypeUnknown,
|
||||
/*Fletching*/ DamageTypeUnknown,
|
||||
/*Brewing*/ DamageTypeUnknown,
|
||||
/*AlcoholTolerance*/ DamageTypeUnknown,
|
||||
/*Begging*/ DamageTypeUnknown,
|
||||
/*JewelryMaking*/ DamageTypeUnknown,
|
||||
/*Pottery*/ DamageTypeUnknown,
|
||||
/*PercussionInstruments*/ DamageTypeSpell,
|
||||
/*Intimidation*/ DamageTypeUnknown,
|
||||
/*Berserking*/ DamageTypeUnknown,
|
||||
/*Taunt*/ DamageTypeUnknown,
|
||||
/*Frenzy*/ 74,
|
||||
/*RemoveTrap*/ DamageTypeUnknown, // Needs research (set for SenseTrap value)
|
||||
/*TripleAttack*/ DamageTypeUnknown, // Needs research (set for DoubleAttack value)
|
||||
/*2HPiercing*/ 36 // Needs research (set for 1HPiercing value - similar to slash/blunt)
|
||||
};
|
||||
|
||||
/*
|
||||
// Used for worn NPC inventory tracking. NPCs don't use
|
||||
// augments, so only the basic slots need to be kept track of.
|
||||
#define MAX_WORN_INVENTORY 22
|
||||
*/
|
||||
|
||||
/*
|
||||
** Inventory Slot Equipment Enum
|
||||
** Mostly used for third-party tools to reference inventory slots
|
||||
**
|
||||
** [pre-HoT]
|
||||
** NOTE: Numbering for personal inventory goes top to bottom, then left to right
|
||||
** It's the opposite for inside bags: left to right, then top to bottom
|
||||
** Example:
|
||||
** Inventory: Containers:
|
||||
** 1 5 1 2
|
||||
** 2 6 3 4
|
||||
** 3 7 5 6
|
||||
** 4 8 7 8
|
||||
** - - 9 10
|
||||
**
|
||||
** [HoT and Higher]
|
||||
** Note: Numbering for inventory and bags goes left to right, then top to bottom
|
||||
** Example:
|
||||
** Inventory: Containers:
|
||||
** 1 2 1 2
|
||||
** 3 4 3 4
|
||||
** 5 6 5 6
|
||||
** 7 8 7 8
|
||||
** 9 10 9 10
|
||||
** - - 11 12 [Note: Additional slots are only available in RoF and higher]
|
||||
**
|
||||
*/
|
||||
|
||||
#define INVALID_INDEX -1
|
||||
|
||||
static const uint32 MAX_SPELL_DB_ID_VAL = 65535;
|
||||
|
||||
enum ChatChannelNames : uint16
|
||||
{
|
||||
ChatChannel_Guild = 0,
|
||||
ChatChannel_Group = 2,
|
||||
ChatChannel_Shout = 3,
|
||||
ChatChannel_Auction = 4,
|
||||
ChatChannel_OOC = 5,
|
||||
ChatChannel_Broadcast = 6,
|
||||
ChatChannel_Tell = 7,
|
||||
ChatChannel_Say = 8,
|
||||
ChatChannel_Petition = 10,
|
||||
ChatChannel_GMSAY = 11,
|
||||
ChatChannel_TellEcho = 14,
|
||||
ChatChannel_Raid = 15,
|
||||
|
||||
ChatChannel_UNKNOWN_Guild = 17,
|
||||
ChatChannel_UNKNOWN_GMSAY = 18,
|
||||
ChatChannel_UCSRelay = 20,
|
||||
ChatChannel_Emotes = 22
|
||||
};
|
||||
|
||||
#endif /*COMMON_EQ_CONSTANTS_H*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,269 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2016 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
|
||||
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
|
||||
*/
|
||||
|
||||
#ifndef COMMON_EQ_LIMITS_H
|
||||
#define COMMON_EQ_LIMITS_H
|
||||
|
||||
#include "types.h"
|
||||
#include "eq_constants.h"
|
||||
#include "emu_versions.h"
|
||||
#include "../common/patches/titanium_limits.h"
|
||||
#include "../common/patches/sof_limits.h"
|
||||
#include "../common/patches/sod_limits.h"
|
||||
#include "../common/patches/uf_limits.h"
|
||||
#include "../common/patches/rof_limits.h"
|
||||
#include "../common/patches/rof2_limits.h"
|
||||
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
void InitializeDynamicLookups();
|
||||
|
||||
namespace constants {
|
||||
struct LookupEntry {
|
||||
EQEmu::expansions::Expansion Expansion;
|
||||
uint32 ExpansionBit;
|
||||
uint32 ExpansionsMask;
|
||||
int16 CharacterCreationLimit;
|
||||
size_t SayLinkBodySize;
|
||||
|
||||
LookupEntry(const LookupEntry *lookup_entry) { }
|
||||
LookupEntry(
|
||||
EQEmu::expansions::Expansion Expansion,
|
||||
uint32 ExpansionBit,
|
||||
uint32 ExpansionsMask,
|
||||
int16 CharacterCreationLimit,
|
||||
size_t SayLinkBodySize
|
||||
) :
|
||||
Expansion(Expansion),
|
||||
ExpansionBit(ExpansionBit),
|
||||
ExpansionsMask(ExpansionsMask),
|
||||
CharacterCreationLimit(CharacterCreationLimit),
|
||||
SayLinkBodySize(SayLinkBodySize)
|
||||
{ }
|
||||
};
|
||||
|
||||
void InitializeDynamicLookups();
|
||||
|
||||
const LookupEntry* DynamicLookup(versions::ClientVersion client_version, bool gm_flag);
|
||||
const LookupEntry* DynamicNonGMLookup(versions::ClientVersion client_version);
|
||||
const LookupEntry* DynamicGMLookup(versions::ClientVersion client_version);
|
||||
const LookupEntry* StaticLookup(versions::ClientVersion client_version);
|
||||
|
||||
} /*constants*/
|
||||
|
||||
namespace inventory {
|
||||
struct LookupEntry {
|
||||
// note: 'PossessionsBitmask' needs to be attuned to the client version with the highest number
|
||||
// of possessions slots and 'InventoryTypeSize[typePossessions]' should reflect the same count
|
||||
// with translators adjusting for valid slot indices. Server-side validations will be performed
|
||||
// against 'PossessionsBitmask' (note: the same applies to CorpseBitmask..size is not dependent)
|
||||
|
||||
struct InventoryTypeSize_Struct { // should reflect count and naming conventions referenced in emu_constants.h
|
||||
int16 Possessions, Bank, SharedBank;
|
||||
int16 Trade, World, Limbo;
|
||||
int16 Tribute, TrophyTribute, GuildTribute;
|
||||
int16 Merchant, Deleted, Corpse;
|
||||
int16 Bazaar, Inspect, RealEstate;
|
||||
int16 ViewMODPC, ViewMODBank, ViewMODSharedBank;
|
||||
int16 ViewMODLimbo, AltStorage, Archived;
|
||||
int16 Mail, GuildTrophyTribute, Krono;
|
||||
int16 Other;
|
||||
|
||||
InventoryTypeSize_Struct(
|
||||
int16 Possessions, int16 Bank, int16 SharedBank,
|
||||
int16 Trade, int16 World, int16 Limbo,
|
||||
int16 Tribute, int16 TrophyTribute, int16 GuildTribute,
|
||||
int16 Merchant, int16 Deleted, int16 Corpse,
|
||||
int16 Bazaar, int16 Inspect, int16 RealEstate,
|
||||
int16 ViewMODPC, int16 ViewMODBank, int16 ViewMODSharedBank,
|
||||
int16 ViewMODLimbo, int16 AltStorage, int16 Archived,
|
||||
int16 Mail, int16 GuildTrophyTribute, int16 Krono,
|
||||
int16 Other
|
||||
) :
|
||||
Possessions(Possessions), Bank(Bank), SharedBank(SharedBank),
|
||||
Trade(Trade), World(World), Limbo(Limbo),
|
||||
Tribute(Tribute), TrophyTribute(TrophyTribute), GuildTribute(GuildTribute),
|
||||
Merchant(Merchant), Deleted(Deleted), Corpse(Corpse),
|
||||
Bazaar(Bazaar), Inspect(Inspect), RealEstate(RealEstate),
|
||||
ViewMODPC(ViewMODPC), ViewMODBank(ViewMODBank), ViewMODSharedBank(ViewMODSharedBank),
|
||||
ViewMODLimbo(ViewMODLimbo), AltStorage(AltStorage), Archived(Archived),
|
||||
Mail(Mail), GuildTrophyTribute(GuildTrophyTribute), Krono(Krono),
|
||||
Other(Other)
|
||||
{ }
|
||||
};
|
||||
|
||||
union {
|
||||
InventoryTypeSize_Struct InventoryTypeSize;
|
||||
int16 InventoryTypeSizeArray[25]; // should reflect EQEmu::invtype::TYPE_COUNT referenced in emu_constants.h
|
||||
};
|
||||
|
||||
uint64 EquipmentBitmask;
|
||||
uint64 GeneralBitmask;
|
||||
uint64 CursorBitmask;
|
||||
uint64 PossessionsBitmask;
|
||||
uint64 CorpseBitmask;
|
||||
int16 BagSlotCount;
|
||||
int16 AugSocketCount;
|
||||
|
||||
bool AllowEmptyBagInBag;
|
||||
bool AllowClickCastFromBag;
|
||||
bool ConcatenateInvTypeLimbo;
|
||||
bool AllowOverLevelEquipment;
|
||||
|
||||
LookupEntry(const LookupEntry *lookup_entry) { }
|
||||
LookupEntry(
|
||||
InventoryTypeSize_Struct InventoryTypeSize,
|
||||
uint64 EquipmentBitmask,
|
||||
uint64 GeneralBitmask,
|
||||
uint64 CursorBitmask,
|
||||
uint64 PossessionsBitmask,
|
||||
uint64 CorpseBitmask,
|
||||
int16 BagSlotCount,
|
||||
int16 AugSocketCount,
|
||||
bool AllowEmptyBagInBag,
|
||||
bool AllowClickCastFromBag,
|
||||
bool ConcatenateInvTypeLimbo,
|
||||
bool AllowOverLevelEquipment
|
||||
) :
|
||||
InventoryTypeSize(InventoryTypeSize),
|
||||
EquipmentBitmask(EquipmentBitmask),
|
||||
GeneralBitmask(GeneralBitmask),
|
||||
CursorBitmask(CursorBitmask),
|
||||
PossessionsBitmask(PossessionsBitmask),
|
||||
CorpseBitmask(CorpseBitmask),
|
||||
BagSlotCount(BagSlotCount),
|
||||
AugSocketCount(AugSocketCount),
|
||||
AllowEmptyBagInBag(AllowEmptyBagInBag),
|
||||
AllowClickCastFromBag(AllowClickCastFromBag),
|
||||
ConcatenateInvTypeLimbo(ConcatenateInvTypeLimbo),
|
||||
AllowOverLevelEquipment(AllowOverLevelEquipment)
|
||||
{ }
|
||||
};
|
||||
|
||||
void InitializeDynamicLookups();
|
||||
|
||||
const LookupEntry* DynamicLookup(versions::MobVersion mob_version, bool gm_flag);
|
||||
const LookupEntry* DynamicNonGMLookup(versions::MobVersion mob_version);
|
||||
const LookupEntry* DynamicGMLookup(versions::MobVersion mob_version);
|
||||
const LookupEntry* StaticLookup(versions::MobVersion mob_version);
|
||||
|
||||
} /*inventory*/
|
||||
|
||||
namespace behavior {
|
||||
struct LookupEntry {
|
||||
bool CoinHasWeight;
|
||||
|
||||
LookupEntry(const LookupEntry *lookup_entry) { }
|
||||
LookupEntry(
|
||||
bool CoinHasWeight
|
||||
) :
|
||||
CoinHasWeight(CoinHasWeight)
|
||||
{ }
|
||||
};
|
||||
|
||||
void InitializeDynamicLookups();
|
||||
|
||||
const LookupEntry* DynamicLookup(versions::MobVersion mob_version, bool gm_flag);
|
||||
const LookupEntry* DynamicNonGMLookup(versions::MobVersion mob_version);
|
||||
const LookupEntry* DynamicGMLookup(versions::MobVersion mob_version);
|
||||
const LookupEntry* StaticLookup(versions::MobVersion mob_version);
|
||||
|
||||
} /*behavior*/
|
||||
|
||||
namespace spells {
|
||||
struct LookupEntry {
|
||||
int SpellIdMax;
|
||||
int SpellbookSize;
|
||||
int SpellGemCount;
|
||||
|
||||
int LongBuffs;
|
||||
int ShortBuffs;
|
||||
int DiscBuffs;
|
||||
int TotalBuffs;
|
||||
int NPCBuffs;
|
||||
int PetBuffs;
|
||||
int MercBuffs;
|
||||
|
||||
LookupEntry(const LookupEntry *lookup_entry) { }
|
||||
LookupEntry(
|
||||
int SpellIdMax,
|
||||
int SpellbookSize,
|
||||
int SpellGemCount,
|
||||
int LongBuffs,
|
||||
int ShortBuffs,
|
||||
int DiscBuffs,
|
||||
int TotalBuffs,
|
||||
int NPCBuffs,
|
||||
int PetBuffs,
|
||||
int MercBuffs
|
||||
) :
|
||||
SpellIdMax(SpellIdMax),
|
||||
SpellbookSize(SpellbookSize),
|
||||
SpellGemCount(SpellGemCount),
|
||||
LongBuffs(LongBuffs),
|
||||
ShortBuffs(ShortBuffs),
|
||||
DiscBuffs(DiscBuffs),
|
||||
TotalBuffs(TotalBuffs),
|
||||
NPCBuffs(NPCBuffs),
|
||||
PetBuffs(PetBuffs),
|
||||
MercBuffs(MercBuffs)
|
||||
{ }
|
||||
};
|
||||
|
||||
void InitializeDynamicLookups();
|
||||
|
||||
const LookupEntry* DynamicLookup(versions::ClientVersion client_version, bool gm_flag);
|
||||
const LookupEntry* DynamicNonGMLookup(versions::ClientVersion client_version);
|
||||
const LookupEntry* DynamicGMLookup(versions::ClientVersion client_version);
|
||||
const LookupEntry* StaticLookup(versions::ClientVersion client_version);
|
||||
|
||||
} /*spells*/
|
||||
|
||||
} /*EQEmu*/
|
||||
|
||||
namespace ClientUnknown
|
||||
{
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace constants {
|
||||
const EQEmu::expansions::Expansion EXPANSION = EQEmu::expansions::Expansion::EverQuest;
|
||||
const uint32 EXPANSION_BIT = EQEmu::expansions::bitEverQuest;
|
||||
const uint32 EXPANSIONS_MASK = EQEmu::expansions::maskEverQuest;
|
||||
|
||||
} // namespace constants
|
||||
|
||||
} /*ClientUnknown*/
|
||||
|
||||
namespace Client62
|
||||
{
|
||||
const int16 IINVALID = -1;
|
||||
const int16 INULL = 0;
|
||||
|
||||
namespace constants {
|
||||
const EQEmu::expansions::Expansion EXPANSION = EQEmu::expansions::Expansion::EverQuest;
|
||||
const uint32 EXPANSION_BIT = EQEmu::expansions::bitEverQuest;
|
||||
const uint32 EXPANSIONS_MASK = EQEmu::expansions::maskEverQuest;
|
||||
|
||||
} // namespace constants
|
||||
|
||||
} /*Client62*/
|
||||
|
||||
#endif /*COMMON_EQ_LIMITS_H*/
|
||||
@@ -1,518 +0,0 @@
|
||||
/*
|
||||
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 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
|
||||
*/
|
||||
|
||||
#include "crc16.h"
|
||||
#include "global_define.h"
|
||||
#include "eq_packet.h"
|
||||
#include "misc.h"
|
||||
#include "op_codes.h"
|
||||
#include "platform.h"
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef STATIC_OPCODE
|
||||
#include "opcodemgr.h"
|
||||
#endif
|
||||
|
||||
#include "packet_dump.h"
|
||||
#include "packet_functions.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
|
||||
: 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);
|
||||
}
|
||||
|
||||
void EQPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQPacket::build_header_dump(char *buffer) const {
|
||||
sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]", emu_opcode, size);
|
||||
}
|
||||
|
||||
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
fprintf(to, "[EmuOpCode 0x%04x Size=%lu]\n",emu_opcode,(unsigned long)size);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void EQProtocolPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQProtocolPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]",opcode,size);
|
||||
}
|
||||
|
||||
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
fprintf(to, "[ProtoOpCode 0x%04x Size=%lu]\n",opcode,(unsigned long)size);
|
||||
}
|
||||
|
||||
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
|
||||
buffer += sprintf(buffer, "[OpCode %s Size=%u]\n",OpcodeManager::EmuToName(emu_opcode),size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQApplicationPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
#ifdef STATIC_OPCODE
|
||||
sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||
#else
|
||||
sprintf(buffer, "[OpCode %s(0x%04x) Size=%u]",OpcodeManager::EmuToName(emu_opcode), GetProtocolOpcode(), size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
fprintf(to, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||
#else
|
||||
fprintf(to, "[OpCode %s Size=%lu]\n",OpcodeManager::EmuToName(emu_opcode),(unsigned long)size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQRawApplicationPacket::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 (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
|
||||
#else
|
||||
buffer += sprintf(buffer, "[OpCode %s (0x%04x) Size=%u]\n", OpcodeManager::EmuToName(emu_opcode), opcode,size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQRawApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQRawApplicationPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
#ifdef STATIC_OPCODE
|
||||
sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
|
||||
#else
|
||||
sprintf(buffer, "[OpCode %s (0x%04x) Size=%u]", OpcodeManager::EmuToName(emu_opcode), opcode,size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
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
|
||||
fprintf(to, "[OpCode %s (0x%04x) Size=%lu]\n", OpcodeManager::EmuToName(emu_opcode), opcode,(unsigned long)size);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32 EQProtocolPacket::serialize(unsigned char *dest) const
|
||||
{
|
||||
if (opcode>0xff) {
|
||||
*(uint16 *)dest=opcode;
|
||||
} else {
|
||||
*(dest)=0;
|
||||
*(dest+1)=opcode;
|
||||
}
|
||||
memcpy(dest+2,pBuffer,size);
|
||||
|
||||
return size+2;
|
||||
}
|
||||
|
||||
uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
|
||||
{
|
||||
uint8 OpCodeBytes = app_opcode_size;
|
||||
|
||||
if (app_opcode_size==1)
|
||||
*(unsigned char *)dest = opcode;
|
||||
else
|
||||
{
|
||||
// Application opcodes with a low order byte of 0x00 require an extra 0x00 byte inserting prior to the opcode.
|
||||
if((opcode & 0x00ff) == 0)
|
||||
{
|
||||
*(uint8 *)dest = 0;
|
||||
*(uint16 *)(dest + 1) = opcode;
|
||||
++OpCodeBytes;
|
||||
}
|
||||
else
|
||||
*(uint16 *)dest = opcode;
|
||||
}
|
||||
memcpy(dest+OpCodeBytes,pBuffer,size);
|
||||
|
||||
return size+OpCodeBytes;
|
||||
}
|
||||
|
||||
/*EQProtocolPacket::EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len)
|
||||
: BasePacket(buf, len),
|
||||
opcode(op)
|
||||
{
|
||||
|
||||
uint32 offset;
|
||||
opcode=ntohs(*(const uint16 *)buf);
|
||||
offset=2;
|
||||
|
||||
if (len-offset) {
|
||||
pBuffer= new unsigned char[len-offset];
|
||||
memcpy(pBuffer,buf+offset,len-offset);
|
||||
size=len-offset;
|
||||
} else {
|
||||
pBuffer=nullptr;
|
||||
size=0;
|
||||
}
|
||||
OpMgr=&RawOpcodeManager;
|
||||
}*/
|
||||
|
||||
bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
|
||||
{
|
||||
bool result=false;
|
||||
if (opcode==OP_Combined && size+rhs->size+5<256) {
|
||||
auto tmpbuffer = new unsigned char[size + rhs->size + 3];
|
||||
memcpy(tmpbuffer,pBuffer,size);
|
||||
uint32 offset=size;
|
||||
tmpbuffer[offset++]=rhs->Size();
|
||||
offset+=rhs->serialize(tmpbuffer+offset);
|
||||
size=offset;
|
||||
delete[] pBuffer;
|
||||
pBuffer=tmpbuffer;
|
||||
result=true;
|
||||
} else if (size+rhs->size+7<256) {
|
||||
auto tmpbuffer = new unsigned char[size + rhs->size + 6];
|
||||
uint32 offset=0;
|
||||
tmpbuffer[offset++]=Size();
|
||||
offset+=serialize(tmpbuffer+offset);
|
||||
tmpbuffer[offset++]=rhs->Size();
|
||||
offset+=rhs->serialize(tmpbuffer+offset);
|
||||
size=offset;
|
||||
delete[] pBuffer;
|
||||
pBuffer=tmpbuffer;
|
||||
opcode=OP_Combined;
|
||||
result=true;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
this is the code to do app-layer combining, instead of protocol layer.
|
||||
this was taken out due to complex interactions with the opcode manager,
|
||||
and will require a bit more thinking (likely moving into EQStream) to
|
||||
get running again... but might be a good thing some day.
|
||||
|
||||
bool EQApplicationPacket::combine(const EQApplicationPacket *rhs)
|
||||
{
|
||||
uint32 newsize=0, offset=0;
|
||||
unsigned char *tmpbuffer=nullptr;
|
||||
|
||||
if (opcode!=OP_AppCombined) {
|
||||
newsize=app_opcode_size+size+(size>254?3:1)+app_opcode_size+rhs->size+(rhs->size>254?3:1);
|
||||
tmpbuffer=new unsigned char [newsize];
|
||||
offset=0;
|
||||
if (size>254) {
|
||||
tmpbuffer[offset++]=0xff;
|
||||
*(uint16 *)(tmpbuffer+offset)=htons(size);
|
||||
offset+=1;
|
||||
} else {
|
||||
tmpbuffer[offset++]=size;
|
||||
}
|
||||
offset+=serialize(tmpbuffer+offset);
|
||||
} else {
|
||||
newsize=size+app_opcode_size+rhs->size+(rhs->size>254?3:1);
|
||||
tmpbuffer=new unsigned char [newsize];
|
||||
memcpy(tmpbuffer,pBuffer,size);
|
||||
offset=size;
|
||||
}
|
||||
|
||||
if (rhs->size>254) {
|
||||
tmpbuffer[offset++]=0xff;
|
||||
*(uint16 *)(tmpbuffer+offset)=htons(rhs->size);
|
||||
offset+=1;
|
||||
} else {
|
||||
tmpbuffer[offset++]=rhs->size;
|
||||
}
|
||||
offset+=rhs->serialize(tmpbuffer+offset);
|
||||
|
||||
size=offset;
|
||||
opcode=OP_AppCombined;
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer=tmpbuffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint32 Key)
|
||||
{
|
||||
bool valid=false;
|
||||
// OP_SessionRequest, OP_SessionResponse, OP_OutOfSession are not CRC'd
|
||||
if (buffer[0]==0x00 && (buffer[1]==OP_SessionRequest || buffer[1]==OP_SessionResponse || buffer[1]==OP_OutOfSession)) {
|
||||
valid=true;
|
||||
} else {
|
||||
uint16 comp_crc=CRC16(buffer,length-2,Key);
|
||||
uint16 packet_crc=ntohs(*(const uint16 *)(buffer+length-2));
|
||||
#ifdef EQN_DEBUG
|
||||
if (packet_crc && comp_crc != packet_crc) {
|
||||
std::cout << "CRC mismatch: comp=" << std::hex << comp_crc << ", packet=" << packet_crc << std::dec << std::endl;
|
||||
}
|
||||
#endif
|
||||
valid = (!packet_crc || comp_crc == packet_crc);
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize)
|
||||
{
|
||||
uint32 newlen=0;
|
||||
uint32 flag_offset=0;
|
||||
newbuf[0]=buffer[0];
|
||||
if (buffer[0]==0x00) {
|
||||
flag_offset=2;
|
||||
newbuf[1]=buffer[1];
|
||||
} else
|
||||
flag_offset=1;
|
||||
|
||||
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];
|
||||
} else if (length>2 && buffer[flag_offset]==0xa5) {
|
||||
memcpy(newbuf+flag_offset,buffer+flag_offset+1,length-(flag_offset+1));
|
||||
newlen=length-1;
|
||||
} else {
|
||||
memcpy(newbuf,buffer,length);
|
||||
newlen=length;
|
||||
}
|
||||
|
||||
return newlen;
|
||||
}
|
||||
|
||||
uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) {
|
||||
uint32 flag_offset=1,newlength;
|
||||
//dump_message_column(buffer,length,"Before: ");
|
||||
newbuf[0]=buffer[0];
|
||||
if (buffer[0]==0) {
|
||||
flag_offset=2;
|
||||
newbuf[1]=buffer[1];
|
||||
}
|
||||
if (length>30) {
|
||||
newlength=DeflatePacket(buffer+flag_offset,length-flag_offset,newbuf+flag_offset+1,newbufsize);
|
||||
*(newbuf+flag_offset)=0x5a;
|
||||
newlength+=flag_offset+1;
|
||||
} else {
|
||||
memmove(newbuf+flag_offset+1,buffer+flag_offset,length-flag_offset);
|
||||
*(newbuf+flag_offset)=0xa5;
|
||||
newlength=length+1;
|
||||
}
|
||||
//dump_message_column(newbuf,length,"After: ");
|
||||
|
||||
return newlength;
|
||||
}
|
||||
|
||||
void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey)
|
||||
{
|
||||
if ((size >= 2) && buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
|
||||
int Key=DecodeKey;
|
||||
unsigned char *test=(unsigned char *)malloc(size);
|
||||
buffer+=2;
|
||||
size-=2;
|
||||
|
||||
int i;
|
||||
for (i = 0 ; i+4 <= size ; i+=4)
|
||||
{
|
||||
int pt = (*(int*)&buffer[i])^(Key);
|
||||
Key = (*(int*)&buffer[i]);
|
||||
*(int*)&test[i]=pt;
|
||||
}
|
||||
unsigned char KC=Key&0xFF;
|
||||
for ( ; i < size ; i++)
|
||||
{
|
||||
test[i]=buffer[i]^KC;
|
||||
}
|
||||
memcpy(buffer,test,size);
|
||||
free(test);
|
||||
}
|
||||
}
|
||||
|
||||
void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey)
|
||||
{
|
||||
if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
|
||||
int Key=EncodeKey;
|
||||
char *test=(char*)malloc(size);
|
||||
int i;
|
||||
buffer+=2;
|
||||
size-=2;
|
||||
for ( i = 0 ; i+4 <= size ; i+=4)
|
||||
{
|
||||
int pt = (*(int*)&buffer[i])^(Key);
|
||||
Key = pt;
|
||||
*(int*)&test[i]=pt;
|
||||
}
|
||||
unsigned char KC=Key&0xFF;
|
||||
for ( ; i < size ; i++)
|
||||
{
|
||||
test[i]=buffer[i]^KC;
|
||||
}
|
||||
memcpy(buffer,test,size);
|
||||
free(test);
|
||||
}
|
||||
}
|
||||
|
||||
EQApplicationPacket *EQApplicationPacket::Copy() const {
|
||||
return(new EQApplicationPacket(*this));
|
||||
}
|
||||
|
||||
EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
|
||||
auto res = new EQRawApplicationPacket(opcode, pBuffer, size);
|
||||
res->copyInfo(this);
|
||||
return(res);
|
||||
}
|
||||
|
||||
EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len)
|
||||
: 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(packet_length >= 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) {
|
||||
if (iShowInfo) {
|
||||
std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
|
||||
std::cout << " size:" << app->size << std::endl;
|
||||
}
|
||||
DumpPacketHex(app->pBuffer, app->size);
|
||||
// DumpPacketAscii(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
std::string DumpPacketToString(const EQApplicationPacket* app){
|
||||
std::ostringstream out;
|
||||
out << DumpPacketHexToString(app->pBuffer, app->size);
|
||||
return out.str();
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
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 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
|
||||
*/
|
||||
#ifndef _EQPACKET_H
|
||||
#define _EQPACKET_H
|
||||
|
||||
#include "base_packet.h"
|
||||
#include "platform.h"
|
||||
#include <iostream>
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
typedef unsigned short EmuOpcode;
|
||||
static const EmuOpcode OP_Unknown = 0;
|
||||
#else
|
||||
#include "emu_opcodes.h"
|
||||
#endif
|
||||
|
||||
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;
|
||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
|
||||
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
|
||||
EmuOpcode emu_opcode;
|
||||
|
||||
EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len);
|
||||
EQPacket(EmuOpcode opcode, SerializeBuffer &buf) : BasePacket(buf), emu_opcode(opcode) { };
|
||||
// EQPacket(const EQPacket &p) { }
|
||||
EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; }
|
||||
|
||||
};
|
||||
|
||||
class EQRawApplicationPacket;
|
||||
|
||||
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; sent_time = 0; }
|
||||
// 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;
|
||||
uint32 sent_time;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class EQApplicationPacket : public EQPacket {
|
||||
friend class EQStream;
|
||||
public:
|
||||
EQApplicationPacket() : EQPacket(OP_Unknown, nullptr, 0), opcode_bypass(0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op) : EQPacket(op, nullptr, 0), opcode_bypass(0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op, nullptr, len), opcode_bypass(0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op, buf, len), opcode_bypass(0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op, SerializeBuffer &buf) : EQPacket(op, buf), opcode_bypass(0)
|
||||
{ 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;
|
||||
|
||||
uint16 GetOpcodeBypass() const { return opcode_bypass; }
|
||||
void SetOpcodeBypass(uint16 v) { opcode_bypass = v; }
|
||||
|
||||
uint16 GetProtocolOpcode() const { return protocol_opcode; }
|
||||
void SetProtocolOpcode(uint16 v) { protocol_opcode = v; }
|
||||
protected:
|
||||
|
||||
uint16 protocol_opcode;
|
||||
uint8 app_opcode_size;
|
||||
uint16 opcode_bypass;
|
||||
private:
|
||||
|
||||
EQApplicationPacket(const EQApplicationPacket &p) : EQPacket(p.emu_opcode, p.pBuffer, p.size), opcode_bypass(p.opcode_bypass) { app_opcode_size = p.app_opcode_size; }
|
||||
|
||||
};
|
||||
|
||||
class EQRawApplicationPacket : public EQApplicationPacket {
|
||||
friend class EQStream;
|
||||
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);
|
||||
};
|
||||
|
||||
extern void DumpPacket(const EQApplicationPacket* app, bool iShowInfo = false);
|
||||
extern std::string DumpPacketToString(const EQApplicationPacket* app);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,314 +0,0 @@
|
||||
#ifndef _EQSTREAM_H
|
||||
#define _EQSTREAM_H
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <deque>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include "../common/misc.h"
|
||||
#include "../common/opcodemgr.h"
|
||||
#include "../common/timer.h"
|
||||
|
||||
#include "eq_packet.h"
|
||||
#include "eq_stream_intf.h"
|
||||
#include "eq_stream_type.h"
|
||||
#include "mutex.h"
|
||||
|
||||
class EQApplicationPacket;
|
||||
class EQProtocolPacket;
|
||||
|
||||
#define FLAG_COMPRESSED 0x01
|
||||
#define FLAG_ENCODED 0x04
|
||||
|
||||
#ifndef RATEBASE
|
||||
#define RATEBASE 1048576
|
||||
#endif
|
||||
|
||||
#ifndef DECAYBASE
|
||||
#define DECAYBASE 78642
|
||||
#endif
|
||||
|
||||
#ifndef RETRANSMIT_TIMEOUT_MULT
|
||||
#define RETRANSMIT_TIMEOUT_MULT 3.0
|
||||
#endif
|
||||
|
||||
#ifndef RETRANSMIT_TIMEOUT_MAX
|
||||
#define RETRANSMIT_TIMEOUT_MAX 5000
|
||||
#endif
|
||||
|
||||
#ifndef AVERAGE_DELTA_MAX
|
||||
#define AVERAGE_DELTA_MAX 2500
|
||||
#endif
|
||||
|
||||
#ifndef RETRANSMIT_ACKED_PACKETS
|
||||
#define RETRANSMIT_ACKED_PACKETS true
|
||||
#endif
|
||||
|
||||
#ifndef MAX_SESSION_RETRIES
|
||||
#define MAX_SESSION_RETRIES 30
|
||||
#endif
|
||||
|
||||
#pragma pack(1)
|
||||
struct SessionRequest {
|
||||
uint32 UnknownA;
|
||||
uint32 Session;
|
||||
uint32 MaxLength;
|
||||
};
|
||||
|
||||
struct SessionResponse {
|
||||
uint32 Session;
|
||||
uint32 Key;
|
||||
uint8 UnknownA;
|
||||
uint8 Format;
|
||||
uint8 UnknownB;
|
||||
uint32 MaxLength;
|
||||
uint32 UnknownD;
|
||||
};
|
||||
|
||||
//Deltas are in ms, representing round trip times
|
||||
struct ClientSessionStats {
|
||||
/*000*/ uint16 RequestID;
|
||||
/*002*/ uint32 last_local_delta;
|
||||
/*006*/ uint32 average_delta;
|
||||
/*010*/ uint32 low_delta;
|
||||
/*014*/ uint32 high_delta;
|
||||
/*018*/ uint32 last_remote_delta;
|
||||
/*022*/ uint64 packets_sent;
|
||||
/*030*/ uint64 packets_received;
|
||||
/*038*/
|
||||
};
|
||||
|
||||
struct ServerSessionStats {
|
||||
/*000*/ uint16 RequestID;
|
||||
/*002*/ uint32 ServerTime;
|
||||
/*006*/ uint64 packets_sent_echo;
|
||||
/*014*/ uint64 packets_received_echo;
|
||||
/*022*/ uint64 packets_sent;
|
||||
/*030*/ uint64 packets_received;
|
||||
/*038*/
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
class OpcodeManager;
|
||||
class EQRawApplicationPacket;
|
||||
|
||||
class EQStream : public EQStreamInterface {
|
||||
friend class EQStreamPair; //for collector.
|
||||
protected:
|
||||
typedef enum {
|
||||
SeqPast,
|
||||
SeqInOrder,
|
||||
SeqFuture
|
||||
} SeqOrder;
|
||||
|
||||
uint32 remote_ip;
|
||||
uint16 remote_port;
|
||||
uint8 buffer[8192];
|
||||
unsigned char *oversize_buffer;
|
||||
uint32 oversize_offset,oversize_length;
|
||||
uint8 app_opcode_size;
|
||||
EQStreamType StreamType;
|
||||
bool compressed,encoded;
|
||||
uint32 retransmittimer;
|
||||
uint32 retransmittimeout;
|
||||
|
||||
uint16 sessionAttempts;
|
||||
bool streamactive;
|
||||
|
||||
//uint32 buffer_len;
|
||||
|
||||
uint32 Session, Key;
|
||||
uint16 NextInSeq;
|
||||
uint32 MaxLen;
|
||||
uint16 MaxSends;
|
||||
|
||||
uint8 active_users; //how many things are actively using this
|
||||
Mutex MInUse;
|
||||
|
||||
EQStreamState State;
|
||||
Mutex MState;
|
||||
|
||||
uint32 LastPacket;
|
||||
Mutex MVarlock;
|
||||
|
||||
// Ack sequence tracking.
|
||||
long NextAckToSend;
|
||||
long LastAckSent;
|
||||
long GetNextAckToSend();
|
||||
long GetLastAckSent();
|
||||
void AckPackets(uint16 seq);
|
||||
void SetNextAckToSend(uint32);
|
||||
void SetLastAckSent(uint32);
|
||||
|
||||
Mutex MAcks;
|
||||
|
||||
// Packets waiting to be sent (all protected by MOutboundQueue)
|
||||
std::queue<EQProtocolPacket *> NonSequencedQueue;
|
||||
std::deque<EQProtocolPacket *> SequencedQueue;
|
||||
uint16 NextOutSeq;
|
||||
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
|
||||
Mutex MOutboundQueue;
|
||||
|
||||
//a buffer we use for compression/decompression
|
||||
unsigned char _tempBuffer[2048];
|
||||
|
||||
// Packets waiting to be processed
|
||||
std::vector<EQRawApplicationPacket *> InboundQueue;
|
||||
std::map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
|
||||
Mutex MInboundQueue;
|
||||
|
||||
static uint16 MaxWindowSize;
|
||||
|
||||
int32 BytesWritten;
|
||||
|
||||
uint64 sent_packet_count;
|
||||
uint64 received_packet_count;
|
||||
|
||||
Mutex MRate;
|
||||
int32 RateThreshold;
|
||||
int32 DecayRate;
|
||||
uint32 AverageDelta;
|
||||
|
||||
OpcodeManager **OpMgr;
|
||||
|
||||
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);
|
||||
void SendOutOfOrderAck(uint16 seq);
|
||||
void QueuePacket(EQProtocolPacket *p);
|
||||
void SendPacket(EQProtocolPacket *p);
|
||||
void NonSequencedPush(EQProtocolPacket *p);
|
||||
void SequencedPush(EQProtocolPacket *p);
|
||||
void WritePacket(int fd,EQProtocolPacket *p);
|
||||
|
||||
|
||||
uint32 GetKey() { return Key; }
|
||||
void SetKey(uint32 k) { Key=k; }
|
||||
void SetSession(uint32 s) { Session=s; }
|
||||
|
||||
void ProcessPacket(EQProtocolPacket *p);
|
||||
|
||||
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(bool resetSession=true);
|
||||
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(); sessionAttempts = 0;
|
||||
streamactive = false; }
|
||||
EQStream(sockaddr_in addr) { init(); remote_ip = addr.sin_addr.s_addr;
|
||||
remote_port = addr.sin_port; State = UNESTABLISHED; StreamType = UnknownStream;
|
||||
compressed = true; encoded = false; app_opcode_size = 2; bytes_sent = 0; bytes_recv = 0;
|
||||
create_time = Timer::GetTimeSeconds(); }
|
||||
virtual ~EQStream() { RemoveData(); SetState(CLOSED); }
|
||||
void SetMaxLen(uint32 length) { MaxLen=length; }
|
||||
|
||||
//interface used by application (EQStreamInterface)
|
||||
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true);
|
||||
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true);
|
||||
virtual EQApplicationPacket *PopPacket();
|
||||
virtual void Close();
|
||||
virtual uint32 GetRemoteIP() const { return remote_ip; }
|
||||
virtual uint16 GetRemotePort() const { return remote_port; }
|
||||
virtual void ReleaseFromUse() { MInUse.lock(); if(active_users > 0) active_users--; MInUse.unlock(); }
|
||||
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"); }
|
||||
|
||||
virtual 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);
|
||||
|
||||
// whether or not the stream has been assigned (we passed our stream match)
|
||||
virtual void SetActive(bool val) { streamactive = val; }
|
||||
|
||||
//
|
||||
inline bool IsInUse() { bool flag; MInUse.lock(); flag=(active_users>0); MInUse.unlock(); return flag; }
|
||||
inline void PutInUse() { MInUse.lock(); active_users++; MInUse.unlock(); }
|
||||
|
||||
virtual EQStreamState GetState() { EQStreamState s; MState.lock(); s=State; MState.unlock(); return s; }
|
||||
|
||||
static SeqOrder CompareSequence(uint16 expected_seq , uint16 seq);
|
||||
|
||||
bool CheckActive() { return GetState()==ESTABLISHED; }
|
||||
bool CheckClosed() { return GetState()==CLOSED; }
|
||||
void SetOpcodeSize(uint8 s) { app_opcode_size = s; }
|
||||
void SetStreamType(EQStreamType t);
|
||||
inline const EQStreamType GetStreamType() const { return StreamType; }
|
||||
static const char *StreamTypeString(EQStreamType t);
|
||||
|
||||
void Decay();
|
||||
void AdjustRates(uint32 average_delta);
|
||||
|
||||
uint32 bytes_sent;
|
||||
uint32 bytes_recv;
|
||||
uint32 create_time;
|
||||
|
||||
void AddBytesSent(uint32 bytes)
|
||||
{
|
||||
bytes_sent += bytes;
|
||||
++sent_packet_count;
|
||||
}
|
||||
|
||||
void AddBytesRecv(uint32 bytes)
|
||||
{
|
||||
bytes_recv += bytes;
|
||||
++received_packet_count;
|
||||
}
|
||||
|
||||
virtual const uint32 GetBytesSent() const { return bytes_sent; }
|
||||
virtual const uint32 GetBytesRecieved() const { return bytes_recv; }
|
||||
virtual const uint32 GetBytesSentPerSecond() const
|
||||
{
|
||||
if((Timer::GetTimeSeconds() - create_time) == 0)
|
||||
return 0;
|
||||
return bytes_sent / (Timer::GetTimeSeconds() - create_time);
|
||||
}
|
||||
|
||||
virtual const uint32 GetBytesRecvPerSecond() const
|
||||
{
|
||||
if((Timer::GetTimeSeconds() - create_time) == 0)
|
||||
return 0;
|
||||
return bytes_recv / (Timer::GetTimeSeconds() - create_time);
|
||||
}
|
||||
|
||||
const uint64 GetPacketsSent() { return sent_packet_count; }
|
||||
const uint64 GetPacketsReceived() { return received_packet_count; }
|
||||
|
||||
//used for dynamic stream identification
|
||||
virtual MatchState CheckSignature(const Signature *sig);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "eq_stream_factory.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <winsock2.h>
|
||||
#include <process.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/select.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "op_codes.h"
|
||||
|
||||
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
|
||||
{
|
||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||
|
||||
fs->ReaderLoop();
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
|
||||
ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
|
||||
{
|
||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||
|
||||
fs->WriterLoop();
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
|
||||
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
|
||||
: Timeoutable(5000), stream_timeout(timeout)
|
||||
{
|
||||
StreamType=type;
|
||||
Port=port;
|
||||
sock=-1;
|
||||
}
|
||||
|
||||
void EQStreamFactory::Close()
|
||||
{
|
||||
Stop();
|
||||
|
||||
#ifdef _WINDOWS
|
||||
closesocket(sock);
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
sock=-1;
|
||||
}
|
||||
|
||||
bool EQStreamFactory::Open()
|
||||
{
|
||||
struct sockaddr_in address;
|
||||
#ifndef WIN32
|
||||
pthread_t t1,t2;
|
||||
#endif
|
||||
/* 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(Port);
|
||||
address.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
/* Setting up UDP port for new clients */
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bind(sock, (struct sockaddr *) &address, sizeof(address)) < 0) {
|
||||
close(sock);
|
||||
sock=-1;
|
||||
return false;
|
||||
}
|
||||
#ifdef _WINDOWS
|
||||
unsigned long nonblock = 1;
|
||||
ioctlsocket(sock, FIONBIO, &nonblock);
|
||||
#else
|
||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
//moved these because on windows the output was delayed and causing the console window to look bad
|
||||
#ifdef _WINDOWS
|
||||
_beginthread(EQStreamFactoryReaderLoop,0, this);
|
||||
_beginthread(EQStreamFactoryWriterLoop,0, this);
|
||||
#else
|
||||
pthread_create(&t1,nullptr,EQStreamFactoryReaderLoop,this);
|
||||
pthread_create(&t2,nullptr,EQStreamFactoryWriterLoop,this);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<EQStream> EQStreamFactory::Pop()
|
||||
{
|
||||
std::shared_ptr<EQStream> s = nullptr;
|
||||
MNewStreams.lock();
|
||||
if (!NewStreams.empty()) {
|
||||
s = NewStreams.front();
|
||||
NewStreams.pop();
|
||||
s->PutInUse();
|
||||
}
|
||||
MNewStreams.unlock();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void EQStreamFactory::Push(std::shared_ptr<EQStream> s)
|
||||
{
|
||||
MNewStreams.lock();
|
||||
NewStreams.push(s);
|
||||
MNewStreams.unlock();
|
||||
}
|
||||
|
||||
void EQStreamFactory::ReaderLoop()
|
||||
{
|
||||
fd_set readset;
|
||||
std::map<std::pair<uint32, uint16>, std::shared_ptr<EQStream>>::iterator stream_itr;
|
||||
int num;
|
||||
int length;
|
||||
unsigned char buffer[2048];
|
||||
sockaddr_in from;
|
||||
int socklen = sizeof(sockaddr_in);
|
||||
timeval sleep_time;
|
||||
ReaderRunning = true;
|
||||
|
||||
while(sock!=-1) {
|
||||
MReaderRunning.lock();
|
||||
if (!ReaderRunning)
|
||||
break;
|
||||
MReaderRunning.unlock();
|
||||
|
||||
FD_ZERO(&readset);
|
||||
FD_SET(sock,&readset);
|
||||
|
||||
sleep_time.tv_sec=30;
|
||||
sleep_time.tv_usec=0;
|
||||
if ((num=select(sock+1,&readset,nullptr,nullptr,&sleep_time))<0) {
|
||||
// What do we wanna do?
|
||||
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)
|
||||
#else
|
||||
if ((length=recvfrom(sock,buffer,2048,0,(struct sockaddr *)&from,(socklen_t *)&socklen)) < 2)
|
||||
#endif
|
||||
{
|
||||
// What do we wanna do?
|
||||
} else {
|
||||
MStreams.lock();
|
||||
stream_itr = Streams.find(std::make_pair(from.sin_addr.s_addr, from.sin_port));
|
||||
if (stream_itr == Streams.end()) {
|
||||
if (buffer[1]==OP_SessionRequest) {
|
||||
std::shared_ptr<EQStream> s = std::make_shared<EQStream>(from);
|
||||
s->SetStreamType(StreamType);
|
||||
Streams[std::make_pair(from.sin_addr.s_addr, from.sin_port)]=s;
|
||||
WriterWork.Signal();
|
||||
Push(s);
|
||||
s->AddBytesRecv(length);
|
||||
s->Process(buffer,length);
|
||||
s->SetLastPacketTime(Timer::GetCurrentTime());
|
||||
}
|
||||
MStreams.unlock();
|
||||
} else {
|
||||
std::shared_ptr<EQStream> curstream = stream_itr->second;
|
||||
//dont bother processing incoming packets for closed connections
|
||||
if(curstream->CheckClosed())
|
||||
curstream = nullptr;
|
||||
else
|
||||
curstream->PutInUse();
|
||||
//the in use flag prevents the stream from being deleted while we are using it.
|
||||
|
||||
if(curstream) {
|
||||
curstream->AddBytesRecv(length);
|
||||
curstream->Process(buffer,length);
|
||||
curstream->SetLastPacketTime(Timer::GetCurrentTime());
|
||||
curstream->ReleaseFromUse();
|
||||
}
|
||||
MStreams.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EQStreamFactory::CheckTimeout()
|
||||
{
|
||||
//lock streams the entire time were checking timeouts, it should be fast.
|
||||
MStreams.lock();
|
||||
|
||||
unsigned long now=Timer::GetCurrentTime();
|
||||
std::map<std::pair<uint32, uint16>, std::shared_ptr<EQStream>>::iterator stream_itr;
|
||||
|
||||
for(stream_itr = Streams.begin(); stream_itr != Streams.end();) {
|
||||
std::shared_ptr<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()) {
|
||||
//give it a little time for everybody to finish with it
|
||||
} else {
|
||||
//everybody is done, we can delete it now
|
||||
auto temp = stream_itr;
|
||||
++stream_itr;
|
||||
temp->second = nullptr;
|
||||
Streams.erase(temp);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
++stream_itr;
|
||||
}
|
||||
MStreams.unlock();
|
||||
}
|
||||
|
||||
void EQStreamFactory::WriterLoop()
|
||||
{
|
||||
bool havework = true;
|
||||
std::vector<std::shared_ptr<EQStream>> wants_write;
|
||||
std::vector<std::shared_ptr<EQStream>>::iterator cur, end;
|
||||
bool decay = false;
|
||||
uint32 stream_count;
|
||||
Timer DecayTimer(20);
|
||||
WriterRunning = true;
|
||||
DecayTimer.Enable();
|
||||
|
||||
while (sock != -1) {
|
||||
MWriterRunning.lock();
|
||||
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();
|
||||
for (auto stream_itr = Streams.begin(); stream_itr != Streams.end(); ++stream_itr) {
|
||||
// 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: %i:%i",
|
||||
stream_itr->first.first, stream_itr->first.second);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stream_itr->second->HasOutgoingData()) {
|
||||
havework = true;
|
||||
stream_itr->second->PutInUse();
|
||||
wants_write.push_back(stream_itr->second);
|
||||
}
|
||||
}
|
||||
MStreams.unlock();
|
||||
|
||||
// do the actual writes
|
||||
cur = wants_write.begin();
|
||||
end = wants_write.end();
|
||||
for (; cur != end; ++cur) {
|
||||
(*cur)->Write(sock);
|
||||
(*cur)->ReleaseFromUse();
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
MStreams.lock();
|
||||
stream_count = Streams.size();
|
||||
MStreams.unlock();
|
||||
if (!stream_count) {
|
||||
WriterWork.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
#ifndef _EQSTREAMFACTORY_H
|
||||
|
||||
#define _EQSTREAMFACTORY_H
|
||||
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
|
||||
#include "../common/eq_stream.h"
|
||||
#include "../common/condition.h"
|
||||
#include "../common/timeoutmgr.h"
|
||||
|
||||
class EQStream;
|
||||
class Timer;
|
||||
|
||||
class EQStreamFactory : private Timeoutable {
|
||||
private:
|
||||
int sock;
|
||||
int Port;
|
||||
|
||||
bool ReaderRunning;
|
||||
Mutex MReaderRunning;
|
||||
bool WriterRunning;
|
||||
Mutex MWriterRunning;
|
||||
|
||||
Condition WriterWork;
|
||||
|
||||
EQStreamType StreamType;
|
||||
|
||||
std::queue<std::shared_ptr<EQStream>> NewStreams;
|
||||
Mutex MNewStreams;
|
||||
|
||||
std::map<std::pair<uint32, uint16>, std::shared_ptr<EQStream>> Streams;
|
||||
Mutex MStreams;
|
||||
|
||||
virtual void CheckTimeout();
|
||||
|
||||
Timer *DecayTimer;
|
||||
|
||||
uint32 stream_timeout;
|
||||
|
||||
public:
|
||||
EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; }
|
||||
EQStreamFactory(EQStreamType type, int port, uint32 timeout = 135000);
|
||||
|
||||
std::shared_ptr<EQStream> Pop();
|
||||
void Push(std::shared_ptr<EQStream> s);
|
||||
|
||||
bool Open();
|
||||
bool Open(unsigned long port) { Port=port; return Open(); }
|
||||
bool IsOpen() { return sock!=-1; }
|
||||
void Close();
|
||||
void ReaderLoop();
|
||||
void WriterLoop();
|
||||
void Stop() { StopReader(); StopWriter(); }
|
||||
void StopReader() { MReaderRunning.lock(); ReaderRunning=false; MReaderRunning.unlock(); }
|
||||
void StopWriter() { MWriterRunning.lock(); WriterRunning=false; MWriterRunning.unlock(); WriterWork.Signal(); }
|
||||
void SignalWriter() { WriterWork.Signal(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,165 +0,0 @@
|
||||
#include <utility>
|
||||
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "eq_stream_ident.h"
|
||||
#include "eq_stream_proxy.h"
|
||||
#include "misc.h"
|
||||
|
||||
EQStreamIdentifier::~EQStreamIdentifier() {
|
||||
while(!m_identified.empty()) {
|
||||
m_identified.front()->ReleaseFromUse();
|
||||
m_identified.pop();
|
||||
}
|
||||
std::vector<Record>::iterator cur, end;
|
||||
cur = m_streams.begin();
|
||||
end = m_streams.end();
|
||||
for(; cur != end; ++cur) {
|
||||
Record &r = *cur;
|
||||
r.stream->ReleaseFromUse();
|
||||
}
|
||||
std::vector<Patch *>::iterator curp, endp;
|
||||
curp = m_patches.begin();
|
||||
endp = m_patches.end();
|
||||
for(; curp != endp; ++curp) {
|
||||
delete *curp;
|
||||
}
|
||||
}
|
||||
|
||||
void EQStreamIdentifier::RegisterPatch(const EQStreamInterface::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs) {
|
||||
auto p = new Patch;
|
||||
p->signature = sig;
|
||||
p->name = name;
|
||||
p->opcodes = opcodes;
|
||||
p->structs = structs;
|
||||
m_patches.push_back(p);
|
||||
}
|
||||
|
||||
void EQStreamIdentifier::Process() {
|
||||
std::vector<Record>::iterator cur;
|
||||
std::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)) {
|
||||
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d before timeout.", r.stream->GetRemoteAddr().c_str(), ntohs(r.stream->GetRemotePort()));
|
||||
r.stream->Close();
|
||||
|
||||
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)
|
||||
{
|
||||
++cur;
|
||||
continue;
|
||||
}
|
||||
if(r.stream->GetState() != ESTABLISHED) {
|
||||
//the stream closed before it was identified.
|
||||
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d before it closed.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()));
|
||||
switch(r.stream->GetState())
|
||||
{
|
||||
case ESTABLISHED:
|
||||
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Established");
|
||||
break;
|
||||
case CLOSING:
|
||||
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closing");
|
||||
break;
|
||||
case DISCONNECTING:
|
||||
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Disconnecting");
|
||||
break;
|
||||
case CLOSED:
|
||||
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closed");
|
||||
break;
|
||||
default:
|
||||
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Unestablished or unknown");
|
||||
break;
|
||||
}
|
||||
r.stream->ReleaseFromUse();
|
||||
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
|
||||
EQStreamInterface::MatchState res = r.stream->CheckSignature(&p->signature);
|
||||
switch(res) {
|
||||
case EQStreamInterface::MatchNotReady:
|
||||
//the stream has not received enough packets to compare with this signature
|
||||
// Log.LogDebugType(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, but stream is not ready for it.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
|
||||
all_ready = false;
|
||||
break;
|
||||
case EQStreamInterface::MatchSuccessful: {
|
||||
//yay, a match.
|
||||
|
||||
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Identified stream %s:%d with signature %s", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
|
||||
|
||||
// before we assign the eqstream to an interface, let the stream recognize it is in use and the session should not be reset any further
|
||||
r.stream->SetActive(true);
|
||||
|
||||
//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;
|
||||
}
|
||||
case EQStreamInterface::MatchFailed:
|
||||
//do nothing...
|
||||
Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, and it did not match.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//if we checked all patches and did not find a match.
|
||||
if(all_ready && !found_one) {
|
||||
//the stream cannot be identified.
|
||||
Log(Logs::General, Logs::Netcode, "[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.
|
||||
cur = m_streams.erase(cur);
|
||||
} else {
|
||||
++cur;
|
||||
}
|
||||
} //end foreach stream
|
||||
}
|
||||
|
||||
void EQStreamIdentifier::AddStream(std::shared_ptr<EQStreamInterface> eqs) {
|
||||
m_streams.push_back(Record(eqs));
|
||||
eqs = nullptr;
|
||||
}
|
||||
|
||||
EQStreamInterface *EQStreamIdentifier::PopIdentified() {
|
||||
if(m_identified.empty())
|
||||
return(nullptr);
|
||||
EQStreamInterface *res = m_identified.front();
|
||||
m_identified.pop();
|
||||
return(res);
|
||||
}
|
||||
|
||||
EQStreamIdentifier::Record::Record(std::shared_ptr<EQStreamInterface> s)
|
||||
: stream(std::move(s)),
|
||||
expire(STREAM_IDENT_WAIT_MS)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef EQSTREAMIDENT_H_
|
||||
#define EQSTREAMIDENT_H_
|
||||
|
||||
#include "eq_stream_intf.h"
|
||||
#include "timer.h"
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
|
||||
#define STREAM_IDENT_WAIT_MS 30000
|
||||
|
||||
class OpcodeManager;
|
||||
class StructStrategy;
|
||||
class EQStreamInterface;
|
||||
|
||||
class EQStreamIdentifier {
|
||||
public:
|
||||
~EQStreamIdentifier();
|
||||
|
||||
//registration interface.
|
||||
void RegisterPatch(const EQStreamInterface::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs);
|
||||
|
||||
//main processing interface
|
||||
void Process();
|
||||
void AddStream(std::shared_ptr<EQStreamInterface> eqs);
|
||||
EQStreamInterface *PopIdentified();
|
||||
|
||||
protected:
|
||||
|
||||
//registered patches..
|
||||
class Patch {
|
||||
public:
|
||||
std::string name;
|
||||
EQStreamInterface::Signature signature;
|
||||
OpcodeManager ** opcodes;
|
||||
const StructStrategy *structs;
|
||||
};
|
||||
std::vector<Patch *> m_patches; //we own these objects.
|
||||
|
||||
//pending streams..
|
||||
class Record {
|
||||
public:
|
||||
Record(std::shared_ptr<EQStreamInterface> s);
|
||||
std::shared_ptr<EQStreamInterface> stream; //we own this
|
||||
Timer expire;
|
||||
};
|
||||
std::vector<Record> m_streams; //we own these objects, and the streams contained in them.
|
||||
std::queue<EQStreamInterface *> m_identified; //we own these objects
|
||||
};
|
||||
|
||||
#endif /*EQSTREAMIDENT_H_*/
|
||||
@@ -1,109 +0,0 @@
|
||||
#ifndef EQSTREAMINTF_H_
|
||||
#define EQSTREAMINTF_H_
|
||||
|
||||
//this is the only part of an EQStream that is seen by the application.
|
||||
|
||||
#include <string>
|
||||
#include "emu_versions.h"
|
||||
#include "eq_packet.h"
|
||||
#include "net/daybreak_connection.h"
|
||||
|
||||
typedef enum {
|
||||
ESTABLISHED,
|
||||
CLOSING, //waiting for pending data to flush.
|
||||
DISCONNECTING, //have sent disconnect, waiting for their disconnect reply.
|
||||
CLOSED, //received a disconnect from remote side.
|
||||
UNESTABLISHED
|
||||
} EQStreamState;
|
||||
|
||||
class EQApplicationPacket;
|
||||
class OpcodeManager;
|
||||
|
||||
struct EQStreamManagerInterfaceOptions
|
||||
{
|
||||
EQStreamManagerInterfaceOptions() {
|
||||
opcode_size = 2;
|
||||
}
|
||||
|
||||
EQStreamManagerInterfaceOptions(int port, bool encoded, bool compressed) {
|
||||
opcode_size = 2;
|
||||
|
||||
//World seems to support both compression and xor zone supports one or the others.
|
||||
//Enforce one or the other in the convienence construct
|
||||
//Login I had trouble getting to recognize compression at all
|
||||
//but that might be because it was still a bit buggy when i was testing that.
|
||||
if (compressed) {
|
||||
daybreak_options.encode_passes[0] = EQ::Net::EncodeCompression;
|
||||
}
|
||||
else if (encoded) {
|
||||
daybreak_options.encode_passes[0] = EQ::Net::EncodeXOR;
|
||||
}
|
||||
|
||||
daybreak_options.port = port;
|
||||
}
|
||||
|
||||
int opcode_size;
|
||||
bool track_opcode_stats;
|
||||
EQ::Net::DaybreakConnectionManagerOptions daybreak_options;
|
||||
};
|
||||
|
||||
class EQStreamManagerInterface
|
||||
{
|
||||
public:
|
||||
EQStreamManagerInterface(const EQStreamManagerInterfaceOptions &options) { m_options = options; }
|
||||
virtual ~EQStreamManagerInterface() { };
|
||||
|
||||
EQStreamManagerInterfaceOptions GetOptions() { return m_options; }
|
||||
const EQStreamManagerInterfaceOptions& GetOptions() const { return m_options; }
|
||||
virtual void SetOptions(const EQStreamManagerInterfaceOptions& options) = 0;
|
||||
protected:
|
||||
EQStreamManagerInterfaceOptions m_options;
|
||||
};
|
||||
|
||||
class EQStreamInterface {
|
||||
public:
|
||||
virtual ~EQStreamInterface() {}
|
||||
|
||||
class Signature {
|
||||
public:
|
||||
//this object could get more complicated if needed...
|
||||
uint16 ignore_eq_opcode; //0=dont ignore
|
||||
uint16 first_eq_opcode;
|
||||
uint32 first_length; //0=dont check length
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
MatchNotReady,
|
||||
MatchSuccessful,
|
||||
MatchFailed
|
||||
} MatchState;
|
||||
|
||||
struct Stats
|
||||
{
|
||||
EQ::Net::DaybreakConnectionStats DaybreakStats;
|
||||
int RecvCount[_maxEmuOpcode];
|
||||
int SentCount[_maxEmuOpcode];
|
||||
};
|
||||
|
||||
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;
|
||||
virtual void Close() = 0;
|
||||
virtual void ReleaseFromUse() = 0;
|
||||
virtual void RemoveData() = 0;
|
||||
virtual std::string GetRemoteAddr() const = 0;
|
||||
virtual uint32 GetRemoteIP() const = 0;
|
||||
virtual uint16 GetRemotePort() const = 0;
|
||||
virtual bool CheckState(EQStreamState state) = 0;
|
||||
virtual std::string Describe() const = 0;
|
||||
virtual void SetActive(bool val) { }
|
||||
virtual MatchState CheckSignature(const Signature *sig) { return MatchFailed; }
|
||||
virtual EQStreamState GetState() = 0;
|
||||
virtual void SetOpcodeManager(OpcodeManager **opm) = 0;
|
||||
virtual const EQEmu::versions::ClientVersion ClientVersion() const { return EQEmu::versions::ClientVersion::Unknown; }
|
||||
virtual Stats GetStats() const = 0;
|
||||
virtual void ResetStats() = 0;
|
||||
virtual EQStreamManagerInterface* GetManager() const = 0;
|
||||
};
|
||||
|
||||
#endif /*EQSTREAMINTF_H_*/
|
||||
@@ -1,172 +0,0 @@
|
||||
/*
|
||||
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 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
|
||||
*/
|
||||
#ifndef _EQSTREAM_LOCATOR_H
|
||||
#define _EQSTREAM_LOCATOR_H
|
||||
|
||||
/*
|
||||
This did not turn out nearly as nice as I hoped.
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class EQStreamInfo {
|
||||
public:
|
||||
EQStreamInfo() {}
|
||||
EQStreamInfo(uint32 isrc_ip, uint32 idst_ip, uint16 isrc_port, uint16 idst_port) {
|
||||
src_ip = isrc_ip;
|
||||
dst_ip = idst_ip;
|
||||
src_port = isrc_port;
|
||||
dst_port = idst_port;
|
||||
}
|
||||
void invert(EQStreamInfo &r) const {
|
||||
r.src_ip = dst_ip;
|
||||
r.dst_ip = src_ip;
|
||||
r.src_port = dst_port;
|
||||
r.dst_port = src_port;
|
||||
}
|
||||
uint32 src_ip;
|
||||
uint32 dst_ip;
|
||||
uint16 src_port;
|
||||
uint16 dst_port;
|
||||
};
|
||||
|
||||
inline bool operator<(const EQStreamInfo &l, const EQStreamInfo &r) {
|
||||
/*printf("Less than called with:\n");
|
||||
printf("0x%.8x:%d -> 0x%.8x:%d < \n", l.src_ip, l.src_port, l.dst_ip, l.dst_port);
|
||||
printf("0x%.8x:%d -> 0x%.8x:%d ", r.src_ip, r.src_port, r.dst_ip, r.dst_port);
|
||||
|
||||
bool res;
|
||||
if(l.src_ip != r.src_ip)
|
||||
res = (l.src_ip < r.src_ip);
|
||||
else if(l.dst_ip != r.dst_ip)
|
||||
res = (l.dst_ip < r.dst_ip);
|
||||
else if(l.src_port != r.src_port)
|
||||
res = (l.src_port < r.src_port);
|
||||
else
|
||||
res = (l.dst_port < r.dst_port);
|
||||
if(res)
|
||||
printf(": True\n");
|
||||
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)
|
||||
return(l.dst_ip < r.dst_ip);
|
||||
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);
|
||||
if(l.src_ip > r.src_ip)
|
||||
return(false);
|
||||
if(l.dst_ip < r.dst_ip)
|
||||
return(true);
|
||||
if(l.dst_ip > r.dst_ip)
|
||||
return(false);
|
||||
if(l.src_port < r.src_port)
|
||||
return(true);
|
||||
if(l.src_port > r.src_port)
|
||||
return(false);
|
||||
return(l.dst_port < r.dst_port);*/
|
||||
}
|
||||
|
||||
inline bool operator==(const EQStreamInfo &l, const EQStreamInfo &r) {
|
||||
// if(l.src_ip == r.dest_ip) {
|
||||
// //maybe swapped
|
||||
// return(l.src_port == r.dst_port && l.dst_ip == r.src_ip && l.dst_port == r.src_port);
|
||||
// }
|
||||
return(l.src_ip == r.src_ip && l.src_port == r.src_port && l.dst_ip == r.dst_ip && l.dst_port == r.dst_port);
|
||||
}
|
||||
|
||||
//Forces the pointer T thing so we can return nullptr
|
||||
template <class T>
|
||||
class EQStreamLocator {
|
||||
protected:
|
||||
typedef typename std::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;
|
||||
cur = streams.begin();
|
||||
end = streams.end();
|
||||
for(; cur != end; ++cur) {
|
||||
if(cur->second == it) {
|
||||
streams.erase(cur);
|
||||
//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);
|
||||
//possibly optimization would be to store streams.end(), since it
|
||||
//may not be a constant time operation in theory, and update our
|
||||
//stored copy only on insert or delete
|
||||
if(res == streams.end())
|
||||
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:
|
||||
std::map<const EQStreamInfo, T *> streams;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,114 +0,0 @@
|
||||
|
||||
#include "global_define.h"
|
||||
#include "eq_stream_proxy.h"
|
||||
#include "struct_strategy.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "opcodemgr.h"
|
||||
|
||||
|
||||
EQStreamProxy::EQStreamProxy(std::shared_ptr<EQStreamInterface> &stream, const StructStrategy *structs, OpcodeManager **opcodes)
|
||||
: m_stream(stream),
|
||||
m_structs(structs),
|
||||
m_opcodes(opcodes)
|
||||
{
|
||||
stream = nullptr; //take the stream.
|
||||
m_stream->SetOpcodeManager(m_opcodes);
|
||||
}
|
||||
|
||||
EQStreamProxy::~EQStreamProxy() {
|
||||
}
|
||||
|
||||
std::string EQStreamProxy::Describe() const {
|
||||
return(m_structs->Describe());
|
||||
}
|
||||
|
||||
const EQEmu::versions::ClientVersion EQStreamProxy::ClientVersion() const
|
||||
{
|
||||
return m_structs->ClientVersion();
|
||||
}
|
||||
|
||||
EQStreamState EQStreamProxy::GetState()
|
||||
{
|
||||
return m_stream->GetState();
|
||||
}
|
||||
|
||||
void EQStreamProxy::SetOpcodeManager(OpcodeManager **opm)
|
||||
{
|
||||
return m_stream->SetOpcodeManager(opm);
|
||||
}
|
||||
|
||||
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
|
||||
if(p == nullptr)
|
||||
return;
|
||||
|
||||
if (p->GetOpcode() != OP_SpecialMesg) {
|
||||
Log(Logs::General, Logs::Server_Client_Packet, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size());
|
||||
Log(Logs::General, Logs::Server_Client_Packet_With_Dump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size(), DumpPacketToString(p).c_str());
|
||||
}
|
||||
|
||||
EQApplicationPacket *newp = p->Copy();
|
||||
FastQueuePacket(&newp, ack_req);
|
||||
}
|
||||
|
||||
void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) {
|
||||
if(p == nullptr || *p == nullptr)
|
||||
return;
|
||||
m_structs->Encode(p, m_stream, ack_req);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void EQStreamProxy::Close() {
|
||||
m_stream->Close();
|
||||
}
|
||||
|
||||
std::string EQStreamProxy::GetRemoteAddr() const {
|
||||
return(m_stream->GetRemoteAddr());
|
||||
}
|
||||
|
||||
uint32 EQStreamProxy::GetRemoteIP() const {
|
||||
return(m_stream->GetRemoteIP());
|
||||
}
|
||||
|
||||
uint16 EQStreamProxy::GetRemotePort() const {
|
||||
return(m_stream->GetRemotePort());
|
||||
}
|
||||
|
||||
void EQStreamProxy::ReleaseFromUse() {
|
||||
m_stream->ReleaseFromUse();
|
||||
}
|
||||
|
||||
void EQStreamProxy::RemoveData() {
|
||||
m_stream->RemoveData();
|
||||
}
|
||||
|
||||
EQStreamInterface::Stats EQStreamProxy::GetStats() const
|
||||
{
|
||||
return m_stream->GetStats();
|
||||
}
|
||||
|
||||
void EQStreamProxy::ResetStats()
|
||||
{
|
||||
m_stream->ResetStats();
|
||||
}
|
||||
|
||||
EQStreamManagerInterface *EQStreamProxy::GetManager() const
|
||||
{
|
||||
return m_stream->GetManager();
|
||||
}
|
||||
|
||||
bool EQStreamProxy::CheckState(EQStreamState state) {
|
||||
if(m_stream)
|
||||
return(m_stream->CheckState(state));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
#ifndef EQSTREAMPROXY_H_
|
||||
#define EQSTREAMPROXY_H_
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "eq_stream_intf.h"
|
||||
#include <memory>
|
||||
|
||||
class StructStrategy;
|
||||
class OpcodeManager;
|
||||
class EQApplicationPacket;
|
||||
|
||||
class EQStreamProxy : public EQStreamInterface {
|
||||
public:
|
||||
//takes ownership of the stream.
|
||||
EQStreamProxy(std::shared_ptr<EQStreamInterface> &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);
|
||||
virtual EQApplicationPacket *PopPacket();
|
||||
virtual void Close();
|
||||
virtual std::string GetRemoteAddr() const;
|
||||
virtual uint32 GetRemoteIP() const;
|
||||
virtual uint16 GetRemotePort() const;
|
||||
virtual void ReleaseFromUse();
|
||||
virtual void RemoveData();
|
||||
virtual bool CheckState(EQStreamState state);
|
||||
virtual std::string Describe() const;
|
||||
virtual const EQEmu::versions::ClientVersion ClientVersion() const;
|
||||
virtual EQStreamState GetState();
|
||||
virtual void SetOpcodeManager(OpcodeManager **opm);
|
||||
virtual Stats GetStats() const;
|
||||
virtual void ResetStats();
|
||||
virtual EQStreamManagerInterface* GetManager() const;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<EQStreamInterface> 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.
|
||||
};
|
||||
|
||||
#endif /*EQSTREAMPROXY_H_*/
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef _EQSTREAMTYPE_H
|
||||
#define _EQSTREAMTYPE_H
|
||||
|
||||
typedef enum {
|
||||
UnknownStream=0,
|
||||
LoginStream,
|
||||
WorldStream,
|
||||
ZoneStream,
|
||||
ChatOrMailStream,
|
||||
ChatStream,
|
||||
MailStream
|
||||
} EQStreamType;
|
||||
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user