mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-30 11:45:46 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ad3d065225 |
@@ -1,21 +0,0 @@
|
|||||||
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
|
|
||||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.101.1/containers/ubuntu-18.04-git
|
|
||||||
{
|
|
||||||
"name": "Ubuntu 18.04 EQEMU",
|
|
||||||
// Moved from dockerfile to image so it builds faster
|
|
||||||
"image": "eqemu/devcontainer:0.0.2",
|
|
||||||
|
|
||||||
// Set *default* container specific settings.json values on container create.
|
|
||||||
"settings": {
|
|
||||||
"terminal.integrated.shell.linux": "/bin/bash"
|
|
||||||
},
|
|
||||||
|
|
||||||
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
|
|
||||||
|
|
||||||
// Add the IDs of extensions you want installed when the container is created.
|
|
||||||
"extensions": ["ms-vscode.cpptools", "ms-azuretools.vscode-docker"],
|
|
||||||
"mounts": ["source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"],
|
|
||||||
"remoteEnv": {
|
|
||||||
"HOST_PROJECT_PATH": "${localWorkspaceFolder}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
+10
-29
@@ -17,40 +17,21 @@
|
|||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
.bash_history
|
|
||||||
|
|
||||||
# CMake
|
# CMake
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
Makefile
|
Makefile
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
install_manifest.txt
|
install_manifest.txt
|
||||||
[Bb]uild*/
|
Build/
|
||||||
|
build/
|
||||||
|
Build32/
|
||||||
|
build32/
|
||||||
|
Build64/
|
||||||
|
build64/
|
||||||
|
Build_32/
|
||||||
|
build_32/
|
||||||
|
Build_64/
|
||||||
|
build_64/
|
||||||
log/
|
log/
|
||||||
logs/
|
logs/
|
||||||
vcpkg/
|
|
||||||
perl/
|
|
||||||
|
|
||||||
.idea/*
|
|
||||||
*cbp
|
|
||||||
|
|
||||||
submodules/*
|
|
||||||
cmake-build-debug/
|
|
||||||
|
|
||||||
.nfs.*
|
|
||||||
|
|
||||||
# Visual Studio and CMAKE Generated Files
|
|
||||||
/.vs/
|
|
||||||
*.vcxproj
|
|
||||||
*.vcxproj.filters
|
|
||||||
*.vcxproj.user
|
|
||||||
*.cmake
|
|
||||||
*.ilk
|
|
||||||
*.pdb
|
|
||||||
*.sln
|
|
||||||
*.dir/
|
|
||||||
libs/
|
|
||||||
bin/
|
|
||||||
/Win32
|
|
||||||
/x64
|
|
||||||
/client_files/**/CMakeFiles/
|
|
||||||
|
|||||||
-21
@@ -1,21 +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
|
|
||||||
[submodule "submodules/expected"]
|
|
||||||
path = submodules/expected
|
|
||||||
url = https://github.com/TartanLlama/expected.git
|
|
||||||
+14
-15
@@ -1,19 +1,18 @@
|
|||||||
language: cpp
|
language: cpp
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
dist: bionic
|
before_install:
|
||||||
|
- sudo apt-get update -qq
|
||||||
addons:
|
- sudo apt-get install -y libmysqlclient-dev libperl-dev libboost-dev liblua5.1-0-dev zlib1g-dev
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libmysqlclient-dev
|
|
||||||
- libperl-dev
|
|
||||||
- libboost-dev
|
|
||||||
- liblua5.1-0-dev
|
|
||||||
- zlib1g-dev
|
|
||||||
- uuid-dev
|
|
||||||
- libssl-dev
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cmake -G "Unix Makefiles" -DEQEMU_BUILD_TESTS=ON -DEQEMU_ENABLE_BOTS=ON -DEQEMU_BUILD_LOGIN=ON
|
- cmake -G "Unix Makefiles" -DEQEMU_BUILD_TESTS=ON -DEQEMU_ENABLE_BOTS=ON
|
||||||
- make -j2
|
- make
|
||||||
- ./bin/tests
|
- ./bin/tests
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- stable
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
irc:
|
||||||
|
channels: "irc.eqemulator.net#eqemucoders"
|
||||||
|
os: linux
|
||||||
Vendored
-16
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"/usr/include/mysql"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/bin/gcc",
|
|
||||||
"cStandard": "c11",
|
|
||||||
"cppStandard": "c++17"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
Vendored
-155
@@ -1,155 +0,0 @@
|
|||||||
{
|
|
||||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
||||||
// for the documentation about the tasks.json format
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "make",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "cd build && make",
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "make clean",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "cd build && make clean",
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "cmake",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "mkdir -p build && cd build && rm CMakeCache.txt && cmake -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -G 'Unix Makefiles' ..",
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"problemMatcher":{
|
|
||||||
"owner": "cpp",
|
|
||||||
"fileLocation": "relative",
|
|
||||||
"pattern":[
|
|
||||||
{
|
|
||||||
"regexp": "([\\w+|\\\\]*\\.\\w+)\\((\\d+)\\)\\: (warning|error) (.*)$",
|
|
||||||
"file": 1,
|
|
||||||
"location": 2,
|
|
||||||
"severity": 3,
|
|
||||||
"message": 4
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "download maps",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "mkdir -p build/bin && cd build/bin && wget https://codeload.github.com/Akkadius/EQEmuMaps/zip/master -O maps.zip && unzip -o maps.zip && rm ./maps -rf && mv EQEmuMaps-master maps && rm maps.zip",
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "download quests",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "mkdir -p build/bin && cd build/bin && cd server && git -C ./quests pull 2> /dev/null || git clone https://github.com/ProjectEQ/projecteqquests.git quests",
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "download eqemu_config",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "mkdir -p build/bin && cd build/bin && wget --no-check-certificate https://raw.githubusercontent.com/Akkadius/EQEmuInstall/master/eqemu_config_docker.json -O eqemu_config.json",
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "rebuild database (mariadb must be started)",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "mkdir -p build/bin && cd build/bin && docker run -i --rm --privileged -v ${HOST_PROJECT_PATH}/build/bin:/src --network=eqemu -it eqemu/server:0.0.3 bash -c './eqemu_server.pl source_peq_db && ./eqemu_server.pl check_db_updates && ./eqemu_server.pl linux_login_server_setup'",
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gcc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "zone 7000",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "docker stop zone7000 | true && docker network create eqemu | true && docker run -i --rm --name zone7000 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 --network=eqemu -p 7000:7000/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./zone dynamic_zone7000:7000",
|
|
||||||
"group": {
|
|
||||||
"kind": "test",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "zone 7001",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "docker stop zone7001 | true && docker network create eqemu | true && docker run -i --rm --name zone7001 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 --network=eqemu -p 7001:7001/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./zone dynamic_zone7001:7001",
|
|
||||||
"group": {
|
|
||||||
"kind": "test",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "loginserver",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "docker stop loginserver | true && docker network create eqemu | true && docker run -i --rm --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 --network=eqemu --name loginserver -p 5999:5999/udp -p 5998:5998/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./loginserver",
|
|
||||||
"group": {
|
|
||||||
"kind": "test",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "shared_memory, world",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "docker stop sharedmemory | true && docker stop world | true && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/build/bin:/src --network=eqemu --name sharedmemory eqemu/server:0.0.3 ./shared_memory && docker run --rm -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 -e LD_LIBRARY_PATH=/src/ --network=eqemu --name world -p 9000:9000 -p 9000:9000/udp -p 9001:9001 -p 9080:9080 eqemu/server:0.0.3 gdb -ex run ./world",
|
|
||||||
"group": {
|
|
||||||
"kind": "test",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "queryserv",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "docker stop queryserv | true && docker run --rm -v ${HOST_PROJECT_PATH}/build/bin:/src --ulimit core=10000000 -e LD_LIBRARY_PATH=/src/ --network=eqemu --name queryserv eqemu/server:0.0.3 gdb -ex run ./queryserv",
|
|
||||||
"group": {
|
|
||||||
"kind": "test",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "mariadb",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "docker stop mariadb | true && cd build/bin && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/build/bin/db:/bitnami/mariadb -p 3306:3306 -e MARIADB_DATABASE=peq -e MARIADB_USER=eqemu -e MARIADB_PASSWORD=eqemupass -e ALLOW_EMPTY_PASSWORD=yes --name mariadb --network=eqemu bitnami/mariadb:latest",
|
|
||||||
"group": {
|
|
||||||
"kind": "test",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
# Guide To Building From Source Without Installer
|
|
||||||
|
|
||||||
This guide is far from exhaustive, you should expect to have some experience with building C++ code before considering compiling the code from scratch. You should instead consider using the installer scripts if you don't want to hack on the code directly.
|
|
||||||
|
|
||||||
### CMake
|
|
||||||
|
|
||||||
EQEmu uses CMake as the build system on all platforms. You will need CMake 3.2 or higher to build from source.
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
|
|
||||||
The following libraries are required to build from source:
|
|
||||||
- [boost](https://www.boost.org/ "boost")
|
|
||||||
- [zlib](https://www.zlib.net/ "zlib") (If not included the source will build [zlib-ng](https://github.com/zlib-ng/zlib-ng "zlib-ng") instead)
|
|
||||||
- [libmysql](https://dev.mysql.com/downloads/connector/c/ "libmysql") or [libmariadb](https://github.com/MariaDB/mariadb-connector-c "libmariadb")
|
|
||||||
|
|
||||||
The following libraries are not strictly required but in many cased recommended.
|
|
||||||
- [OpenSSL](https://www.openssl.org/ "OpenSSL") or [mbedTLS](https://tls.mbed.org/ "mbedTLS") (Required for the loginserver and headless client)
|
|
||||||
- [libsodium](https://github.com/jedisct1/libsodium "libsodium") (Required for strong password hashing on the loginserver)
|
|
||||||
- [Lua 5.1](https://www.lua.org/ "Lua 5.1") or [LuaJit](http://luajit.org/ "LuaJit") (Required for Lua Quest Scripting)
|
|
||||||
- [Perl](https://www.perl.org/ "Perl") (Required for Perl Quest Scripting)
|
|
||||||
|
|
||||||
##### Windows
|
|
||||||
For windows it is suggested you make use of [vcpkg](https://github.com/microsoft/vcpkg "vcpkg") if you wish to build your own dependencies.
|
|
||||||
|
|
||||||
If you wish to use Perl then you should use whichever version of Perl you have installed on the target system.
|
|
||||||
|
|
||||||
You can also download a vcpkg export from our releases section for Visual Studio [x86](https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x86.zip "x86") or [x64](https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x64.zip "x64") that includes a toolchain file you can pass to CMake.
|
|
||||||
|
|
||||||
##### Linux
|
|
||||||
For Linux you simply can install the dependencies from your package manager, below is an example of doing it on Ubuntu using apt-get.
|
|
||||||
|
|
||||||
sudo apt-get install libmysqlclient-dev libperl-dev libboost-dev liblua5.1-0-dev zlib1g-dev uuid-dev libssl-dev
|
|
||||||
|
|
||||||
### Running CMake
|
|
||||||
|
|
||||||
##### Windows
|
|
||||||
The following is a modified command our automated build server uses to run CMake via the release vcpkg export and its toolchain file.
|
|
||||||
|
|
||||||
Assuming it is starting in c:/projects/eqemu and the x64 dependencies were extracted to c:/projects/eqemu/vcpkg.
|
|
||||||
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake -G "Visual Studio 15 2017 Win64" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_ZLIB=ON -DEQEMU_ENABLE_BOTS=ON -DCMAKE_TOOLCHAIN_FILE="c:/projects/eqemu/vcpkg/vcpkg-export-20180828-145455/scripts/buildsystems/vcpkg.cmake" ..
|
|
||||||
|
|
||||||
##### Linux
|
|
||||||
Similarly to Windows running CMake on Linux is simple it just omits the toolchain file and uses a different generator.
|
|
||||||
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake -G "Unix Makefiles" -DEQEMU_BUILD_TESTS=ON -DEQEMU_ENABLE_BOTS=ON -DEQEMU_BUILD_LOGIN=ON ..
|
|
||||||
|
|
||||||
### Building
|
|
||||||
|
|
||||||
##### Windows
|
|
||||||
Inside the build directory a file EQEmu.sln should be produced by a successful run of the CMake command. You can either open this with Visual Studio or build it directly with MSBuild via the command line.
|
|
||||||
|
|
||||||
msbuild EQEmu.sln /p:Configuration=Release
|
|
||||||
|
|
||||||
##### Linux
|
|
||||||
From the build directory you can simply call make to build.
|
|
||||||
|
|
||||||
For example.
|
|
||||||
|
|
||||||
make -j4
|
|
||||||
+280
-310
@@ -1,28 +1,124 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
#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_STREAM_SEND_RATE
|
||||||
|
#EQEMU_STREAM_DECAY_RATE
|
||||||
|
#EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL
|
||||||
|
#EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX
|
||||||
|
#EQEMU_STREAM_AVERAGE_DELTA_MAX
|
||||||
|
#EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS
|
||||||
|
#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_MAP_DIR
|
||||||
|
|
||||||
|
#We set a fairly new version (as of 2013) because I found finding perl was a bit... buggy on older ones
|
||||||
|
#Can change this if you really want but you should upgrade!
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
|
|
||||||
|
#FindMySQL is located here so lets make it so CMake can find it
|
||||||
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
|
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
IF(POLICY CMP0074)
|
#Our project name is EQEmu
|
||||||
CMAKE_POLICY(SET CMP0074 NEW)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
PROJECT(EQEmu)
|
PROJECT(EQEmu)
|
||||||
|
|
||||||
|
#Default build type is set to RelWithDebInfo for generators that honor that like makefiles
|
||||||
IF(NOT CMAKE_BUILD_TYPE)
|
IF(NOT CMAKE_BUILD_TYPE)
|
||||||
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
|
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
|
||||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
SET(CMAKE_CXX_STANDARD 11)
|
#Add our various windows definitions
|
||||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
IF(MSVC OR MINGW)
|
||||||
SET(CMAKE_CXX_EXTENSIONS OFF)
|
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(MSVC)
|
||||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
#Set our default locations for zlib/mysql based on x86/x64
|
||||||
ADD_DEFINITIONS(-DNOMINMAX)
|
IF(CMAKE_CL_64)
|
||||||
ADD_DEFINITIONS(-DCRASH_LOGGING)
|
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64")
|
||||||
|
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64")
|
||||||
|
SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_x64")
|
||||||
|
ELSE(CMAKE_CL_64)
|
||||||
|
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86")
|
||||||
|
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86")
|
||||||
|
SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_x86")
|
||||||
|
ENDIF(CMAKE_CL_64)
|
||||||
|
|
||||||
|
#disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere
|
||||||
|
OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON)
|
||||||
|
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
|
||||||
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
|
||||||
|
|
||||||
|
#fast FP if you'd like it
|
||||||
|
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
|
||||||
|
IF(EQEMU_FAST_FLOATINGPOINT)
|
||||||
|
ADD_DEFINITIONS(/fp:fast)
|
||||||
|
ENDIF(EQEMU_FAST_FLOATINGPOINT)
|
||||||
|
|
||||||
|
#crash logging currently only works on windows x86/x64
|
||||||
|
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
|
||||||
|
IF(EQEMU_ENABLE_CRASH_LOGGING)
|
||||||
|
ADD_DEFINITIONS(-DCRASH_LOGGING)
|
||||||
|
ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
|
||||||
|
|
||||||
|
#Disable safe SEH or not?
|
||||||
|
OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF)
|
||||||
|
IF(EQEMU_DISABLE_SAFESEH)
|
||||||
|
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
|
||||||
|
SET(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
|
||||||
|
ENDIF(EQEMU_DISABLE_SAFESEH)
|
||||||
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
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)
|
ELSE(MSVC)
|
||||||
|
#Normally set by perl but we don't use the perl flags anymore so we set it.
|
||||||
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
|
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|
||||||
@@ -30,7 +126,6 @@ ENDIF(MSVC)
|
|||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
ADD_DEFINITIONS(-DFREEBSD)
|
ADD_DEFINITIONS(-DFREEBSD)
|
||||||
ADD_DEFINITIONS(-D_GLIBCXX_USE_C99)
|
|
||||||
SET(FREEBSD TRUE)
|
SET(FREEBSD TRUE)
|
||||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||||
@@ -39,325 +134,205 @@ IF(UNIX)
|
|||||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||||
ENDIF(UNIX)
|
ENDIF(UNIX)
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DGLM_FORCE_RADIANS)
|
#debug level, 5 is default. Most people wont ever change this but it's there if you want to
|
||||||
ADD_DEFINITIONS(-DGLM_FORCE_CTOR_INIT)
|
SET(EQEMU_DEBUG_LEVEL 5 CACHE STRING "EQEmu debug level:
|
||||||
ADD_DEFINITIONS(-DGLM_ENABLE_EXPERIMENTAL)
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
#MSVC can fetch dependencies automatically.
|
SET(EQEMU_LOG_LEVEL_STATUS 2 CACHE STRING "EQEmu logging level for [Status]:
|
||||||
IF(MSVC)
|
0 - Disabled
|
||||||
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/DependencyHelperMSVC.cmake")
|
1 - Ouput to File Enabled
|
||||||
ENDIF()
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
#Find everything we need
|
SET(EQEMU_LOG_LEVEL_NORMAL 3 CACHE STRING "EQEmu logging level for [Normal]:
|
||||||
FIND_PACKAGE(Boost REQUIRED)
|
0 - Disabled
|
||||||
FIND_PACKAGE(MySQL)
|
1 - Ouput to File Enabled
|
||||||
FIND_PACKAGE(MariaDB)
|
2 - Output to stdout Enabled
|
||||||
FIND_PACKAGE(ZLIB)
|
3 - Output to File and stdout Enabled
|
||||||
FIND_PACKAGE(OpenSSL)
|
8 - Output to stderr Enabled
|
||||||
FIND_PACKAGE(Lua51)
|
9 - Output to File and stderr Enabled
|
||||||
FIND_PACKAGE(PerlLibs)
|
11 - Output to File, stdout and stderr Enabled"
|
||||||
FIND_PACKAGE(Sodium)
|
)
|
||||||
FIND_PACKAGE(mbedTLS)
|
|
||||||
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
SET(EQEMU_LOG_LEVEL_ERROR 2 CACHE STRING "EQEmu logging level for [Error]:
|
||||||
MESSAGE(STATUS "* Library Detection *")
|
0 - Disabled
|
||||||
MESSAGE(STATUS "**************************************************")
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
IF(MYSQL_FOUND)
|
SET(EQEMU_LOG_LEVEL_DEBUG 3 CACHE STRING "EQEmu logging level for [Debug]:
|
||||||
MESSAGE(STATUS "* MySQL: FOUND *")
|
0 - Disabled
|
||||||
ELSE()
|
1 - Ouput to File Enabled
|
||||||
MESSAGE(STATUS "* MySQL: MISSING *")
|
2 - Output to stdout Enabled
|
||||||
ENDIF()
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
IF(MARIADB_FOUND)
|
SET(EQEMU_LOG_LEVEL_QUEST 2 CACHE STRING "EQEmu logging level for [Quest]:
|
||||||
MESSAGE(STATUS "* MariaDB: FOUND *")
|
0 - Disabled
|
||||||
ELSE()
|
1 - Ouput to File Enabled
|
||||||
MESSAGE(STATUS "* MariaDB: MISSING *")
|
2 - Output to stdout Enabled
|
||||||
ENDIF()
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
IF(ZLIB_FOUND)
|
SET(EQEMU_LOG_LEVEL_COMMANDS 1 CACHE STRING "EQEmu logging level for [Commands]:
|
||||||
MESSAGE(STATUS "* ZLIB: FOUND *")
|
0 - Disabled
|
||||||
ELSE()
|
1 - Ouput to File Enabled
|
||||||
MESSAGE(STATUS "* ZLIB: MISSING *")
|
2 - Output to stdout Enabled
|
||||||
ENDIF()
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
IF(Lua51_FOUND)
|
SET(EQEMU_LOG_LEVEL_CRASH 3 CACHE STRING "EQEmu logging level for [Crash]:
|
||||||
MESSAGE(STATUS "* Lua: FOUND *")
|
0 - Disabled
|
||||||
ELSE()
|
1 - Ouput to File Enabled
|
||||||
MESSAGE(STATUS "* Lua: MISSING *")
|
2 - Output to stdout Enabled
|
||||||
ENDIF()
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
IF(PerlLibs_FOUND)
|
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)
|
||||||
MESSAGE(STATUS "* Perl: FOUND *")
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(STATUS "* Perl: MISSING *")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(SODIUM_FOUND)
|
SET(EQEMU_STREAM_SEND_RATE 1048576 CACHE STRING "Advanced: Base amount of data stream can send before throttle.")
|
||||||
MESSAGE(STATUS "* libsodium: FOUND *")
|
SET(EQEMU_STREAM_DECAY_RATE 78642 CACHE STRING "Advanced: Base amount of data stream recovers per tic.")
|
||||||
ELSE()
|
SET(EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL 3.0 CACHE STRING "Advanced: Multiplier on retransmit timeout.")
|
||||||
MESSAGE(STATUS "* libsodium: MISSING *")
|
SET(EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX 5000 CACHE STRING "Advanced: Max in ms for retransmit timeout timer.")
|
||||||
ENDIF()
|
SET(EQEMU_STREAM_AVERAGE_DELTA_MAX 2500 CACHE STRING "Advanced: The maximum average delta in ms allowed.")
|
||||||
|
SET(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS TRUE CACHE BOOL "Advanced: Whether or not acked packets can be retransmitted")
|
||||||
|
MARK_AS_ADVANCED(EQEMU_STREAM_SEND_RATE EQEMU_STREAM_DECAY_RATE EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX EQEMU_STREAM_AVERAGE_DELTA_MAX EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
|
||||||
|
|
||||||
IF(OpenSSL_FOUND)
|
#NPC Types Cache Behavior
|
||||||
MESSAGE(STATUS "* OpenSSL: FOUND *")
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(STATUS "* OpenSSL: MISSING *")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(MBEDTLS_FOUND)
|
|
||||||
MESSAGE(STATUS "* mbedTLS: FOUND *")
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(STATUS "* mbedTLS: MISSING *")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
|
||||||
|
|
||||||
#options
|
|
||||||
OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (will cause a larger database hit on #repop but is more convienent)." ON)
|
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)
|
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)
|
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
|
||||||
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
|
|
||||||
OPTION(EQEMU_BUILD_LOGIN "Build the login server." ON)
|
|
||||||
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
|
|
||||||
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
|
||||||
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
|
||||||
|
|
||||||
IF(EQEMU_COMMANDS_LOGGING)
|
IF(EQEMU_COMMANDS_LOGGING)
|
||||||
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
|
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
|
||||||
ENDIF(EQEMU_COMMANDS_LOGGING)
|
ENDIF(EQEMU_COMMANDS_LOGGING)
|
||||||
|
|
||||||
|
IF(EQEMU_DISABLE_LOGSYS)
|
||||||
|
ADD_DEFINITIONS(-DDISABLE_LOGSYS)
|
||||||
|
ENDIF(EQEMU_DISABLE_LOGSYS)
|
||||||
|
|
||||||
IF(EQEMU_ENABLE_BOTS)
|
IF(EQEMU_ENABLE_BOTS)
|
||||||
ADD_DEFINITIONS(-DBOTS)
|
ADD_DEFINITIONS(-DBOTS)
|
||||||
ENDIF(EQEMU_ENABLE_BOTS)
|
ENDIF(EQEMU_ENABLE_BOTS)
|
||||||
|
|
||||||
#database
|
#What to build
|
||||||
IF(MySQL_FOUND AND MariaDB_FOUND)
|
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
|
||||||
SET(DATABASE_LIBRARY_SELECTION MySQL CACHE STRING "Database library to use:
|
OPTION(EQEMU_BUILD_LOGIN "Build the login server." OFF)
|
||||||
MySQL
|
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
||||||
MariaDB"
|
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)
|
||||||
|
|
||||||
|
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(-DRATEBASE=${EQEMU_STREAM_SEND_RATE})
|
||||||
|
ADD_DEFINITIONS(-DDECAYBASE=${EQEMU_STREAM_DECAY_RATE})
|
||||||
|
ADD_DEFINITIONS(-DRETRANSMIT_TIMEOUT_MULT=${EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL})
|
||||||
|
ADD_DEFINITIONS(-DRETRANSMIT_TIMEOUT_MAX=${EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX})
|
||||||
|
ADD_DEFINITIONS(-DAVERAGE_DELTA_MAX=${EQEMU_STREAM_AVERAGE_DELTA_MAX})
|
||||||
|
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)
|
||||||
|
|
||||||
|
IF(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
|
||||||
|
ADD_DEFINITIONS(-DRETRANSMIT_ACKED_PACKETS=true)
|
||||||
|
ELSE(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
|
||||||
|
ADD_DEFINITIONS(-DRETRANSMIT_ACKED_PACKETS=false)
|
||||||
|
ENDIF(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
|
||||||
|
|
||||||
|
#Find everything we need
|
||||||
|
FIND_PACKAGE(ZLIB REQUIRED)
|
||||||
|
FIND_PACKAGE(MySQL REQUIRED)
|
||||||
|
IF(EQEMU_BUILD_PERL)
|
||||||
|
FIND_PACKAGE(PerlLibs REQUIRED)
|
||||||
|
INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}")
|
||||||
|
ENDIF(EQEMU_BUILD_PERL)
|
||||||
|
|
||||||
|
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("${LUA_INCLUDE_DIR}" "${Boost_INCLUDE_DIRS}" "luabind")
|
||||||
|
|
||||||
IF(DATABASE_LIBRARY_SELECTION STREQUAL "MySQL")
|
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
|
||||||
SET(DATABASE_LIBRARY_TYPE " MySQL")
|
IF(EQEMU_SANITIZE_LUA_LIBS)
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
|
ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
|
ENDIF(EQEMU_SANITIZE_LUA_LIBS)
|
||||||
ELSEIF(DATABASE_LIBRARY_SELECTION STREQUAL "MariaDB")
|
ENDIF(EQEMU_BUILD_LUA)
|
||||||
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(FATAL_ERROR "Unknown database library set, should be one of: MySQL, MariaDB")
|
|
||||||
ENDIF()
|
|
||||||
ELSEIF(MariaDB_FOUND)
|
|
||||||
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
|
|
||||||
ELSEIF(MySQL_FOUND)
|
|
||||||
SET(DATABASE_LIBRARY_TYPE " MySQL")
|
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
|
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(FATAL_ERROR "One of MySQL or MariaDB is a required dependency.")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
#security
|
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/common/glm/glm")
|
||||||
#prefer openssl to mbedtls (arbitrary)
|
|
||||||
IF(OpenSSL_FOUND AND MBEDTLS_FOUND)
|
|
||||||
SET(TLS_LIBRARY_SELECTION OpenSSL CACHE STRING "TLS library to use:
|
|
||||||
OpenSSL
|
|
||||||
mbedTLS"
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(TLS_LIBRARY_SELECTION STREQUAL "OpenSSL")
|
|
||||||
SET(TLS_LIBRARY_TYPE " OpenSSL")
|
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
|
||||||
SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
|
|
||||||
SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
|
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
|
|
||||||
ELSEIF(TLS_LIBRARY_SELECTION STREQUAL "mbedTLS")
|
|
||||||
SET(TLS_LIBRARY_TYPE " mbedTLS")
|
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
|
||||||
SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
|
|
||||||
SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
|
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(FATAL_ERROR "Unknown TLS library set, should be one of: OpenSSL, mbedTLS")
|
|
||||||
ENDIF()
|
|
||||||
ELSEIF(OpenSSL_FOUND)
|
|
||||||
SET(TLS_LIBRARY_TYPE " OpenSSL")
|
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
|
||||||
SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
|
|
||||||
SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
|
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
|
|
||||||
ELSEIF(MBEDTLS_FOUND)
|
|
||||||
SET(TLS_LIBRARY_TYPE " mbedTLS")
|
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
|
||||||
SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
|
|
||||||
SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
|
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
|
|
||||||
ELSE()
|
|
||||||
SET(TLS_LIBRARY_TYPE "Disabled")
|
|
||||||
SET(TLS_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(SODIUM_FOUND)
|
IF(EQEMU_BUILD_LUA)
|
||||||
SET(SODIUM_LIBRARY_TYPE "Libsodium")
|
ADD_SUBDIRECTORY(luabind)
|
||||||
SET(SODIUM_LIBRARY_ENABLED ON)
|
ENDIF(EQEMU_BUILD_LUA)
|
||||||
SET(SODIUM_LIBRARY_LIBS ${SODIUM_LIBRARIES})
|
|
||||||
SET(SODIUM_LIBRARY_INCLUDE ${SODIUM_INCLUDE_DIRS})
|
|
||||||
ADD_DEFINITIONS(-DENABLE_SECURITY)
|
|
||||||
ELSE()
|
|
||||||
SET(SODIUM_LIBRARY_TYPE " Disabled")
|
|
||||||
SET(SODIUM_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(Lua51_FOUND)
|
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
|
||||||
SET(LUA_LIBRARY_TYPE " Lua 5.1")
|
|
||||||
SET(LUA_LIBRARY_ENABLED ON)
|
|
||||||
SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind)
|
|
||||||
SET(LUA_LIBRARY_INCLUDE ${LUA_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
|
||||||
ELSE()
|
|
||||||
SET(LUA_LIBRARY_TYPE "Disabled")
|
|
||||||
SET(LUA_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(PerlLibs_FOUND)
|
|
||||||
SET(PERL_LIBRARY_TYPE " Perl")
|
|
||||||
SET(PERL_LIBRARY_ENABLED ON)
|
|
||||||
SET(PERL_LIBRARY_LIBS ${PERL_LIBRARY})
|
|
||||||
SET(PERL_LIBRARY_INCLUDE ${PERL_INCLUDE_PATH})
|
|
||||||
ELSE()
|
|
||||||
SET(PERL_LIBRARY_TYPE "Disabled")
|
|
||||||
SET(PERL_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
#use zlib if exists
|
|
||||||
IF(ZLIB_FOUND)
|
|
||||||
OPTION(EQEMU_BUILD_ZLIB "Build internal version of zlib." ON)
|
|
||||||
IF(EQEMU_BUILD_ZLIB)
|
|
||||||
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
|
||||||
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
|
||||||
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
|
||||||
ELSE()
|
|
||||||
SET(ZLIB_LIBRARY_TYPE " zlib")
|
|
||||||
SET(ZLIB_LIBRARY_LIBS ${ZLIB_LIBRARY})
|
|
||||||
SET(ZLIB_LIBRARY_INCLUDE ${ZLIB_INCLUDE_DIRS})
|
|
||||||
ENDIF()
|
|
||||||
ELSE()
|
|
||||||
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
|
||||||
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
|
||||||
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
MESSAGE(STATUS "")
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
|
||||||
MESSAGE(STATUS "* Library Usage *")
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
|
||||||
MESSAGE(STATUS "* Database: ${DATABASE_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* TLS: ${TLS_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* Sodium: ${SODIUM_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* Lua: ${LUA_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* Perl: ${PERL_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* zlib: ${ZLIB_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
|
||||||
|
|
||||||
#setup server libs and headers
|
|
||||||
SET(SERVER_LIBS common ${DATABASE_LIBRARY_LIBS} ${ZLIB_LIBRARY_LIBS} ${Boost_LIBRARIES} uv_a fmt RecastNavigation::Detour)
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${DATABASE_LIBRARY_INCLUDE}")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_LIBRARY_INCLUDE}")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${Boost_INCLUDE_DIRS}")
|
|
||||||
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/expected/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")
|
|
||||||
|
|
||||||
OPTION(EQEMU_BUILD_LOGGING "Build Logging (To speed up compilation)" ON)
|
|
||||||
IF(EQEMU_BUILD_LOGGING)
|
|
||||||
ADD_DEFINITIONS(-DBUILD_LOGGING)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(TLS_LIBRARY_ENABLED)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${TLS_LIBRARY_LIBS})
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${TLS_LIBRARY_INCLUDE}")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(SODIUM_LIBRARY_ENABLED)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${SODIUM_LIBRARY_LIBS})
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${SODIUM_LIBRARY_INCLUDE}")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(LUA_LIBRARY_ENABLED)
|
|
||||||
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_LUA)
|
|
||||||
ADD_DEFINITIONS(-DLUA_EQEMU)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${LUA_LIBRARY_LIBS})
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${LUA_LIBRARY_INCLUDE}")
|
|
||||||
|
|
||||||
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()
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(PERL_LIBRARY_ENABLED)
|
|
||||||
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
|
||||||
IF(EQEMU_BUILD_PERL)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${PERL_LIBRARY_LIBS})
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${PERL_LIBRARY_INCLUDE}")
|
|
||||||
ADD_DEFINITIONS(-DEMBPERL)
|
|
||||||
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
|
|
||||||
ENDIF()
|
|
||||||
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_LOGIN AND NOT TLS_LIBRARY_ENABLED)
|
|
||||||
MESSAGE(FATAL_ERROR "Login server requires a TLS Library to build.")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_HC AND NOT TLS_LIBRARY_ENABLED)
|
|
||||||
MESSAGE(FATAL_ERROR "Headless client requires a TLS Library to build.")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
|
||||||
ADD_SUBDIRECTORY(common)
|
ADD_SUBDIRECTORY(common)
|
||||||
ADD_SUBDIRECTORY(libs)
|
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
|
||||||
ADD_SUBDIRECTORY(submodules/fmt)
|
|
||||||
ADD_SUBDIRECTORY(submodules/libuv)
|
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
||||||
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)
|
|
||||||
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_SERVER)
|
IF(EQEMU_BUILD_SERVER)
|
||||||
ADD_SUBDIRECTORY(shared_memory)
|
ADD_SUBDIRECTORY(shared_memory)
|
||||||
ADD_SUBDIRECTORY(world)
|
ADD_SUBDIRECTORY(world)
|
||||||
@@ -366,15 +341,10 @@ IF(EQEMU_BUILD_SERVER)
|
|||||||
ADD_SUBDIRECTORY(queryserv)
|
ADD_SUBDIRECTORY(queryserv)
|
||||||
ADD_SUBDIRECTORY(eqlaunch)
|
ADD_SUBDIRECTORY(eqlaunch)
|
||||||
ENDIF(EQEMU_BUILD_SERVER)
|
ENDIF(EQEMU_BUILD_SERVER)
|
||||||
|
|
||||||
IF(EQEMU_BUILD_LOGIN)
|
IF(EQEMU_BUILD_LOGIN)
|
||||||
ADD_SUBDIRECTORY(loginserver)
|
ADD_SUBDIRECTORY(loginserver)
|
||||||
ENDIF(EQEMU_BUILD_LOGIN)
|
ENDIF(EQEMU_BUILD_LOGIN)
|
||||||
|
|
||||||
IF(EQEMU_BUILD_HC)
|
|
||||||
ADD_SUBDIRECTORY(hc)
|
|
||||||
ENDIF(EQEMU_BUILD_HC)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_TESTS)
|
IF(EQEMU_BUILD_TESTS)
|
||||||
ADD_SUBDIRECTORY(tests)
|
ADD_SUBDIRECTORY(tests)
|
||||||
ENDIF(EQEMU_BUILD_TESTS)
|
ENDIF(EQEMU_BUILD_TESTS)
|
||||||
|
|||||||
@@ -0,0 +1,339 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser General
|
||||||
|
Public License instead of this License.
|
||||||
@@ -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>.
|
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
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 License
|
||||||
|
StackWalker - New BSD License
|
||||||
|
ZLib - ZLib License
|
||||||
|
MySQL - GPL
|
||||||
|
Perl - GPL / ActiveState (under the assumption that this is a free project).
|
||||||
|
CPPUnit - GLP
|
||||||
|
StringUtilities - Apache
|
||||||
@@ -1,78 +1,53 @@
|
|||||||
# EQEmulator Core Server
|
EQEmu
|
||||||
|Travis CI (Linux)|Appveyor (Windows x86) |Appveyor (Windows x64) |
|
===
|
||||||
|:---:|:---:|:---:|
|
|
||||||
|[](https://travis-ci.org/EQEmu/Server) |[](https://ci.appveyor.com/project/KimLS/server) |[](https://ci.appveyor.com/project/KimLS/server-87crp) |
|
|
||||||
|
|
||||||
***
|
[](https://travis-ci.org/EQEmu/Server)
|
||||||
|
|
||||||
**EQEmulator is a custom completely from-scratch open source server implementation for EverQuest built mostly on C++**
|
Overview
|
||||||
* 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
|
EQEmu is a custom server implementation for EverQuest
|
||||||
| |Windows|Linux|
|
|
||||||
|:---:|:---:|:---:|
|
|
||||||
|**Install Count**|||
|
|
||||||
### > Windows
|
|
||||||
* [Install](https://eqemu.gitbook.io/server/categories/how-to-guides/installation/server-installation-windows)
|
|
||||||
|
|
||||||
### > Debian/Ubuntu/CentOS/Fedora
|
Dependencies
|
||||||
* 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
|
For Windows: http://eqemu.github.io
|
||||||
|
|
||||||
## Supported Clients
|
Login Server dependencies for Windows/Linux/OSX: http://eqemu.github.io
|
||||||
|
|
||||||
|Titanium Edition|Secrets of Faydwer|Seeds of Destruction|Underfoot|Rain of Fear|
|
For Debian based distros (adjust to your local flavor):
|
||||||
|:---:|:---:|:---:|:---:|:---:|
|
|
||||||
|<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">
|
- libmysqlclient-dev
|
||||||
* Please use the [issue tracker](https://github.com/EQEmu/Server/issues) provided by GitHub to send us bug
|
- libperl-dev
|
||||||
|
- liblua5.1-0-dev (5.2 should work as well)
|
||||||
|
- libboost-dev
|
||||||
|
|
||||||
|
Further instructions on building the source can be found on the
|
||||||
|
[wiki](http://wiki.eqemulator.org/i?M=Wiki).
|
||||||
|
|
||||||
|
Bug reports
|
||||||
|
---
|
||||||
|
|
||||||
|
Please use the [issue tracker](https://github.com/EQEmu/Server/issues) provided by GitHub to send us bug
|
||||||
reports or feature requests.
|
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 [EQEmu Forums](http://www.eqemulator.org/forums/) also have forums to submit
|
||||||
|
bugs/get help with bugs.
|
||||||
|
|
||||||
* The preferred way to contribute is to fork the repo and submit a pull request on
|
Contributions
|
||||||
|
---
|
||||||
|
|
||||||
|
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
|
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
|
try IRC. 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)
|
[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.
|
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">
|
Contact
|
||||||
|
---
|
||||||
|
- **User IRC Channel**: `#eqemu` on `irc.eqemulator.net`
|
||||||
|
- **Developer IRC Channel**: `#eqemucoders` on `irc.eqemulator.net`
|
||||||
|
|
||||||
- Discord Channel: https://discord.gg/QHsm7CD
|
|
||||||
- **User Discord Channel**: `#general`
|
|
||||||
- **Developer Discord Channel**: `#eqemucoders`
|
|
||||||
|
|
||||||
## Resources
|
|
||||||
- [EQEmulator Forums](http://www.eqemulator.org/forums)
|
- [EQEmulator Forums](http://www.eqemulator.org/forums)
|
||||||
- [EQEmulator Wiki](https://eqemu.gitbook.io/)
|
- [EQEmulator Wiki](http://wiki.eqemulator.org/i?M=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,3 +0,0 @@
|
|||||||
# Security Policy - Reporting Vulnerabilities
|
|
||||||
|
|
||||||
When reporting active hacks, exploits and other vulnerabilities, please describe how to reproduce said report and if you can provide context into a possible solution
|
|
||||||
@@ -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
|
|
||||||
+779
-2735
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
|
|
||||||
add_subdirectory(import)
|
add_subdirectory(import)
|
||||||
add_subdirectory(export)
|
add_subdirectory(export)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
|
|
||||||
SET(export_sources
|
SET(export_sources
|
||||||
main.cpp
|
main.cpp
|
||||||
@@ -9,8 +9,28 @@ SET(export_headers
|
|||||||
|
|
||||||
ADD_EXECUTABLE(export_client_files ${export_sources} ${export_headers})
|
ADD_EXECUTABLE(export_client_files ${export_sources} ${export_headers})
|
||||||
|
|
||||||
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(export_client_files ${SERVER_LIBS})
|
TARGET_LINK_LIBRARIES(export_client_files common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||||
|
|
||||||
|
IF(MSVC)
|
||||||
|
SET_TARGET_PROPERTIES(export_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||||
|
TARGET_LINK_LIBRARIES(export_client_files "Ws2_32.lib")
|
||||||
|
ENDIF(MSVC)
|
||||||
|
|
||||||
|
IF(MINGW)
|
||||||
|
TARGET_LINK_LIBRARIES(export_client_files "WS2_32")
|
||||||
|
ENDIF(MINGW)
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(export_client_files "${CMAKE_DL_LIBS}")
|
||||||
|
TARGET_LINK_LIBRARIES(export_client_files "z")
|
||||||
|
TARGET_LINK_LIBRARIES(export_client_files "m")
|
||||||
|
IF(NOT DARWIN)
|
||||||
|
TARGET_LINK_LIBRARIES(export_client_files "rt")
|
||||||
|
ENDIF(NOT DARWIN)
|
||||||
|
TARGET_LINK_LIBRARIES(export_client_files "pthread")
|
||||||
|
ADD_DEFINITIONS(-fPIC)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
|||||||
@@ -17,9 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "../../common/debug.h"
|
||||||
#include "../../common/eqemu_logsys.h"
|
|
||||||
#include "../../common/global_define.h"
|
|
||||||
#include "../../common/shareddb.h"
|
#include "../../common/shareddb.h"
|
||||||
#include "../../common/eqemu_config.h"
|
#include "../../common/eqemu_config.h"
|
||||||
#include "../../common/platform.h"
|
#include "../../common/platform.h"
|
||||||
@@ -27,77 +25,47 @@
|
|||||||
#include "../../common/rulesys.h"
|
#include "../../common/rulesys.h"
|
||||||
#include "../../common/string_util.h"
|
#include "../../common/string_util.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase *db);
|
void ExportSpells(SharedDatabase *db);
|
||||||
void ExportSkillCaps(SharedDatabase *db);
|
void ExportSkillCaps(SharedDatabase *db);
|
||||||
void ExportBaseData(SharedDatabase *db);
|
void ExportBaseData(SharedDatabase *db);
|
||||||
void ExportDBStrings(SharedDatabase *db);
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
RegisterExecutablePlatform(ExePlatformClientExport);
|
RegisterExecutablePlatform(ExePlatformClientExport);
|
||||||
LogSys.LoadLogSettingsDefaults();
|
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
LogInfo("Client Files Export Utility");
|
LogFile->write(EQEMuLog::Status, "Client Files Export Utility");
|
||||||
if(!EQEmuConfig::LoadConfig()) {
|
if(!EQEmuConfig::LoadConfig()) {
|
||||||
LogError("Unable to load configuration file");
|
LogFile->write(EQEMuLog::Error, "Unable to load configuration file.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Config = EQEmuConfig::get();
|
const EQEmuConfig *config = EQEmuConfig::get();
|
||||||
|
if(!load_log_settings(config->LogSettingsFile.c_str())) {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Warning: unable to read %s.", config->LogSettingsFile.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
SharedDatabase database;
|
SharedDatabase database;
|
||||||
LogInfo("Connecting to database");
|
LogFile->write(EQEMuLog::Status, "Connecting to database...");
|
||||||
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
|
if(!database.Connect(config->DatabaseHost.c_str(), config->DatabaseUsername.c_str(),
|
||||||
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) {
|
config->DatabasePassword.c_str(), config->DatabaseDB.c_str(), config->DatabasePort)) {
|
||||||
LogError("Unable to connect to the database, cannot continue without a database connection");
|
LogFile->write(EQEMuLog::Error, "Unable to connect to the database, cannot continue without a "
|
||||||
|
"database connection");
|
||||||
return 1;
|
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);
|
ExportSpells(&database);
|
||||||
ExportSkillCaps(&database);
|
ExportSkillCaps(&database);
|
||||||
ExportBaseData(&database);
|
ExportBaseData(&database);
|
||||||
ExportDBStrings(&database);
|
|
||||||
|
|
||||||
LogSys.CloseFileLogs();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase *db) {
|
void ExportSpells(SharedDatabase *db) {
|
||||||
LogInfo("Exporting Spells");
|
LogFile->write(EQEMuLog::Status, "Exporting Spells...");
|
||||||
|
|
||||||
FILE *f = fopen("export/spells_us.txt", "w");
|
FILE *f = fopen("export/spells_us.txt", "w");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open export/spells_us.txt to write, skipping.");
|
LogFile->write(EQEMuLog::Error, "Unable to open export/spells_us.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +89,7 @@ void ExportSpells(SharedDatabase *db) {
|
|||||||
fprintf(f, "%s\n", line.c_str());
|
fprintf(f, "%s\n", line.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in ExportSpells query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@@ -134,6 +103,7 @@ bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) {
|
|||||||
class_id, skill_id);
|
class_id, skill_id);
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
if(!results.Success()) {
|
if(!results.Success()) {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in skill_usable query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,6 +123,7 @@ int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
|
|||||||
class_id, skill_id, level);
|
class_id, skill_id, level);
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in get_skill query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,11 +135,11 @@ int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExportSkillCaps(SharedDatabase *db) {
|
void ExportSkillCaps(SharedDatabase *db) {
|
||||||
LogInfo("Exporting Skill Caps");
|
LogFile->write(EQEMuLog::Status, "Exporting Skill Caps...");
|
||||||
|
|
||||||
FILE *f = fopen("export/SkillCaps.txt", "w");
|
FILE *f = fopen("export/SkillCaps.txt", "w");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open export/SkillCaps.txt to write, skipping.");
|
LogFile->write(EQEMuLog::Error, "Unable to open export/SkillCaps.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,11 +164,11 @@ void ExportSkillCaps(SharedDatabase *db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExportBaseData(SharedDatabase *db) {
|
void ExportBaseData(SharedDatabase *db) {
|
||||||
LogInfo("Exporting Base Data");
|
LogFile->write(EQEMuLog::Status, "Exporting Base Data...");
|
||||||
|
|
||||||
FILE *f = fopen("export/BaseData.txt", "w");
|
FILE *f = fopen("export/BaseData.txt", "w");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open export/BaseData.txt to write, skipping.");
|
LogFile->write(EQEMuLog::Error, "Unable to open export/BaseData.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,38 +189,8 @@ void ExportBaseData(SharedDatabase *db) {
|
|||||||
|
|
||||||
fprintf(f, "%s\n", line.c_str());
|
fprintf(f, "%s\n", line.c_str());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in ExportBaseData query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExportDBStrings(SharedDatabase *db) {
|
|
||||||
LogInfo("Exporting DB Strings");
|
|
||||||
|
|
||||||
FILE *f = fopen("export/dbstr_us.txt", "w");
|
|
||||||
if(!f) {
|
|
||||||
LogError("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);
|
fclose(f);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
|
|
||||||
SET(import_sources
|
SET(import_sources
|
||||||
main.cpp
|
main.cpp
|
||||||
@@ -9,8 +9,28 @@ SET(import_headers
|
|||||||
|
|
||||||
ADD_EXECUTABLE(import_client_files ${import_sources} ${import_headers})
|
ADD_EXECUTABLE(import_client_files ${import_sources} ${import_headers})
|
||||||
|
|
||||||
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(import_client_files ${SERVER_LIBS})
|
TARGET_LINK_LIBRARIES(import_client_files common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||||
|
|
||||||
|
IF(MSVC)
|
||||||
|
SET_TARGET_PROPERTIES(import_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||||
|
TARGET_LINK_LIBRARIES(import_client_files "Ws2_32.lib")
|
||||||
|
ENDIF(MSVC)
|
||||||
|
|
||||||
|
IF(MINGW)
|
||||||
|
TARGET_LINK_LIBRARIES(import_client_files "WS2_32")
|
||||||
|
ENDIF(MINGW)
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(import_client_files "${CMAKE_DL_LIBS}")
|
||||||
|
TARGET_LINK_LIBRARIES(import_client_files "z")
|
||||||
|
TARGET_LINK_LIBRARIES(import_client_files "m")
|
||||||
|
IF(NOT DARWIN)
|
||||||
|
TARGET_LINK_LIBRARIES(import_client_files "rt")
|
||||||
|
ENDIF(NOT DARWIN)
|
||||||
|
TARGET_LINK_LIBRARIES(import_client_files "pthread")
|
||||||
|
ADD_DEFINITIONS(-fPIC)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
|||||||
+23
-110
@@ -16,8 +16,7 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../common/eqemu_logsys.h"
|
#include "../../common/debug.h"
|
||||||
#include "../../common/global_define.h"
|
|
||||||
#include "../../common/shareddb.h"
|
#include "../../common/shareddb.h"
|
||||||
#include "../../common/eqemu_config.h"
|
#include "../../common/eqemu_config.h"
|
||||||
#include "../../common/platform.h"
|
#include "../../common/platform.h"
|
||||||
@@ -25,45 +24,38 @@
|
|||||||
#include "../../common/rulesys.h"
|
#include "../../common/rulesys.h"
|
||||||
#include "../../common/string_util.h"
|
#include "../../common/string_util.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
|
||||||
|
|
||||||
void ImportSpells(SharedDatabase *db);
|
void ImportSpells(SharedDatabase *db);
|
||||||
void ImportSkillCaps(SharedDatabase *db);
|
void ImportSkillCaps(SharedDatabase *db);
|
||||||
void ImportBaseData(SharedDatabase *db);
|
void ImportBaseData(SharedDatabase *db);
|
||||||
void ImportDBStrings(SharedDatabase *db);
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
RegisterExecutablePlatform(ExePlatformClientImport);
|
RegisterExecutablePlatform(ExePlatformClientImport);
|
||||||
LogSys.LoadLogSettingsDefaults();
|
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
LogInfo("Client Files Import Utility");
|
LogFile->write(EQEMuLog::Status, "Client Files Import Utility");
|
||||||
if(!EQEmuConfig::LoadConfig()) {
|
if(!EQEmuConfig::LoadConfig()) {
|
||||||
LogError("Unable to load configuration file.");
|
LogFile->write(EQEMuLog::Error, "Unable to load configuration file.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Config = EQEmuConfig::get();
|
const EQEmuConfig *config = EQEmuConfig::get();
|
||||||
|
if(!load_log_settings(config->LogSettingsFile.c_str())) {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Warning: unable to read %s.", config->LogSettingsFile.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
SharedDatabase database;
|
SharedDatabase database;
|
||||||
LogInfo("Connecting to database");
|
LogFile->write(EQEMuLog::Status, "Connecting to database...");
|
||||||
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
|
if(!database.Connect(config->DatabaseHost.c_str(), config->DatabaseUsername.c_str(),
|
||||||
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) {
|
config->DatabasePassword.c_str(), config->DatabaseDB.c_str(), config->DatabasePort)) {
|
||||||
LogError("Unable to connect to the database, cannot continue without a "
|
LogFile->write(EQEMuLog::Error, "Unable to connect to the database, cannot continue without a "
|
||||||
"database connection");
|
"database connection");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
database.LoadLogSettings(LogSys.log_settings);
|
|
||||||
LogSys.StartFileLogs();
|
|
||||||
|
|
||||||
ImportSpells(&database);
|
ImportSpells(&database);
|
||||||
ImportSkillCaps(&database);
|
ImportSkillCaps(&database);
|
||||||
ImportBaseData(&database);
|
ImportBaseData(&database);
|
||||||
ImportDBStrings(&database);
|
|
||||||
|
|
||||||
LogSys.CloseFileLogs();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,35 +64,18 @@ int GetSpellColumns(SharedDatabase *db) {
|
|||||||
const std::string query = "DESCRIBE spells_new";
|
const std::string query = "DESCRIBE spells_new";
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
if(!results.Success()) {
|
if(!results.Success()) {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in GetSpellColumns query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return results.RowCount();
|
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) {
|
void ImportSpells(SharedDatabase *db) {
|
||||||
LogInfo("Importing Spells");
|
LogFile->write(EQEMuLog::Status, "Importing Spells...");
|
||||||
FILE *f = fopen("import/spells_us.txt", "r");
|
FILE *f = fopen("import/spells_us.txt", "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open import/spells_us.txt to read, skipping.");
|
LogFile->write(EQEMuLog::Error, "Unable to open import/spells_us.txt to read, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,12 +108,7 @@ void ImportSpells(SharedDatabase *db) {
|
|||||||
sql += "'";
|
sql += "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(split[i].compare("") == 0 && !IsStringField(i)) {
|
sql += split[i];
|
||||||
sql += "0";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += split[i];
|
|
||||||
}
|
|
||||||
sql += "'";
|
sql += "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,12 +123,7 @@ void ImportSpells(SharedDatabase *db) {
|
|||||||
sql += "'";
|
sql += "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(split[i].compare("") == 0 && !IsStringField(i)) {
|
sql += split[i];
|
||||||
sql += "0";
|
|
||||||
} else {
|
|
||||||
sql += split[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
sql += "'";
|
sql += "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,23 +138,23 @@ void ImportSpells(SharedDatabase *db) {
|
|||||||
|
|
||||||
spells_imported++;
|
spells_imported++;
|
||||||
if(spells_imported % 1000 == 0) {
|
if(spells_imported % 1000 == 0) {
|
||||||
LogInfo("[{}] spells imported", spells_imported);
|
LogFile->write(EQEMuLog::Status, "%d spells imported.", spells_imported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(spells_imported % 1000 != 0) {
|
if(spells_imported % 1000 != 0) {
|
||||||
LogInfo("[{}] spells imported", spells_imported);
|
LogFile->write(EQEMuLog::Status, "%d spells imported.", spells_imported);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportSkillCaps(SharedDatabase *db) {
|
void ImportSkillCaps(SharedDatabase *db) {
|
||||||
LogInfo("Importing Skill Caps");
|
LogFile->write(EQEMuLog::Status, "Importing Skill Caps...");
|
||||||
|
|
||||||
FILE *f = fopen("import/SkillCaps.txt", "r");
|
FILE *f = fopen("import/SkillCaps.txt", "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open import/SkillCaps.txt to read, skipping.");
|
LogFile->write(EQEMuLog::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +169,7 @@ void ImportSkillCaps(SharedDatabase *db) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int class_id, skill_id, level, cap;
|
int class_id, skill_id, level, cap;
|
||||||
class_id = atoi(split[0].c_str());
|
class_id = atoi(split[0].c_str());
|
||||||
skill_id = atoi(split[1].c_str());
|
skill_id = atoi(split[1].c_str());
|
||||||
@@ -220,11 +186,11 @@ void ImportSkillCaps(SharedDatabase *db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImportBaseData(SharedDatabase *db) {
|
void ImportBaseData(SharedDatabase *db) {
|
||||||
LogInfo("Importing Base Data");
|
LogFile->write(EQEMuLog::Status, "Importing Base Data...");
|
||||||
|
|
||||||
FILE *f = fopen("import/BaseData.txt", "r");
|
FILE *f = fopen("import/BaseData.txt", "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open import/BaseData.txt to read, skipping.");
|
LogFile->write(EQEMuLog::Error, "Unable to open import/BaseData.txt to read, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,56 +229,3 @@ void ImportBaseData(SharedDatabase *db) {
|
|||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportDBStrings(SharedDatabase *db) {
|
|
||||||
LogInfo("Importing DB Strings");
|
|
||||||
|
|
||||||
FILE *f = fopen("import/dbstr_us.txt", "r");
|
|
||||||
if(!f) {
|
|
||||||
LogError("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,94 +0,0 @@
|
|||||||
OPTION(EQEMU_FETCH_MSVC_DEPENDENCIES_VCPKG "Automatically fetch vcpkg dependencies for MSCV" ON)
|
|
||||||
OPTION(EQEMU_FETCH_MSVC_DEPENDENCIES_PERL "Automatically fetch perl dependencies for MSCV" ON)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(EQEMU_FETCH_MSVC_DEPENDENCIES_VCPKG)
|
|
||||||
MARK_AS_ADVANCED(EQEMU_FETCH_MSVC_DEPENDENCIES_PERL)
|
|
||||||
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X86 "https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x86.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X64 "https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x64.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X86 "http://strawberryperl.com/download/5.24.4.1/strawberry-perl-5.24.4.1-32bit-portable.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X64 "http://strawberryperl.com/download/5.24.4.1/strawberry-perl-5.24.4.1-64bit-portable.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_ZIP "vcpkg-export-x86.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_ZIP "vcpkg-export-x64.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_DIR "vcpkg-export-x86")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_DIR "vcpkg-export-x64")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X86_ZIP "strawberry-perl-5.24.4.1-32bit-portable.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X64_ZIP "strawberry-perl-5.24.4.1-64bit-portable.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X86_DIR "x86")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X64_DIR "x64")
|
|
||||||
|
|
||||||
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
SET(EQEMU_VCPKG_URL ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X64})
|
|
||||||
SET(EQEMU_PERL_URL ${EQEMU_MSVC_DEPENDENCIES_PERL_X64})
|
|
||||||
SET(EQEMU_VCPKG_ZIP ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_ZIP})
|
|
||||||
SET(EQEMU_VCPKG_DIR ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_DIR})
|
|
||||||
SET(EQEMU_PERL_ZIP ${EQEMU_MSVC_DEPENDENCIES_PERL_X64_ZIP})
|
|
||||||
SET(EQEMU_PERL_DIR ${EQEMU_MSVC_DEPENDENCIES_PERL_X64_DIR})
|
|
||||||
ELSE()
|
|
||||||
SET(EQEMU_VCPKG_URL ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X86})
|
|
||||||
SET(EQEMU_PERL_URL ${EQEMU_MSVC_DEPENDENCIES_PERL_X86})
|
|
||||||
SET(EQEMU_VCPKG_ZIP ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_ZIP})
|
|
||||||
SET(EQEMU_VCPKG_DIR ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_DIR})
|
|
||||||
SET(EQEMU_PERL_ZIP ${EQEMU_MSVC_DEPENDENCIES_PERL_X86_ZIP})
|
|
||||||
SET(EQEMU_PERL_DIR ${EQEMU_MSVC_DEPENDENCIES_PERL_X86_DIR})
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_FETCH_MSVC_DEPENDENCIES_VCPKG)
|
|
||||||
MESSAGE(STATUS "Resolving vcpkg dependencies...")
|
|
||||||
|
|
||||||
IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_ZIP})
|
|
||||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/vcpkg)
|
|
||||||
|
|
||||||
MESSAGE(STATUS "Downloading existing vcpkg dependencies from releases...")
|
|
||||||
FILE(DOWNLOAD ${EQEMU_VCPKG_URL} ${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_ZIP}
|
|
||||||
SHOW_PROGRESS
|
|
||||||
STATUS DOWNLOAD_STATUS)
|
|
||||||
|
|
||||||
LIST(GET DOWNLOAD_STATUS 0 STATUS_CODE)
|
|
||||||
IF(NOT STATUS_CODE EQUAL 0)
|
|
||||||
MESSAGE(FATAL_ERROR "Was unable to download dependencies from ${EQEMU_VCPKG_URL}")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
MESSAGE(STATUS "Extracting files...")
|
|
||||||
EXECUTE_PROCESS(
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_ZIP}
|
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vcpkg
|
|
||||||
)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
INCLUDE(${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_FETCH_MSVC_DEPENDENCIES_PERL)
|
|
||||||
#Try to find perl first, (so you can use your active install first)
|
|
||||||
FIND_PACKAGE(PerlLibs)
|
|
||||||
|
|
||||||
IF(NOT PerlLibs_FOUND)
|
|
||||||
MESSAGE(STATUS "Resolving perl dependencies...")
|
|
||||||
|
|
||||||
IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_ZIP})
|
|
||||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/perl)
|
|
||||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR})
|
|
||||||
|
|
||||||
MESSAGE(STATUS "Downloading portable perl...")
|
|
||||||
FILE(DOWNLOAD ${EQEMU_PERL_URL} ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_ZIP}
|
|
||||||
SHOW_PROGRESS
|
|
||||||
STATUS DOWNLOAD_STATUS)
|
|
||||||
|
|
||||||
LIST(GET DOWNLOAD_STATUS 0 STATUS_CODE)
|
|
||||||
IF(NOT STATUS_CODE EQUAL 0)
|
|
||||||
MESSAGE(FATAL_ERROR "Was unable to download dependencies from ${EQEMU_PERL_URL}")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
MESSAGE(STATUS "Extracting files...")
|
|
||||||
EXECUTE_PROCESS(
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_ZIP}
|
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}
|
|
||||||
)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(PERL_EXECUTABLE ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}/perl/bin/perl.exe CACHE FILEPATH "Path to perl program" FORCE)
|
|
||||||
SET(PERL_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}/perl/lib/CORE CACHE PATH "Path to perl include files" FORCE)
|
|
||||||
SET(PERL_LIBRARY ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}/perl/lib/CORE/libperl524.a CACHE FILEPATH "Path to perl library" FORCE)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
#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,91 +0,0 @@
|
|||||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
||||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
||||||
# Modified from the FindLua51 that comes with CMake
|
|
||||||
|
|
||||||
#[=======================================================================[.rst:
|
|
||||||
FindLua51
|
|
||||||
---------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Locate Lua51 library 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)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Note that the expected include convention is
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
|
|
||||||
and not
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
#include <lua/lua.h>
|
|
||||||
|
|
||||||
This is because, the lua location is not standardized and may exist in
|
|
||||||
locations other than lua/
|
|
||||||
#]=======================================================================]
|
|
||||||
|
|
||||||
find_path(LUA_INCLUDE_DIR lua.h
|
|
||||||
HINTS
|
|
||||||
ENV LUA_DIR
|
|
||||||
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include/luajit include
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/sw # Fink
|
|
||||||
/opt/local # DarwinPorts
|
|
||||||
/opt/csw # Blastwave
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(LUA_LIBRARY
|
|
||||||
NAMES lua51 lua5.1 lua-5.1 lua luajit
|
|
||||||
HINTS
|
|
||||||
ENV LUA_DIR
|
|
||||||
PATH_SUFFIXES lib
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/sw
|
|
||||||
/opt/local
|
|
||||||
/opt/csw
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
if(LUA_LIBRARY)
|
|
||||||
# include the math library for Unix
|
|
||||||
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
|
|
||||||
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(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set LUA51_FOUND to TRUE if
|
|
||||||
# all listed variables are TRUE
|
|
||||||
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 mariadbclient
|
|
||||||
#
|
|
||||||
# -*- cmake -*-
|
|
||||||
#
|
|
||||||
# Find the native MariaDB includes and library
|
|
||||||
#
|
|
||||||
# MariaDB_INCLUDE_DIR - where to find mysql.h, etc.
|
|
||||||
# MariaDB_LIBRARIES - List of libraries when using MariaDB.
|
|
||||||
# MariaDB_FOUND - True if MariaDB found.
|
|
||||||
# The following can be used as a hint as to where to search:
|
|
||||||
# MARIADB_ROOT
|
|
||||||
|
|
||||||
IF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARIES)
|
|
||||||
# Already in cache, be silent
|
|
||||||
SET(MariaDB_FIND_QUIETLY TRUE)
|
|
||||||
ENDIF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARIES)
|
|
||||||
|
|
||||||
# Include dir
|
|
||||||
IF(MARIADB_ROOT)
|
|
||||||
FIND_PATH(MariaDB_INCLUDE_DIR
|
|
||||||
NAMES mariadb_version.h
|
|
||||||
PATHS ${MARIADB_ROOT}/include
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
NO_SYSTEM_ENVIRONMENT_PATH
|
|
||||||
)
|
|
||||||
FIND_PATH(MariaDB_INCLUDE_DIR
|
|
||||||
NAMES mariadb_version.h
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
)
|
|
||||||
ELSE(MARIADB_ROOT)
|
|
||||||
FIND_PATH(MariaDB_INCLUDE_DIR
|
|
||||||
NAMES mariadb_version.h
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
)
|
|
||||||
ENDIF(MARIADB_ROOT)
|
|
||||||
|
|
||||||
# Library
|
|
||||||
SET(MariaDB_NAMES libmariadb)
|
|
||||||
IF(MARIADB_ROOT)
|
|
||||||
FIND_LIBRARY(MariaDB_LIBRARY
|
|
||||||
NAMES ${MariaDB_NAMES}
|
|
||||||
PATHS ${MARIADB_ROOT}/lib
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
NO_SYSTEM_ENVIRONMENT_PATH
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(MariaDB_LIBRARY
|
|
||||||
NAMES ${MariaDB_NAMES}
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
)
|
|
||||||
ELSE(MARIADB_ROOT)
|
|
||||||
FIND_LIBRARY(MariaDB_LIBRARY
|
|
||||||
NAMES ${MariaDB_NAMES} mariadbclient_r mariadbclient
|
|
||||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
)
|
|
||||||
ENDIF(MARIADB_ROOT)
|
|
||||||
|
|
||||||
IF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
|
|
||||||
SET(MariaDB_FOUND TRUE)
|
|
||||||
SET(MariaDB_LIBRARIES ${MariaDB_LIBRARY})
|
|
||||||
ELSE (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
|
|
||||||
SET(MariaDB_FOUND FALSE)
|
|
||||||
SET(MariaDB_LIBRARIES)
|
|
||||||
ENDIF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
|
|
||||||
|
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set MariaDB_FOUND to TRUE if
|
|
||||||
# all listed variables are TRUE
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MariaDB DEFAULT_MSG MariaDB_LIBRARY MariaDB_INCLUDE_DIR)
|
|
||||||
|
|
||||||
IF(MariaDB_FOUND)
|
|
||||||
SET( MariaDB_LIBRARY_RELEASE ${MariaDB_LIBRARY} )
|
|
||||||
SET( MariaDB_LIBRARY_DEBUG ${MariaDB_LIBRARY} )
|
|
||||||
SET( MariaDB_LIBRARIES ${MariaDB_LIBRARY_RELEASE} ${MariaDB_LIBRARY_DEBUG} )
|
|
||||||
ELSE(MariaDB_FOUND)
|
|
||||||
SET( MariaDB_LIBRARIES )
|
|
||||||
ENDIF(MariaDB_FOUND)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
MariaDB_LIBRARY_DEBUG
|
|
||||||
MariaDB_LIBRARY_RELEASE
|
|
||||||
MariaDB_INCLUDE_DIR
|
|
||||||
)
|
|
||||||
+20
-23
@@ -21,12 +21,6 @@ IF(MYSQL_ROOT)
|
|||||||
NAMES mysql.h
|
NAMES mysql.h
|
||||||
PATHS ${MYSQL_ROOT}/include
|
PATHS ${MYSQL_ROOT}/include
|
||||||
PATH_SUFFIXES mysql
|
PATH_SUFFIXES mysql
|
||||||
NO_DEFAULT_PATH
|
|
||||||
NO_SYSTEM_ENVIRONMENT_PATH
|
|
||||||
)
|
|
||||||
FIND_PATH(MySQL_INCLUDE_DIR
|
|
||||||
NAMES mysql.h
|
|
||||||
PATH_SUFFIXES mysql
|
|
||||||
)
|
)
|
||||||
ELSE(MYSQL_ROOT)
|
ELSE(MYSQL_ROOT)
|
||||||
FIND_PATH(MySQL_INCLUDE_DIR
|
FIND_PATH(MySQL_INCLUDE_DIR
|
||||||
@@ -36,46 +30,49 @@ ELSE(MYSQL_ROOT)
|
|||||||
ENDIF(MYSQL_ROOT)
|
ENDIF(MYSQL_ROOT)
|
||||||
|
|
||||||
# Library
|
# Library
|
||||||
SET(MySQL_NAMES libmysql)
|
SET(MySQL_NAMES mysqlclient_r mysqlclient)
|
||||||
IF(MYSQL_ROOT)
|
IF(MYSQL_ROOT)
|
||||||
FIND_LIBRARY(MySQL_LIBRARY
|
FIND_LIBRARY(MySQL_LIBRARY_DEBUG
|
||||||
NAMES ${MySQL_NAMES}
|
NAMES ${MySQL_NAMES}
|
||||||
PATHS ${MYSQL_ROOT}/lib
|
PATHS ${MYSQL_ROOT}/lib/debug /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||||
PATH_SUFFIXES mysql
|
PATH_SUFFIXES mysql
|
||||||
NO_DEFAULT_PATH
|
|
||||||
NO_SYSTEM_ENVIRONMENT_PATH
|
|
||||||
)
|
)
|
||||||
|
|
||||||
FIND_LIBRARY(MySQL_LIBRARY
|
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
|
||||||
NAMES ${MySQL_NAMES}
|
NAMES ${MySQL_NAMES}
|
||||||
|
PATHS ${MYSQL_ROOT}/lib /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||||
PATH_SUFFIXES mysql
|
PATH_SUFFIXES mysql
|
||||||
)
|
)
|
||||||
ELSE(MYSQL_ROOT)
|
ELSE(MYSQL_ROOT)
|
||||||
FIND_LIBRARY(MySQL_LIBRARY
|
FIND_LIBRARY(MySQL_LIBRARY_DEBUG
|
||||||
NAMES ${MySQL_NAMES} mysqlclient_r mysqlclient
|
NAMES ${MySQL_NAMES}
|
||||||
|
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||||
|
PATH_SUFFIXES mysql
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
|
||||||
|
NAMES ${MySQL_NAMES}
|
||||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||||
PATH_SUFFIXES mysql
|
PATH_SUFFIXES mysql
|
||||||
)
|
)
|
||||||
ENDIF(MYSQL_ROOT)
|
ENDIF(MYSQL_ROOT)
|
||||||
|
|
||||||
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
|
||||||
SET(MySQL_FOUND TRUE)
|
SET(MySQL_FOUND TRUE)
|
||||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY} )
|
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
|
||||||
ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
|
||||||
SET(MySQL_FOUND FALSE)
|
SET(MySQL_FOUND FALSE)
|
||||||
SET( MySQL_LIBRARIES )
|
SET( MySQL_LIBRARIES )
|
||||||
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
|
||||||
|
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set MySQL_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set MySQL_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY MySQL_INCLUDE_DIR)
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY_DEBUG MySQL_LIBRARY_RELEASE MySQL_INCLUDE_DIR)
|
||||||
|
|
||||||
IF(MySQL_FOUND)
|
IF(MySQL_FOUND)
|
||||||
SET( MySQL_LIBRARY_RELEASE ${MySQL_LIBRARY} )
|
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
|
||||||
SET( MySQL_LIBRARY_DEBUG ${MySQL_LIBRARY} )
|
|
||||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_RELEASE} ${MySQL_LIBRARY_DEBUG} )
|
|
||||||
ELSE(MySQL_FOUND)
|
ELSE(MySQL_FOUND)
|
||||||
SET( MySQL_LIBRARIES )
|
SET( MySQL_LIBRARIES )
|
||||||
ENDIF(MySQL_FOUND)
|
ENDIF(MySQL_FOUND)
|
||||||
|
|||||||
@@ -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,93 +0,0 @@
|
|||||||
# - Try to find mbedTLS
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# Read-Only variables
|
|
||||||
# MBEDTLS_FOUND - system has mbedTLS
|
|
||||||
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
|
|
||||||
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
|
|
||||||
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
|
|
||||||
# MBEDTLS_LIBRARY - path to mbedTLS library
|
|
||||||
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
|
|
||||||
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
|
|
||||||
#
|
|
||||||
# Hint
|
|
||||||
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
|
|
||||||
|
|
||||||
SET(_MBEDTLS_ROOT_HINTS
|
|
||||||
${MBEDTLS_ROOT_DIR}
|
|
||||||
ENV MBEDTLS_ROOT_DIR
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
|
|
||||||
HINTS ${_MBEDTLS_ROOT_HINTS}
|
|
||||||
PATHS ${_MBEDTLS_ROOT_PATHS}
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_PATH(MBEDTLS_INCLUDE_DIR
|
|
||||||
NAMES mbedtls/version.h
|
|
||||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
|
||||||
PATH_SUFFIXES include
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
|
|
||||||
# Already in cache, be silent
|
|
||||||
SET(MBEDTLS_FIND_QUIETLY TRUE)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
FIND_LIBRARY(MBEDTLS_LIBRARY
|
|
||||||
NAMES mbedtls libmbedtls
|
|
||||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
|
||||||
PATH_SUFFIXES library
|
|
||||||
)
|
|
||||||
FIND_LIBRARY(MBEDX509_LIBRARY
|
|
||||||
NAMES mbedx509 libmbedx509
|
|
||||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
|
||||||
PATH_SUFFIXES library
|
|
||||||
)
|
|
||||||
FIND_LIBRARY(MBEDCRYPTO_LIBRARY
|
|
||||||
NAMES mbedcrypto libmbedcrypto
|
|
||||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
|
||||||
PATH_SUFFIXES library
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
|
|
||||||
SET(MBEDTLS_FOUND TRUE)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(MBEDTLS_FOUND)
|
|
||||||
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
|
|
||||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
|
|
||||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
|
|
||||||
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
|
|
||||||
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
|
|
||||||
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
|
|
||||||
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
|
|
||||||
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
|
|
||||||
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
|
|
||||||
|
|
||||||
IF(NOT MBEDTLS_FIND_QUIETLY)
|
|
||||||
MESSAGE(STATUS "Found mbedTLS:")
|
|
||||||
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
|
|
||||||
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
|
|
||||||
IF (MBEDTLSMATCH)
|
|
||||||
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
|
|
||||||
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
|
|
||||||
ENDIF(MBEDTLSMATCH)
|
|
||||||
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
|
|
||||||
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
|
|
||||||
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
|
|
||||||
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
|
|
||||||
ELSE(MBEDTLS_FOUND)
|
|
||||||
IF(MBEDTLS_FIND_REQUIRED)
|
|
||||||
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
|
|
||||||
ENDIF(MBEDTLS_FIND_REQUIRED)
|
|
||||||
ENDIF(MBEDTLS_FOUND)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
MBEDTLS_INCLUDE_DIR
|
|
||||||
MBEDTLS_LIBRARY_DIR
|
|
||||||
MBEDTLS_LIBRARIES
|
|
||||||
MBEDTLS_LIBRARY
|
|
||||||
MBEDX509_LIBRARY
|
|
||||||
MBEDCRYPTO_LIBRARY
|
|
||||||
)
|
|
||||||
+145
-212
@@ -1,53 +1,43 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
|
|
||||||
SET(common_sources
|
SET(common_sources
|
||||||
base_packet.cpp
|
base_packet.cpp
|
||||||
classes.cpp
|
classes.cpp
|
||||||
cli/eqemu_command_handler.cpp
|
|
||||||
compression.cpp
|
|
||||||
condition.cpp
|
condition.cpp
|
||||||
crash.cpp
|
crash.cpp
|
||||||
crc16.cpp
|
crc16.cpp
|
||||||
crc32.cpp
|
crc32.cpp
|
||||||
database/database_dump_service.cpp
|
|
||||||
database.cpp
|
database.cpp
|
||||||
database_conversions.cpp
|
|
||||||
database_instances.cpp
|
|
||||||
dbcore.cpp
|
dbcore.cpp
|
||||||
deity.cpp
|
debug.cpp
|
||||||
emu_constants.cpp
|
|
||||||
emu_limits.cpp
|
|
||||||
emu_opcodes.cpp
|
emu_opcodes.cpp
|
||||||
emu_versions.cpp
|
emu_tcp_connection.cpp
|
||||||
|
emu_tcp_server.cpp
|
||||||
|
eq_dictionary.cpp
|
||||||
eqdb.cpp
|
eqdb.cpp
|
||||||
eqdb_res.cpp
|
eqdb_res.cpp
|
||||||
eqemu_exception.cpp
|
eqemu_exception.cpp
|
||||||
eqemu_config.cpp
|
eqemu_config.cpp
|
||||||
eqemu_logsys.cpp
|
eqemu_error.cpp
|
||||||
eq_limits.cpp
|
|
||||||
eq_packet.cpp
|
eq_packet.cpp
|
||||||
|
eq_stream.cpp
|
||||||
|
eq_stream_factory.cpp
|
||||||
eq_stream_ident.cpp
|
eq_stream_ident.cpp
|
||||||
eq_stream_proxy.cpp
|
eq_stream_proxy.cpp
|
||||||
eqtime.cpp
|
eqtime.cpp
|
||||||
event_sub.cpp
|
|
||||||
extprofile.cpp
|
extprofile.cpp
|
||||||
faction.cpp
|
faction.cpp
|
||||||
file_util.cpp
|
|
||||||
guild_base.cpp
|
guild_base.cpp
|
||||||
guilds.cpp
|
guilds.cpp
|
||||||
inventory_profile.cpp
|
|
||||||
inventory_slot.cpp
|
|
||||||
ipc_mutex.cpp
|
ipc_mutex.cpp
|
||||||
ip_util.cpp
|
item.cpp
|
||||||
item_data.cpp
|
logsys.cpp
|
||||||
item_instance.cpp
|
logsys_eqemu.cpp
|
||||||
json_config.cpp
|
|
||||||
light_source.cpp
|
|
||||||
md5.cpp
|
md5.cpp
|
||||||
memory_buffer.cpp
|
|
||||||
memory_mapped_file.cpp
|
memory_mapped_file.cpp
|
||||||
misc.cpp
|
misc.cpp
|
||||||
misc_functions.cpp
|
misc_functions.cpp
|
||||||
|
moremath.cpp
|
||||||
mutex.cpp
|
mutex.cpp
|
||||||
mysql_request_result.cpp
|
mysql_request_result.cpp
|
||||||
mysql_request_row.cpp
|
mysql_request_row.cpp
|
||||||
@@ -59,127 +49,110 @@ SET(common_sources
|
|||||||
perl_eqdb.cpp
|
perl_eqdb.cpp
|
||||||
perl_eqdb_res.cpp
|
perl_eqdb_res.cpp
|
||||||
proc_launcher.cpp
|
proc_launcher.cpp
|
||||||
profanity_manager.cpp
|
|
||||||
ptimer.cpp
|
ptimer.cpp
|
||||||
races.cpp
|
races.cpp
|
||||||
rdtsc.cpp
|
rdtsc.cpp
|
||||||
rulesys.cpp
|
rulesys.cpp
|
||||||
say_link.cpp
|
|
||||||
serialize_buffer.cpp
|
|
||||||
serverinfo.cpp
|
serverinfo.cpp
|
||||||
shareddb.cpp
|
shareddb.cpp
|
||||||
skills.cpp
|
skills.cpp
|
||||||
spdat.cpp
|
spdat.cpp
|
||||||
string_util.cpp
|
string_util.cpp
|
||||||
struct_strategy.cpp
|
struct_strategy.cpp
|
||||||
textures.cpp
|
tcp_connection.cpp
|
||||||
|
tcp_server.cpp
|
||||||
|
timeoutmgr.cpp
|
||||||
timer.cpp
|
timer.cpp
|
||||||
unix.cpp
|
unix.cpp
|
||||||
|
worldconn.cpp
|
||||||
|
xml_parser.cpp
|
||||||
platform.cpp
|
platform.cpp
|
||||||
json/jsoncpp.cpp
|
patches/client62.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/patches.cpp
|
||||||
patches/sod.cpp
|
patches/sod.cpp
|
||||||
patches/sod_limits.cpp
|
|
||||||
patches/sof.cpp
|
patches/sof.cpp
|
||||||
patches/sof_limits.cpp
|
|
||||||
patches/rof.cpp
|
patches/rof.cpp
|
||||||
patches/rof_limits.cpp
|
|
||||||
patches/rof2.cpp
|
|
||||||
patches/rof2_limits.cpp
|
|
||||||
patches/titanium.cpp
|
patches/titanium.cpp
|
||||||
patches/titanium_limits.cpp
|
patches/underfoot.cpp
|
||||||
patches/uf.cpp
|
SocketLib/Base64.cpp
|
||||||
patches/uf_limits.cpp
|
SocketLib/File.cpp
|
||||||
|
SocketLib/HttpdCookies.cpp
|
||||||
|
SocketLib/HttpdForm.cpp
|
||||||
|
SocketLib/HttpdSocket.cpp
|
||||||
|
SocketLib/HTTPSocket.cpp
|
||||||
|
SocketLib/MemFile.cpp
|
||||||
|
SocketLib/Mime.cpp
|
||||||
|
SocketLib/Parse.cpp
|
||||||
|
SocketLib/socket_include.cpp
|
||||||
|
SocketLib/Utility.cpp
|
||||||
StackWalker/StackWalker.cpp
|
StackWalker/StackWalker.cpp
|
||||||
util/directory.cpp
|
tinyxml/tinystr.cpp
|
||||||
util/uuid.cpp)
|
tinyxml/tinyxml.cpp
|
||||||
|
tinyxml/tinyxmlerror.cpp
|
||||||
|
tinyxml/tinyxmlparser.cpp
|
||||||
|
)
|
||||||
|
|
||||||
SET(common_headers
|
SET(common_headers
|
||||||
any.h
|
any.h
|
||||||
base_packet.h
|
base_packet.h
|
||||||
base_data.h
|
base_data.h
|
||||||
bodytypes.h
|
bodytypes.h
|
||||||
|
breakdowns.h
|
||||||
classes.h
|
classes.h
|
||||||
compression.h
|
|
||||||
condition.h
|
condition.h
|
||||||
crash.h
|
crash.h
|
||||||
crc16.h
|
crc16.h
|
||||||
crc32.h
|
crc32.h
|
||||||
cli/argh.h
|
|
||||||
cli/eqemu_command_handler.h
|
|
||||||
cli/terminal_color.hpp
|
|
||||||
database/database_dump_service.h
|
|
||||||
data_verification.h
|
data_verification.h
|
||||||
database.h
|
database.h
|
||||||
database_schema.h
|
|
||||||
dbcore.h
|
dbcore.h
|
||||||
|
debug.h
|
||||||
deity.h
|
deity.h
|
||||||
emu_constants.h
|
|
||||||
emu_limits.h
|
|
||||||
emu_opcodes.h
|
emu_opcodes.h
|
||||||
emu_oplist.h
|
emu_oplist.h
|
||||||
emu_versions.h
|
emu_tcp_connection.h
|
||||||
|
emu_tcp_server.h
|
||||||
eq_constants.h
|
eq_constants.h
|
||||||
|
eq_dictionary.h
|
||||||
eq_packet_structs.h
|
eq_packet_structs.h
|
||||||
eqdb.h
|
eqdb.h
|
||||||
eqdb_res.h
|
eqdb_res.h
|
||||||
eqemu_exception.h
|
eqemu_exception.h
|
||||||
eqemu_config.h
|
eqemu_config.h
|
||||||
eqemu_config_elements.h
|
eqemu_config_elements.h
|
||||||
eqemu_logsys.h
|
eqemu_error.h
|
||||||
eqemu_logsys_log_aliases.h
|
|
||||||
eq_limits.h
|
|
||||||
eq_packet.h
|
eq_packet.h
|
||||||
|
eq_stream.h
|
||||||
|
eq_stream_factory.h
|
||||||
eq_stream_ident.h
|
eq_stream_ident.h
|
||||||
eq_stream_intf.h
|
eq_stream_intf.h
|
||||||
eq_stream_locator.h
|
eq_stream_locator.h
|
||||||
eq_stream_proxy.h
|
eq_stream_proxy.h
|
||||||
|
eq_stream_type.h
|
||||||
eqtime.h
|
eqtime.h
|
||||||
errmsg.h
|
errmsg.h
|
||||||
event_sub.h
|
|
||||||
expected.h
|
|
||||||
extprofile.h
|
extprofile.h
|
||||||
faction.h
|
faction.h
|
||||||
file_util.h
|
|
||||||
features.h
|
features.h
|
||||||
fixed_memory_hash_set.h
|
fixed_memory_hash_set.h
|
||||||
fixed_memory_variable_hash_set.h
|
fixed_memory_variable_hash_set.h
|
||||||
global_define.h
|
|
||||||
guild_base.h
|
guild_base.h
|
||||||
guilds.h
|
guilds.h
|
||||||
http/httplib.h
|
|
||||||
inventory_profile.h
|
|
||||||
inventory_slot.h
|
|
||||||
ipc_mutex.h
|
ipc_mutex.h
|
||||||
ip_util.h
|
item.h
|
||||||
item_data.h
|
|
||||||
item_fieldlist.h
|
item_fieldlist.h
|
||||||
item_instance.h
|
item_struct.h
|
||||||
json_config.h
|
|
||||||
languages.h
|
languages.h
|
||||||
light_source.h
|
|
||||||
linked_list.h
|
linked_list.h
|
||||||
|
logsys.h
|
||||||
|
logtypes.h
|
||||||
loottable.h
|
loottable.h
|
||||||
mail_oplist.h
|
mail_oplist.h
|
||||||
md5.h
|
md5.h
|
||||||
memory_buffer.h
|
|
||||||
memory_mapped_file.h
|
memory_mapped_file.h
|
||||||
misc.h
|
misc.h
|
||||||
misc_functions.h
|
misc_functions.h
|
||||||
|
moremath.h
|
||||||
mutex.h
|
mutex.h
|
||||||
mysql_request_result.h
|
mysql_request_result.h
|
||||||
mysql_request_row.h
|
mysql_request_row.h
|
||||||
@@ -191,18 +164,14 @@ SET(common_headers
|
|||||||
packet_functions.h
|
packet_functions.h
|
||||||
platform.h
|
platform.h
|
||||||
proc_launcher.h
|
proc_launcher.h
|
||||||
profanity_manager.h
|
|
||||||
profiler.h
|
profiler.h
|
||||||
ptimer.h
|
ptimer.h
|
||||||
queue.h
|
queue.h
|
||||||
races.h
|
races.h
|
||||||
random.h
|
|
||||||
rdtsc.h
|
rdtsc.h
|
||||||
rulesys.h
|
rulesys.h
|
||||||
ruletypes.h
|
ruletypes.h
|
||||||
say_link.h
|
|
||||||
seperator.h
|
seperator.h
|
||||||
serialize_buffer.h
|
|
||||||
serverinfo.h
|
serverinfo.h
|
||||||
servertalk.h
|
servertalk.h
|
||||||
shareddb.h
|
shareddb.h
|
||||||
@@ -210,177 +179,141 @@ SET(common_headers
|
|||||||
spdat.h
|
spdat.h
|
||||||
string_util.h
|
string_util.h
|
||||||
struct_strategy.h
|
struct_strategy.h
|
||||||
textures.h
|
tcp_basic_server.h
|
||||||
|
tcp_connection.h
|
||||||
|
tcp_server.h
|
||||||
|
timeoutmgr.h
|
||||||
timer.h
|
timer.h
|
||||||
types.h
|
types.h
|
||||||
unix.h
|
unix.h
|
||||||
useperl.h
|
useperl.h
|
||||||
version.h
|
version.h
|
||||||
|
worldconn.h
|
||||||
|
xml_parser.h
|
||||||
zone_numbers.h
|
zone_numbers.h
|
||||||
event/event_loop.h
|
patches/client62.h
|
||||||
event/task.h
|
patches/client62_constants.h
|
||||||
event/timer.h
|
patches/client62_itemfields.h
|
||||||
json/json.h
|
patches/client62_ops.h
|
||||||
json/json-forwards.h
|
patches/client62_structs.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/patches.h
|
||||||
patches/sod.h
|
patches/sod.h
|
||||||
patches/sod_limits.h
|
patches/sod_constants.h
|
||||||
|
patches/sod_itemfields.h
|
||||||
patches/sod_ops.h
|
patches/sod_ops.h
|
||||||
patches/sod_structs.h
|
patches/sod_structs.h
|
||||||
patches/sof.h
|
patches/sof.h
|
||||||
patches/sof_limits.h
|
patches/sof_constants.h
|
||||||
|
patches/sof_itemfields.h
|
||||||
|
patches/sof_opcode_list.h
|
||||||
patches/sof_ops.h
|
patches/sof_ops.h
|
||||||
patches/sof_structs.h
|
patches/sof_structs.h
|
||||||
patches/ss_declare.h
|
patches/ss_declare.h
|
||||||
patches/ss_define.h
|
patches/ss_define.h
|
||||||
patches/ss_register.h
|
patches/ss_register.h
|
||||||
patches/rof.h
|
patches/rof.h
|
||||||
patches/rof_limits.h
|
patches/rof_constants.h
|
||||||
|
patches/rof_itemfields.h
|
||||||
patches/rof_ops.h
|
patches/rof_ops.h
|
||||||
patches/rof_structs.h
|
patches/rof_structs.h
|
||||||
patches/rof2.h
|
patches/rof2_constants.h
|
||||||
patches/rof2_limits.h
|
|
||||||
patches/rof2_ops.h
|
|
||||||
patches/rof2_structs.h
|
|
||||||
patches/titanium.h
|
patches/titanium.h
|
||||||
patches/titanium_limits.h
|
patches/titanium_constants.h
|
||||||
|
patches/titanium_itemfields.h
|
||||||
patches/titanium_ops.h
|
patches/titanium_ops.h
|
||||||
patches/titanium_structs.h
|
patches/titanium_structs.h
|
||||||
patches/uf.h
|
patches/underfoot.h
|
||||||
patches/uf_limits.h
|
patches/underfoot_constants.h
|
||||||
patches/uf_ops.h
|
patches/underfoot_itemfields.h
|
||||||
patches/uf_structs.h
|
patches/underfoot_ops.h
|
||||||
shared/shared_memory.h
|
patches/underfoot_structs.h
|
||||||
shared/shared_memory_error.h
|
SocketLib/Base64.h
|
||||||
shared/shared_memory_handle.h
|
SocketLib/File.h
|
||||||
shared/shared_memory_list.h
|
SocketLib/HttpdCookies.h
|
||||||
shared/shared_memory_map.h
|
SocketLib/HttpdForm.h
|
||||||
shared/shared_memory_string.h
|
SocketLib/HttpdSocket.h
|
||||||
shared/shared_memory_vector.h
|
SocketLib/HTTPSocket.h
|
||||||
|
SocketLib/IFile.h
|
||||||
|
SocketLib/MemFile.h
|
||||||
|
SocketLib/Mime.h
|
||||||
|
SocketLib/Parse.h
|
||||||
|
SocketLib/socket_include.h
|
||||||
|
SocketLib/Utility.h
|
||||||
StackWalker/StackWalker.h
|
StackWalker/StackWalker.h
|
||||||
util/memory_stream.h
|
tinyxml/tinystr.h
|
||||||
util/directory.h
|
tinyxml/tinyxml.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
|
SOURCE_GROUP(Patches FILES
|
||||||
|
patches/client62.h
|
||||||
|
patches/client62_itemfields.h
|
||||||
|
patches/client62_ops.h
|
||||||
|
patches/client62_constants.h
|
||||||
|
patches/client62_structs.h
|
||||||
patches/patches.h
|
patches/patches.h
|
||||||
patches/sod.h
|
patches/sod.h
|
||||||
patches/sod_limits.h
|
patches/sod_itemfields.h
|
||||||
patches/sod_ops.h
|
patches/sod_ops.h
|
||||||
|
patches/sod_constants.h
|
||||||
patches/sod_structs.h
|
patches/sod_structs.h
|
||||||
patches/sof.h
|
patches/sof.h
|
||||||
patches/sof_limits.h
|
patches/sof_itemfields.h
|
||||||
|
patches/sof_opcode_list.h
|
||||||
patches/sof_ops.h
|
patches/sof_ops.h
|
||||||
|
patches/sof_constants.h
|
||||||
patches/sof_structs.h
|
patches/sof_structs.h
|
||||||
patches/ss_declare.h
|
patches/ss_declare.h
|
||||||
patches/ss_define.h
|
patches/ss_define.h
|
||||||
patches/ss_register.h
|
patches/ss_register.h
|
||||||
patches/rof.h
|
patches/rof.h
|
||||||
patches/rof_limits.h
|
patches/rof_itemfields.h
|
||||||
patches/rof_ops.h
|
patches/rof_ops.h
|
||||||
|
patches/rof_constants.h
|
||||||
|
patches/rof2_constants.h
|
||||||
patches/rof_structs.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.h
|
||||||
patches/titanium_limits.h
|
patches/titanium_itemfields.h
|
||||||
patches/titanium_ops.h
|
patches/titanium_ops.h
|
||||||
|
patches/titanium_constants.h
|
||||||
patches/titanium_structs.h
|
patches/titanium_structs.h
|
||||||
patches/uf.h
|
patches/underfoot.h
|
||||||
patches/uf_limits.h
|
patches/underfoot_itemfields.h
|
||||||
patches/uf_ops.h
|
patches/underfoot_ops.h
|
||||||
patches/uf_structs.h
|
patches/underfoot_constants.h
|
||||||
|
patches/underfoot_structs.h
|
||||||
|
patches/client62.cpp
|
||||||
patches/patches.cpp
|
patches/patches.cpp
|
||||||
patches/sod.cpp
|
patches/sod.cpp
|
||||||
patches/sod_limits.cpp
|
|
||||||
patches/sof.cpp
|
patches/sof.cpp
|
||||||
patches/sof_limits.cpp
|
|
||||||
patches/rof.cpp
|
patches/rof.cpp
|
||||||
patches/rof_limits.cpp
|
|
||||||
patches/rof2.cpp
|
|
||||||
patches/rof2_limits.cpp
|
|
||||||
patches/titanium.cpp
|
patches/titanium.cpp
|
||||||
patches/titanium_limits.cpp
|
patches/underfoot.cpp
|
||||||
patches/uf.cpp
|
|
||||||
patches/uf_limits.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(shared FILES
|
SOURCE_GROUP(SocketLib FILES
|
||||||
shared/shared_memory.h
|
SocketLib/Base64.h
|
||||||
shared/shared_memory_error.h
|
SocketLib/File.h
|
||||||
shared/shared_memory_handle.h
|
SocketLib/HttpdCookies.h
|
||||||
shared/shared_memory_list.h
|
SocketLib/HttpdForm.h
|
||||||
shared/shared_memory_map.h
|
SocketLib/HttpdSocket.h
|
||||||
shared/shared_memory_string.h
|
SocketLib/HTTPSocket.h
|
||||||
shared/shared_memory_vector.h
|
SocketLib/IFile.h
|
||||||
|
SocketLib/MemFile.h
|
||||||
|
SocketLib/Mime.h
|
||||||
|
SocketLib/Parse.h
|
||||||
|
SocketLib/socket_include.h
|
||||||
|
SocketLib/Utility.h
|
||||||
|
SocketLib/Base64.cpp
|
||||||
|
SocketLib/File.cpp
|
||||||
|
SocketLib/HttpdCookies.cpp
|
||||||
|
SocketLib/HttpdForm.cpp
|
||||||
|
SocketLib/HttpdSocket.cpp
|
||||||
|
SocketLib/HTTPSocket.cpp
|
||||||
|
SocketLib/MemFile.cpp
|
||||||
|
SocketLib/Mime.cpp
|
||||||
|
SocketLib/Parse.cpp
|
||||||
|
SocketLib/socket_include.cpp
|
||||||
|
SocketLib/Utility.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(StackWalker FILES
|
SOURCE_GROUP(StackWalker FILES
|
||||||
@@ -388,22 +321,22 @@ SOURCE_GROUP(StackWalker FILES
|
|||||||
StackWalker/StackWalker.cpp
|
StackWalker/StackWalker.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(Util FILES
|
SOURCE_GROUP(TinyXML FILES
|
||||||
util/memory_stream.h
|
tinyxml/tinystr.h
|
||||||
util/directory.cpp
|
tinyxml/tinyxml.h
|
||||||
util/directory.h
|
tinyxml/tinystr.cpp
|
||||||
util/uuid.cpp
|
tinyxml/tinyxml.cpp
|
||||||
util/uuid.h
|
tinyxml/tinyxmlerror.cpp
|
||||||
|
tinyxml/tinyxmlparser.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker)
|
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML)
|
||||||
|
|
||||||
ADD_LIBRARY(common ${common_sources} ${common_headers})
|
ADD_LIBRARY(common ${common_sources} ${common_headers})
|
||||||
|
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
SET_SOURCE_FILES_PROPERTIES("SocketLib/Mime.cpp" PROPERTY COMPILE_FLAGS -Wno-unused-result)
|
ADD_DEFINITIONS(-fPIC)
|
||||||
SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES COMPILE_FLAGS -O0)
|
SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0)
|
||||||
ENDIF(UNIX)
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
|
||||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning(disable:4786)
|
#pragma warning(disable:4786)
|
||||||
#endif
|
#endif
|
||||||
#include "../global_define.h"
|
#include "../debug.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ along with this program; if not, write to the Free Software
|
|||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../global_define.h"
|
#include "../debug.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning(disable:4786)
|
#pragma warning(disable:4786)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning(disable:4786)
|
#pragma warning(disable:4786)
|
||||||
#endif
|
#endif
|
||||||
#include "../global_define.h"
|
#include "../debug.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
#include "HttpdCookies.h"
|
#include "HttpdCookies.h"
|
||||||
#include "HttpdForm.h"
|
#include "HttpdForm.h"
|
||||||
@@ -194,6 +194,7 @@ void HttpdSocket::OnHeaderComplete()
|
|||||||
|
|
||||||
void HttpdSocket::OnData(const char *p,size_t l)
|
void HttpdSocket::OnData(const char *p,size_t l)
|
||||||
{
|
{
|
||||||
|
//printf("Got %d bytes: %.*s\n", l, l, p);
|
||||||
if (m_file)
|
if (m_file)
|
||||||
{
|
{
|
||||||
m_file -> fwrite(p,1,l);
|
m_file -> fwrite(p,1,l);
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ size_t MemFile::fread(char *ptr, size_t size, size_t nmemb)
|
|||||||
size_t sz = size * nmemb;
|
size_t sz = size * nmemb;
|
||||||
if (p + sz < BLOCKSIZE)
|
if (p + sz < BLOCKSIZE)
|
||||||
{
|
{
|
||||||
|
//printf("Read @ %d(%d). %d bytes. (%c)\n", m_read_ptr, p, sz, *(m_current_read -> data + p));
|
||||||
memcpy(ptr, m_current_read -> data + p, sz);
|
memcpy(ptr, m_current_read -> data + p, sz);
|
||||||
m_read_ptr += sz;
|
m_read_ptr += sz;
|
||||||
}
|
}
|
||||||
@@ -141,6 +142,7 @@ size_t MemFile::fwrite(const char *ptr, size_t size, size_t nmemb)
|
|||||||
size_t sz = size * nmemb;
|
size_t sz = size * nmemb;
|
||||||
if (p + sz < BLOCKSIZE)
|
if (p + sz < BLOCKSIZE)
|
||||||
{
|
{
|
||||||
|
//printf("Write @ %d(%d). %d bytes.\n", m_write_ptr, p, sz);
|
||||||
memcpy(m_current_write -> data + p, ptr, sz);
|
memcpy(m_current_write -> data + p, ptr, sz);
|
||||||
m_write_ptr += sz;
|
m_write_ptr += sz;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1128,6 +1128,7 @@ BOOL __stdcall StackWalker::myReadProcMem(
|
|||||||
SIZE_T st;
|
SIZE_T st;
|
||||||
BOOL bRet = ReadProcessMemory(hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, &st);
|
BOOL bRet = ReadProcessMemory(hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, &st);
|
||||||
*lpNumberOfBytesRead = (DWORD) st;
|
*lpNumberOfBytesRead = (DWORD) st;
|
||||||
|
//printf("ReadMemory: hProcess: %p, baseAddr: %p, buffer: %p, size: %d, read: %d, result: %d\n", hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, (DWORD) st, (DWORD) bRet);
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+2
-2
@@ -24,8 +24,8 @@ struct BaseDataStruct
|
|||||||
double base_hp;
|
double base_hp;
|
||||||
double base_mana;
|
double base_mana;
|
||||||
double base_end;
|
double base_end;
|
||||||
double hp_regen;
|
double unk1;
|
||||||
double end_regen;
|
double unk2;
|
||||||
double hp_factor;
|
double hp_factor;
|
||||||
double mana_factor;
|
double mana_factor;
|
||||||
double endurance_factor;
|
double endurance_factor;
|
||||||
|
|||||||
+3
-14
@@ -15,12 +15,13 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
#include "debug.h"
|
||||||
#include "global_define.h"
|
|
||||||
#include "base_packet.h"
|
#include "base_packet.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "packet_dump.h"
|
#include "packet_dump.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BasePacket::BasePacket(const unsigned char *buf, uint32 len)
|
BasePacket::BasePacket(const unsigned char *buf, uint32 len)
|
||||||
{
|
{
|
||||||
this->pBuffer=nullptr;
|
this->pBuffer=nullptr;
|
||||||
@@ -39,18 +40,6 @@ BasePacket::BasePacket(const unsigned char *buf, uint32 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()
|
BasePacket::~BasePacket()
|
||||||
{
|
{
|
||||||
if (pBuffer)
|
if (pBuffer)
|
||||||
|
|||||||
+3
-10
@@ -19,14 +19,14 @@
|
|||||||
#define BASEPACKET_H_
|
#define BASEPACKET_H_
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "serialize_buffer.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef WIN32
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <winsock2.h>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@@ -64,18 +64,12 @@ public:
|
|||||||
void WriteFloat(float value) { *(float *)(pBuffer + _wpos) = value; _wpos += sizeof(float); }
|
void WriteFloat(float value) { *(float *)(pBuffer + _wpos) = value; _wpos += sizeof(float); }
|
||||||
void WriteDouble(double value) { *(double *)(pBuffer + _wpos) = value; _wpos += sizeof(double); }
|
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; }
|
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() { uint8 value = *(uint8 *)(pBuffer + _rpos); _rpos += sizeof(uint8); return value; }
|
||||||
uint8 ReadUInt8(uint32 Offset) const { uint8 value = *(uint8 *)(pBuffer + Offset); 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 value = *(uint32 *)(pBuffer + _rpos); _rpos += sizeof(uint32); return value; }
|
||||||
uint32 ReadUInt32(uint32 Offset) const { uint32 value = *(uint32 *)(pBuffer + Offset); return value; }
|
uint32 ReadUInt32(uint32 Offset) const { uint32 value = *(uint32 *)(pBuffer + Offset); return value; }
|
||||||
void ReadString(char *str) { uint32 len = static_cast<uint32>(strlen((char *)(pBuffer + _rpos))) + 1; memcpy(str, pBuffer + _rpos, len); _rpos += len; }
|
void ReadString(char *str) { uint32 len = static_cast<uint32>(strlen((char *)(pBuffer + _rpos))) + 1; memcpy(str, pBuffer + _rpos, len); _rpos += len; }
|
||||||
void ReadString(std::string &str) { str = reinterpret_cast<char *>(pBuffer + _rpos); _rpos += str.length() + 1; }
|
|
||||||
void ReadString(char *str, uint32 Offset, uint32 MaxLength) const;
|
void ReadString(char *str, uint32 Offset, uint32 MaxLength) const;
|
||||||
|
|
||||||
uint32 GetWritePosition() { return _wpos; }
|
uint32 GetWritePosition() { return _wpos; }
|
||||||
@@ -87,7 +81,6 @@ protected:
|
|||||||
virtual ~BasePacket();
|
virtual ~BasePacket();
|
||||||
BasePacket() { pBuffer=nullptr; size=0; _wpos = 0; _rpos = 0; }
|
BasePacket() { pBuffer=nullptr; size=0; _wpos = 0; _rpos = 0; }
|
||||||
BasePacket(const unsigned char *buf, const uint32 len);
|
BasePacket(const unsigned char *buf, const uint32 len);
|
||||||
BasePacket(SerializeBuffer &buf);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void DumpPacketHex(const BasePacket* app);
|
extern void DumpPacketHex(const BasePacket* app);
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ typedef enum {
|
|||||||
BT_Greater_Akheva = 14,
|
BT_Greater_Akheva = 14,
|
||||||
BT_Khati_Sha = 15,
|
BT_Khati_Sha = 15,
|
||||||
BT_Seru = 16, //not confirmed....
|
BT_Seru = 16, //not confirmed....
|
||||||
BT_Draz_Nurakk = 18,
|
|
||||||
BT_Zek = 19,
|
BT_Zek = 19,
|
||||||
BT_Luggald = 20,
|
BT_Luggald = 20,
|
||||||
BT_Animal = 21,
|
BT_Animal = 21,
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
/* 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 BREAKDOWNS_H_
|
||||||
|
#define BREAKDOWNS_H_
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
struct uint16_breakdown {
|
||||||
|
union {
|
||||||
|
uint16 all;
|
||||||
|
struct {
|
||||||
|
uint8 b1;
|
||||||
|
uint8 b2;
|
||||||
|
} bytes;
|
||||||
|
};
|
||||||
|
inline uint16& operator=(const uint16& val) { return (all=val); }
|
||||||
|
inline uint16* operator&() { return &all; }
|
||||||
|
inline operator uint16&() { return all; }
|
||||||
|
inline uint8& b1() { return bytes.b1; }
|
||||||
|
inline uint8& b2() { return bytes.b2; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct uint32_breakdown {
|
||||||
|
union {
|
||||||
|
uint32 all;
|
||||||
|
struct {
|
||||||
|
uint16 w1;
|
||||||
|
uint16 w2;
|
||||||
|
} words;
|
||||||
|
struct {
|
||||||
|
uint8 b1;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint8 b2;
|
||||||
|
uint8 b3;
|
||||||
|
} middle;
|
||||||
|
uint16 w2_3; // word bytes 2 to 3
|
||||||
|
};
|
||||||
|
uint8 b4;
|
||||||
|
} bytes;
|
||||||
|
};
|
||||||
|
inline uint32& operator=(const uint32& val) { return (all=val); }
|
||||||
|
inline uint32* operator&() { return &all; }
|
||||||
|
inline operator uint32&() { return all; }
|
||||||
|
|
||||||
|
inline uint16& w1() { return words.w1; }
|
||||||
|
inline uint16& w2() { return words.w2; }
|
||||||
|
inline uint16& w2_3() { return bytes.w2_3; }
|
||||||
|
inline uint8& b1() { return bytes.b1; }
|
||||||
|
inline uint8& b2() { return bytes.middle.b2; }
|
||||||
|
inline uint8& b3() { return bytes.middle.b3; }
|
||||||
|
inline uint8& b4() { return bytes.b4; }
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
struct uint64_breakdown {
|
||||||
|
union {
|
||||||
|
uint64 all;
|
||||||
|
struct {
|
||||||
|
uint16 w1; // 1 2
|
||||||
|
uint16 w2; // 3 4
|
||||||
|
uint16 w3; // 5 6
|
||||||
|
uint16 w4; // 7 8
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
uint32 dw1; // 1 4
|
||||||
|
uint32 dw2; // 5 6
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
uint8 b1;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint16 w2_3;
|
||||||
|
uint16 w4_5;
|
||||||
|
uint16 w6_7;
|
||||||
|
};
|
||||||
|
uint32 dw2_5;
|
||||||
|
struct {
|
||||||
|
uint8 b2;
|
||||||
|
union {
|
||||||
|
uint32 dw3_6;
|
||||||
|
struct {
|
||||||
|
uint8 b3;
|
||||||
|
union {
|
||||||
|
uint32 dw4_7;
|
||||||
|
struct {
|
||||||
|
uint8 b4;
|
||||||
|
uint8 b5;
|
||||||
|
uint8 b6;
|
||||||
|
uint8 b7;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
inline uint64* operator&() { return &all; }
|
||||||
|
inline operator uint64&() { return all; }
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*BREAKDOWNS_H_*/
|
||||||
+131
-501
@@ -1,5 +1,5 @@
|
|||||||
/* EQEMu: Everquest Server Emulator
|
/* EQEMu: Everquest Server Emulator
|
||||||
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org)
|
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,336 +14,233 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "../common/global_define.h"
|
#include "../common/debug.h"
|
||||||
#include "../common/classes.h"
|
#include "../common/classes.h"
|
||||||
|
|
||||||
const char *GetClassIDName(uint8 class_id, uint8 level)
|
const char* GetEQClassName(uint8 class_, uint8 level) {
|
||||||
{
|
switch(class_) {
|
||||||
switch (class_id) {
|
|
||||||
case WARRIOR:
|
case WARRIOR:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Vanquisher";
|
return "Vanquisher";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE.
|
return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE.
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Warlord";
|
return "Warlord";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Myrmidon";
|
return "Myrmidon";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Champion";
|
return "Champion";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Warrior";
|
return "Warrior";
|
||||||
}
|
|
||||||
case CLERIC:
|
case CLERIC:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Prelate";
|
return "Prelate";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Archon";
|
return "Archon";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "High Priest";
|
return "High Priest";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Templar";
|
return "Templar";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Vicar";
|
return "Vicar";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Cleric";
|
return "Cleric";
|
||||||
}
|
|
||||||
case PALADIN:
|
case PALADIN:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Lord";
|
return "Lord";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Lord Protector";
|
return "Lord Protector";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Crusader";
|
return "Crusader";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Knight";
|
return "Knight";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Cavalier";
|
return "Cavalier";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Paladin";
|
return "Paladin";
|
||||||
}
|
|
||||||
case RANGER:
|
case RANGER:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Plainswalker";
|
return "Plainswalker";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Forest Stalker";
|
return "Forest Stalker";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Warder";
|
return "Warder";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Outrider";
|
return "Outrider";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Pathfinder";
|
return "Pathfinder";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Ranger";
|
return "Ranger";
|
||||||
}
|
|
||||||
case SHADOWKNIGHT:
|
case SHADOWKNIGHT:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Scourge Knight";
|
return "Scourge Knight";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Dread Lord";
|
return "Dread Lord";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Grave Lord";
|
return "Grave Lord";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Revenant";
|
return "Revenant";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Reaver";
|
return "Reaver";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Shadowknight";
|
return "Shadowknight";
|
||||||
}
|
|
||||||
case DRUID:
|
case DRUID:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Natureguard";
|
return "Natureguard";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Storm Warden";
|
return "Storm Warden";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Hierophant";
|
return "Hierophant";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Preserver";
|
return "Preserver";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Wanderer";
|
return "Wanderer";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Druid";
|
return "Druid";
|
||||||
}
|
|
||||||
case MONK:
|
case MONK:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Stone Fist";
|
return "Stone Fist";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Transcendent";
|
return "Transcendent";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Grandmaster";
|
return "Grandmaster";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Master";
|
return "Master";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Disciple";
|
return "Disciple";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Monk";
|
return "Monk";
|
||||||
}
|
|
||||||
case BARD:
|
case BARD:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Performer";
|
return "Performer";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Maestro";
|
return "Maestro";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Virtuoso";
|
return "Virtuoso";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Troubadour";
|
return "Troubadour";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Minstrel";
|
return "Minstrel";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Bard";
|
return "Bard";
|
||||||
}
|
|
||||||
case ROGUE:
|
case ROGUE:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Nemesis";
|
return "Nemesis";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Deceiver";
|
return "Deceiver";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Assassin";
|
return "Assassin";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Blackguard";
|
return "Blackguard";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Rake";
|
return "Rake";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Rogue";
|
return "Rogue";
|
||||||
}
|
|
||||||
case SHAMAN:
|
case SHAMAN:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Soothsayer";
|
return "Soothsayer";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Prophet";
|
return "Prophet";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Oracle";
|
return "Oracle";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Luminary";
|
return "Luminary";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Mystic";
|
return "Mystic";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Shaman";
|
return "Shaman";
|
||||||
}
|
|
||||||
case NECROMANCER:
|
case NECROMANCER:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Wraith";
|
return "Wraith";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Arch Lich";
|
return "Arch Lich";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Warlock";
|
return "Warlock";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Defiler";
|
return "Defiler";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Heretic";
|
return "Heretic";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Necromancer";
|
return "Necromancer";
|
||||||
}
|
|
||||||
case WIZARD:
|
case WIZARD:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Grand Arcanist";
|
return "Grand Arcanist";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Arcanist";
|
return "Arcanist";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Sorcerer";
|
return "Sorcerer";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Evoker";
|
return "Evoker";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Channeler";
|
return "Channeler";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Wizard";
|
return "Wizard";
|
||||||
}
|
|
||||||
case MAGICIAN:
|
case MAGICIAN:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Arch Magus";
|
return "Arch Magus";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Arch Convoker";
|
return "Arch Convoker";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Arch Mage";
|
return "Arch Mage";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Conjurer";
|
return "Conjurer";
|
||||||
}
|
if (level >= 51)
|
||||||
if (level >= 51) {
|
|
||||||
return "Elementalist";
|
return "Elementalist";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Magician";
|
return "Magician";
|
||||||
}
|
|
||||||
case ENCHANTER:
|
case ENCHANTER:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Bedazzler";
|
return "Bedazzler";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Coercer";
|
return "Coercer";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Phantasmist";
|
return "Phantasmist";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Beguiler";
|
return "Beguiler";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Illusionist";
|
return "Illusionist";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Enchanter";
|
return "Enchanter";
|
||||||
}
|
|
||||||
case BEASTLORD:
|
case BEASTLORD:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Wildblood";
|
return "Wildblood";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Feral Lord";
|
return "Feral Lord";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Savage Lord";
|
return "Savage Lord";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Animist";
|
return "Animist";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Primalist";
|
return "Primalist";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Beastlord";
|
return "Beastlord";
|
||||||
}
|
|
||||||
case BERSERKER:
|
case BERSERKER:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Ravager";
|
return "Ravager";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Fury";
|
return "Fury";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Rager";
|
return "Rager";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Vehement";
|
return "Vehement";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Brawler";
|
return "Brawler";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Berserker";
|
return "Berserker";
|
||||||
}
|
|
||||||
case BANKER:
|
case BANKER:
|
||||||
if (level >= 70) {
|
if (level >= 70)
|
||||||
return "Master Banker";
|
return "Master Banker";
|
||||||
}
|
else if (level >= 65)
|
||||||
else if (level >= 65) {
|
|
||||||
return "Elder Banker";
|
return "Elder Banker";
|
||||||
}
|
else if (level >= 60)
|
||||||
else if (level >= 60) {
|
|
||||||
return "Oldest Banker";
|
return "Oldest Banker";
|
||||||
}
|
else if (level >= 55)
|
||||||
else if (level >= 55) {
|
|
||||||
return "Older Banker";
|
return "Older Banker";
|
||||||
}
|
else if (level >= 51)
|
||||||
else if (level >= 51) {
|
|
||||||
return "Old Banker";
|
return "Old Banker";
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return "Banker";
|
return "Banker";
|
||||||
}
|
|
||||||
case WARRIORGM:
|
case WARRIORGM:
|
||||||
return "Warrior Guildmaster";
|
return "Warrior Guildmaster";
|
||||||
case CLERICGM:
|
case CLERICGM:
|
||||||
@@ -393,317 +290,50 @@ const char *GetClassIDName(uint8 class_id, uint8 level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *GetPlayerClassName(uint32 player_class_value, uint8 level)
|
uint32 GetArrayEQClass(uint8 eqclass) {
|
||||||
{
|
switch (eqclass) {
|
||||||
return GetClassIDName(GetClassIDFromPlayerClassValue(player_class_value), level);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 GetPlayerClassValue(uint8 class_id)
|
|
||||||
{
|
|
||||||
switch (class_id) {
|
|
||||||
case WARRIOR:
|
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;
|
return WARRIOR;
|
||||||
case PLAYER_CLASS_CLERIC_BIT:
|
case CLERIC:
|
||||||
return CLERIC;
|
return CLERIC;
|
||||||
case PLAYER_CLASS_PALADIN_BIT:
|
case PALADIN:
|
||||||
return PALADIN;
|
return PALADIN;
|
||||||
case PLAYER_CLASS_RANGER_BIT:
|
case RANGER:
|
||||||
return RANGER;
|
return RANGER;
|
||||||
case PLAYER_CLASS_SHADOWKNIGHT_BIT:
|
case SHADOWKNIGHT:
|
||||||
return SHADOWKNIGHT;
|
return SHADOWKNIGHT;
|
||||||
case PLAYER_CLASS_DRUID_BIT:
|
case DRUID:
|
||||||
return DRUID;
|
return DRUID;
|
||||||
case PLAYER_CLASS_MONK_BIT:
|
case MONK:
|
||||||
return MONK;
|
return MONK;
|
||||||
case PLAYER_CLASS_BARD_BIT:
|
case BARD:
|
||||||
return BARD;
|
return BARD;
|
||||||
case PLAYER_CLASS_ROGUE_BIT:
|
case ROGUE:
|
||||||
return ROGUE;
|
return ROGUE;
|
||||||
case PLAYER_CLASS_SHAMAN_BIT:
|
case SHAMAN:
|
||||||
return SHAMAN;
|
return SHAMAN;
|
||||||
case PLAYER_CLASS_NECROMANCER_BIT:
|
case NECROMANCER:
|
||||||
return NECROMANCER;
|
return NECROMANCER;
|
||||||
case PLAYER_CLASS_WIZARD_BIT:
|
case WIZARD:
|
||||||
return WIZARD;
|
return WIZARD;
|
||||||
case PLAYER_CLASS_MAGICIAN_BIT:
|
case MAGICIAN:
|
||||||
return MAGICIAN;
|
return MAGICIAN;
|
||||||
case PLAYER_CLASS_ENCHANTER_BIT:
|
case ENCHANTER:
|
||||||
return ENCHANTER;
|
return ENCHANTER;
|
||||||
case PLAYER_CLASS_BEASTLORD_BIT:
|
case BEASTLORD:
|
||||||
return BEASTLORD;
|
return BEASTLORD;
|
||||||
case PLAYER_CLASS_BERSERKER_BIT:
|
case BERSERKER:
|
||||||
return BERSERKER;
|
return BERSERKER;
|
||||||
default:
|
default:
|
||||||
return PLAYER_CLASS_UNKNOWN; // watch
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsFighterClass(uint8 class_id)
|
uint8 GetEQArrayEQClass(uint8 eqclass) {
|
||||||
{
|
if (eqclass >= WARRIOR && eqclass <= BERSERKER)
|
||||||
switch (class_id) {
|
return eqclass - WARRIOR;
|
||||||
case WARRIOR:
|
if (eqclass >= WARRIORGM && eqclass <= BERSERKERGM)
|
||||||
case PALADIN:
|
return eqclass - WARRIORGM;
|
||||||
case RANGER:
|
return WARRIOR;
|
||||||
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 IsHybridClass(uint8 class_id)
|
|
||||||
{
|
|
||||||
switch (class_id) {
|
|
||||||
case PALADIN:
|
|
||||||
case RANGER:
|
|
||||||
case SHADOWKNIGHT:
|
|
||||||
case BARD:
|
|
||||||
case BEASTLORD:
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+44
-101
@@ -1,5 +1,5 @@
|
|||||||
/* EQEMu: Everquest Server Emulator
|
/* EQEMu: Everquest Server Emulator
|
||||||
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org)
|
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,25 +17,26 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef CLASSES_CH
|
#ifndef CLASSES_CH
|
||||||
#define CLASSES_CH
|
#define CLASSES_CH
|
||||||
|
|
||||||
#include "../common/types.h"
|
#include "../common/types.h"
|
||||||
|
|
||||||
#define WARRIOR 1
|
#define Array_Class_UNKNOWN 0
|
||||||
#define CLERIC 2
|
#define WARRIOR 1
|
||||||
#define PALADIN 3
|
#define CLERIC 2
|
||||||
#define RANGER 4
|
#define PALADIN 3
|
||||||
#define SHADOWKNIGHT 5
|
#define RANGER 4
|
||||||
#define DRUID 6
|
#define SHADOWKNIGHT 5
|
||||||
#define MONK 7
|
#define DRUID 6
|
||||||
#define BARD 8
|
#define MONK 7
|
||||||
#define ROGUE 9
|
#define BARD 8
|
||||||
#define SHAMAN 10
|
#define ROGUE 9
|
||||||
#define NECROMANCER 11
|
#define SHAMAN 10
|
||||||
#define WIZARD 12
|
#define NECROMANCER 11
|
||||||
#define MAGICIAN 13
|
#define WIZARD 12
|
||||||
#define ENCHANTER 14
|
#define MAGICIAN 13
|
||||||
#define BEASTLORD 15
|
#define ENCHANTER 14
|
||||||
#define BERSERKER 16
|
#define BEASTLORD 15
|
||||||
|
#define BERSERKER 16
|
||||||
|
#define PLAYER_CLASS_COUNT 16 // used for array defines, must be the count of playable classes
|
||||||
#define WARRIORGM 20
|
#define WARRIORGM 20
|
||||||
#define CLERICGM 21
|
#define CLERICGM 21
|
||||||
#define PALADINGM 22
|
#define PALADINGM 22
|
||||||
@@ -57,93 +58,35 @@
|
|||||||
#define DISCORD_MERCHANT 59
|
#define DISCORD_MERCHANT 59
|
||||||
#define ADVENTURERECRUITER 60
|
#define ADVENTURERECRUITER 60
|
||||||
#define ADVENTUREMERCHANT 61
|
#define ADVENTUREMERCHANT 61
|
||||||
#define LDON_TREASURE 62 // objects you can use /open on first seen in LDONs
|
#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 CORPSE_CLASS 62 //only seen on Danvi's Corpse in Akheva so far..
|
||||||
#define TRIBUTE_MASTER 63
|
#define TRIBUTE_MASTER 63
|
||||||
#define GUILD_TRIBUTE_MASTER 64 // not sure
|
#define GUILD_TRIBUTE_MASTER 64 //not sure
|
||||||
#define NORRATHS_KEEPERS_MERCHANT 67
|
#define NORRATHS_KEEPERS_MERCHANT 67
|
||||||
#define DARK_REIGN_MERCHANT 68
|
#define DARK_REIGN_MERCHANT 68
|
||||||
#define FELLOWSHIP_MASTER 69
|
#define FELLOWSHIP_MASTER 69
|
||||||
#define ALT_CURRENCY_MERCHANT 70
|
#define ALT_CURRENCY_MERCHANT 70
|
||||||
#define MERCERNARY_MASTER 71
|
#define MERCERNARY_MASTER 71
|
||||||
|
#define warrior_1 1
|
||||||
|
#define monk_1 64
|
||||||
|
#define paladin_1 4
|
||||||
|
#define shadow_1 16
|
||||||
|
#define bard_1 128
|
||||||
|
#define cleric_1 2
|
||||||
|
#define necromancer_1 1024
|
||||||
|
#define ranger_1 8
|
||||||
|
#define druid_1 32
|
||||||
|
#define mage_1 4096
|
||||||
|
#define wizard_1 2048
|
||||||
|
#define enchanter_1 8192
|
||||||
|
#define rogue_1 256
|
||||||
|
#define shaman_1 512
|
||||||
|
#define beastlord_1 16384
|
||||||
|
#define berserker_1 32768
|
||||||
|
#define call_1 65536
|
||||||
|
|
||||||
|
const char* GetEQClassName(uint8 class_, uint8 level = 0);
|
||||||
// player class values
|
uint32 GetArrayEQClass(uint8 eqclass);
|
||||||
#define PLAYER_CLASS_UNKNOWN 0
|
uint8 GetEQArrayEQClass(uint8 eqclass);
|
||||||
#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 IsHybridClass(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
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,434 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <sstream>
|
|
||||||
#include <limits>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <set>
|
|
||||||
#include <map>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace argh
|
|
||||||
{
|
|
||||||
// Terminology:
|
|
||||||
// A command line is composed of 2 types of args:
|
|
||||||
// 1. Positional args, i.e. free standing values
|
|
||||||
// 2. Options: args beginning with '-'. We identify two kinds:
|
|
||||||
// 2.1: Flags: boolean options => (exist ? true : false)
|
|
||||||
// 2.2: Parameters: a name followed by a non-option value
|
|
||||||
|
|
||||||
#if !defined(__GNUC__) || (__GNUC__ >= 5)
|
|
||||||
using string_stream = std::istringstream;
|
|
||||||
#else
|
|
||||||
// Until GCC 5, istringstream did not have a move constructor.
|
|
||||||
// stringstream_proxy is used instead, as a workaround.
|
|
||||||
class stringstream_proxy
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
stringstream_proxy() = default;
|
|
||||||
|
|
||||||
// Construct with a value.
|
|
||||||
stringstream_proxy(std::string const& value) :
|
|
||||||
stream_(value)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// Copy constructor.
|
|
||||||
stringstream_proxy(const stringstream_proxy& other) :
|
|
||||||
stream_(other.stream_.str())
|
|
||||||
{
|
|
||||||
stream_.setstate(other.stream_.rdstate());
|
|
||||||
}
|
|
||||||
|
|
||||||
void setstate(std::ios_base::iostate state) { stream_.setstate(state); }
|
|
||||||
|
|
||||||
// Stream out the value of the parameter.
|
|
||||||
// If the conversion was not possible, the stream will enter the fail state,
|
|
||||||
// and operator bool will return false.
|
|
||||||
template<typename T>
|
|
||||||
stringstream_proxy& operator >> (T& thing)
|
|
||||||
{
|
|
||||||
stream_ >> thing;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Get the string value.
|
|
||||||
std::string str() const { return stream_.str(); }
|
|
||||||
|
|
||||||
std::stringbuf* rdbuf() const { return stream_.rdbuf(); }
|
|
||||||
|
|
||||||
// Check the state of the stream.
|
|
||||||
// False when the most recent stream operation failed
|
|
||||||
operator bool() const { return !!stream_; }
|
|
||||||
|
|
||||||
~stringstream_proxy() = default;
|
|
||||||
private:
|
|
||||||
std::istringstream stream_;
|
|
||||||
};
|
|
||||||
using string_stream = stringstream_proxy;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class parser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum Mode { PREFER_FLAG_FOR_UNREG_OPTION = 1 << 0,
|
|
||||||
PREFER_PARAM_FOR_UNREG_OPTION = 1 << 1,
|
|
||||||
NO_SPLIT_ON_EQUALSIGN = 1 << 2,
|
|
||||||
SINGLE_DASH_IS_MULTIFLAG = 1 << 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
parser() = default;
|
|
||||||
|
|
||||||
parser(std::initializer_list<char const* const> pre_reg_names)
|
|
||||||
{ add_params(pre_reg_names); }
|
|
||||||
|
|
||||||
parser(const char* const argv[], int mode = PREFER_FLAG_FOR_UNREG_OPTION)
|
|
||||||
{ parse(argv, mode); }
|
|
||||||
|
|
||||||
parser(int argc, const char* const argv[], int mode = PREFER_FLAG_FOR_UNREG_OPTION)
|
|
||||||
{ parse(argc, argv, mode); }
|
|
||||||
|
|
||||||
void add_param(std::string const& name);
|
|
||||||
void add_params(std::initializer_list<char const* const> init_list);
|
|
||||||
|
|
||||||
void parse(const char* const argv[], int mode = PREFER_FLAG_FOR_UNREG_OPTION);
|
|
||||||
void parse(int argc, const char* const argv[], int mode = PREFER_FLAG_FOR_UNREG_OPTION);
|
|
||||||
|
|
||||||
std::multiset<std::string> const& flags() const { return flags_; }
|
|
||||||
std::map<std::string, std::string> const& params() const { return params_; }
|
|
||||||
std::vector<std::string> const& pos_args() const { return pos_args_; }
|
|
||||||
|
|
||||||
// begin() and end() for using range-for over positional args.
|
|
||||||
std::vector<std::string>::const_iterator begin() const { return pos_args_.cbegin(); }
|
|
||||||
std::vector<std::string>::const_iterator end() const { return pos_args_.cend(); }
|
|
||||||
size_t size() const { return pos_args_.size(); }
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// Accessors
|
|
||||||
|
|
||||||
// flag (boolean) accessors: return true if the flag appeared, otherwise false.
|
|
||||||
bool operator[](std::string const& name) const;
|
|
||||||
|
|
||||||
// multiple flag (boolean) accessors: return true if at least one of the flag appeared, otherwise false.
|
|
||||||
bool operator[](std::initializer_list<char const* const> init_list) const;
|
|
||||||
|
|
||||||
// returns positional arg string by order. Like argv[] but without the options
|
|
||||||
std::string const& operator[](size_t ind) const;
|
|
||||||
|
|
||||||
// returns a std::istream that can be used to convert a positional arg to a typed value.
|
|
||||||
string_stream operator()(size_t ind) const;
|
|
||||||
|
|
||||||
// same as above, but with a default value in case the arg is missing (index out of range).
|
|
||||||
template<typename T>
|
|
||||||
string_stream operator()(size_t ind, T&& def_val) const;
|
|
||||||
|
|
||||||
// parameter accessors, give a name get an std::istream that can be used to convert to a typed value.
|
|
||||||
// call .str() on result to get as string
|
|
||||||
string_stream operator()(std::string const& name) const;
|
|
||||||
|
|
||||||
// accessor for a parameter with multiple names, give a list of names, get an std::istream that can be used to convert to a typed value.
|
|
||||||
// call .str() on result to get as string
|
|
||||||
// returns the first value in the list to be found.
|
|
||||||
string_stream operator()(std::initializer_list<char const* const> init_list) const;
|
|
||||||
|
|
||||||
// same as above, but with a default value in case the param was missing.
|
|
||||||
// Non-string def_val types must have an operator<<() (output stream operator)
|
|
||||||
// If T only has an input stream operator, pass the string version of the type as in "3" instead of 3.
|
|
||||||
template<typename T>
|
|
||||||
string_stream operator()(std::string const& name, T&& def_val) const;
|
|
||||||
|
|
||||||
// same as above but for a list of names. returns the first value to be found.
|
|
||||||
template<typename T>
|
|
||||||
string_stream operator()(std::initializer_list<char const* const> init_list, T&& def_val) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
string_stream bad_stream() const;
|
|
||||||
std::string trim_leading_dashes(std::string const& name) const;
|
|
||||||
bool is_number(std::string const& arg) const;
|
|
||||||
bool is_option(std::string const& arg) const;
|
|
||||||
bool got_flag(std::string const& name) const;
|
|
||||||
bool is_param(std::string const& name) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<std::string> args_;
|
|
||||||
std::map<std::string, std::string> params_;
|
|
||||||
std::vector<std::string> pos_args_;
|
|
||||||
std::multiset<std::string> flags_;
|
|
||||||
std::set<std::string> registeredParams_;
|
|
||||||
std::string empty_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline void parser::parse(const char * const argv[], int mode)
|
|
||||||
{
|
|
||||||
int argc = 0;
|
|
||||||
for (auto argvp = argv; *argvp; ++argc, ++argvp);
|
|
||||||
parse(argc, argv, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline void parser::parse(int argc, const char* const argv[], int mode /*= PREFER_FLAG_FOR_UNREG_OPTION*/)
|
|
||||||
{
|
|
||||||
// convert to strings
|
|
||||||
args_.resize(argc);
|
|
||||||
std::transform(argv, argv + argc, args_.begin(), [](const char* const arg) { return arg; });
|
|
||||||
|
|
||||||
// parse line
|
|
||||||
for (auto i = 0u; i < args_.size(); ++i)
|
|
||||||
{
|
|
||||||
if (!is_option(args_[i]))
|
|
||||||
{
|
|
||||||
pos_args_.emplace_back(args_[i]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto name = trim_leading_dashes(args_[i]);
|
|
||||||
|
|
||||||
if (!(mode & NO_SPLIT_ON_EQUALSIGN))
|
|
||||||
{
|
|
||||||
auto equalPos = name.find('=');
|
|
||||||
if (equalPos != std::string::npos)
|
|
||||||
{
|
|
||||||
params_.insert({ name.substr(0, equalPos), name.substr(equalPos + 1) });
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the option is unregistered and should be a multi-flag
|
|
||||||
if (1 == (args_[i].size() - name.size()) && // single dash
|
|
||||||
argh::parser::SINGLE_DASH_IS_MULTIFLAG & mode && // multi-flag mode
|
|
||||||
!is_param(name)) // unregistered
|
|
||||||
{
|
|
||||||
std::string keep_param;
|
|
||||||
|
|
||||||
if (!name.empty() && is_param(std::string(1ul, name.back()))) // last char is param
|
|
||||||
{
|
|
||||||
keep_param += name.back();
|
|
||||||
name.resize(name.size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto const& c : name)
|
|
||||||
{
|
|
||||||
flags_.emplace(std::string{ c });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!keep_param.empty())
|
|
||||||
{
|
|
||||||
name = keep_param;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue; // do not consider other options for this arg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// any potential option will get as its value the next arg, unless that arg is an option too
|
|
||||||
// in that case it will be determined a flag.
|
|
||||||
if (i == args_.size() - 1 || is_option(args_[i + 1]))
|
|
||||||
{
|
|
||||||
flags_.emplace(name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if 'name' is a pre-registered option, then the next arg cannot be a free parameter to it is skipped
|
|
||||||
// otherwise we have 2 modes:
|
|
||||||
// PREFER_FLAG_FOR_UNREG_OPTION: a non-registered 'name' is determined a flag.
|
|
||||||
// The following value (the next arg) will be a free parameter.
|
|
||||||
//
|
|
||||||
// PREFER_PARAM_FOR_UNREG_OPTION: a non-registered 'name' is determined a parameter, the next arg
|
|
||||||
// will be the value of that option.
|
|
||||||
|
|
||||||
assert(!(mode & argh::parser::PREFER_FLAG_FOR_UNREG_OPTION)
|
|
||||||
|| !(mode & argh::parser::PREFER_PARAM_FOR_UNREG_OPTION));
|
|
||||||
|
|
||||||
bool preferParam = mode & argh::parser::PREFER_PARAM_FOR_UNREG_OPTION;
|
|
||||||
|
|
||||||
if (is_param(name) || preferParam)
|
|
||||||
{
|
|
||||||
params_.insert({ name, args_[i + 1] });
|
|
||||||
++i; // skip next value, it is not a free parameter
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
flags_.emplace(name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline string_stream parser::bad_stream() const
|
|
||||||
{
|
|
||||||
string_stream bad;
|
|
||||||
bad.setstate(std::ios_base::failbit);
|
|
||||||
return bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline bool parser::is_number(std::string const& arg) const
|
|
||||||
{
|
|
||||||
// inefficient but simple way to determine if a string is a number (which can start with a '-')
|
|
||||||
std::istringstream istr(arg);
|
|
||||||
double number;
|
|
||||||
istr >> number;
|
|
||||||
return !(istr.fail() || istr.bad());
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline bool parser::is_option(std::string const& arg) const
|
|
||||||
{
|
|
||||||
assert(0 != arg.size());
|
|
||||||
if (is_number(arg))
|
|
||||||
return false;
|
|
||||||
return '-' == arg[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline std::string parser::trim_leading_dashes(std::string const& name) const
|
|
||||||
{
|
|
||||||
auto pos = name.find_first_not_of('-');
|
|
||||||
return std::string::npos != pos ? name.substr(pos) : name;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline bool argh::parser::got_flag(std::string const& name) const
|
|
||||||
{
|
|
||||||
return flags_.end() != flags_.find(trim_leading_dashes(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline bool argh::parser::is_param(std::string const& name) const
|
|
||||||
{
|
|
||||||
return registeredParams_.count(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline bool parser::operator[](std::string const& name) const
|
|
||||||
{
|
|
||||||
return got_flag(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline bool parser::operator[](std::initializer_list<char const* const> init_list) const
|
|
||||||
{
|
|
||||||
return std::any_of(init_list.begin(), init_list.end(), [&](char const* const name) { return got_flag(name); });
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline std::string const& parser::operator[](size_t ind) const
|
|
||||||
{
|
|
||||||
if (ind < pos_args_.size())
|
|
||||||
return pos_args_[ind];
|
|
||||||
return empty_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline string_stream parser::operator()(std::string const& name) const
|
|
||||||
{
|
|
||||||
auto optIt = params_.find(trim_leading_dashes(name));
|
|
||||||
if (params_.end() != optIt)
|
|
||||||
return string_stream(optIt->second);
|
|
||||||
return bad_stream();
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline string_stream parser::operator()(std::initializer_list<char const* const> init_list) const
|
|
||||||
{
|
|
||||||
for (auto& name : init_list)
|
|
||||||
{
|
|
||||||
auto optIt = params_.find(trim_leading_dashes(name));
|
|
||||||
if (params_.end() != optIt)
|
|
||||||
return string_stream(optIt->second);
|
|
||||||
}
|
|
||||||
return bad_stream();
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
string_stream parser::operator()(std::string const& name, T&& def_val) const
|
|
||||||
{
|
|
||||||
auto optIt = params_.find(trim_leading_dashes(name));
|
|
||||||
if (params_.end() != optIt)
|
|
||||||
return string_stream(optIt->second);
|
|
||||||
|
|
||||||
std::ostringstream ostr;
|
|
||||||
ostr.precision(std::numeric_limits<long double>::max_digits10);
|
|
||||||
ostr << def_val;
|
|
||||||
return string_stream(ostr.str()); // use default
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// same as above but for a list of names. returns the first value to be found.
|
|
||||||
template<typename T>
|
|
||||||
string_stream parser::operator()(std::initializer_list<char const* const> init_list, T&& def_val) const
|
|
||||||
{
|
|
||||||
for (auto& name : init_list)
|
|
||||||
{
|
|
||||||
auto optIt = params_.find(trim_leading_dashes(name));
|
|
||||||
if (params_.end() != optIt)
|
|
||||||
return string_stream(optIt->second);
|
|
||||||
}
|
|
||||||
std::ostringstream ostr;
|
|
||||||
ostr.precision(std::numeric_limits<long double>::max_digits10);
|
|
||||||
ostr << def_val;
|
|
||||||
return string_stream(ostr.str()); // use default
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline string_stream parser::operator()(size_t ind) const
|
|
||||||
{
|
|
||||||
if (pos_args_.size() <= ind)
|
|
||||||
return bad_stream();
|
|
||||||
|
|
||||||
return string_stream(pos_args_[ind]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
string_stream parser::operator()(size_t ind, T&& def_val) const
|
|
||||||
{
|
|
||||||
if (pos_args_.size() <= ind)
|
|
||||||
{
|
|
||||||
std::ostringstream ostr;
|
|
||||||
ostr.precision(std::numeric_limits<long double>::max_digits10);
|
|
||||||
ostr << def_val;
|
|
||||||
return string_stream(ostr.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
return string_stream(pos_args_[ind]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline void parser::add_param(std::string const& name)
|
|
||||||
{
|
|
||||||
registeredParams_.insert(trim_leading_dashes(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
inline void parser::add_params(std::initializer_list<char const* const> init_list)
|
|
||||||
{
|
|
||||||
for (auto& name : init_list)
|
|
||||||
registeredParams_.insert(trim_leading_dashes(name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,194 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This 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 <fmt/format.h>
|
|
||||||
#include "eqemu_command_handler.h"
|
|
||||||
#include "terminal_color.hpp"
|
|
||||||
#include "../platform.h"
|
|
||||||
|
|
||||||
namespace EQEmuCommand {
|
|
||||||
|
|
||||||
std::map<std::string, void (*)(
|
|
||||||
int argc,
|
|
||||||
char **argv,
|
|
||||||
argh::parser &cmd,
|
|
||||||
std::string &description
|
|
||||||
)> function_map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param cmd
|
|
||||||
*/
|
|
||||||
void DisplayDebug(argh::parser &cmd)
|
|
||||||
{
|
|
||||||
if (cmd[{"-d", "--debug"}]) {
|
|
||||||
std::cout << "Positional args:\n";
|
|
||||||
for (auto &pos_arg : cmd.pos_args())
|
|
||||||
std::cout << '\t' << pos_arg << std::endl;
|
|
||||||
|
|
||||||
std::cout << "\nFlags:\n";
|
|
||||||
for (auto &flag : cmd.flags())
|
|
||||||
std::cout << '\t' << flag << std::endl;
|
|
||||||
|
|
||||||
std::cout << "\nParameters:\n";
|
|
||||||
for (auto ¶m : cmd.params())
|
|
||||||
std::cout << '\t' << param.first << " : " << param.second << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param arguments
|
|
||||||
* @param options
|
|
||||||
* @param cmd
|
|
||||||
* @param argc
|
|
||||||
* @param argv
|
|
||||||
*/
|
|
||||||
void ValidateCmdInput(
|
|
||||||
std::vector<std::string> &arguments,
|
|
||||||
std::vector<std::string> &options,
|
|
||||||
argh::parser &cmd,
|
|
||||||
int argc,
|
|
||||||
char **argv
|
|
||||||
)
|
|
||||||
{
|
|
||||||
bool arguments_filled = true;
|
|
||||||
|
|
||||||
int index = 2;
|
|
||||||
for (auto &arg : arguments) {
|
|
||||||
if (cmd(arg).str().empty() && cmd(index).str().empty()) {
|
|
||||||
arguments_filled = false;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!arguments_filled || argc == 2) {
|
|
||||||
std::string arguments_string;
|
|
||||||
for (auto &arg : arguments) {
|
|
||||||
arguments_string += " " + arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string options_string;
|
|
||||||
for (auto &opt : options) {
|
|
||||||
options_string += " " + opt + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::stringstream command_string;
|
|
||||||
|
|
||||||
command_string <<
|
|
||||||
termcolor::colorize <<
|
|
||||||
termcolor::yellow <<
|
|
||||||
"\nCommand" <<
|
|
||||||
termcolor::reset << "\n\n" <<
|
|
||||||
termcolor::green << argv[1] << arguments_string << termcolor::reset << "\n" <<
|
|
||||||
termcolor::yellow << (!options_string.empty() ? "\nOptions\n\n" : "") <<
|
|
||||||
termcolor::reset << termcolor::cyan << options_string << termcolor::reset;
|
|
||||||
|
|
||||||
std::cout << command_string.str() << std::endl;
|
|
||||||
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param in_function_map
|
|
||||||
* @param cmd
|
|
||||||
* @param argc
|
|
||||||
* @param argv
|
|
||||||
*/
|
|
||||||
void HandleMenu(
|
|
||||||
std::map<std::string, void (*)(
|
|
||||||
int argc,
|
|
||||||
char **argv,
|
|
||||||
argh::parser &cmd,
|
|
||||||
std::string &description
|
|
||||||
)> &in_function_map,
|
|
||||||
argh::parser &cmd,
|
|
||||||
int argc,
|
|
||||||
char **argv
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string description;
|
|
||||||
bool ran_command = false;
|
|
||||||
for (auto &it: in_function_map) {
|
|
||||||
if (it.first == argv[1]) {
|
|
||||||
(it.second)(argc, argv, cmd, description);
|
|
||||||
ran_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd[{"-h", "--help"}]) {
|
|
||||||
std::cout << std::endl;
|
|
||||||
std::cout <<
|
|
||||||
"> " <<
|
|
||||||
termcolor::yellow <<
|
|
||||||
"EQEmulator [" + GetPlatformName() + "] CLI Menu" <<
|
|
||||||
termcolor::reset
|
|
||||||
<< std::endl
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get max command length for padding length
|
|
||||||
*/
|
|
||||||
int max_command_length = 0;
|
|
||||||
|
|
||||||
for (auto &it: in_function_map) {
|
|
||||||
std::stringstream command;
|
|
||||||
command << termcolor::colorize << termcolor::yellow << it.first << termcolor::reset;
|
|
||||||
if (command.str().length() > max_command_length) {
|
|
||||||
max_command_length = command.str().length() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display command menu
|
|
||||||
*/
|
|
||||||
std::string command_section;
|
|
||||||
for (auto &it: in_function_map) {
|
|
||||||
description = "";
|
|
||||||
|
|
||||||
(it.second)(argc, argv, cmd, description);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print section header
|
|
||||||
*/
|
|
||||||
std::string command_prefix = it.first.substr(0, it.first.find(":"));
|
|
||||||
if (command_section != command_prefix) {
|
|
||||||
command_section = command_prefix;
|
|
||||||
std::cout << termcolor::reset << command_prefix << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print commands
|
|
||||||
*/
|
|
||||||
std::stringstream command;
|
|
||||||
command << termcolor::colorize << termcolor::yellow << it.first << termcolor::reset;
|
|
||||||
printf(" %-*s %s\n", max_command_length, command.str().c_str(), description.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
std::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ran_command) {
|
|
||||||
std::exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This 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_EQEMU_COMMAND_HANDLER_H
|
|
||||||
#define EQEMU_EQEMU_COMMAND_HANDLER_H
|
|
||||||
|
|
||||||
#include "argh.h"
|
|
||||||
|
|
||||||
namespace EQEmuCommand {
|
|
||||||
|
|
||||||
extern std::map<std::string, void (*)(
|
|
||||||
int argc,
|
|
||||||
char **argv,
|
|
||||||
argh::parser &cmd,
|
|
||||||
std::string &description
|
|
||||||
)> function_map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param arguments
|
|
||||||
* @param options
|
|
||||||
* @param cmd
|
|
||||||
* @param argc
|
|
||||||
* @param argv
|
|
||||||
*/
|
|
||||||
void ValidateCmdInput(
|
|
||||||
std::vector<std::string> &arguments,
|
|
||||||
std::vector<std::string> &options,
|
|
||||||
argh::parser &cmd,
|
|
||||||
int argc,
|
|
||||||
char **argv
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param cmd
|
|
||||||
*/
|
|
||||||
void DisplayDebug(argh::parser &cmd);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param in_function_map
|
|
||||||
* @param cmd
|
|
||||||
* @param argc
|
|
||||||
* @param argv
|
|
||||||
*/
|
|
||||||
void HandleMenu(
|
|
||||||
std::map<std::string, void (*)(
|
|
||||||
int argc,
|
|
||||||
char **argv,
|
|
||||||
argh::parser &cmd,
|
|
||||||
std::string &description
|
|
||||||
)> &in_function_map,
|
|
||||||
argh::parser &cmd,
|
|
||||||
int argc,
|
|
||||||
char **argv
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //EQEMU_EQEMU_COMMAND_HANDLER_H
|
|
||||||
@@ -1,557 +0,0 @@
|
|||||||
//!
|
|
||||||
//! termcolor
|
|
||||||
//! ~~~~~~~~~
|
|
||||||
//!
|
|
||||||
//! termcolor is a header-only c++ library for printing colored messages
|
|
||||||
//! to the terminal. Written just for fun with a help of the Force.
|
|
||||||
//!
|
|
||||||
//! :copyright: (c) 2013 by Ihor Kalnytskyi
|
|
||||||
//! :license: BSD, see LICENSE for details
|
|
||||||
//!
|
|
||||||
|
|
||||||
#ifndef TERMCOLOR_HPP_
|
|
||||||
#define TERMCOLOR_HPP_
|
|
||||||
|
|
||||||
// the following snippet of code detects the current OS and
|
|
||||||
// defines the appropriate macro that is used to wrap some
|
|
||||||
// platform specific things
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
|
||||||
# define TERMCOLOR_OS_WINDOWS
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
# define TERMCOLOR_OS_MACOS
|
|
||||||
#elif defined(__unix__) || defined(__unix)
|
|
||||||
# define TERMCOLOR_OS_LINUX
|
|
||||||
#else
|
|
||||||
# error unsupported platform
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// This headers provides the `isatty()`/`fileno()` functions,
|
|
||||||
// which are used for testing whether a standart stream refers
|
|
||||||
// to the terminal. As for Windows, we also need WinApi funcs
|
|
||||||
// for changing colors attributes of the terminal.
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
# include <unistd.h>
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
# include <io.h>
|
|
||||||
# include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace termcolor
|
|
||||||
{
|
|
||||||
// Forward declaration of the `_internal` namespace.
|
|
||||||
// All comments are below.
|
|
||||||
namespace _internal
|
|
||||||
{
|
|
||||||
// An index to be used to access a private storage of I/O streams. See
|
|
||||||
// colorize / nocolorize I/O manipulators for details.
|
|
||||||
static int colorize_index = std::ios_base::xalloc();
|
|
||||||
|
|
||||||
inline FILE* get_standard_stream(const std::ostream& stream);
|
|
||||||
inline bool is_colorized(std::ostream& stream);
|
|
||||||
inline bool is_atty(const std::ostream& stream);
|
|
||||||
|
|
||||||
#if defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
inline void win_change_attributes(std::ostream& stream, int foreground, int background=-1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& colorize(std::ostream& stream)
|
|
||||||
{
|
|
||||||
stream.iword(_internal::colorize_index) = 1L;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& nocolorize(std::ostream& stream)
|
|
||||||
{
|
|
||||||
stream.iword(_internal::colorize_index) = 0L;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& reset(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;00m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream, -1, -1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& bold(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;1m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& dark(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;2m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& underline(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;4m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& blink(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;5m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& reverse(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;7m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& concealed(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;8m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& grey(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;30m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream,
|
|
||||||
0 // grey (black)
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& red(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;31m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream,
|
|
||||||
FOREGROUND_RED
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& green(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;32m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream,
|
|
||||||
FOREGROUND_GREEN
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& yellow(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;33m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream,
|
|
||||||
FOREGROUND_GREEN | FOREGROUND_RED
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& blue(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;34m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream,
|
|
||||||
FOREGROUND_BLUE
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& magenta(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;35m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream,
|
|
||||||
FOREGROUND_BLUE | FOREGROUND_RED
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& cyan(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;36m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream,
|
|
||||||
FOREGROUND_BLUE | FOREGROUND_GREEN
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& white(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;37m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream,
|
|
||||||
FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& on_grey(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;40m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream, -1,
|
|
||||||
0 // grey (black)
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& on_red(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;41m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream, -1,
|
|
||||||
BACKGROUND_RED
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& on_green(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;42m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream, -1,
|
|
||||||
BACKGROUND_GREEN
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& on_yellow(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;43m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream, -1,
|
|
||||||
BACKGROUND_GREEN | BACKGROUND_RED
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& on_blue(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;44m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream, -1,
|
|
||||||
BACKGROUND_BLUE
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& on_magenta(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;45m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream, -1,
|
|
||||||
BACKGROUND_BLUE | BACKGROUND_RED
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& on_cyan(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;46m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream, -1,
|
|
||||||
BACKGROUND_GREEN | BACKGROUND_BLUE
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::ostream& on_white(std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (_internal::is_colorized(stream))
|
|
||||||
{
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
stream << "\e[1;47m";
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
_internal::win_change_attributes(stream, -1,
|
|
||||||
BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Since C++ hasn't a way to hide something in the header from
|
|
||||||
//! the outer access, I have to introduce this namespace which
|
|
||||||
//! is used for internal purpose and should't be access from
|
|
||||||
//! the user code.
|
|
||||||
namespace _internal
|
|
||||||
{
|
|
||||||
//! Since C++ hasn't a true way to extract stream handler
|
|
||||||
//! from the a given `std::ostream` object, I have to write
|
|
||||||
//! this kind of hack.
|
|
||||||
inline
|
|
||||||
FILE* get_standard_stream(const std::ostream& stream)
|
|
||||||
{
|
|
||||||
if (&stream == &std::cout)
|
|
||||||
return stdout;
|
|
||||||
else if ((&stream == &std::cerr) || (&stream == &std::clog))
|
|
||||||
return stderr;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Say whether a given stream should be colorized or not. It's always
|
|
||||||
// true for ATTY streams and may be true for streams marked with
|
|
||||||
// colorize flag.
|
|
||||||
inline
|
|
||||||
bool is_colorized(std::ostream& stream)
|
|
||||||
{
|
|
||||||
return is_atty(stream) || static_cast<bool>(stream.iword(colorize_index));
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Test whether a given `std::ostream` object refers to
|
|
||||||
//! a terminal.
|
|
||||||
inline
|
|
||||||
bool is_atty(const std::ostream& stream)
|
|
||||||
{
|
|
||||||
FILE* std_stream = get_standard_stream(stream);
|
|
||||||
|
|
||||||
// Unfortunately, fileno() ends with segmentation fault
|
|
||||||
// if invalid file descriptor is passed. So we need to
|
|
||||||
// handle this case gracefully and assume it's not a tty
|
|
||||||
// if standard stream is not detected, and 0 is returned.
|
|
||||||
if (!std_stream)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX)
|
|
||||||
return ::isatty(fileno(std_stream));
|
|
||||||
#elif defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
return ::_isatty(_fileno(std_stream));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(TERMCOLOR_OS_WINDOWS)
|
|
||||||
//! Change Windows Terminal colors attribute. If some
|
|
||||||
//! parameter is `-1` then attribute won't changed.
|
|
||||||
inline void win_change_attributes(std::ostream& stream, int foreground, int background)
|
|
||||||
{
|
|
||||||
// yeah, i know.. it's ugly, it's windows.
|
|
||||||
static WORD defaultAttributes = 0;
|
|
||||||
|
|
||||||
// Windows doesn't have ANSI escape sequences and so we use special
|
|
||||||
// API to change Terminal output color. That means we can't
|
|
||||||
// manipulate colors by means of "std::stringstream" and hence
|
|
||||||
// should do nothing in this case.
|
|
||||||
if (!_internal::is_atty(stream))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// get terminal handle
|
|
||||||
HANDLE hTerminal = INVALID_HANDLE_VALUE;
|
|
||||||
if (&stream == &std::cout)
|
|
||||||
hTerminal = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
else if (&stream == &std::cerr)
|
|
||||||
hTerminal = GetStdHandle(STD_ERROR_HANDLE);
|
|
||||||
|
|
||||||
// save default terminal attributes if it unsaved
|
|
||||||
if (!defaultAttributes)
|
|
||||||
{
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
|
||||||
if (!GetConsoleScreenBufferInfo(hTerminal, &info))
|
|
||||||
return;
|
|
||||||
defaultAttributes = info.wAttributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// restore all default settings
|
|
||||||
if (foreground == -1 && background == -1)
|
|
||||||
{
|
|
||||||
SetConsoleTextAttribute(hTerminal, defaultAttributes);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get current settings
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
|
||||||
if (!GetConsoleScreenBufferInfo(hTerminal, &info))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (foreground != -1)
|
|
||||||
{
|
|
||||||
info.wAttributes &= ~(info.wAttributes & 0x0F);
|
|
||||||
info.wAttributes |= static_cast<WORD>(foreground);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (background != -1)
|
|
||||||
{
|
|
||||||
info.wAttributes &= ~(info.wAttributes & 0xF0);
|
|
||||||
info.wAttributes |= static_cast<WORD>(background);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetConsoleTextAttribute(hTerminal, info.wAttributes);
|
|
||||||
}
|
|
||||||
#endif // TERMCOLOR_OS_WINDOWS
|
|
||||||
|
|
||||||
} // namespace _internal
|
|
||||||
|
|
||||||
} // namespace termcolor
|
|
||||||
|
|
||||||
|
|
||||||
#undef TERMCOLOR_OS_WINDOWS
|
|
||||||
#undef TERMCOLOR_OS_MACOS
|
|
||||||
#undef TERMCOLOR_OS_LINUX
|
|
||||||
|
|
||||||
#endif // TERMCOLOR_HPP_
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
#ifndef CLIENTVERSIONS_H
|
||||||
|
#define CLIENTVERSIONS_H
|
||||||
|
|
||||||
|
static const uint32 BIT_Client62 = 1;
|
||||||
|
static const uint32 BIT_Titanium = 2;
|
||||||
|
static const uint32 BIT_SoF = 4;
|
||||||
|
static const uint32 BIT_SoD = 8;
|
||||||
|
static const uint32 BIT_Underfoot = 16;
|
||||||
|
static const uint32 BIT_RoF = 32;
|
||||||
|
static const uint32 BIT_RoF2 = 64;
|
||||||
|
|
||||||
|
static const uint32 BIT_TitaniumAndEarlier = 0x00000003;
|
||||||
|
static const uint32 BIT_SoFAndLater = 0xFFFFFFFC;
|
||||||
|
static const uint32 BIT_SoDAndLater = 0xFFFFFFF8;
|
||||||
|
static const uint32 BIT_UnderfootAndLater = 0xFFFFFFF0;
|
||||||
|
static const uint32 BIT_RoFAndLater = 0xFFFFFFE0;
|
||||||
|
static const uint32 BIT_RoF2AndLater = 0xFFFFFFC0;
|
||||||
|
static const uint32 BIT_AllClients = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
EQClientUnknown = 0,
|
||||||
|
EQClient62, // Build: 'Aug 4 2005 15:40:59'
|
||||||
|
EQClientTitanium, // Build: 'Oct 31 2005 10:33:37'
|
||||||
|
EQClientSoF, // Build: 'Sep 7 2007 09:11:49'
|
||||||
|
EQClientSoD, // Build: 'Dec 19 2008 15:22:49'
|
||||||
|
EQClientUnderfoot, // Build: 'Jun 8 2010 16:44:32'
|
||||||
|
EQClientRoF, // Build: 'Dec 10 2012 17:35:44'
|
||||||
|
EQClientRoF2, // Build: 'May 10 2013 23:30:08'
|
||||||
|
|
||||||
|
_EQClientCount, // place new clients before this point (preferably, in release/attribute order)
|
||||||
|
|
||||||
|
// Values below are not implemented, as yet...
|
||||||
|
|
||||||
|
EmuNPC = _EQClientCount,
|
||||||
|
EmuMerc,
|
||||||
|
EmuBot,
|
||||||
|
EmuPet,
|
||||||
|
|
||||||
|
_EmuClientCount // array size for EQLimits
|
||||||
|
} EQClientVersion;
|
||||||
|
|
||||||
|
static const char* EQClientVersionName(EQClientVersion version)
|
||||||
|
{
|
||||||
|
switch (version)
|
||||||
|
{
|
||||||
|
case EQClientUnknown:
|
||||||
|
return "EQClientUnknown";
|
||||||
|
case EQClient62:
|
||||||
|
return "EQClient62";
|
||||||
|
case EQClientTitanium:
|
||||||
|
return "EQClientTitanium";
|
||||||
|
case EQClientSoF:
|
||||||
|
return "EQClientSoF";
|
||||||
|
case EQClientSoD:
|
||||||
|
return "EQClientSoD";
|
||||||
|
case EQClientUnderfoot:
|
||||||
|
return "EQClientUnderfoot";
|
||||||
|
case EQClientRoF:
|
||||||
|
return "EQClientRoF";
|
||||||
|
case EQClientRoF2:
|
||||||
|
return "EQClientRoF2";
|
||||||
|
case EmuNPC:
|
||||||
|
return "EmuNPC";
|
||||||
|
case EmuMerc:
|
||||||
|
return "EmuMerc";
|
||||||
|
case EmuBot:
|
||||||
|
return "EmuBot";
|
||||||
|
case EmuPet:
|
||||||
|
return "EmuPet";
|
||||||
|
default:
|
||||||
|
return "ERROR: Invalid EQClientVersion";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CLIENTVERSIONS_H */
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
#include "condition.h"
|
#include "condition.h"
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
|
|||||||
+1
-2
@@ -18,8 +18,7 @@
|
|||||||
#ifndef __CONDITION_H
|
#ifndef __CONDITION_H
|
||||||
#define __CONDITION_H
|
#define __CONDITION_H
|
||||||
|
|
||||||
#include "global_define.h"
|
#include "debug.h"
|
||||||
#include "mutex.h"
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+24
-78
@@ -1,5 +1,4 @@
|
|||||||
#include "global_define.h"
|
#include "debug.h"
|
||||||
#include "eqemu_logsys.h"
|
|
||||||
#include "crash.h"
|
#include "crash.h"
|
||||||
|
|
||||||
#if defined(_WINDOWS) && defined(CRASH_LOGGING)
|
#if defined(_WINDOWS) && defined(CRASH_LOGGING)
|
||||||
@@ -25,7 +24,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(Logs::General, Logs::Crash, buffer);
|
LogFile->write(EQEMuLog::Crash, buffer);
|
||||||
StackWalker::OnOutput(szText);
|
StackWalker::OnOutput(szText);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -35,67 +34,67 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
|||||||
switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
|
switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
|
||||||
{
|
{
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
case EXCEPTION_ACCESS_VIOLATION:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_ACCESS_VIOLATION");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ACCESS_VIOLATION");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_BREAKPOINT:
|
case EXCEPTION_BREAKPOINT:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_BREAKPOINT");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_BREAKPOINT");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
case EXCEPTION_FLT_INEXACT_RESULT:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
case EXCEPTION_FLT_INVALID_OPERATION:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_FLT_OVERFLOW:
|
case EXCEPTION_FLT_OVERFLOW:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_OVERFLOW");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_OVERFLOW");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_FLT_STACK_CHECK:
|
case EXCEPTION_FLT_STACK_CHECK:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_STACK_CHECK");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_STACK_CHECK");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_FLT_UNDERFLOW:
|
case EXCEPTION_FLT_UNDERFLOW:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_UNDERFLOW");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_UNDERFLOW");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_IN_PAGE_ERROR:
|
case EXCEPTION_IN_PAGE_ERROR:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_IN_PAGE_ERROR");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_IN_PAGE_ERROR");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_INT_OVERFLOW:
|
case EXCEPTION_INT_OVERFLOW:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_INT_OVERFLOW");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_OVERFLOW");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_INVALID_DISPOSITION:
|
case EXCEPTION_INVALID_DISPOSITION:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_INVALID_DISPOSITION");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INVALID_DISPOSITION");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
|
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_PRIV_INSTRUCTION:
|
case EXCEPTION_PRIV_INSTRUCTION:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_PRIV_INSTRUCTION");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_PRIV_INSTRUCTION");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_SINGLE_STEP:
|
case EXCEPTION_SINGLE_STEP:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_SINGLE_STEP");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_SINGLE_STEP");
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_STACK_OVERFLOW:
|
case EXCEPTION_STACK_OVERFLOW:
|
||||||
Log(Logs::General, Logs::Crash, "EXCEPTION_STACK_OVERFLOW");
|
LogFile->write(EQEMuLog::Crash, "EXCEPTION_STACK_OVERFLOW");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log(Logs::General, Logs::Crash, "Unknown Exception");
|
LogFile->write(EQEMuLog::Crash, "Unknown Exception");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,60 +110,7 @@ void set_exception_handler() {
|
|||||||
SetUnhandledExceptionFilter(windows_exception_handler);
|
SetUnhandledExceptionFilter(windows_exception_handler);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/fcntl.h>
|
|
||||||
|
|
||||||
void print_trace()
|
|
||||||
{
|
|
||||||
auto uid = geteuid();
|
|
||||||
|
|
||||||
std::string temp_output_file = "/tmp/dump-output";
|
|
||||||
|
|
||||||
char pid_buf[30];
|
|
||||||
sprintf(pid_buf, "%d", getpid());
|
|
||||||
char name_buf[512];
|
|
||||||
name_buf[readlink("/proc/self/exe", name_buf, 511)] = 0;
|
|
||||||
int child_pid = fork();
|
|
||||||
if (!child_pid) {
|
|
||||||
int fd = open(temp_output_file.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
|
||||||
|
|
||||||
dup2(fd, 1); // redirect output to stderr
|
|
||||||
fprintf(stdout, "stack trace for %s pid=%s\n", name_buf, pid_buf);
|
|
||||||
if (uid == 0) {
|
|
||||||
execlp("gdb", "gdb", "--batch", "-n", "-ex", "thread", "-ex", "bt", name_buf, pid_buf, NULL);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
execlp("sudo", "gdb", "gdb", "--batch", "-n", "-ex", "thread", "-ex", "bt", name_buf, pid_buf, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
abort(); /* If gdb failed to start */
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
waitpid(child_pid, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ifstream input(temp_output_file);
|
|
||||||
for (std::string line; getline(input, line);) {
|
|
||||||
LogCrash("{}", line);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::remove(temp_output_file.c_str());
|
|
||||||
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// crash is off or an unhandled platform
|
// crash is off or an unhandled platform
|
||||||
void set_exception_handler()
|
void set_exception_handler() {
|
||||||
{
|
|
||||||
signal(SIGABRT, reinterpret_cast<void (*)(int)>(print_trace));
|
|
||||||
signal(SIGFPE, reinterpret_cast<void (*)(int)>(print_trace));
|
|
||||||
signal(SIGFPE, reinterpret_cast<void (*)(int)>(print_trace));
|
|
||||||
signal(SIGSEGV, reinterpret_cast<void (*)(int)>(print_trace));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+39
-48
@@ -1,57 +1,48 @@
|
|||||||
/**
|
/* EQEMu: Everquest Server Emulator
|
||||||
* EQEmulator: Everquest Server Emulator
|
Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net)
|
||||||
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This 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
|
This 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_DATA_VERIFICATION_H
|
||||||
|
#define COMMON_DATA_VERIFICATION_H
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
namespace EQEmu {
|
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>
|
template <typename T>
|
||||||
T ClampLower(const T &value, const T &lower)
|
T Clamp(const T& value, const T& lower, const T& upper) {
|
||||||
{
|
return std::max(lower, std::min(value, upper));
|
||||||
return std::max(lower, value);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
T ClampUpper(const T &value, const T &upper)
|
T ClampLower(const T& value, const T& lower) {
|
||||||
{
|
return std::max(lower, value);
|
||||||
return std::min(value, upper);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
bool ValueWithin(const T &value, const T &lower, const T &upper)
|
T ClampUpper(const T& value, const T& upper) {
|
||||||
{
|
return std::min(value, upper);
|
||||||
return value >= lower && value <= upper;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T1, typename T2, typename T3>
|
template <typename T>
|
||||||
bool ValueWithin(const T1 &value, const T2 &lower, const T3 &upper)
|
bool ValueWithin(const T& value, const T& lower, const T& upper) {
|
||||||
{
|
return value >= lower && value <= upper;
|
||||||
return value >= (T1) lower && value <= (T1) upper;
|
}
|
||||||
}
|
|
||||||
} /*EQEmu*/
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
+2166
-828
File diff suppressed because it is too large
Load Diff
+145
-161
@@ -1,5 +1,5 @@
|
|||||||
/* EQEMu: Everquest Server Emulator
|
/* EQEMu: Everquest Server Emulator
|
||||||
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
|
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -21,15 +21,11 @@
|
|||||||
#define AUTHENTICATION_TIMEOUT 60
|
#define AUTHENTICATION_TIMEOUT 60
|
||||||
#define INVALID_ID 0xFFFFFFFF
|
#define INVALID_ID 0xFFFFFFFF
|
||||||
|
|
||||||
#include "global_define.h"
|
#include "debug.h"
|
||||||
#include "eqemu_logsys.h"
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "dbcore.h"
|
#include "dbcore.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
#include "eq_packet_structs.h"
|
#include "eq_packet_structs.h"
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -37,13 +33,22 @@
|
|||||||
//atoi is not uint32 or uint32 safe!!!!
|
//atoi is not uint32 or uint32 safe!!!!
|
||||||
#define atoul(str) strtoul(str, nullptr, 10)
|
#define atoul(str) strtoul(str, nullptr, 10)
|
||||||
|
|
||||||
class MySQLRequestResult;
|
//class Spawn;
|
||||||
|
class Corpse;
|
||||||
|
class Spawn2;
|
||||||
|
class NPC;
|
||||||
|
class SpawnGroupList;
|
||||||
|
class Petition;
|
||||||
class Client;
|
class Client;
|
||||||
|
class Merc;
|
||||||
namespace EQEmu
|
struct Combine_Struct;
|
||||||
{
|
//struct Faction;
|
||||||
class InventoryProfile;
|
//struct FactionMods;
|
||||||
}
|
//struct FactionValue;
|
||||||
|
struct ZonePoint;
|
||||||
|
struct NPCType;
|
||||||
|
class Inventory;
|
||||||
|
class ItemInst;
|
||||||
|
|
||||||
struct EventLogDetails_Struct {
|
struct EventLogDetails_Struct {
|
||||||
uint32 id;
|
uint32 id;
|
||||||
@@ -58,238 +63,217 @@ struct EventLogDetails_Struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct CharacterEventLog_Struct {
|
struct CharacterEventLog_Struct {
|
||||||
uint32 count;
|
uint32 count;
|
||||||
uint8 eventid;
|
uint8 eventid;
|
||||||
EventLogDetails_Struct eld[255];
|
EventLogDetails_Struct eld[255];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Added By Hogie
|
||||||
|
// INSERT into variables (varname,value) values('decaytime [minlevel] [maxlevel]','[number of seconds]');
|
||||||
|
// IE: decaytime 1 54 = Levels 1 through 54
|
||||||
|
// decaytime 55 100 = Levels 55 through 100
|
||||||
|
// It will always put the LAST time for the level (I think) from the Database
|
||||||
struct npcDecayTimes_Struct {
|
struct npcDecayTimes_Struct {
|
||||||
uint16 minlvl;
|
uint16 minlvl;
|
||||||
uint16 maxlvl;
|
uint16 maxlvl;
|
||||||
uint32 seconds;
|
uint32 seconds;
|
||||||
};
|
};
|
||||||
|
// Added By Hogie -- End
|
||||||
|
|
||||||
struct VarCache_Struct {
|
struct VarCache_Struct {
|
||||||
std::map<std::string, std::string> m_cache;
|
char varname[26]; // varname is char(25) in database
|
||||||
uint32 last_update;
|
char value[0];
|
||||||
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);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PlayerProfile_Struct;
|
||||||
|
struct GuildRankLevel_Struct;
|
||||||
|
struct GuildRanks_Struct;
|
||||||
|
struct ExtendedProfile_Struct;
|
||||||
|
struct GuildMember_Struct;
|
||||||
class PTimerList;
|
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
|
|
||||||
|
|
||||||
#define SQL(...) #__VA_ARGS__
|
|
||||||
|
|
||||||
class Database : public DBcore {
|
class Database : public DBcore {
|
||||||
public:
|
public:
|
||||||
Database();
|
Database();
|
||||||
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||||
bool Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port);
|
bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||||
~Database();
|
~Database();
|
||||||
|
bool ThrowDBError(std::string ErrorMessage, std::string query_title, std::string query);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* General Character Related Stuff
|
||||||
|
*/
|
||||||
|
|
||||||
/* Character Creation */
|
/* Character Creation */
|
||||||
|
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
|
||||||
|
|
||||||
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* character_name);
|
|
||||||
bool MoveCharacterToZone(const char* charname, const char* zonename);
|
bool MoveCharacterToZone(const char* charname, const char* zonename);
|
||||||
bool MoveCharacterToZone(const char* charname, const char* zonename,uint32 zoneid);
|
bool MoveCharacterToZone(const char* charname, const char* zonename,uint32 zoneid);
|
||||||
bool MoveCharacterToZone(uint32 iCharID, const char* iZonename);
|
bool MoveCharacterToZone(uint32 iCharID, const char* iZonename);
|
||||||
bool ReserveName(uint32 account_id, char* name);
|
bool UpdateName(const char* oldname, const char* newname);
|
||||||
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
|
|
||||||
bool SetHackerFlag(const char* accountname, const char* charactername, const char* hacked);
|
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 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 AddToNameFilter(const char* name);
|
||||||
bool UpdateName(const char* oldname, const char* newname);
|
bool ReserveName(uint32 account_id, 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 StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inventory* inv);
|
||||||
|
bool DeleteCharacter(char* name);
|
||||||
|
|
||||||
/* General Information Queries */
|
/*
|
||||||
|
* General Information Getting 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 CheckNameFilter(const char* name, bool surname = false);
|
||||||
bool CheckUsedName(const char* name);
|
bool CheckUsedName(const char* name);
|
||||||
|
|
||||||
uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0);
|
uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0);
|
||||||
uint32 GetAccountIDByChar(uint32 char_id);
|
uint32 GetAccountIDByChar(uint32 char_id);
|
||||||
uint32 GetAccountIDByName(const char* accname, const char *loginserver, int16* status = 0, uint32* lsid = 0);
|
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);
|
uint32 GetGuildIDByCharID(uint32 char_id);
|
||||||
uint32 GetGroupIDByCharID(uint32 char_id);
|
|
||||||
uint32 GetRaidIDByCharID(uint32 char_id);
|
|
||||||
|
|
||||||
void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0);
|
void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0);
|
||||||
void GetCharName(uint32 char_id, char* name);
|
void GetCharName(uint32 char_id, char* name);
|
||||||
const char *GetCharNameByID(uint32 char_id);
|
uint32 GetCharacterInfo(const char* iName, uint32* oAccID = 0, uint32* oZoneID = 0, uint32* oInstanceID = 0,float* oX = 0, float* oY = 0, float* oZ = 0);
|
||||||
const char *GetNPCNameByID(uint32 npc_id);
|
uint32 GetCharacterID(const char *name);
|
||||||
|
bool CheckBannedIPs(const char* loginIP); //Lieka Edit: Check incomming connection against banned IP table.
|
||||||
|
bool AddBannedIP(char* bannedIP, const char* notes); //Lieka Edit: Add IP address to the Banned_IPs table.
|
||||||
|
bool CheckGMIPs(const char* loginIP, uint32 account_id);
|
||||||
|
bool AddGMIP(char* ip_address, char* name);
|
||||||
void LoginIP(uint32 AccountID, const char* LoginIP);
|
void LoginIP(uint32 AccountID, const char* LoginIP);
|
||||||
|
|
||||||
/* Instancing */
|
/*
|
||||||
|
* Instancing Stuff
|
||||||
bool AddClientToInstance(uint16 instance_id, uint32 char_id);
|
*/
|
||||||
|
bool VerifyZoneInstance(uint32 zone_id, uint16 instance_id);
|
||||||
|
bool VerifyInstanceAlive(uint16 instance_id, uint32 char_id);
|
||||||
bool CharacterInInstanceGroup(uint16 instance_id, uint32 char_id);
|
bool CharacterInInstanceGroup(uint16 instance_id, uint32 char_id);
|
||||||
bool CheckInstanceExists(uint16 instance_id);
|
void DeleteInstance(uint16 instance_id);
|
||||||
bool CheckInstanceExpired(uint16 instance_id);
|
bool CheckInstanceExpired(uint16 instance_id);
|
||||||
bool CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration);
|
uint32 ZoneIDFromInstanceID(uint16 instance_id);
|
||||||
|
uint32 VersionFromInstanceID(uint16 instance_id);
|
||||||
|
uint32 GetTimeRemainingInstance(uint16 instance_id, bool &is_perma);
|
||||||
bool GetUnusedInstanceID(uint16 &instance_id);
|
bool GetUnusedInstanceID(uint16 &instance_id);
|
||||||
bool GlobalInstance(uint16 instance_id);
|
bool CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration);
|
||||||
|
void PurgeExpiredInstances();
|
||||||
|
bool AddClientToInstance(uint16 instance_id, uint32 char_id);
|
||||||
bool RemoveClientFromInstance(uint16 instance_id, uint32 char_id);
|
bool RemoveClientFromInstance(uint16 instance_id, uint32 char_id);
|
||||||
bool RemoveClientsFromInstance(uint16 instance_id);
|
bool RemoveClientsFromInstance(uint16 instance_id);
|
||||||
bool VerifyInstanceAlive(uint16 instance_id, uint32 char_id);
|
bool CheckInstanceExists(uint16 instance_id);
|
||||||
bool VerifyZoneInstance(uint32 zone_id, uint16 instance_id);
|
void BuryCorpsesInInstance(uint16 instance_id);
|
||||||
|
uint16 GetInstanceVersion(uint16 instance_id);
|
||||||
uint16 GetInstanceID(const char* zone, uint32 charid, int16 version);
|
uint16 GetInstanceID(const char* zone, uint32 charid, int16 version);
|
||||||
uint16 GetInstanceID(uint32 zone, uint32 charid, int16 version);
|
uint16 GetInstanceID(uint32 zone, uint32 charid, int16 version);
|
||||||
uint16 GetInstanceVersion(uint16 instance_id);
|
void GetCharactersInInstance(uint16 instance_id, std::list<uint32> &charid_list);
|
||||||
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 AssignGroupToInstance(uint32 gid, uint32 instance_id);
|
||||||
void AssignRaidToInstance(uint32 rid, 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 FlagInstanceByGroupLeader(uint32 zone, int16 version, uint32 charid, uint32 gid);
|
||||||
void FlagInstanceByRaidLeader(uint32 zone, int16 version, uint32 charid, uint32 rid);
|
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);
|
void SetInstanceDuration(uint16 instance_id, uint32 new_duration);
|
||||||
|
bool GlobalInstance(uint16 instance_id);
|
||||||
|
|
||||||
/* Adventure related. */
|
/*
|
||||||
|
* Adventure related.
|
||||||
|
*/
|
||||||
void UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win);
|
void UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win);
|
||||||
bool GetAdventureStats(uint32 char_id, AdventureStats_Struct *as);
|
bool GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w, uint32 &tak_w,
|
||||||
|
uint32 &guk_l, uint32 &mir_l, uint32 &mmc_l, uint32 &ruj_l, uint32 &tak_l);
|
||||||
/* Account Related */
|
|
||||||
|
|
||||||
bool DeleteAccount(const char *name, const char* loginserver);
|
|
||||||
bool GetLiveChar(uint32 account_id, char* cname);
|
|
||||||
bool SetAccountStatus(const char* name, int16 status);
|
|
||||||
bool SetAccountStatus(const std::string& account_name, int16 status);
|
|
||||||
bool SetLocalPassword(uint32 accid, const char* password);
|
|
||||||
bool UpdateLiveChar(char* charname, uint32 account_id);
|
|
||||||
|
|
||||||
int16 CheckStatus(uint32 account_id);
|
|
||||||
|
|
||||||
uint32 CheckLogin(const char* name, const char* password, const char *loginserver, int16* oStatus = 0);
|
|
||||||
uint32 CreateAccount(const char* name, const char* password, int16 status, const char* loginserver, uint32 lsaccount_id);
|
|
||||||
uint32 GetAccountIDFromLSID(const std::string& in_loginserver_id, uint32 in_loginserver_account_id, char* in_account_name = 0, int16* in_status = 0);
|
|
||||||
uint8 GetAgreementFlag(uint32 acctid);
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Account Related
|
||||||
|
*/
|
||||||
|
uint32 GetMiniLoginAccount(char* ip);
|
||||||
void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus);
|
void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus);
|
||||||
|
uint32 CheckLogin(const char* name, const char* password, int16* oStatus = 0);
|
||||||
|
int16 CheckStatus(uint32 account_id);
|
||||||
|
uint32 CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id = 0);
|
||||||
|
bool DeleteAccount(const char* name);
|
||||||
|
bool SetAccountStatus(const char* name, int16 status);
|
||||||
|
bool SetLocalPassword(uint32 accid, const char* password);
|
||||||
|
uint32 GetAccountIDFromLSID(uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0);
|
||||||
|
bool UpdateLiveChar(char* charname,uint32 lsaccount_id);
|
||||||
|
bool GetLiveChar(uint32 account_id, char* cname);
|
||||||
|
uint8 GetAgreementFlag(uint32 acctid);
|
||||||
void SetAgreementFlag(uint32 acctid);
|
void SetAgreementFlag(uint32 acctid);
|
||||||
|
|
||||||
int GetIPExemption(std::string account_ip);
|
/*
|
||||||
|
* Groups
|
||||||
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);
|
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 SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ismerc = false);
|
||||||
|
void ClearGroup(uint32 gid = 0);
|
||||||
|
char* GetGroupLeaderForLogin(const char* name,char* leaderbuf);
|
||||||
|
|
||||||
void SetGroupLeaderName(uint32 gid, const char* name);
|
void SetGroupLeaderName(uint32 gid, const char* name);
|
||||||
|
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr,
|
||||||
|
GroupLeadershipAA_Struct* GLAA = nullptr);
|
||||||
|
void ClearGroupLeader(uint32 gid = 0);
|
||||||
|
|
||||||
|
|
||||||
/* Raids */
|
/*
|
||||||
|
* Raids
|
||||||
const char *GetRaidLeaderName(uint32 rid);
|
*/
|
||||||
|
|
||||||
uint32 GetRaidID(const char* name);
|
|
||||||
|
|
||||||
void ClearRaid(uint32 rid = 0);
|
void ClearRaid(uint32 rid = 0);
|
||||||
void ClearRaidDetails(uint32 rid = 0);
|
void ClearRaidDetails(uint32 rid = 0);
|
||||||
void ClearRaidLeader(uint32 gid = 0xFFFFFFFF, uint32 rid = 0);
|
uint32 GetRaidID(const char* name);
|
||||||
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);
|
const char *GetRaidLeaderName(uint32 rid);
|
||||||
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();
|
bool CheckDatabaseConversions();
|
||||||
|
|
||||||
/* Database Conversions 'database_conversions.cpp' */
|
/*
|
||||||
|
* Database Variables
|
||||||
bool CheckDatabaseConversions();
|
*/
|
||||||
bool CheckDatabaseConvertCorpseDeblob();
|
bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len);
|
||||||
bool CheckDatabaseConvertPPDeblob();
|
bool SetVariable(const char* varname, const char* varvalue);
|
||||||
|
|
||||||
/* Database Variables */
|
|
||||||
|
|
||||||
bool GetVariable(std::string varname, std::string &varvalue);
|
|
||||||
bool SetVariable(const std::string varname, const std::string &varvalue);
|
|
||||||
bool LoadVariables();
|
bool LoadVariables();
|
||||||
|
uint32 LoadVariables_MQ(char** query);
|
||||||
|
bool LoadVariables_result(MySQLRequestResult results);
|
||||||
|
|
||||||
/* General Queries */
|
/*
|
||||||
|
* 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();
|
bool LoadZoneNames();
|
||||||
|
bool GetZoneLongName(const char* short_name, char** long_name, char* file_name = 0, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, uint32* graveyard_id = 0, uint32* maxclients = 0);
|
||||||
const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false);
|
bool GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid = 0, float* graveyard_x = 0, float* graveyard_y = 0, float* graveyard_z = 0, float* graveyard_heading = 0);
|
||||||
|
|
||||||
uint32 GetZoneGraveyardID(uint32 zone_id, uint32 version);
|
uint32 GetZoneGraveyardID(uint32 zone_id, uint32 version);
|
||||||
uint32 GetZoneID(const char* zonename);
|
uint32 GetZoneID(const char* zonename);
|
||||||
|
|
||||||
uint8 GetPEQZone(uint32 zoneID, uint32 version);
|
uint8 GetPEQZone(uint32 zoneID, uint32 version);
|
||||||
uint8 GetRaceSkill(uint8 skillid, uint8 in_race);
|
const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false);
|
||||||
uint8 GetServerType();
|
uint8 GetServerType();
|
||||||
|
bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr);
|
||||||
|
bool GetSafePoints(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); }
|
||||||
uint8 GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level);
|
uint8 GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level);
|
||||||
|
uint8 GetRaceSkill(uint8 skillid, uint8 in_race);
|
||||||
void AddReport(std::string who, std::string against, std::string lines);
|
bool LoadPTimers(uint32 charid, PTimerList &into);
|
||||||
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 ClearPTimers(uint32 charid);
|
||||||
void SetFirstLogon(uint32 CharID, uint8 firstlogon);
|
void ClearMerchantTemp();
|
||||||
void SetLFG(uint32 CharID, bool LFG);
|
|
||||||
void SetLFP(uint32 CharID, bool LFP);
|
void SetLFP(uint32 CharID, bool LFP);
|
||||||
|
void SetLFG(uint32 CharID, bool LFG);
|
||||||
|
void SetFirstLogon(uint32 CharID, uint8 firstlogon);
|
||||||
void SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon);
|
void SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon);
|
||||||
|
void AddReport(std::string who, std::string against, std::string lines);
|
||||||
int CountInvSnapshots();
|
|
||||||
void ClearInvSnapshots(bool from_now = false);
|
|
||||||
|
|
||||||
/* EQEmuLogSys */
|
|
||||||
void LoadLogSettings(EQEmuLogSys::LogSettings* log_settings);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void DBInitVars();
|
||||||
|
|
||||||
std::map<uint32,std::string> zonename_array;
|
std::map<uint32,std::string> zonename_array;
|
||||||
|
|
||||||
Mutex Mvarcache;
|
Mutex Mvarcache;
|
||||||
VarCache_Struct varcache;
|
uint32 varcache_max;
|
||||||
|
VarCache_Struct** varcache_array;
|
||||||
|
uint32 varcache_lastupdate;
|
||||||
|
|
||||||
/* Groups, utility methods. */
|
|
||||||
|
/*
|
||||||
|
* Groups, utility methods.
|
||||||
|
*/
|
||||||
void ClearAllGroupLeaders();
|
void ClearAllGroupLeaders();
|
||||||
void ClearAllGroups();
|
void ClearAllGroups();
|
||||||
|
|
||||||
/* Raid, utility methods. */
|
|
||||||
|
/*
|
||||||
|
* Raid, utility methods.
|
||||||
|
*/
|
||||||
void ClearAllRaids();
|
void ClearAllRaids();
|
||||||
void ClearAllRaidDetails();
|
void ClearAllRaidDetails();
|
||||||
void ClearAllRaidLeaders();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,569 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This 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 <string>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <iterator>
|
|
||||||
#include "database_dump_service.h"
|
|
||||||
#include "../eqemu_logsys.h"
|
|
||||||
#include "../string_util.h"
|
|
||||||
#include "../eqemu_config.h"
|
|
||||||
#include "../database_schema.h"
|
|
||||||
#include "../file_util.h"
|
|
||||||
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
#if _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DATABASE_DUMP_PATH "backups/"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param cmd
|
|
||||||
* @param return_result
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::execute(const std::string &cmd, bool return_result = true)
|
|
||||||
{
|
|
||||||
const char *file_name = "db-exec-result.txt";
|
|
||||||
|
|
||||||
if (return_result) {
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
std::system((cmd + " > " + file_name + " 2>&1").c_str());
|
|
||||||
#else
|
|
||||||
std::system((cmd + " > " + file_name).c_str());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
std::system((cmd).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string result;
|
|
||||||
|
|
||||||
if (return_result) {
|
|
||||||
std::ifstream file(file_name);
|
|
||||||
result = {std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
|
|
||||||
std::remove(file_name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
bool DatabaseDumpService::IsMySQLInstalled()
|
|
||||||
{
|
|
||||||
std::string version_output = GetMySQLVersion();
|
|
||||||
|
|
||||||
return version_output.find("mysql") != std::string::npos && version_output.find("Ver") != std::string::npos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Linux
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
bool DatabaseDumpService::IsTarAvailable()
|
|
||||||
{
|
|
||||||
std::string version_output = execute("tar --version");
|
|
||||||
|
|
||||||
return version_output.find("GNU tar") != std::string::npos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Windows
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
bool DatabaseDumpService::Is7ZipAvailable()
|
|
||||||
{
|
|
||||||
std::string version_output = execute("7z --help");
|
|
||||||
|
|
||||||
return version_output.find("7-Zip") != std::string::npos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool DatabaseDumpService::HasCompressionBinary()
|
|
||||||
{
|
|
||||||
return IsTarAvailable() || Is7ZipAvailable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetMySQLVersion()
|
|
||||||
{
|
|
||||||
std::string version_output = execute("mysql --version");
|
|
||||||
|
|
||||||
return trim(version_output);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetBaseMySQLDumpCommand()
|
|
||||||
{
|
|
||||||
auto config = EQEmuConfig::get();
|
|
||||||
|
|
||||||
return fmt::format(
|
|
||||||
"mysqldump -u {} -p{} -h {} {}",
|
|
||||||
config->DatabaseUsername,
|
|
||||||
config->DatabasePassword,
|
|
||||||
config->DatabaseHost,
|
|
||||||
config->DatabaseDB
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetPlayerTablesList()
|
|
||||||
{
|
|
||||||
std::string tables_list;
|
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetPlayerTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim(tables_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetLoginTableList()
|
|
||||||
{
|
|
||||||
std::string tables_list;
|
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetLoginTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim(tables_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetQueryServTables()
|
|
||||||
{
|
|
||||||
std::string tables_list;
|
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetQueryServerTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim(tables_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetSystemTablesList()
|
|
||||||
{
|
|
||||||
std::string tables_list;
|
|
||||||
|
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetServerTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
tables = DatabaseSchema::GetVersionTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim(tables_list);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetStateTablesList()
|
|
||||||
{
|
|
||||||
std::string tables_list;
|
|
||||||
|
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetStateTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim(tables_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetContentTablesList()
|
|
||||||
{
|
|
||||||
std::string tables_list;
|
|
||||||
|
|
||||||
std::vector<std::string> tables = DatabaseSchema::GetContentTables();
|
|
||||||
for (const auto &table : tables) {
|
|
||||||
tables_list += table + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim(tables_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string GetDumpDate()
|
|
||||||
{
|
|
||||||
|
|
||||||
time_t now = time(nullptr);
|
|
||||||
struct tm time_struct{};
|
|
||||||
char buf[80];
|
|
||||||
time_struct = *localtime(&now);
|
|
||||||
strftime(buf, sizeof(buf), "%Y-%m-%d", &time_struct);
|
|
||||||
|
|
||||||
std::string time = buf;
|
|
||||||
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetSetDumpPath()
|
|
||||||
{
|
|
||||||
return !GetDumpPath().empty() ? GetDumpPath() : DATABASE_DUMP_PATH;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string DatabaseDumpService::GetDumpFileNameWithPath()
|
|
||||||
{
|
|
||||||
return GetSetDumpPath() + GetDumpFileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::Dump()
|
|
||||||
{
|
|
||||||
if (!IsMySQLInstalled()) {
|
|
||||||
LogError("MySQL is not installed; Please check your PATH for a valid MySQL installation");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDumpDropTableSyntaxOnly()) {
|
|
||||||
SetDumpOutputToConsole(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDumpOutputToConsole()) {
|
|
||||||
LogSys.SilenceConsoleLogging();
|
|
||||||
}
|
|
||||||
|
|
||||||
LogInfo("MySQL installed [{}]", GetMySQLVersion());
|
|
||||||
|
|
||||||
SetDumpFileName(EQEmuConfig::get()->DatabaseDB + '-' + GetDumpDate());
|
|
||||||
|
|
||||||
auto config = EQEmuConfig::get();
|
|
||||||
|
|
||||||
LogInfo(
|
|
||||||
"Database [{}] Host [{}] Username [{}]",
|
|
||||||
config->DatabaseDB,
|
|
||||||
config->DatabaseHost,
|
|
||||||
config->DatabaseUsername
|
|
||||||
);
|
|
||||||
|
|
||||||
std::string options = "--allow-keywords --extended-insert";
|
|
||||||
|
|
||||||
if (IsDumpWithNoData()) {
|
|
||||||
options += " --no-data";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsDumpTableLock()) {
|
|
||||||
options += " --skip-lock-tables";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string tables_to_dump;
|
|
||||||
std::string dump_descriptor;
|
|
||||||
|
|
||||||
if (!IsDumpAllTables()) {
|
|
||||||
if (IsDumpPlayerTables()) {
|
|
||||||
tables_to_dump += GetPlayerTablesList() + " ";
|
|
||||||
dump_descriptor += "-player";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDumpSystemTables()) {
|
|
||||||
tables_to_dump += GetSystemTablesList() + " ";
|
|
||||||
dump_descriptor += "-system";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDumpStateTables()) {
|
|
||||||
tables_to_dump += GetStateTablesList() + " ";
|
|
||||||
dump_descriptor += "-state";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDumpContentTables()) {
|
|
||||||
tables_to_dump += GetContentTablesList() + " ";
|
|
||||||
dump_descriptor += "-content";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDumpLoginServerTables()) {
|
|
||||||
tables_to_dump += GetLoginTableList() + " ";
|
|
||||||
dump_descriptor += "-login";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDumpQueryServerTables()) {
|
|
||||||
tables_to_dump += GetQueryServTables();
|
|
||||||
dump_descriptor += "-queryserv";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dump_descriptor.empty()) {
|
|
||||||
SetDumpFileName(GetDumpFileName() + dump_descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If we are dumping to stdout then we don't generate a file
|
|
||||||
*/
|
|
||||||
std::string pipe_file;
|
|
||||||
if (!IsDumpOutputToConsole()) {
|
|
||||||
pipe_file = fmt::format(" > {}.sql", GetDumpFileNameWithPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string execute_command = fmt::format(
|
|
||||||
"{} {} {} {}",
|
|
||||||
GetBaseMySQLDumpCommand(),
|
|
||||||
options,
|
|
||||||
tables_to_dump,
|
|
||||||
pipe_file
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!FileUtil::exists(GetSetDumpPath()) && !IsDumpOutputToConsole()) {
|
|
||||||
FileUtil::mkdir(GetSetDumpPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDumpDropTableSyntaxOnly()) {
|
|
||||||
std::vector<std::string> tables = SplitString(tables_to_dump, ' ');
|
|
||||||
|
|
||||||
for (auto &table : tables) {
|
|
||||||
std::cout << "DROP TABLE IF EXISTS `" << table << "`;" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tables_to_dump.empty()) {
|
|
||||||
std::cerr << "No tables were specified" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
std::string execution_result = execute(execute_command, IsDumpOutputToConsole());
|
|
||||||
if (!execution_result.empty()) {
|
|
||||||
std::cout << execution_result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tables_to_dump.empty()) {
|
|
||||||
LogInfo("Dumping Tables [{}]", tables_to_dump);
|
|
||||||
}
|
|
||||||
|
|
||||||
LogInfo("Database dump created at [{}.sql]", GetDumpFileNameWithPath());
|
|
||||||
|
|
||||||
if (IsDumpWithCompression() && !IsDumpOutputToConsole()) {
|
|
||||||
if (HasCompressionBinary()) {
|
|
||||||
LogInfo("Compression requested... Compressing dump [{}.sql]", GetDumpFileNameWithPath());
|
|
||||||
|
|
||||||
if (IsTarAvailable()) {
|
|
||||||
execute(
|
|
||||||
fmt::format(
|
|
||||||
"tar -zcvf {}.tar.gz -C {} {}.sql",
|
|
||||||
GetDumpFileNameWithPath(),
|
|
||||||
GetSetDumpPath(),
|
|
||||||
GetDumpFileName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
LogInfo("Compressed dump created at [{}.tar.gz]", GetDumpFileNameWithPath());
|
|
||||||
}
|
|
||||||
else if (Is7ZipAvailable()) {
|
|
||||||
execute(
|
|
||||||
fmt::format(
|
|
||||||
"7z a -t7z {}.zip {}.sql",
|
|
||||||
GetDumpFileNameWithPath(),
|
|
||||||
GetDumpFileNameWithPath()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
LogInfo("Compressed dump created at [{}.zip]", GetDumpFileNameWithPath());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogInfo("Compression requested, but no available compression binary was found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogWarning("Compression requested but binary not found... Skipping...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogDebug("[{}] dump-to-console", IsDumpOutputToConsole());
|
|
||||||
// LogDebug("[{}] dump-path", GetSetDumpPath());
|
|
||||||
// LogDebug("[{}] compression", (IsDumpWithCompression() ? "true" : "false"));
|
|
||||||
// LogDebug("[{}] query-serv", (IsDumpQueryServerTables() ? "true" : "false"));
|
|
||||||
// LogDebug("[{}] has-compression-binary", (HasCompressionBinary() ? "true" : "false"));
|
|
||||||
// LogDebug("[{}] content", (IsDumpContentTables() ? "true" : "false"));
|
|
||||||
// LogDebug("[{}] no-data", (IsDumpWithNoData() ? "true" : "false"));
|
|
||||||
// LogDebug("[{}] login", (IsDumpLoginServerTables() ? "true" : "false"));
|
|
||||||
// LogDebug("[{}] player", (IsDumpPlayerTables() ? "true" : "false"));
|
|
||||||
// LogDebug("[{}] system", (IsDumpSystemTables() ? "true" : "false"));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpSystemTables() const
|
|
||||||
{
|
|
||||||
return dump_system_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpSystemTables(bool dump_system_tables)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_system_tables = dump_system_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpContentTables() const
|
|
||||||
{
|
|
||||||
return dump_content_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpContentTables(bool dump_content_tables)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_content_tables = dump_content_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpPlayerTables() const
|
|
||||||
{
|
|
||||||
return dump_player_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpPlayerTables(bool dump_player_tables)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_player_tables = dump_player_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpLoginServerTables() const
|
|
||||||
{
|
|
||||||
return dump_login_server_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpLoginServerTables(bool dump_login_server_tables)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_login_server_tables = dump_login_server_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpWithNoData() const
|
|
||||||
{
|
|
||||||
return dump_with_no_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpWithNoData(bool dump_with_no_data)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_with_no_data = dump_with_no_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpAllTables() const
|
|
||||||
{
|
|
||||||
return dump_all_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpAllTables(bool dump_all_tables)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_all_tables = dump_all_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpTableLock() const
|
|
||||||
{
|
|
||||||
return dump_table_lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpTableLock(bool dump_table_lock)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_table_lock = dump_table_lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpWithCompression() const
|
|
||||||
{
|
|
||||||
return dump_with_compression;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpWithCompression(bool dump_with_compression)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_with_compression = dump_with_compression;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &DatabaseDumpService::GetDumpPath() const
|
|
||||||
{
|
|
||||||
return dump_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpPath(const std::string &dump_path)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_path = dump_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpFileName(const std::string &dump_file_name)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_file_name = dump_file_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &DatabaseDumpService::GetDumpFileName() const
|
|
||||||
{
|
|
||||||
return dump_file_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpQueryServerTables() const
|
|
||||||
{
|
|
||||||
return dump_query_server_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpQueryServerTables(bool dump_query_server_tables)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_query_server_tables = dump_query_server_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpOutputToConsole() const
|
|
||||||
{
|
|
||||||
return dump_output_to_console;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpOutputToConsole(bool dump_output_to_console)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_output_to_console = dump_output_to_console;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpDropTableSyntaxOnly() const
|
|
||||||
{
|
|
||||||
return dump_drop_table_syntax_only;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpDropTableSyntaxOnly(bool dump_drop_table_syntax_only)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_drop_table_syntax_only = dump_drop_table_syntax_only;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpStateTables() const
|
|
||||||
{
|
|
||||||
return dump_state_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpStateTables(bool dump_state_tables)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_state_tables = dump_state_tables;
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This 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_DUMP_SERVICE_H
|
|
||||||
#define EQEMU_DATABASE_DUMP_SERVICE_H
|
|
||||||
|
|
||||||
|
|
||||||
class DatabaseDumpService {
|
|
||||||
public:
|
|
||||||
void Dump();
|
|
||||||
bool IsDumpAllTables() const;
|
|
||||||
void SetDumpAllTables(bool dump_all_tables);
|
|
||||||
bool IsDumpWithNoData() const;
|
|
||||||
void SetDumpWithNoData(bool dump_with_no_data);
|
|
||||||
bool IsDumpSystemTables() const;
|
|
||||||
void SetDumpSystemTables(bool dump_system_tables);
|
|
||||||
bool IsDumpContentTables() const;
|
|
||||||
void SetDumpContentTables(bool dump_content_tables);
|
|
||||||
bool IsDumpPlayerTables() const;
|
|
||||||
void SetDumpPlayerTables(bool dump_player_tables);
|
|
||||||
bool IsDumpLoginServerTables() const;
|
|
||||||
void SetDumpLoginServerTables(bool dump_login_server_tables);
|
|
||||||
bool IsDumpTableLock() const;
|
|
||||||
void SetDumpTableLock(bool dump_table_lock);
|
|
||||||
bool IsDumpWithCompression() const;
|
|
||||||
void SetDumpWithCompression(bool dump_with_compression);
|
|
||||||
const std::string &GetDumpPath() const;
|
|
||||||
void SetDumpPath(const std::string &dump_path);
|
|
||||||
const std::string &GetDumpFileName() const;
|
|
||||||
void SetDumpFileName(const std::string &dump_file_name);
|
|
||||||
bool IsDumpQueryServerTables() const;
|
|
||||||
void SetDumpQueryServerTables(bool dump_query_server_tables);
|
|
||||||
bool IsDumpOutputToConsole() const;
|
|
||||||
void SetDumpOutputToConsole(bool dump_output_to_console);
|
|
||||||
bool IsDumpDropTableSyntaxOnly() const;
|
|
||||||
void SetDumpDropTableSyntaxOnly(bool dump_drop_table_syntax_only);
|
|
||||||
bool IsDumpStateTables() const;
|
|
||||||
void SetDumpStateTables(bool dump_state_tables);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool dump_all_tables = false;
|
|
||||||
bool dump_state_tables = false;
|
|
||||||
bool dump_system_tables = false;
|
|
||||||
bool dump_content_tables = false;
|
|
||||||
bool dump_player_tables = false;
|
|
||||||
bool dump_query_server_tables = false;
|
|
||||||
bool dump_login_server_tables = false;
|
|
||||||
bool dump_with_no_data = false;
|
|
||||||
bool dump_table_lock = false;
|
|
||||||
bool dump_with_compression = false;
|
|
||||||
bool dump_output_to_console = false;
|
|
||||||
bool dump_drop_table_syntax_only = false;
|
|
||||||
std::string dump_path;
|
|
||||||
std::string dump_file_name;
|
|
||||||
|
|
||||||
std::string execute(const std::string &cmd, bool return_result);
|
|
||||||
bool IsMySQLInstalled();
|
|
||||||
std::string GetMySQLVersion();
|
|
||||||
std::string GetBaseMySQLDumpCommand();
|
|
||||||
std::string GetPlayerTablesList();
|
|
||||||
std::string GetSystemTablesList();
|
|
||||||
std::string GetStateTablesList();
|
|
||||||
std::string GetContentTablesList();
|
|
||||||
std::string GetLoginTableList();
|
|
||||||
bool IsTarAvailable();
|
|
||||||
bool Is7ZipAvailable();
|
|
||||||
bool HasCompressionBinary();
|
|
||||||
std::string GetDumpFileNameWithPath();
|
|
||||||
std::string GetSetDumpPath();
|
|
||||||
std::string GetQueryServTables();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //EQEMU_DATABASE_DUMP_SERVICE_H
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,617 +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);
|
|
||||||
|
|
||||||
return (start_time + duration) <= tv.tv_sec;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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 (%u, %u, %u, UNIX_TIMESTAMP(), %u)",
|
|
||||||
instance_id,
|
|
||||||
zone_id,
|
|
||||||
version,
|
|
||||||
duration
|
|
||||||
);
|
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
|
|
||||||
return results.Success();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
|
||||||
{
|
|
||||||
uint32 max_reserved_instance_id = RuleI(Instances, ReservedInstances);
|
|
||||||
uint32 max = 32000;
|
|
||||||
|
|
||||||
std::string query = StringFormat(
|
|
||||||
"SELECT IFNULL(MAX(id),%u)+1 FROM instance_list WHERE id > %u",
|
|
||||||
max_reserved_instance_id,
|
|
||||||
max_reserved_instance_id
|
|
||||||
);
|
|
||||||
|
|
||||||
if (RuleB(Instances, RecycleInstanceIds)) {
|
|
||||||
query = (
|
|
||||||
SQL(
|
|
||||||
SELECT i.id + 1 AS next_available
|
|
||||||
FROM instance_list i
|
|
||||||
LEFT JOIN instance_list i2 ON i2.id = i.id + 1
|
|
||||||
WHERE i2.id IS NULL
|
|
||||||
ORDER BY i.id
|
|
||||||
LIMIT 0, 1;
|
|
||||||
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
|
|
||||||
if (!results.Success()) {
|
|
||||||
instance_id = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.RowCount() == 0) {
|
|
||||||
instance_id = max_reserved_instance_id;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto row = results.begin();
|
|
||||||
|
|
||||||
if (atoi(row[0]) <= max) {
|
|
||||||
instance_id = atoi(row[0]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (instance_id < max_reserved_instance_id) {
|
|
||||||
instance_id = max_reserved_instance_id;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
query = StringFormat("SELECT id FROM instance_list where id > %u ORDER BY id", max_reserved_instance_id);
|
|
||||||
results = QueryDatabase(query);
|
|
||||||
|
|
||||||
if (!results.Success()) {
|
|
||||||
instance_id = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.RowCount() == 0) {
|
|
||||||
instance_id = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
max_reserved_instance_id++;
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
|
||||||
if (max_reserved_instance_id < atoi(row[0])) {
|
|
||||||
instance_id = max_reserved_instance_id;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (max_reserved_instance_id > max) {
|
|
||||||
instance_id = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
max_reserved_instance_id++;
|
|
||||||
}
|
|
||||||
|
|
||||||
instance_id = max_reserved_instance_id;
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delay purging by a day so that we can continue using adjacent free instance id's
|
|
||||||
* from the table without risking the chance we immediately re-allocate a zone that freshly expired but
|
|
||||||
* has not been fully de-allocated
|
|
||||||
*/
|
|
||||||
std::string query =
|
|
||||||
SQL(
|
|
||||||
SELECT
|
|
||||||
id
|
|
||||||
FROM
|
|
||||||
instance_list
|
|
||||||
where
|
|
||||||
(start_time + duration) <= (UNIX_TIMESTAMP() - 86400)
|
|
||||||
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,369 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This 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_SCHEMA_H
|
|
||||||
#define EQEMU_DATABASE_SCHEMA_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace DatabaseSchema {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Character-specific tables
|
|
||||||
*
|
|
||||||
* Does not included related meta-data tables such as 'guilds', 'accounts'
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static std::map<std::string, std::string> GetCharacterTables()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
{"adventure_stats", "player_id"},
|
|
||||||
{"buyer", "charid"},
|
|
||||||
{"char_recipe_list", "char_id"},
|
|
||||||
{"character_activities", "charid"},
|
|
||||||
{"character_alt_currency", "char_id"},
|
|
||||||
{"character_alternate_abilities", "id"},
|
|
||||||
{"character_auras", "id"},
|
|
||||||
{"character_bandolier", "id"},
|
|
||||||
{"character_bind", "id"},
|
|
||||||
{"character_buffs", "character_id"},
|
|
||||||
{"character_corpses", "id"},
|
|
||||||
{"character_currency", "id"},
|
|
||||||
{"character_data", "id"},
|
|
||||||
{"character_disciplines", "id"},
|
|
||||||
{"character_enabledtasks", "charid"},
|
|
||||||
{"character_inspect_messages", "id"},
|
|
||||||
{"character_item_recast", "id"},
|
|
||||||
{"character_languages", "id"},
|
|
||||||
{"character_leadership_abilities", "id"},
|
|
||||||
{"character_material", "id"},
|
|
||||||
{"character_memmed_spells", "id"},
|
|
||||||
{"character_pet_buffs", "char_id"},
|
|
||||||
{"character_pet_info", "char_id"},
|
|
||||||
{"character_pet_inventory", "char_id"},
|
|
||||||
{"character_potionbelt", "id"},
|
|
||||||
{"character_skills", "id"},
|
|
||||||
{"character_spells", "id"},
|
|
||||||
{"character_tasks", "charid"},
|
|
||||||
{"character_tribute", "id"},
|
|
||||||
{"completed_tasks", "charid"},
|
|
||||||
{"data_buckets", "id"},
|
|
||||||
{"faction_values", "char_id"},
|
|
||||||
{"friends", "charid"},
|
|
||||||
{"guild_members", "char_id"},
|
|
||||||
{"guilds", "id"},
|
|
||||||
{"instance_list_player", "id"},
|
|
||||||
{"inventory", "charid"},
|
|
||||||
{"inventory_snapshots", "charid"},
|
|
||||||
{"keyring", "char_id"},
|
|
||||||
{"mail", "charid"},
|
|
||||||
{"player_titlesets", "char_id"},
|
|
||||||
{"quest_globals", "charid"},
|
|
||||||
{"timers", "char_id"},
|
|
||||||
{"titles", "char_id"},
|
|
||||||
{"trader", "char_id"},
|
|
||||||
{"zone_flags", "charID"}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Gets all player and meta-data tables
|
|
||||||
* @note These tables have no content in the PEQ daily dump
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static std::vector<std::string> GetPlayerTables()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"account",
|
|
||||||
"account_ip",
|
|
||||||
"account_flags",
|
|
||||||
"account_rewards",
|
|
||||||
"adventure_details",
|
|
||||||
"adventure_stats",
|
|
||||||
"buyer",
|
|
||||||
"char_recipe_list",
|
|
||||||
"character_activities",
|
|
||||||
"character_alt_currency",
|
|
||||||
"character_alternate_abilities",
|
|
||||||
"character_auras",
|
|
||||||
"character_bandolier",
|
|
||||||
"character_bind",
|
|
||||||
"character_buffs",
|
|
||||||
"character_corpse_items",
|
|
||||||
"character_corpses",
|
|
||||||
"character_currency",
|
|
||||||
"character_data",
|
|
||||||
"character_disciplines",
|
|
||||||
"character_enabledtasks",
|
|
||||||
"character_inspect_messages",
|
|
||||||
"character_item_recast",
|
|
||||||
"character_languages",
|
|
||||||
"character_leadership_abilities",
|
|
||||||
"character_material",
|
|
||||||
"character_memmed_spells",
|
|
||||||
"character_pet_buffs",
|
|
||||||
"character_pet_info",
|
|
||||||
"character_pet_inventory",
|
|
||||||
"character_potionbelt",
|
|
||||||
"character_skills",
|
|
||||||
"character_spells",
|
|
||||||
"character_tasks",
|
|
||||||
"character_tribute",
|
|
||||||
"completed_tasks",
|
|
||||||
"data_buckets",
|
|
||||||
"discovered_items",
|
|
||||||
"faction_values",
|
|
||||||
"friends",
|
|
||||||
"guild_bank",
|
|
||||||
"guild_members",
|
|
||||||
"guild_ranks",
|
|
||||||
"guild_relations",
|
|
||||||
"guilds",
|
|
||||||
"instance_list_player",
|
|
||||||
"inventory",
|
|
||||||
"inventory_snapshots",
|
|
||||||
"keyring",
|
|
||||||
"mail",
|
|
||||||
"petitions",
|
|
||||||
"player_titlesets",
|
|
||||||
"quest_globals",
|
|
||||||
"sharedbank",
|
|
||||||
"spell_buckets",
|
|
||||||
"spell_globals",
|
|
||||||
"timers",
|
|
||||||
"titles",
|
|
||||||
"trader",
|
|
||||||
"trader_audit",
|
|
||||||
"zone_flags"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets content tables
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static std::vector<std::string> GetContentTables()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"aa_ability",
|
|
||||||
"aa_actions",
|
|
||||||
"aa_effects",
|
|
||||||
"aa_rank_effects",
|
|
||||||
"aa_rank_prereqs",
|
|
||||||
"aa_ranks",
|
|
||||||
"aa_required_level_cost",
|
|
||||||
"adventure_template",
|
|
||||||
"adventure_template_entry",
|
|
||||||
"adventure_template_entry_flavor",
|
|
||||||
"altadv_vars",
|
|
||||||
"alternate_currency",
|
|
||||||
"auras",
|
|
||||||
"base_data",
|
|
||||||
"blocked_spells",
|
|
||||||
"books",
|
|
||||||
"char_create_combinations",
|
|
||||||
"char_create_point_allocations",
|
|
||||||
"class_skill",
|
|
||||||
"damageshieldtypes",
|
|
||||||
"doors",
|
|
||||||
"faction_base_data",
|
|
||||||
"faction_list",
|
|
||||||
"faction_list_mod",
|
|
||||||
"fear_hints",
|
|
||||||
"fishing",
|
|
||||||
"forage",
|
|
||||||
"global_loot",
|
|
||||||
"goallists",
|
|
||||||
"graveyard",
|
|
||||||
"grid",
|
|
||||||
"grid_entries",
|
|
||||||
"ground_spawns",
|
|
||||||
"horses",
|
|
||||||
"instance_list",
|
|
||||||
"items",
|
|
||||||
"ldon_trap_entries",
|
|
||||||
"ldon_trap_templates",
|
|
||||||
"lootdrop",
|
|
||||||
"lootdrop_entries",
|
|
||||||
"loottable",
|
|
||||||
"loottable_entries",
|
|
||||||
"merchantlist",
|
|
||||||
"npc_emotes",
|
|
||||||
"npc_faction",
|
|
||||||
"npc_faction_entries",
|
|
||||||
"npc_scale_global_base",
|
|
||||||
"npc_spells",
|
|
||||||
"npc_spells_effects",
|
|
||||||
"npc_spells_effects_entries",
|
|
||||||
"npc_spells_entries",
|
|
||||||
"npc_types",
|
|
||||||
"npc_types_metadata",
|
|
||||||
"npc_types_tint",
|
|
||||||
"object",
|
|
||||||
"pets",
|
|
||||||
"pets_equipmentset",
|
|
||||||
"pets_equipmentset_entries",
|
|
||||||
"proximities",
|
|
||||||
"races",
|
|
||||||
"skill_caps",
|
|
||||||
"spawn2",
|
|
||||||
"spawn_condition_values",
|
|
||||||
"spawn_conditions",
|
|
||||||
"spawn_events",
|
|
||||||
"spawnentry",
|
|
||||||
"spawngroup",
|
|
||||||
"spells_new",
|
|
||||||
"start_zones",
|
|
||||||
"starting_items",
|
|
||||||
"task_activities",
|
|
||||||
"tasks",
|
|
||||||
"tasksets",
|
|
||||||
"tradeskill_recipe",
|
|
||||||
"tradeskill_recipe_entries",
|
|
||||||
"traps",
|
|
||||||
"tribute_levels",
|
|
||||||
"tributes",
|
|
||||||
"veteran_reward_templates",
|
|
||||||
"zone",
|
|
||||||
"zone_points",
|
|
||||||
"zone_server",
|
|
||||||
"zoneserver_auth",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets server tables
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static std::vector<std::string> GetServerTables()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"chatchannels",
|
|
||||||
"command_settings",
|
|
||||||
"db_str",
|
|
||||||
"eqtime",
|
|
||||||
"launcher",
|
|
||||||
"launcher_zones",
|
|
||||||
"level_exp_mods",
|
|
||||||
"logsys_categories",
|
|
||||||
"name_filter",
|
|
||||||
"perl_event_export_settings",
|
|
||||||
"profanity_list",
|
|
||||||
"rule_sets",
|
|
||||||
"rule_values",
|
|
||||||
"variables",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets QueryServer tables
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static std::vector<std::string> GetQueryServerTables()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"qs_merchant_transaction_record",
|
|
||||||
"qs_merchant_transaction_record_entries",
|
|
||||||
"qs_player_aa_rate_hourly",
|
|
||||||
"qs_player_delete_record",
|
|
||||||
"qs_player_delete_record_entries",
|
|
||||||
"qs_player_events",
|
|
||||||
"qs_player_handin_record",
|
|
||||||
"qs_player_handin_record_entries",
|
|
||||||
"qs_player_move_record",
|
|
||||||
"qs_player_move_record_entries",
|
|
||||||
"qs_player_npc_kill_record",
|
|
||||||
"qs_player_npc_kill_record_entries",
|
|
||||||
"qs_player_speech",
|
|
||||||
"qs_player_trade_record",
|
|
||||||
"qs_player_trade_record_entries",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets state tables
|
|
||||||
* Tables that keep track of server state
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static std::vector<std::string> GetStateTables()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"adventure_members",
|
|
||||||
"banned_ips",
|
|
||||||
"bug_reports",
|
|
||||||
"bugs",
|
|
||||||
"eventlog",
|
|
||||||
"gm_ips",
|
|
||||||
"group_id",
|
|
||||||
"group_leaders",
|
|
||||||
"hackers",
|
|
||||||
"ip_exemptions",
|
|
||||||
"item_tick",
|
|
||||||
"lfguild",
|
|
||||||
"merchantlist_temp",
|
|
||||||
"object_contents",
|
|
||||||
"raid_details",
|
|
||||||
"raid_leaders",
|
|
||||||
"raid_members",
|
|
||||||
"reports",
|
|
||||||
"respawn_times",
|
|
||||||
"saylink",
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets login tables
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static std::vector<std::string> GetLoginTables()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"login_accounts",
|
|
||||||
"login_api_tokens",
|
|
||||||
"login_server_admins",
|
|
||||||
"login_server_list_types",
|
|
||||||
"login_world_servers",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets login tables
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static std::vector<std::string> GetVersionTables()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"db_version",
|
|
||||||
"inventory_versions",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //EQEMU_DATABASE_SCHEMA_H
|
|
||||||
+166
-132
@@ -1,51 +1,46 @@
|
|||||||
|
#include "../common/debug.h"
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "misc_functions.h"
|
|
||||||
#include "eqemu_logsys.h"
|
|
||||||
#include "timer.h"
|
|
||||||
|
|
||||||
#include "dbcore.h"
|
|
||||||
|
|
||||||
#include <errmsg.h>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <errmsg.h>
|
||||||
#include <mysqld_error.h>
|
#include <mysqld_error.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include "dbcore.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "../common/misc_functions.h"
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#else
|
#else
|
||||||
|
#include "unix.h"
|
||||||
#include "unix.h"
|
#include <pthread.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _EQDEBUG
|
#ifdef _EQDEBUG
|
||||||
#define DEBUG_MYSQL_QUERIES 0
|
#define DEBUG_MYSQL_QUERIES 0
|
||||||
#else
|
#else
|
||||||
#define DEBUG_MYSQL_QUERIES 0
|
#define DEBUG_MYSQL_QUERIES 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DBcore::DBcore()
|
DBcore::DBcore() {
|
||||||
{
|
|
||||||
mysql_init(&mysql);
|
mysql_init(&mysql);
|
||||||
pHost = 0;
|
pHost = 0;
|
||||||
pUser = 0;
|
pUser = 0;
|
||||||
pPassword = 0;
|
pPassword = 0;
|
||||||
pDatabase = 0;
|
pDatabase = 0;
|
||||||
pCompress = false;
|
pCompress = false;
|
||||||
pSSL = false;
|
pSSL = false;
|
||||||
pStatus = Closed;
|
pStatus = Closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBcore::~DBcore()
|
DBcore::~DBcore() {
|
||||||
{
|
|
||||||
mysql_close(&mysql);
|
mysql_close(&mysql);
|
||||||
safe_delete_array(pHost);
|
safe_delete_array(pHost);
|
||||||
safe_delete_array(pUser);
|
safe_delete_array(pUser);
|
||||||
@@ -54,8 +49,7 @@ DBcore::~DBcore()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sends the MySQL server a keepalive
|
// Sends the MySQL server a keepalive
|
||||||
void DBcore::ping()
|
void DBcore::ping() {
|
||||||
{
|
|
||||||
if (!MDatabase.trylock()) {
|
if (!MDatabase.trylock()) {
|
||||||
// well, if's it's locked, someone's using it. If someone's using it, it doesnt need a keepalive
|
// well, if's it's locked, someone's using it. If someone's using it, it doesnt need a keepalive
|
||||||
return;
|
return;
|
||||||
@@ -69,35 +63,34 @@ MySQLRequestResult DBcore::QueryDatabase(std::string query, bool retryOnFailureO
|
|||||||
return QueryDatabase(query.c_str(), query.length(), retryOnFailureOnce);
|
return QueryDatabase(query.c_str(), query.length(), retryOnFailureOnce);
|
||||||
}
|
}
|
||||||
|
|
||||||
MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, bool retryOnFailureOnce)
|
MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce)
|
||||||
{
|
{
|
||||||
BenchTimer timer;
|
|
||||||
timer.reset();
|
|
||||||
|
|
||||||
LockMutex lock(&MDatabase);
|
LockMutex lock(&MDatabase);
|
||||||
|
|
||||||
// Reconnect if we are not connected before hand.
|
// Reconnect if we are not connected before hand.
|
||||||
if (pStatus != Connected) {
|
if (pStatus != Connected)
|
||||||
Open();
|
Open();
|
||||||
}
|
|
||||||
|
|
||||||
// request query. != 0 indicates some kind of error.
|
// request query. != 0 indicates some kind of error.
|
||||||
if (mysql_real_query(&mysql, query, querylen) != 0) {
|
if (mysql_real_query(&mysql, query, querylen) != 0)
|
||||||
|
{
|
||||||
unsigned int errorNumber = mysql_errno(&mysql);
|
unsigned int errorNumber = mysql_errno(&mysql);
|
||||||
|
|
||||||
if (errorNumber == CR_SERVER_GONE_ERROR) {
|
if (errorNumber == CR_SERVER_GONE_ERROR)
|
||||||
pStatus = Error;
|
pStatus = Error;
|
||||||
}
|
|
||||||
|
|
||||||
// error appears to be a disconnect error, may need to try again.
|
// error appears to be a disconnect error, may need to try again.
|
||||||
if (errorNumber == CR_SERVER_LOST || errorNumber == CR_SERVER_GONE_ERROR) {
|
if (errorNumber == CR_SERVER_LOST || errorNumber == CR_SERVER_GONE_ERROR)
|
||||||
|
{
|
||||||
|
|
||||||
if (retryOnFailureOnce) {
|
if (retryOnFailureOnce)
|
||||||
LogInfo("Database Error: Lost connection, attempting to recover");
|
{
|
||||||
|
std::cout << "Database Error: Lost connection, attempting to recover...." << std::endl;
|
||||||
MySQLRequestResult requestResult = QueryDatabase(query, querylen, false);
|
MySQLRequestResult requestResult = QueryDatabase(query, querylen, false);
|
||||||
|
|
||||||
if (requestResult.Success()) {
|
if (requestResult.Success())
|
||||||
LogInfo("Reconnection to database successful");
|
{
|
||||||
|
std::cout << "Reconnection to database successful." << std::endl;
|
||||||
return requestResult;
|
return requestResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,154 +98,195 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo
|
|||||||
|
|
||||||
pStatus = Error;
|
pStatus = Error;
|
||||||
|
|
||||||
auto errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
char *errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
||||||
|
|
||||||
snprintf(errorBuffer, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
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);
|
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||||
|
|
||||||
|
return MySQLRequestResult(nullptr, 0, 0, 0, 0, (uint32)mysql_errno(&mysql), errorBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
char *errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
||||||
snprintf(errorBuffer, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
snprintf(errorBuffer, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||||
|
|
||||||
/**
|
#ifdef _EQDEBUG
|
||||||
* Error logging
|
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||||
*/
|
#endif
|
||||||
if (mysql_errno(&mysql) > 0 && strlen(query) > 0) {
|
return MySQLRequestResult(nullptr, 0, 0, 0, 0, mysql_errno(&mysql),errorBuffer);
|
||||||
LogMySQLError("[{}] [{}]\n[{}]", mysql_errno(&mysql), mysql_error(&mysql), query);
|
|
||||||
}
|
|
||||||
|
|
||||||
return MySQLRequestResult(nullptr, 0, 0, 0, 0, mysql_errno(&mysql), errorBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// successful query. get results.
|
// successful query. get results.
|
||||||
MYSQL_RES *res = mysql_store_result(&mysql);
|
MYSQL_RES* res = mysql_store_result(&mysql);
|
||||||
uint32 rowCount = 0;
|
uint32 rowCount = 0;
|
||||||
|
|
||||||
if (res != nullptr) {
|
if (res != nullptr)
|
||||||
rowCount = (uint32) mysql_num_rows(res);
|
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 DEBUG_MYSQL_QUERIES >= 1
|
||||||
|
if (requestResult.Success())
|
||||||
|
{
|
||||||
|
std::cout << "query successful";
|
||||||
|
if (requestResult.Result())
|
||||||
|
std::cout << ", " << (int) mysql_num_rows(requestResult.Result()) << " rows returned";
|
||||||
|
|
||||||
|
std::cout << ", " << requestResult.RowCount() << " rows affected";
|
||||||
|
std::cout<< std::endl;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
MySQLRequestResult requestResult(
|
std::cout << "QUERY: query FAILED" << std::endl;
|
||||||
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)) {
|
|
||||||
LogMySQLQuery(
|
|
||||||
"{0} ({1} row{2} returned) ({3}s)",
|
|
||||||
query,
|
|
||||||
requestResult.RowCount(),
|
|
||||||
requestResult.RowCount() == 1 ? "" : "s",
|
|
||||||
std::to_string(timer.elapsed())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogMySQLQuery(
|
|
||||||
"{0} ({1} row{2} affected) ({3}s)",
|
|
||||||
query,
|
|
||||||
requestResult.RowsAffected(),
|
|
||||||
requestResult.RowsAffected() == 1 ? "" : "s",
|
|
||||||
std::to_string(timer.elapsed())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return requestResult;
|
return requestResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBcore::TransactionBegin()
|
bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RES** result, uint32* affected_rows, uint32* last_insert_id, uint32* errnum, bool retry) {
|
||||||
{
|
if (errnum)
|
||||||
QueryDatabase("START TRANSACTION");
|
*errnum = 0;
|
||||||
|
if (errbuf)
|
||||||
|
errbuf[0] = 0;
|
||||||
|
bool ret = false;
|
||||||
|
LockMutex lock(&MDatabase);
|
||||||
|
if (pStatus != Connected)
|
||||||
|
Open();
|
||||||
|
|
||||||
|
if (mysql_real_query(&mysql, query, querylen)) {
|
||||||
|
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
|
||||||
|
pStatus = Error;
|
||||||
|
if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
|
||||||
|
if (retry) {
|
||||||
|
std::cout << "Database Error: Lost connection, attempting to recover...." << std::endl;
|
||||||
|
ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
|
||||||
|
if (ret)
|
||||||
|
std::cout << "Reconnection to database successful." << std::endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pStatus = Error;
|
||||||
|
if (errnum)
|
||||||
|
*errnum = mysql_errno(&mysql);
|
||||||
|
if (errbuf)
|
||||||
|
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||||
|
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (errnum)
|
||||||
|
*errnum = mysql_errno(&mysql);
|
||||||
|
if (errbuf)
|
||||||
|
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||||
|
#ifdef _EQDEBUG
|
||||||
|
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||||
|
#endif
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (result && mysql_field_count(&mysql)) {
|
||||||
|
*result = mysql_store_result(&mysql);
|
||||||
|
#ifdef _EQDEBUG
|
||||||
|
DBMemLeak::Alloc(*result, query);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (result)
|
||||||
|
*result = 0;
|
||||||
|
if (affected_rows)
|
||||||
|
*affected_rows = mysql_affected_rows(&mysql);
|
||||||
|
if (last_insert_id)
|
||||||
|
*last_insert_id = (uint32)mysql_insert_id(&mysql);
|
||||||
|
if (result) {
|
||||||
|
if (*result) {
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#ifdef _EQDEBUG
|
||||||
|
std::cout << "DB Query Error: No Result" << std::endl;
|
||||||
|
#endif
|
||||||
|
if (errnum)
|
||||||
|
*errnum = UINT_MAX;
|
||||||
|
if (errbuf)
|
||||||
|
strcpy(errbuf, "DBcore::RunQuery: No Result");
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if DEBUG_MYSQL_QUERIES >= 1
|
||||||
|
if (ret) {
|
||||||
|
std::cout << "query successful";
|
||||||
|
if (result && (*result))
|
||||||
|
std::cout << ", " << (int) mysql_num_rows(*result) << " rows returned";
|
||||||
|
if (affected_rows)
|
||||||
|
std::cout << ", " << (*affected_rows) << " rows affected";
|
||||||
|
std::cout<< std::endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "QUERY: query FAILED" << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBcore::TransactionCommit()
|
uint32 DBcore::DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen) {
|
||||||
{
|
|
||||||
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.
|
// No good reason to lock the DB, we only need it in the first place to check char encoding.
|
||||||
// LockMutex lock(&MDatabase);
|
// LockMutex lock(&MDatabase);
|
||||||
return mysql_real_escape_string(&mysql, tobuf, frombuf, fromlen);
|
return mysql_real_escape_string(&mysql, tobuf, frombuf, fromlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DBcore::Open(
|
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) {
|
||||||
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);
|
LockMutex lock(&MDatabase);
|
||||||
safe_delete(pHost);
|
safe_delete(pHost);
|
||||||
safe_delete(pUser);
|
safe_delete(pUser);
|
||||||
safe_delete(pPassword);
|
safe_delete(pPassword);
|
||||||
safe_delete(pDatabase);
|
safe_delete(pDatabase);
|
||||||
pHost = strcpy(new char[strlen(iHost) + 1], iHost);
|
pHost = strcpy(new char[strlen(iHost) + 1], iHost);
|
||||||
pUser = strcpy(new char[strlen(iUser) + 1], iUser);
|
pUser = strcpy(new char[strlen(iUser) + 1], iUser);
|
||||||
pPassword = strcpy(new char[strlen(iPassword) + 1], iPassword);
|
pPassword = strcpy(new char[strlen(iPassword) + 1], iPassword);
|
||||||
pDatabase = strcpy(new char[strlen(iDatabase) + 1], iDatabase);
|
pDatabase = strcpy(new char[strlen(iDatabase) + 1], iDatabase);
|
||||||
pCompress = iCompress;
|
pCompress = iCompress;
|
||||||
pPort = iPort;
|
pPort = iPort;
|
||||||
pSSL = iSSL;
|
pSSL = iSSL;
|
||||||
return Open(errnum, errbuf);
|
return Open(errnum, errbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DBcore::Open(uint32 *errnum, char *errbuf)
|
bool DBcore::Open(uint32* errnum, char* errbuf) {
|
||||||
{
|
if (errbuf)
|
||||||
if (errbuf) {
|
|
||||||
errbuf[0] = 0;
|
errbuf[0] = 0;
|
||||||
}
|
|
||||||
LockMutex lock(&MDatabase);
|
LockMutex lock(&MDatabase);
|
||||||
if (GetStatus() == Connected) {
|
if (GetStatus() == Connected)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
if (GetStatus() == Error) {
|
if (GetStatus() == Error) {
|
||||||
mysql_close(&mysql);
|
mysql_close(&mysql);
|
||||||
mysql_init(&mysql); // Initialize structure again
|
mysql_init(&mysql); // Initialize structure again
|
||||||
}
|
}
|
||||||
if (!pHost) {
|
if (!pHost)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
Added CLIENT_FOUND_ROWS flag to the connect
|
Added CLIENT_FOUND_ROWS flag to the connect
|
||||||
otherwise DB update calls would say 0 rows affected when the value already equalled
|
otherwise DB update calls would say 0 rows affected when the value already equalled
|
||||||
what the function was tring to set it to, therefore the function would think it failed
|
what the function was tring to set it to, therefore the function would think it failed
|
||||||
*/
|
*/
|
||||||
uint32 flags = CLIENT_FOUND_ROWS;
|
uint32 flags = CLIENT_FOUND_ROWS;
|
||||||
if (pCompress) {
|
if (pCompress)
|
||||||
flags |= CLIENT_COMPRESS;
|
flags |= CLIENT_COMPRESS;
|
||||||
}
|
if (pSSL)
|
||||||
if (pSSL) {
|
|
||||||
flags |= CLIENT_SSL;
|
flags |= CLIENT_SSL;
|
||||||
}
|
|
||||||
if (mysql_real_connect(&mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
|
if (mysql_real_connect(&mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
|
||||||
pStatus = Connected;
|
pStatus = Connected;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (errnum) {
|
if (errnum)
|
||||||
*errnum = mysql_errno(&mysql);
|
*errnum = mysql_errno(&mysql);
|
||||||
}
|
if (errbuf)
|
||||||
if (errbuf) {
|
|
||||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||||
}
|
|
||||||
pStatus = Error;
|
pStatus = Error;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-8
@@ -2,16 +2,19 @@
|
|||||||
#define DBCORE_H
|
#define DBCORE_H
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <winsock2.h>
|
#include <winsock.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../common/mutex.h"
|
|
||||||
#include "../common/mysql_request_result.h"
|
|
||||||
#include "../common/types.h"
|
|
||||||
|
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "../common/types.h"
|
||||||
|
#include "../common/mutex.h"
|
||||||
|
#include "../common/linked_list.h"
|
||||||
|
#include "../common/queue.h"
|
||||||
|
#include "../common/timer.h"
|
||||||
|
#include "../common/condition.h"
|
||||||
|
#include "../common/mysql_request_result.h"
|
||||||
|
|
||||||
class DBcore {
|
class DBcore {
|
||||||
public:
|
public:
|
||||||
@@ -20,11 +23,9 @@ public:
|
|||||||
DBcore();
|
DBcore();
|
||||||
~DBcore();
|
~DBcore();
|
||||||
eStatus GetStatus() { return pStatus; }
|
eStatus GetStatus() { return pStatus; }
|
||||||
|
bool RunQuery(const char* query, uint32 querylen, char* errbuf = 0, MYSQL_RES** result = 0, uint32* affected_rows = 0, uint32* last_insert_id = 0, uint32* errnum = 0, bool retry = true);
|
||||||
MySQLRequestResult QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce = true);
|
MySQLRequestResult QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce = true);
|
||||||
MySQLRequestResult QueryDatabase(std::string query, 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);
|
uint32 DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen);
|
||||||
void ping();
|
void ping();
|
||||||
MYSQL* getMySQL(){ return &mysql; }
|
MYSQL* getMySQL(){ return &mysql; }
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
// Doors
|
||||||
|
#ifdef SHAREMEM
|
||||||
|
int32 Database::GetDoorsCount(uint32* oMaxID) {
|
||||||
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
|
char *query = 0;
|
||||||
|
MYSQL_RES *result;
|
||||||
|
MYSQL_ROW row;
|
||||||
|
query = new char[256];
|
||||||
|
strcpy(query, "SELECT MAX(id), count(*) FROM doors");
|
||||||
|
if (RunQuery(query, strlen(query), errbuf, &result)) {
|
||||||
|
safe_delete(query);
|
||||||
|
row = mysql_fetch_row(result);
|
||||||
|
if (row && row[1]) {
|
||||||
|
int32 ret = atoi(row[1]);
|
||||||
|
if (oMaxID) {
|
||||||
|
if (row[0])
|
||||||
|
*oMaxID = atoi(row[0]);
|
||||||
|
else
|
||||||
|
*oMaxID = 0;
|
||||||
|
}
|
||||||
|
mysql_free_result(result);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cerr << "Error in GetDoorsCount query '" << query << "' " << errbuf << endl;
|
||||||
|
delete[] query;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" bool extDBLoadDoors(uint32 iDoorCount, uint32 iMaxDoorID) { return database.DBLoadDoors(iDoorCount, iMaxDoorID); }
|
||||||
|
const Door* Database::GetDoor(uint8 door_id, const char* zone_name) {
|
||||||
|
for(uint32 i=0; i<max_door_type; i++) {
|
||||||
|
const Door* door = GetDoorDBID(i);
|
||||||
|
if(door && door->door_id == door_id && strcasecmp(door->zone_name, zone_name) == 0)
|
||||||
|
return door;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Door* Database::GetDoorDBID(uint32 db_id) {
|
||||||
|
return EMuShareMemDLL.Doors.GetDoor(db_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Database::LoadDoors() {
|
||||||
|
if (!EMuShareMemDLL.Load())
|
||||||
|
return false;
|
||||||
|
int32 tmp_max_door_type = -1;
|
||||||
|
uint32 tmp = 0;
|
||||||
|
tmp_max_door_type = GetDoorsCount(&tmp);
|
||||||
|
if (tmp_max_door_type < 0) {
|
||||||
|
cout << "Error: Database::LoadDoors-ShareMem: GetDoorsCount() returned < 0" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
max_door_type = tmp_max_door_type;
|
||||||
|
bool ret = EMuShareMemDLL.Doors.DLLLoadDoors(&extDBLoadDoors, sizeof(Door), max_door_type, tmp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Database::DBLoadDoors(uint32 iDoorCount, uint32 iMaxDoorID) {
|
||||||
|
cout << "Loading Doors from database..." << endl;
|
||||||
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
|
char *query = 0;
|
||||||
|
MYSQL_RES *result;
|
||||||
|
MYSQL_ROW row;
|
||||||
|
query = new char[256];
|
||||||
|
strcpy(query, "SELECT MAX(id), Count(*) FROM doors");
|
||||||
|
if (RunQuery(query, strlen(query), errbuf, &result))
|
||||||
|
{
|
||||||
|
safe_delete(query);
|
||||||
|
row = mysql_fetch_row(result);
|
||||||
|
if (row && row[0]) {
|
||||||
|
if (atoi(row[0]) > iMaxDoorID) {
|
||||||
|
cout << "Error: Insufficient shared memory to load doors." << endl;
|
||||||
|
cout << "Max(id): " << atoi(row[0]) << ", iMaxDoorID: " << iMaxDoorID << endl;
|
||||||
|
cout << "Fix this by increasing the MMF_MAX_Door_ID define statement" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (atoi(row[1]) != iDoorCount) {
|
||||||
|
cout << "Error: Insufficient shared memory to load doors." << endl;
|
||||||
|
cout << "Count(*): " << atoi(row[1]) << ", iDoorCount: " << iDoorCount << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
max_door_type = atoi(row[0]);
|
||||||
|
mysql_free_result(result);
|
||||||
|
Door tmpDoor;
|
||||||
|
MakeAnyLenString(&query, "SELECT id,doorid,zone,name,pos_x,pos_y,pos_z,heading,opentype,guild,lockpick,keyitem,triggerdoor,triggertype from doors");//WHERE zone='%s'", zone_name
|
||||||
|
if (RunQuery(query, strlen(query), errbuf, &result))
|
||||||
|
{
|
||||||
|
safe_delete(query);
|
||||||
|
while((row = mysql_fetch_row(result))) {
|
||||||
|
memset(&tmpDoor, 0, sizeof(Door));
|
||||||
|
tmpDoor.db_id = atoi(row[0]);
|
||||||
|
tmpDoor.door_id = atoi(row[1]);
|
||||||
|
strn0cpy(tmpDoor.zone_name,row[2],32);
|
||||||
|
strn0cpy(tmpDoor.door_name,row[3],32);
|
||||||
|
tmpDoor.pos_x = (float)atof(row[4]);
|
||||||
|
tmpDoor.pos_y = (float)atof(row[5]);
|
||||||
|
tmpDoor.pos_z = (float)atof(row[6]);
|
||||||
|
tmpDoor.heading = atoi(row[7]);
|
||||||
|
tmpDoor.opentype = atoi(row[8]);
|
||||||
|
tmpDoor.guild_id = atoi(row[9]);
|
||||||
|
tmpDoor.lockpick = atoi(row[10]);
|
||||||
|
tmpDoor.keyitem = atoi(row[11]);
|
||||||
|
tmpDoor.trigger_door = atoi(row[12]);
|
||||||
|
tmpDoor.trigger_type = atoi(row[13]);
|
||||||
|
EMuShareMemDLL.Doors.cbAddDoor(tmpDoor.db_id, &tmpDoor);
|
||||||
|
Sleep(0);
|
||||||
|
}
|
||||||
|
mysql_free_result(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cerr << "Error in DBLoadDoors query '" << query << "' " << errbuf << endl;
|
||||||
|
delete[] query;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,441 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
#include <process.h>
|
||||||
|
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#define vsnprintf _vsnprintf
|
||||||
|
#define strncasecmp _strnicmp
|
||||||
|
#define strcasecmp _stricmp
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "string_util.h"
|
||||||
|
#include "misc_functions.h"
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#ifndef va_copy
|
||||||
|
#define va_copy(d,s) ((d) = (s))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static volatile bool logFileValid = false;
|
||||||
|
static EQEMuLog realLogFile;
|
||||||
|
EQEMuLog *LogFile = &realLogFile;
|
||||||
|
|
||||||
|
static const char* FileNames[EQEMuLog::MaxLogID] = { "logs/eqemu", "logs/eqemu", "logs/eqemu_error", "logs/eqemu_debug", "logs/eqemu_quest", "logs/eqemu_commands", "logs/crash" };
|
||||||
|
static const char* LogNames[EQEMuLog::MaxLogID] = { "Status", "Normal", "Error", "Debug", "Quest", "Command", "Crash" };
|
||||||
|
|
||||||
|
EQEMuLog::EQEMuLog() {
|
||||||
|
for (int i=0; i<MaxLogID; i++) {
|
||||||
|
fp[i] = 0;
|
||||||
|
logCallbackFmt[i] = nullptr;
|
||||||
|
logCallbackBuf[i] = nullptr;
|
||||||
|
logCallbackPva[i] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pLogStatus[Status] = LOG_LEVEL_STATUS;
|
||||||
|
pLogStatus[Normal] = LOG_LEVEL_NORMAL;
|
||||||
|
pLogStatus[Error] = LOG_LEVEL_ERROR;
|
||||||
|
pLogStatus[Debug] = LOG_LEVEL_DEBUG;
|
||||||
|
pLogStatus[Quest] = LOG_LEVEL_QUEST;
|
||||||
|
pLogStatus[Commands] = LOG_LEVEL_COMMANDS;
|
||||||
|
pLogStatus[Crash] = LOG_LEVEL_CRASH;
|
||||||
|
logFileValid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
EQEMuLog::~EQEMuLog() {
|
||||||
|
logFileValid = false;
|
||||||
|
for (int i=0; i<MaxLogID; i++) {
|
||||||
|
LockMutex lock(&MLog[i]); //to prevent termination race
|
||||||
|
if (fp[i])
|
||||||
|
fclose(fp[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EQEMuLog::open(LogIDs id) {
|
||||||
|
if (!logFileValid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (id >= MaxLogID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LockMutex lock(&MOpen);
|
||||||
|
if (pLogStatus[id] & 4) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (fp[id]) {
|
||||||
|
//cerr<<"Warning: LogFile already open"<<endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
char exename[200] = "";
|
||||||
|
const EQEmuExePlatform &platform = GetExecutablePlatform();
|
||||||
|
if(platform == ExePlatformWorld) {
|
||||||
|
snprintf(exename, sizeof(exename), "_world");
|
||||||
|
} else if(platform == ExePlatformZone) {
|
||||||
|
snprintf(exename, sizeof(exename), "_zone");
|
||||||
|
} else if(platform == ExePlatformLaunch) {
|
||||||
|
snprintf(exename, sizeof(exename), "_launch");
|
||||||
|
} else if(platform == ExePlatformUCS) {
|
||||||
|
snprintf(exename, sizeof(exename), "_ucs");
|
||||||
|
} else if(platform == ExePlatformQueryServ) {
|
||||||
|
snprintf(exename, sizeof(exename), "_queryserv");
|
||||||
|
} else if(platform == ExePlatformSharedMemory) {
|
||||||
|
snprintf(exename, sizeof(exename), "_shared_memory");
|
||||||
|
} else if(platform == ExePlatformClientImport) {
|
||||||
|
snprintf(exename, sizeof(exename), "_import");
|
||||||
|
} else if(platform == ExePlatformClientExport) {
|
||||||
|
snprintf(exename, sizeof(exename), "_export");
|
||||||
|
}
|
||||||
|
|
||||||
|
char filename[200];
|
||||||
|
#ifndef NO_PIDLOG
|
||||||
|
snprintf(filename, sizeof(filename), "%s%s_%04i.log", FileNames[id], exename, getpid());
|
||||||
|
#else
|
||||||
|
snprintf(filename, sizeof(filename), "%s%s.log", FileNames[id], exename);
|
||||||
|
#endif
|
||||||
|
fp[id] = fopen(filename, "a");
|
||||||
|
if (!fp[id]) {
|
||||||
|
std::cerr << "Failed to open log file: " << filename << std::endl;
|
||||||
|
pLogStatus[id] |= 4; // set file state to error
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fputs("---------------------------------------------\n",fp[id]);
|
||||||
|
write(id, "Starting Log: %s", filename);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
|
||||||
|
if (!logFileValid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (id >= MaxLogID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool dofile = false;
|
||||||
|
if (pLogStatus[id] & 1) {
|
||||||
|
dofile = open(id);
|
||||||
|
}
|
||||||
|
if (!(dofile || pLogStatus[id] & 2))
|
||||||
|
return false;
|
||||||
|
LockMutex lock(&MLog[id]);
|
||||||
|
if (!logFileValid)
|
||||||
|
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||||
|
|
||||||
|
time_t aclock;
|
||||||
|
struct tm *newtime;
|
||||||
|
|
||||||
|
time( &aclock ); /* Get time in seconds */
|
||||||
|
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||||
|
|
||||||
|
if (dofile)
|
||||||
|
#ifndef NO_PIDLOG
|
||||||
|
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||||
|
#else
|
||||||
|
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
va_list argptr, tmpargptr;
|
||||||
|
va_start(argptr, fmt);
|
||||||
|
if (dofile) {
|
||||||
|
va_copy(tmpargptr, argptr);
|
||||||
|
vfprintf( fp[id], fmt, tmpargptr );
|
||||||
|
}
|
||||||
|
if(logCallbackFmt[id]) {
|
||||||
|
msgCallbackFmt p = logCallbackFmt[id];
|
||||||
|
va_copy(tmpargptr, argptr);
|
||||||
|
p(id, fmt, tmpargptr );
|
||||||
|
}
|
||||||
|
if (pLogStatus[id] & 2) {
|
||||||
|
if (pLogStatus[id] & 8) {
|
||||||
|
fprintf(stderr, "[%s] ", LogNames[id]);
|
||||||
|
vfprintf( stderr, fmt, argptr );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout, "[%s] ", LogNames[id]);
|
||||||
|
vfprintf( stdout, fmt, argptr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
va_end(argptr);
|
||||||
|
if (dofile)
|
||||||
|
fprintf(fp[id], "\n");
|
||||||
|
if (pLogStatus[id] & 2) {
|
||||||
|
if (pLogStatus[id] & 8) {
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
fflush(stderr);
|
||||||
|
} else {
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(dofile)
|
||||||
|
fflush(fp[id]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//write with Prefix and a VA_list
|
||||||
|
bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list argptr) {
|
||||||
|
if (!logFileValid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (id >= MaxLogID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool dofile = false;
|
||||||
|
if (pLogStatus[id] & 1) {
|
||||||
|
dofile = open(id);
|
||||||
|
}
|
||||||
|
if (!(dofile || pLogStatus[id] & 2)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LockMutex lock(&MLog[id]);
|
||||||
|
if (!logFileValid)
|
||||||
|
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||||
|
|
||||||
|
time_t aclock;
|
||||||
|
struct tm *newtime;
|
||||||
|
|
||||||
|
time( &aclock ); /* Get time in seconds */
|
||||||
|
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||||
|
|
||||||
|
va_list tmpargptr;
|
||||||
|
|
||||||
|
if (dofile) {
|
||||||
|
#ifndef NO_PIDLOG
|
||||||
|
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] %s", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
|
||||||
|
#else
|
||||||
|
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] %s", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
|
||||||
|
#endif
|
||||||
|
va_copy(tmpargptr, argptr);
|
||||||
|
vfprintf( fp[id], fmt, tmpargptr );
|
||||||
|
}
|
||||||
|
if(logCallbackPva[id]) {
|
||||||
|
msgCallbackPva p = logCallbackPva[id];
|
||||||
|
va_copy(tmpargptr, argptr);
|
||||||
|
p(id, prefix, fmt, tmpargptr );
|
||||||
|
}
|
||||||
|
if (pLogStatus[id] & 2) {
|
||||||
|
if (pLogStatus[id] & 8) {
|
||||||
|
fprintf(stderr, "[%s] %s", LogNames[id], prefix);
|
||||||
|
vfprintf( stderr, fmt, argptr );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout, "[%s] %s", LogNames[id], prefix);
|
||||||
|
vfprintf( stdout, fmt, argptr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
va_end(argptr);
|
||||||
|
if (dofile)
|
||||||
|
fprintf(fp[id], "\n");
|
||||||
|
if (pLogStatus[id] & 2) {
|
||||||
|
if (pLogStatus[id] & 8)
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
else
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
}
|
||||||
|
if(dofile)
|
||||||
|
fflush(fp[id]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
|
||||||
|
if (!logFileValid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (id >= MaxLogID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool dofile = false;
|
||||||
|
if (pLogStatus[id] & 1) {
|
||||||
|
dofile = open(id);
|
||||||
|
}
|
||||||
|
if (!(dofile || pLogStatus[id] & 2))
|
||||||
|
return false;
|
||||||
|
LockMutex lock(&MLog[id]);
|
||||||
|
if (!logFileValid)
|
||||||
|
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||||
|
|
||||||
|
time_t aclock;
|
||||||
|
struct tm *newtime;
|
||||||
|
|
||||||
|
time( &aclock ); /* Get time in seconds */
|
||||||
|
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||||
|
|
||||||
|
if (dofile)
|
||||||
|
#ifndef NO_PIDLOG
|
||||||
|
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||||
|
#else
|
||||||
|
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (dofile) {
|
||||||
|
fwrite(buf, size, count, fp[id]);
|
||||||
|
fprintf(fp[id], "\n");
|
||||||
|
}
|
||||||
|
if(logCallbackBuf[id]) {
|
||||||
|
msgCallbackBuf p = logCallbackBuf[id];
|
||||||
|
p(id, buf, size, count);
|
||||||
|
}
|
||||||
|
if (pLogStatus[id] & 2) {
|
||||||
|
if (pLogStatus[id] & 8) {
|
||||||
|
fprintf(stderr, "[%s] ", LogNames[id]);
|
||||||
|
fwrite(buf, size, count, stderr);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
} else {
|
||||||
|
fprintf(stdout, "[%s] ", LogNames[id]);
|
||||||
|
fwrite(buf, size, count, stdout);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(dofile)
|
||||||
|
fflush(fp[id]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
|
||||||
|
va_list argptr, tmpargptr;
|
||||||
|
va_start(argptr, fmt);
|
||||||
|
if (dofile) {
|
||||||
|
va_copy(tmpargptr, argptr);
|
||||||
|
vfprintf( fp[id], fmt, tmpargptr );
|
||||||
|
}
|
||||||
|
if (pLogStatus[id] & 2) {
|
||||||
|
if (pLogStatus[id] & 8)
|
||||||
|
vfprintf( stderr, fmt, argptr );
|
||||||
|
else
|
||||||
|
vfprintf( stdout, fmt, argptr );
|
||||||
|
}
|
||||||
|
va_end(argptr);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
|
||||||
|
if (!logFileValid) {
|
||||||
|
#if EQDEBUG >= 10
|
||||||
|
std::cerr << "Error: Dump() from null pointer" << std::endl;
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (size == 0)
|
||||||
|
return true;
|
||||||
|
if (!LogFile)
|
||||||
|
return false;
|
||||||
|
if (id >= MaxLogID)
|
||||||
|
return false;
|
||||||
|
bool dofile = false;
|
||||||
|
if (pLogStatus[id] & 1) {
|
||||||
|
dofile = open(id);
|
||||||
|
}
|
||||||
|
if (!(dofile || pLogStatus[id] & 2))
|
||||||
|
return false;
|
||||||
|
LockMutex lock(&MLog[id]);
|
||||||
|
if (!logFileValid)
|
||||||
|
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||||
|
|
||||||
|
write(id, "Dumping Packet: %i", size);
|
||||||
|
// Output as HEX
|
||||||
|
|
||||||
|
int beginningOfLineOffset = 0;
|
||||||
|
uint32 indexInData;
|
||||||
|
std::string asciiOutput;
|
||||||
|
|
||||||
|
for(indexInData=skip; indexInData<size; indexInData++) {
|
||||||
|
if ((indexInData-skip)%cols==0) {
|
||||||
|
if (indexInData != skip)
|
||||||
|
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
|
||||||
|
writeNTS(id, dofile, "%4i: ", indexInData-skip);
|
||||||
|
asciiOutput.clear();
|
||||||
|
beginningOfLineOffset = 0;
|
||||||
|
}
|
||||||
|
else if ((indexInData-skip)%(cols/2) == 0) {
|
||||||
|
writeNTS(id, dofile, "- ");
|
||||||
|
}
|
||||||
|
writeNTS(id, dofile, "%02X ", (unsigned char)data[indexInData]);
|
||||||
|
|
||||||
|
if (data[indexInData] >= 32 && data[indexInData] < 127)
|
||||||
|
{
|
||||||
|
// According to http://msdn.microsoft.com/en-us/library/vstudio/ee404875(v=vs.100).aspx
|
||||||
|
// Visual Studio 2010 doesn't have std::to_string(int) but it does have the long long
|
||||||
|
// version.
|
||||||
|
asciiOutput.append(std::to_string((long long)data[indexInData]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
asciiOutput.append(".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint32 k = ((indexInData-skip)-1)%cols;
|
||||||
|
if (k < 8)
|
||||||
|
writeNTS(id, dofile, " ");
|
||||||
|
for (uint32 h = k+1; h < cols; h++) {
|
||||||
|
writeNTS(id, dofile, " ");
|
||||||
|
}
|
||||||
|
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
|
||||||
|
if (dofile)
|
||||||
|
fflush(fp[id]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEMuLog::SetCallback(LogIDs id, msgCallbackFmt proc) {
|
||||||
|
if (!logFileValid)
|
||||||
|
return;
|
||||||
|
if (id >= MaxLogID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logCallbackFmt[id] = proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEMuLog::SetCallback(LogIDs id, msgCallbackBuf proc) {
|
||||||
|
if (!logFileValid)
|
||||||
|
return;
|
||||||
|
if (id >= MaxLogID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logCallbackBuf[id] = proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEMuLog::SetCallback(LogIDs id, msgCallbackPva proc) {
|
||||||
|
if (!logFileValid)
|
||||||
|
return;
|
||||||
|
if (id >= MaxLogID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logCallbackPva[id] = proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEMuLog::SetAllCallbacks(msgCallbackFmt proc) {
|
||||||
|
if (!logFileValid)
|
||||||
|
return;
|
||||||
|
int r;
|
||||||
|
for(r = Status; r < MaxLogID; r++) {
|
||||||
|
SetCallback((LogIDs)r, proc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEMuLog::SetAllCallbacks(msgCallbackBuf proc) {
|
||||||
|
if (!logFileValid)
|
||||||
|
return;
|
||||||
|
int r;
|
||||||
|
for(r = Status; r < MaxLogID; r++) {
|
||||||
|
SetCallback((LogIDs)r, proc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEMuLog::SetAllCallbacks(msgCallbackPva proc) {
|
||||||
|
if (!logFileValid)
|
||||||
|
return;
|
||||||
|
int r;
|
||||||
|
for(r = Status; r < MaxLogID; r++) {
|
||||||
|
SetCallback((LogIDs)r, proc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+149
@@ -0,0 +1,149 @@
|
|||||||
|
/* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Debug Levels
|
||||||
|
#ifndef EQDEBUG
|
||||||
|
#define EQDEBUG 1
|
||||||
|
#else
|
||||||
|
////// File/Console options
|
||||||
|
// 0 <= Quiet mode Errors to file Status and Normal ignored
|
||||||
|
// 1 >= Status and Normal to console, Errors to file
|
||||||
|
// 2 >= Status, Normal, and Error to console and logfile
|
||||||
|
// 3 >= Lite debug
|
||||||
|
// 4 >= Medium debug
|
||||||
|
// 5 >= Debug release (Anything higher is not recommended for regular use)
|
||||||
|
// 6 == (Reserved for special builds) Login opcode debug All packets dumped
|
||||||
|
// 7 == (Reserved for special builds) Chat Opcode debug All packets dumped
|
||||||
|
// 8 == (Reserved for special builds) World opcode debug All packets dumped
|
||||||
|
// 9 == (Reserved for special builds) Zone Opcode debug All packets dumped
|
||||||
|
// 10 >= More than you ever wanted to know
|
||||||
|
//
|
||||||
|
/////
|
||||||
|
// Add more below to reserve for file's functions ect.
|
||||||
|
/////
|
||||||
|
// Any setup code based on defines should go here
|
||||||
|
//
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_DEBUG) && defined(WIN32)
|
||||||
|
#ifndef _CRTDBG_MAP_ALLOC
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <crtdbg.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EQDEBUG_H
|
||||||
|
#define EQDEBUG_H
|
||||||
|
|
||||||
|
#ifndef _WINDOWS
|
||||||
|
#define DebugBreak() if(0) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define _WINSOCKAPI_ //stupid windows, trying to fix the winsock2 vs. winsock issues
|
||||||
|
#if defined(WIN32) && ( defined(PACKETCOLLECTOR) || defined(COLLECTOR) )
|
||||||
|
// Packet Collector on win32 requires winsock.h due to latest pcap.h
|
||||||
|
// winsock.h must come before windows.h
|
||||||
|
#include <winsock.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
#include <windows.h>
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "logsys.h"
|
||||||
|
|
||||||
|
#include "../common/mutex.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
|
class EQEMuLog {
|
||||||
|
public:
|
||||||
|
EQEMuLog();
|
||||||
|
~EQEMuLog();
|
||||||
|
|
||||||
|
enum LogIDs {
|
||||||
|
Status = 0, /* This must stay the first entry in this list */
|
||||||
|
Normal, /* Normal Logs */
|
||||||
|
Error, /* Error Logs */
|
||||||
|
Debug, /* Debug Logs */
|
||||||
|
Quest, /* Quest Logs */
|
||||||
|
Commands, /* Issued Comamnds */
|
||||||
|
Crash, /* Crash Logs */
|
||||||
|
Save, /* Client Saves */
|
||||||
|
MaxLogID /* Max, used in functions to get the max log ID */
|
||||||
|
};
|
||||||
|
|
||||||
|
//these are callbacks called for each
|
||||||
|
typedef void (* msgCallbackBuf)(LogIDs id, const char *buf, uint8 size, uint32 count);
|
||||||
|
typedef void (* msgCallbackFmt)(LogIDs id, const char *fmt, va_list ap);
|
||||||
|
typedef void (* msgCallbackPva)(LogIDs id, const char *prefix, const char *fmt, va_list ap);
|
||||||
|
|
||||||
|
void SetAllCallbacks(msgCallbackFmt proc);
|
||||||
|
void SetAllCallbacks(msgCallbackBuf proc);
|
||||||
|
void SetAllCallbacks(msgCallbackPva proc);
|
||||||
|
void SetCallback(LogIDs id, msgCallbackFmt proc);
|
||||||
|
void SetCallback(LogIDs id, msgCallbackBuf proc);
|
||||||
|
void SetCallback(LogIDs id, msgCallbackPva proc);
|
||||||
|
|
||||||
|
bool writebuf(LogIDs id, const char *buf, uint8 size, uint32 count);
|
||||||
|
bool write(LogIDs id, const char *fmt, ...);
|
||||||
|
bool writePVA(LogIDs id, const char *prefix, const char *fmt, va_list args);
|
||||||
|
bool Dump(LogIDs id, uint8* data, uint32 size, uint32 cols=16, uint32 skip=0);
|
||||||
|
private:
|
||||||
|
bool open(LogIDs id);
|
||||||
|
bool writeNTS(LogIDs id, bool dofile, const char *fmt, ...); // no error checking, assumes is open, no locking, no timestamp, no newline
|
||||||
|
|
||||||
|
Mutex MOpen;
|
||||||
|
Mutex MLog[MaxLogID];
|
||||||
|
FILE* fp[MaxLogID];
|
||||||
|
|
||||||
|
/* LogStatus: bitwise variable
|
||||||
|
1 = output to file
|
||||||
|
2 = output to stdout
|
||||||
|
4 = fopen error, dont retry
|
||||||
|
8 = use stderr instead (2 must be set)
|
||||||
|
*/
|
||||||
|
uint8 pLogStatus[MaxLogID];
|
||||||
|
|
||||||
|
msgCallbackFmt logCallbackFmt[MaxLogID];
|
||||||
|
msgCallbackBuf logCallbackBuf[MaxLogID];
|
||||||
|
msgCallbackPva logCallbackPva[MaxLogID];
|
||||||
|
};
|
||||||
|
|
||||||
|
extern EQEMuLog* LogFile;
|
||||||
|
|
||||||
|
#ifdef _EQDEBUG
|
||||||
|
class PerformanceMonitor {
|
||||||
|
public:
|
||||||
|
PerformanceMonitor(int64* ip) {
|
||||||
|
p = ip;
|
||||||
|
QueryPerformanceCounter(&tmp);
|
||||||
|
}
|
||||||
|
~PerformanceMonitor() {
|
||||||
|
LARGE_INTEGER tmp2;
|
||||||
|
QueryPerformanceCounter(&tmp2);
|
||||||
|
*p += tmp2.QuadPart - tmp.QuadPart;
|
||||||
|
}
|
||||||
|
LARGE_INTEGER tmp;
|
||||||
|
int64* p;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
#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";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
+141
-56
@@ -1,6 +1,5 @@
|
|||||||
/* EQEMu: Everquest Server Emulator
|
/* EQEMu: Everquest Server Emulator
|
||||||
|
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||||
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org)
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,68 +13,154 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
#ifndef DEITY_H
|
||||||
#ifndef COMMON_DEITY_H
|
#define DEITY_H
|
||||||
#define COMMON_DEITY_H
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// NOTE: This code is not fully implemented since there are no references in the existing code
|
||||||
|
|
||||||
namespace EQEmu
|
/*
|
||||||
|
** Diety types
|
||||||
|
**
|
||||||
|
** (ref: eqstr_us.txt)
|
||||||
|
**
|
||||||
|
** (Another orphaned enumeration...)
|
||||||
|
*/
|
||||||
|
enum DeityTypes
|
||||||
{
|
{
|
||||||
namespace deity {
|
/*----*/ DeityUnknown = 0,
|
||||||
enum DeityType {
|
/*----*/ DeityAgnostic_LB = 140,
|
||||||
DeityUnknown = 0,
|
/*3251*/ DeityBertoxxulous = 201,
|
||||||
DeityAgnostic_LB = 140,
|
/*3262*/ DeityBrellSirilis,
|
||||||
DeityBertoxxulous = 201,
|
/*3253*/ DeityCazicThule,
|
||||||
DeityBrellSirilis,
|
/*3256*/ DeityErollisiMarr,
|
||||||
DeityCazicThule,
|
/*3252*/ DeityBristlebane,
|
||||||
DeityErollisiMarr,
|
/*3254*/ DeityInnoruuk,
|
||||||
DeityBristlebane,
|
/*3255*/ DeityKarana,
|
||||||
DeityInnoruuk,
|
/*3257*/ DeityMithanielMarr,
|
||||||
DeityKarana,
|
/*3259*/ DeityPrexus,
|
||||||
DeityMithanielMarr,
|
/*3260*/ DeityQuellious,
|
||||||
DeityPrexus,
|
/*3266*/ DeityRallosZek,
|
||||||
DeityQuellious,
|
/*3258*/ DeityRodcetNife,
|
||||||
DeityRallosZek,
|
/*3261*/ DeitySolusekRo,
|
||||||
DeityRodcetNife,
|
/*3263*/ DeityTheTribunal,
|
||||||
DeitySolusekRo,
|
/*3264*/ DeityTunare,
|
||||||
DeityTheTribunal,
|
/*3265*/ DeityVeeshan,
|
||||||
DeityTunare,
|
/*3250*/ DeityAgnostic = 396
|
||||||
DeityVeeshan,
|
};
|
||||||
DeityAgnostic = 396
|
|
||||||
};
|
|
||||||
|
|
||||||
enum DeityTypeBit : uint32 {
|
/*
|
||||||
bit_DeityNone = 0x00000000,
|
** Deity type bits
|
||||||
bit_DeityAgnostic = 0x00000001,
|
**
|
||||||
bit_DeityBertoxxulous = 0x00000002,
|
** (New orphan, but make use of it!)
|
||||||
bit_DeityBrellSirilis = 0x00000004,
|
*/
|
||||||
bit_DeityCazicThule = 0x00000008,
|
enum DeityTypeBits : uint32
|
||||||
bit_DeityErollisiMarr = 0x00000010,
|
{
|
||||||
bit_DeityBristlebane = 0x00000020,
|
BIT_DeityAll = 0x00000000,
|
||||||
bit_DeityInnoruuk = 0x00000040,
|
BIT_DeityAgnostic = 0x00000001,
|
||||||
bit_DeityKarana = 0x00000080,
|
BIT_DeityBertoxxulous = 0x00000002,
|
||||||
bit_DeityMithanielMarr = 0x00000100,
|
BIT_DeityBrellSirilis = 0x00000004,
|
||||||
bit_DeityPrexus = 0x00000200,
|
BIT_DeityCazicThule = 0x00000008,
|
||||||
bit_DeityQuellious = 0x00000400,
|
BIT_DeityErollisiMarr = 0x00000010,
|
||||||
bit_DeityRallosZek = 0x00000800,
|
BIT_DeityBristlebane = 0x00000020,
|
||||||
bit_DeityRodcetNife = 0x00001000,
|
BIT_DeityInnoruuk = 0x00000040,
|
||||||
bit_DeitySolusekRo = 0x00002000,
|
BIT_DeityKarana = 0x00000080,
|
||||||
bit_DeityTheTribunal = 0x00004000,
|
BIT_DeityMithanielMarr = 0x00000100,
|
||||||
bit_DeityTunare = 0x00008000,
|
BIT_DeityPrexus = 0x00000200,
|
||||||
bit_DeityVeeshan = 0x00010000,
|
BIT_DeityQuellious = 0x00000400,
|
||||||
bit_DeityAll = 0xFFFFFFFF
|
BIT_DeityRallosZek = 0x00000800,
|
||||||
};
|
BIT_DeityRodcetNife = 0x00001000,
|
||||||
|
BIT_DeitySolusekRo = 0x00002000,
|
||||||
|
BIT_DeityTheTribunal = 0x00004000,
|
||||||
|
BIT_DeityTunare = 0x00008000,
|
||||||
|
BIT_DeityVeeshan = 0x00010000
|
||||||
|
};
|
||||||
|
|
||||||
extern DeityTypeBit ConvertDeityTypeToDeityTypeBit(DeityType deity_type);
|
static DeityTypeBits ConvertDeityToBitDeity(DeityTypes deity)
|
||||||
extern DeityType ConvertDeityTypeBitToDeityType(DeityTypeBit deity_type_bit);
|
{
|
||||||
extern const char* DeityName(DeityType deity_type);
|
switch(deity)
|
||||||
|
{
|
||||||
|
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: { break; }
|
||||||
|
};
|
||||||
|
|
||||||
} /*deity*/
|
return BIT_DeityAll;
|
||||||
|
};
|
||||||
|
|
||||||
} /*EQEmu*/
|
static DeityTypes ConvertBitDeityToDeity(DeityTypeBits deity_bit)
|
||||||
|
{
|
||||||
|
switch(deity_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: { break; }
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* COMMON_DEITY_H */
|
return DeityUnknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string GetDeityName(DeityTypes deity)
|
||||||
|
{
|
||||||
|
switch(deity)
|
||||||
|
{
|
||||||
|
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: { break; }
|
||||||
|
};
|
||||||
|
|
||||||
|
return "Unknown";
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -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,337 +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 DevTools {
|
|
||||||
const int32 GM_ACCOUNT_STATUS_LEVEL = 150;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace consent {
|
|
||||||
enum eConsentType : uint8 {
|
|
||||||
Normal = 0,
|
|
||||||
Group,
|
|
||||||
Raid,
|
|
||||||
Guild
|
|
||||||
};
|
|
||||||
}; // namespace consent
|
|
||||||
|
|
||||||
} /*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*/
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global_define.h"
|
#include "debug.h"
|
||||||
#include "emu_opcodes.h"
|
#include "emu_opcodes.h"
|
||||||
|
|
||||||
const char *OpcodeNames[_maxEmuOpcode+1] = {
|
const char *OpcodeNames[_maxEmuOpcode+1] = {
|
||||||
|
|||||||
+2
-23
@@ -9,7 +9,6 @@ N(OP_AcceptNewTask),
|
|||||||
N(OP_AckPacket),
|
N(OP_AckPacket),
|
||||||
N(OP_Action),
|
N(OP_Action),
|
||||||
N(OP_Action2),
|
N(OP_Action2),
|
||||||
N(OP_AddNimbusEffect),
|
|
||||||
N(OP_AdventureData),
|
N(OP_AdventureData),
|
||||||
N(OP_AdventureDetails),
|
N(OP_AdventureDetails),
|
||||||
N(OP_AdventureFinish),
|
N(OP_AdventureFinish),
|
||||||
@@ -26,9 +25,6 @@ N(OP_AdventureRequest),
|
|||||||
N(OP_AdventureStatsReply),
|
N(OP_AdventureStatsReply),
|
||||||
N(OP_AdventureStatsRequest),
|
N(OP_AdventureStatsRequest),
|
||||||
N(OP_AdventureUpdate),
|
N(OP_AdventureUpdate),
|
||||||
N(OP_AggroMeterLockTarget),
|
|
||||||
N(OP_AggroMeterTargetInfo),
|
|
||||||
N(OP_AggroMeterUpdate),
|
|
||||||
N(OP_AltCurrency),
|
N(OP_AltCurrency),
|
||||||
N(OP_AltCurrencyMerchantReply),
|
N(OP_AltCurrencyMerchantReply),
|
||||||
N(OP_AltCurrencyMerchantRequest),
|
N(OP_AltCurrencyMerchantRequest),
|
||||||
@@ -68,7 +64,6 @@ N(OP_BuffRemoveRequest),
|
|||||||
N(OP_Bug),
|
N(OP_Bug),
|
||||||
N(OP_CameraEffect),
|
N(OP_CameraEffect),
|
||||||
N(OP_Camp),
|
N(OP_Camp),
|
||||||
N(OP_CancelSneakHide),
|
|
||||||
N(OP_CancelTask),
|
N(OP_CancelTask),
|
||||||
N(OP_CancelTrade),
|
N(OP_CancelTrade),
|
||||||
N(OP_CastSpell),
|
N(OP_CastSpell),
|
||||||
@@ -79,9 +74,7 @@ N(OP_CharacterCreateRequest),
|
|||||||
N(OP_CharInventory),
|
N(OP_CharInventory),
|
||||||
N(OP_Charm),
|
N(OP_Charm),
|
||||||
N(OP_ChatMessage),
|
N(OP_ChatMessage),
|
||||||
N(OP_ClearAA),
|
|
||||||
N(OP_ClearBlockedBuffs),
|
N(OP_ClearBlockedBuffs),
|
||||||
N(OP_ClearLeadershipAbilities),
|
|
||||||
N(OP_ClearNPCMarks),
|
N(OP_ClearNPCMarks),
|
||||||
N(OP_ClearObject),
|
N(OP_ClearObject),
|
||||||
N(OP_ClearSurname),
|
N(OP_ClearSurname),
|
||||||
@@ -169,7 +162,6 @@ N(OP_FinishTrade),
|
|||||||
N(OP_FinishWindow),
|
N(OP_FinishWindow),
|
||||||
N(OP_FinishWindow2),
|
N(OP_FinishWindow2),
|
||||||
N(OP_Fishing),
|
N(OP_Fishing),
|
||||||
N(OP_Fling),
|
|
||||||
N(OP_FloatListThing),
|
N(OP_FloatListThing),
|
||||||
N(OP_Forage),
|
N(OP_Forage),
|
||||||
N(OP_ForceFindPerson),
|
N(OP_ForceFindPerson),
|
||||||
@@ -215,13 +207,11 @@ N(OP_GroupInvite2),
|
|||||||
N(OP_GroupLeaderChange),
|
N(OP_GroupLeaderChange),
|
||||||
N(OP_GroupLeadershipAAUpdate),
|
N(OP_GroupLeadershipAAUpdate),
|
||||||
N(OP_GroupMakeLeader),
|
N(OP_GroupMakeLeader),
|
||||||
N(OP_GroupMentor),
|
|
||||||
N(OP_GroupRoles),
|
N(OP_GroupRoles),
|
||||||
N(OP_GroupUpdate),
|
N(OP_GroupUpdate),
|
||||||
N(OP_GroupUpdateB),
|
N(OP_GroupUpdateB),
|
||||||
N(OP_GroupUpdateLeaderAA),
|
N(OP_GroupUpdateLeaderAA),
|
||||||
N(OP_GuildBank),
|
N(OP_GuildBank),
|
||||||
N(OP_GuildBankItemList),
|
|
||||||
N(OP_GuildCreate),
|
N(OP_GuildCreate),
|
||||||
N(OP_GuildDelete),
|
N(OP_GuildDelete),
|
||||||
N(OP_GuildDemote),
|
N(OP_GuildDemote),
|
||||||
@@ -254,7 +244,6 @@ N(OP_IncreaseStats),
|
|||||||
N(OP_InitialHPUpdate),
|
N(OP_InitialHPUpdate),
|
||||||
N(OP_InitialMobHealth),
|
N(OP_InitialMobHealth),
|
||||||
N(OP_InspectAnswer),
|
N(OP_InspectAnswer),
|
||||||
N(OP_InspectBuffs),
|
|
||||||
N(OP_InspectMessageUpdate),
|
N(OP_InspectMessageUpdate),
|
||||||
N(OP_InspectRequest),
|
N(OP_InspectRequest),
|
||||||
N(OP_InstillDoubt),
|
N(OP_InstillDoubt),
|
||||||
@@ -293,7 +282,6 @@ N(OP_LFGuild),
|
|||||||
N(OP_LFPCommand),
|
N(OP_LFPCommand),
|
||||||
N(OP_LFPGetMatchesRequest),
|
N(OP_LFPGetMatchesRequest),
|
||||||
N(OP_LFPGetMatchesResponse),
|
N(OP_LFPGetMatchesResponse),
|
||||||
N(OP_LinkedReuse),
|
|
||||||
N(OP_LoadSpellSet),
|
N(OP_LoadSpellSet),
|
||||||
N(OP_LocInfo),
|
N(OP_LocInfo),
|
||||||
N(OP_LockoutTimerInfo),
|
N(OP_LockoutTimerInfo),
|
||||||
@@ -340,7 +328,6 @@ N(OP_MOTD),
|
|||||||
N(OP_MoveCoin),
|
N(OP_MoveCoin),
|
||||||
N(OP_MoveDoor),
|
N(OP_MoveDoor),
|
||||||
N(OP_MoveItem),
|
N(OP_MoveItem),
|
||||||
N(OP_MoveMultipleItems),
|
|
||||||
N(OP_MoveLogDisregard),
|
N(OP_MoveLogDisregard),
|
||||||
N(OP_MoveLogRequest),
|
N(OP_MoveLogRequest),
|
||||||
N(OP_MultiLineMsg),
|
N(OP_MultiLineMsg),
|
||||||
@@ -357,8 +344,6 @@ N(OP_OpenTributeMaster),
|
|||||||
N(OP_PDeletePetition),
|
N(OP_PDeletePetition),
|
||||||
N(OP_PetBuffWindow),
|
N(OP_PetBuffWindow),
|
||||||
N(OP_PetCommands),
|
N(OP_PetCommands),
|
||||||
N(OP_PetCommandState),
|
|
||||||
N(OP_PetHoTT),
|
|
||||||
N(OP_Petition),
|
N(OP_Petition),
|
||||||
N(OP_PetitionBug),
|
N(OP_PetitionBug),
|
||||||
N(OP_PetitionCheckIn),
|
N(OP_PetitionCheckIn),
|
||||||
@@ -375,8 +360,6 @@ N(OP_PetitionUnCheckout),
|
|||||||
N(OP_PetitionUpdate),
|
N(OP_PetitionUpdate),
|
||||||
N(OP_PickPocket),
|
N(OP_PickPocket),
|
||||||
N(OP_PlayerProfile),
|
N(OP_PlayerProfile),
|
||||||
N(OP_PlayerStateAdd),
|
|
||||||
N(OP_PlayerStateRemove),
|
|
||||||
N(OP_PlayEverquestRequest),
|
N(OP_PlayEverquestRequest),
|
||||||
N(OP_PlayEverquestResponse),
|
N(OP_PlayEverquestResponse),
|
||||||
N(OP_PlayMP3),
|
N(OP_PlayMP3),
|
||||||
@@ -393,7 +376,6 @@ N(OP_PVPLeaderBoardReply),
|
|||||||
N(OP_PVPLeaderBoardRequest),
|
N(OP_PVPLeaderBoardRequest),
|
||||||
N(OP_PVPStats),
|
N(OP_PVPStats),
|
||||||
N(OP_QueryResponseThing),
|
N(OP_QueryResponseThing),
|
||||||
N(OP_QueryUCSServerStatus),
|
|
||||||
N(OP_RaidInvite),
|
N(OP_RaidInvite),
|
||||||
N(OP_RaidJoin),
|
N(OP_RaidJoin),
|
||||||
N(OP_RaidUpdate),
|
N(OP_RaidUpdate),
|
||||||
@@ -411,7 +393,6 @@ N(OP_ReloadUI),
|
|||||||
N(OP_RemoveAllDoors),
|
N(OP_RemoveAllDoors),
|
||||||
N(OP_RemoveBlockedBuffs),
|
N(OP_RemoveBlockedBuffs),
|
||||||
N(OP_RemoveNimbusEffect),
|
N(OP_RemoveNimbusEffect),
|
||||||
N(OP_RemoveTrap),
|
|
||||||
N(OP_Report),
|
N(OP_Report),
|
||||||
N(OP_ReqClientSpawn),
|
N(OP_ReqClientSpawn),
|
||||||
N(OP_ReqNewZone),
|
N(OP_ReqNewZone),
|
||||||
@@ -527,7 +508,6 @@ N(OP_TributeToggle),
|
|||||||
N(OP_TributeUpdate),
|
N(OP_TributeUpdate),
|
||||||
N(OP_Untargetable),
|
N(OP_Untargetable),
|
||||||
N(OP_UpdateAA),
|
N(OP_UpdateAA),
|
||||||
N(OP_UpdateAura),
|
|
||||||
N(OP_UpdateLeadershipAA),
|
N(OP_UpdateLeadershipAA),
|
||||||
N(OP_VetClaimReply),
|
N(OP_VetClaimReply),
|
||||||
N(OP_VetClaimRequest),
|
N(OP_VetClaimRequest),
|
||||||
@@ -535,6 +515,8 @@ N(OP_VetRewardsAvaliable),
|
|||||||
N(OP_VoiceMacroIn),
|
N(OP_VoiceMacroIn),
|
||||||
N(OP_VoiceMacroOut),
|
N(OP_VoiceMacroOut),
|
||||||
N(OP_WeaponEquip1),
|
N(OP_WeaponEquip1),
|
||||||
|
N(OP_WeaponEquip2),
|
||||||
|
N(OP_WeaponUnequip2),
|
||||||
N(OP_WearChange),
|
N(OP_WearChange),
|
||||||
N(OP_Weather),
|
N(OP_Weather),
|
||||||
N(OP_Weblink),
|
N(OP_Weblink),
|
||||||
@@ -548,8 +530,6 @@ N(OP_WorldLogout),
|
|||||||
N(OP_WorldObjectsSent),
|
N(OP_WorldObjectsSent),
|
||||||
N(OP_WorldUnknown001),
|
N(OP_WorldUnknown001),
|
||||||
N(OP_XTargetAutoAddHaters),
|
N(OP_XTargetAutoAddHaters),
|
||||||
N(OP_XTargetOpen),
|
|
||||||
N(OP_XTargetOpenResponse),
|
|
||||||
N(OP_XTargetRequest),
|
N(OP_XTargetRequest),
|
||||||
N(OP_XTargetResponse),
|
N(OP_XTargetResponse),
|
||||||
N(OP_YellForHelp),
|
N(OP_YellForHelp),
|
||||||
@@ -563,5 +543,4 @@ N(OP_ZoneServerInfo),
|
|||||||
N(OP_ZoneServerReady),
|
N(OP_ZoneServerReady),
|
||||||
N(OP_ZoneSpawns),
|
N(OP_ZoneSpawns),
|
||||||
N(OP_ZoneUnavail),
|
N(OP_ZoneUnavail),
|
||||||
N(OP_ResetAA),
|
|
||||||
// mail and chat opcodes located in ../mail_oplist.h
|
// mail and chat opcodes located in ../mail_oplist.h
|
||||||
|
|||||||
@@ -0,0 +1,820 @@
|
|||||||
|
/* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
There are really two or three different objects shoe-hored into this
|
||||||
|
connection object. Sombody really needs to factor out the relay link
|
||||||
|
crap into its own subclass of this object, it will clean things up
|
||||||
|
tremendously.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../common/debug.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
#include "emu_tcp_connection.h"
|
||||||
|
#include "emu_tcp_server.h"
|
||||||
|
#include "../common/servertalk.h"
|
||||||
|
#include "../common/packet_dump.h"
|
||||||
|
|
||||||
|
#ifdef FREEBSD //Timothy Whitman - January 7, 2003
|
||||||
|
#define MSG_NOSIGNAL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TCPN_DEBUG 0
|
||||||
|
#define TCPN_DEBUG_Console 0
|
||||||
|
#define TCPN_DEBUG_Memory 0
|
||||||
|
#define TCPN_LOG_PACKETS 0
|
||||||
|
#define TCPN_LOG_RAW_DATA_OUT 0
|
||||||
|
#define TCPN_LOG_RAW_DATA_IN 0
|
||||||
|
|
||||||
|
|
||||||
|
//server side case
|
||||||
|
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_socket, uint32 irIP, uint16 irPort, bool iOldFormat)
|
||||||
|
: TCPConnection(ID, in_socket, irIP, irPort),
|
||||||
|
keepalive_timer(SERVER_TIMEOUT),
|
||||||
|
timeout_timer(SERVER_TIMEOUT * 2)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
Server = nullptr;
|
||||||
|
pOldFormat = iOldFormat;
|
||||||
|
#ifdef MINILOGIN
|
||||||
|
TCPMode = modePacket;
|
||||||
|
PacketMode = packetModeLogin;
|
||||||
|
#else
|
||||||
|
if (pOldFormat)
|
||||||
|
TCPMode = modePacket;
|
||||||
|
else
|
||||||
|
TCPMode = modeConsole;
|
||||||
|
PacketMode = packetModeZone;
|
||||||
|
#endif
|
||||||
|
RelayLink = 0;
|
||||||
|
RelayServer = false;
|
||||||
|
RelayCount = 0;
|
||||||
|
RemoteID = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//client outgoing connection case (and client side relay)
|
||||||
|
EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer, eTCPMode iMode)
|
||||||
|
: TCPConnection(),
|
||||||
|
keepalive_timer(SERVER_TIMEOUT),
|
||||||
|
timeout_timer(SERVER_TIMEOUT * 2)
|
||||||
|
{
|
||||||
|
Server = iRelayServer;
|
||||||
|
if (Server)
|
||||||
|
RelayServer = true;
|
||||||
|
else
|
||||||
|
RelayServer = false;
|
||||||
|
RelayLink = 0;
|
||||||
|
RelayCount = 0;
|
||||||
|
RemoteID = 0;
|
||||||
|
pOldFormat = iOldFormat;
|
||||||
|
TCPMode = iMode;
|
||||||
|
PacketMode = packetModeZone;
|
||||||
|
#if TCPN_DEBUG_Memory >= 7
|
||||||
|
std::cout << "Constructor #1 on outgoing TCP# " << GetID() << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//server side relay case
|
||||||
|
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort)
|
||||||
|
: TCPConnection(ID, 0, irIP, irPort),
|
||||||
|
keepalive_timer(SERVER_TIMEOUT),
|
||||||
|
timeout_timer(SERVER_TIMEOUT * 2)
|
||||||
|
{
|
||||||
|
Server = iServer;
|
||||||
|
RelayLink = iRelayLink;
|
||||||
|
RelayServer = true;
|
||||||
|
RelayCount = 0;
|
||||||
|
RemoteID = iRemoteID;
|
||||||
|
pOldFormat = false;
|
||||||
|
ConnectionType = Incomming;
|
||||||
|
TCPMode = modePacket;
|
||||||
|
PacketMode = packetModeZone;
|
||||||
|
#if TCPN_DEBUG_Memory >= 7
|
||||||
|
std::cout << "Constructor #3 on outgoing TCP# " << GetID() << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
EmuTCPConnection::~EmuTCPConnection() {
|
||||||
|
//the queues free their content right now I believe.
|
||||||
|
}
|
||||||
|
|
||||||
|
EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32 iDestination) {
|
||||||
|
int32 size = sizeof(EmuTCPNetPacket_Struct) + pack->size;
|
||||||
|
if (pack->compressed) {
|
||||||
|
size += 4;
|
||||||
|
}
|
||||||
|
if (iDestination) {
|
||||||
|
size += 4;
|
||||||
|
}
|
||||||
|
EmuTCPNetPacket_Struct* tnps = (EmuTCPNetPacket_Struct*) new uchar[size];
|
||||||
|
tnps->size = size;
|
||||||
|
tnps->opcode = pack->opcode;
|
||||||
|
*((uint8*) &tnps->flags) = 0;
|
||||||
|
uchar* buffer = tnps->buffer;
|
||||||
|
if (pack->compressed) {
|
||||||
|
tnps->flags.compressed = 1;
|
||||||
|
*((int32*) buffer) = pack->InflatedSize;
|
||||||
|
buffer += 4;
|
||||||
|
}
|
||||||
|
if (iDestination) {
|
||||||
|
tnps->flags.destination = 1;
|
||||||
|
*((int32*) buffer) = iDestination;
|
||||||
|
buffer += 4;
|
||||||
|
}
|
||||||
|
memcpy(buffer, pack->pBuffer, pack->size);
|
||||||
|
return tnps;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPackSendQueue* EmuTCPConnection::MakeOldPacket(ServerPacket* pack) {
|
||||||
|
SPackSendQueue* spsq = (SPackSendQueue*) new uchar[sizeof(SPackSendQueue) + pack->size + 4];
|
||||||
|
if (pack->pBuffer != 0 && pack->size != 0)
|
||||||
|
memcpy((char *) &spsq->buffer[4], (char *) pack->pBuffer, pack->size);
|
||||||
|
memcpy((char *) &spsq->buffer[0], (char *) &pack->opcode, 2);
|
||||||
|
spsq->size = pack->size+4;
|
||||||
|
memcpy((char *) &spsq->buffer[2], (char *) &spsq->size, 2);
|
||||||
|
return spsq;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
|
||||||
|
if (!Connected())
|
||||||
|
return false;
|
||||||
|
eTCPMode tmp = GetMode();
|
||||||
|
if (tmp != modePacket && tmp != modeTransition)
|
||||||
|
return false;
|
||||||
|
LockMutex lock(&MState);
|
||||||
|
if (RemoteID)
|
||||||
|
return RelayLink->SendPacket(pack, RemoteID);
|
||||||
|
else if (pOldFormat) {
|
||||||
|
#if TCPN_LOG_PACKETS >= 1
|
||||||
|
if (pack && pack->opcode != 0) {
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = GetrIP();
|
||||||
|
CoutTimestamp(true);
|
||||||
|
std::cout << ": Logging outgoing TCP OldPacket. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||||
|
#if TCPN_LOG_PACKETS == 2
|
||||||
|
if (pack->size >= 32)
|
||||||
|
DumpPacket(pack->pBuffer, 32);
|
||||||
|
else
|
||||||
|
DumpPacket(pack);
|
||||||
|
#endif
|
||||||
|
#if TCPN_LOG_PACKETS >= 3
|
||||||
|
DumpPacket(pack);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
SPackSendQueue* spsq = MakeOldPacket(pack);
|
||||||
|
ServerSendQueuePushEnd(spsq->buffer, spsq->size);
|
||||||
|
safe_delete_array(spsq);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
EmuTCPNetPacket_Struct* tnps = MakePacket(pack, iDestination);
|
||||||
|
if (tmp == modeTransition) {
|
||||||
|
InModeQueuePush(tnps);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#if TCPN_LOG_PACKETS >= 1
|
||||||
|
if (pack && pack->opcode != 0) {
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = GetrIP();
|
||||||
|
CoutTimestamp(true);
|
||||||
|
std::cout << ": Logging outgoing TCP packet. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||||
|
#if TCPN_LOG_PACKETS == 2
|
||||||
|
if (pack->size >= 32)
|
||||||
|
DumpPacket(pack->pBuffer, 32);
|
||||||
|
else
|
||||||
|
DumpPacket(pack);
|
||||||
|
#endif
|
||||||
|
#if TCPN_LOG_PACKETS >= 3
|
||||||
|
DumpPacket(pack);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
ServerSendQueuePushEnd((uchar**) &tnps, tnps->size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
|
||||||
|
if (RemoteID)
|
||||||
|
return false;
|
||||||
|
if (!Connected())
|
||||||
|
return false;
|
||||||
|
if (GetMode() != modePacket)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
LockMutex lock(&MState);
|
||||||
|
eTCPMode tmp = GetMode();
|
||||||
|
if (tmp == modeTransition) {
|
||||||
|
EmuTCPNetPacket_Struct* tnps2 = (EmuTCPNetPacket_Struct*) new uchar[tnps->size];
|
||||||
|
memcpy(tnps2, tnps, tnps->size);
|
||||||
|
InModeQueuePush(tnps2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#if TCPN_LOG_PACKETS >= 1
|
||||||
|
if (tnps && tnps->opcode != 0) {
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = GetrIP();
|
||||||
|
CoutTimestamp(true);
|
||||||
|
std::cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << tnps->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
|
||||||
|
if (pOldFormat)
|
||||||
|
std::cout << " (OldFormat)";
|
||||||
|
std::cout << std::endl;
|
||||||
|
#if TCPN_LOG_PACKETS == 2
|
||||||
|
if (tnps->size >= 32)
|
||||||
|
DumpPacket((uchar*) tnps, 32);
|
||||||
|
else
|
||||||
|
DumpPacket((uchar*) tnps, tnps->size);
|
||||||
|
#endif
|
||||||
|
#if TCPN_LOG_PACKETS >= 3
|
||||||
|
DumpPacket((uchar*) tnps, tnps->size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
ServerSendQueuePushEnd((const uchar*) tnps, tnps->size);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerPacket* EmuTCPConnection::PopPacket() {
|
||||||
|
ServerPacket* ret;
|
||||||
|
if (!MOutQueueLock.trylock())
|
||||||
|
return nullptr;
|
||||||
|
ret = OutQueue.pop();
|
||||||
|
MOutQueueLock.unlock();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPConnection::InModeQueuePush(EmuTCPNetPacket_Struct* tnps) {
|
||||||
|
MSendQueue.lock();
|
||||||
|
InModeQueue.push(tnps);
|
||||||
|
MSendQueue.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPConnection::OutQueuePush(ServerPacket* pack) {
|
||||||
|
MOutQueueLock.lock();
|
||||||
|
OutQueue.push(pack);
|
||||||
|
MOutQueueLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool EmuTCPConnection::LineOutQueuePush(char* line) {
|
||||||
|
#if defined(GOTFRAGS) && 0
|
||||||
|
if (strcmp(line, "**CRASHME**") == 0) {
|
||||||
|
int i = 0;
|
||||||
|
std::cout << (5 / i) << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if(line[0] == '*') {
|
||||||
|
if (strcmp(line, "**PACKETMODE**") == 0) {
|
||||||
|
MSendQueue.lock();
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
if (TCPMode == modeConsole)
|
||||||
|
Send((const uchar*) "\0**PACKETMODE**\r", 16);
|
||||||
|
TCPMode = modePacket;
|
||||||
|
PacketMode = packetModeLogin;
|
||||||
|
EmuTCPNetPacket_Struct* tnps = 0;
|
||||||
|
while ((tnps = InModeQueue.pop())) {
|
||||||
|
SendPacket(tnps);
|
||||||
|
safe_delete_array(tnps);
|
||||||
|
}
|
||||||
|
MSendQueue.unlock();
|
||||||
|
safe_delete_array(line);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
if (strcmp(line, "**PACKETMODEZONE**") == 0) {
|
||||||
|
MSendQueue.lock();
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
if (TCPMode == modeConsole)
|
||||||
|
Send((const uchar*) "\0**PACKETMODEZONE**\r", 20);
|
||||||
|
TCPMode = modePacket;
|
||||||
|
PacketMode = packetModeZone;
|
||||||
|
EmuTCPNetPacket_Struct* tnps = 0;
|
||||||
|
while ((tnps = InModeQueue.pop())) {
|
||||||
|
SendPacket(tnps);
|
||||||
|
safe_delete_array(tnps);
|
||||||
|
}
|
||||||
|
MSendQueue.unlock();
|
||||||
|
safe_delete_array(line);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
if (strcmp(line, "**PACKETMODELAUNCHER**") == 0) {
|
||||||
|
MSendQueue.lock();
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
if (TCPMode == modeConsole)
|
||||||
|
Send((const uchar*) "\0**PACKETMODELAUNCHER**\r", 24);
|
||||||
|
TCPMode = modePacket;
|
||||||
|
PacketMode = packetModeLauncher;
|
||||||
|
EmuTCPNetPacket_Struct* tnps = 0;
|
||||||
|
while ((tnps = InModeQueue.pop())) {
|
||||||
|
SendPacket(tnps);
|
||||||
|
safe_delete_array(tnps);
|
||||||
|
}
|
||||||
|
MSendQueue.unlock();
|
||||||
|
safe_delete_array(line);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
if (strcmp(line, "**PACKETMODEUCS**") == 0) {
|
||||||
|
MSendQueue.lock();
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
if (TCPMode == modeConsole)
|
||||||
|
Send((const uchar*) "\0**PACKETMODEUCS**\r", 19);
|
||||||
|
TCPMode = modePacket;
|
||||||
|
PacketMode = packetModeUCS;
|
||||||
|
EmuTCPNetPacket_Struct* tnps = 0;
|
||||||
|
while ((tnps = InModeQueue.pop())) {
|
||||||
|
SendPacket(tnps);
|
||||||
|
safe_delete_array(tnps);
|
||||||
|
}
|
||||||
|
MSendQueue.unlock();
|
||||||
|
safe_delete_array(line);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
if (strcmp(line, "**PACKETMODEQS**") == 0) {
|
||||||
|
MSendQueue.lock();
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
if (TCPMode == modeConsole)
|
||||||
|
Send((const uchar*) "\0**PACKETMODEQS**\r", 18);
|
||||||
|
TCPMode = modePacket;
|
||||||
|
PacketMode = packetModeQueryServ;
|
||||||
|
EmuTCPNetPacket_Struct* tnps = 0;
|
||||||
|
while ((tnps = InModeQueue.pop())) {
|
||||||
|
SendPacket(tnps);
|
||||||
|
safe_delete_array(tnps);
|
||||||
|
}
|
||||||
|
MSendQueue.unlock();
|
||||||
|
safe_delete_array(line);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(TCPConnection::LineOutQueuePush(line));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
|
||||||
|
TCPConnection::Disconnect();
|
||||||
|
|
||||||
|
if (RelayLink) {
|
||||||
|
RelayLink->RemoveRelay(this, iSendRelayDisconnect);
|
||||||
|
RelayLink = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
|
||||||
|
if(!TCPConnection::ConnectIP(irIP, irPort, errbuf))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
MSendQueue.lock();
|
||||||
|
#ifdef MINILOGIN
|
||||||
|
TCPMode = modePacket;
|
||||||
|
#else
|
||||||
|
if (pOldFormat) {
|
||||||
|
TCPMode = modePacket;
|
||||||
|
}
|
||||||
|
else if (TCPMode == modePacket || TCPMode == modeTransition) {
|
||||||
|
TCPMode = modeTransition;
|
||||||
|
if(PacketMode == packetModeLauncher) {
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
sendbuf_size = 24;
|
||||||
|
sendbuf_used = sendbuf_size;
|
||||||
|
sendbuf = new uchar[sendbuf_size];
|
||||||
|
memcpy(sendbuf, "\0**PACKETMODELAUNCHER**\r", sendbuf_size);
|
||||||
|
} else if(PacketMode == packetModeLogin) {
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
sendbuf_size = 16;
|
||||||
|
sendbuf_used = sendbuf_size;
|
||||||
|
sendbuf = new uchar[sendbuf_size];
|
||||||
|
memcpy(sendbuf, "\0**PACKETMODE**\r", sendbuf_size);
|
||||||
|
} else if(PacketMode == packetModeUCS) {
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
sendbuf_size = 19;
|
||||||
|
sendbuf_used = sendbuf_size;
|
||||||
|
sendbuf = new uchar[sendbuf_size];
|
||||||
|
memcpy(sendbuf, "\0**PACKETMODEUCS**\r", sendbuf_size);
|
||||||
|
}
|
||||||
|
else if(PacketMode == packetModeQueryServ) {
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
sendbuf_size = 18;
|
||||||
|
sendbuf_used = sendbuf_size;
|
||||||
|
sendbuf = new uchar[sendbuf_size];
|
||||||
|
memcpy(sendbuf, "\0**PACKETMODEQS**\r", sendbuf_size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//default: packetModeZone
|
||||||
|
safe_delete_array(sendbuf);
|
||||||
|
sendbuf_size = 20;
|
||||||
|
sendbuf_used = sendbuf_size;
|
||||||
|
sendbuf = new uchar[sendbuf_size];
|
||||||
|
memcpy(sendbuf, "\0**PACKETMODEZONE**\r", sendbuf_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
MSendQueue.unlock();
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPConnection::ClearBuffers() {
|
||||||
|
TCPConnection::ClearBuffers();
|
||||||
|
|
||||||
|
LockMutex lock2(&MOutQueueLock);
|
||||||
|
ServerPacket* pack = 0;
|
||||||
|
while ((pack = OutQueue.pop()))
|
||||||
|
safe_delete(pack);
|
||||||
|
|
||||||
|
EmuTCPNetPacket_Struct* tnps = 0;
|
||||||
|
while ((tnps = InModeQueue.pop()))
|
||||||
|
safe_delete(tnps);
|
||||||
|
|
||||||
|
keepalive_timer.Start();
|
||||||
|
timeout_timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
|
||||||
|
#if TCPC_DEBUG >= 1
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = GetrIP();
|
||||||
|
std::cout "NetError: '";
|
||||||
|
if (reason)
|
||||||
|
std::cout << reason;
|
||||||
|
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
|
||||||
|
#endif
|
||||||
|
ServerPacket* pack = new ServerPacket(0);
|
||||||
|
pack->size = 1;
|
||||||
|
if (reason)
|
||||||
|
pack->size += strlen(reason) + 1;
|
||||||
|
pack->pBuffer = new uchar[pack->size];
|
||||||
|
memset(pack->pBuffer, 0, pack->size);
|
||||||
|
pack->pBuffer[0] = 255;
|
||||||
|
strcpy((char*) &pack->pBuffer[1], reason);
|
||||||
|
SendPacket(pack);
|
||||||
|
safe_delete(pack);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPConnection::RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect) {
|
||||||
|
if (iSendRelayDisconnect) {
|
||||||
|
ServerPacket* pack = new ServerPacket(0, 5);
|
||||||
|
pack->pBuffer[0] = 3;
|
||||||
|
*((uint32*) &pack->pBuffer[1]) = relay->GetRemoteID();
|
||||||
|
SendPacket(pack);
|
||||||
|
safe_delete(pack);
|
||||||
|
}
|
||||||
|
RelayCount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool EmuTCPConnection::ProcessReceivedData(char* errbuf) {
|
||||||
|
if (errbuf)
|
||||||
|
errbuf[0] = 0;
|
||||||
|
timeout_timer.Start();
|
||||||
|
if (!recvbuf)
|
||||||
|
return true;
|
||||||
|
if (TCPMode == modePacket) {
|
||||||
|
if (pOldFormat)
|
||||||
|
return ProcessReceivedDataAsOldPackets(errbuf);
|
||||||
|
else
|
||||||
|
return ProcessReceivedDataAsPackets(errbuf);
|
||||||
|
}
|
||||||
|
//else, use the base class's text processing.
|
||||||
|
bool ret = TCPConnection::ProcessReceivedData(errbuf);
|
||||||
|
//see if we made the transition to packet mode...
|
||||||
|
if(ret && TCPMode == modePacket) {
|
||||||
|
return ProcessReceivedDataAsPackets(errbuf);
|
||||||
|
}
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
|
||||||
|
if (errbuf)
|
||||||
|
errbuf[0] = 0;
|
||||||
|
int32 base = 0;
|
||||||
|
int32 size = 7;
|
||||||
|
uchar* buffer;
|
||||||
|
ServerPacket* pack = 0;
|
||||||
|
while ((recvbuf_used - base) >= size) {
|
||||||
|
EmuTCPNetPacket_Struct* tnps = (EmuTCPNetPacket_Struct*) &recvbuf[base];
|
||||||
|
buffer = tnps->buffer;
|
||||||
|
size = tnps->size;
|
||||||
|
if (size >= MaxTCPReceiveBuffferSize) {
|
||||||
|
#if TCPN_DEBUG_Memory >= 1
|
||||||
|
std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
|
||||||
|
DumpPacket(&recvbuf[base], 16);
|
||||||
|
#endif
|
||||||
|
if (errbuf)
|
||||||
|
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ((recvbuf_used - base) >= size) {
|
||||||
|
// ok, we got enough data to make this packet!
|
||||||
|
pack = new ServerPacket;
|
||||||
|
pack->size = size - sizeof(EmuTCPNetPacket_Struct);
|
||||||
|
// read headers
|
||||||
|
pack->opcode = tnps->opcode;
|
||||||
|
if (tnps->flags.compressed) {
|
||||||
|
pack->compressed = true;
|
||||||
|
pack->InflatedSize = *((int32*)buffer);
|
||||||
|
pack->size -= 4;
|
||||||
|
buffer += 4;
|
||||||
|
}
|
||||||
|
if (tnps->flags.destination) {
|
||||||
|
pack->destination = *((int32*)buffer);
|
||||||
|
pack->size -= 4;
|
||||||
|
buffer += 4;
|
||||||
|
}
|
||||||
|
// end read headers
|
||||||
|
if (pack->size > 0) {
|
||||||
|
if (tnps->flags.compressed) {
|
||||||
|
// Lets decompress the packet here
|
||||||
|
pack->compressed = false;
|
||||||
|
pack->pBuffer = new uchar[pack->InflatedSize];
|
||||||
|
pack->size = InflatePacket(buffer, pack->size, pack->pBuffer, pack->InflatedSize);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pack->pBuffer = new uchar[pack->size];
|
||||||
|
memcpy(pack->pBuffer, buffer, pack->size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pack->opcode == 0) {
|
||||||
|
if (pack->size) {
|
||||||
|
#if TCPN_DEBUG >= 2
|
||||||
|
std::cout << "Received TCP Network layer packet" << std::endl;
|
||||||
|
#endif
|
||||||
|
ProcessNetworkLayerPacket(pack);
|
||||||
|
}
|
||||||
|
#if TCPN_DEBUG >= 5
|
||||||
|
else {
|
||||||
|
std::cout << "Received TCP keepalive packet. (opcode=0)" << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// keepalive, no need to process
|
||||||
|
safe_delete(pack);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#if TCPN_LOG_PACKETS >= 1
|
||||||
|
if (pack && pack->opcode != 0) {
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = GetrIP();
|
||||||
|
CoutTimestamp(true);
|
||||||
|
std::cout << ": Logging incoming TCP packet. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||||
|
#if TCPN_LOG_PACKETS == 2
|
||||||
|
if (pack->size >= 32)
|
||||||
|
DumpPacket(pack->pBuffer, 32);
|
||||||
|
else
|
||||||
|
DumpPacket(pack);
|
||||||
|
#endif
|
||||||
|
#if TCPN_LOG_PACKETS >= 3
|
||||||
|
DumpPacket(pack);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (RelayServer && Server && pack->destination) {
|
||||||
|
EmuTCPConnection* con = Server->FindConnection(pack->destination);
|
||||||
|
if (!con) {
|
||||||
|
#if TCPN_DEBUG >= 1
|
||||||
|
std::cout << "Error relaying packet: con = 0" << std::endl;
|
||||||
|
#endif
|
||||||
|
safe_delete(pack);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
con->OutQueuePush(pack);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
OutQueuePush(pack);
|
||||||
|
}
|
||||||
|
base += size;
|
||||||
|
size = 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (base != 0) {
|
||||||
|
if (base >= recvbuf_used) {
|
||||||
|
safe_delete_array(recvbuf);
|
||||||
|
} else {
|
||||||
|
uchar* tmpbuf = new uchar[recvbuf_size - base];
|
||||||
|
memcpy(tmpbuf, &recvbuf[base], recvbuf_used - base);
|
||||||
|
safe_delete_array(recvbuf);
|
||||||
|
recvbuf = tmpbuf;
|
||||||
|
recvbuf_used -= base;
|
||||||
|
recvbuf_size -= base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
|
||||||
|
int32 base = 0;
|
||||||
|
int32 size = 4;
|
||||||
|
uchar* buffer;
|
||||||
|
ServerPacket* pack = 0;
|
||||||
|
while ((recvbuf_used - base) >= size) {
|
||||||
|
buffer = &recvbuf[base];
|
||||||
|
memcpy(&size, &buffer[2], 2);
|
||||||
|
if (size >= MaxTCPReceiveBuffferSize) {
|
||||||
|
#if TCPN_DEBUG_Memory >= 1
|
||||||
|
std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
|
||||||
|
#endif
|
||||||
|
if (errbuf)
|
||||||
|
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ((recvbuf_used - base) >= size) {
|
||||||
|
// ok, we got enough data to make this packet!
|
||||||
|
pack = new ServerPacket;
|
||||||
|
memcpy(&pack->opcode, &buffer[0], 2);
|
||||||
|
pack->size = size - 4;
|
||||||
|
/* if () { // TODO: Checksum or size check or something similar
|
||||||
|
// Datastream corruption, get the hell outta here!
|
||||||
|
delete pack;
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
if (pack->size > 0) {
|
||||||
|
pack->pBuffer = new uchar[pack->size];
|
||||||
|
memcpy(pack->pBuffer, &buffer[4], pack->size);
|
||||||
|
}
|
||||||
|
if (pack->opcode == 0) {
|
||||||
|
// keepalive, no need to process
|
||||||
|
safe_delete(pack);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#if TCPN_LOG_PACKETS >= 1
|
||||||
|
if (pack && pack->opcode != 0) {
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = GetrIP();
|
||||||
|
CoutTimestamp(true);
|
||||||
|
std::cout << ": Logging incoming TCP OldPacket. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||||
|
#if TCPN_LOG_PACKETS == 2
|
||||||
|
if (pack->size >= 32)
|
||||||
|
DumpPacket(pack->pBuffer, 32);
|
||||||
|
else
|
||||||
|
DumpPacket(pack);
|
||||||
|
#endif
|
||||||
|
#if TCPN_LOG_PACKETS >= 3
|
||||||
|
DumpPacket(pack);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
OutQueuePush(pack);
|
||||||
|
}
|
||||||
|
base += size;
|
||||||
|
size = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (base != 0) {
|
||||||
|
if (base >= recvbuf_used) {
|
||||||
|
safe_delete_array(recvbuf);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uchar* tmpbuf = new uchar[recvbuf_size - base];
|
||||||
|
memcpy(tmpbuf, &recvbuf[base], recvbuf_used - base);
|
||||||
|
safe_delete_array(recvbuf);
|
||||||
|
recvbuf = tmpbuf;
|
||||||
|
recvbuf_used -= base;
|
||||||
|
recvbuf_size -= base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
|
||||||
|
uint8 opcode = pack->pBuffer[0];
|
||||||
|
uint8* data = &pack->pBuffer[1];
|
||||||
|
switch (opcode) {
|
||||||
|
case 0: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: { // Switch to RelayServer mode
|
||||||
|
if (pack->size != 1) {
|
||||||
|
SendNetErrorPacket("New RelayClient: wrong size, expected 1");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (RelayServer) {
|
||||||
|
SendNetErrorPacket("Switch to RelayServer mode when already in RelayServer mode");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (RemoteID) {
|
||||||
|
SendNetErrorPacket("Switch to RelayServer mode by a Relay Client");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ConnectionType != Incomming) {
|
||||||
|
SendNetErrorPacket("Switch to RelayServer mode on outgoing connection");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#if TCPC_DEBUG >= 3
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = GetrIP();
|
||||||
|
std::cout << "Switching to RelayServer mode: " << inet_ntoa(in) << ":" << GetPort() << std::endl;
|
||||||
|
#endif
|
||||||
|
RelayServer = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: { // New Relay Client
|
||||||
|
if (!RelayServer) {
|
||||||
|
SendNetErrorPacket("New RelayClient when not in RelayServer mode");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pack->size != 11) {
|
||||||
|
SendNetErrorPacket("New RelayClient: wrong size, expected 11");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ConnectionType != Incomming) {
|
||||||
|
SendNetErrorPacket("New RelayClient: illegal on outgoing connection");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EmuTCPConnection* con = new EmuTCPConnection(Server->GetNextID(), Server, this, *((uint32*) data), *((uint32*) &data[4]), *((uint16*) &data[8]));
|
||||||
|
Server->AddConnection(con);
|
||||||
|
RelayCount++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: { // Delete Relay Client
|
||||||
|
if (!RelayServer) {
|
||||||
|
SendNetErrorPacket("Delete RelayClient when not in RelayServer mode");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pack->size != 5) {
|
||||||
|
SendNetErrorPacket("Delete RelayClient: wrong size, expected 5");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EmuTCPConnection* con = Server->FindConnection(*((uint32*)data));
|
||||||
|
if (con) {
|
||||||
|
if (ConnectionType == Incomming) {
|
||||||
|
if (con->GetRelayLink() != this) {
|
||||||
|
SendNetErrorPacket("Delete RelayClient: RelayLink != this");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
con->Disconnect(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 255: {
|
||||||
|
#if TCPC_DEBUG >= 1
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = GetrIP();
|
||||||
|
std::cout "Received NetError: '";
|
||||||
|
if (pack->size > 1)
|
||||||
|
std::cout << (char*) data;
|
||||||
|
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
|
||||||
|
sent_something = false;
|
||||||
|
if(!TCPConnection::SendData(sent_something, errbuf))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
if(sent_something)
|
||||||
|
keepalive_timer.Start();
|
||||||
|
else if (TCPMode == modePacket && keepalive_timer.Check()) {
|
||||||
|
ServerPacket* pack = new ServerPacket(0, 0);
|
||||||
|
SendPacket(pack);
|
||||||
|
safe_delete(pack);
|
||||||
|
#if TCPN_DEBUG >= 5
|
||||||
|
std::cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EmuTCPConnection::RecvData(char* errbuf) {
|
||||||
|
if(!TCPConnection::RecvData(errbuf)) {
|
||||||
|
if (OutQueue.count())
|
||||||
|
return(true);
|
||||||
|
else
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((TCPMode == modePacket || TCPMode == modeTransition) && timeout_timer.Check()) {
|
||||||
|
if (errbuf)
|
||||||
|
snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Connection timeout");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
#ifndef EmuTCPCONNECTION_H_
|
||||||
|
#define EmuTCPCONNECTION_H_
|
||||||
|
|
||||||
|
#include "tcp_connection.h"
|
||||||
|
#include "timer.h"
|
||||||
|
|
||||||
|
//moved out of TCPConnection:: to be more exportable
|
||||||
|
#pragma pack(1)
|
||||||
|
struct EmuTCPNetPacket_Struct {
|
||||||
|
uint32 size;
|
||||||
|
struct {
|
||||||
|
uint8
|
||||||
|
compressed : 1,
|
||||||
|
destination : 1,
|
||||||
|
flag3 : 1,
|
||||||
|
flag4 : 1,
|
||||||
|
flag5 : 1,
|
||||||
|
flag6 : 1,
|
||||||
|
flag7 : 1,
|
||||||
|
flag8 : 1;
|
||||||
|
} flags;
|
||||||
|
uint16 opcode;
|
||||||
|
uchar buffer[0];
|
||||||
|
};
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
struct SPackSendQueue;
|
||||||
|
class EmuTCPServer;
|
||||||
|
|
||||||
|
class EmuTCPConnection : public TCPConnection {
|
||||||
|
public:
|
||||||
|
enum eTCPMode { modeConsole, modeTransition, modePacket };
|
||||||
|
enum ePacketMode { packetModeZone, packetModeLauncher, packetModeLogin, packetModeUCS, packetModeQueryServ };
|
||||||
|
|
||||||
|
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET iSock, uint32 irIP, uint16 irPort, bool iOldFormat = false);
|
||||||
|
EmuTCPConnection(bool iOldFormat = false, EmuTCPServer* iRelayServer = 0, eTCPMode iMode = modePacket); // for outgoing connections
|
||||||
|
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort); // for relay connections
|
||||||
|
virtual ~EmuTCPConnection();
|
||||||
|
|
||||||
|
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
|
||||||
|
virtual void Disconnect(bool iSendRelayDisconnect = true);
|
||||||
|
|
||||||
|
static EmuTCPNetPacket_Struct* MakePacket(ServerPacket* pack, uint32 iDestination = 0);
|
||||||
|
static SPackSendQueue* MakeOldPacket(ServerPacket* pack);
|
||||||
|
|
||||||
|
virtual bool SendPacket(ServerPacket* pack, uint32 iDestination = 0);
|
||||||
|
virtual bool SendPacket(EmuTCPNetPacket_Struct* tnps);
|
||||||
|
ServerPacket* PopPacket(); // OutQueuePop()
|
||||||
|
void SetPacketMode(ePacketMode mode) { PacketMode = mode; }
|
||||||
|
|
||||||
|
eTCPMode GetMode() const { return TCPMode; }
|
||||||
|
ePacketMode GetPacketMode() const { return(PacketMode); }
|
||||||
|
|
||||||
|
//relay crap:
|
||||||
|
inline bool IsRelayServer() const { return RelayServer; }
|
||||||
|
inline TCPConnection* GetRelayLink() const { return RelayLink; }
|
||||||
|
inline uint32 GetRemoteID() const { return RemoteID; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OutQueuePush(ServerPacket* pack);
|
||||||
|
void RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect);
|
||||||
|
|
||||||
|
void SendNetErrorPacket(const char* reason = 0);
|
||||||
|
|
||||||
|
virtual bool SendData(bool &sent_something, char* errbuf = 0);
|
||||||
|
virtual bool RecvData(char* errbuf = 0);
|
||||||
|
|
||||||
|
virtual bool ProcessReceivedData(char* errbuf = 0);
|
||||||
|
bool ProcessReceivedDataAsPackets(char* errbuf = 0);
|
||||||
|
bool ProcessReceivedDataAsOldPackets(char* errbuf = 0);
|
||||||
|
void ProcessNetworkLayerPacket(ServerPacket* pack);
|
||||||
|
|
||||||
|
virtual bool LineOutQueuePush(char* line);
|
||||||
|
virtual void ClearBuffers();
|
||||||
|
|
||||||
|
EmuTCPServer* Server;
|
||||||
|
|
||||||
|
eTCPMode TCPMode;
|
||||||
|
ePacketMode PacketMode;
|
||||||
|
bool pOldFormat;
|
||||||
|
|
||||||
|
Timer keepalive_timer;
|
||||||
|
Timer timeout_timer;
|
||||||
|
|
||||||
|
//relay crap:
|
||||||
|
EmuTCPConnection* RelayLink;
|
||||||
|
int32 RelayCount;
|
||||||
|
bool RelayServer;
|
||||||
|
uint32 RemoteID;
|
||||||
|
|
||||||
|
//input queue...
|
||||||
|
void InModeQueuePush(EmuTCPNetPacket_Struct* tnps);
|
||||||
|
MyQueue<EmuTCPNetPacket_Struct> InModeQueue;
|
||||||
|
|
||||||
|
//output queue...
|
||||||
|
MyQueue<ServerPacket> OutQueue;
|
||||||
|
Mutex MOutQueueLock;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /*EmuTCPCONNECTION_H_*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
#include "debug.h"
|
||||||
|
#include "emu_tcp_server.h"
|
||||||
|
#include "emu_tcp_connection.h"
|
||||||
|
|
||||||
|
EmuTCPServer::EmuTCPServer(uint16 iPort, bool iOldFormat)
|
||||||
|
: TCPServer<EmuTCPConnection>(iPort),
|
||||||
|
pOldFormat(iOldFormat)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EmuTCPServer::~EmuTCPServer() {
|
||||||
|
MInQueue.lock();
|
||||||
|
while(!m_InQueue.empty()) {
|
||||||
|
delete m_InQueue.front();
|
||||||
|
m_InQueue.pop();
|
||||||
|
}
|
||||||
|
MInQueue.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPServer::Process() {
|
||||||
|
CheckInQueue();
|
||||||
|
TCPServer<EmuTCPConnection>::Process();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPServer::CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
|
||||||
|
{
|
||||||
|
EmuTCPConnection *conn = new EmuTCPConnection(ID, this, in_socket, irIP, irPort, pOldFormat);
|
||||||
|
AddConnection(conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EmuTCPServer::SendPacket(ServerPacket* pack) {
|
||||||
|
EmuTCPNetPacket_Struct* tnps = EmuTCPConnection::MakePacket(pack);
|
||||||
|
SendPacket(&tnps);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPServer::SendPacket(EmuTCPNetPacket_Struct** tnps) {
|
||||||
|
MInQueue.lock();
|
||||||
|
m_InQueue.push(*tnps);
|
||||||
|
MInQueue.unlock();
|
||||||
|
tnps = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuTCPServer::CheckInQueue() {
|
||||||
|
EmuTCPNetPacket_Struct* tnps = 0;
|
||||||
|
|
||||||
|
while (( tnps = InQueuePop() )) {
|
||||||
|
vitr cur, end;
|
||||||
|
cur = m_list.begin();
|
||||||
|
end = m_list.end();
|
||||||
|
for(; cur != end; cur++) {
|
||||||
|
if ((*cur)->GetMode() != EmuTCPConnection::modeConsole && (*cur)->GetRemoteID() == 0)
|
||||||
|
(*cur)->SendPacket(tnps);
|
||||||
|
}
|
||||||
|
safe_delete(tnps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EmuTCPNetPacket_Struct* EmuTCPServer::InQueuePop() {
|
||||||
|
EmuTCPNetPacket_Struct* ret = nullptr;
|
||||||
|
MInQueue.lock();
|
||||||
|
if(!m_InQueue.empty()) {
|
||||||
|
ret = m_InQueue.front();
|
||||||
|
m_InQueue.pop();
|
||||||
|
}
|
||||||
|
MInQueue.unlock();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EmuTCPConnection *EmuTCPServer::FindConnection(uint32 iID) {
|
||||||
|
vitr cur, end;
|
||||||
|
cur = m_list.begin();
|
||||||
|
end = m_list.end();
|
||||||
|
for(; cur != end; cur++) {
|
||||||
|
if ((*cur)->GetID() == iID)
|
||||||
|
return *cur;
|
||||||
|
}
|
||||||
|
return(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef EmuTCPSERVER_H_
|
||||||
|
#define EmuTCPSERVER_H_
|
||||||
|
|
||||||
|
#include "tcp_server.h"
|
||||||
|
|
||||||
|
class EmuTCPConnection;
|
||||||
|
struct EmuTCPNetPacket_Struct;
|
||||||
|
class ServerPacket;
|
||||||
|
|
||||||
|
class EmuTCPServer : public TCPServer<EmuTCPConnection> {
|
||||||
|
public:
|
||||||
|
EmuTCPServer(uint16 iPort = 0, bool iOldFormat = false);
|
||||||
|
virtual ~EmuTCPServer();
|
||||||
|
|
||||||
|
//packet broadcast routines.
|
||||||
|
void SendPacket(ServerPacket* pack);
|
||||||
|
void SendPacket(EmuTCPNetPacket_Struct** tnps);
|
||||||
|
|
||||||
|
//special crap for relay management
|
||||||
|
EmuTCPConnection *FindConnection(uint32 iID);
|
||||||
|
|
||||||
|
//exposed for some crap we pull. Do not call from outside this object.
|
||||||
|
using TCPServer<EmuTCPConnection>::AddConnection;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void Process();
|
||||||
|
|
||||||
|
virtual void CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort);
|
||||||
|
|
||||||
|
bool pOldFormat;
|
||||||
|
|
||||||
|
//broadcast packet queue..
|
||||||
|
void CheckInQueue();
|
||||||
|
Mutex MInQueue;
|
||||||
|
EmuTCPNetPacket_Struct* InQueuePop(); //returns ownership
|
||||||
|
std::queue<EmuTCPNetPacket_Struct *> m_InQueue;
|
||||||
|
};
|
||||||
|
#endif /*EmuTCPSERVER_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*/
|
|
||||||
+629
-190
@@ -1,6 +1,5 @@
|
|||||||
/* EQEMu: Everquest Server Emulator
|
/* EQEMu: Everquest Server Emulator
|
||||||
|
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
|
||||||
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,64 +13,362 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
#ifndef EQ_CONSTANTS_H
|
||||||
#ifndef COMMON_EQ_CONSTANTS_H
|
#define EQ_CONSTANTS_H
|
||||||
#define COMMON_EQ_CONSTANTS_H
|
|
||||||
|
|
||||||
#include "skills.h"
|
#include "skills.h"
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Item attributes
|
||||||
|
**
|
||||||
|
** (There are no grepwin hits other than these declarations... Do they have a use?)
|
||||||
|
*/
|
||||||
|
enum ItemAttributes : uint32
|
||||||
|
{
|
||||||
|
ItemAttrNone = 0x00000000,
|
||||||
|
ItemAttrLore = 0x00000001,
|
||||||
|
ItemAttrArtifact = 0x00000002,
|
||||||
|
ItemAttrSummoned = 0x00000004,
|
||||||
|
ItemAttrMagic = 0x00000008,
|
||||||
|
ItemAttrAugment = 0x00000010,
|
||||||
|
ItemAttrPendingLore = 0x00000020,
|
||||||
|
ItemAttrUnknown = 0xFFFFFFFF
|
||||||
|
};
|
||||||
|
|
||||||
//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)
|
** Item class types
|
||||||
#define AT_WhoLevel 1 // the level that shows up on /who
|
**
|
||||||
#define AT_HPMax 2 // idk
|
*/
|
||||||
#define AT_Invis 3 // 0 = visible, 1 = invisible
|
enum ItemClassTypes
|
||||||
#define AT_PVP 4 // 0 = blue, 1 = pvp (red)
|
{
|
||||||
#define AT_Light 5 // light type emitted by player (lightstone, shiny shield)
|
ItemClassCommon = 0,
|
||||||
#define AT_Anim 14 // 100=standing, 110=sitting, 111=ducking, 115=feigned, 105=looting
|
ItemClassContainer,
|
||||||
#define AT_Sneak 15 // 0 = normal, 1 = sneaking
|
ItemClassBook,
|
||||||
#define AT_SpawnID 16 // server to client, sets player spawn id
|
_ItemClassCount
|
||||||
#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)
|
/*
|
||||||
|
** Item use types
|
||||||
|
**
|
||||||
|
** (ref: database and eqstr_us.txt)
|
||||||
|
**
|
||||||
|
** (Looking at a recent database, it's possible that some of the item values may be off [10-27-2013] -U)
|
||||||
|
*/
|
||||||
|
enum ItemUseTypes : uint8
|
||||||
|
{
|
||||||
|
/*9138*/ ItemType1HSlash = 0,
|
||||||
|
/*9141*/ ItemType2HSlash,
|
||||||
|
/*9140*/ ItemType1HPiercing,
|
||||||
|
/*9139*/ ItemType1HBlunt,
|
||||||
|
/*9142*/ ItemType2HBlunt,
|
||||||
|
/*5504*/ ItemTypeBow,
|
||||||
|
/*----*/ ItemTypeUnknown1,
|
||||||
|
/*----*/ ItemTypeLargeThrowing,
|
||||||
|
/*5505*/ ItemTypeShield,
|
||||||
|
/*5506*/ ItemTypeScroll,
|
||||||
|
/*5507*/ ItemTypeArmor,
|
||||||
|
/*5508*/ ItemTypeMisc, // a lot of random crap has this item use.
|
||||||
|
/*7564*/ ItemTypeLockPick,
|
||||||
|
/*----*/ ItemTypeUnknown2,
|
||||||
|
/*5509*/ ItemTypeFood,
|
||||||
|
/*5510*/ ItemTypeDrink,
|
||||||
|
/*5511*/ ItemTypeLight,
|
||||||
|
/*5512*/ ItemTypeCombinable, // not all stackable items are this use...
|
||||||
|
/*5513*/ ItemTypeBandage,
|
||||||
|
/*----*/ ItemTypeSmallThrowing,
|
||||||
|
/*----*/ ItemTypeSpell, // spells and tomes
|
||||||
|
/*5514*/ ItemTypePotion,
|
||||||
|
/*----*/ ItemTypeUnknown3,
|
||||||
|
/*0406*/ ItemTypeWindInstrument,
|
||||||
|
/*0407*/ ItemTypeStringedInstrument,
|
||||||
|
/*0408*/ ItemTypeBrassInstrument,
|
||||||
|
/*0405*/ ItemTypePercussionInstrument,
|
||||||
|
/*5515*/ ItemTypeArrow,
|
||||||
|
/*----*/ ItemTypeUnknown4,
|
||||||
|
/*5521*/ ItemTypeJewelry,
|
||||||
|
/*----*/ ItemTypeSkull,
|
||||||
|
/*5516*/ ItemTypeBook, // skill-up tomes/books? (would probably need a pp flag if true...)
|
||||||
|
/*5517*/ ItemTypeNote,
|
||||||
|
/*5518*/ ItemTypeKey,
|
||||||
|
/*----*/ ItemTypeCoin,
|
||||||
|
/*5520*/ ItemType2HPiercing,
|
||||||
|
/*----*/ ItemTypeFishingPole,
|
||||||
|
/*----*/ ItemTypeFishingBait,
|
||||||
|
/*5519*/ ItemTypeAlcohol,
|
||||||
|
/*----*/ ItemTypeKey2, // keys and satchels?? (questable keys?)
|
||||||
|
/*----*/ ItemTypeCompass,
|
||||||
|
/*----*/ ItemTypeUnknown5,
|
||||||
|
/*----*/ ItemTypePoison, // might be wrong, but includes poisons
|
||||||
|
/*----*/ ItemTypeUnknown6,
|
||||||
|
/*----*/ ItemTypeUnknown7,
|
||||||
|
/*5522*/ ItemTypeMartial,
|
||||||
|
/*----*/ ItemTypeUnknown8,
|
||||||
|
/*----*/ ItemTypeUnknown9,
|
||||||
|
/*----*/ ItemTypeUnknown10,
|
||||||
|
/*----*/ ItemTypeUnknown11,
|
||||||
|
/*----*/ ItemTypeSinging,
|
||||||
|
/*5750*/ ItemTypeAllInstrumentTypes,
|
||||||
|
/*5776*/ ItemTypeCharm,
|
||||||
|
/*----*/ ItemTypeDye,
|
||||||
|
/*----*/ ItemTypeAugmentation,
|
||||||
|
/*----*/ ItemTypeAugmentationSolvent,
|
||||||
|
/*----*/ ItemTypeAugmentationDistiller,
|
||||||
|
/*----*/ ItemTypeUnknown12,
|
||||||
|
/*----*/ ItemTypeFellowshipKit,
|
||||||
|
/*----*/ ItemTypeUnknown13,
|
||||||
|
/*----*/ ItemTypeRecipe,
|
||||||
|
/*----*/ ItemTypeAdvancedRecipe,
|
||||||
|
/*----*/ ItemTypeJournal, // only one(1) database entry
|
||||||
|
/*----*/ ItemTypeAltCurrency, // alt-currency (as opposed to coinage)
|
||||||
|
/*5881*/ ItemTypePerfectedAugmentationDistiller,
|
||||||
|
/*----*/ _ItemTypeCount
|
||||||
|
|
||||||
// animations for AT_Anim
|
/*
|
||||||
#define ANIM_FREEZE 102
|
Unknowns:
|
||||||
|
|
||||||
|
Mounts?
|
||||||
|
Ornamentations?
|
||||||
|
GuildBanners?
|
||||||
|
Collectible?
|
||||||
|
Placeable?
|
||||||
|
(others?)
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Augmentation use type bitmasks (1-based)
|
||||||
|
**
|
||||||
|
** (ref: dbstr_us.txt)
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
enum AugmentationUseTypeBitmasks : uint32 {
|
||||||
|
AugUseNone = 0x00000000,
|
||||||
|
AugUseGeneralSingleStat = 0x00000001, /*1^16^1 (General: Single Stat)^0*/
|
||||||
|
AugUseGeneralMultipleStat = 0x00000002, /*2^16^2 (General: Multiple Stat)^0*/
|
||||||
|
AugUseGeneralSpellEffect = 0x00000004, /*3^16^3 (General: Spell Effect)^0*/
|
||||||
|
AugUseWeaponGeneral = 0x00000008, /*4^16^4 (Weapon: General)^0*/
|
||||||
|
AugUseWeaponElemDamage = 0x00000010, /*5^16^5 (Weapon: Elem Damage)^0*/
|
||||||
|
AugUseWeaponBaseDamage = 0x00000020, /*6^16^6 (Weapon: Base Damage)^0*/
|
||||||
|
AugUseGeneralGroup = 0x00000040, /*7^16^7 (General: Group)^0*/
|
||||||
|
AugUseGeneralRaid = 0x00000080, /*8^16^8 (General: Raid)^0*/
|
||||||
|
AugUseGeneralDragonsPoints = 0x00000100, /*9^16^9 (General: Dragons Points)^0*/
|
||||||
|
AugUseCraftedCommon = 0x00000200, /*10^16^10 (Crafted: Common)^0*/
|
||||||
|
AugUseCraftedGroup1 = 0x00000400, /*11^16^11 (Crafted: Group)^0*/
|
||||||
|
AugUseCraftedRaid1 = 0x00000800, /*12^16^12 (Crafted: Raid)^0*/
|
||||||
|
AugUseEnergeiacGroup = 0x00001000, /*13^16^13 (Energeiac: Group)^0*/
|
||||||
|
AugUseEnergeiacRaid = 0x00002000, /*14^16^14 (Energeiac: Raid)^0*/
|
||||||
|
AugUseEmblem = 0x00004000, /*15^16^15 (Emblem)^0*/
|
||||||
|
AugUseCraftedGroup2 = 0x00008000, /*16^16^16 (Crafted: Group)^0*/
|
||||||
|
AugUseCraftedRaid2 = 0x00010000, /*17^16^17 (Crafted: Raid)^0*/
|
||||||
|
AugUseUnknown1 = 0x00020000, /*18^16^18^0*/
|
||||||
|
AugUseUnknown2 = 0x00040000, /*19^16^19^0*/
|
||||||
|
AugUseOrnamentation = 0x00080000, /*20^16^20 (Ornamentation)^0*/
|
||||||
|
AugUseSpecialOrnamentation = 0x00100000, /*21^16^21 (Special Ornamentation)^0*/
|
||||||
|
AugUseUnknown3 = 0x00200000, /*22^16^22^0*/
|
||||||
|
AugUseUnknown4 = 0x00400000, /*23^16^23^0*/
|
||||||
|
AugUseUnknown5 = 0x00800000, /*24^16^24^0*/
|
||||||
|
AugUseUnknown6 = 0x01000000, /*25^16^25^0*/
|
||||||
|
AugUseUnknown7 = 0x02000000, /*26^16^26^0*/
|
||||||
|
AugUseUnknown8 = 0x04000000, /*27^16^27^0*/
|
||||||
|
AugUseUnknown9 = 0x08000000, /*28^16^28^0*/
|
||||||
|
AugUseUnknown10 = 0x10000000, /*29^16^29^0*/
|
||||||
|
AugUseEpic25 = 0x20000000, /*30^16^30^0*/
|
||||||
|
AugUseTest = 0x40000000, /*31^16^Test^0*/ // listed as 31^16^31^0 in 5-10 client
|
||||||
|
AugUseAll = 0xFFFFFFFF
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Augmentation use types (enumerated)
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
enum AugmentationUseTypes : uint8 {
|
||||||
|
AugTypeNone = 0,
|
||||||
|
AugTypeGeneralSingleStat,
|
||||||
|
AugTypeGeneralMultipleStat,
|
||||||
|
AugTypeGeneralSpellEffect,
|
||||||
|
AugTypeWeaponGeneral,
|
||||||
|
AugTypeWeaponElemDamage,
|
||||||
|
AugTypeWeaponBaseDamage,
|
||||||
|
AugTypeGeneralGroup,
|
||||||
|
AugTypeGeneralRaid,
|
||||||
|
AugTypeGeneralDragonsPoints,
|
||||||
|
AugTypeCraftedCommon,
|
||||||
|
AugTypeCraftedGroup1,
|
||||||
|
AugTypeCraftedRaid1,
|
||||||
|
AugTypeEnergeiacGroup,
|
||||||
|
AugTypeEnergeiacRaid,
|
||||||
|
AugTypeEmblem,
|
||||||
|
AugTypeCraftedGroup2,
|
||||||
|
AugTypeCraftedRaid2,
|
||||||
|
AugTypeUnknown1,
|
||||||
|
AugTypeUnknown2,
|
||||||
|
AugTypeOrnamentation,
|
||||||
|
AugTypeSpecialOrnamentation,
|
||||||
|
AugTypeUnknown3,
|
||||||
|
AugTypeUnknown4,
|
||||||
|
AugTypeUnknown5,
|
||||||
|
AugTypeUnknown6,
|
||||||
|
AugTypeUnknown7,
|
||||||
|
AugTypeUnknown8,
|
||||||
|
AugTypeUnknown9,
|
||||||
|
AugTypeUnknown10,
|
||||||
|
AugTypeEpic25,
|
||||||
|
AugTypeTest,
|
||||||
|
_AugTypeCount,
|
||||||
|
AugTypeAll = 255
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Augmentation restriction types (in-work)
|
||||||
|
**
|
||||||
|
** (ref: eqstr_us.txt)
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
enum AugmentationRestrictionTypes : uint8 {
|
||||||
|
/*4690*/ AugRestrAny = 0,
|
||||||
|
/*9134*/ AugRestrArmor,
|
||||||
|
/*9135*/ AugRestrWeapons,
|
||||||
|
/*9136*/ AugRestr1HWeapons,
|
||||||
|
/*9137*/ AugRestr2HWeapons,
|
||||||
|
/*9138*/ AugRestr1HSlash,
|
||||||
|
/*9139*/ AugRestr1HBlunt,
|
||||||
|
/*9140*/ AugRestrPiercing,
|
||||||
|
/*9148*/ AugRestrHandToHand,
|
||||||
|
/*9141*/ AugRestr2HSlash,
|
||||||
|
/*9142*/ AugRestr2HBlunt,
|
||||||
|
/*9143*/ AugRestr2HPierce,
|
||||||
|
/*9144*/ AugRestrBows,
|
||||||
|
/*9145*/ AugRestrShields,
|
||||||
|
/*8052*/ AugRestr1HSlash1HBluntOrHandToHand,
|
||||||
|
/*9200*/ AugRestr1HBluntOrHandToHand, // no listed peq entries
|
||||||
|
|
||||||
|
// these three appear to be post-RoF (12-10-2012) and can not be verified until RoF (05-10-2013) is supported
|
||||||
|
/*????*/ AugRestrUnknown1,
|
||||||
|
/*????*/ AugRestrUnknown2,
|
||||||
|
/*????*/ AugRestrUnknown3, // last value in peq entries
|
||||||
|
_AugRestrCount
|
||||||
|
|
||||||
|
/*4687*/ //AugTypeAllItems, // ?? unknown atm
|
||||||
|
/*4688*/ //AugTypePrestige, // ?? unknown atm
|
||||||
|
/*4689*/ //AugTypeNonPrestige, // ?? unknown atm
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Container use types
|
||||||
|
**
|
||||||
|
** This correlates to world 'object.type' (object.h/Object.cpp) as well as Item_Struct.BagType
|
||||||
|
**
|
||||||
|
** (ref: database, web forums and eqstr_us.txt)
|
||||||
|
*/
|
||||||
|
enum ContainerUseTypes : uint8
|
||||||
|
{
|
||||||
|
/*3400*/ BagTypeSmallBag = 0,
|
||||||
|
/*3401*/ BagTypeLargeBag,
|
||||||
|
/*3402*/ BagTypeQuiver,
|
||||||
|
/*3403*/ BagTypeBeltPouch,
|
||||||
|
/*3404*/ BagTypeWristPouch,
|
||||||
|
/*3405*/ BagTypeBackPack,
|
||||||
|
/*3406*/ BagTypeSmallChest,
|
||||||
|
/*3407*/ BagTypeLargeChest,
|
||||||
|
/*----*/ BagTypeBandolier, // <*Database Reference Only>
|
||||||
|
/*3408*/ BagTypeMedicineBag,
|
||||||
|
/*3409*/ BagTypeToolBox,
|
||||||
|
/*3410*/ BagTypeLexicon,
|
||||||
|
/*3411*/ BagTypeMortar,
|
||||||
|
/*3412*/ BagTypeSelfDusting, // Quest container (Auto-clear contents?)
|
||||||
|
/*3413*/ BagTypeMixingBowl,
|
||||||
|
/*3414*/ BagTypeOven,
|
||||||
|
/*3415*/ BagTypeSewingKit,
|
||||||
|
/*3416*/ BagTypeForge,
|
||||||
|
/*3417*/ BagTypeFletchingKit,
|
||||||
|
/*3418*/ BagTypeBrewBarrel,
|
||||||
|
/*3419*/ BagTypeJewelersKit,
|
||||||
|
/*3420*/ BagTypePotteryWheel,
|
||||||
|
/*3421*/ BagTypeKiln,
|
||||||
|
/*3422*/ BagTypeKeymaker, // (no database entries as of peq rev 69)
|
||||||
|
/*3423*/ BagTypeWizardsLexicon,
|
||||||
|
/*3424*/ BagTypeMagesLexicon,
|
||||||
|
/*3425*/ BagTypeNecromancersLexicon,
|
||||||
|
/*3426*/ BagTypeEnchantersLexicon,
|
||||||
|
/*----*/ BagTypeUnknown1, // (a coin pouch/purse?) (no database entries as of peq rev 69)
|
||||||
|
/*----*/ BagTypeConcordanceofResearch, // <*Database Reference Only>
|
||||||
|
/*3427*/ BagTypeAlwaysWorks, // Quest container (Never-fail combines?)
|
||||||
|
/*3428*/ BagTypeKoadaDalForge, // High Elf
|
||||||
|
/*3429*/ BagTypeTeirDalForge, // Dark Elf
|
||||||
|
/*3430*/ BagTypeOggokForge, // Ogre
|
||||||
|
/*3431*/ BagTypeStormguardForge, // Dwarf
|
||||||
|
/*3432*/ BagTypeAkanonForge, // Gnome
|
||||||
|
/*3433*/ BagTypeNorthmanForge, // Barbarian
|
||||||
|
/*----*/ BagTypeUnknown2, // (no database entries as of peq rev 69)
|
||||||
|
/*3434*/ BagTypeCabilisForge, // Iksar
|
||||||
|
/*3435*/ BagTypeFreeportForge, // Human 1
|
||||||
|
/*3436*/ BagTypeRoyalQeynosForge, // Human 2
|
||||||
|
/*3439*/ BagTypeHalflingTailoringKit,
|
||||||
|
/*3438*/ BagTypeErudTailoringKit,
|
||||||
|
/*3440*/ BagTypeFierDalTailoringKit, // Wood Elf
|
||||||
|
/*3441*/ BagTypeFierDalFletchingKit, // Wood Elf
|
||||||
|
/*3437*/ BagTypeIksarPotteryWheel,
|
||||||
|
/*3442*/ BagTypeTackleBox,
|
||||||
|
/*3443*/ BagTypeTrollForge,
|
||||||
|
/*3445*/ BagTypeFierDalForge, // Wood Elf
|
||||||
|
/*3444*/ BagTypeValeForge, // Halfling
|
||||||
|
/*3446*/ BagTypeErudForge,
|
||||||
|
/*----*/ BagTypeTradersSatchel, // <*Database Reference Only> (db: Yellow Trader's Satchel Token?)
|
||||||
|
/*5785*/ BagTypeGuktaForge, // Froglok (no database entries as of peq rev 69)
|
||||||
|
/*3359*/ BagTypeAugmentationSealer,
|
||||||
|
/*----*/ BagTypeIceCreamChurn, // <*Database Reference Only>
|
||||||
|
/*6325*/ BagTypeTransformationmold, // Ornamentation
|
||||||
|
/*6340*/ BagTypeDetransformationmold, // Ornamentation Stripper
|
||||||
|
/*5400*/ BagTypeUnattuner,
|
||||||
|
/*7684*/ BagTypeTradeskillBag,
|
||||||
|
/*7692*/ BagTypeCollectibleBag,
|
||||||
|
/*----*/ _BagTypeCount
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Item Effect Types
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
ET_CombatProc = 0,
|
||||||
|
ET_ClickEffect = 1,
|
||||||
|
ET_WornEffect = 2,
|
||||||
|
ET_Expendable = 3,
|
||||||
|
ET_EquipClick = 4,
|
||||||
|
ET_ClickEffect2 = 5, //name unknown
|
||||||
|
ET_Focus = 6,
|
||||||
|
ET_Scroll = 7
|
||||||
|
};
|
||||||
|
|
||||||
|
//SpawnAppearance types:
|
||||||
|
#define AT_Die 0 // this causes the client to keel over and zone to bind point
|
||||||
|
#define AT_WhoLevel 1 // the level that shows up on /who
|
||||||
|
#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
|
||||||
|
#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_Split 28 // 0 = normal, 1 = autosplit on
|
||||||
|
#define AT_Size 29 // spawn's size
|
||||||
|
#define AT_NPCName 31 // change PC's name's color to NPC color 0 = normal, 1 = npc name
|
||||||
|
#define AT_ShowHelm 43 // 0 = do not show helmet graphic, 1 = show graphic
|
||||||
|
#define AT_DamageState 44 // The damage state of a destructible object (0 through 4)
|
||||||
|
//#define AT_Trader 300 // Bazzar Trader Mode
|
||||||
|
|
||||||
|
// solar: animations for AT_Anim
|
||||||
|
#define ANIM_FREEZE 102
|
||||||
#define ANIM_STAND 0x64
|
#define ANIM_STAND 0x64
|
||||||
#define ANIM_SIT 0x6e
|
#define ANIM_SIT 0x6e
|
||||||
#define ANIM_CROUCH 0x6f
|
#define ANIM_CROUCH 0x6f
|
||||||
@@ -87,114 +384,174 @@ typedef enum {
|
|||||||
_eaMaxAppearance
|
_eaMaxAppearance
|
||||||
} EmuAppearance;
|
} EmuAppearance;
|
||||||
|
|
||||||
namespace Chat {
|
// msg_type's for custom usercolors
|
||||||
const uint16 White = 0;
|
#define MT_Say 256
|
||||||
const uint16 DimGray = 1;
|
#define MT_Tell 257
|
||||||
const uint16 Default = 1;
|
#define MT_Group 258
|
||||||
const uint16 Green = 2;
|
#define MT_Guild 259
|
||||||
const uint16 BrightBlue = 3;
|
#define MT_OOC 260
|
||||||
const uint16 LightBlue = 4;
|
#define MT_Auction 261
|
||||||
const uint16 Magenta = 5;
|
#define MT_Shout 262
|
||||||
const uint16 Gray = 6;
|
#define MT_Emote 263
|
||||||
const uint16 LightGray = 7;
|
#define MT_Spells 264
|
||||||
const uint16 NPCQuestSay = 10;
|
#define MT_YouHitOther 265
|
||||||
const uint16 DarkGray = 12;
|
#define MT_OtherHitsYou 266
|
||||||
const uint16 Red = 13;
|
#define MT_YouMissOther 267
|
||||||
const uint16 Lime = 14;
|
#define MT_OtherMissesYou 268
|
||||||
const uint16 Yellow = 15;
|
#define MT_Broadcasts 269
|
||||||
const uint16 Blue = 16;
|
#define MT_Skills 270
|
||||||
const uint16 LightNavy = 17;
|
#define MT_Disciplines 271
|
||||||
const uint16 Cyan = 18;
|
#define MT_Unused1 272
|
||||||
const uint16 Black = 20;
|
#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
|
||||||
|
|
||||||
/**
|
//from showeq
|
||||||
* User colors
|
enum ChatColor
|
||||||
*/
|
{
|
||||||
const uint16 Say = 256;
|
CC_Default = 0,
|
||||||
const uint16 Tell = 257;
|
CC_DarkGrey = 1,
|
||||||
const uint16 Group = 258;
|
CC_DarkGreen = 2,
|
||||||
const uint16 Guild = 259;
|
CC_DarkBlue = 3,
|
||||||
const uint16 OOC = 260;
|
CC_Purple = 5,
|
||||||
const uint16 Auction = 261;
|
CC_LightGrey = 6,
|
||||||
const uint16 Shout = 262;
|
CC_User_Say = 256,
|
||||||
const uint16 Emote = 263;
|
CC_User_Tell = 257,
|
||||||
const uint16 Spells = 264;
|
CC_User_Group = 258,
|
||||||
const uint16 YouHitOther = 265;
|
CC_User_Guild = 259,
|
||||||
const uint16 OtherHitYou = 266;
|
CC_User_OOC = 260,
|
||||||
const uint16 YouMissOther = 267;
|
CC_User_Auction = 261,
|
||||||
const uint16 OtherMissYou = 268;
|
CC_User_Shout = 262,
|
||||||
const uint16 Broadcasts = 269;
|
CC_User_Emote = 263,
|
||||||
const uint16 Skills = 270;
|
CC_User_Spells = 264,
|
||||||
const uint16 Disciplines = 271;
|
CC_User_YouHitOther = 265,
|
||||||
const uint16 Unused1 = 272;
|
CC_User_OtherHitYou = 266,
|
||||||
const uint16 DefaultText = 273;
|
CC_User_YouMissOther = 267,
|
||||||
const uint16 Unused2 = 274;
|
CC_User_OtherMissYou = 268,
|
||||||
const uint16 MerchantOffer = 275;
|
CC_User_Duels = 269,
|
||||||
const uint16 MerchantExchange = 276;
|
CC_User_Skills = 270,
|
||||||
const uint16 YourDeath = 277;
|
CC_User_Disciplines = 271,
|
||||||
const uint16 OtherDeath = 278;
|
CC_User_Default = 273,
|
||||||
const uint16 OtherHitOther = 279;
|
CC_User_MerchantOffer = 275,
|
||||||
const uint16 OtherMissOther = 280;
|
CC_User_MerchantExchange = 276,
|
||||||
const uint16 Who = 281;
|
CC_User_YourDeath = 277,
|
||||||
const uint16 YellForHelp = 282;
|
CC_User_OtherDeath = 278,
|
||||||
const uint16 NonMelee = 283;
|
CC_User_OtherHitOther = 279,
|
||||||
const uint16 SpellWornOff = 284;
|
CC_User_OtherMissOther = 280,
|
||||||
const uint16 MoneySplit = 285;
|
CC_User_Who = 281,
|
||||||
const uint16 Loot = 286;
|
CC_User_Yell = 282,
|
||||||
const uint16 DiceRoll = 287;
|
CC_User_NonMelee = 283,
|
||||||
const uint16 OtherSpells = 288;
|
CC_User_SpellWornOff = 284,
|
||||||
const uint16 SpellFailure = 289;
|
CC_User_MoneySplit = 285,
|
||||||
const uint16 ChatChannel = 290;
|
CC_User_Loot = 286,
|
||||||
const uint16 Chat1 = 291;
|
CC_User_Random = 287,
|
||||||
const uint16 Chat2 = 292;
|
CC_User_OtherSpells = 288,
|
||||||
const uint16 Chat3 = 293;
|
CC_User_SpellFailure = 289,
|
||||||
const uint16 Chat4 = 294;
|
CC_User_ChatChannel = 290,
|
||||||
const uint16 Chat5 = 295;
|
CC_User_Chat1 = 291,
|
||||||
const uint16 Chat6 = 296;
|
CC_User_Chat2 = 292,
|
||||||
const uint16 Chat7 = 297;
|
CC_User_Chat3 = 293,
|
||||||
const uint16 Chat8 = 298;
|
CC_User_Chat4 = 294,
|
||||||
const uint16 Chat9 = 299;
|
CC_User_Chat5 = 295,
|
||||||
const uint16 Chat10 = 300;
|
CC_User_Chat6 = 296,
|
||||||
const uint16 MeleeCrit = 301;
|
CC_User_Chat7 = 297,
|
||||||
const uint16 SpellCrit = 302;
|
CC_User_Chat8 = 298,
|
||||||
const uint16 TooFarAway = 303;
|
CC_User_Chat9 = 299,
|
||||||
const uint16 NPCRampage = 304;
|
CC_User_Chat10 = 300,
|
||||||
const uint16 NPCFlurry = 305;
|
CC_User_MeleeCrit = 301,
|
||||||
const uint16 NPCEnrage = 306;
|
CC_User_SpellCrit = 302,
|
||||||
const uint16 EchoSay = 307;
|
CC_User_TooFarAway = 303,
|
||||||
const uint16 EchoTell = 308;
|
CC_User_NPCRampage = 304,
|
||||||
const uint16 EchoGroup = 309;
|
CC_User_NPCFurry = 305,
|
||||||
const uint16 EchoGuild = 310;
|
CC_User_NPCEnrage = 306,
|
||||||
const uint16 EchoOOC = 311;
|
CC_User_EchoSay = 307,
|
||||||
const uint16 EchoAuction = 312;
|
CC_User_EchoTell = 308,
|
||||||
const uint16 EchoShout = 313;
|
CC_User_EchoGroup = 309,
|
||||||
const uint16 EchoEmote = 314;
|
CC_User_EchoGuild = 310,
|
||||||
const uint16 EchoChat1 = 315;
|
CC_User_EchoOOC = 311,
|
||||||
const uint16 EchoChat2 = 316;
|
CC_User_EchoAuction = 312,
|
||||||
const uint16 EchoChat3 = 317;
|
CC_User_EchoShout = 313,
|
||||||
const uint16 EchoChat4 = 318;
|
CC_User_EchoEmote = 314,
|
||||||
const uint16 EchoChat5 = 319;
|
CC_User_EchoChat1 = 315,
|
||||||
const uint16 EchoChat6 = 320;
|
CC_User_EchoChat2 = 316,
|
||||||
const uint16 EchoChat7 = 321;
|
CC_User_EchoChat3 = 317,
|
||||||
const uint16 EchoChat8 = 322;
|
CC_User_EchoChat4 = 318,
|
||||||
const uint16 EchoChat9 = 323;
|
CC_User_EchoChat5 = 319,
|
||||||
const uint16 EchoChat10 = 324;
|
CC_User_EchoChat6 = 320,
|
||||||
const uint16 DotDamage = 325;
|
CC_User_EchoChat7 = 321,
|
||||||
const uint16 ItemLink = 326;
|
CC_User_EchoChat8 = 322,
|
||||||
const uint16 RaidSay = 327;
|
CC_User_EchoChat9 = 323,
|
||||||
const uint16 MyPet = 328;
|
CC_User_EchoChat10 = 324,
|
||||||
const uint16 DamageShield = 329;
|
CC_User_UnusedAtThisTime = 325,
|
||||||
const uint16 LeaderShip = 330;
|
CC_User_ItemTags = 326,
|
||||||
const uint16 PetFlurry = 331;
|
CC_User_RaidSay = 327,
|
||||||
const uint16 PetCritical = 332;
|
CC_User_MyPet = 328,
|
||||||
const uint16 FocusEffect = 333;
|
CC_User_DamageShield = 329,
|
||||||
const uint16 Experience = 334;
|
|
||||||
const uint16 System = 335;
|
|
||||||
const uint16 PetSpell = 336;
|
|
||||||
const uint16 PetResponse = 337;
|
|
||||||
const uint16 ItemSpeech = 338;
|
|
||||||
const uint16 StrikeThrough = 339;
|
|
||||||
const uint16 Stun = 340;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//ZoneChange_Struct->success values
|
//ZoneChange_Struct->success values
|
||||||
@@ -318,7 +675,7 @@ static const uint8 DamageTypeUnknown = 0xFF;
|
|||||||
**
|
**
|
||||||
** (indexed by 'Skill' of SkillUseTypes)
|
** (indexed by 'Skill' of SkillUseTypes)
|
||||||
*/
|
*/
|
||||||
static const uint8 SkillDamageTypes[EQEmu::skills::HIGHEST_SKILL + 1] = // change to _SkillServerArraySize once activated
|
static const uint8 SkillDamageTypes[HIGHEST_SKILL + 1] = // change to _SkillServerArraySize once activated
|
||||||
{
|
{
|
||||||
/*1HBlunt*/ 0,
|
/*1HBlunt*/ 0,
|
||||||
/*1HSlashing*/ 1,
|
/*1HSlashing*/ 1,
|
||||||
@@ -394,10 +751,29 @@ static const uint8 SkillDamageTypes[EQEmu::skills::HIGHEST_SKILL + 1] = // chang
|
|||||||
/*Intimidation*/ DamageTypeUnknown,
|
/*Intimidation*/ DamageTypeUnknown,
|
||||||
/*Berserking*/ DamageTypeUnknown,
|
/*Berserking*/ DamageTypeUnknown,
|
||||||
/*Taunt*/ DamageTypeUnknown,
|
/*Taunt*/ DamageTypeUnknown,
|
||||||
/*Frenzy*/ 74,
|
/*Frenzy*/ 74 //,
|
||||||
/*RemoveTrap*/ DamageTypeUnknown, // Needs research (set for SenseTrap value)
|
// /*RemoveTrap*/ DamageTypeUnknown, // Needs research (set for SenseTrap value)
|
||||||
/*TripleAttack*/ DamageTypeUnknown, // Needs research (set for DoubleAttack value)
|
// /*TripleAttack*/ DamageTypeUnknown, // Needs research (set for DoubleAttack value)
|
||||||
/*2HPiercing*/ 36 // Needs research (set for 1HPiercing value - similar to slash/blunt)
|
// /*2HPiercing*/ 36 // Needs research (set for 1HPiercing value - similar to slash/blunt)
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Material use slots
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
enum MaterialUseSlots : uint8
|
||||||
|
{
|
||||||
|
MaterialHead = 0,
|
||||||
|
MaterialChest,
|
||||||
|
MaterialArms,
|
||||||
|
MaterialWrist,
|
||||||
|
MaterialHands,
|
||||||
|
MaterialLegs,
|
||||||
|
MaterialFeet,
|
||||||
|
MaterialPrimary,
|
||||||
|
MaterialSecondary,
|
||||||
|
_MaterialCount,
|
||||||
|
_MaterialInvalid = 255
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -435,33 +811,96 @@ static const uint8 SkillDamageTypes[EQEmu::skills::HIGHEST_SKILL + 1] = // chang
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define INVALID_INDEX -1
|
#define INVALID_INDEX -1
|
||||||
|
#define NOT_USED 0
|
||||||
|
#define NO_ITEM 0
|
||||||
|
|
||||||
static const uint32 MAX_SPELL_DB_ID_VAL = 65535;
|
#define DB_ITEM_CONTAINER_SIZE 255 // probably need to move to database.h
|
||||||
|
|
||||||
enum ChatChannelNames : uint16
|
// yes..these are redundant... but, they help to identify and define what is actually being performed
|
||||||
{
|
// plus, since they're pre-op's, they don't affect the actual binary size
|
||||||
ChatChannel_Guild = 0,
|
#define MAP_BEGIN 0
|
||||||
ChatChannel_Group = 2,
|
#define MAIN_BEGIN 0
|
||||||
ChatChannel_Shout = 3,
|
#define SUB_BEGIN 0
|
||||||
ChatChannel_Auction = 4,
|
#define AUG_BEGIN 0
|
||||||
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,
|
namespace legacy {
|
||||||
ChatChannel_UNKNOWN_GMSAY = 18,
|
// this is for perl and other legacy systems
|
||||||
ChatChannel_UCSRelay = 20,
|
|
||||||
ChatChannel_Emotes = 22
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace ZoneBlockedSpellTypes {
|
typedef enum {
|
||||||
const uint8 ZoneWide = 1;
|
SLOT_CHARM = 0,
|
||||||
const uint8 Region = 2;
|
SLOT_EAR01 = 1,
|
||||||
};
|
SLOT_HEAD = 2,
|
||||||
|
SLOT_FACE = 3,
|
||||||
|
SLOT_EAR02 = 4,
|
||||||
|
SLOT_NECK = 5,
|
||||||
|
SLOT_SHOULDER = 6,
|
||||||
|
SLOT_ARMS = 7,
|
||||||
|
SLOT_BACK = 8,
|
||||||
|
SLOT_BRACER01 = 9,
|
||||||
|
SLOT_BRACER02 = 10,
|
||||||
|
SLOT_RANGE = 11,
|
||||||
|
SLOT_HANDS = 12,
|
||||||
|
SLOT_PRIMARY = 13,
|
||||||
|
SLOT_SECONDARY = 14,
|
||||||
|
SLOT_RING01 = 15,
|
||||||
|
SLOT_RING02 = 16,
|
||||||
|
SLOT_CHEST = 17,
|
||||||
|
SLOT_LEGS = 18,
|
||||||
|
SLOT_FEET = 19,
|
||||||
|
SLOT_WAIST = 20,
|
||||||
|
SLOT_POWER_SOURCE = 9999,
|
||||||
|
SLOT_AMMO = 21,
|
||||||
|
SLOT_GENERAL_1 = 22,
|
||||||
|
SLOT_GENERAL_2 = 23,
|
||||||
|
SLOT_GENERAL_3 = 24,
|
||||||
|
SLOT_GENERAL_4 = 25,
|
||||||
|
SLOT_GENERAL_5 = 26,
|
||||||
|
SLOT_GENERAL_6 = 27,
|
||||||
|
SLOT_GENERAL_7 = 28,
|
||||||
|
SLOT_GENERAL_8 = 29,
|
||||||
|
//SLOT_GENERAL_9 = not supported
|
||||||
|
//SLOT_GENERAL_10 = not supported
|
||||||
|
SLOT_CURSOR = 30,
|
||||||
|
SLOT_CURSOR_END = (int16)0xFFFE, // I hope no one is using this...
|
||||||
|
SLOT_TRADESKILL = 1000,
|
||||||
|
SLOT_AUGMENT = 1001,
|
||||||
|
SLOT_INVALID = (int16)0xFFFF,
|
||||||
|
|
||||||
#endif /*COMMON_EQ_CONSTANTS_H*/
|
SLOT_POSSESSIONS_BEGIN = 0,
|
||||||
|
SLOT_POSSESSIONS_END = 30,
|
||||||
|
|
||||||
|
SLOT_EQUIPMENT_BEGIN = 0,
|
||||||
|
SLOT_EQUIPMENT_END = 21,
|
||||||
|
|
||||||
|
SLOT_PERSONAL_BEGIN = 22,
|
||||||
|
SLOT_PERSONAL_END = 29,
|
||||||
|
SLOT_PERSONAL_BAGS_BEGIN = 251,
|
||||||
|
SLOT_PERSONAL_BAGS_END = 330,
|
||||||
|
|
||||||
|
SLOT_CURSOR_BAG_BEGIN = 331,
|
||||||
|
SLOT_CURSOR_BAG_END = 340,
|
||||||
|
|
||||||
|
SLOT_TRIBUTE_BEGIN = 400,
|
||||||
|
SLOT_TRIBUTE_END = 404,
|
||||||
|
|
||||||
|
SLOT_BANK_BEGIN = 2000,
|
||||||
|
SLOT_BANK_END = 2023,
|
||||||
|
SLOT_BANK_BAGS_BEGIN = 2031,
|
||||||
|
SLOT_BANK_BAGS_END = 2270,
|
||||||
|
|
||||||
|
SLOT_SHARED_BANK_BEGIN = 2500,
|
||||||
|
SLOT_SHARED_BANK_END = 2501,
|
||||||
|
SLOT_SHARED_BANK_BAGS_BEGIN = 2531,
|
||||||
|
SLOT_SHARED_BANK_BAGS_END = 2550,
|
||||||
|
|
||||||
|
SLOT_TRADE_BEGIN = 3000,
|
||||||
|
SLOT_TRADE_END = 3007,
|
||||||
|
SLOT_TRADE_BAGS_BEGIN = 3031,
|
||||||
|
SLOT_TRADE_BAGS_END = 3110,
|
||||||
|
|
||||||
|
SLOT_WORLD_BEGIN = 4000,
|
||||||
|
SLOT_WORLD_END = 4009
|
||||||
|
} InventorySlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,211 @@
|
|||||||
|
/*
|
||||||
|
EQEMu: Everquest Server Emulator
|
||||||
|
|
||||||
|
Copyright (C) 2001-2014 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 EQ_DICTIONARY_H
|
||||||
|
#define EQ_DICTIONARY_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
#include "eq_constants.h"
|
||||||
|
#include "clientversions.h"
|
||||||
|
#include <string>
|
||||||
|
#include "../common/patches/client62_constants.h"
|
||||||
|
#include "../common/patches/titanium_constants.h"
|
||||||
|
#include "../common/patches/sof_constants.h"
|
||||||
|
#include "../common/patches/sod_constants.h"
|
||||||
|
#include "../common/patches/underfoot_constants.h"
|
||||||
|
#include "../common/patches/rof_constants.h"
|
||||||
|
#include "../common/patches/rof2_constants.h"
|
||||||
|
|
||||||
|
// *** DO NOT CHANGE without a full understanding of the consequences..the server is set up to use these settings explicitly!! ***
|
||||||
|
// *** You will cause compilation failures and corrupt your database if partial or incorrect attempts to change them are made!! ***
|
||||||
|
|
||||||
|
// Hard-coded values usually indicate that further research is needed and the values given are from the old (known) system
|
||||||
|
|
||||||
|
using namespace RoF2::maps; // server inventory maps enumeration (code and database sync'd to reference)
|
||||||
|
using namespace RoF2::slots; // server possessions slots enumeration (code and database sync'd to reference)
|
||||||
|
|
||||||
|
class EmuConstants {
|
||||||
|
// an immutable value is required to initialize arrays, etc... use this class as a repository for those
|
||||||
|
public:
|
||||||
|
// database
|
||||||
|
static const EQClientVersion CHARACTER_CREATION_CLIENT = EQClientRoF; // adjust according to starting item placement and target client
|
||||||
|
|
||||||
|
// inventory
|
||||||
|
static uint16 InventoryMapSize(int16 map);
|
||||||
|
//static std::string InventoryLocationName(Location_Struct location);
|
||||||
|
static std::string InventoryMapName(int16 map);
|
||||||
|
static std::string InventoryMainName(int16 main);
|
||||||
|
static std::string InventorySubName(int16 sub);
|
||||||
|
static std::string InventoryAugName(int16 aug);
|
||||||
|
|
||||||
|
// these are currently hard-coded for existing inventory system..do not use in place of special client version handlers until ready
|
||||||
|
static const uint16 MAP_POSSESSIONS_SIZE = RoF2::consts::MAP_POSSESSIONS_SIZE;
|
||||||
|
static const uint16 MAP_BANK_SIZE = RoF2::consts::MAP_BANK_SIZE;
|
||||||
|
static const uint16 MAP_SHARED_BANK_SIZE = RoF2::consts::MAP_SHARED_BANK_SIZE;
|
||||||
|
static const uint16 MAP_TRADE_SIZE = RoF2::consts::MAP_TRADE_SIZE;
|
||||||
|
static const uint16 MAP_WORLD_SIZE = RoF2::consts::MAP_WORLD_SIZE;
|
||||||
|
static const uint16 MAP_LIMBO_SIZE = RoF2::consts::MAP_LIMBO_SIZE;
|
||||||
|
static const uint16 MAP_TRIBUTE_SIZE = Titanium::consts::MAP_TRIBUTE_SIZE; // server is setup for 'presumed' Titanium value of 5..if Titanium::consts is changed, hard-code this to '5' until server/db is updated
|
||||||
|
static const uint16 MAP_TROPHY_TRIBUTE_SIZE = 0;
|
||||||
|
static const uint16 MAP_GUILD_TRIBUTE_SIZE = 0;
|
||||||
|
static const uint16 MAP_MERCHANT_SIZE = 0;
|
||||||
|
static const uint16 MAP_DELETED_SIZE = 0;
|
||||||
|
static const uint16 MAP_CORPSE_SIZE = RoF2::consts::MAP_CORPSE_SIZE; // no bitmask use..limits to size of client corpse window (see EQLimits::InventoryMapSize(MapCorpse, <EQClientVersion))
|
||||||
|
static const uint16 MAP_BAZAAR_SIZE = Titanium::consts::MAP_BAZAAR_SIZE;
|
||||||
|
static const uint16 MAP_INSPECT_SIZE = RoF2::consts::MAP_INSPECT_SIZE;
|
||||||
|
static const uint16 MAP_REAL_ESTATE_SIZE = 0;
|
||||||
|
static const uint16 MAP_VIEW_MOD_PC_SIZE = NOT_USED;
|
||||||
|
static const uint16 MAP_VIEW_MOD_BANK_SIZE = NOT_USED;
|
||||||
|
static const uint16 MAP_VIEW_MOD_SHARED_BANK_SIZE = NOT_USED;
|
||||||
|
static const uint16 MAP_VIEW_MOD_LIMBO_SIZE = NOT_USED;
|
||||||
|
static const uint16 MAP_ALT_STORAGE_SIZE = 0;
|
||||||
|
static const uint16 MAP_ARCHIVED_SIZE = 0;
|
||||||
|
static const uint16 MAP_MAIL_SIZE = 0;
|
||||||
|
static const uint16 MAP_GUILD_TROPHY_TRIBUTE_SIZE = 0;
|
||||||
|
static const uint16 MAP_KRONO_SIZE = RoF::consts::MAP_KRONO_SIZE;
|
||||||
|
static const uint16 MAP_OTHER_SIZE = 0;
|
||||||
|
|
||||||
|
// most of these definitions will go away with the structure-based system..this maintains compatibility for now
|
||||||
|
// (these are mainly to assign specific values to constants used in conversions and to identify per-client ranges/offsets)
|
||||||
|
static const int16 EQUIPMENT_BEGIN = RoF2::consts::EQUIPMENT_BEGIN;
|
||||||
|
static const int16 EQUIPMENT_END = RoF2::consts::EQUIPMENT_END;
|
||||||
|
static const uint16 EQUIPMENT_SIZE = RoF2::consts::EQUIPMENT_SIZE;
|
||||||
|
|
||||||
|
static const int16 GENERAL_BEGIN = RoF2::consts::GENERAL_BEGIN;
|
||||||
|
static const int16 GENERAL_END = RoF2::consts::GENERAL_END;
|
||||||
|
static const uint16 GENERAL_SIZE = RoF2::consts::GENERAL_SIZE;
|
||||||
|
static const int16 GENERAL_BAGS_BEGIN = RoF2::consts::GENERAL_BAGS_BEGIN;
|
||||||
|
static const int16 GENERAL_BAGS_END_OFFSET = RoF2::consts::GENERAL_BAGS_END_OFFSET;
|
||||||
|
static const int16 GENERAL_BAGS_END = RoF2::consts::GENERAL_BAGS_END;
|
||||||
|
|
||||||
|
static const int16 CURSOR_BAG_BEGIN = RoF2::consts::CURSOR_BAG_BEGIN;
|
||||||
|
static const int16 CURSOR_BAG_END_OFFSET = RoF2::consts::CURSOR_BAG_END_OFFSET;
|
||||||
|
static const int16 CURSOR_BAG_END = RoF2::consts::CURSOR_BAG_END;
|
||||||
|
|
||||||
|
static const int16 BANK_BEGIN = RoF2::consts::BANK_BEGIN;
|
||||||
|
static const int16 BANK_END = RoF2::consts::BANK_END;
|
||||||
|
static const int16 BANK_BAGS_BEGIN = RoF2::consts::BANK_BAGS_BEGIN;
|
||||||
|
static const int16 BANK_BAGS_END_OFFSET = RoF2::consts::BANK_BAGS_END_OFFSET;
|
||||||
|
static const int16 BANK_BAGS_END = RoF2::consts::BANK_BAGS_END;
|
||||||
|
|
||||||
|
static const int16 SHARED_BANK_BEGIN = RoF2::consts::SHARED_BANK_BEGIN;
|
||||||
|
static const int16 SHARED_BANK_END = RoF2::consts::SHARED_BANK_END;
|
||||||
|
static const int16 SHARED_BANK_BAGS_BEGIN = RoF2::consts::SHARED_BANK_BAGS_BEGIN;
|
||||||
|
static const int16 SHARED_BANK_BAGS_END_OFFSET = RoF2::consts::SHARED_BANK_BAGS_END_OFFSET;
|
||||||
|
static const int16 SHARED_BANK_BAGS_END = RoF2::consts::SHARED_BANK_BAGS_END;
|
||||||
|
|
||||||
|
static const int16 TRADE_BEGIN = RoF2::consts::TRADE_BEGIN;
|
||||||
|
static const int16 TRADE_END = RoF2::consts::TRADE_END;
|
||||||
|
static const int16 TRADE_NPC_END = RoF2::consts::TRADE_NPC_END;
|
||||||
|
static const int16 TRADE_NPC_SIZE = RoF2::consts::TRADE_NPC_SIZE;
|
||||||
|
static const int16 TRADE_BAGS_BEGIN = RoF2::consts::TRADE_BAGS_BEGIN;
|
||||||
|
static const int16 TRADE_BAGS_END_OFFSET = RoF2::consts::TRADE_BAGS_END_OFFSET;
|
||||||
|
static const int16 TRADE_BAGS_END = RoF2::consts::TRADE_BAGS_END;
|
||||||
|
|
||||||
|
static const int16 WORLD_BEGIN = RoF2::consts::WORLD_BEGIN;
|
||||||
|
static const int16 WORLD_END = RoF2::consts::WORLD_END;
|
||||||
|
static const int16 WORLD_SIZE = MAP_WORLD_SIZE;
|
||||||
|
|
||||||
|
static const int16 TRIBUTE_BEGIN = RoF2::consts::TRIBUTE_BEGIN;
|
||||||
|
static const int16 TRIBUTE_END = RoF2::consts::TRIBUTE_END;
|
||||||
|
static const int16 TRIBUTE_SIZE = MAP_TRIBUTE_SIZE;
|
||||||
|
|
||||||
|
static const int16 CORPSE_BEGIN = RoF2::consts::CORPSE_BEGIN;
|
||||||
|
static const int16 CORPSE_END = RoF2::consts::CORPSE_END;
|
||||||
|
|
||||||
|
static const int16 MATERIAL_BEGIN = Underfoot::consts::MATERIAL_BEGIN;
|
||||||
|
static const int16 MATERIAL_END = Underfoot::consts::MATERIAL_END;
|
||||||
|
static const int16 MATERIAL_TINT_END = Underfoot::consts::MATERIAL_TINT_END;
|
||||||
|
static const int16 MATERIAL_SIZE = Underfoot::consts::MATERIAL_SIZE;
|
||||||
|
|
||||||
|
// items
|
||||||
|
// common and container sizes will not increase until the new 'location' struct is implemented
|
||||||
|
static const uint16 ITEM_COMMON_SIZE = Underfoot::consts::ITEM_COMMON_SIZE;
|
||||||
|
static const uint16 ITEM_CONTAINER_SIZE = Underfoot::consts::ITEM_CONTAINER_SIZE;
|
||||||
|
|
||||||
|
// player profile
|
||||||
|
//static const uint32 CLASS_BITMASK = 0; // needs value
|
||||||
|
//static const uint32 RACE_BITMASK = 0; // needs value
|
||||||
|
|
||||||
|
// BANDOLIERS_COUNT sets maximum limit..active limit will need to be handled by the appropriate AA
|
||||||
|
static const uint32 BANDOLIERS_COUNT = Titanium::consts::BANDOLIERS_COUNT; // count = number of bandolier instances
|
||||||
|
static const uint32 BANDOLIER_SIZE = Titanium::consts::BANDOLIER_SIZE; // size = number of equipment slots in bandolier instance
|
||||||
|
static const uint32 POTION_BELT_SIZE = Titanium::consts::POTION_BELT_SIZE;
|
||||||
|
|
||||||
|
// legacy-related functions
|
||||||
|
//static int ServerToPerlSlot(int slot); // encode
|
||||||
|
//static int PerlToServerSlot(int slot); // decode
|
||||||
|
};
|
||||||
|
|
||||||
|
class EQLimits {
|
||||||
|
// values should default to a non-beneficial value..unless value conflicts with intended operation
|
||||||
|
//
|
||||||
|
// EmuConstants may be used as references..but, not every reference needs to be in EmuConstants (i.e., AllowsEmptyBagInBag(), CoinHasWeight(), etc...)
|
||||||
|
public:
|
||||||
|
// client version validation (checks to avoid crashing zone server when accessing reference arrays)
|
||||||
|
// use this inside of class Client (limits to actual clients)
|
||||||
|
static bool IsValidClientVersion(uint32 version);
|
||||||
|
static uint32 ValidateClientVersion(uint32 version);
|
||||||
|
static EQClientVersion ValidateClientVersion(EQClientVersion version);
|
||||||
|
|
||||||
|
// basically..any non-client classes - do not when setting a valid client
|
||||||
|
static bool IsValidNPCVersion(uint32 version);
|
||||||
|
static uint32 ValidateNPCVersion(uint32 version);
|
||||||
|
static EQClientVersion ValidateNPCVersion(EQClientVersion version);
|
||||||
|
|
||||||
|
// these are 'universal' - do not when setting a valid client
|
||||||
|
static bool IsValidMobVersion(uint32 version);
|
||||||
|
static uint32 ValidateMobVersion(uint32 version);
|
||||||
|
static EQClientVersion ValidateMobVersion(EQClientVersion version);
|
||||||
|
|
||||||
|
// inventory
|
||||||
|
static uint16 InventoryMapSize(int16 map, uint32 version);
|
||||||
|
static uint64 PossessionsBitmask(uint32 version);
|
||||||
|
static uint64 EquipmentBitmask(uint32 version);
|
||||||
|
static uint64 GeneralBitmask(uint32 version);
|
||||||
|
static uint64 CursorBitmask(uint32 version);
|
||||||
|
|
||||||
|
static bool AllowsEmptyBagInBag(uint32 version);
|
||||||
|
static bool AllowsClickCastFromBag(uint32 version);
|
||||||
|
|
||||||
|
// items
|
||||||
|
static uint16 ItemCommonSize(uint32 version);
|
||||||
|
static uint16 ItemContainerSize(uint32 version);
|
||||||
|
|
||||||
|
// player profile
|
||||||
|
static bool CoinHasWeight(uint32 version);
|
||||||
|
|
||||||
|
static uint32 BandoliersCount(uint32 version);
|
||||||
|
static uint32 BandolierSize(uint32 version);
|
||||||
|
|
||||||
|
static uint32 PotionBeltSize(uint32 version);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* EQ_LIMITS_H */
|
||||||
|
|
||||||
|
/*
|
||||||
|
Working Notes:
|
||||||
|
--------------
|
||||||
|
|
||||||
|
- full review of client_packet.cpp and client translators needed
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
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*/
|
|
||||||
+9
-18
@@ -15,22 +15,18 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
#include "debug.h"
|
||||||
#include "crc16.h"
|
#include <stdio.h>
|
||||||
#include "global_define.h"
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
#include "eq_packet.h"
|
#include "eq_packet.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "op_codes.h"
|
#include "op_codes.h"
|
||||||
|
#include "crc16.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <iomanip>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifndef STATIC_OPCODE
|
#ifndef STATIC_OPCODE
|
||||||
#include "opcodemgr.h"
|
#include "opcodemgr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "packet_dump.h"
|
#include "packet_dump.h"
|
||||||
#include "packet_functions.h"
|
#include "packet_functions.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -132,7 +128,7 @@ void EQApplicationPacket::build_header_dump(char *buffer) const
|
|||||||
#ifdef STATIC_OPCODE
|
#ifdef STATIC_OPCODE
|
||||||
sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||||
#else
|
#else
|
||||||
sprintf(buffer, "[OpCode %s(0x%04x) Size=%u]",OpcodeManager::EmuToName(emu_opcode), GetProtocolOpcode(), size);
|
sprintf(buffer, "[OpCode %s Size=%u]",OpcodeManager::EmuToName(emu_opcode),size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +256,7 @@ bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
|
|||||||
{
|
{
|
||||||
bool result=false;
|
bool result=false;
|
||||||
if (opcode==OP_Combined && size+rhs->size+5<256) {
|
if (opcode==OP_Combined && size+rhs->size+5<256) {
|
||||||
auto tmpbuffer = new unsigned char[size + rhs->size + 3];
|
unsigned char *tmpbuffer=new unsigned char [size+rhs->size+3];
|
||||||
memcpy(tmpbuffer,pBuffer,size);
|
memcpy(tmpbuffer,pBuffer,size);
|
||||||
uint32 offset=size;
|
uint32 offset=size;
|
||||||
tmpbuffer[offset++]=rhs->Size();
|
tmpbuffer[offset++]=rhs->Size();
|
||||||
@@ -270,7 +266,7 @@ bool result=false;
|
|||||||
pBuffer=tmpbuffer;
|
pBuffer=tmpbuffer;
|
||||||
result=true;
|
result=true;
|
||||||
} else if (size+rhs->size+7<256) {
|
} else if (size+rhs->size+7<256) {
|
||||||
auto tmpbuffer = new unsigned char[size + rhs->size + 6];
|
unsigned char *tmpbuffer=new unsigned char [size+rhs->size+6];
|
||||||
uint32 offset=0;
|
uint32 offset=0;
|
||||||
tmpbuffer[offset++]=Size();
|
tmpbuffer[offset++]=Size();
|
||||||
offset+=serialize(tmpbuffer+offset);
|
offset+=serialize(tmpbuffer+offset);
|
||||||
@@ -457,7 +453,7 @@ EQApplicationPacket *EQApplicationPacket::Copy() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
|
EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
|
||||||
auto res = new EQRawApplicationPacket(opcode, pBuffer, size);
|
EQRawApplicationPacket *res = new EQRawApplicationPacket(opcode, pBuffer, size);
|
||||||
res->copyInfo(this);
|
res->copyInfo(this);
|
||||||
return(res);
|
return(res);
|
||||||
}
|
}
|
||||||
@@ -511,8 +507,3 @@ void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
|
|||||||
// DumpPacketAscii(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();
|
|
||||||
}
|
|
||||||
+8
-11
@@ -19,8 +19,9 @@
|
|||||||
#define _EQPACKET_H
|
#define _EQPACKET_H
|
||||||
|
|
||||||
#include "base_packet.h"
|
#include "base_packet.h"
|
||||||
|
#include "eq_stream_type.h"
|
||||||
|
#include "op_codes.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#ifdef STATIC_OPCODE
|
#ifdef STATIC_OPCODE
|
||||||
typedef unsigned short EmuOpcode;
|
typedef unsigned short EmuOpcode;
|
||||||
@@ -29,6 +30,9 @@
|
|||||||
#include "emu_opcodes.h"
|
#include "emu_opcodes.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class EQStream;
|
||||||
|
class EQStreamPair;
|
||||||
|
|
||||||
class EQPacket : public BasePacket {
|
class EQPacket : public BasePacket {
|
||||||
friend class EQStream;
|
friend class EQStream;
|
||||||
public:
|
public:
|
||||||
@@ -51,7 +55,6 @@ protected:
|
|||||||
EmuOpcode emu_opcode;
|
EmuOpcode emu_opcode;
|
||||||
|
|
||||||
EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len);
|
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(const EQPacket &p) { }
|
||||||
EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; }
|
EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; }
|
||||||
|
|
||||||
@@ -63,7 +66,7 @@ class EQProtocolPacket : public BasePacket {
|
|||||||
friend class EQStream;
|
friend class EQStream;
|
||||||
friend class EQStreamPair;
|
friend class EQStreamPair;
|
||||||
public:
|
public:
|
||||||
EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) : BasePacket(buf, len), opcode(op) { acked = false; sent_time = 0; }
|
EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) : BasePacket(buf,len), opcode(op) { acked = false; }
|
||||||
// EQProtocolPacket(const unsigned char *buf, uint32 len);
|
// EQProtocolPacket(const unsigned char *buf, uint32 len);
|
||||||
bool combine(const EQProtocolPacket *rhs);
|
bool combine(const EQProtocolPacket *rhs);
|
||||||
uint32 serialize (unsigned char *dest) const;
|
uint32 serialize (unsigned char *dest) const;
|
||||||
@@ -71,7 +74,6 @@ public:
|
|||||||
EQRawApplicationPacket *MakeAppPacket() const;
|
EQRawApplicationPacket *MakeAppPacket() const;
|
||||||
|
|
||||||
bool acked;
|
bool acked;
|
||||||
uint32 sent_time;
|
|
||||||
|
|
||||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||||
virtual void build_header_dump(char *buffer) const;
|
virtual void build_header_dump(char *buffer) const;
|
||||||
@@ -105,8 +107,6 @@ public:
|
|||||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||||
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op, buf, len), opcode_bypass(0)
|
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; }
|
{ 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);
|
bool combine(const EQApplicationPacket *rhs);
|
||||||
uint32 serialize (uint16 opcode, unsigned char *dest) const;
|
uint32 serialize (uint16 opcode, unsigned char *dest) const;
|
||||||
uint32 Size() const { return size+app_opcode_size; }
|
uint32 Size() const { return size+app_opcode_size; }
|
||||||
@@ -118,14 +118,11 @@ public:
|
|||||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||||
|
|
||||||
uint16 GetOpcodeBypass() const { return opcode_bypass; }
|
uint16 GetOpcodeBypass() { return opcode_bypass; }
|
||||||
void SetOpcodeBypass(uint16 v) { opcode_bypass = v; }
|
void SetOpcodeBypass(uint16 v) { opcode_bypass = v; }
|
||||||
|
|
||||||
uint16 GetProtocolOpcode() const { return protocol_opcode; }
|
|
||||||
void SetProtocolOpcode(uint16 v) { protocol_opcode = v; }
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
uint16 protocol_opcode;
|
|
||||||
uint8 app_opcode_size;
|
uint8 app_opcode_size;
|
||||||
uint16 opcode_bypass;
|
uint16 opcode_bypass;
|
||||||
private:
|
private:
|
||||||
@@ -154,6 +151,6 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern void DumpPacket(const EQApplicationPacket* app, bool iShowInfo = false);
|
extern void DumpPacket(const EQApplicationPacket* app, bool iShowInfo = false);
|
||||||
extern std::string DumpPacketToString(const EQApplicationPacket* app);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+411
-681
File diff suppressed because it is too large
Load Diff
+307
-306
File diff suppressed because it is too large
Load Diff
+28
-52
@@ -1,26 +1,22 @@
|
|||||||
#ifndef _EQSTREAM_H
|
#ifndef _EQSTREAM_H
|
||||||
#define _EQSTREAM_H
|
#define _EQSTREAM_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "eq_stream_type.h"
|
||||||
#include "../common/misc.h"
|
|
||||||
#include "../common/opcodemgr.h"
|
|
||||||
#include "../common/timer.h"
|
|
||||||
|
|
||||||
#include "eq_packet.h"
|
#include "eq_packet.h"
|
||||||
#include "eq_stream_intf.h"
|
#include "eq_stream_intf.h"
|
||||||
#include "eq_stream_type.h"
|
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
|
#include "../common/opcodemgr.h"
|
||||||
class EQApplicationPacket;
|
#include "../common/misc.h"
|
||||||
class EQProtocolPacket;
|
#include "../common/condition.h"
|
||||||
|
#include "../common/timer.h"
|
||||||
|
|
||||||
#define FLAG_COMPRESSED 0x01
|
#define FLAG_COMPRESSED 0x01
|
||||||
#define FLAG_ENCODED 0x04
|
#define FLAG_ENCODED 0x04
|
||||||
@@ -49,10 +45,6 @@ class EQProtocolPacket;
|
|||||||
#define RETRANSMIT_ACKED_PACKETS true
|
#define RETRANSMIT_ACKED_PACKETS true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAX_SESSION_RETRIES
|
|
||||||
#define MAX_SESSION_RETRIES 30
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
struct SessionRequest {
|
struct SessionRequest {
|
||||||
uint32 UnknownA;
|
uint32 UnknownA;
|
||||||
@@ -71,7 +63,7 @@ struct SessionResponse {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Deltas are in ms, representing round trip times
|
//Deltas are in ms, representing round trip times
|
||||||
struct ClientSessionStats {
|
struct SessionStats {
|
||||||
/*000*/ uint16 RequestID;
|
/*000*/ uint16 RequestID;
|
||||||
/*002*/ uint32 last_local_delta;
|
/*002*/ uint32 last_local_delta;
|
||||||
/*006*/ uint32 average_delta;
|
/*006*/ uint32 average_delta;
|
||||||
@@ -83,19 +75,10 @@ struct ClientSessionStats {
|
|||||||
/*038*/
|
/*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()
|
#pragma pack()
|
||||||
|
|
||||||
class OpcodeManager;
|
class OpcodeManager;
|
||||||
|
class EQStreamPair;
|
||||||
class EQRawApplicationPacket;
|
class EQRawApplicationPacket;
|
||||||
|
|
||||||
class EQStream : public EQStreamInterface {
|
class EQStream : public EQStreamInterface {
|
||||||
@@ -118,9 +101,6 @@ class EQStream : public EQStreamInterface {
|
|||||||
uint32 retransmittimer;
|
uint32 retransmittimer;
|
||||||
uint32 retransmittimeout;
|
uint32 retransmittimeout;
|
||||||
|
|
||||||
uint16 sessionAttempts;
|
|
||||||
bool streamactive;
|
|
||||||
|
|
||||||
//uint32 buffer_len;
|
//uint32 buffer_len;
|
||||||
|
|
||||||
uint32 Session, Key;
|
uint32 Session, Key;
|
||||||
@@ -153,6 +133,7 @@ class EQStream : public EQStreamInterface {
|
|||||||
std::deque<EQProtocolPacket *> SequencedQueue;
|
std::deque<EQProtocolPacket *> SequencedQueue;
|
||||||
uint16 NextOutSeq;
|
uint16 NextOutSeq;
|
||||||
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
|
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
|
||||||
|
long NextSequencedSend; //index into SequencedQueue
|
||||||
Mutex MOutboundQueue;
|
Mutex MOutboundQueue;
|
||||||
|
|
||||||
//a buffer we use for compression/decompression
|
//a buffer we use for compression/decompression
|
||||||
@@ -167,13 +148,10 @@ class EQStream : public EQStreamInterface {
|
|||||||
|
|
||||||
int32 BytesWritten;
|
int32 BytesWritten;
|
||||||
|
|
||||||
uint64 sent_packet_count;
|
|
||||||
uint64 received_packet_count;
|
|
||||||
|
|
||||||
Mutex MRate;
|
Mutex MRate;
|
||||||
int32 RateThreshold;
|
int32 RateThreshold;
|
||||||
int32 DecayRate;
|
int32 DecayRate;
|
||||||
uint32 AverageDelta;
|
|
||||||
|
|
||||||
OpcodeManager **OpMgr;
|
OpcodeManager **OpMgr;
|
||||||
|
|
||||||
@@ -216,16 +194,10 @@ class EQStream : public EQStreamInterface {
|
|||||||
|
|
||||||
void _SendDisconnect();
|
void _SendDisconnect();
|
||||||
|
|
||||||
void init(bool resetSession=true);
|
void init();
|
||||||
public:
|
public:
|
||||||
EQStream() { init(); remote_ip = 0; remote_port = 0; State = UNESTABLISHED;
|
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(); }
|
||||||
StreamType = UnknownStream; compressed = true; encoded = false; app_opcode_size = 2;
|
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(); }
|
||||||
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); }
|
virtual ~EQStream() { RemoveData(); SetState(CLOSED); }
|
||||||
void SetMaxLen(uint32 length) { MaxLen=length; }
|
void SetMaxLen(uint32 length) { MaxLen=length; }
|
||||||
|
|
||||||
@@ -241,7 +213,7 @@ class EQStream : public EQStreamInterface {
|
|||||||
virtual bool CheckState(EQStreamState state) { return GetState() == state; }
|
virtual bool CheckState(EQStreamState state) { return GetState() == state; }
|
||||||
virtual std::string Describe() const { return("Direct EQStream"); }
|
virtual std::string Describe() const { return("Direct EQStream"); }
|
||||||
|
|
||||||
virtual void SetOpcodeManager(OpcodeManager **opm) { OpMgr = opm; }
|
void SetOpcodeManager(OpcodeManager **opm) { OpMgr = opm; }
|
||||||
|
|
||||||
void CheckTimeout(uint32 now, uint32 timeout=30);
|
void CheckTimeout(uint32 now, uint32 timeout=30);
|
||||||
bool HasOutgoingData();
|
bool HasOutgoingData();
|
||||||
@@ -249,14 +221,11 @@ class EQStream : public EQStreamInterface {
|
|||||||
void SetLastPacketTime(uint32 t) {LastPacket=t;}
|
void SetLastPacketTime(uint32 t) {LastPacket=t;}
|
||||||
void Write(int eq_fd);
|
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 bool IsInUse() { bool flag; MInUse.lock(); flag=(active_users>0); MInUse.unlock(); return flag; }
|
||||||
inline void PutInUse() { MInUse.lock(); active_users++; MInUse.unlock(); }
|
inline void PutInUse() { MInUse.lock(); active_users++; MInUse.unlock(); }
|
||||||
|
|
||||||
virtual EQStreamState GetState() { EQStreamState s; MState.lock(); s=State; MState.unlock(); return s; }
|
inline EQStreamState GetState() { EQStreamState s; MState.lock(); s=State; MState.unlock(); return s; }
|
||||||
|
|
||||||
static SeqOrder CompareSequence(uint16 expected_seq , uint16 seq);
|
static SeqOrder CompareSequence(uint16 expected_seq , uint16 seq);
|
||||||
|
|
||||||
@@ -277,13 +246,11 @@ class EQStream : public EQStreamInterface {
|
|||||||
void AddBytesSent(uint32 bytes)
|
void AddBytesSent(uint32 bytes)
|
||||||
{
|
{
|
||||||
bytes_sent += bytes;
|
bytes_sent += bytes;
|
||||||
++sent_packet_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddBytesRecv(uint32 bytes)
|
void AddBytesRecv(uint32 bytes)
|
||||||
{
|
{
|
||||||
bytes_recv += bytes;
|
bytes_recv += bytes;
|
||||||
++received_packet_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const uint32 GetBytesSent() const { return bytes_sent; }
|
virtual const uint32 GetBytesSent() const { return bytes_sent; }
|
||||||
@@ -302,11 +269,20 @@ class EQStream : public EQStreamInterface {
|
|||||||
return bytes_recv / (Timer::GetTimeSeconds() - create_time);
|
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
|
//used for dynamic stream identification
|
||||||
virtual MatchState CheckSignature(const Signature *sig);
|
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;
|
||||||
|
MatchState CheckSignature(const Signature *sig);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#include "global_define.h"
|
#include "debug.h"
|
||||||
#include "eqemu_logsys.h"
|
|
||||||
#include "eq_stream_factory.h"
|
#include "eq_stream_factory.h"
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <winsock2.h>
|
#include <winsock.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -15,18 +13,26 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <iostream>
|
||||||
#include "op_codes.h"
|
#include "op_codes.h"
|
||||||
|
#include "eq_stream.h"
|
||||||
|
#include "logsys.h"
|
||||||
|
|
||||||
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
|
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
|
||||||
{
|
{
|
||||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
_log(COMMON__THREADS, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||||
|
#endif
|
||||||
|
|
||||||
fs->ReaderLoop();
|
fs->ReaderLoop();
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
_log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||||
|
#endif
|
||||||
|
|
||||||
THREAD_RETURN(nullptr);
|
THREAD_RETURN(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,8 +40,16 @@ ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
|
|||||||
{
|
{
|
||||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
_log(COMMON__THREADS, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
|
||||||
|
#endif
|
||||||
|
|
||||||
fs->WriterLoop();
|
fs->WriterLoop();
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
_log(COMMON__THREADS, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
|
||||||
|
#endif
|
||||||
|
|
||||||
THREAD_RETURN(nullptr);
|
THREAD_RETURN(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +104,8 @@ struct sockaddr_in address;
|
|||||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||||
#endif
|
#endif
|
||||||
//moved these because on windows the output was delayed and causing the console window to look bad
|
//moved these because on windows the output was delayed and causing the console window to look bad
|
||||||
|
//std::cout << "Starting factory Reader" << std::endl;
|
||||||
|
//std::cout << "Starting factory Writer" << std::endl;
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
_beginthread(EQStreamFactoryReaderLoop,0, this);
|
_beginthread(EQStreamFactoryReaderLoop,0, this);
|
||||||
_beginthread(EQStreamFactoryWriterLoop,0, this);
|
_beginthread(EQStreamFactoryWriterLoop,0, this);
|
||||||
@@ -100,39 +116,44 @@ struct sockaddr_in address;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<EQStream> EQStreamFactory::Pop()
|
EQStream *EQStreamFactory::Pop()
|
||||||
{
|
{
|
||||||
std::shared_ptr<EQStream> s = nullptr;
|
EQStream *s=nullptr;
|
||||||
|
//std::cout << "Pop():Locking MNewStreams" << std::endl;
|
||||||
MNewStreams.lock();
|
MNewStreams.lock();
|
||||||
if (!NewStreams.empty()) {
|
if (NewStreams.size()) {
|
||||||
s = NewStreams.front();
|
s=NewStreams.front();
|
||||||
NewStreams.pop();
|
NewStreams.pop();
|
||||||
s->PutInUse();
|
s->PutInUse();
|
||||||
}
|
}
|
||||||
MNewStreams.unlock();
|
MNewStreams.unlock();
|
||||||
|
//std::cout << "Pop(): Unlocking MNewStreams" << std::endl;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQStreamFactory::Push(std::shared_ptr<EQStream> s)
|
void EQStreamFactory::Push(EQStream *s)
|
||||||
{
|
{
|
||||||
|
//std::cout << "Push():Locking MNewStreams" << std::endl;
|
||||||
MNewStreams.lock();
|
MNewStreams.lock();
|
||||||
NewStreams.push(s);
|
NewStreams.push(s);
|
||||||
MNewStreams.unlock();
|
MNewStreams.unlock();
|
||||||
|
//std::cout << "Push(): Unlocking MNewStreams" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQStreamFactory::ReaderLoop()
|
void EQStreamFactory::ReaderLoop()
|
||||||
{
|
{
|
||||||
fd_set readset;
|
fd_set readset;
|
||||||
std::map<std::pair<uint32, uint16>, std::shared_ptr<EQStream>>::iterator stream_itr;
|
std::map<std::pair<uint32, uint16>,EQStream *>::iterator stream_itr;
|
||||||
int num;
|
int num;
|
||||||
int length;
|
int length;
|
||||||
unsigned char buffer[2048];
|
unsigned char buffer[2048];
|
||||||
sockaddr_in from;
|
sockaddr_in from;
|
||||||
int socklen = sizeof(sockaddr_in);
|
int socklen=sizeof(sockaddr_in);
|
||||||
timeval sleep_time;
|
timeval sleep_time;
|
||||||
ReaderRunning = true;
|
//time_t now;
|
||||||
|
|
||||||
|
ReaderRunning=true;
|
||||||
while(sock!=-1) {
|
while(sock!=-1) {
|
||||||
MReaderRunning.lock();
|
MReaderRunning.lock();
|
||||||
if (!ReaderRunning)
|
if (!ReaderRunning)
|
||||||
@@ -163,10 +184,10 @@ void EQStreamFactory::ReaderLoop()
|
|||||||
// What do we wanna do?
|
// What do we wanna do?
|
||||||
} else {
|
} else {
|
||||||
MStreams.lock();
|
MStreams.lock();
|
||||||
stream_itr = Streams.find(std::make_pair(from.sin_addr.s_addr, from.sin_port));
|
stream_itr=Streams.find(std::make_pair(from.sin_addr.s_addr, from.sin_port));
|
||||||
if (stream_itr == Streams.end()) {
|
if (stream_itr == Streams.end()) {
|
||||||
if (buffer[1]==OP_SessionRequest) {
|
if (buffer[1]==OP_SessionRequest) {
|
||||||
std::shared_ptr<EQStream> s = std::make_shared<EQStream>(from);
|
EQStream *s = new EQStream(from);
|
||||||
s->SetStreamType(StreamType);
|
s->SetStreamType(StreamType);
|
||||||
Streams[std::make_pair(from.sin_addr.s_addr, from.sin_port)]=s;
|
Streams[std::make_pair(from.sin_addr.s_addr, from.sin_port)]=s;
|
||||||
WriterWork.Signal();
|
WriterWork.Signal();
|
||||||
@@ -177,13 +198,13 @@ void EQStreamFactory::ReaderLoop()
|
|||||||
}
|
}
|
||||||
MStreams.unlock();
|
MStreams.unlock();
|
||||||
} else {
|
} else {
|
||||||
std::shared_ptr<EQStream> curstream = stream_itr->second;
|
EQStream *curstream = stream_itr->second;
|
||||||
//dont bother processing incoming packets for closed connections
|
//dont bother processing incoming packets for closed connections
|
||||||
if(curstream->CheckClosed())
|
if(curstream->CheckClosed())
|
||||||
curstream = nullptr;
|
curstream = nullptr;
|
||||||
else
|
else
|
||||||
curstream->PutInUse();
|
curstream->PutInUse();
|
||||||
//the in use flag prevents the stream from being deleted while we are using it.
|
MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it.
|
||||||
|
|
||||||
if(curstream) {
|
if(curstream) {
|
||||||
curstream->AddBytesRecv(length);
|
curstream->AddBytesRecv(length);
|
||||||
@@ -191,7 +212,6 @@ void EQStreamFactory::ReaderLoop()
|
|||||||
curstream->SetLastPacketTime(Timer::GetCurrentTime());
|
curstream->SetLastPacketTime(Timer::GetCurrentTime());
|
||||||
curstream->ReleaseFromUse();
|
curstream->ReleaseFromUse();
|
||||||
}
|
}
|
||||||
MStreams.unlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,10 +224,10 @@ void EQStreamFactory::CheckTimeout()
|
|||||||
MStreams.lock();
|
MStreams.lock();
|
||||||
|
|
||||||
unsigned long now=Timer::GetCurrentTime();
|
unsigned long now=Timer::GetCurrentTime();
|
||||||
std::map<std::pair<uint32, uint16>, std::shared_ptr<EQStream>>::iterator stream_itr;
|
std::map<std::pair<uint32, uint16>,EQStream *>::iterator stream_itr;
|
||||||
|
|
||||||
for(stream_itr = Streams.begin(); stream_itr != Streams.end();) {
|
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
|
||||||
std::shared_ptr<EQStream> s = stream_itr->second;
|
EQStream *s = stream_itr->second;
|
||||||
|
|
||||||
s->CheckTimeout(now, stream_timeout);
|
s->CheckTimeout(now, stream_timeout);
|
||||||
|
|
||||||
@@ -219,9 +239,11 @@ void EQStreamFactory::CheckTimeout()
|
|||||||
//give it a little time for everybody to finish with it
|
//give it a little time for everybody to finish with it
|
||||||
} else {
|
} else {
|
||||||
//everybody is done, we can delete it now
|
//everybody is done, we can delete it now
|
||||||
auto temp = stream_itr;
|
//std::cout << "Removing connection" << std::endl;
|
||||||
|
std::map<std::pair<uint32, uint16>,EQStream *>::iterator temp=stream_itr;
|
||||||
++stream_itr;
|
++stream_itr;
|
||||||
temp->second = nullptr;
|
//let whoever has the stream outside delete it
|
||||||
|
delete temp->second;
|
||||||
Streams.erase(temp);
|
Streams.erase(temp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -234,16 +256,21 @@ void EQStreamFactory::CheckTimeout()
|
|||||||
|
|
||||||
void EQStreamFactory::WriterLoop()
|
void EQStreamFactory::WriterLoop()
|
||||||
{
|
{
|
||||||
bool havework = true;
|
std::map<std::pair<uint32, uint16>,EQStream *>::iterator stream_itr;
|
||||||
std::vector<std::shared_ptr<EQStream>> wants_write;
|
bool havework=true;
|
||||||
std::vector<std::shared_ptr<EQStream>>::iterator cur, end;
|
std::vector<EQStream *> wants_write;
|
||||||
bool decay = false;
|
std::vector<EQStream *>::iterator cur,end;
|
||||||
uint32 stream_count;
|
bool decay=false;
|
||||||
Timer DecayTimer(20);
|
uint32 stream_count;
|
||||||
WriterRunning = true;
|
|
||||||
DecayTimer.Enable();
|
|
||||||
|
|
||||||
while (sock != -1) {
|
Timer DecayTimer(20);
|
||||||
|
|
||||||
|
WriterRunning=true;
|
||||||
|
DecayTimer.Enable();
|
||||||
|
while(sock!=-1) {
|
||||||
|
//if (!havework) {
|
||||||
|
//WriterWork.Wait();
|
||||||
|
//}
|
||||||
MWriterRunning.lock();
|
MWriterRunning.lock();
|
||||||
if (!WriterRunning)
|
if (!WriterRunning)
|
||||||
break;
|
break;
|
||||||
@@ -252,36 +279,34 @@ void EQStreamFactory::WriterLoop()
|
|||||||
havework = false;
|
havework = false;
|
||||||
wants_write.clear();
|
wants_write.clear();
|
||||||
|
|
||||||
decay = DecayTimer.Check();
|
decay=DecayTimer.Check();
|
||||||
|
|
||||||
// copy streams into a seperate list so we dont have to keep
|
//copy streams into a seperate list so we dont have to keep
|
||||||
// MStreams locked while we are writting
|
//MStreams locked while we are writting
|
||||||
MStreams.lock();
|
MStreams.lock();
|
||||||
for (auto stream_itr = Streams.begin(); stream_itr != Streams.end(); ++stream_itr) {
|
for(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 it's time to decay the bytes sent, then let's do it before we try to write
|
||||||
if (decay)
|
if (decay)
|
||||||
stream_itr->second->Decay();
|
stream_itr->second->Decay();
|
||||||
|
|
||||||
// bullshit checking, to see if this is really happening, GDB seems to think so...
|
//bullshit checking, to see if this is really happening, GDB seems to think so...
|
||||||
if (stream_itr->second == nullptr) {
|
if(stream_itr->second == nullptr) {
|
||||||
fprintf(stderr,
|
fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %i", stream_itr->first.first, stream_itr->first.second);
|
||||||
"ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %i:%i",
|
|
||||||
stream_itr->first.first, stream_itr->first.second);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream_itr->second->HasOutgoingData()) {
|
if (stream_itr->second->HasOutgoingData()) {
|
||||||
havework = true;
|
havework=true;
|
||||||
stream_itr->second->PutInUse();
|
stream_itr->second->PutInUse();
|
||||||
wants_write.push_back(stream_itr->second);
|
wants_write.push_back(stream_itr->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MStreams.unlock();
|
MStreams.unlock();
|
||||||
|
|
||||||
// do the actual writes
|
//do the actual writes
|
||||||
cur = wants_write.begin();
|
cur = wants_write.begin();
|
||||||
end = wants_write.end();
|
end = wants_write.end();
|
||||||
for (; cur != end; ++cur) {
|
for(; cur != end; ++cur) {
|
||||||
(*cur)->Write(sock);
|
(*cur)->Write(sock);
|
||||||
(*cur)->ReleaseFromUse();
|
(*cur)->ReleaseFromUse();
|
||||||
}
|
}
|
||||||
@@ -289,10 +314,12 @@ void EQStreamFactory::WriterLoop()
|
|||||||
Sleep(10);
|
Sleep(10);
|
||||||
|
|
||||||
MStreams.lock();
|
MStreams.lock();
|
||||||
stream_count = Streams.size();
|
stream_count=Streams.size();
|
||||||
MStreams.unlock();
|
MStreams.unlock();
|
||||||
if (!stream_count) {
|
if (!stream_count) {
|
||||||
|
//std::cout << "No streams, waiting on condition" << std::endl;
|
||||||
WriterWork.Wait();
|
WriterWork.Wait();
|
||||||
|
//std::cout << "Awake from condition, must have a stream now" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,13 @@
|
|||||||
|
|
||||||
#define _EQSTREAMFACTORY_H
|
#define _EQSTREAMFACTORY_H
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "../common/eq_stream.h"
|
#include "../common/eq_stream.h"
|
||||||
#include "../common/condition.h"
|
#include "../common/condition.h"
|
||||||
#include "../common/timeoutmgr.h"
|
#include "../common/timeoutmgr.h"
|
||||||
|
#include "../common/opcodemgr.h"
|
||||||
class EQStream;
|
#include "../common/timer.h"
|
||||||
class Timer;
|
|
||||||
|
|
||||||
class EQStreamFactory : private Timeoutable {
|
class EQStreamFactory : private Timeoutable {
|
||||||
private:
|
private:
|
||||||
@@ -27,10 +24,10 @@ class EQStreamFactory : private Timeoutable {
|
|||||||
|
|
||||||
EQStreamType StreamType;
|
EQStreamType StreamType;
|
||||||
|
|
||||||
std::queue<std::shared_ptr<EQStream>> NewStreams;
|
std::queue<EQStream *> NewStreams;
|
||||||
Mutex MNewStreams;
|
Mutex MNewStreams;
|
||||||
|
|
||||||
std::map<std::pair<uint32, uint16>, std::shared_ptr<EQStream>> Streams;
|
std::map<std::pair<uint32, uint16>,EQStream *> Streams;
|
||||||
Mutex MStreams;
|
Mutex MStreams;
|
||||||
|
|
||||||
virtual void CheckTimeout();
|
virtual void CheckTimeout();
|
||||||
@@ -43,8 +40,8 @@ class EQStreamFactory : private Timeoutable {
|
|||||||
EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; }
|
EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; }
|
||||||
EQStreamFactory(EQStreamType type, int port, uint32 timeout = 135000);
|
EQStreamFactory(EQStreamType type, int port, uint32 timeout = 135000);
|
||||||
|
|
||||||
std::shared_ptr<EQStream> Pop();
|
EQStream *Pop();
|
||||||
void Push(std::shared_ptr<EQStream> s);
|
void Push(EQStream *s);
|
||||||
|
|
||||||
bool Open();
|
bool Open();
|
||||||
bool Open(unsigned long port) { Port=port; return Open(); }
|
bool Open(unsigned long port) { Port=port; return Open(); }
|
||||||
|
|||||||
+42
-44
@@ -1,22 +1,20 @@
|
|||||||
#include <utility>
|
#include "debug.h"
|
||||||
|
|
||||||
#include "global_define.h"
|
|
||||||
#include "eqemu_logsys.h"
|
|
||||||
#include "eq_stream_ident.h"
|
#include "eq_stream_ident.h"
|
||||||
#include "eq_stream_proxy.h"
|
#include "eq_stream_proxy.h"
|
||||||
#include "misc.h"
|
#include "logsys.h"
|
||||||
|
|
||||||
EQStreamIdentifier::~EQStreamIdentifier() {
|
EQStreamIdentifier::~EQStreamIdentifier() {
|
||||||
while(!m_identified.empty()) {
|
while(!m_identified.empty()) {
|
||||||
m_identified.front()->ReleaseFromUse();
|
m_identified.front()->ReleaseFromUse();
|
||||||
m_identified.pop();
|
m_identified.pop();
|
||||||
}
|
}
|
||||||
std::vector<Record>::iterator cur, end;
|
std::vector<Record *>::iterator cur, end;
|
||||||
cur = m_streams.begin();
|
cur = m_streams.begin();
|
||||||
end = m_streams.end();
|
end = m_streams.end();
|
||||||
for(; cur != end; ++cur) {
|
for(; cur != end; ++cur) {
|
||||||
Record &r = *cur;
|
Record *r = *cur;
|
||||||
r.stream->ReleaseFromUse();
|
r->stream->ReleaseFromUse();
|
||||||
|
delete r;
|
||||||
}
|
}
|
||||||
std::vector<Patch *>::iterator curp, endp;
|
std::vector<Patch *>::iterator curp, endp;
|
||||||
curp = m_patches.begin();
|
curp = m_patches.begin();
|
||||||
@@ -26,8 +24,8 @@ EQStreamIdentifier::~EQStreamIdentifier() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQStreamIdentifier::RegisterPatch(const EQStreamInterface::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs) {
|
void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs) {
|
||||||
auto p = new Patch;
|
Patch *p = new Patch;
|
||||||
p->signature = sig;
|
p->signature = sig;
|
||||||
p->name = name;
|
p->name = name;
|
||||||
p->opcodes = opcodes;
|
p->opcodes = opcodes;
|
||||||
@@ -36,52 +34,54 @@ void EQStreamIdentifier::RegisterPatch(const EQStreamInterface::Signature &sig,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EQStreamIdentifier::Process() {
|
void EQStreamIdentifier::Process() {
|
||||||
std::vector<Record>::iterator cur;
|
std::vector<Record *>::iterator cur;
|
||||||
std::vector<Patch *>::iterator curp, endp;
|
std::vector<Patch *>::iterator curp, endp;
|
||||||
|
|
||||||
//foreach pending stream.
|
//foreach pending stream.
|
||||||
cur = m_streams.begin();
|
cur = m_streams.begin();
|
||||||
while(cur != m_streams.end()) {
|
while(cur != m_streams.end()) {
|
||||||
Record &r = *cur;
|
Record *r = *cur;
|
||||||
|
|
||||||
//first see if this stream has expired
|
//first see if this stream has expired
|
||||||
if(r.expire.Check(false)) {
|
if(r->expire.Check(false)) {
|
||||||
LogNetcode("[StreamIdentify] Unable to identify stream from [{}:{}] before timeout", r.stream->GetRemoteAddr().c_str(), ntohs(r.stream->GetRemotePort()));
|
//this stream has failed to match any pattern in our timeframe.
|
||||||
r.stream->Close();
|
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d before timeout.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||||
|
r->stream->ReleaseFromUse();
|
||||||
|
delete r;
|
||||||
cur = m_streams.erase(cur);
|
cur = m_streams.erase(cur);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//then make sure the stream is still active
|
//then make sure the stream is still active
|
||||||
//if stream hasn't finished initializing then continue;
|
//if stream hasn't finished initializing then continue;
|
||||||
if(r.stream->GetState() == UNESTABLISHED)
|
if(r->stream->GetState() == UNESTABLISHED)
|
||||||
{
|
{
|
||||||
++cur;
|
++cur;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(r.stream->GetState() != ESTABLISHED) {
|
if(r->stream->GetState() != ESTABLISHED) {
|
||||||
//the stream closed before it was identified.
|
//the stream closed before it was identified.
|
||||||
LogNetcode("[StreamIdentify] Unable to identify stream from [{}:{}] before it closed", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()));
|
_log(NET__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())
|
switch(r->stream->GetState())
|
||||||
{
|
{
|
||||||
case ESTABLISHED:
|
case ESTABLISHED:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Established");
|
_log(NET__IDENTIFY, "Stream state was Established");
|
||||||
break;
|
break;
|
||||||
case CLOSING:
|
case CLOSING:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Closing");
|
_log(NET__IDENTIFY, "Stream state was Closing");
|
||||||
break;
|
break;
|
||||||
case DISCONNECTING:
|
case DISCONNECTING:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Disconnecting");
|
_log(NET__IDENTIFY, "Stream state was Disconnecting");
|
||||||
break;
|
break;
|
||||||
case CLOSED:
|
case CLOSED:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Closed");
|
_log(NET__IDENTIFY, "Stream state was Closed");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Unestablished or unknown");
|
_log(NET__IDENTIFY, "Stream state was Unestablished or unknown");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
r.stream->ReleaseFromUse();
|
r->stream->ReleaseFromUse();
|
||||||
|
delete r;
|
||||||
cur = m_streams.erase(cur);
|
cur = m_streams.erase(cur);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -98,31 +98,28 @@ void EQStreamIdentifier::Process() {
|
|||||||
Patch *p = *curp;
|
Patch *p = *curp;
|
||||||
|
|
||||||
//ask the stream to see if it matches the supplied signature
|
//ask the stream to see if it matches the supplied signature
|
||||||
EQStreamInterface::MatchState res = r.stream->CheckSignature(&p->signature);
|
EQStream::MatchState res = r->stream->CheckSignature(&p->signature);
|
||||||
switch(res) {
|
switch(res) {
|
||||||
case EQStreamInterface::MatchNotReady:
|
case EQStream::MatchNotReady:
|
||||||
//the stream has not received enough packets to compare with this signature
|
//the stream has not received enough packets to compare with this signature
|
||||||
// Log.LogDebugType(Logs::General, Logs::Netcode, "[StreamIdentify] %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());
|
// _log(NET__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;
|
all_ready = false;
|
||||||
break;
|
break;
|
||||||
case EQStreamInterface::MatchSuccessful: {
|
case EQStream::MatchSuccessful: {
|
||||||
//yay, a match.
|
//yay, a match.
|
||||||
|
|
||||||
LogNetcode("[StreamIdentify] Identified stream [{}:{}] with signature [{}]", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
|
_log(NET__IDENTIFY, "Identified stream %s:%d with signature %s", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
|
||||||
|
|
||||||
// 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..
|
//might want to do something less-specific here... some day..
|
||||||
EQStreamInterface *s = new EQStreamProxy(r.stream, p->structs, p->opcodes);
|
EQStreamInterface *s = new EQStreamProxy(r->stream, p->structs, p->opcodes);
|
||||||
m_identified.push(s);
|
m_identified.push(s);
|
||||||
|
|
||||||
found_one = true;
|
found_one = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EQStreamInterface::MatchFailed:
|
case EQStream::MatchFailed:
|
||||||
//do nothing...
|
//do nothing...
|
||||||
LogNetcode("[StreamIdentify] [{}:{}] Tried patch [{}] and it did not match", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
|
_log(NET__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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,13 +127,14 @@ void EQStreamIdentifier::Process() {
|
|||||||
//if we checked all patches and did not find a match.
|
//if we checked all patches and did not find a match.
|
||||||
if(all_ready && !found_one) {
|
if(all_ready && !found_one) {
|
||||||
//the stream cannot be identified.
|
//the stream cannot be identified.
|
||||||
LogNetcode("[StreamIdentify] Unable to identify stream from [{}:{}], no match found", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()));
|
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d, no match found.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||||
r.stream->ReleaseFromUse();
|
r->stream->ReleaseFromUse();
|
||||||
}
|
}
|
||||||
|
|
||||||
//if we found a match, or were not able to identify it
|
//if we found a match, or were not able to identify it
|
||||||
if(found_one || all_ready) {
|
if(found_one || all_ready) {
|
||||||
//cannot print ip/port here. r.stream is invalid.
|
//cannot print ip/port here. r->stream is invalid.
|
||||||
|
delete r;
|
||||||
cur = m_streams.erase(cur);
|
cur = m_streams.erase(cur);
|
||||||
} else {
|
} else {
|
||||||
++cur;
|
++cur;
|
||||||
@@ -144,8 +142,8 @@ void EQStreamIdentifier::Process() {
|
|||||||
} //end foreach stream
|
} //end foreach stream
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQStreamIdentifier::AddStream(std::shared_ptr<EQStreamInterface> eqs) {
|
void EQStreamIdentifier::AddStream(EQStream *&eqs) {
|
||||||
m_streams.push_back(Record(eqs));
|
m_streams.push_back(new Record(eqs));
|
||||||
eqs = nullptr;
|
eqs = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,8 +155,8 @@ EQStreamInterface *EQStreamIdentifier::PopIdentified() {
|
|||||||
return(res);
|
return(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
EQStreamIdentifier::Record::Record(std::shared_ptr<EQStreamInterface> s)
|
EQStreamIdentifier::Record::Record(EQStream *s)
|
||||||
: stream(std::move(s)),
|
: stream(s),
|
||||||
expire(STREAM_IDENT_WAIT_MS)
|
expire(STREAM_IDENT_WAIT_MS)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,27 @@
|
|||||||
#ifndef EQSTREAMIDENT_H_
|
#ifndef EQSTREAMIDENT_H_
|
||||||
#define EQSTREAMIDENT_H_
|
#define EQSTREAMIDENT_H_
|
||||||
|
|
||||||
#include "eq_stream_intf.h"
|
#include "eq_stream.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#define STREAM_IDENT_WAIT_MS 30000
|
#define STREAM_IDENT_WAIT_MS 10000
|
||||||
|
|
||||||
class OpcodeManager;
|
class OpcodeManager;
|
||||||
class StructStrategy;
|
class StructStrategy;
|
||||||
class EQStreamInterface;
|
|
||||||
|
|
||||||
class EQStreamIdentifier {
|
class EQStreamIdentifier {
|
||||||
public:
|
public:
|
||||||
~EQStreamIdentifier();
|
~EQStreamIdentifier();
|
||||||
|
|
||||||
//registration interface.
|
//registration interface.
|
||||||
void RegisterPatch(const EQStreamInterface::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs);
|
void RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs);
|
||||||
|
|
||||||
//main processing interface
|
//main processing interface
|
||||||
void Process();
|
void Process();
|
||||||
void AddStream(std::shared_ptr<EQStreamInterface> eqs);
|
void AddStream(EQStream *& eqs);
|
||||||
EQStreamInterface *PopIdentified();
|
EQStreamInterface *PopIdentified();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -31,7 +30,7 @@ protected:
|
|||||||
class Patch {
|
class Patch {
|
||||||
public:
|
public:
|
||||||
std::string name;
|
std::string name;
|
||||||
EQStreamInterface::Signature signature;
|
EQStream::Signature signature;
|
||||||
OpcodeManager ** opcodes;
|
OpcodeManager ** opcodes;
|
||||||
const StructStrategy *structs;
|
const StructStrategy *structs;
|
||||||
};
|
};
|
||||||
@@ -40,11 +39,11 @@ protected:
|
|||||||
//pending streams..
|
//pending streams..
|
||||||
class Record {
|
class Record {
|
||||||
public:
|
public:
|
||||||
Record(std::shared_ptr<EQStreamInterface> s);
|
Record(EQStream *s);
|
||||||
std::shared_ptr<EQStreamInterface> stream; //we own this
|
EQStream *stream; //we own this
|
||||||
Timer expire;
|
Timer expire;
|
||||||
};
|
};
|
||||||
std::vector<Record> m_streams; //we own these objects, and the streams contained in them.
|
std::vector<Record *> m_streams; //we own these objects, and the streams contained in them.
|
||||||
std::queue<EQStreamInterface *> m_identified; //we own these objects
|
std::queue<EQStreamInterface *> m_identified; //we own these objects
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+7
-75
@@ -4,9 +4,7 @@
|
|||||||
//this is the only part of an EQStream that is seen by the application.
|
//this is the only part of an EQStream that is seen by the application.
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "emu_versions.h"
|
#include "clientversions.h"
|
||||||
#include "eq_packet.h"
|
|
||||||
#include "net/daybreak_connection.h"
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ESTABLISHED,
|
ESTABLISHED,
|
||||||
@@ -17,93 +15,27 @@ typedef enum {
|
|||||||
} EQStreamState;
|
} EQStreamState;
|
||||||
|
|
||||||
class EQApplicationPacket;
|
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 {
|
class EQStreamInterface {
|
||||||
public:
|
public:
|
||||||
virtual ~EQStreamInterface() {}
|
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 QueuePacket(const EQApplicationPacket *p, bool ack_req=true) = 0;
|
||||||
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true) = 0;
|
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true) = 0;
|
||||||
virtual EQApplicationPacket *PopPacket() = 0;
|
virtual EQApplicationPacket *PopPacket() = 0;
|
||||||
virtual void Close() = 0;
|
virtual void Close() = 0;
|
||||||
virtual void ReleaseFromUse() = 0;
|
virtual void ReleaseFromUse() = 0;
|
||||||
virtual void RemoveData() = 0;
|
virtual void RemoveData() = 0;
|
||||||
virtual std::string GetRemoteAddr() const = 0;
|
|
||||||
virtual uint32 GetRemoteIP() const = 0;
|
virtual uint32 GetRemoteIP() const = 0;
|
||||||
virtual uint16 GetRemotePort() const = 0;
|
virtual uint16 GetRemotePort() const = 0;
|
||||||
virtual bool CheckState(EQStreamState state) = 0;
|
virtual bool CheckState(EQStreamState state) = 0;
|
||||||
virtual std::string Describe() const = 0;
|
virtual std::string Describe() const = 0;
|
||||||
virtual void SetActive(bool val) { }
|
|
||||||
virtual MatchState CheckSignature(const Signature *sig) { return MatchFailed; }
|
virtual const uint32 GetBytesSent() const { return 0; }
|
||||||
virtual EQStreamState GetState() = 0;
|
virtual const uint32 GetBytesRecieved() const { return 0; }
|
||||||
virtual void SetOpcodeManager(OpcodeManager **opm) = 0;
|
virtual const uint32 GetBytesSentPerSecond() const { return 0; }
|
||||||
virtual const EQEmu::versions::ClientVersion ClientVersion() const { return EQEmu::versions::ClientVersion::Unknown; }
|
virtual const uint32 GetBytesRecvPerSecond() const { return 0; }
|
||||||
virtual Stats GetStats() const = 0;
|
virtual const EQClientVersion ClientVersion() const { return EQClientUnknown; }
|
||||||
virtual void ResetStats() = 0;
|
|
||||||
virtual EQStreamManagerInterface* GetManager() const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*EQSTREAMINTF_H_*/
|
#endif /*EQSTREAMINTF_H_*/
|
||||||
|
|||||||
+31
-39
@@ -1,12 +1,11 @@
|
|||||||
|
|
||||||
#include "global_define.h"
|
#include "debug.h"
|
||||||
#include "eq_stream_proxy.h"
|
#include "eq_stream_proxy.h"
|
||||||
|
#include "eq_stream.h"
|
||||||
#include "struct_strategy.h"
|
#include "struct_strategy.h"
|
||||||
#include "eqemu_logsys.h"
|
|
||||||
#include "opcodemgr.h"
|
|
||||||
|
|
||||||
|
|
||||||
EQStreamProxy::EQStreamProxy(std::shared_ptr<EQStreamInterface> &stream, const StructStrategy *structs, OpcodeManager **opcodes)
|
EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes)
|
||||||
: m_stream(stream),
|
: m_stream(stream),
|
||||||
m_structs(structs),
|
m_structs(structs),
|
||||||
m_opcodes(opcodes)
|
m_opcodes(opcodes)
|
||||||
@@ -16,36 +15,22 @@ EQStreamProxy::EQStreamProxy(std::shared_ptr<EQStreamInterface> &stream, const S
|
|||||||
}
|
}
|
||||||
|
|
||||||
EQStreamProxy::~EQStreamProxy() {
|
EQStreamProxy::~EQStreamProxy() {
|
||||||
|
//delete m_stream; //released by the stream factory.
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string EQStreamProxy::Describe() const {
|
std::string EQStreamProxy::Describe() const {
|
||||||
return(m_structs->Describe());
|
return(m_structs->Describe());
|
||||||
}
|
}
|
||||||
|
|
||||||
const EQEmu::versions::ClientVersion EQStreamProxy::ClientVersion() const
|
const EQClientVersion EQStreamProxy::ClientVersion() const
|
||||||
{
|
{
|
||||||
return m_structs->ClientVersion();
|
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) {
|
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
|
||||||
if(p == nullptr)
|
if(p == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (p->GetOpcode() != OP_SpecialMesg) {
|
|
||||||
Log(Logs::General, Logs::PacketServerClient, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size());
|
|
||||||
Log(Logs::General, Logs::PacketServerClientWithDump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size(), DumpPacketToString(p).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
EQApplicationPacket *newp = p->Copy();
|
EQApplicationPacket *newp = p->Copy();
|
||||||
FastQueuePacket(&newp, ack_req);
|
FastQueuePacket(&newp, ack_req);
|
||||||
}
|
}
|
||||||
@@ -70,10 +55,6 @@ void EQStreamProxy::Close() {
|
|||||||
m_stream->Close();
|
m_stream->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string EQStreamProxy::GetRemoteAddr() const {
|
|
||||||
return(m_stream->GetRemoteAddr());
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 EQStreamProxy::GetRemoteIP() const {
|
uint32 EQStreamProxy::GetRemoteIP() const {
|
||||||
return(m_stream->GetRemoteIP());
|
return(m_stream->GetRemoteIP());
|
||||||
}
|
}
|
||||||
@@ -82,29 +63,40 @@ uint16 EQStreamProxy::GetRemotePort() const {
|
|||||||
return(m_stream->GetRemotePort());
|
return(m_stream->GetRemotePort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint32 EQStreamProxy::GetBytesSent() const
|
||||||
|
{
|
||||||
|
return(m_stream->GetBytesSent());
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32 EQStreamProxy::GetBytesRecieved() const
|
||||||
|
{
|
||||||
|
return(m_stream->GetBytesRecieved());
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32 EQStreamProxy::GetBytesSentPerSecond() const
|
||||||
|
{
|
||||||
|
return(m_stream->GetBytesSentPerSecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32 EQStreamProxy::GetBytesRecvPerSecond() const
|
||||||
|
{
|
||||||
|
return(m_stream->GetBytesRecvPerSecond());
|
||||||
|
}
|
||||||
|
|
||||||
void EQStreamProxy::ReleaseFromUse() {
|
void EQStreamProxy::ReleaseFromUse() {
|
||||||
m_stream->ReleaseFromUse();
|
m_stream->ReleaseFromUse();
|
||||||
|
|
||||||
|
//this is so ugly, but I cant think of a better way to deal with
|
||||||
|
//it right now...
|
||||||
|
if(!m_stream->IsInUse()) {
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQStreamProxy::RemoveData() {
|
void EQStreamProxy::RemoveData() {
|
||||||
m_stream->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) {
|
bool EQStreamProxy::CheckState(EQStreamState state) {
|
||||||
if(m_stream)
|
if(m_stream)
|
||||||
return(m_stream->CheckState(state));
|
return(m_stream->CheckState(state));
|
||||||
|
|||||||
+10
-11
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "eq_stream_intf.h"
|
#include "eq_stream_intf.h"
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
class EQStream;
|
||||||
class StructStrategy;
|
class StructStrategy;
|
||||||
class OpcodeManager;
|
class OpcodeManager;
|
||||||
class EQApplicationPacket;
|
class EQApplicationPacket;
|
||||||
@@ -13,7 +13,7 @@ class EQApplicationPacket;
|
|||||||
class EQStreamProxy : public EQStreamInterface {
|
class EQStreamProxy : public EQStreamInterface {
|
||||||
public:
|
public:
|
||||||
//takes ownership of the stream.
|
//takes ownership of the stream.
|
||||||
EQStreamProxy(std::shared_ptr<EQStreamInterface> &stream, const StructStrategy *structs, OpcodeManager **opcodes);
|
EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes);
|
||||||
virtual ~EQStreamProxy();
|
virtual ~EQStreamProxy();
|
||||||
|
|
||||||
//EQStreamInterface:
|
//EQStreamInterface:
|
||||||
@@ -21,23 +21,22 @@ public:
|
|||||||
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true);
|
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true);
|
||||||
virtual EQApplicationPacket *PopPacket();
|
virtual EQApplicationPacket *PopPacket();
|
||||||
virtual void Close();
|
virtual void Close();
|
||||||
virtual std::string GetRemoteAddr() const;
|
|
||||||
virtual uint32 GetRemoteIP() const;
|
virtual uint32 GetRemoteIP() const;
|
||||||
virtual uint16 GetRemotePort() const;
|
virtual uint16 GetRemotePort() const;
|
||||||
virtual void ReleaseFromUse();
|
virtual void ReleaseFromUse();
|
||||||
virtual void RemoveData();
|
virtual void RemoveData();
|
||||||
virtual bool CheckState(EQStreamState state);
|
virtual bool CheckState(EQStreamState state);
|
||||||
virtual std::string Describe() const;
|
virtual std::string Describe() const;
|
||||||
virtual const EQEmu::versions::ClientVersion ClientVersion() const;
|
virtual const EQClientVersion ClientVersion() const;
|
||||||
virtual EQStreamState GetState();
|
|
||||||
virtual void SetOpcodeManager(OpcodeManager **opm);
|
virtual const uint32 GetBytesSent() const;
|
||||||
virtual Stats GetStats() const;
|
virtual const uint32 GetBytesRecieved() const;
|
||||||
virtual void ResetStats();
|
virtual const uint32 GetBytesSentPerSecond() const;
|
||||||
virtual EQStreamManagerInterface* GetManager() const;
|
virtual const uint32 GetBytesRecvPerSecond() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<EQStreamInterface> const m_stream; //we own this stream object.
|
EQStream *const m_stream; //we own this stream object.
|
||||||
const StructStrategy *const m_structs; //we do not own this object.
|
const StructStrategy *const m_structs; //we do not own this object.
|
||||||
//this is a pointer to a pointer to make it less likely that a packet will
|
//this is a pointer to a pointer to make it less likely that a packet will
|
||||||
//reference an invalid opcode manager when they are being reloaded.
|
//reference an invalid opcode manager when they are being reloaded.
|
||||||
OpcodeManager **const m_opcodes; //we do not own this object.
|
OpcodeManager **const m_opcodes; //we do not own this object.
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "global_define.h"
|
#include "debug.h"
|
||||||
#include "eqdb.h"
|
#include "eqdb.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
@@ -63,7 +63,7 @@ EQDBRes * EQDB::query(Const_char *q) {
|
|||||||
//NOT THREAD SAFE!
|
//NOT THREAD SAFE!
|
||||||
Const_char *EQDB::escape_string(Const_char *from) {
|
Const_char *EQDB::escape_string(Const_char *from) {
|
||||||
int len = strlen(from);
|
int len = strlen(from);
|
||||||
auto res = new char[len * 2 + 1];
|
char *res = new char[len*2+1];
|
||||||
|
|
||||||
mysql_real_escape_string(mysql_ref,res,from,len);
|
mysql_real_escape_string(mysql_ref,res,from,len);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "global_define.h"
|
#include "debug.h"
|
||||||
#include "eqdb_res.h"
|
#include "eqdb_res.h"
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
|
||||||
|
|||||||
+359
-272
@@ -1,4 +1,4 @@
|
|||||||
/* EQEMu: Everquest Server Emulator
|
/* EQEMu: Everquest Server Emulator
|
||||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
@@ -15,299 +15,392 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
#include "../common/debug.h"
|
||||||
#include "../common/global_define.h"
|
|
||||||
#include "eqemu_config.h"
|
#include "eqemu_config.h"
|
||||||
#include "misc_functions.h"
|
#include "misc_functions.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
std::string EQEmuConfig::ConfigFile = "eqemu_config.json";
|
std::string EQEmuConfig::ConfigFile = "eqemu_config.xml";
|
||||||
EQEmuConfig *EQEmuConfig::_config = nullptr;
|
EQEmuConfig *EQEmuConfig::_config = nullptr;
|
||||||
|
|
||||||
void EQEmuConfig::parse_config()
|
void EQEmuConfig::do_world(TiXmlElement *ele) {
|
||||||
{
|
const char *text;
|
||||||
|
TiXmlElement * sub_ele;;
|
||||||
|
|
||||||
ShortName = _root["server"]["world"].get("shortname", "").asString();
|
text= ParseTextBlock(ele,"shortname");
|
||||||
LongName = _root["server"]["world"].get("longname", "").asString();
|
if (text)
|
||||||
WorldAddress = _root["server"]["world"].get("address", "").asString();
|
ShortName=text;
|
||||||
LocalAddress = _root["server"]["world"].get("localaddress", "").asString();
|
|
||||||
MaxClients = atoi(_root["server"]["world"].get("maxclients", "-1").asString().c_str());
|
|
||||||
SharedKey = _root["server"]["world"].get("key", "").asString();
|
|
||||||
LoginCount = 0;
|
|
||||||
|
|
||||||
if (_root["server"]["world"]["loginserver"].isObject()) {
|
text = ParseTextBlock(ele,"longname");
|
||||||
LoginHost = _root["server"]["world"]["loginserver"].get("host", "login.eqemulator.net").asString();
|
if (text)
|
||||||
LoginPort = atoi(_root["server"]["world"]["loginserver"].get("port", "5998").asString().c_str());
|
LongName=text;
|
||||||
LoginLegacy = false;
|
|
||||||
if (_root["server"]["world"]["loginserver"].get("legacy", "0").asString() == "1") { LoginLegacy = true; }
|
text = ParseTextBlock(ele,"address",true);
|
||||||
LoginAccount = _root["server"]["world"]["loginserver"].get("account", "").asString();
|
if (text)
|
||||||
LoginPassword = _root["server"]["world"]["loginserver"].get("password", "").asString();
|
WorldAddress=text;
|
||||||
}
|
|
||||||
else {
|
text = ParseTextBlock(ele,"localaddress",true);
|
||||||
char str[32];
|
if (text)
|
||||||
loginlist.Clear();
|
LocalAddress=text;
|
||||||
|
|
||||||
|
text = ParseTextBlock(ele,"maxclients",true);
|
||||||
|
if (text)
|
||||||
|
MaxClients=atoi(text);
|
||||||
|
|
||||||
|
// Get the <key> element
|
||||||
|
text = ParseTextBlock(ele,"key",true);
|
||||||
|
if (text)
|
||||||
|
SharedKey=text;
|
||||||
|
|
||||||
|
// Get the <loginserver> element
|
||||||
|
sub_ele = ele->FirstChildElement("loginserver");
|
||||||
|
if (sub_ele) {
|
||||||
|
text=ParseTextBlock(sub_ele,"host",true);
|
||||||
|
if (text)
|
||||||
|
LoginHost=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(sub_ele,"port",true);
|
||||||
|
if (text)
|
||||||
|
LoginPort=atoi(text);
|
||||||
|
|
||||||
|
text=ParseTextBlock(sub_ele,"account",true);
|
||||||
|
if (text)
|
||||||
|
LoginAccount=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(sub_ele,"password",true);
|
||||||
|
if (text)
|
||||||
|
LoginPassword=text;
|
||||||
|
} else {
|
||||||
|
char str[32];
|
||||||
do {
|
do {
|
||||||
sprintf(str, "loginserver%i", ++LoginCount);
|
sprintf(str, "loginserver%i", ++LoginCount);
|
||||||
if (!_root["server"]["world"][str].isObject()) {
|
sub_ele = ele->FirstChildElement(str);
|
||||||
break;
|
if (sub_ele) {
|
||||||
|
LoginConfig* loginconfig = new LoginConfig;
|
||||||
|
text=ParseTextBlock(sub_ele,"host",true);
|
||||||
|
if (text)
|
||||||
|
loginconfig->LoginHost=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(sub_ele,"port",true);
|
||||||
|
if (text)
|
||||||
|
loginconfig->LoginPort=atoi(text);
|
||||||
|
|
||||||
|
text=ParseTextBlock(sub_ele,"account",true);
|
||||||
|
if (text)
|
||||||
|
loginconfig->LoginAccount=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(sub_ele,"password",true);
|
||||||
|
if (text)
|
||||||
|
loginconfig->LoginPassword=text;
|
||||||
|
loginlist.Insert(loginconfig);
|
||||||
}
|
}
|
||||||
|
} while(sub_ele);
|
||||||
auto loginconfig = new LoginConfig;
|
|
||||||
loginconfig->LoginHost = _root["server"]["world"][str].get("host", "login.eqemulator.net").asString();
|
|
||||||
loginconfig->LoginPort = atoi(_root["server"]["world"][str].get("port", "5998").asString().c_str());
|
|
||||||
loginconfig->LoginAccount = _root["server"]["world"][str].get("account", "").asString();
|
|
||||||
loginconfig->LoginPassword = _root["server"]["world"][str].get("password", "").asString();
|
|
||||||
|
|
||||||
loginconfig->LoginLegacy = false;
|
|
||||||
if (_root["server"]["world"][str].get("legacy", "0").asString() == "1") { loginconfig->LoginLegacy = true; }
|
|
||||||
loginlist.Insert(loginconfig);
|
|
||||||
} while (LoginCount < 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for locked
|
||||||
|
sub_ele = ele->FirstChildElement("locked");
|
||||||
|
if (sub_ele != nullptr)
|
||||||
|
Locked=true;
|
||||||
|
|
||||||
//<locked> from xml converts to json as locked: "", so i default to "false".
|
// Get the <tcp> element
|
||||||
//The only way to enable locked is by switching to true, meaning this value is always false until manually set true
|
sub_ele = ele->FirstChildElement("tcp");
|
||||||
Locked = false;
|
if(sub_ele != nullptr) {
|
||||||
if (_root["server"]["world"].get("locked", "false").asString() == "true") { Locked = true; }
|
|
||||||
WorldIP = _root["server"]["world"]["tcp"].get("host", "127.0.0.1").asString();
|
|
||||||
WorldTCPPort = atoi(_root["server"]["world"]["tcp"].get("port", "9000").asString().c_str());
|
|
||||||
|
|
||||||
TelnetIP = _root["server"]["world"]["telnet"].get("ip", "127.0.0.1").asString();
|
text = sub_ele->Attribute("ip");
|
||||||
TelnetTCPPort = atoi(_root["server"]["world"]["telnet"].get("port", "9001").asString().c_str());
|
if (text)
|
||||||
TelnetEnabled = false;
|
WorldIP=text;
|
||||||
if (_root["server"]["world"]["telnet"].get("enabled", "false").asString() == "true") { TelnetEnabled = true; }
|
|
||||||
|
|
||||||
WorldHTTPMimeFile = _root["server"]["world"]["http"].get("mimefile", "mime.types").asString();
|
text = sub_ele->Attribute("port");
|
||||||
WorldHTTPPort = atoi(_root["server"]["world"]["http"].get("port", "9080").asString().c_str());
|
if (text)
|
||||||
WorldHTTPEnabled = false;
|
WorldTCPPort=atoi(text);
|
||||||
|
|
||||||
|
text = sub_ele->Attribute("telnet");
|
||||||
|
if (text && !strcasecmp(text,"enabled"))
|
||||||
|
TelnetEnabled=true;
|
||||||
|
|
||||||
if (_root["server"]["world"]["http"].get("enabled", "false").asString() == "true") {
|
|
||||||
WorldHTTPEnabled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Get the <http> element
|
||||||
* UCS
|
sub_ele = ele->FirstChildElement("http");
|
||||||
*/
|
if(sub_ele != nullptr) {
|
||||||
ChatHost = _root["server"]["chatserver"].get("host", "eqchat.eqemulator.net").asString();
|
|
||||||
ChatPort = atoi(_root["server"]["chatserver"].get("port", "7778").asString().c_str());
|
|
||||||
MailHost = _root["server"]["mailserver"].get("host", "eqmail.eqemulator.net").asString();
|
|
||||||
MailPort = atoi(_root["server"]["mailserver"].get("port", "7778").asString().c_str());
|
|
||||||
|
|
||||||
/**
|
// text = sub_ele->Attribute("ip");
|
||||||
* Database
|
// if (text)
|
||||||
*/
|
// WorldIP=text;
|
||||||
DatabaseUsername = _root["server"]["database"].get("username", "eq").asString();
|
|
||||||
DatabasePassword = _root["server"]["database"].get("password", "eq").asString();
|
|
||||||
DatabaseHost = _root["server"]["database"].get("host", "localhost").asString();
|
|
||||||
DatabasePort = atoi(_root["server"]["database"].get("port", "3306").asString().c_str());
|
|
||||||
DatabaseDB = _root["server"]["database"].get("db", "eq").asString();
|
|
||||||
|
|
||||||
/**
|
text = sub_ele->Attribute("mimefile");
|
||||||
* QS
|
if (text)
|
||||||
*/
|
WorldHTTPMimeFile=text;
|
||||||
QSDatabaseHost = _root["server"]["qsdatabase"].get("host", "localhost").asString();
|
|
||||||
QSDatabasePort = atoi(_root["server"]["qsdatabase"].get("port", "3306").asString().c_str());
|
|
||||||
QSDatabaseUsername = _root["server"]["qsdatabase"].get("username", "eq").asString();
|
|
||||||
QSDatabasePassword = _root["server"]["qsdatabase"].get("password", "eq").asString();
|
|
||||||
QSDatabaseDB = _root["server"]["qsdatabase"].get("db", "eq").asString();
|
|
||||||
|
|
||||||
/**
|
text = sub_ele->Attribute("port");
|
||||||
* Zones
|
if (text)
|
||||||
*/
|
WorldHTTPPort=atoi(text);
|
||||||
DefaultStatus = atoi(_root["server"]["zones"].get("defaultstatus", 0).asString().c_str());
|
|
||||||
ZonePortLow = atoi(_root["server"]["zones"]["ports"].get("low", "7000").asString().c_str());
|
|
||||||
ZonePortHigh = atoi(_root["server"]["zones"]["ports"].get("high", "7999").asString().c_str());
|
|
||||||
|
|
||||||
/**
|
text = sub_ele->Attribute("enabled");
|
||||||
* Files
|
if (text && !strcasecmp(text,"true"))
|
||||||
*/
|
WorldHTTPEnabled=true;
|
||||||
SpellsFile = _root["server"]["files"].get("spells", "spells_us.txt").asString();
|
|
||||||
OpCodesFile = _root["server"]["files"].get("opcodes", "opcodes.conf").asString();
|
|
||||||
MailOpCodesFile = _root["server"]["files"].get("mail_opcodes", "mail_opcodes.conf").asString();
|
|
||||||
PluginPlFile = _root["server"]["files"].get("plugin.pl", "plugin.pl").asString();
|
|
||||||
|
|
||||||
/**
|
}
|
||||||
* Directories
|
}
|
||||||
*/
|
|
||||||
MapDir = _root["server"]["directories"].get("maps", "Maps/").asString();
|
|
||||||
QuestDir = _root["server"]["directories"].get("quests", "quests/").asString();
|
|
||||||
PluginDir = _root["server"]["directories"].get("plugins", "plugins/").asString();
|
|
||||||
LuaModuleDir = _root["server"]["directories"].get("lua_modules", "lua_modules/").asString();
|
|
||||||
PatchDir = _root["server"]["directories"].get("patches", "./").asString();
|
|
||||||
SharedMemDir = _root["server"]["directories"].get("shared_memory", "shared/").asString();
|
|
||||||
LogDir = _root["server"]["directories"].get("logs", "logs/").asString();
|
|
||||||
|
|
||||||
/**
|
void EQEmuConfig::do_chatserver(TiXmlElement *ele) {
|
||||||
* Logs
|
const char *text;
|
||||||
*/
|
|
||||||
LogPrefix = _root["server"]["launcher"].get("logprefix", "logs/zone-").asString();
|
|
||||||
LogSuffix = _root["server"]["launcher"].get("logsuffix", ".log").asString();
|
|
||||||
|
|
||||||
/**
|
text=ParseTextBlock(ele,"host",true);
|
||||||
* Launcher
|
if (text)
|
||||||
*/
|
ChatHost=text;
|
||||||
RestartWait = atoi(_root["server"]["launcher"]["timers"].get("restart", "10000").asString().c_str());
|
|
||||||
TerminateWait = atoi(_root["server"]["launcher"]["timers"].get("reterminate", "10000").asString().c_str());
|
text=ParseTextBlock(ele,"port",true);
|
||||||
InitialBootWait = atoi(_root["server"]["launcher"]["timers"].get("initial", "20000").asString().c_str());
|
if (text)
|
||||||
ZoneBootInterval = atoi(_root["server"]["launcher"]["timers"].get("interval", "2000").asString().c_str());
|
ChatPort=atoi(text);
|
||||||
#ifdef WIN32
|
}
|
||||||
ZoneExe = _root["server"]["launcher"].get("exe", "zone.exe").asString();
|
|
||||||
#else
|
void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
|
||||||
ZoneExe = _root["server"]["launcher"].get("exe", "./zone").asString();
|
const char *text;
|
||||||
#endif
|
|
||||||
|
text=ParseTextBlock(ele,"host",true);
|
||||||
|
if (text)
|
||||||
|
MailHost=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"port",true);
|
||||||
|
if (text)
|
||||||
|
MailPort=atoi(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEmuConfig::do_database(TiXmlElement *ele) {
|
||||||
|
const char *text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"host",true);
|
||||||
|
if (text)
|
||||||
|
DatabaseHost=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"port",true);
|
||||||
|
if (text)
|
||||||
|
DatabasePort=atoi(text);
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"username",true);
|
||||||
|
if (text)
|
||||||
|
DatabaseUsername=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"password",true);
|
||||||
|
if (text)
|
||||||
|
DatabasePassword=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"db",true);
|
||||||
|
if (text)
|
||||||
|
DatabaseDB=text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EQEmuConfig::do_qsdatabase(TiXmlElement *ele) {
|
||||||
|
const char *text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"host",true);
|
||||||
|
if (text)
|
||||||
|
QSDatabaseHost=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"port",true);
|
||||||
|
if (text)
|
||||||
|
QSDatabasePort=atoi(text);
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"username",true);
|
||||||
|
if (text)
|
||||||
|
QSDatabaseUsername=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"password",true);
|
||||||
|
if (text)
|
||||||
|
QSDatabasePassword=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"db",true);
|
||||||
|
if (text)
|
||||||
|
QSDatabaseDB=text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEmuConfig::do_zones(TiXmlElement *ele) {
|
||||||
|
const char *text;
|
||||||
|
TiXmlElement *sub_ele;
|
||||||
|
// TiXmlNode *node,*sub_node;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"defaultstatus",true);
|
||||||
|
if (text)
|
||||||
|
DefaultStatus=atoi(text);
|
||||||
|
|
||||||
|
// Get the <ports> element
|
||||||
|
sub_ele = ele->FirstChildElement("ports");
|
||||||
|
if(sub_ele != nullptr) {
|
||||||
|
|
||||||
|
text = sub_ele->Attribute("low");
|
||||||
|
if (text)
|
||||||
|
ZonePortLow=atoi(text);;
|
||||||
|
|
||||||
|
text = sub_ele->Attribute("high");
|
||||||
|
if (text)
|
||||||
|
ZonePortHigh=atoi(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEmuConfig::do_files(TiXmlElement *ele) {
|
||||||
|
const char *text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"spells",true);
|
||||||
|
if (text)
|
||||||
|
SpellsFile=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"opcodes",true);
|
||||||
|
if (text)
|
||||||
|
OpCodesFile=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"logsettings",true);
|
||||||
|
if (text)
|
||||||
|
LogSettingsFile=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"eqtime",true);
|
||||||
|
if (text)
|
||||||
|
EQTimeFile=text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEmuConfig::do_directories(TiXmlElement *ele) {
|
||||||
|
const char *text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"maps",true);
|
||||||
|
if (text)
|
||||||
|
MapDir=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"quests",true);
|
||||||
|
if (text)
|
||||||
|
QuestDir=text;
|
||||||
|
|
||||||
|
text=ParseTextBlock(ele,"plugins",true);
|
||||||
|
if (text)
|
||||||
|
PluginDir=text;
|
||||||
|
|
||||||
}
|
}
|
||||||
std::string EQEmuConfig::GetByName(const std::string &var_name) const
|
|
||||||
{
|
void EQEmuConfig::do_launcher(TiXmlElement *ele) {
|
||||||
if (var_name == "ShortName") {
|
const char *text;
|
||||||
return (ShortName);
|
TiXmlElement *sub_ele;
|
||||||
}
|
|
||||||
if (var_name == "LongName") {
|
text=ParseTextBlock(ele,"logprefix",true);
|
||||||
return (LongName);
|
if (text)
|
||||||
}
|
LogPrefix = text;
|
||||||
if (var_name == "WorldAddress") {
|
|
||||||
return (WorldAddress);
|
text=ParseTextBlock(ele,"logsuffix",true);
|
||||||
}
|
if (text)
|
||||||
if (var_name == "LoginHost") {
|
LogSuffix = text;
|
||||||
return (LoginHost);
|
|
||||||
}
|
// Get the <exe> element
|
||||||
if (var_name == "LoginAccount") {
|
text = ParseTextBlock(ele,"exe",true);
|
||||||
return (LoginAccount);
|
if (text)
|
||||||
}
|
ZoneExe = text;
|
||||||
if (var_name == "LoginPassword") {
|
|
||||||
return (LoginPassword);
|
// Get the <timers> element
|
||||||
}
|
sub_ele = ele->FirstChildElement("timers");
|
||||||
if (var_name == "LoginPort") {
|
if(sub_ele != nullptr) {
|
||||||
return (itoa(LoginPort));
|
text = sub_ele->Attribute("restart");
|
||||||
}
|
if (text)
|
||||||
if (var_name == "LoginLegacy") {
|
RestartWait = atoi(text);
|
||||||
return (itoa(LoginLegacy ? 1 : 0));
|
|
||||||
}
|
text = sub_ele->Attribute("reterminate");
|
||||||
if (var_name == "Locked") {
|
if (text)
|
||||||
return (Locked ? "true" : "false");
|
TerminateWait = atoi(text);
|
||||||
}
|
|
||||||
if (var_name == "WorldTCPPort") {
|
text = sub_ele->Attribute("initial");
|
||||||
return (itoa(WorldTCPPort));
|
if (text)
|
||||||
}
|
InitialBootWait = atoi(text);
|
||||||
if (var_name == "WorldIP") {
|
|
||||||
return (WorldIP);
|
text = sub_ele->Attribute("interval");
|
||||||
}
|
if (text)
|
||||||
if (var_name == "TelnetTCPPort") {
|
ZoneBootInterval = atoi(text);
|
||||||
return (itoa(TelnetTCPPort));
|
|
||||||
}
|
|
||||||
if (var_name == "TelnetIP") {
|
|
||||||
return (TelnetIP);
|
|
||||||
}
|
|
||||||
if (var_name == "TelnetEnabled") {
|
|
||||||
return (TelnetEnabled ? "true" : "false");
|
|
||||||
}
|
|
||||||
if (var_name == "WorldHTTPPort") {
|
|
||||||
return (itoa(WorldHTTPPort));
|
|
||||||
}
|
|
||||||
if (var_name == "WorldHTTPMimeFile") {
|
|
||||||
return (WorldHTTPMimeFile);
|
|
||||||
}
|
|
||||||
if (var_name == "WorldHTTPEnabled") {
|
|
||||||
return (WorldHTTPEnabled ? "true" : "false");
|
|
||||||
}
|
|
||||||
if (var_name == "ChatHost") {
|
|
||||||
return (ChatHost);
|
|
||||||
}
|
|
||||||
if (var_name == "ChatPort") {
|
|
||||||
return (itoa(ChatPort));
|
|
||||||
}
|
|
||||||
if (var_name == "MailHost") {
|
|
||||||
return (MailHost);
|
|
||||||
}
|
|
||||||
if (var_name == "MailPort") {
|
|
||||||
return (itoa(MailPort));
|
|
||||||
}
|
|
||||||
if (var_name == "DatabaseHost") {
|
|
||||||
return (DatabaseHost);
|
|
||||||
}
|
|
||||||
if (var_name == "DatabaseUsername") {
|
|
||||||
return (DatabaseUsername);
|
|
||||||
}
|
|
||||||
if (var_name == "DatabasePassword") {
|
|
||||||
return (DatabasePassword);
|
|
||||||
}
|
|
||||||
if (var_name == "DatabaseDB") {
|
|
||||||
return (DatabaseDB);
|
|
||||||
}
|
|
||||||
if (var_name == "DatabasePort") {
|
|
||||||
return (itoa(DatabasePort));
|
|
||||||
}
|
|
||||||
if (var_name == "QSDatabaseHost") {
|
|
||||||
return (QSDatabaseHost);
|
|
||||||
}
|
|
||||||
if (var_name == "QSDatabaseUsername") {
|
|
||||||
return (QSDatabaseUsername);
|
|
||||||
}
|
|
||||||
if (var_name == "QSDatabasePassword") {
|
|
||||||
return (QSDatabasePassword);
|
|
||||||
}
|
|
||||||
if (var_name == "QSDatabaseDB") {
|
|
||||||
return (QSDatabaseDB);
|
|
||||||
}
|
|
||||||
if (var_name == "QSDatabasePort") {
|
|
||||||
return (itoa(QSDatabasePort));
|
|
||||||
}
|
|
||||||
if (var_name == "SpellsFile") {
|
|
||||||
return (SpellsFile);
|
|
||||||
}
|
|
||||||
if (var_name == "OpCodesFile") {
|
|
||||||
return (OpCodesFile);
|
|
||||||
}
|
|
||||||
if (var_name == "MailOpCodesFile") {
|
|
||||||
return (MailOpCodesFile);
|
|
||||||
}
|
|
||||||
if (var_name == "PluginPlFile") {
|
|
||||||
return (PluginPlFile);
|
|
||||||
}
|
|
||||||
if (var_name == "MapDir") {
|
|
||||||
return (MapDir);
|
|
||||||
}
|
|
||||||
if (var_name == "QuestDir") {
|
|
||||||
return (QuestDir);
|
|
||||||
}
|
|
||||||
if (var_name == "PluginDir") {
|
|
||||||
return (PluginDir);
|
|
||||||
}
|
|
||||||
if (var_name == "LuaModuleDir") {
|
|
||||||
return (LuaModuleDir);
|
|
||||||
}
|
|
||||||
if (var_name == "PatchDir") {
|
|
||||||
return (PatchDir);
|
|
||||||
}
|
|
||||||
if (var_name == "SharedMemDir") {
|
|
||||||
return (SharedMemDir);
|
|
||||||
}
|
|
||||||
if (var_name == "LogDir") {
|
|
||||||
return (LogDir);
|
|
||||||
}
|
|
||||||
if (var_name == "LogPrefix") {
|
|
||||||
return (LogPrefix);
|
|
||||||
}
|
|
||||||
if (var_name == "LogSuffix") {
|
|
||||||
return (LogSuffix);
|
|
||||||
}
|
|
||||||
if (var_name == "ZoneExe") {
|
|
||||||
return (ZoneExe);
|
|
||||||
}
|
|
||||||
if (var_name == "ZonePortLow") {
|
|
||||||
return (itoa(ZonePortLow));
|
|
||||||
}
|
|
||||||
if (var_name == "ZonePortHigh") {
|
|
||||||
return (itoa(ZonePortHigh));
|
|
||||||
}
|
|
||||||
if (var_name == "DefaultStatus") {
|
|
||||||
return (itoa(DefaultStatus));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string EQEmuConfig::GetByName(const std::string &var_name) const {
|
||||||
|
if(var_name == "ShortName")
|
||||||
|
return(ShortName);
|
||||||
|
if(var_name == "LongName")
|
||||||
|
return(LongName);
|
||||||
|
if(var_name == "WorldAddress")
|
||||||
|
return(WorldAddress);
|
||||||
|
if(var_name == "LoginHost")
|
||||||
|
return(LoginHost);
|
||||||
|
if(var_name == "LoginAccount")
|
||||||
|
return(LoginAccount);
|
||||||
|
if(var_name == "LoginPassword")
|
||||||
|
return(LoginPassword);
|
||||||
|
if(var_name == "LoginPort")
|
||||||
|
return(itoa(LoginPort));
|
||||||
|
if(var_name == "Locked")
|
||||||
|
return(Locked?"true":"false");
|
||||||
|
if(var_name == "WorldTCPPort")
|
||||||
|
return(itoa(WorldTCPPort));
|
||||||
|
if(var_name == "WorldIP")
|
||||||
|
return(WorldIP);
|
||||||
|
if(var_name == "TelnetEnabled")
|
||||||
|
return(TelnetEnabled?"true":"false");
|
||||||
|
if(var_name == "WorldHTTPPort")
|
||||||
|
return(itoa(WorldHTTPPort));
|
||||||
|
if(var_name == "WorldHTTPMimeFile")
|
||||||
|
return(WorldHTTPMimeFile);
|
||||||
|
if(var_name == "WorldHTTPEnabled")
|
||||||
|
return(WorldHTTPEnabled?"true":"false");
|
||||||
|
if(var_name == "ChatHost")
|
||||||
|
return(ChatHost);
|
||||||
|
if(var_name == "ChatPort")
|
||||||
|
return(itoa(ChatPort));
|
||||||
|
if(var_name == "MailHost")
|
||||||
|
return(MailHost);
|
||||||
|
if(var_name == "MailPort")
|
||||||
|
return(itoa(MailPort));
|
||||||
|
if(var_name == "DatabaseHost")
|
||||||
|
return(DatabaseHost);
|
||||||
|
if(var_name == "DatabaseUsername")
|
||||||
|
return(DatabaseUsername);
|
||||||
|
if(var_name == "DatabasePassword")
|
||||||
|
return(DatabasePassword);
|
||||||
|
if(var_name == "DatabaseDB")
|
||||||
|
return(DatabaseDB);
|
||||||
|
if(var_name == "DatabasePort")
|
||||||
|
return(itoa(DatabasePort));
|
||||||
|
if(var_name == "QSDatabaseHost")
|
||||||
|
return(QSDatabaseHost);
|
||||||
|
if(var_name == "QSDatabaseUsername")
|
||||||
|
return(QSDatabaseUsername);
|
||||||
|
if(var_name == "QSDatabasePassword")
|
||||||
|
return(QSDatabasePassword);
|
||||||
|
if(var_name == "QSDatabaseDB")
|
||||||
|
return(QSDatabaseDB);
|
||||||
|
if(var_name == "QSDatabasePort")
|
||||||
|
return(itoa(QSDatabasePort));
|
||||||
|
if(var_name == "SpellsFile")
|
||||||
|
return(SpellsFile);
|
||||||
|
if(var_name == "OpCodesFile")
|
||||||
|
return(OpCodesFile);
|
||||||
|
if(var_name == "EQTimeFile")
|
||||||
|
return(EQTimeFile);
|
||||||
|
if(var_name == "LogSettingsFile")
|
||||||
|
return(LogSettingsFile);
|
||||||
|
if(var_name == "MapDir")
|
||||||
|
return(MapDir);
|
||||||
|
if(var_name == "QuestDir")
|
||||||
|
return(QuestDir);
|
||||||
|
if(var_name == "PluginDir")
|
||||||
|
return(PluginDir);
|
||||||
|
if(var_name == "LogPrefix")
|
||||||
|
return(LogPrefix);
|
||||||
|
if(var_name == "LogSuffix")
|
||||||
|
return(LogSuffix);
|
||||||
|
if(var_name == "ZoneExe")
|
||||||
|
return(ZoneExe);
|
||||||
|
if(var_name == "ZonePortLow")
|
||||||
|
return(itoa(ZonePortLow));
|
||||||
|
if(var_name == "ZonePortHigh")
|
||||||
|
return(itoa(ZonePortHigh));
|
||||||
|
if(var_name == "DefaultStatus")
|
||||||
|
return(itoa(DefaultStatus));
|
||||||
// if(var_name == "DynamicCount")
|
// if(var_name == "DynamicCount")
|
||||||
// return(itoa(DynamicCount));
|
// return(itoa(DynamicCount));
|
||||||
return ("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQEmuConfig::Dump() const
|
void EQEmuConfig::Dump() const
|
||||||
@@ -319,12 +412,9 @@ void EQEmuConfig::Dump() const
|
|||||||
std::cout << "LoginAccount = " << LoginAccount << std::endl;
|
std::cout << "LoginAccount = " << LoginAccount << std::endl;
|
||||||
std::cout << "LoginPassword = " << LoginPassword << std::endl;
|
std::cout << "LoginPassword = " << LoginPassword << std::endl;
|
||||||
std::cout << "LoginPort = " << LoginPort << std::endl;
|
std::cout << "LoginPort = " << LoginPort << std::endl;
|
||||||
std::cout << "LoginLegacy = " << LoginLegacy << std::endl;
|
|
||||||
std::cout << "Locked = " << Locked << std::endl;
|
std::cout << "Locked = " << Locked << std::endl;
|
||||||
std::cout << "WorldTCPPort = " << WorldTCPPort << std::endl;
|
std::cout << "WorldTCPPort = " << WorldTCPPort << std::endl;
|
||||||
std::cout << "WorldIP = " << WorldIP << std::endl;
|
std::cout << "WorldIP = " << WorldIP << std::endl;
|
||||||
std::cout << "TelnetTCPPort = " << TelnetTCPPort << std::endl;
|
|
||||||
std::cout << "TelnetIP = " << TelnetIP << std::endl;
|
|
||||||
std::cout << "TelnetEnabled = " << TelnetEnabled << std::endl;
|
std::cout << "TelnetEnabled = " << TelnetEnabled << std::endl;
|
||||||
std::cout << "WorldHTTPPort = " << WorldHTTPPort << std::endl;
|
std::cout << "WorldHTTPPort = " << WorldHTTPPort << std::endl;
|
||||||
std::cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << std::endl;
|
std::cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << std::endl;
|
||||||
@@ -345,17 +435,14 @@ void EQEmuConfig::Dump() const
|
|||||||
std::cout << "QSDatabasePort = " << QSDatabasePort << std::endl;
|
std::cout << "QSDatabasePort = " << QSDatabasePort << std::endl;
|
||||||
std::cout << "SpellsFile = " << SpellsFile << std::endl;
|
std::cout << "SpellsFile = " << SpellsFile << std::endl;
|
||||||
std::cout << "OpCodesFile = " << OpCodesFile << std::endl;
|
std::cout << "OpCodesFile = " << OpCodesFile << std::endl;
|
||||||
std::cout << "MailOpcodesFile = " << MailOpCodesFile << std::endl;
|
std::cout << "EQTimeFile = " << EQTimeFile << std::endl;
|
||||||
std::cout << "PluginPlFile = " << PluginPlFile << std::endl;
|
std::cout << "LogSettingsFile = " << LogSettingsFile << std::endl;
|
||||||
std::cout << "MapDir = " << MapDir << std::endl;
|
std::cout << "MapDir = " << MapDir << std::endl;
|
||||||
std::cout << "QuestDir = " << QuestDir << std::endl;
|
std::cout << "QuestDir = " << QuestDir << std::endl;
|
||||||
std::cout << "PluginDir = " << PluginDir << std::endl;
|
std::cout << "PluginDir = " << PluginDir << std::endl;
|
||||||
std::cout << "LuaModuleDir = " << LuaModuleDir << std::endl;
|
|
||||||
std::cout << "PatchDir = " << PatchDir << std::endl;
|
|
||||||
std::cout << "SharedMemDir = " << SharedMemDir << std::endl;
|
|
||||||
std::cout << "LogDir = " << LogDir << std::endl;
|
|
||||||
std::cout << "ZonePortLow = " << ZonePortLow << std::endl;
|
std::cout << "ZonePortLow = " << ZonePortLow << std::endl;
|
||||||
std::cout << "ZonePortHigh = " << ZonePortHigh << std::endl;
|
std::cout << "ZonePortHigh = " << ZonePortHigh << std::endl;
|
||||||
std::cout << "DefaultStatus = " << (int) DefaultStatus << std::endl;
|
std::cout << "DefaultStatus = " << (int)DefaultStatus << std::endl;
|
||||||
// std::cout << "DynamicCount = " << DynamicCount << std::endl;
|
// std::cout << "DynamicCount = " << DynamicCount << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+171
-121
@@ -1,4 +1,4 @@
|
|||||||
/* EQEMu: Everquest Server Emulator
|
/* EQEMu: Everquest Server Emulator
|
||||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
@@ -18,160 +18,210 @@
|
|||||||
#ifndef __EQEmuConfig_H
|
#ifndef __EQEmuConfig_H
|
||||||
#define __EQEmuConfig_H
|
#define __EQEmuConfig_H
|
||||||
|
|
||||||
#include "json/json.h"
|
#include "xml_parser.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
struct LoginConfig {
|
struct LoginConfig {
|
||||||
std::string LoginHost;
|
std::string LoginHost;
|
||||||
std::string LoginAccount;
|
std::string LoginAccount;
|
||||||
std::string LoginPassword;
|
std::string LoginPassword;
|
||||||
uint16 LoginPort;
|
uint16 LoginPort;
|
||||||
bool LoginLegacy;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class EQEmuConfig
|
class EQEmuConfig : public XMLParser {
|
||||||
{
|
public:
|
||||||
public:
|
virtual std::string GetByName(const std::string &var_name) const;
|
||||||
virtual std::string GetByName(const std::string &var_name) const;
|
|
||||||
|
|
||||||
// From <world/>
|
// From <world/>
|
||||||
std::string ShortName;
|
std::string ShortName;
|
||||||
std::string LongName;
|
std::string LongName;
|
||||||
std::string WorldAddress;
|
std::string WorldAddress;
|
||||||
std::string LocalAddress;
|
std::string LocalAddress;
|
||||||
std::string LoginHost;
|
std::string LoginHost;
|
||||||
std::string LoginAccount;
|
std::string LoginAccount;
|
||||||
std::string LoginPassword;
|
std::string LoginPassword;
|
||||||
uint16 LoginPort;
|
uint16 LoginPort;
|
||||||
bool LoginLegacy;
|
uint32 LoginCount;
|
||||||
uint32 LoginCount;
|
LinkedList<LoginConfig*> loginlist;
|
||||||
LinkedList<LoginConfig*> loginlist;
|
bool Locked;
|
||||||
bool Locked;
|
uint16 WorldTCPPort;
|
||||||
uint16 WorldTCPPort;
|
std::string WorldIP;
|
||||||
std::string WorldIP;
|
bool TelnetEnabled;
|
||||||
uint16 TelnetTCPPort;
|
int32 MaxClients;
|
||||||
std::string TelnetIP;
|
bool WorldHTTPEnabled;
|
||||||
bool TelnetEnabled;
|
uint16 WorldHTTPPort;
|
||||||
int32 MaxClients;
|
std::string WorldHTTPMimeFile;
|
||||||
bool WorldHTTPEnabled;
|
std::string SharedKey;
|
||||||
uint16 WorldHTTPPort;
|
|
||||||
std::string WorldHTTPMimeFile;
|
|
||||||
std::string SharedKey;
|
|
||||||
|
|
||||||
// From <chatserver/>
|
// From <chatserver/>
|
||||||
std::string ChatHost;
|
std::string ChatHost;
|
||||||
uint16 ChatPort;
|
uint16 ChatPort;
|
||||||
|
|
||||||
// From <mailserver/>
|
// From <mailserver/>
|
||||||
std::string MailHost;
|
std::string MailHost;
|
||||||
uint16 MailPort;
|
uint16 MailPort;
|
||||||
|
|
||||||
// From <database/>
|
// From <database/>
|
||||||
std::string DatabaseHost;
|
std::string DatabaseHost;
|
||||||
std::string DatabaseUsername;
|
std::string DatabaseUsername;
|
||||||
std::string DatabasePassword;
|
std::string DatabasePassword;
|
||||||
std::string DatabaseDB;
|
std::string DatabaseDB;
|
||||||
uint16 DatabasePort;
|
uint16 DatabasePort;
|
||||||
|
|
||||||
// From <qsdatabase> // QueryServ
|
// From <qsdatabase> // QueryServ
|
||||||
std::string QSDatabaseHost;
|
std::string QSDatabaseHost;
|
||||||
std::string QSDatabaseUsername;
|
std::string QSDatabaseUsername;
|
||||||
std::string QSDatabasePassword;
|
std::string QSDatabasePassword;
|
||||||
std::string QSDatabaseDB;
|
std::string QSDatabaseDB;
|
||||||
uint16 QSDatabasePort;
|
uint16 QSDatabasePort;
|
||||||
|
|
||||||
// From <files/>
|
// From <files/>
|
||||||
std::string SpellsFile;
|
std::string SpellsFile;
|
||||||
std::string OpCodesFile;
|
std::string OpCodesFile;
|
||||||
std::string MailOpCodesFile;
|
std::string EQTimeFile;
|
||||||
std::string PluginPlFile;
|
std::string LogSettingsFile;
|
||||||
|
|
||||||
// From <directories/>
|
// From <directories/>
|
||||||
std::string MapDir;
|
std::string MapDir;
|
||||||
std::string QuestDir;
|
std::string QuestDir;
|
||||||
std::string PluginDir;
|
std::string PluginDir;
|
||||||
std::string LuaModuleDir;
|
|
||||||
std::string PatchDir;
|
|
||||||
std::string SharedMemDir;
|
|
||||||
std::string LogDir;
|
|
||||||
|
|
||||||
// From <launcher/>
|
// From <launcher/>
|
||||||
std::string LogPrefix;
|
std::string LogPrefix;
|
||||||
std::string LogSuffix;
|
std::string LogSuffix;
|
||||||
std::string ZoneExe;
|
std::string ZoneExe;
|
||||||
uint32 RestartWait;
|
uint32 RestartWait;
|
||||||
uint32 TerminateWait;
|
uint32 TerminateWait;
|
||||||
uint32 InitialBootWait;
|
uint32 InitialBootWait;
|
||||||
uint32 ZoneBootInterval;
|
uint32 ZoneBootInterval;
|
||||||
|
|
||||||
// From <zones/>
|
// From <zones/>
|
||||||
uint16 ZonePortLow;
|
uint16 ZonePortLow;
|
||||||
uint16 ZonePortHigh;
|
uint16 ZonePortHigh;
|
||||||
uint8 DefaultStatus;
|
uint8 DefaultStatus;
|
||||||
|
|
||||||
// uint16 DynamicCount;
|
// uint16 DynamicCount;
|
||||||
|
|
||||||
// map<string,uint16> StaticZones;
|
// map<string,uint16> StaticZones;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static EQEmuConfig *_config;
|
static EQEmuConfig *_config;
|
||||||
Json::Value _root;
|
|
||||||
static std::string ConfigFile;
|
|
||||||
|
|
||||||
void parse_config();
|
static std::string ConfigFile;
|
||||||
|
|
||||||
EQEmuConfig()
|
#define ELEMENT(name) \
|
||||||
{
|
void do_##name(TiXmlElement *ele);
|
||||||
|
#include "eqemu_config_elements.h"
|
||||||
|
|
||||||
}
|
|
||||||
virtual ~EQEmuConfig() {}
|
|
||||||
|
|
||||||
public:
|
EQEmuConfig() {
|
||||||
|
// import the needed handler prototypes
|
||||||
|
#define ELEMENT(name) \
|
||||||
|
Handlers[#name]=(ElementHandler)&EQEmuConfig::do_##name;
|
||||||
|
#include "eqemu_config_elements.h"
|
||||||
|
|
||||||
// Produce a const singleton
|
// Set sane defaults
|
||||||
static const EQEmuConfig *get()
|
|
||||||
{
|
// Login server
|
||||||
|
LoginHost="eqemulator.net";
|
||||||
|
LoginPort=5998;
|
||||||
|
|
||||||
|
// World
|
||||||
|
Locked=false;
|
||||||
|
WorldTCPPort=9000;
|
||||||
|
TelnetEnabled=false;
|
||||||
|
WorldHTTPEnabled=false;
|
||||||
|
WorldHTTPPort=9080;
|
||||||
|
WorldHTTPMimeFile="mime.types";
|
||||||
|
SharedKey = ""; //blank disables authentication
|
||||||
|
|
||||||
|
// Mail
|
||||||
|
ChatHost="eqchat.eqemulator.net";
|
||||||
|
ChatPort=7778;
|
||||||
|
|
||||||
|
// Mail
|
||||||
|
MailHost="eqmail.eqemulator.net";
|
||||||
|
MailPort=7779;
|
||||||
|
|
||||||
|
// Mysql
|
||||||
|
DatabaseHost="localhost";
|
||||||
|
DatabasePort=3306;
|
||||||
|
DatabaseUsername="eq";
|
||||||
|
DatabasePassword="eq";
|
||||||
|
DatabaseDB="eq";
|
||||||
|
|
||||||
|
// QueryServ Database
|
||||||
|
QSDatabaseHost="localhost";
|
||||||
|
QSDatabasePort=3306;
|
||||||
|
QSDatabaseUsername="eq";
|
||||||
|
QSDatabasePassword="eq";
|
||||||
|
QSDatabaseDB="eq";
|
||||||
|
|
||||||
|
// Files
|
||||||
|
SpellsFile="spells_us.txt";
|
||||||
|
OpCodesFile="opcodes.conf";
|
||||||
|
EQTimeFile="eqtime.cfg";
|
||||||
|
LogSettingsFile="log.ini";
|
||||||
|
|
||||||
|
// Dirs
|
||||||
|
MapDir="Maps";
|
||||||
|
QuestDir="quests";
|
||||||
|
PluginDir="plugins";
|
||||||
|
|
||||||
|
// Launcher
|
||||||
|
LogPrefix = "logs/zone-";
|
||||||
|
LogSuffix = ".log";
|
||||||
|
RestartWait = 10000; //milliseconds
|
||||||
|
TerminateWait = 10000; //milliseconds
|
||||||
|
InitialBootWait = 20000; //milliseconds
|
||||||
|
ZoneBootInterval = 2000; //milliseconds
|
||||||
|
#ifdef WIN32
|
||||||
|
ZoneExe = "zone.exe";
|
||||||
|
#else
|
||||||
|
ZoneExe = "./zone";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Zones
|
||||||
|
ZonePortLow=7000;
|
||||||
|
ZonePortHigh=7999;
|
||||||
|
DefaultStatus=0;
|
||||||
|
|
||||||
|
// For where zones need to connect to.
|
||||||
|
WorldIP="127.0.0.1";
|
||||||
|
|
||||||
|
// Dynamics to start
|
||||||
|
//DynamicCount=5;
|
||||||
|
|
||||||
|
MaxClients=-1;
|
||||||
|
|
||||||
|
LoginCount=0;
|
||||||
|
|
||||||
|
}
|
||||||
|
virtual ~EQEmuConfig() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Produce a const singleton
|
||||||
|
static const EQEmuConfig *get() {
|
||||||
|
if (_config == nullptr)
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
return (_config);
|
return(_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow the use to set the conf file to be used.
|
// Allow the use to set the conf file to be used.
|
||||||
static void SetConfigFile(std::string file)
|
static void SetConfigFile(std::string file) { EQEmuConfig::ConfigFile = file; }
|
||||||
{
|
|
||||||
EQEmuConfig::ConfigFile = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the config
|
// Load the config
|
||||||
static bool LoadConfig()
|
static bool LoadConfig() {
|
||||||
{
|
if (_config != nullptr)
|
||||||
if (_config != nullptr) {
|
delete _config;
|
||||||
return true;
|
_config=new EQEmuConfig;
|
||||||
}
|
|
||||||
_config = new EQEmuConfig;
|
|
||||||
|
|
||||||
return parseFile();
|
return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(),"server");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load config file and parse data
|
void Dump() const;
|
||||||
static bool parseFile() {
|
|
||||||
if (_config == nullptr) {
|
|
||||||
return LoadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ifstream fconfig(EQEmuConfig::ConfigFile, std::ifstream::binary);
|
|
||||||
try {
|
|
||||||
fconfig >> _config->_root;
|
|
||||||
_config->parse_config();
|
|
||||||
}
|
|
||||||
catch (std::exception &) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dump() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user