mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 13:16:39 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 307923598b | |||
| 644d9c15c6 | |||
| cf4f628340 | |||
| 8af508d8c5 | |||
| f85644a09c | |||
| 1a6c6cf768 | |||
| c5ffb44edb | |||
| e0637e29f1 | |||
| 40980a9d39 | |||
| d906f79e6f | |||
| 8293225ecc | |||
| e06a845921 | |||
| aa4aced94d | |||
| 0e0027ca20 | |||
| 5c7ab59fd3 | |||
| 120cf6a4b8 | |||
| 3ddfed8bb6 | |||
| 586eb9e5c1 | |||
| 32227d19ce | |||
| c233379894 | |||
| a51a1d7106 | |||
| 6d05903170 | |||
| 4ae0f2a1d7 |
@@ -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
|
|
||||||
+1
-24
@@ -17,8 +17,6 @@
|
|||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
.bash_history
|
|
||||||
|
|
||||||
# CMake
|
# CMake
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
@@ -29,28 +27,7 @@ install_manifest.txt
|
|||||||
log/
|
log/
|
||||||
logs/
|
logs/
|
||||||
vcpkg/
|
vcpkg/
|
||||||
perl/
|
|
||||||
|
|
||||||
.idea/*
|
.idea/*
|
||||||
*cbp
|
*cbp
|
||||||
|
.editorconfig
|
||||||
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/
|
|
||||||
+3
-3
@@ -16,6 +16,6 @@
|
|||||||
[submodule "submodules/recastnavigation"]
|
[submodule "submodules/recastnavigation"]
|
||||||
path = submodules/recastnavigation
|
path = submodules/recastnavigation
|
||||||
url = https://github.com/EQEmu/recastnavigation.git
|
url = https://github.com/EQEmu/recastnavigation.git
|
||||||
[submodule "submodules/expected"]
|
[submodule "submodules/zlibng"]
|
||||||
path = submodules/expected
|
path = submodules/zlibng
|
||||||
url = https://github.com/TartanLlama/expected.git
|
url = https://github.com/zlib-ng/zlib-ng.git
|
||||||
|
|||||||
+19
-11
@@ -1,18 +1,26 @@
|
|||||||
language: cpp
|
language: cpp
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
dist: bionic
|
dist: trusty
|
||||||
|
|
||||||
addons:
|
before_install:
|
||||||
apt:
|
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||||
packages:
|
- sudo apt-get update -qq
|
||||||
- libmysqlclient-dev
|
- mkdir $HOME/usr
|
||||||
- libperl-dev
|
- export PATH="$HOME/usr/bin:$PATH"
|
||||||
- libboost-dev
|
- wget https://cmake.org/files/v3.11/cmake-3.11.2-Linux-x86_64.sh
|
||||||
- liblua5.1-0-dev
|
- chmod +x cmake-3.11.2-Linux-x86_64.sh
|
||||||
- zlib1g-dev
|
- ./cmake-3.11.2-Linux-x86_64.sh --prefix=$HOME/usr --exclude-subdir --skip-license
|
||||||
- uuid-dev
|
|
||||||
- libssl-dev
|
|
||||||
|
|
||||||
|
install:
|
||||||
|
- sudo apt-get install -qq g++-7
|
||||||
|
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
|
||||||
|
- sudo apt-get install libmysqlclient-dev
|
||||||
|
- sudo apt-get install libperl-dev
|
||||||
|
- sudo apt-get install libboost-dev
|
||||||
|
- sudo apt-get install liblua5.1-0-dev
|
||||||
|
- sudo apt-get install zlib1g-dev
|
||||||
|
- sudo apt-get install uuid-dev
|
||||||
|
- sudo apt-get install libssl-dev
|
||||||
script:
|
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 -DEQEMU_BUILD_LOGIN=ON
|
||||||
- make -j2
|
- make -j2
|
||||||
|
|||||||
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
|
|
||||||
+47
-99
@@ -1,18 +1,14 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
|
||||||
|
|
||||||
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)
|
|
||||||
CMAKE_POLICY(SET CMP0074 NEW)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
PROJECT(EQEmu)
|
PROJECT(EQEmu)
|
||||||
|
|
||||||
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)
|
SET(CMAKE_CXX_STANDARD 14)
|
||||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
SET(CMAKE_CXX_EXTENSIONS OFF)
|
SET(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
@@ -43,15 +39,10 @@ ADD_DEFINITIONS(-DGLM_FORCE_RADIANS)
|
|||||||
ADD_DEFINITIONS(-DGLM_FORCE_CTOR_INIT)
|
ADD_DEFINITIONS(-DGLM_FORCE_CTOR_INIT)
|
||||||
ADD_DEFINITIONS(-DGLM_ENABLE_EXPERIMENTAL)
|
ADD_DEFINITIONS(-DGLM_ENABLE_EXPERIMENTAL)
|
||||||
|
|
||||||
#MSVC can fetch dependencies automatically.
|
|
||||||
IF(MSVC)
|
|
||||||
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/DependencyHelperMSVC.cmake")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
#Find everything we need
|
#Find everything we need
|
||||||
FIND_PACKAGE(Boost REQUIRED)
|
|
||||||
FIND_PACKAGE(MySQL)
|
FIND_PACKAGE(MySQL)
|
||||||
FIND_PACKAGE(MariaDB)
|
FIND_PACKAGE(MariaDB)
|
||||||
|
FIND_PACKAGE(Boost REQUIRED)
|
||||||
FIND_PACKAGE(ZLIB)
|
FIND_PACKAGE(ZLIB)
|
||||||
FIND_PACKAGE(OpenSSL)
|
FIND_PACKAGE(OpenSSL)
|
||||||
FIND_PACKAGE(Lua51)
|
FIND_PACKAGE(Lua51)
|
||||||
@@ -118,7 +109,6 @@ OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (wi
|
|||||||
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
|
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
|
||||||
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_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_HC "Build the headless client." OFF)
|
||||||
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
||||||
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
||||||
@@ -132,23 +122,11 @@ IF(EQEMU_ENABLE_BOTS)
|
|||||||
ENDIF(EQEMU_ENABLE_BOTS)
|
ENDIF(EQEMU_ENABLE_BOTS)
|
||||||
|
|
||||||
#database
|
#database
|
||||||
|
#prefer mariadb to mysql (arbitrary)
|
||||||
IF(MySQL_FOUND AND MariaDB_FOUND)
|
IF(MySQL_FOUND AND MariaDB_FOUND)
|
||||||
SET(DATABASE_LIBRARY_SELECTION MySQL CACHE STRING "Database library to use:
|
|
||||||
MySQL
|
|
||||||
MariaDB"
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(DATABASE_LIBRARY_SELECTION STREQUAL "MySQL")
|
|
||||||
SET(DATABASE_LIBRARY_TYPE " MySQL")
|
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
|
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
|
|
||||||
ELSEIF(DATABASE_LIBRARY_SELECTION STREQUAL "MariaDB")
|
|
||||||
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
|
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)
|
ELSEIF(MariaDB_FOUND)
|
||||||
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
||||||
@@ -164,41 +142,23 @@ ENDIF()
|
|||||||
#security
|
#security
|
||||||
#prefer openssl to mbedtls (arbitrary)
|
#prefer openssl to mbedtls (arbitrary)
|
||||||
IF(OpenSSL_FOUND AND MBEDTLS_FOUND)
|
IF(OpenSSL_FOUND AND MBEDTLS_FOUND)
|
||||||
SET(TLS_LIBRARY_SELECTION OpenSSL CACHE STRING "TLS library to use:
|
SET(SSL_LIBRARY_TYPE " OpenSSL")
|
||||||
OpenSSL
|
SET(SSL_LIBRARY_ENABLED ON)
|
||||||
mbedTLS"
|
SET(SSL_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
|
||||||
)
|
SET(SSL_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
|
||||||
|
|
||||||
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)
|
ELSEIF(OpenSSL_FOUND)
|
||||||
SET(TLS_LIBRARY_TYPE " OpenSSL")
|
SET(SSL_LIBRARY_TYPE " OpenSSL")
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
SET(SSL_LIBRARY_ENABLED ON)
|
||||||
SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
|
SET(SSL_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
|
||||||
SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
|
SET(SSL_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
|
|
||||||
ELSEIF(MBEDTLS_FOUND)
|
ELSEIF(MBEDTLS_FOUND)
|
||||||
SET(TLS_LIBRARY_TYPE " mbedTLS")
|
SET(SSL_LIBRARY_TYPE " mbedTLS")
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
SET(SSL_LIBRARY_ENABLED ON)
|
||||||
SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
|
SET(SSL_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
|
||||||
SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
|
SET(SSL_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
|
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(TLS_LIBRARY_TYPE "Disabled")
|
SET(SSL_LIBRARY_TYPE "Disabled")
|
||||||
SET(TLS_LIBRARY_ENABLED OFF)
|
SET(SSL_LIBRARY_ENABLED OFF)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(SODIUM_FOUND)
|
IF(SODIUM_FOUND)
|
||||||
@@ -214,31 +174,42 @@ ENDIF()
|
|||||||
|
|
||||||
IF(Lua51_FOUND)
|
IF(Lua51_FOUND)
|
||||||
SET(LUA_LIBRARY_TYPE " Lua 5.1")
|
SET(LUA_LIBRARY_TYPE " Lua 5.1")
|
||||||
SET(LUA_LIBRARY_ENABLED ON)
|
|
||||||
SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind)
|
SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind)
|
||||||
SET(LUA_LIBRARY_INCLUDE ${LUA_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
SET(LUA_LIBRARY_INCLUDE ${LUA_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
||||||
|
|
||||||
|
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
||||||
|
IF(EQEMU_BUILD_LUA)
|
||||||
|
ADD_DEFINITIONS(-DLUA_EQEMU)
|
||||||
|
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()
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(LUA_LIBRARY_TYPE "Disabled")
|
SET(LUA_LIBRARY_TYPE "Disabled")
|
||||||
SET(LUA_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(PerlLibs_FOUND)
|
IF(PerlLibs_FOUND)
|
||||||
SET(PERL_LIBRARY_TYPE " Perl")
|
SET(PERL_LIBRARY_TYPE " Perl")
|
||||||
SET(PERL_LIBRARY_ENABLED ON)
|
|
||||||
SET(PERL_LIBRARY_LIBS ${PERL_LIBRARY})
|
SET(PERL_LIBRARY_LIBS ${PERL_LIBRARY})
|
||||||
SET(PERL_LIBRARY_INCLUDE ${PERL_INCLUDE_PATH})
|
SET(PERL_LIBRARY_INCLUDE ${PERL_INCLUDE_PATH})
|
||||||
|
|
||||||
|
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
||||||
|
IF(EQEMU_BUILD_PERL)
|
||||||
|
ADD_DEFINITIONS(-DEMBPERL)
|
||||||
|
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
|
||||||
|
ENDIF()
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(PERL_LIBRARY_TYPE "Disabled")
|
SET(PERL_LIBRARY_TYPE "Disabled")
|
||||||
SET(PERL_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
#use zlib if exists
|
#use zlib if exists
|
||||||
IF(ZLIB_FOUND)
|
IF(ZLIB_FOUND)
|
||||||
OPTION(EQEMU_BUILD_ZLIB "Build internal version of zlib." ON)
|
OPTION(EQEMU_BUILD_ZLIB "Build internal version of zlib." OFF)
|
||||||
IF(EQEMU_BUILD_ZLIB)
|
IF(EQEMU_BUILD_ZLIB)
|
||||||
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
||||||
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
||||||
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/submodules/zlibng")
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(ZLIB_LIBRARY_TYPE " zlib")
|
SET(ZLIB_LIBRARY_TYPE " zlib")
|
||||||
SET(ZLIB_LIBRARY_LIBS ${ZLIB_LIBRARY})
|
SET(ZLIB_LIBRARY_LIBS ${ZLIB_LIBRARY})
|
||||||
@@ -247,7 +218,7 @@ IF(ZLIB_FOUND)
|
|||||||
ELSE()
|
ELSE()
|
||||||
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
||||||
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
||||||
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/submodules/zlibng")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
MESSAGE(STATUS "")
|
MESSAGE(STATUS "")
|
||||||
@@ -255,7 +226,7 @@ MESSAGE(STATUS "**************************************************")
|
|||||||
MESSAGE(STATUS "* Library Usage *")
|
MESSAGE(STATUS "* Library Usage *")
|
||||||
MESSAGE(STATUS "**************************************************")
|
MESSAGE(STATUS "**************************************************")
|
||||||
MESSAGE(STATUS "* Database: ${DATABASE_LIBRARY_TYPE} *")
|
MESSAGE(STATUS "* Database: ${DATABASE_LIBRARY_TYPE} *")
|
||||||
MESSAGE(STATUS "* TLS: ${TLS_LIBRARY_TYPE} *")
|
MESSAGE(STATUS "* TLS: ${SSL_LIBRARY_TYPE} *")
|
||||||
MESSAGE(STATUS "* Sodium: ${SODIUM_LIBRARY_TYPE} *")
|
MESSAGE(STATUS "* Sodium: ${SODIUM_LIBRARY_TYPE} *")
|
||||||
MESSAGE(STATUS "* Lua: ${LUA_LIBRARY_TYPE} *")
|
MESSAGE(STATUS "* Lua: ${LUA_LIBRARY_TYPE} *")
|
||||||
MESSAGE(STATUS "* Perl: ${PERL_LIBRARY_TYPE} *")
|
MESSAGE(STATUS "* Perl: ${PERL_LIBRARY_TYPE} *")
|
||||||
@@ -270,7 +241,6 @@ INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_LIBRARY_INCLUDE}")
|
|||||||
INCLUDE_DIRECTORIES(SYSTEM "${Boost_INCLUDE_DIRS}")
|
INCLUDE_DIRECTORIES(SYSTEM "${Boost_INCLUDE_DIRS}")
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/glm")
|
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/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/fmt/include")
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/libuv/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/DebugUtils/Include")
|
||||||
@@ -280,14 +250,9 @@ INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigat
|
|||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Recast/Include")
|
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Recast/Include")
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/websocketpp")
|
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/websocketpp")
|
||||||
|
|
||||||
OPTION(EQEMU_BUILD_LOGGING "Build Logging (To speed up compilation)" ON)
|
IF(SSL_LIBRARY_ENABLED)
|
||||||
IF(EQEMU_BUILD_LOGGING)
|
SET(SERVER_LIBS ${SERVER_LIBS} ${SSL_LIBRARY_LIBS})
|
||||||
ADD_DEFINITIONS(-DBUILD_LOGGING)
|
INCLUDE_DIRECTORIES(SYSTEM "${SSL_LIBRARY_INCLUDE}")
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(TLS_LIBRARY_ENABLED)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${TLS_LIBRARY_LIBS})
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${TLS_LIBRARY_INCLUDE}")
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(SODIUM_LIBRARY_ENABLED)
|
IF(SODIUM_LIBRARY_ENABLED)
|
||||||
@@ -295,29 +260,14 @@ IF(SODIUM_LIBRARY_ENABLED)
|
|||||||
INCLUDE_DIRECTORIES(SYSTEM "${SODIUM_LIBRARY_INCLUDE}")
|
INCLUDE_DIRECTORIES(SYSTEM "${SODIUM_LIBRARY_INCLUDE}")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(LUA_LIBRARY_ENABLED)
|
IF(EQEMU_BUILD_LUA)
|
||||||
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_LUA)
|
|
||||||
ADD_DEFINITIONS(-DLUA_EQEMU)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${LUA_LIBRARY_LIBS})
|
SET(SERVER_LIBS ${SERVER_LIBS} ${LUA_LIBRARY_LIBS})
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${LUA_LIBRARY_INCLUDE}")
|
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()
|
ENDIF()
|
||||||
|
|
||||||
IF(PERL_LIBRARY_ENABLED)
|
IF(EQEMU_BUILD_PERL)
|
||||||
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
|
||||||
IF(EQEMU_BUILD_PERL)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${PERL_LIBRARY_LIBS})
|
SET(SERVER_LIBS ${SERVER_LIBS} ${PERL_LIBRARY_LIBS})
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${PERL_LIBRARY_INCLUDE}")
|
INCLUDE_DIRECTORIES(SYSTEM "${PERL_LIBRARY_INCLUDE}")
|
||||||
ADD_DEFINITIONS(-DEMBPERL)
|
|
||||||
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
@@ -332,12 +282,8 @@ IF(UNIX)
|
|||||||
SET(SERVER_LIBS ${SERVER_LIBS} "uuid")
|
SET(SERVER_LIBS ${SERVER_LIBS} "uuid")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(EQEMU_BUILD_LOGIN AND NOT TLS_LIBRARY_ENABLED)
|
IF(EQEMU_BUILD_LOGIN AND NOT SSL_LIBRARY_ENABLED)
|
||||||
MESSAGE(FATAL_ERROR "Login server requires a TLS Library to build.")
|
MESSAGE(FATAL_ERROR "Login server requires a SSL 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()
|
ENDIF()
|
||||||
|
|
||||||
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
||||||
@@ -349,7 +295,7 @@ IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_H
|
|||||||
IF(EQEMU_BUILD_ZLIB)
|
IF(EQEMU_BUILD_ZLIB)
|
||||||
SET(ZLIB_COMPAT ON CACHE BOOL "Compile with zlib compatible API")
|
SET(ZLIB_COMPAT ON CACHE BOOL "Compile with zlib compatible API")
|
||||||
SET(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Build test binaries")
|
SET(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Build test binaries")
|
||||||
ADD_SUBDIRECTORY(libs/zlibng)
|
ADD_SUBDIRECTORY(submodules/zlibng)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
SET(RECASTNAVIGATION_DEMO OFF CACHE BOOL "Build demo")
|
SET(RECASTNAVIGATION_DEMO OFF CACHE BOOL "Build demo")
|
||||||
@@ -358,6 +304,8 @@ IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_H
|
|||||||
ADD_SUBDIRECTORY(submodules/recastnavigation)
|
ADD_SUBDIRECTORY(submodules/recastnavigation)
|
||||||
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
||||||
|
|
||||||
|
MESSAGE(STATUS "Libs: ${SERVER_LIBS}")
|
||||||
|
|
||||||
IF(EQEMU_BUILD_SERVER)
|
IF(EQEMU_BUILD_SERVER)
|
||||||
ADD_SUBDIRECTORY(shared_memory)
|
ADD_SUBDIRECTORY(shared_memory)
|
||||||
ADD_SUBDIRECTORY(world)
|
ADD_SUBDIRECTORY(world)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# EQEmulator Core Server
|
# EQEmulator Core Server
|
||||||
|Travis CI (Linux)|Appveyor (Windows x86) |Appveyor (Windows x64) |
|
|Travis CI (Linux)|Appveyor w/ Bots (Windows) |Appveyor w/o Bots (Windows) |
|
||||||
|:---:|:---:|:---:|
|
|:---:|:---:|:---:|
|
||||||
|[](https://travis-ci.org/EQEmu/Server) |[](https://ci.appveyor.com/project/KimLS/server) |[](https://ci.appveyor.com/project/KimLS/server-87crp) |
|
|[](https://travis-ci.org/EQEmu/Server) |[](https://ci.appveyor.com/project/KimLS/server-87crp/branch/master) |[](https://ci.appveyor.com/project/KimLS/server-w0pq2/branch/master) |
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|:---:|:---:|:---:|
|
|:---:|:---:|:---:|
|
||||||
|**Install Count**|||
|
|**Install Count**|||
|
||||||
### > Windows
|
### > Windows
|
||||||
* [Install](https://eqemu.gitbook.io/server/categories/how-to-guides/installation/server-installation-windows)
|
* [Install](https://github.com/EQEmu/Server/wiki/Windows-Server)
|
||||||
|
|
||||||
### > Debian/Ubuntu/CentOS/Fedora
|
### > Debian/Ubuntu/CentOS/Fedora
|
||||||
* You can use curl or wget to kick off the installer (whichever your OS has)
|
* You can use curl or wget to kick off the installer (whichever your OS has)
|
||||||
@@ -52,7 +52,7 @@ forum, although pull requests will be much quicker and easier on all parties.
|
|||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
- [EQEmulator Forums](http://www.eqemulator.org/forums)
|
- [EQEmulator Forums](http://www.eqemulator.org/forums)
|
||||||
- [EQEmulator Wiki](https://eqemu.gitbook.io/)
|
- [EQEmulator Wiki](https://github.com/EQEmu/Server/wiki)
|
||||||
|
|
||||||
## Related Repositories
|
## Related Repositories
|
||||||
* [ProjectEQ Quests](https://github.com/ProjectEQ/projecteqquests)
|
* [ProjectEQ Quests](https://github.com/ProjectEQ/projecteqquests)
|
||||||
|
|||||||
+478
-489
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
|
||||||
|
|
||||||
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 3.10)
|
||||||
|
|
||||||
SET(export_sources
|
SET(export_sources
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|||||||
@@ -39,19 +39,20 @@ int main(int argc, char **argv) {
|
|||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
LogInfo("Client Files Export Utility");
|
Log(Logs::General, Logs::Status, "Client Files Export Utility");
|
||||||
if(!EQEmuConfig::LoadConfig()) {
|
if(!EQEmuConfig::LoadConfig()) {
|
||||||
LogError("Unable to load configuration file");
|
Log(Logs::General, Logs::Error, "Unable to load configuration file.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Config = EQEmuConfig::get();
|
auto Config = EQEmuConfig::get();
|
||||||
|
|
||||||
SharedDatabase database;
|
SharedDatabase database;
|
||||||
LogInfo("Connecting to database");
|
Log(Logs::General, Logs::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");
|
Log(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a "
|
||||||
|
"database connection");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,11 +94,11 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase *db) {
|
void ExportSpells(SharedDatabase *db) {
|
||||||
LogInfo("Exporting Spells");
|
Log(Logs::General, Logs::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.");
|
Log(Logs::General, Logs::Error, "Unable to open export/spells_us.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,11 +165,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");
|
Log(Logs::General, Logs::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.");
|
Log(Logs::General, Logs::Error, "Unable to open export/SkillCaps.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,11 +194,11 @@ void ExportSkillCaps(SharedDatabase *db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExportBaseData(SharedDatabase *db) {
|
void ExportBaseData(SharedDatabase *db) {
|
||||||
LogInfo("Exporting Base Data");
|
Log(Logs::General, Logs::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.");
|
Log(Logs::General, Logs::Error, "Unable to open export/BaseData.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,11 +225,11 @@ void ExportBaseData(SharedDatabase *db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExportDBStrings(SharedDatabase *db) {
|
void ExportDBStrings(SharedDatabase *db) {
|
||||||
LogInfo("Exporting DB Strings");
|
Log(Logs::General, Logs::Status, "Exporting DB Strings...");
|
||||||
|
|
||||||
FILE *f = fopen("export/dbstr_us.txt", "w");
|
FILE *f = fopen("export/dbstr_us.txt", "w");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open export/dbstr_us.txt to write, skipping.");
|
Log(Logs::General, Logs::Error, "Unable to open export/dbstr_us.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
|
||||||
|
|
||||||
SET(import_sources
|
SET(import_sources
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|||||||
@@ -37,19 +37,19 @@ int main(int argc, char **argv) {
|
|||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
LogInfo("Client Files Import Utility");
|
Log(Logs::General, Logs::Status, "Client Files Import Utility");
|
||||||
if(!EQEmuConfig::LoadConfig()) {
|
if(!EQEmuConfig::LoadConfig()) {
|
||||||
LogError("Unable to load configuration file.");
|
Log(Logs::General, Logs::Error, "Unable to load configuration file.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Config = EQEmuConfig::get();
|
auto Config = EQEmuConfig::get();
|
||||||
|
|
||||||
SharedDatabase database;
|
SharedDatabase database;
|
||||||
LogInfo("Connecting to database");
|
Log(Logs::General, Logs::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 "
|
Log(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a "
|
||||||
"database connection");
|
"database connection");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -97,10 +97,10 @@ bool IsStringField(int i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImportSpells(SharedDatabase *db) {
|
void ImportSpells(SharedDatabase *db) {
|
||||||
LogInfo("Importing Spells");
|
Log(Logs::General, Logs::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.");
|
Log(Logs::General, Logs::Error, "Unable to open import/spells_us.txt to read, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,23 +173,23 @@ void ImportSpells(SharedDatabase *db) {
|
|||||||
|
|
||||||
spells_imported++;
|
spells_imported++;
|
||||||
if(spells_imported % 1000 == 0) {
|
if(spells_imported % 1000 == 0) {
|
||||||
LogInfo("[{}] spells imported", spells_imported);
|
Log(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(spells_imported % 1000 != 0) {
|
if(spells_imported % 1000 != 0) {
|
||||||
LogInfo("[{}] spells imported", spells_imported);
|
Log(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportSkillCaps(SharedDatabase *db) {
|
void ImportSkillCaps(SharedDatabase *db) {
|
||||||
LogInfo("Importing Skill Caps");
|
Log(Logs::General, Logs::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.");
|
Log(Logs::General, Logs::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,11 +220,11 @@ void ImportSkillCaps(SharedDatabase *db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImportBaseData(SharedDatabase *db) {
|
void ImportBaseData(SharedDatabase *db) {
|
||||||
LogInfo("Importing Base Data");
|
Log(Logs::General, Logs::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.");
|
Log(Logs::General, Logs::Error, "Unable to open import/BaseData.txt to read, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,11 +265,11 @@ void ImportBaseData(SharedDatabase *db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImportDBStrings(SharedDatabase *db) {
|
void ImportDBStrings(SharedDatabase *db) {
|
||||||
LogInfo("Importing DB Strings");
|
Log(Logs::General, Logs::Status, "Importing DB Strings...");
|
||||||
|
|
||||||
FILE *f = fopen("import/dbstr_us.txt", "r");
|
FILE *f = fopen("import/dbstr_us.txt", "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open import/dbstr_us.txt to read, skipping.");
|
Log(Logs::General, Logs::Error, "Unable to open import/dbstr_us.txt to read, skipping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
|
||||||
@@ -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)
|
|
||||||
|
|
||||||
+26
-36
@@ -1,15 +1,12 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
|
||||||
|
|
||||||
SET(common_sources
|
SET(common_sources
|
||||||
base_packet.cpp
|
base_packet.cpp
|
||||||
classes.cpp
|
classes.cpp
|
||||||
cli/eqemu_command_handler.cpp
|
|
||||||
compression.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_conversions.cpp
|
||||||
database_instances.cpp
|
database_instances.cpp
|
||||||
@@ -32,13 +29,11 @@ SET(common_sources
|
|||||||
event_sub.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_profile.cpp
|
||||||
inventory_slot.cpp
|
inventory_slot.cpp
|
||||||
ipc_mutex.cpp
|
ipc_mutex.cpp
|
||||||
ip_util.cpp
|
|
||||||
item_data.cpp
|
item_data.cpp
|
||||||
item_instance.cpp
|
item_instance.cpp
|
||||||
json_config.cpp
|
json_config.cpp
|
||||||
@@ -75,6 +70,7 @@ SET(common_sources
|
|||||||
textures.cpp
|
textures.cpp
|
||||||
timer.cpp
|
timer.cpp
|
||||||
unix.cpp
|
unix.cpp
|
||||||
|
xml_parser.cpp
|
||||||
platform.cpp
|
platform.cpp
|
||||||
json/jsoncpp.cpp
|
json/jsoncpp.cpp
|
||||||
net/console_server.cpp
|
net/console_server.cpp
|
||||||
@@ -105,8 +101,13 @@ SET(common_sources
|
|||||||
patches/uf.cpp
|
patches/uf.cpp
|
||||||
patches/uf_limits.cpp
|
patches/uf_limits.cpp
|
||||||
StackWalker/StackWalker.cpp
|
StackWalker/StackWalker.cpp
|
||||||
|
tinyxml/tinystr.cpp
|
||||||
|
tinyxml/tinyxml.cpp
|
||||||
|
tinyxml/tinyxmlerror.cpp
|
||||||
|
tinyxml/tinyxmlparser.cpp
|
||||||
util/directory.cpp
|
util/directory.cpp
|
||||||
util/uuid.cpp)
|
util/uuid.cpp
|
||||||
|
)
|
||||||
|
|
||||||
SET(common_headers
|
SET(common_headers
|
||||||
any.h
|
any.h
|
||||||
@@ -119,13 +120,8 @@ SET(common_headers
|
|||||||
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
|
||||||
deity.h
|
deity.h
|
||||||
emu_constants.h
|
emu_constants.h
|
||||||
@@ -141,7 +137,7 @@ SET(common_headers
|
|||||||
eqemu_config.h
|
eqemu_config.h
|
||||||
eqemu_config_elements.h
|
eqemu_config_elements.h
|
||||||
eqemu_logsys.h
|
eqemu_logsys.h
|
||||||
eqemu_logsys_log_aliases.h
|
eqemu_logsys_fmt.h
|
||||||
eq_limits.h
|
eq_limits.h
|
||||||
eq_packet.h
|
eq_packet.h
|
||||||
eq_stream_ident.h
|
eq_stream_ident.h
|
||||||
@@ -151,21 +147,17 @@ SET(common_headers
|
|||||||
eqtime.h
|
eqtime.h
|
||||||
errmsg.h
|
errmsg.h
|
||||||
event_sub.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
|
global_define.h
|
||||||
guild_base.h
|
guild_base.h
|
||||||
guilds.h
|
guilds.h
|
||||||
http/httplib.h
|
|
||||||
inventory_profile.h
|
inventory_profile.h
|
||||||
inventory_slot.h
|
inventory_slot.h
|
||||||
ipc_mutex.h
|
ipc_mutex.h
|
||||||
ip_util.h
|
|
||||||
item_data.h
|
item_data.h
|
||||||
item_fieldlist.h
|
item_fieldlist.h
|
||||||
item_instance.h
|
item_instance.h
|
||||||
@@ -216,8 +208,10 @@ SET(common_headers
|
|||||||
unix.h
|
unix.h
|
||||||
useperl.h
|
useperl.h
|
||||||
version.h
|
version.h
|
||||||
|
xml_parser.h
|
||||||
zone_numbers.h
|
zone_numbers.h
|
||||||
event/event_loop.h
|
event/event_loop.h
|
||||||
|
event/idle.h
|
||||||
event/task.h
|
event/task.h
|
||||||
event/timer.h
|
event/timer.h
|
||||||
json/json.h
|
json/json.h
|
||||||
@@ -268,20 +262,17 @@ SET(common_headers
|
|||||||
patches/uf_limits.h
|
patches/uf_limits.h
|
||||||
patches/uf_ops.h
|
patches/uf_ops.h
|
||||||
patches/uf_structs.h
|
patches/uf_structs.h
|
||||||
shared/shared_memory.h
|
|
||||||
shared/shared_memory_error.h
|
|
||||||
shared/shared_memory_handle.h
|
|
||||||
shared/shared_memory_list.h
|
|
||||||
shared/shared_memory_map.h
|
|
||||||
shared/shared_memory_string.h
|
|
||||||
shared/shared_memory_vector.h
|
|
||||||
StackWalker/StackWalker.h
|
StackWalker/StackWalker.h
|
||||||
|
tinyxml/tinystr.h
|
||||||
|
tinyxml/tinyxml.h
|
||||||
util/memory_stream.h
|
util/memory_stream.h
|
||||||
util/directory.h
|
util/directory.h
|
||||||
util/uuid.h)
|
util/uuid.h
|
||||||
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(Event FILES
|
SOURCE_GROUP(Event FILES
|
||||||
event/event_loop.h
|
event/event_loop.h
|
||||||
|
event/idle.h
|
||||||
event/timer.h
|
event/timer.h
|
||||||
event/task.h
|
event/task.h
|
||||||
)
|
)
|
||||||
@@ -373,21 +364,20 @@ SOURCE_GROUP(Patches FILES
|
|||||||
patches/uf_limits.cpp
|
patches/uf_limits.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(shared FILES
|
|
||||||
shared/shared_memory.h
|
|
||||||
shared/shared_memory_error.h
|
|
||||||
shared/shared_memory_handle.h
|
|
||||||
shared/shared_memory_list.h
|
|
||||||
shared/shared_memory_map.h
|
|
||||||
shared/shared_memory_string.h
|
|
||||||
shared/shared_memory_vector.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SOURCE_GROUP(StackWalker FILES
|
SOURCE_GROUP(StackWalker FILES
|
||||||
StackWalker/StackWalker.h
|
StackWalker/StackWalker.h
|
||||||
StackWalker/StackWalker.cpp
|
StackWalker/StackWalker.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SOURCE_GROUP(TinyXML FILES
|
||||||
|
tinyxml/tinystr.h
|
||||||
|
tinyxml/tinyxml.h
|
||||||
|
tinyxml/tinystr.cpp
|
||||||
|
tinyxml/tinyxml.cpp
|
||||||
|
tinyxml/tinyxmlerror.cpp
|
||||||
|
tinyxml/tinyxmlparser.cpp
|
||||||
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(Util FILES
|
SOURCE_GROUP(Util FILES
|
||||||
util/memory_stream.h
|
util/memory_stream.h
|
||||||
util/directory.cpp
|
util/directory.cpp
|
||||||
@@ -396,7 +386,7 @@ SOURCE_GROUP(Util FILES
|
|||||||
util/uuid.h
|
util/uuid.h
|
||||||
)
|
)
|
||||||
|
|
||||||
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})
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
* 2005-08-05 v5 - Removed most Lint (http://www.gimpel.com/) errors... thanks to Okko Willeboordse!
|
* 2005-08-05 v5 - Removed most Lint (http://www.gimpel.com/) errors... thanks to Okko Willeboordse!
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
* 2013-01-26 - Modified by KimLS(KLS) for EQEmu's purposes
|
* 2013-01-26 - Modified by KimLS(KLS) for EQEmu's purposes
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
// #pragma once is supported starting with _MCS_VER 1000,
|
// #pragma once is supported starting with _MCS_VER 1000,
|
||||||
// so we need not to check the version (because we only support _MSC_VER >= 1100)!
|
// so we need not to check the version (because we only support _MSC_VER >= 1100)!
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|||||||
@@ -573,20 +573,6 @@ bool IsNonSpellFighterClass(uint8 class_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
bool IsCasterClass(uint8 class_id)
|
||||||
{
|
{
|
||||||
switch (class_id) {
|
switch (class_id) {
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ uint8 GetClassIDFromPlayerClassBit(uint32 player_class_bit);
|
|||||||
bool IsFighterClass(uint8 class_id);
|
bool IsFighterClass(uint8 class_id);
|
||||||
bool IsSpellFighterClass(uint8 class_id);
|
bool IsSpellFighterClass(uint8 class_id);
|
||||||
bool IsNonSpellFighterClass(uint8 class_id);
|
bool IsNonSpellFighterClass(uint8 class_id);
|
||||||
bool IsHybridClass(uint8 class_id);
|
|
||||||
bool IsCasterClass(uint8 class_id);
|
bool IsCasterClass(uint8 class_id);
|
||||||
bool IsINTCasterClass(uint8 class_id);
|
bool IsINTCasterClass(uint8 class_id);
|
||||||
bool IsWISCasterClass(uint8 class_id);
|
bool IsWISCasterClass(uint8 class_id);
|
||||||
|
|||||||
@@ -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_
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "condition.h"
|
#include "condition.h"
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
|
|
||||||
Condition::Condition()
|
Condition::Condition()
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "global_define.h"
|
#include "global_define.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
class Condition {
|
class Condition {
|
||||||
private:
|
private:
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
enum {
|
enum {
|
||||||
SignalEvent = 0,
|
SignalEvent = 0,
|
||||||
BroadcastEvent,
|
BroadcastEvent,
|
||||||
|
|||||||
+2
-55
@@ -2,7 +2,7 @@
|
|||||||
#include "eqemu_logsys.h"
|
#include "eqemu_logsys.h"
|
||||||
#include "crash.h"
|
#include "crash.h"
|
||||||
|
|
||||||
#if defined(_WINDOWS) && defined(CRASH_LOGGING)
|
#if defined(_WIN32) && defined(CRASH_LOGGING)
|
||||||
#include "StackWalker.h"
|
#include "StackWalker.h"
|
||||||
|
|
||||||
class EQEmuStackWalker : public StackWalker
|
class EQEmuStackWalker : public StackWalker
|
||||||
@@ -111,60 +111,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
|
||||||
|
|||||||
+32
-36
@@ -1,57 +1,53 @@
|
|||||||
/**
|
/* EQEMu: Everquest Server Emulator
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
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
|
||||||
* the Free Software Foundation; version 2 of the License.
|
the Free Software Foundation; version 2 of the License.
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||||
* are required to give you total support for your newly bought product;
|
are required to give you total support for your newly bought product;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace EQEmu {
|
namespace EQEmu
|
||||||
template<typename T>
|
{
|
||||||
T Clamp(const T &value, const T &lower, const T &upper)
|
template <typename T>
|
||||||
{
|
T Clamp(const T& value, const T& lower, const T& upper) {
|
||||||
return std::max(lower, std::min(value, upper));
|
return std::max(lower, std::min(value, upper));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
T ClampLower(const T &value, const T &lower)
|
T ClampLower(const T& value, const T& lower) {
|
||||||
{
|
|
||||||
return std::max(lower, value);
|
return std::max(lower, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
T ClampUpper(const T &value, const T &upper)
|
T ClampUpper(const T& value, const T& upper) {
|
||||||
{
|
|
||||||
return std::min(value, upper);
|
return std::min(value, upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
bool ValueWithin(const T &value, const T &lower, const T &upper)
|
bool ValueWithin(const T& value, const T& lower, const T& upper) {
|
||||||
{
|
|
||||||
return value >= lower && value <= upper;
|
return value >= lower && value <= upper;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2, typename T3>
|
template <typename T1, typename T2, typename T3>
|
||||||
bool ValueWithin(const T1 &value, const T2 &lower, const T3 &upper)
|
bool ValueWithin(const T1& value, const T2& lower, const T3& upper) {
|
||||||
{
|
return value >= (T1)lower && value <= (T1)upper;
|
||||||
return value >= (T1) lower && value <= (T1) upper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} /*EQEmu*/
|
} /*EQEmu*/
|
||||||
|
|
||||||
|
|||||||
+117
-274
@@ -30,7 +30,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// Disgrace: for windows compile
|
// Disgrace: for windows compile
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
@@ -45,7 +45,6 @@
|
|||||||
#include "eq_packet_structs.h"
|
#include "eq_packet_structs.h"
|
||||||
#include "extprofile.h"
|
#include "extprofile.h"
|
||||||
#include "string_util.h"
|
#include "string_util.h"
|
||||||
#include "database_schema.h"
|
|
||||||
|
|
||||||
extern Client client;
|
extern Client client;
|
||||||
|
|
||||||
@@ -65,11 +64,11 @@ bool Database::Connect(const char* host, const char* user, const char* passwd, c
|
|||||||
uint32 errnum= 0;
|
uint32 errnum= 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
if (!Open(host, user, passwd, database, port, &errnum, errbuf)) {
|
if (!Open(host, user, passwd, database, port, &errnum, errbuf)) {
|
||||||
LogError("Failed to connect to database: Error: {}", errbuf);
|
Log(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogInfo("Using database [{}] at [{}]:[{}]", database, host,port);
|
Log(Logs::General, Logs::Status, "Using database '%s' at %s:%d", database, host,port);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,7 +86,7 @@ Database::~Database()
|
|||||||
Return the account id or zero if no account matches.
|
Return the account id or zero if no account matches.
|
||||||
Zero will also be returned if there is a database error.
|
Zero will also be returned if there is a database error.
|
||||||
*/
|
*/
|
||||||
uint32 Database::CheckLogin(const char* name, const char* password, const char *loginserver, int16* oStatus) {
|
uint32 Database::CheckLogin(const char* name, const char* password, int16* oStatus) {
|
||||||
|
|
||||||
if(strlen(name) >= 50 || strlen(password) >= 50)
|
if(strlen(name) >= 50 || strlen(password) >= 50)
|
||||||
return(0);
|
return(0);
|
||||||
@@ -98,10 +97,9 @@ uint32 Database::CheckLogin(const char* name, const char* password, const char *
|
|||||||
DoEscapeString(tmpUN, name, strlen(name));
|
DoEscapeString(tmpUN, name, strlen(name));
|
||||||
DoEscapeString(tmpPW, password, strlen(password));
|
DoEscapeString(tmpPW, password, strlen(password));
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT id, status FROM account WHERE `name`='%s' AND ls_id='%s' AND password is not null "
|
std::string query = StringFormat("SELECT id, status FROM account WHERE name='%s' AND password is not null "
|
||||||
"and length(password) > 0 and (password='%s' or password=MD5('%s'))",
|
"and length(password) > 0 and (password='%s' or password=MD5('%s'))",
|
||||||
tmpUN, EscapeString(loginserver).c_str(), tmpPW, tmpPW);
|
tmpUN, tmpPW, tmpPW);
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
@@ -125,7 +123,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, const char *
|
|||||||
//Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table.
|
//Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table.
|
||||||
bool Database::CheckBannedIPs(const char* loginIP)
|
bool Database::CheckBannedIPs(const char* loginIP)
|
||||||
{
|
{
|
||||||
std::string query = StringFormat("SELECT ip_address FROM banned_ips WHERE ip_address='%s'", loginIP);
|
std::string query = StringFormat("SELECT ip_address FROM Banned_IPs WHERE ip_address='%s'", loginIP);
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
@@ -141,7 +139,7 @@ bool Database::CheckBannedIPs(const char* loginIP)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::AddBannedIP(char* bannedIP, const char* notes) {
|
bool Database::AddBannedIP(char* bannedIP, const char* notes) {
|
||||||
std::string query = StringFormat("INSERT into banned_ips SET ip_address='%s', notes='%s'", bannedIP, notes);
|
std::string query = StringFormat("INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -199,61 +197,32 @@ int16 Database::CheckStatus(uint32 account_id)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
uint32 Database::CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id) {
|
||||||
* @param name
|
|
||||||
* @param password
|
|
||||||
* @param status
|
|
||||||
* @param loginserver
|
|
||||||
* @param lsaccount_id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
uint32 Database::CreateAccount(
|
|
||||||
const char *name,
|
|
||||||
const char *password,
|
|
||||||
int16 status,
|
|
||||||
const char *loginserver,
|
|
||||||
uint32 lsaccount_id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
if (password) {
|
if (password)
|
||||||
query = StringFormat(
|
query = StringFormat("INSERT INTO account SET name='%s', password='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name,password,status, lsaccount_id);
|
||||||
"INSERT INTO account SET name='%s', password='%s', status=%i, ls_id='%s', lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",
|
else
|
||||||
name,
|
query = StringFormat("INSERT INTO account SET name='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name, status, lsaccount_id);
|
||||||
password,
|
|
||||||
status,
|
|
||||||
loginserver,
|
|
||||||
lsaccount_id
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
query = StringFormat(
|
|
||||||
"INSERT INTO account SET name='%s', status=%i, ls_id='%s', lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",
|
|
||||||
name,
|
|
||||||
status,
|
|
||||||
loginserver,
|
|
||||||
lsaccount_id
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
LogInfo("Account Attempting to be created: [{0}:{1}] status: {2}", loginserver, name, status);
|
Log(Logs::General, Logs::World_Server, "Account Attempting to be created: '%s' status: %i", name, status);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.LastInsertedID() == 0) {
|
if (results.LastInsertedID() == 0)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return results.LastInsertedID();
|
return results.LastInsertedID();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::DeleteAccount(const char* name, const char *loginserver) {
|
bool Database::DeleteAccount(const char* name) {
|
||||||
std::string query = StringFormat("DELETE FROM account WHERE `name`='%s' AND ls_id='%s'", name, loginserver);
|
std::string query = StringFormat("DELETE FROM account WHERE name='%s';",name);
|
||||||
LogInfo("Account Attempting to be deleted:'[{}]:[{}]'", loginserver, name);
|
Log(Logs::General, Logs::World_Server, "Account Attempting to be deleted:'%s'", name);
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
@@ -294,44 +263,13 @@ bool Database::SetAccountStatus(const char* name, int16 status) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param account_name
|
|
||||||
* @param status
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool Database::SetAccountStatus(const std::string& account_name, int16 status)
|
|
||||||
{
|
|
||||||
LogInfo("Account [{}] is attempting to be set to status [{}]", account_name, status);
|
|
||||||
|
|
||||||
std::string query = fmt::format(
|
|
||||||
SQL(
|
|
||||||
UPDATE account SET status = {} WHERE name = '{}'
|
|
||||||
),
|
|
||||||
status,
|
|
||||||
account_name
|
|
||||||
);
|
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
|
|
||||||
if (!results.Success()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.RowsAffected() == 0) {
|
|
||||||
LogWarning("Account [{}] does not exist!", account_name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This initially creates the character during character create */
|
/* This initially creates the character during character create */
|
||||||
bool Database::ReserveName(uint32 account_id, char* name) {
|
bool Database::ReserveName(uint32 account_id, char* name) {
|
||||||
std::string query = StringFormat("SELECT `account_id`, `name` FROM `character_data` WHERE `name` = '%s'", name);
|
std::string query = StringFormat("SELECT `account_id`, `name` FROM `character_data` WHERE `name` = '%s'", name);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
if (row[0] && atoi(row[0]) > 0){
|
if (row[0] && atoi(row[0]) > 0){
|
||||||
LogInfo("Account: [{}] tried to request name: [{}], but it is already taken", account_id, name);
|
Log(Logs::General, Logs::World_Server, "Account: %i tried to request name: %s, but it is already taken...", account_id, name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,81 +277,70 @@ bool Database::ReserveName(uint32 account_id, char* name) {
|
|||||||
query = StringFormat("INSERT INTO `character_data` SET `account_id` = %i, `name` = '%s'", account_id, name);
|
query = StringFormat("INSERT INTO `character_data` SET `account_id` = %i, `name` = '%s'", account_id, name);
|
||||||
results = QueryDatabase(query);
|
results = QueryDatabase(query);
|
||||||
if (!results.Success() || results.ErrorMessage() != ""){ return false; }
|
if (!results.Success() || results.ErrorMessage() != ""){ return false; }
|
||||||
|
|
||||||
// Put character into the default guild if rule is being used.
|
|
||||||
int guild_id = RuleI(Character, DefaultGuild);
|
|
||||||
|
|
||||||
if (guild_id != 0) {
|
|
||||||
int character_id=results.LastInsertedID();
|
|
||||||
if (character_id > -1) {
|
|
||||||
query = StringFormat("INSERT INTO `guild_members` SET `char_id` = %i, `guild_id` = '%i'", character_id, guild_id);
|
|
||||||
results = QueryDatabase(query);
|
|
||||||
if (!results.Success() || results.ErrorMessage() != ""){
|
|
||||||
LogInfo("Could not put character [{}] into default Guild", name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* @param character_name
|
Delete the character with the name "name"
|
||||||
* @return
|
returns false on failure, true otherwise
|
||||||
*/
|
*/
|
||||||
bool Database::DeleteCharacter(char *character_name) {
|
bool Database::DeleteCharacter(char *name) {
|
||||||
uint32 character_id = 0;
|
uint32 charid = 0;
|
||||||
if(!character_name || !strlen(character_name)) {
|
if(!name || !strlen(name)) {
|
||||||
LogInfo("DeleteCharacter: request to delete without a name (empty char slot)");
|
Log(Logs::General, Logs::World_Server, "DeleteCharacter: request to delete without a name (empty char slot)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Log(Logs::General, Logs::World_Server, "Database::DeleteCharacter name : '%s'", name);
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT `id` from `character_data` WHERE `name` = '%s'", character_name);
|
/* Get id from character_data before deleting record so we can clean up the rest of the tables */
|
||||||
|
std::string query = StringFormat("SELECT `id` from `character_data` WHERE `name` = '%s'", name);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) { charid = atoi(row[0]); }
|
||||||
character_id = atoi(row[0]);
|
if (charid <= 0){
|
||||||
}
|
Log(Logs::General, Logs::Error, "Database::DeleteCharacter :: Character (%s) not found, stopping delete...", name);
|
||||||
|
|
||||||
if (character_id <= 0) {
|
|
||||||
LogError("DeleteCharacter | Invalid Character ID [{}]", character_name);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string delete_type = "hard-deleted";
|
query = StringFormat("DELETE FROM `quest_globals` WHERE `charid` = '%d'", charid); QueryDatabase(query);
|
||||||
if (RuleB(Character, SoftDeletes)) {
|
query = StringFormat("DELETE FROM `character_activities` WHERE `charid` = '%d'", charid); QueryDatabase(query);
|
||||||
delete_type = "soft-deleted";
|
query = StringFormat("DELETE FROM `character_enabledtasks` WHERE `charid` = '%d'", charid); QueryDatabase(query);
|
||||||
std::string query = fmt::format(
|
query = StringFormat("DELETE FROM `character_tasks` WHERE `charid` = '%d'", charid); QueryDatabase(query);
|
||||||
SQL(
|
query = StringFormat("DELETE FROM `completed_tasks` WHERE `charid` = '%d'", charid); QueryDatabase(query);
|
||||||
UPDATE
|
query = StringFormat("DELETE FROM `friends` WHERE `charid` = '%d'", charid); QueryDatabase(query);
|
||||||
character_data
|
query = StringFormat("DELETE FROM `mail` WHERE `charid` = '%d'", charid); QueryDatabase(query);
|
||||||
SET
|
query = StringFormat("DELETE FROM `timers` WHERE `char_id` = '%d'", charid); QueryDatabase(query);
|
||||||
name = SUBSTRING(CONCAT(name, '-deleted-', UNIX_TIMESTAMP()), 1, 64),
|
query = StringFormat("DELETE FROM `inventory` WHERE `charid` = '%d'", charid); QueryDatabase(query);
|
||||||
deleted_at = NOW()
|
query = StringFormat("DELETE FROM `char_recipe_list` WHERE `char_id` = '%d'", charid); QueryDatabase(query);
|
||||||
WHERE
|
query = StringFormat("DELETE FROM `adventure_stats` WHERE `player_id` ='%d'", charid); QueryDatabase(query);
|
||||||
id = '{}'
|
query = StringFormat("DELETE FROM `zone_flags` WHERE `charID` = '%d'", charid); QueryDatabase(query);
|
||||||
),
|
query = StringFormat("DELETE FROM `titles` WHERE `char_id` = '%d'", charid); QueryDatabase(query);
|
||||||
character_id
|
query = StringFormat("DELETE FROM `player_titlesets` WHERE `char_id` = '%d'", charid); QueryDatabase(query);
|
||||||
);
|
query = StringFormat("DELETE FROM `keyring` WHERE `char_id` = '%d'", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `faction_values` WHERE `char_id` = '%d'", charid); QueryDatabase(query);
|
||||||
QueryDatabase(query);
|
query = StringFormat("DELETE FROM `instance_list_player` WHERE `charid` = '%d'", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `character_data` WHERE `id` = '%d'", charid); QueryDatabase(query);
|
||||||
return true;
|
query = StringFormat("DELETE FROM `character_skills` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
}
|
query = StringFormat("DELETE FROM `character_languages` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `character_bind` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
LogInfo("DeleteCharacter | Character [{}] ({}) is being [{}]", character_name, character_id, delete_type);
|
query = StringFormat("DELETE FROM `character_alternate_abilities` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `character_currency` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
for (const auto& iter : DatabaseSchema::GetCharacterTables()) {
|
query = StringFormat("DELETE FROM `character_data` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
std::string table_name = iter.first;
|
query = StringFormat("DELETE FROM `character_spells` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
std::string character_id_column_name = iter.second;
|
query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `character_disciplines` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
QueryDatabase(fmt::format("DELETE FROM {} WHERE {} = {}", table_name, character_id_column_name, character_id));
|
query = StringFormat("DELETE FROM `character_material` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
}
|
query = StringFormat("DELETE FROM `character_tribute` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `character_bandolier` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `character_potionbelt` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `character_inspect_messages` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", charid); QueryDatabase(query);
|
||||||
|
query = StringFormat("DELETE FROM `character_alt_currency` WHERE `char_id` = '%d'", charid); QueryDatabase(query);
|
||||||
#ifdef BOTS
|
#ifdef BOTS
|
||||||
query = StringFormat("DELETE FROM `guild_members` WHERE `char_id` = '%d' AND GetMobTypeById(%i) = 'C'", character_id); // note: only use of GetMobTypeById()
|
query = StringFormat("DELETE FROM `guild_members` WHERE `char_id` = '%d' AND GetMobTypeById(%i) = 'C'", charid); // note: only use of GetMobTypeById()
|
||||||
QueryDatabase(query);
|
#else
|
||||||
|
query = StringFormat("DELETE FROM `guild_members` WHERE `char_id` = '%d'", charid);
|
||||||
#endif
|
#endif
|
||||||
|
QueryDatabase(query);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -695,7 +622,6 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
|
|||||||
pp->RestTimer // " RestTimer) "
|
pp->RestTimer // " RestTimer) "
|
||||||
);
|
);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
/* Save Bind Points */
|
/* Save Bind Points */
|
||||||
query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot)"
|
query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot)"
|
||||||
" VALUES (%u, %u, %u, %f, %f, %f, %f, %i), "
|
" VALUES (%u, %u, %u, %f, %f, %f, %f, %i), "
|
||||||
@@ -758,7 +684,7 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQEmu
|
|||||||
charid = GetCharacterID(pp->name);
|
charid = GetCharacterID(pp->name);
|
||||||
|
|
||||||
if(!charid) {
|
if(!charid) {
|
||||||
LogError("StoreCharacter: no character id");
|
Log(Logs::General, Logs::Error, "StoreCharacter: no character id");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,12 +785,11 @@ uint32 Database::GetAccountIDByChar(uint32 char_id) {
|
|||||||
return atoi(row[0]);
|
return atoi(row[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Database::GetAccountIDByName(const char* accname, const char *loginserver, int16* status, uint32* lsid) {
|
uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32* lsid) {
|
||||||
if (!isAlphaNumeric(accname))
|
if (!isAlphaNumeric(accname))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT `id`, `status`, `lsaccount_id` FROM `account` WHERE `name` = '%s' AND `ls_id`='%s' LIMIT 1",
|
std::string query = StringFormat("SELECT `id`, `status`, `lsaccount_id` FROM `account` WHERE `name` = '%s' LIMIT 1", accname);
|
||||||
EscapeString(accname).c_str(), EscapeString(loginserver).c_str());
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
@@ -925,38 +850,6 @@ void Database::GetCharName(uint32 char_id, char* name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Database::GetCharNameByID(uint32 char_id) {
|
|
||||||
std::string query = fmt::format("SELECT `name` FROM `character_data` WHERE id = {}", char_id);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
|
|
||||||
if (!results.Success()) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.RowCount() == 0) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
auto row = results.begin();
|
|
||||||
return row[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Database::GetNPCNameByID(uint32 npc_id) {
|
|
||||||
std::string query = fmt::format("SELECT `name` FROM `npc_types` WHERE id = {}", npc_id);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
|
|
||||||
if (!results.Success()) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.RowCount() == 0) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
auto row = results.begin();
|
|
||||||
return row[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Database::LoadVariables() {
|
bool Database::LoadVariables() {
|
||||||
auto results = QueryDatabase(StringFormat("SELECT varname, value, unix_timestamp() FROM variables where unix_timestamp(ts) >= %d", varcache.last_update));
|
auto results = QueryDatabase(StringFormat("SELECT varname, value, unix_timestamp() FROM variables where unix_timestamp(ts) >= %d", varcache.last_update));
|
||||||
|
|
||||||
@@ -1025,6 +918,18 @@ bool Database::SetVariable(const std::string varname, const std::string &varvalu
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 Database::GetMiniLoginAccount(char* ip)
|
||||||
|
{
|
||||||
|
std::string query = StringFormat("SELECT `id` FROM `account` WHERE `minilogin_ip` = '%s'", ip);
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
|
if (!results.Success())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
return atoi(row[0]);
|
||||||
|
}
|
||||||
|
|
||||||
// Get zone starting points from DB
|
// Get zone starting points from DB
|
||||||
bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe_x, float* safe_y, float* safe_z, int16* minstatus, uint8* minlevel, char *flag_needed) {
|
bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe_x, float* safe_y, float* safe_z, int16* minstatus, uint8* minlevel, char *flag_needed) {
|
||||||
|
|
||||||
@@ -1286,46 +1191,25 @@ bool Database::AddToNameFilter(const char* name) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* oStatus) {
|
||||||
* @param in_loginserver_id
|
|
||||||
* @param in_loginserver_account_id
|
|
||||||
* @param in_account_name
|
|
||||||
* @param in_status
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
uint32 Database::GetAccountIDFromLSID(
|
|
||||||
const std::string &in_loginserver_id,
|
|
||||||
uint32 in_loginserver_account_id,
|
|
||||||
char *in_account_name,
|
|
||||||
int16 *in_status
|
|
||||||
)
|
|
||||||
{
|
|
||||||
uint32 account_id = 0;
|
uint32 account_id = 0;
|
||||||
auto query = fmt::format(
|
std::string query = StringFormat("SELECT id, name, status FROM account WHERE lsaccount_id=%i", iLSID);
|
||||||
"SELECT id, `name`, status FROM account WHERE lsaccount_id = {0} AND ls_id = '{1}'",
|
|
||||||
in_loginserver_account_id,
|
|
||||||
in_loginserver_id
|
|
||||||
);
|
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.RowCount() != 1) {
|
if (results.RowCount() != 1)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
account_id = std::stoi(row[0]);
|
account_id = atoi(row[0]);
|
||||||
|
|
||||||
if (in_account_name) {
|
if (oAccountName)
|
||||||
strcpy(in_account_name, row[1]);
|
strcpy(oAccountName, row[1]);
|
||||||
}
|
if (oStatus)
|
||||||
if (in_status) {
|
*oStatus = atoi(row[2]);
|
||||||
*in_status = std::stoi(row[2]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return account_id;
|
return account_id;
|
||||||
@@ -1333,7 +1217,7 @@ uint32 Database::GetAccountIDFromLSID(
|
|||||||
|
|
||||||
void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
|
void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT `name`, status FROM account WHERE id=%i", id);
|
std::string query = StringFormat("SELECT name, status FROM account WHERE id=%i", id);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()){
|
if (!results.Success()){
|
||||||
@@ -1558,9 +1442,9 @@ uint32 Database::GetCharacterInfo(
|
|||||||
return charid;
|
return charid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::UpdateLiveChar(char* charname, uint32 account_id) {
|
bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) {
|
||||||
|
|
||||||
std::string query = StringFormat("UPDATE account SET charname='%s' WHERE id=%i;", charname, account_id);
|
std::string query = StringFormat("UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()){
|
if (!results.Success()){
|
||||||
@@ -1627,7 +1511,7 @@ void Database::SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ism
|
|||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
LogError("Error deleting character from group id: {}", results.ErrorMessage().c_str());
|
Log(Logs::General, Logs::Error, "Error deleting character from group id: %s", results.ErrorMessage().c_str());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1670,7 +1554,7 @@ uint32 Database::GetGroupID(const char* name){
|
|||||||
if (results.RowCount() == 0)
|
if (results.RowCount() == 0)
|
||||||
{
|
{
|
||||||
// Commenting this out until logging levels can prevent this from going to console
|
// Commenting this out until logging levels can prevent this from going to console
|
||||||
//LogDebug(, "Character not in a group: [{}]", name);
|
//Log(Logs::General, Logs::None,, "Character not in a group: %s", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1717,7 +1601,7 @@ void Database::SetGroupLeaderName(uint32 gid, const char* name) {
|
|||||||
result = QueryDatabase(query);
|
result = QueryDatabase(query);
|
||||||
|
|
||||||
if(!result.Success()) {
|
if(!result.Success()) {
|
||||||
LogDebug("Error in Database::SetGroupLeaderName: [{}]", result.ErrorMessage().c_str());
|
Log(Logs::General, Logs::None, "Error in Database::SetGroupLeaderName: %s", result.ErrorMessage().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1923,7 +1807,7 @@ const char* Database::GetRaidLeaderName(uint32 raid_id)
|
|||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
LogDebug("Unable to get Raid Leader Name for Raid ID: [{}]", raid_id);
|
Log(Logs::General, Logs::Debug, "Unable to get Raid Leader Name for Raid ID: %u", raid_id);
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2190,49 +2074,9 @@ uint32 Database::GetGuildIDByCharID(uint32 character_id)
|
|||||||
return atoi(row[0]);
|
return atoi(row[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Database::GetGroupIDByCharID(uint32 character_id)
|
void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings) {
|
||||||
{
|
// log_settings previously initialized to '0' by EQEmuLogSys::LoadLogSettingsDefaults()
|
||||||
std::string query = fmt::format(
|
|
||||||
SQL(
|
|
||||||
SELECT groupid
|
|
||||||
FROM group_id
|
|
||||||
WHERE charid = '{}'
|
|
||||||
),
|
|
||||||
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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 Database::GetRaidIDByCharID(uint32 character_id) {
|
|
||||||
std::string query = fmt::format(
|
|
||||||
SQL(
|
|
||||||
SELECT raidid
|
|
||||||
FROM raid_members
|
|
||||||
WHERE charid = '{}'
|
|
||||||
),
|
|
||||||
character_id
|
|
||||||
);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
|
||||||
return atoi(row[0]);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param log_settings
|
|
||||||
*/
|
|
||||||
void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|
||||||
{
|
|
||||||
std::string query =
|
std::string query =
|
||||||
"SELECT "
|
"SELECT "
|
||||||
"log_category_id, "
|
"log_category_id, "
|
||||||
@@ -2245,9 +2089,10 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|||||||
"ORDER BY log_category_id";
|
"ORDER BY log_category_id";
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
int log_category_id = 0;
|
int log_category_id = 0;
|
||||||
|
|
||||||
int *categories_in_database = new int[1000];
|
int categories_in_database[1000] = {};
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
log_category_id = atoi(row[0]);
|
log_category_id = atoi(row[0]);
|
||||||
@@ -2287,14 +2132,15 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|||||||
* Auto inject categories that don't exist in the database...
|
* Auto inject categories that don't exist in the database...
|
||||||
*/
|
*/
|
||||||
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
||||||
if (categories_in_database[log_index] != 1) {
|
if (!categories_in_database[log_index]) {
|
||||||
|
|
||||||
LogInfo(
|
Log(Logs::General,
|
||||||
"New Log Category [{0}] doesn't exist... Automatically adding to [logsys_categories] table...",
|
Logs::Status,
|
||||||
|
"New Log Category '%s' doesn't exist... Automatically adding to `logsys_categories` table...",
|
||||||
Logs::LogCategoryName[log_index]
|
Logs::LogCategoryName[log_index]
|
||||||
);
|
);
|
||||||
|
|
||||||
auto inject_query = fmt::format(
|
std::string inject_query = StringFormat(
|
||||||
"INSERT INTO logsys_categories "
|
"INSERT INTO logsys_categories "
|
||||||
"(log_category_id, "
|
"(log_category_id, "
|
||||||
"log_category_description, "
|
"log_category_description, "
|
||||||
@@ -2302,19 +2148,17 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|||||||
"log_to_file, "
|
"log_to_file, "
|
||||||
"log_to_gmsay) "
|
"log_to_gmsay) "
|
||||||
"VALUES "
|
"VALUES "
|
||||||
"({0}, '{1}', {2}, {3}, {4})",
|
"(%i, '%s', %i, %i, %i)",
|
||||||
log_index,
|
log_index,
|
||||||
EscapeString(Logs::LogCategoryName[log_index]),
|
EscapeString(Logs::LogCategoryName[log_index]).c_str(),
|
||||||
std::to_string(log_settings[log_index].log_to_console),
|
log_settings[log_category_id].log_to_console,
|
||||||
std::to_string(log_settings[log_index].log_to_file),
|
log_settings[log_category_id].log_to_file,
|
||||||
std::to_string(log_settings[log_index].log_to_gmsay)
|
log_settings[log_category_id].log_to_gmsay
|
||||||
);
|
);
|
||||||
|
|
||||||
QueryDatabase(inject_query);
|
QueryDatabase(inject_query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] categories_in_database;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::CountInvSnapshots() {
|
int Database::CountInvSnapshots() {
|
||||||
@@ -2351,7 +2195,7 @@ struct TimeOfDay_Struct Database::LoadTime(time_t &realtime)
|
|||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success() || results.RowCount() == 0){
|
if (!results.Success() || results.RowCount() == 0){
|
||||||
LogInfo("Loading EQ time of day failed. Using defaults");
|
Log(Logs::Detail, Logs::World_Server, "Loading EQ time of day failed. Using defaults.");
|
||||||
eqTime.minute = 0;
|
eqTime.minute = 0;
|
||||||
eqTime.hour = 9;
|
eqTime.hour = 9;
|
||||||
eqTime.day = 1;
|
eqTime.day = 1;
|
||||||
@@ -2405,4 +2249,3 @@ int Database::GetInstanceID(uint32 char_id, uint32 zone_id) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-23
@@ -82,17 +82,7 @@ struct VarCache_Struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class PTimerList;
|
class PTimerList;
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
#if _MSC_VER > 1700 // greater than 2012 (2013+)
|
|
||||||
# define _ISNAN_(a) std::isnan(a)
|
# 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__
|
#define SQL(...) #__VA_ARGS__
|
||||||
|
|
||||||
@@ -107,7 +97,7 @@ public:
|
|||||||
|
|
||||||
bool AddToNameFilter(const char* name);
|
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 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 DeleteCharacter(char* 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);
|
||||||
@@ -120,7 +110,7 @@ public:
|
|||||||
|
|
||||||
/* General Information Queries */
|
/* General Information Queries */
|
||||||
|
|
||||||
bool AddBannedIP(char* bannedIP, const char* notes); //Add IP address to the banned_ips table.
|
bool AddBannedIP(char* bannedIP, const char* notes); //Add IP address to the Banned_IPs table.
|
||||||
bool AddGMIP(char* ip_address, char* name);
|
bool AddGMIP(char* ip_address, char* name);
|
||||||
bool CheckBannedIPs(const char* loginIP); //Check incoming connection against banned IP table.
|
bool CheckBannedIPs(const char* loginIP); //Check incoming connection against banned IP table.
|
||||||
bool CheckGMIPs(const char* loginIP, uint32 account_id);
|
bool CheckGMIPs(const char* loginIP, uint32 account_id);
|
||||||
@@ -129,17 +119,13 @@ public:
|
|||||||
|
|
||||||
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 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 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);
|
|
||||||
const char *GetNPCNameByID(uint32 npc_id);
|
|
||||||
void LoginIP(uint32 AccountID, const char* LoginIP);
|
void LoginIP(uint32 AccountID, const char* LoginIP);
|
||||||
|
|
||||||
/* Instancing */
|
/* Instancing */
|
||||||
@@ -180,18 +166,18 @@ public:
|
|||||||
|
|
||||||
/* Account Related */
|
/* Account Related */
|
||||||
|
|
||||||
bool DeleteAccount(const char *name, const char* loginserver);
|
bool DeleteAccount(const char* name);
|
||||||
bool GetLiveChar(uint32 account_id, char* cname);
|
bool GetLiveChar(uint32 account_id, char* cname);
|
||||||
bool SetAccountStatus(const char* name, int16 status);
|
bool SetAccountStatus(const char* name, int16 status);
|
||||||
bool SetAccountStatus(const std::string& account_name, int16 status);
|
|
||||||
bool SetLocalPassword(uint32 accid, const char* password);
|
bool SetLocalPassword(uint32 accid, const char* password);
|
||||||
bool UpdateLiveChar(char* charname, uint32 account_id);
|
bool UpdateLiveChar(char* charname, uint32 lsaccount_id);
|
||||||
|
|
||||||
int16 CheckStatus(uint32 account_id);
|
int16 CheckStatus(uint32 account_id);
|
||||||
|
|
||||||
uint32 CheckLogin(const char* name, const char* password, const char *loginserver, int16* oStatus = 0);
|
uint32 CheckLogin(const char* name, const char* password, int16* oStatus = 0);
|
||||||
uint32 CreateAccount(const char* name, const char* password, int16 status, const char* loginserver, uint32 lsaccount_id);
|
uint32 CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id = 0);
|
||||||
uint32 GetAccountIDFromLSID(const std::string& in_loginserver_id, uint32 in_loginserver_account_id, char* in_account_name = 0, int16* in_status = 0);
|
uint32 GetAccountIDFromLSID(uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0);
|
||||||
|
uint32 GetMiniLoginAccount(char* ip);
|
||||||
uint8 GetAgreementFlag(uint32 acctid);
|
uint8 GetAgreementFlag(uint32 acctid);
|
||||||
|
|
||||||
void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus);
|
void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus);
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Disgrace: for windows compile
|
// Disgrace: for windows compile
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Disgrace: for windows compile
|
// Disgrace: for windows compile
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
@@ -101,20 +101,14 @@ bool Database::CheckInstanceExpired(uint16 instance_id)
|
|||||||
int32 duration = 0;
|
int32 duration = 0;
|
||||||
uint32 never_expires = 0;
|
uint32 never_expires = 0;
|
||||||
|
|
||||||
std::string query = StringFormat(
|
std::string query = StringFormat("SELECT start_time, duration, never_expires FROM instance_list WHERE id=%u", instance_id);
|
||||||
"SELECT start_time, duration, never_expires FROM instance_list WHERE id=%u",
|
|
||||||
instance_id
|
|
||||||
);
|
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success())
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
if (results.RowCount() == 0) {
|
if (results.RowCount() == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
|
|
||||||
@@ -122,28 +116,23 @@ bool Database::CheckInstanceExpired(uint16 instance_id)
|
|||||||
duration = atoi(row[1]);
|
duration = atoi(row[1]);
|
||||||
never_expires = atoi(row[2]);
|
never_expires = atoi(row[2]);
|
||||||
|
|
||||||
if (never_expires == 1) {
|
if (never_expires == 1)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
timeval tv{};
|
timeval tv;
|
||||||
gettimeofday(&tv, nullptr);
|
gettimeofday(&tv, nullptr);
|
||||||
|
|
||||||
return (start_time + duration) <= tv.tv_sec;
|
if ((start_time + duration) <= tv.tv_sec)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration)
|
bool Database::CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration)
|
||||||
{
|
{
|
||||||
std::string query = StringFormat(
|
std::string query = StringFormat("INSERT INTO instance_list (id, zone, version, start_time, duration)"
|
||||||
"INSERT INTO instance_list (id, zone, version, start_time, duration)"
|
" values(%lu, %lu, %lu, UNIX_TIMESTAMP(), %lu)",
|
||||||
" values (%u, %u, %u, UNIX_TIMESTAMP(), %u)",
|
(unsigned long)instance_id, (unsigned long)zone_id, (unsigned long)version, (unsigned long)duration);
|
||||||
instance_id,
|
|
||||||
zone_id,
|
|
||||||
version,
|
|
||||||
duration
|
|
||||||
);
|
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
return results.Success();
|
return results.Success();
|
||||||
@@ -151,84 +140,66 @@ bool Database::CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version
|
|||||||
|
|
||||||
bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
||||||
{
|
{
|
||||||
uint32 max_reserved_instance_id = RuleI(Instances, ReservedInstances);
|
uint32 count = RuleI(Zone, ReservedInstances);
|
||||||
uint32 max = 32000;
|
uint32 max = 65535;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
std::string query = StringFormat("SELECT IFNULL(MAX(id),%u)+1 FROM instance_list WHERE id > %u", count, count);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success())
|
||||||
|
{
|
||||||
instance_id = 0;
|
instance_id = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.RowCount() == 0) {
|
if (results.RowCount() == 0)
|
||||||
instance_id = max_reserved_instance_id;
|
{
|
||||||
return true;
|
instance_id = 0;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
|
|
||||||
if (atoi(row[0]) <= max) {
|
if (atoi(row[0]) <= max)
|
||||||
|
{
|
||||||
instance_id = atoi(row[0]);
|
instance_id = atoi(row[0]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance_id < max_reserved_instance_id) {
|
query = StringFormat("SELECT id FROM instance_list where id > %u ORDER BY id", count);
|
||||||
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);
|
results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success())
|
||||||
|
{
|
||||||
instance_id = 0;
|
instance_id = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.RowCount() == 0) {
|
if (results.RowCount() == 0)
|
||||||
|
{
|
||||||
instance_id = 0;
|
instance_id = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
max_reserved_instance_id++;
|
count++;
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row)
|
||||||
if (max_reserved_instance_id < atoi(row[0])) {
|
{
|
||||||
instance_id = max_reserved_instance_id;
|
if (count < atoi(row[0]))
|
||||||
|
{
|
||||||
|
instance_id = count;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_reserved_instance_id > max) {
|
if (count > max)
|
||||||
|
{
|
||||||
instance_id = 0;
|
instance_id = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
max_reserved_instance_id++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance_id = max_reserved_instance_id;
|
instance_id = count;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,36 +548,17 @@ void Database::GetCharactersInInstance(uint16 instance_id, std::list<uint32> &ch
|
|||||||
|
|
||||||
void Database::PurgeExpiredInstances()
|
void Database::PurgeExpiredInstances()
|
||||||
{
|
{
|
||||||
|
std::string query("SELECT id FROM instance_list where (start_time+duration) <= UNIX_TIMESTAMP() and never_expires = 0");
|
||||||
/**
|
|
||||||
* 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);
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (results.RowCount() == 0) {
|
if (results.RowCount() == 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row)
|
||||||
DeleteInstance(atoi(row[0]));
|
DeleteInstance(atoi(row[0]));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::SetInstanceDuration(uint16 instance_id, uint32 new_duration)
|
void Database::SetInstanceDuration(uint16 instance_id, uint32 new_duration)
|
||||||
|
|||||||
@@ -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
|
|
||||||
+56
-104
@@ -1,10 +1,9 @@
|
|||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "misc_functions.h"
|
#include "../common/misc_functions.h"
|
||||||
#include "eqemu_logsys.h"
|
#include "../common/eqemu_logsys.h"
|
||||||
#include "timer.h"
|
|
||||||
|
|
||||||
#include "dbcore.h"
|
#include "dbcore.h"
|
||||||
|
|
||||||
@@ -14,26 +13,23 @@
|
|||||||
#include <mysqld_error.h>
|
#include <mysqld_error.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#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;
|
||||||
@@ -44,8 +40,7 @@ DBcore::DBcore()
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,96 +102,63 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo
|
|||||||
|
|
||||||
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);
|
return MySQLRequestResult(nullptr, 0, 0, 0, 0, (uint32)mysql_errno(&mysql), errorBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
auto 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));
|
||||||
|
|
||||||
/**
|
/* Implement Logging at the Root */
|
||||||
* Error logging
|
if (mysql_errno(&mysql) > 0 && strlen(query) > 0){
|
||||||
*/
|
if (LogSys.log_settings[Logs::MySQLError].is_category_enabled == 1)
|
||||||
if (mysql_errno(&mysql) > 0 && strlen(query) > 0) {
|
Log(Logs::General, Logs::MySQLError, "%i: %s \n %s", mysql_errno(&mysql), mysql_error(&mysql), query);
|
||||||
LogMySQLError("[{}] [{}]\n[{}]", mysql_errno(&mysql), mysql_error(&mysql), query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return MySQLRequestResult(nullptr, 0, 0, 0, 0, mysql_errno(&mysql), errorBuffer);
|
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(
|
MySQLRequestResult requestResult(res, (uint32)mysql_affected_rows(&mysql), rowCount, (uint32)mysql_field_count(&mysql), (uint32)mysql_insert_id(&mysql));
|
||||||
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 (LogSys.log_settings[Logs::MySQLQuery].is_category_enabled == 1)
|
||||||
|
{
|
||||||
if ((strncasecmp(query, "select", 6) == 0)) {
|
if ((strncasecmp(query, "select", 6) == 0)) {
|
||||||
LogMySQLQuery(
|
Log(Logs::General, Logs::MySQLQuery, "%s (%u row%s returned)", query, requestResult.RowCount(), requestResult.RowCount() == 1 ? "" : "s");
|
||||||
"{0} ({1} row{2} returned) ({3}s)",
|
|
||||||
query,
|
|
||||||
requestResult.RowCount(),
|
|
||||||
requestResult.RowCount() == 1 ? "" : "s",
|
|
||||||
std::to_string(timer.elapsed())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogMySQLQuery(
|
Log(Logs::General, Logs::MySQLQuery, "%s (%u row%s affected)", query, requestResult.RowsAffected(), requestResult.RowsAffected() == 1 ? "" : "s");
|
||||||
"{0} ({1} row{2} affected) ({3}s)",
|
|
||||||
query,
|
|
||||||
requestResult.RowsAffected(),
|
|
||||||
requestResult.RowsAffected() == 1 ? "" : "s",
|
|
||||||
std::to_string(timer.elapsed())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestResult;
|
return requestResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBcore::TransactionBegin()
|
void DBcore::TransactionBegin() {
|
||||||
{
|
|
||||||
QueryDatabase("START TRANSACTION");
|
QueryDatabase("START TRANSACTION");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBcore::TransactionCommit()
|
void DBcore::TransactionCommit() {
|
||||||
{
|
|
||||||
QueryDatabase("COMMIT");
|
QueryDatabase("COMMIT");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBcore::TransactionRollback()
|
void DBcore::TransactionRollback() {
|
||||||
{
|
|
||||||
QueryDatabase("ROLLBACK");
|
QueryDatabase("ROLLBACK");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 DBcore::DoEscapeString(char *tobuf, const char *frombuf, uint32 fromlen)
|
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);
|
||||||
@@ -214,45 +174,37 @@ bool DBcore::Open(
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#ifndef DBCORE_H
|
#ifndef DBCORE_H
|
||||||
#define DBCORE_H
|
#define DBCORE_H
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -317,15 +317,6 @@ namespace EQEmu
|
|||||||
QuestControlGrid = -1
|
QuestControlGrid = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace consent {
|
|
||||||
enum eConsentType : uint8 {
|
|
||||||
Normal = 0,
|
|
||||||
Group,
|
|
||||||
Raid,
|
|
||||||
Guild
|
|
||||||
};
|
|
||||||
}; // namespace consent
|
|
||||||
|
|
||||||
} /*EQEmu*/
|
} /*EQEmu*/
|
||||||
|
|
||||||
#endif /*COMMON_EMU_CONSTANTS_H*/
|
#endif /*COMMON_EMU_CONSTANTS_H*/
|
||||||
|
|||||||
@@ -459,9 +459,4 @@ enum ChatChannelNames : uint16
|
|||||||
ChatChannel_Emotes = 22
|
ChatChannel_Emotes = 22
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ZoneBlockedSpellTypes {
|
|
||||||
const uint8 ZoneWide = 1;
|
|
||||||
const uint8 Region = 2;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /*COMMON_EQ_CONSTANTS_H*/
|
#endif /*COMMON_EQ_CONSTANTS_H*/
|
||||||
|
|||||||
+37
-43
@@ -35,8 +35,6 @@ static const uint32 MAX_MERC = 100;
|
|||||||
static const uint32 MAX_MERC_GRADES = 10;
|
static const uint32 MAX_MERC_GRADES = 10;
|
||||||
static const uint32 MAX_MERC_STANCES = 10;
|
static const uint32 MAX_MERC_STANCES = 10;
|
||||||
static const uint32 BLOCKED_BUFF_COUNT = 20;
|
static const uint32 BLOCKED_BUFF_COUNT = 20;
|
||||||
static const uint32 QUESTREWARD_COUNT = 8;
|
|
||||||
static const uint32 ADVANCED_LORE_LENGTH = 8192;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1361,23 +1359,20 @@ struct BecomeCorpse_Struct {
|
|||||||
struct PlayerPositionUpdateServer_Struct
|
struct PlayerPositionUpdateServer_Struct
|
||||||
{
|
{
|
||||||
/*0000*/ uint16 spawn_id;
|
/*0000*/ uint16 spawn_id;
|
||||||
/*0002*/ uint16 vehicle_id;
|
/*0002*/ int32 delta_heading:10, // change in heading
|
||||||
/*0004*/ signed padding0004 : 12;
|
x_pos:19, // x coord
|
||||||
signed y_pos : 19; // y coord
|
padding0002:3; // ***Placeholder
|
||||||
unsigned padding : 1;
|
/*0006*/ int32 y_pos:19, // y coord
|
||||||
/*0008*/ signed delta_z : 13; // change in z
|
animation:10, // animation
|
||||||
signed delta_x : 13; // change in x
|
padding0006:3; // ***Placeholder
|
||||||
signed padding0008 : 6;
|
/*0010*/ int32 z_pos:19, // z coord
|
||||||
/*0012*/ signed x_pos : 19; // x coord
|
delta_y:13; // change in y
|
||||||
unsigned heading : 12; // heading
|
/*0014*/ int32 delta_x:13, // change in x
|
||||||
signed padding0016 : 1;
|
heading:12, // heading
|
||||||
/*0016*/ signed delta_heading : 10; // change in heading
|
padding0014:7; // ***Placeholder
|
||||||
signed z_pos : 19; // z coord
|
/*0018*/ int32 delta_z:13, // change in z
|
||||||
signed padding0020 : 3;
|
padding0018:19; // ***Placeholder
|
||||||
/*0020*/ signed animation : 10; // animation
|
/*0022*/
|
||||||
signed delta_y : 13; // change in y
|
|
||||||
signed padding0024 : 9;
|
|
||||||
/*0024*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1388,23 +1383,21 @@ struct PlayerPositionUpdateServer_Struct
|
|||||||
*/
|
*/
|
||||||
struct PlayerPositionUpdateClient_Struct
|
struct PlayerPositionUpdateClient_Struct
|
||||||
{
|
{
|
||||||
/*0000*/ uint16 sequence; // increments one each packet - Verified
|
/*0000*/ uint16 spawn_id;
|
||||||
/*0002*/ uint16 spawn_id; // Player's spawn id
|
/*0002*/ uint16 sequence; //increments one each packet
|
||||||
/*0004*/ uint16 vehicle_id; // Player's vehicle spawn id
|
/*0004*/ float y_pos; // y coord
|
||||||
/*0006*/ uint8 unknown0004[4]; // ***Placeholder
|
/*0008*/ float delta_z; // Change in z
|
||||||
/*0010*/ float delta_x; // Change in x
|
/*0012*/ float delta_x; // Change in x
|
||||||
/*0014*/ unsigned heading : 12; // Directional heading
|
/*0016*/ float delta_y; // Change in y
|
||||||
unsigned padding0040 : 20; // ***Placeholder
|
/*0020*/ int32 animation:10, // animation
|
||||||
/*0018*/ float x_pos; // x coord (2nd loc value)
|
delta_heading:10, // change in heading
|
||||||
/*0022*/ float delta_z; // Change in z
|
padding0020:12; // ***Placeholder (mostly 1)
|
||||||
/*0026*/ float z_pos; // z coord (3rd loc value)
|
/*0024*/ float x_pos; // x coord
|
||||||
/*0030*/ float y_pos; // y coord (1st loc value)
|
/*0028*/ float z_pos; // z coord
|
||||||
/*0034*/ unsigned animation : 10; // ***Placeholder
|
/*0032*/ uint16 heading:12, // Directional heading
|
||||||
unsigned padding0024 : 22; // animation
|
padding0004:4; // ***Placeholder
|
||||||
/*0038*/ float delta_y; // Change in y
|
/*0034*/ uint8 unknown0006[2]; // ***Placeholder
|
||||||
/*0042*/ signed delta_heading : 10; // change in heading
|
/*0036*/
|
||||||
unsigned padding0041 : 22; // ***Placeholder
|
|
||||||
/*0046*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SpawnPositionUpdate_Struct
|
struct SpawnPositionUpdate_Struct
|
||||||
@@ -2182,7 +2175,14 @@ struct QuestReward_Struct
|
|||||||
/*024*/ uint32 silver; // Gives silver to the client
|
/*024*/ uint32 silver; // Gives silver to the client
|
||||||
/*028*/ uint32 gold; // Gives gold to the client
|
/*028*/ uint32 gold; // Gives gold to the client
|
||||||
/*032*/ uint32 platinum; // Gives platinum to the client
|
/*032*/ uint32 platinum; // Gives platinum to the client
|
||||||
/*036*/ int32 item_id[QUESTREWARD_COUNT]; // -1 for nothing
|
/*036*/ uint32 item_id;
|
||||||
|
/*040*/ uint32 unknown040;
|
||||||
|
/*044*/ uint32 unknown044;
|
||||||
|
/*048*/ uint32 unknown048;
|
||||||
|
/*052*/ uint32 unknown052;
|
||||||
|
/*056*/ uint32 unknown056;
|
||||||
|
/*060*/ uint32 unknown060;
|
||||||
|
/*064*/ uint32 unknown064;
|
||||||
/*068*/
|
/*068*/
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2967,12 +2967,6 @@ struct ItemViewRequest_Struct {
|
|||||||
/*046*/ char unknown046[2];
|
/*046*/ char unknown046[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ItemAdvancedLoreText_Struct {
|
|
||||||
int32 item_id;
|
|
||||||
char item_name[64];
|
|
||||||
char advanced_lore[ADVANCED_LORE_LENGTH];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LDONItemViewRequest_Struct {
|
struct LDONItemViewRequest_Struct {
|
||||||
uint32 item_id;
|
uint32 item_id;
|
||||||
uint8 unknown004[4];
|
uint8 unknown004[4];
|
||||||
|
|||||||
+104
-104
@@ -84,14 +84,14 @@ void EQStream::init(bool resetSession) {
|
|||||||
|
|
||||||
OpMgr = nullptr;
|
OpMgr = nullptr;
|
||||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||||
LogNetcode(_L "init Invalid Sequenced queue: BS [{}] + SQ [{}] != NOS [{}]" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
Log(Logs::Detail, Logs::Netcode, _L "init Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
|
EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
|
||||||
{
|
{
|
||||||
EQRawApplicationPacket *ap=nullptr;
|
EQRawApplicationPacket *ap=nullptr;
|
||||||
LogNetcode(_L "Creating new application packet, length [{}]" __L, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, p->size);
|
||||||
// _raw(NET__APP_CREATE_HEX, 0xFFFF, p);
|
// _raw(NET__APP_CREATE_HEX, 0xFFFF, p);
|
||||||
ap = p->MakeAppPacket();
|
ap = p->MakeAppPacket();
|
||||||
return ap;
|
return ap;
|
||||||
@@ -100,7 +100,7 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
|
|||||||
EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len)
|
EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len)
|
||||||
{
|
{
|
||||||
EQRawApplicationPacket *ap=nullptr;
|
EQRawApplicationPacket *ap=nullptr;
|
||||||
LogNetcode(_L "Creating new application packet, length [{}]" __L, len);
|
Log(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, len);
|
||||||
ap = new EQRawApplicationPacket(buf, len);
|
ap = new EQRawApplicationPacket(buf, len);
|
||||||
return ap;
|
return ap;
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Session && p->opcode!=OP_SessionRequest && p->opcode!=OP_SessionResponse) {
|
if (!Session && p->opcode!=OP_SessionRequest && p->opcode!=OP_SessionResponse) {
|
||||||
LogNetcode(_L "Session not initialized, packet ignored" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Session not initialized, packet ignored" __L);
|
||||||
// _raw(NET__DEBUG, 0xFFFF, p);
|
// _raw(NET__DEBUG, 0xFFFF, p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
while(processed < p->size) {
|
while(processed < p->size) {
|
||||||
subpacket_length=*(p->pBuffer+processed);
|
subpacket_length=*(p->pBuffer+processed);
|
||||||
EQProtocolPacket *subp=MakeProtocolPacket(p->pBuffer+processed+1,subpacket_length);
|
EQProtocolPacket *subp=MakeProtocolPacket(p->pBuffer+processed+1,subpacket_length);
|
||||||
LogNetcode(_L "Extracting combined packet of length [{}]" __L, subpacket_length);
|
Log(Logs::Detail, Logs::Netcode, _L "Extracting combined packet of length %d" __L, subpacket_length);
|
||||||
// _raw(NET__NET_CREATE_HEX, 0xFFFF, subp);
|
// _raw(NET__NET_CREATE_HEX, 0xFFFF, subp);
|
||||||
subp->copyInfo(p);
|
subp->copyInfo(p);
|
||||||
ProcessPacket(subp);
|
ProcessPacket(subp);
|
||||||
@@ -156,12 +156,12 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
while(processed<p->size) {
|
while(processed<p->size) {
|
||||||
EQRawApplicationPacket *ap=nullptr;
|
EQRawApplicationPacket *ap=nullptr;
|
||||||
if ((subpacket_length=(unsigned char)*(p->pBuffer+processed))!=0xff) {
|
if ((subpacket_length=(unsigned char)*(p->pBuffer+processed))!=0xff) {
|
||||||
LogNetcode(_L "Extracting combined app packet of length [{}], short len" __L, subpacket_length);
|
Log(Logs::Detail, Logs::Netcode, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length);
|
||||||
ap=MakeApplicationPacket(p->pBuffer+processed+1,subpacket_length);
|
ap=MakeApplicationPacket(p->pBuffer+processed+1,subpacket_length);
|
||||||
processed+=subpacket_length+1;
|
processed+=subpacket_length+1;
|
||||||
} else {
|
} else {
|
||||||
subpacket_length=ntohs(*(uint16 *)(p->pBuffer+processed+1));
|
subpacket_length=ntohs(*(uint16 *)(p->pBuffer+processed+1));
|
||||||
LogNetcode(_L "Extracting combined app packet of length [{}], short len" __L, subpacket_length);
|
Log(Logs::Detail, Logs::Netcode, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length);
|
||||||
ap=MakeApplicationPacket(p->pBuffer+processed+3,subpacket_length);
|
ap=MakeApplicationPacket(p->pBuffer+processed+3,subpacket_length);
|
||||||
processed+=subpacket_length+3;
|
processed+=subpacket_length+3;
|
||||||
}
|
}
|
||||||
@@ -176,29 +176,29 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
case OP_Packet: {
|
case OP_Packet: {
|
||||||
if(!p->pBuffer || (p->Size() < 4))
|
if(!p->pBuffer || (p->Size() < 4))
|
||||||
{
|
{
|
||||||
LogNetcode(_L "Received OP_Packet that was of malformed size" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_Packet that was of malformed size" __L);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
|
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
|
||||||
SeqOrder check=CompareSequence(NextInSeq,seq);
|
SeqOrder check=CompareSequence(NextInSeq,seq);
|
||||||
if (check == SeqFuture) {
|
if (check == SeqFuture) {
|
||||||
LogNetcode(_L "Future OP_Packet: Expecting Seq=[{}], but got Seq=[{}]" __L, NextInSeq, seq);
|
Log(Logs::Detail, Logs::Netcode, _L "Future OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
|
||||||
// _raw(NET__DEBUG, seq, p);
|
// _raw(NET__DEBUG, seq, p);
|
||||||
|
|
||||||
PacketQueue[seq]=p->Copy();
|
PacketQueue[seq]=p->Copy();
|
||||||
LogNetcode(_L "OP_Packet Queue size=[{}]" __L, PacketQueue.size());
|
Log(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size());
|
||||||
|
|
||||||
//SendOutOfOrderAck(seq);
|
//SendOutOfOrderAck(seq);
|
||||||
|
|
||||||
} else if (check == SeqPast) {
|
} else if (check == SeqPast) {
|
||||||
LogNetcode(_L "Duplicate OP_Packet: Expecting Seq=[{}], but got Seq=[{}]" __L, NextInSeq, seq);
|
Log(Logs::Detail, Logs::Netcode, _L "Duplicate OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
|
||||||
// _raw(NET__DEBUG, seq, p);
|
// _raw(NET__DEBUG, seq, p);
|
||||||
SendOutOfOrderAck(seq); //we already got this packet but it was out of order
|
SendOutOfOrderAck(seq); //we already got this packet but it was out of order
|
||||||
} else {
|
} else {
|
||||||
// In case we did queue one before as well.
|
// In case we did queue one before as well.
|
||||||
EQProtocolPacket *qp=RemoveQueue(seq);
|
EQProtocolPacket *qp=RemoveQueue(seq);
|
||||||
if (qp) {
|
if (qp) {
|
||||||
LogNetcode("[NET_TRACE] OP_Packet: Removing older queued packet with sequence [{}]", seq);
|
Log(Logs::General, Logs::Netcode, "[NET_TRACE] OP_Packet: Removing older queued packet with sequence %d", seq);
|
||||||
delete qp;
|
delete qp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
// Check for an embedded OP_AppCombinded (protocol level 0x19)
|
// Check for an embedded OP_AppCombinded (protocol level 0x19)
|
||||||
if (*(p->pBuffer+2)==0x00 && *(p->pBuffer+3)==0x19) {
|
if (*(p->pBuffer+2)==0x00 && *(p->pBuffer+3)==0x19) {
|
||||||
EQProtocolPacket *subp=MakeProtocolPacket(p->pBuffer+2,p->size-2);
|
EQProtocolPacket *subp=MakeProtocolPacket(p->pBuffer+2,p->size-2);
|
||||||
LogNetcode(_L "seq [{}], Extracting combined packet of length [{}]" __L, seq, subp->size);
|
Log(Logs::Detail, Logs::Netcode, _L "seq %d, Extracting combined packet of length %d" __L, seq, subp->size);
|
||||||
// _raw(NET__NET_CREATE_HEX, seq, subp);
|
// _raw(NET__NET_CREATE_HEX, seq, subp);
|
||||||
subp->copyInfo(p);
|
subp->copyInfo(p);
|
||||||
ProcessPacket(subp);
|
ProcessPacket(subp);
|
||||||
@@ -226,29 +226,29 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
case OP_Fragment: {
|
case OP_Fragment: {
|
||||||
if(!p->pBuffer || (p->Size() < 4))
|
if(!p->pBuffer || (p->Size() < 4))
|
||||||
{
|
{
|
||||||
LogNetcode(_L "Received OP_Fragment that was of malformed size" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_Fragment that was of malformed size" __L);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
|
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
|
||||||
SeqOrder check=CompareSequence(NextInSeq,seq);
|
SeqOrder check=CompareSequence(NextInSeq,seq);
|
||||||
if (check == SeqFuture) {
|
if (check == SeqFuture) {
|
||||||
LogNetcode(_L "Future OP_Fragment: Expecting Seq=[{}], but got Seq=[{}]" __L, NextInSeq, seq);
|
Log(Logs::Detail, Logs::Netcode, _L "Future OP_Fragment: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
|
||||||
// _raw(NET__DEBUG, seq, p);
|
// _raw(NET__DEBUG, seq, p);
|
||||||
|
|
||||||
PacketQueue[seq]=p->Copy();
|
PacketQueue[seq]=p->Copy();
|
||||||
LogNetcode(_L "OP_Fragment Queue size=[{}]" __L, PacketQueue.size());
|
Log(Logs::Detail, Logs::Netcode, _L "OP_Fragment Queue size=%d" __L, PacketQueue.size());
|
||||||
|
|
||||||
//SendOutOfOrderAck(seq);
|
//SendOutOfOrderAck(seq);
|
||||||
|
|
||||||
} else if (check == SeqPast) {
|
} else if (check == SeqPast) {
|
||||||
LogNetcode(_L "Duplicate OP_Fragment: Expecting Seq=[{}], but got Seq=[{}]" __L, NextInSeq, seq);
|
Log(Logs::Detail, Logs::Netcode, _L "Duplicate OP_Fragment: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
|
||||||
// _raw(NET__DEBUG, seq, p);
|
// _raw(NET__DEBUG, seq, p);
|
||||||
SendOutOfOrderAck(seq);
|
SendOutOfOrderAck(seq);
|
||||||
} else {
|
} else {
|
||||||
// In case we did queue one before as well.
|
// In case we did queue one before as well.
|
||||||
EQProtocolPacket *qp=RemoveQueue(seq);
|
EQProtocolPacket *qp=RemoveQueue(seq);
|
||||||
if (qp) {
|
if (qp) {
|
||||||
LogNetcode("[NET_TRACE] OP_Fragment: Removing older queued packet with sequence [{}]", seq);
|
Log(Logs::General, Logs::Netcode, "[NET_TRACE] OP_Fragment: Removing older queued packet with sequence %d", seq);
|
||||||
delete qp;
|
delete qp;
|
||||||
}
|
}
|
||||||
SetNextAckToSend(seq);
|
SetNextAckToSend(seq);
|
||||||
@@ -256,18 +256,18 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
if (oversize_buffer) {
|
if (oversize_buffer) {
|
||||||
memcpy(oversize_buffer+oversize_offset,p->pBuffer+2,p->size-2);
|
memcpy(oversize_buffer+oversize_offset,p->pBuffer+2,p->size-2);
|
||||||
oversize_offset+=p->size-2;
|
oversize_offset+=p->size-2;
|
||||||
LogNetcode(_L "Fragment of oversized of length [{}], seq [{}]: now at [{}]/[{}]" __L, p->size-2, seq, oversize_offset, oversize_length);
|
Log(Logs::Detail, Logs::Netcode, _L "Fragment of oversized of length %d, seq %d: now at %d/%d" __L, p->size-2, seq, oversize_offset, oversize_length);
|
||||||
if (oversize_offset==oversize_length) {
|
if (oversize_offset==oversize_length) {
|
||||||
if (*(p->pBuffer+2)==0x00 && *(p->pBuffer+3)==0x19) {
|
if (*(p->pBuffer+2)==0x00 && *(p->pBuffer+3)==0x19) {
|
||||||
EQProtocolPacket *subp=MakeProtocolPacket(oversize_buffer,oversize_offset);
|
EQProtocolPacket *subp=MakeProtocolPacket(oversize_buffer,oversize_offset);
|
||||||
LogNetcode(_L "seq [{}], Extracting combined oversize packet of length [{}]" __L, seq, subp->size);
|
Log(Logs::Detail, Logs::Netcode, _L "seq %d, Extracting combined oversize packet of length %d" __L, seq, subp->size);
|
||||||
//// _raw(NET__NET_CREATE_HEX, subp);
|
//// _raw(NET__NET_CREATE_HEX, subp);
|
||||||
subp->copyInfo(p);
|
subp->copyInfo(p);
|
||||||
ProcessPacket(subp);
|
ProcessPacket(subp);
|
||||||
delete subp;
|
delete subp;
|
||||||
} else {
|
} else {
|
||||||
EQRawApplicationPacket *ap=MakeApplicationPacket(oversize_buffer,oversize_offset);
|
EQRawApplicationPacket *ap=MakeApplicationPacket(oversize_buffer,oversize_offset);
|
||||||
LogNetcode(_L "seq [{}], completed combined oversize packet of length [{}]" __L, seq, ap->size);
|
Log(Logs::Detail, Logs::Netcode, _L "seq %d, completed combined oversize packet of length %d" __L, seq, ap->size);
|
||||||
if (ap) {
|
if (ap) {
|
||||||
ap->copyInfo(p);
|
ap->copyInfo(p);
|
||||||
InboundQueuePush(ap);
|
InboundQueuePush(ap);
|
||||||
@@ -282,20 +282,20 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
oversize_buffer=new unsigned char[oversize_length];
|
oversize_buffer=new unsigned char[oversize_length];
|
||||||
memcpy(oversize_buffer,p->pBuffer+6,p->size-6);
|
memcpy(oversize_buffer,p->pBuffer+6,p->size-6);
|
||||||
oversize_offset=p->size-6;
|
oversize_offset=p->size-6;
|
||||||
LogNetcode(_L "First fragment of oversized of seq [{}]: now at [{}]/[{}]" __L, seq, oversize_offset, oversize_length);
|
Log(Logs::Detail, Logs::Netcode, _L "First fragment of oversized of seq %d: now at %d/%d" __L, seq, oversize_offset, oversize_length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_KeepAlive: {
|
case OP_KeepAlive: {
|
||||||
NonSequencedPush(new EQProtocolPacket(p->opcode,p->pBuffer,p->size));
|
NonSequencedPush(new EQProtocolPacket(p->opcode,p->pBuffer,p->size));
|
||||||
LogNetcode(_L "Received and queued reply to keep alive" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received and queued reply to keep alive" __L);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_Ack: {
|
case OP_Ack: {
|
||||||
if(!p->pBuffer || (p->Size() < 4))
|
if(!p->pBuffer || (p->Size() < 4))
|
||||||
{
|
{
|
||||||
LogNetcode(_L "Received OP_Ack that was of malformed size" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_Ack that was of malformed size" __L);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
|
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
|
||||||
@@ -309,11 +309,11 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
case OP_SessionRequest: {
|
case OP_SessionRequest: {
|
||||||
if(p->Size() < sizeof(SessionRequest))
|
if(p->Size() < sizeof(SessionRequest))
|
||||||
{
|
{
|
||||||
LogNetcode(_L "Received OP_SessionRequest that was of malformed size" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest that was of malformed size" __L);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (GetState()==ESTABLISHED) {
|
if (GetState()==ESTABLISHED) {
|
||||||
LogNetcode(_L "Received OP_SessionRequest in ESTABLISHED state ([{}]) streamactive ([{}]) attempt ([{}])" __L, GetState(),streamactive,sessionAttempts);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest in ESTABLISHED state (%d) streamactive (%i) attempt (%i)" __L, GetState(),streamactive,sessionAttempts);
|
||||||
|
|
||||||
// client seems to try a max of 30 times (initial+3 retries) then gives up, giving it a few more attempts just in case
|
// client seems to try a max of 30 times (initial+3 retries) then gives up, giving it a few more attempts just in case
|
||||||
// streamactive means we identified the opcode for the stream, we cannot re-establish this connection
|
// streamactive means we identified the opcode for the stream, we cannot re-establish this connection
|
||||||
@@ -331,7 +331,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
SessionRequest *Request=(SessionRequest *)p->pBuffer;
|
SessionRequest *Request=(SessionRequest *)p->pBuffer;
|
||||||
Session=ntohl(Request->Session);
|
Session=ntohl(Request->Session);
|
||||||
SetMaxLen(ntohl(Request->MaxLength));
|
SetMaxLen(ntohl(Request->MaxLength));
|
||||||
LogNetcode(_L "Received OP_SessionRequest: session [{}], maxlen [{}]" __L, (unsigned long)Session, MaxLen);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest: session %lu, maxlen %d" __L, (unsigned long)Session, MaxLen);
|
||||||
SetState(ESTABLISHED);
|
SetState(ESTABLISHED);
|
||||||
Key=0x11223344;
|
Key=0x11223344;
|
||||||
SendSessionResponse();
|
SendSessionResponse();
|
||||||
@@ -340,7 +340,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
case OP_SessionResponse: {
|
case OP_SessionResponse: {
|
||||||
if(p->Size() < sizeof(SessionResponse))
|
if(p->Size() < sizeof(SessionResponse))
|
||||||
{
|
{
|
||||||
LogNetcode(_L "Received OP_SessionResponse that was of malformed size" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionResponse that was of malformed size" __L);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
compressed=(Response->Format&FLAG_COMPRESSED);
|
compressed=(Response->Format&FLAG_COMPRESSED);
|
||||||
encoded=(Response->Format&FLAG_ENCODED);
|
encoded=(Response->Format&FLAG_ENCODED);
|
||||||
|
|
||||||
LogNetcode(_L "Received OP_SessionResponse: session [{}], maxlen [{}], key [{}], compressed? [{}], encoded? [{}]" __L, (unsigned long)Session, MaxLen, (unsigned long)Key, compressed?"yes":"no", encoded?"yes":"no");
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionResponse: session %lu, maxlen %d, key %lu, compressed? %s, encoded? %s" __L, (unsigned long)Session, MaxLen, (unsigned long)Key, compressed?"yes":"no", encoded?"yes":"no");
|
||||||
|
|
||||||
// Kinda kludgy, but trie for now
|
// Kinda kludgy, but trie for now
|
||||||
if (StreamType==UnknownStream) {
|
if (StreamType==UnknownStream) {
|
||||||
@@ -379,17 +379,17 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
EQStreamState state = GetState();
|
EQStreamState state = GetState();
|
||||||
if(state == ESTABLISHED) {
|
if(state == ESTABLISHED) {
|
||||||
//client initiated disconnect?
|
//client initiated disconnect?
|
||||||
LogNetcode(_L "Received unsolicited OP_SessionDisconnect. Treating like a client-initiated disconnect" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received unsolicited OP_SessionDisconnect. Treating like a client-initiated disconnect." __L);
|
||||||
_SendDisconnect();
|
_SendDisconnect();
|
||||||
SetState(CLOSED);
|
SetState(CLOSED);
|
||||||
} else if(state == CLOSING) {
|
} else if(state == CLOSING) {
|
||||||
//we were waiting for this anyways, ignore pending messages, send the reply and be closed.
|
//we were waiting for this anyways, ignore pending messages, send the reply and be closed.
|
||||||
LogNetcode(_L "Received OP_SessionDisconnect when we have a pending close, they beat us to it. Were happy though" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionDisconnect when we have a pending close, they beat us to it. Were happy though." __L);
|
||||||
_SendDisconnect();
|
_SendDisconnect();
|
||||||
SetState(CLOSED);
|
SetState(CLOSED);
|
||||||
} else {
|
} else {
|
||||||
//we are expecting this (or have already gotten it, but dont care either way)
|
//we are expecting this (or have already gotten it, but dont care either way)
|
||||||
LogNetcode(_L "Received expected OP_SessionDisconnect. Moving to closed state" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received expected OP_SessionDisconnect. Moving to closed state." __L);
|
||||||
SetState(CLOSED);
|
SetState(CLOSED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,14 +397,14 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
case OP_OutOfOrderAck: {
|
case OP_OutOfOrderAck: {
|
||||||
if(!p->pBuffer || (p->Size() < 4))
|
if(!p->pBuffer || (p->Size() < 4))
|
||||||
{
|
{
|
||||||
LogNetcode(_L "Received OP_OutOfOrderAck that was of malformed size" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck that was of malformed size" __L);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
|
uint16 seq=ntohs(*(uint16 *)(p->pBuffer));
|
||||||
MOutboundQueue.lock();
|
MOutboundQueue.lock();
|
||||||
|
|
||||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||||
LogNetcode(_L "Pre-OOA Invalid Sequenced queue: BS [{}] + SQ [{}] != NOS [{}]" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
Log(Logs::Detail, Logs::Netcode, _L "Pre-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the packet they got out of order is between our last acked packet and the last sent packet, then its valid.
|
//if the packet they got out of order is between our last acked packet and the last sent packet, then its valid.
|
||||||
@@ -414,7 +414,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
|
|
||||||
uint16 sqsize = SequencedQueue.size();
|
uint16 sqsize = SequencedQueue.size();
|
||||||
uint16 index = seq - SequencedBase;
|
uint16 index = seq - SequencedBase;
|
||||||
LogNetcode(_L "OP_OutOfOrderAck marking packet acked in queue (queue index = [{}], queue size = [{}])" __L, index, sqsize);
|
Log(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
|
||||||
if (index < sqsize) {
|
if (index < sqsize) {
|
||||||
SequencedQueue[index]->acked = true;
|
SequencedQueue[index]->acked = true;
|
||||||
// flag packets for a resend
|
// flag packets for a resend
|
||||||
@@ -423,7 +423,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
for (auto sitr = SequencedQueue.begin(); sitr != SequencedQueue.end() && count < index; ++sitr, ++count) {
|
for (auto sitr = SequencedQueue.begin(); sitr != SequencedQueue.end() && count < index; ++sitr, ++count) {
|
||||||
if (!(*sitr)->acked && (*sitr)->sent_time > 0 && (((*sitr)->sent_time + timeout) < Timer::GetCurrentTime())) {
|
if (!(*sitr)->acked && (*sitr)->sent_time > 0 && (((*sitr)->sent_time + timeout) < Timer::GetCurrentTime())) {
|
||||||
(*sitr)->sent_time = 0;
|
(*sitr)->sent_time = 0;
|
||||||
LogNetcode(_L "OP_OutOfOrderAck Flagging packet [{}] for retransmission" __L, SequencedBase + count);
|
Log(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck Flagging packet %d for retransmission" __L, SequencedBase + count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,11 +432,11 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
retransmittimer = Timer::GetCurrentTime();
|
retransmittimer = Timer::GetCurrentTime();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogNetcode(_L "Received OP_OutOfOrderAck for out-of-window [{}]. Window ([{}]->[{}])" __L, seq, SequencedBase, NextOutSeq);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck for out-of-window %d. Window (%d->%d)." __L, seq, SequencedBase, NextOutSeq);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||||
LogNetcode(_L "Post-OOA Invalid Sequenced queue: BS [{}] + SQ [{}] != NOS [{}]" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
Log(Logs::Detail, Logs::Netcode, _L "Post-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOutboundQueue.unlock();
|
MOutboundQueue.unlock();
|
||||||
@@ -445,7 +445,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
case OP_SessionStatRequest: {
|
case OP_SessionStatRequest: {
|
||||||
if(p->Size() < sizeof(ClientSessionStats))
|
if(p->Size() < sizeof(ClientSessionStats))
|
||||||
{
|
{
|
||||||
LogNetcode(_L "Received OP_SessionStatRequest that was of malformed size" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionStatRequest that was of malformed size" __L);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ClientSessionStats *ClientStats=(ClientSessionStats *)p->pBuffer;
|
ClientSessionStats *ClientStats=(ClientSessionStats *)p->pBuffer;
|
||||||
@@ -468,7 +468,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
retransmittimeout += 300;
|
retransmittimeout += 300;
|
||||||
if(retransmittimeout > RETRANSMIT_TIMEOUT_MAX)
|
if(retransmittimeout > RETRANSMIT_TIMEOUT_MAX)
|
||||||
retransmittimeout = RETRANSMIT_TIMEOUT_MAX;
|
retransmittimeout = RETRANSMIT_TIMEOUT_MAX;
|
||||||
LogNetcode(_L "Retransmit timeout recalculated to [{}]ms" __L, retransmittimeout);
|
Log(Logs::Detail, Logs::Netcode, _L "Retransmit timeout recalculated to %dms" __L, retransmittimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,11 +485,11 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_SessionStatResponse: {
|
case OP_SessionStatResponse: {
|
||||||
LogNetcode(_L "Received OP_SessionStatResponse. Ignoring" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionStatResponse. Ignoring." __L);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_OutOfSession: {
|
case OP_OutOfSession: {
|
||||||
LogNetcode(_L "Received OP_OutOfSession. Ignoring" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfSession. Ignoring." __L);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -520,7 +520,7 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if(OpMgr == nullptr || *OpMgr == nullptr) {
|
if(OpMgr == nullptr || *OpMgr == nullptr) {
|
||||||
LogNetcode(_L "Packet enqueued into a stream with no opcode manager, dropping" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Packet enqueued into a stream with no opcode manager, dropping." __L);
|
||||||
delete pack;
|
delete pack;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -559,18 +559,18 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
|||||||
|
|
||||||
// Convert the EQApplicationPacket to 1 or more EQProtocolPackets
|
// Convert the EQApplicationPacket to 1 or more EQProtocolPackets
|
||||||
if (p->size>(MaxLen-8)) { // proto-op(2), seq(2), app-op(2) ... data ... crc(2)
|
if (p->size>(MaxLen-8)) { // proto-op(2), seq(2), app-op(2) ... data ... crc(2)
|
||||||
LogNetcode(_L "Making oversized packet, len [{}]" __L, p->Size());
|
Log(Logs::Detail, Logs::Netcode, _L "Making oversized packet, len %d" __L, p->Size());
|
||||||
|
|
||||||
auto tmpbuff = new unsigned char[p->size + 3];
|
auto tmpbuff = new unsigned char[p->size + 3];
|
||||||
length=p->serialize(opcode, tmpbuff);
|
length=p->serialize(opcode, tmpbuff);
|
||||||
if (length != p->Size())
|
if (length != p->Size())
|
||||||
LogNetcode(_L "Packet adjustment, len [{}] to [{}]" __L, p->Size(), length);
|
Log(Logs::Detail, Logs::Netcode, _L "Packet adjustment, len %d to %d" __L, p->Size(), length);
|
||||||
|
|
||||||
auto out = new EQProtocolPacket(OP_Fragment, nullptr, MaxLen - 4);
|
auto out = new EQProtocolPacket(OP_Fragment, nullptr, MaxLen - 4);
|
||||||
*(uint32 *)(out->pBuffer+2)=htonl(length);
|
*(uint32 *)(out->pBuffer+2)=htonl(length);
|
||||||
used=MaxLen-10;
|
used=MaxLen-10;
|
||||||
memcpy(out->pBuffer+6,tmpbuff,used);
|
memcpy(out->pBuffer+6,tmpbuff,used);
|
||||||
LogNetcode(_L "First fragment: used [{}]/[{}]. Payload size [{}] in the packet" __L, used, length, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "First fragment: used %d/%d. Payload size %d in the packet" __L, used, length, p->size);
|
||||||
SequencedPush(out);
|
SequencedPush(out);
|
||||||
|
|
||||||
|
|
||||||
@@ -581,7 +581,7 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
|||||||
out->size=chunksize+2;
|
out->size=chunksize+2;
|
||||||
SequencedPush(out);
|
SequencedPush(out);
|
||||||
used+=chunksize;
|
used+=chunksize;
|
||||||
LogNetcode(_L "Subsequent fragment: len [{}], used [{}]/[{}]" __L, chunksize, used, length);
|
Log(Logs::Detail, Logs::Netcode, _L "Subsequent fragment: len %d, used %d/%d." __L, chunksize, used, length);
|
||||||
}
|
}
|
||||||
delete p;
|
delete p;
|
||||||
delete[] tmpbuff;
|
delete[] tmpbuff;
|
||||||
@@ -623,7 +623,7 @@ void EQStream::SequencedPush(EQProtocolPacket *p)
|
|||||||
void EQStream::NonSequencedPush(EQProtocolPacket *p)
|
void EQStream::NonSequencedPush(EQProtocolPacket *p)
|
||||||
{
|
{
|
||||||
MOutboundQueue.lock();
|
MOutboundQueue.lock();
|
||||||
LogNetcode(_L "Pushing non-sequenced packet of length [{}]" __L, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Pushing non-sequenced packet of length %d" __L, p->size);
|
||||||
NonSequencedQueue.push(p);
|
NonSequencedQueue.push(p);
|
||||||
MOutboundQueue.unlock();
|
MOutboundQueue.unlock();
|
||||||
}
|
}
|
||||||
@@ -631,14 +631,14 @@ void EQStream::NonSequencedPush(EQProtocolPacket *p)
|
|||||||
void EQStream::SendAck(uint16 seq)
|
void EQStream::SendAck(uint16 seq)
|
||||||
{
|
{
|
||||||
uint16 Seq=htons(seq);
|
uint16 Seq=htons(seq);
|
||||||
LogNetcode(_L "Sending ack with sequence [{}]" __L, seq);
|
Log(Logs::Detail, Logs::Netcode, _L "Sending ack with sequence %d" __L, seq);
|
||||||
SetLastAckSent(seq);
|
SetLastAckSent(seq);
|
||||||
NonSequencedPush(new EQProtocolPacket(OP_Ack,(unsigned char *)&Seq,sizeof(uint16)));
|
NonSequencedPush(new EQProtocolPacket(OP_Ack,(unsigned char *)&Seq,sizeof(uint16)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQStream::SendOutOfOrderAck(uint16 seq)
|
void EQStream::SendOutOfOrderAck(uint16 seq)
|
||||||
{
|
{
|
||||||
LogNetcode(_L "Sending out of order ack with sequence [{}]" __L, seq);
|
Log(Logs::Detail, Logs::Netcode, _L "Sending out of order ack with sequence %d" __L, seq);
|
||||||
uint16 Seq=htons(seq);
|
uint16 Seq=htons(seq);
|
||||||
NonSequencedPush(new EQProtocolPacket(OP_OutOfOrderAck,(unsigned char *)&Seq,sizeof(uint16)));
|
NonSequencedPush(new EQProtocolPacket(OP_OutOfOrderAck,(unsigned char *)&Seq,sizeof(uint16)));
|
||||||
}
|
}
|
||||||
@@ -688,24 +688,24 @@ void EQStream::Write(int eq_fd)
|
|||||||
// If we don't have a packet to try to combine into, use this one as the base
|
// If we don't have a packet to try to combine into, use this one as the base
|
||||||
// And remove it form the queue
|
// And remove it form the queue
|
||||||
p = NonSequencedQueue.front();
|
p = NonSequencedQueue.front();
|
||||||
LogNetcode(_L "Starting combined packet with non-seq packet of len [{}]" __L, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Starting combined packet with non-seq packet of len %d" __L, p->size);
|
||||||
NonSequencedQueue.pop();
|
NonSequencedQueue.pop();
|
||||||
} else if (!p->combine(NonSequencedQueue.front())) {
|
} else if (!p->combine(NonSequencedQueue.front())) {
|
||||||
// Trying to combine this packet with the base didn't work (too big maybe)
|
// Trying to combine this packet with the base didn't work (too big maybe)
|
||||||
// So just send the base packet (we'll try this packet again later)
|
// So just send the base packet (we'll try this packet again later)
|
||||||
LogNetcode(_L "Combined packet full at len [{}], next non-seq packet is len [{}]" __L, p->size, (NonSequencedQueue.front())->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Combined packet full at len %d, next non-seq packet is len %d" __L, p->size, (NonSequencedQueue.front())->size);
|
||||||
ReadyToSend.push(p);
|
ReadyToSend.push(p);
|
||||||
BytesWritten+=p->size;
|
BytesWritten+=p->size;
|
||||||
p=nullptr;
|
p=nullptr;
|
||||||
|
|
||||||
if (BytesWritten > threshold) {
|
if (BytesWritten > threshold) {
|
||||||
// Sent enough this round, lets stop to be fair
|
// Sent enough this round, lets stop to be fair
|
||||||
LogNetcode(_L "Exceeded write threshold in nonseq ([{}] > [{}])" __L, BytesWritten, threshold);
|
Log(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in nonseq (%d > %d)" __L, BytesWritten, threshold);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Combine worked, so just remove this packet and it's spot in the queue
|
// Combine worked, so just remove this packet and it's spot in the queue
|
||||||
LogNetcode(_L "Combined non-seq packet of len [{}], yeilding [{}] combined" __L, (NonSequencedQueue.front())->size, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Combined non-seq packet of len %d, yeilding %d combined." __L, (NonSequencedQueue.front())->size, p->size);
|
||||||
delete NonSequencedQueue.front();
|
delete NonSequencedQueue.front();
|
||||||
NonSequencedQueue.pop();
|
NonSequencedQueue.pop();
|
||||||
}
|
}
|
||||||
@@ -718,7 +718,7 @@ void EQStream::Write(int eq_fd)
|
|||||||
uint16 seq_send = SequencedBase + count; //just for logging...
|
uint16 seq_send = SequencedBase + count; //just for logging...
|
||||||
|
|
||||||
if(SequencedQueue.empty()) {
|
if(SequencedQueue.empty()) {
|
||||||
LogNetcode(_L "Tried to write a packet with an empty queue ([{}] is past next out [{}])" __L, seq_send, NextOutSeq);
|
Log(Logs::Detail, Logs::Netcode, _L "Tried to write a packet with an empty queue (%d is past next out %d)" __L, seq_send, NextOutSeq);
|
||||||
SeqEmpty=true;
|
SeqEmpty=true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -728,35 +728,35 @@ void EQStream::Write(int eq_fd)
|
|||||||
++sitr;
|
++sitr;
|
||||||
++count;
|
++count;
|
||||||
if (p) {
|
if (p) {
|
||||||
LogNetcode(_L "Final combined packet not full, len [{}]" __L, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size);
|
||||||
ReadyToSend.push(p);
|
ReadyToSend.push(p);
|
||||||
BytesWritten += p->size;
|
BytesWritten += p->size;
|
||||||
p = nullptr;
|
p = nullptr;
|
||||||
}
|
}
|
||||||
LogNetcode(_L "Not retransmitting seq packet [{}] because already marked as acked" __L, seq_send);
|
Log(Logs::Detail, Logs::Netcode, _L "Not retransmitting seq packet %d because already marked as acked" __L, seq_send);
|
||||||
} else if (!p) {
|
} else if (!p) {
|
||||||
// If we don't have a packet to try to combine into, use this one as the base
|
// If we don't have a packet to try to combine into, use this one as the base
|
||||||
// Copy it first as it will still live until it is acked
|
// Copy it first as it will still live until it is acked
|
||||||
p=(*sitr)->Copy();
|
p=(*sitr)->Copy();
|
||||||
LogNetcode(_L "Starting combined packet with seq packet [{}] of len [{}]" __L, seq_send, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size);
|
||||||
(*sitr)->sent_time = Timer::GetCurrentTime();
|
(*sitr)->sent_time = Timer::GetCurrentTime();
|
||||||
++sitr;
|
++sitr;
|
||||||
++count;
|
++count;
|
||||||
} else if (!p->combine(*sitr)) {
|
} else if (!p->combine(*sitr)) {
|
||||||
// Trying to combine this packet with the base didn't work (too big maybe)
|
// Trying to combine this packet with the base didn't work (too big maybe)
|
||||||
// So just send the base packet (we'll try this packet again later)
|
// So just send the base packet (we'll try this packet again later)
|
||||||
LogNetcode(_L "Combined packet full at len [{}], next seq packet [{}] is len [{}]" __L, p->size, seq_send + 1, (*sitr)->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send + 1, (*sitr)->size);
|
||||||
ReadyToSend.push(p);
|
ReadyToSend.push(p);
|
||||||
BytesWritten+=p->size;
|
BytesWritten+=p->size;
|
||||||
p=nullptr;
|
p=nullptr;
|
||||||
if ((*sitr)->opcode != OP_Fragment && BytesWritten > threshold) {
|
if ((*sitr)->opcode != OP_Fragment && BytesWritten > threshold) {
|
||||||
// Sent enough this round, lets stop to be fair
|
// Sent enough this round, lets stop to be fair
|
||||||
LogNetcode(_L "Exceeded write threshold in seq ([{}] > [{}])" __L, BytesWritten, threshold);
|
Log(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Combine worked
|
// Combine worked
|
||||||
LogNetcode(_L "Combined seq packet [{}] of len [{}], yeilding [{}] combined" __L, seq_send, (*sitr)->size, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Combined seq packet %d of len %d, yeilding %d combined." __L, seq_send, (*sitr)->size, p->size);
|
||||||
(*sitr)->sent_time = Timer::GetCurrentTime();
|
(*sitr)->sent_time = Timer::GetCurrentTime();
|
||||||
++sitr;
|
++sitr;
|
||||||
++count;
|
++count;
|
||||||
@@ -766,7 +766,7 @@ void EQStream::Write(int eq_fd)
|
|||||||
++sitr;
|
++sitr;
|
||||||
++count;
|
++count;
|
||||||
if (p) {
|
if (p) {
|
||||||
LogNetcode(_L "Final combined packet not full, len [{}]" __L, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size);
|
||||||
ReadyToSend.push(p);
|
ReadyToSend.push(p);
|
||||||
BytesWritten += p->size;
|
BytesWritten += p->size;
|
||||||
p = nullptr;
|
p = nullptr;
|
||||||
@@ -776,25 +776,25 @@ void EQStream::Write(int eq_fd)
|
|||||||
// Copy it first as it will still live until it is acked
|
// Copy it first as it will still live until it is acked
|
||||||
p=(*sitr)->Copy();
|
p=(*sitr)->Copy();
|
||||||
(*sitr)->sent_time = Timer::GetCurrentTime();
|
(*sitr)->sent_time = Timer::GetCurrentTime();
|
||||||
LogNetcode(_L "Starting combined packet with seq packet [{}] of len [{}]" __L, seq_send, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size);
|
||||||
++sitr;
|
++sitr;
|
||||||
++count;
|
++count;
|
||||||
} else if (!p->combine(*sitr)) {
|
} else if (!p->combine(*sitr)) {
|
||||||
// Trying to combine this packet with the base didn't work (too big maybe)
|
// Trying to combine this packet with the base didn't work (too big maybe)
|
||||||
// So just send the base packet (we'll try this packet again later)
|
// So just send the base packet (we'll try this packet again later)
|
||||||
LogNetcode(_L "Combined packet full at len [{}], next seq packet [{}] is len [{}]" __L, p->size, seq_send, (*sitr)->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send, (*sitr)->size);
|
||||||
ReadyToSend.push(p);
|
ReadyToSend.push(p);
|
||||||
BytesWritten+=p->size;
|
BytesWritten+=p->size;
|
||||||
p=nullptr;
|
p=nullptr;
|
||||||
|
|
||||||
if (BytesWritten > threshold) {
|
if (BytesWritten > threshold) {
|
||||||
// Sent enough this round, lets stop to be fair
|
// Sent enough this round, lets stop to be fair
|
||||||
LogNetcode(_L "Exceeded write threshold in seq ([{}] > [{}])" __L, BytesWritten, threshold);
|
Log(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Combine worked
|
// Combine worked
|
||||||
LogNetcode(_L "Combined seq packet [{}] of len [{}], yielding [{}] combined" __L, seq_send, (*sitr)->size, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Combined seq packet %d of len %d, yielding %d combined." __L, seq_send, (*sitr)->size, p->size);
|
||||||
(*sitr)->sent_time = Timer::GetCurrentTime();
|
(*sitr)->sent_time = Timer::GetCurrentTime();
|
||||||
++sitr;
|
++sitr;
|
||||||
++count;
|
++count;
|
||||||
@@ -802,7 +802,7 @@ void EQStream::Write(int eq_fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||||
LogNetcode(_L "Post send Invalid Sequenced queue: BS [{}] + SQ [{}] != NOS [{}]" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
Log(Logs::Detail, Logs::Netcode, _L "Post send Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No more sequenced packets
|
// No more sequenced packets
|
||||||
@@ -814,7 +814,7 @@ void EQStream::Write(int eq_fd)
|
|||||||
|
|
||||||
// We have a packet still, must have run out of both seq and non-seq, so send it
|
// We have a packet still, must have run out of both seq and non-seq, so send it
|
||||||
if (p) {
|
if (p) {
|
||||||
LogNetcode(_L "Final combined packet not full, len [{}]" __L, p->size);
|
Log(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size);
|
||||||
ReadyToSend.push(p);
|
ReadyToSend.push(p);
|
||||||
BytesWritten+=p->size;
|
BytesWritten+=p->size;
|
||||||
}
|
}
|
||||||
@@ -831,7 +831,7 @@ void EQStream::Write(int eq_fd)
|
|||||||
if(SeqEmpty && NonSeqEmpty) {
|
if(SeqEmpty && NonSeqEmpty) {
|
||||||
//no more data to send
|
//no more data to send
|
||||||
if(CheckState(CLOSING)) {
|
if(CheckState(CLOSING)) {
|
||||||
LogNetcode(_L "All outgoing data flushed, closing stream" __L );
|
Log(Logs::Detail, Logs::Netcode, _L "All outgoing data flushed, closing stream." __L );
|
||||||
//we are waiting for the queues to empty, now we can do our disconnect.
|
//we are waiting for the queues to empty, now we can do our disconnect.
|
||||||
//this packet will not actually go out until the next call to Write().
|
//this packet will not actually go out until the next call to Write().
|
||||||
_SendDisconnect();
|
_SendDisconnect();
|
||||||
@@ -910,7 +910,7 @@ void EQStream::SendSessionRequest()
|
|||||||
Request->Session=htonl(time(nullptr));
|
Request->Session=htonl(time(nullptr));
|
||||||
Request->MaxLength=htonl(512);
|
Request->MaxLength=htonl(512);
|
||||||
|
|
||||||
LogNetcode(_L "Sending OP_SessionRequest: session [{}], maxlen=[{}]" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength));
|
Log(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength));
|
||||||
|
|
||||||
NonSequencedPush(out);
|
NonSequencedPush(out);
|
||||||
}
|
}
|
||||||
@@ -924,7 +924,7 @@ void EQStream::_SendDisconnect()
|
|||||||
*(uint32 *)out->pBuffer=htonl(Session);
|
*(uint32 *)out->pBuffer=htonl(Session);
|
||||||
NonSequencedPush(out);
|
NonSequencedPush(out);
|
||||||
|
|
||||||
LogNetcode(_L "Sending OP_SessionDisconnect: session [{}]" __L, (unsigned long)Session);
|
Log(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionDisconnect: session %lu" __L, (unsigned long)Session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
|
void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
|
||||||
@@ -976,7 +976,7 @@ EQRawApplicationPacket *p=nullptr;
|
|||||||
if(OpMgr != nullptr && *OpMgr != nullptr) {
|
if(OpMgr != nullptr && *OpMgr != nullptr) {
|
||||||
EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode);
|
EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode);
|
||||||
if(emu_op == OP_Unknown) {
|
if(emu_op == OP_Unknown) {
|
||||||
LogNetcode("Unable to convert EQ opcode {:#04x} to an Application opcode", p->opcode);
|
Log(Logs::General, Logs::Netcode, "Unable to convert EQ opcode 0x%.4x to an Application opcode.", p->opcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->SetOpcode(emu_op);
|
p->SetOpcode(emu_op);
|
||||||
@@ -1004,7 +1004,7 @@ void EQStream::InboundQueueClear()
|
|||||||
{
|
{
|
||||||
EQApplicationPacket *p=nullptr;
|
EQApplicationPacket *p=nullptr;
|
||||||
|
|
||||||
LogNetcode(_L "Clearing inbound queue" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Clearing inbound queue" __L);
|
||||||
|
|
||||||
MInboundQueue.lock();
|
MInboundQueue.lock();
|
||||||
if (!InboundQueue.empty()) {
|
if (!InboundQueue.empty()) {
|
||||||
@@ -1047,7 +1047,7 @@ void EQStream::OutboundQueueClear()
|
|||||||
{
|
{
|
||||||
EQProtocolPacket *p=nullptr;
|
EQProtocolPacket *p=nullptr;
|
||||||
|
|
||||||
LogNetcode(_L "Clearing outbound queue" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Clearing outbound queue" __L);
|
||||||
|
|
||||||
MOutboundQueue.lock();
|
MOutboundQueue.lock();
|
||||||
while(!NonSequencedQueue.empty()) {
|
while(!NonSequencedQueue.empty()) {
|
||||||
@@ -1069,7 +1069,7 @@ void EQStream::PacketQueueClear()
|
|||||||
{
|
{
|
||||||
EQProtocolPacket *p=nullptr;
|
EQProtocolPacket *p=nullptr;
|
||||||
|
|
||||||
LogNetcode(_L "Clearing future packet queue" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Clearing future packet queue" __L);
|
||||||
|
|
||||||
if(!PacketQueue.empty()) {
|
if(!PacketQueue.empty()) {
|
||||||
std::map<unsigned short,EQProtocolPacket *>::iterator itr;
|
std::map<unsigned short,EQProtocolPacket *>::iterator itr;
|
||||||
@@ -1101,7 +1101,7 @@ void EQStream::Process(const unsigned char *buffer, const uint32 length)
|
|||||||
delete p;
|
delete p;
|
||||||
ProcessQueue();
|
ProcessQueue();
|
||||||
} else {
|
} else {
|
||||||
LogNetcode(_L "Incoming packet failed checksum" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Incoming packet failed checksum" __L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1132,23 +1132,23 @@ std::deque<EQProtocolPacket *>::iterator itr, tmp;
|
|||||||
SeqOrder ord = CompareSequence(SequencedBase, seq);
|
SeqOrder ord = CompareSequence(SequencedBase, seq);
|
||||||
if(ord == SeqInOrder) {
|
if(ord == SeqInOrder) {
|
||||||
//they are not acking anything new...
|
//they are not acking anything new...
|
||||||
LogNetcode(_L "Received an ack with no window advancement (seq [{}])" __L, seq);
|
Log(Logs::Detail, Logs::Netcode, _L "Received an ack with no window advancement (seq %d)." __L, seq);
|
||||||
} else if(ord == SeqPast) {
|
} else if(ord == SeqPast) {
|
||||||
//they are nacking blocks going back before our buffer, wtf?
|
//they are nacking blocks going back before our buffer, wtf?
|
||||||
LogNetcode(_L "Received an ack with backward window advancement (they gave [{}], our window starts at [{}]). This is bad" __L, seq, SequencedBase);
|
Log(Logs::Detail, Logs::Netcode, _L "Received an ack with backward window advancement (they gave %d, our window starts at %d). This is bad." __L, seq, SequencedBase);
|
||||||
} else {
|
} else {
|
||||||
LogNetcode(_L "Received an ack up through sequence [{}]. Our base is [{}]" __L, seq, SequencedBase);
|
Log(Logs::Detail, Logs::Netcode, _L "Received an ack up through sequence %d. Our base is %d." __L, seq, SequencedBase);
|
||||||
|
|
||||||
|
|
||||||
//this is a good ack, we get to ack some blocks.
|
//this is a good ack, we get to ack some blocks.
|
||||||
seq++; //we stop at the block right after their ack, counting on the wrap of both numbers.
|
seq++; //we stop at the block right after their ack, counting on the wrap of both numbers.
|
||||||
while(SequencedBase != seq) {
|
while(SequencedBase != seq) {
|
||||||
if(SequencedQueue.empty()) {
|
if(SequencedQueue.empty()) {
|
||||||
LogNetcode(_L "OUT OF PACKETS acked packet with sequence [{}]. Next send is [{}] before this" __L, (unsigned long)SequencedBase, SequencedQueue.size());
|
Log(Logs::Detail, Logs::Netcode, _L "OUT OF PACKETS acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, SequencedQueue.size());
|
||||||
SequencedBase = NextOutSeq;
|
SequencedBase = NextOutSeq;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LogNetcode(_L "Removing acked packet with sequence [{}]" __L, (unsigned long)SequencedBase);
|
Log(Logs::Detail, Logs::Netcode, _L "Removing acked packet with sequence %lu." __L, (unsigned long)SequencedBase);
|
||||||
//clean out the acked packet
|
//clean out the acked packet
|
||||||
delete SequencedQueue.front();
|
delete SequencedQueue.front();
|
||||||
SequencedQueue.pop_front();
|
SequencedQueue.pop_front();
|
||||||
@@ -1156,7 +1156,7 @@ std::deque<EQProtocolPacket *>::iterator itr, tmp;
|
|||||||
SequencedBase++;
|
SequencedBase++;
|
||||||
}
|
}
|
||||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||||
LogNetcode(_L "Post-Ack on [{}] Invalid Sequenced queue: BS [{}] + SQ [{}] != NOS [{}]" __L, seq, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
Log(Logs::Detail, Logs::Netcode, _L "Post-Ack on %d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, seq, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1166,7 +1166,7 @@ std::deque<EQProtocolPacket *>::iterator itr, tmp;
|
|||||||
void EQStream::SetNextAckToSend(uint32 seq)
|
void EQStream::SetNextAckToSend(uint32 seq)
|
||||||
{
|
{
|
||||||
MAcks.lock();
|
MAcks.lock();
|
||||||
LogNetcode(_L "Set Next Ack To Send to [{}]" __L, (unsigned long)seq);
|
Log(Logs::Detail, Logs::Netcode, _L "Set Next Ack To Send to %lu" __L, (unsigned long)seq);
|
||||||
NextAckToSend=seq;
|
NextAckToSend=seq;
|
||||||
MAcks.unlock();
|
MAcks.unlock();
|
||||||
}
|
}
|
||||||
@@ -1174,7 +1174,7 @@ void EQStream::SetNextAckToSend(uint32 seq)
|
|||||||
void EQStream::SetLastAckSent(uint32 seq)
|
void EQStream::SetLastAckSent(uint32 seq)
|
||||||
{
|
{
|
||||||
MAcks.lock();
|
MAcks.lock();
|
||||||
LogNetcode(_L "Set Last Ack Sent to [{}]" __L, (unsigned long)seq);
|
Log(Logs::Detail, Logs::Netcode, _L "Set Last Ack Sent to %lu" __L, (unsigned long)seq);
|
||||||
LastAckSent=seq;
|
LastAckSent=seq;
|
||||||
MAcks.unlock();
|
MAcks.unlock();
|
||||||
}
|
}
|
||||||
@@ -1187,10 +1187,10 @@ void EQStream::ProcessQueue()
|
|||||||
|
|
||||||
EQProtocolPacket *qp=nullptr;
|
EQProtocolPacket *qp=nullptr;
|
||||||
while((qp=RemoveQueue(NextInSeq))!=nullptr) {
|
while((qp=RemoveQueue(NextInSeq))!=nullptr) {
|
||||||
LogNetcode(_L "Processing Queued Packet: Seq=[{}]" __L, NextInSeq);
|
Log(Logs::Detail, Logs::Netcode, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq);
|
||||||
ProcessPacket(qp);
|
ProcessPacket(qp);
|
||||||
delete qp;
|
delete qp;
|
||||||
LogNetcode(_L "OP_Packet Queue size=[{}]" __L, PacketQueue.size());
|
Log(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1201,21 +1201,21 @@ EQProtocolPacket *qp=nullptr;
|
|||||||
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
|
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
|
||||||
qp=itr->second;
|
qp=itr->second;
|
||||||
PacketQueue.erase(itr);
|
PacketQueue.erase(itr);
|
||||||
LogNetcode(_L "OP_Packet Queue size=[{}]" __L, PacketQueue.size());
|
Log(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size());
|
||||||
}
|
}
|
||||||
return qp;
|
return qp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQStream::SetStreamType(EQStreamType type)
|
void EQStream::SetStreamType(EQStreamType type)
|
||||||
{
|
{
|
||||||
LogNetcode(_L "Changing stream type from [{}] to [{}]" __L, StreamTypeString(StreamType), StreamTypeString(type));
|
Log(Logs::Detail, Logs::Netcode, _L "Changing stream type from %s to %s" __L, StreamTypeString(StreamType), StreamTypeString(type));
|
||||||
StreamType=type;
|
StreamType=type;
|
||||||
switch (StreamType) {
|
switch (StreamType) {
|
||||||
case LoginStream:
|
case LoginStream:
|
||||||
app_opcode_size=1;
|
app_opcode_size=1;
|
||||||
compressed=false;
|
compressed=false;
|
||||||
encoded=false;
|
encoded=false;
|
||||||
LogNetcode(_L "Login stream has app opcode size [{}], is not compressed or encoded" __L, app_opcode_size);
|
Log(Logs::Detail, Logs::Netcode, _L "Login stream has app opcode size %d, is not compressed or encoded." __L, app_opcode_size);
|
||||||
break;
|
break;
|
||||||
case ChatOrMailStream:
|
case ChatOrMailStream:
|
||||||
case ChatStream:
|
case ChatStream:
|
||||||
@@ -1223,7 +1223,7 @@ void EQStream::SetStreamType(EQStreamType type)
|
|||||||
app_opcode_size=1;
|
app_opcode_size=1;
|
||||||
compressed=false;
|
compressed=false;
|
||||||
encoded=true;
|
encoded=true;
|
||||||
LogNetcode(_L "Chat/Mail stream has app opcode size [{}], is not compressed, and is encoded" __L, app_opcode_size);
|
Log(Logs::Detail, Logs::Netcode, _L "Chat/Mail stream has app opcode size %d, is not compressed, and is encoded." __L, app_opcode_size);
|
||||||
break;
|
break;
|
||||||
case ZoneStream:
|
case ZoneStream:
|
||||||
case WorldStream:
|
case WorldStream:
|
||||||
@@ -1231,7 +1231,7 @@ void EQStream::SetStreamType(EQStreamType type)
|
|||||||
app_opcode_size=2;
|
app_opcode_size=2;
|
||||||
compressed=true;
|
compressed=true;
|
||||||
encoded=false;
|
encoded=false;
|
||||||
LogNetcode(_L "World/Zone stream has app opcode size [{}], is compressed, and is not encoded" __L, app_opcode_size);
|
Log(Logs::Detail, Logs::Netcode, _L "World/Zone stream has app opcode size %d, is compressed, and is not encoded." __L, app_opcode_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1281,7 +1281,7 @@ EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
|
|||||||
|
|
||||||
void EQStream::SetState(EQStreamState state) {
|
void EQStream::SetState(EQStreamState state) {
|
||||||
MState.lock();
|
MState.lock();
|
||||||
LogNetcode(_L "Changing state from [{}] to [{}]" __L, State, state);
|
Log(Logs::Detail, Logs::Netcode, _L "Changing state from %d to %d" __L, State, state);
|
||||||
State=state;
|
State=state;
|
||||||
MState.unlock();
|
MState.unlock();
|
||||||
}
|
}
|
||||||
@@ -1293,29 +1293,29 @@ void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
|
|||||||
|
|
||||||
EQStreamState orig_state = GetState();
|
EQStreamState orig_state = GetState();
|
||||||
if (orig_state == CLOSING && !outgoing_data) {
|
if (orig_state == CLOSING && !outgoing_data) {
|
||||||
LogNetcode(_L "Out of data in closing state, disconnecting" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Out of data in closing state, disconnecting." __L);
|
||||||
_SendDisconnect();
|
_SendDisconnect();
|
||||||
SetState(DISCONNECTING);
|
SetState(DISCONNECTING);
|
||||||
} else if (LastPacket && (now-LastPacket) > timeout) {
|
} else if (LastPacket && (now-LastPacket) > timeout) {
|
||||||
switch(orig_state) {
|
switch(orig_state) {
|
||||||
case CLOSING:
|
case CLOSING:
|
||||||
//if we time out in the closing state, they are not acking us, just give up
|
//if we time out in the closing state, they are not acking us, just give up
|
||||||
LogNetcode(_L "Timeout expired in closing state. Moving to closed state" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Timeout expired in closing state. Moving to closed state." __L);
|
||||||
_SendDisconnect();
|
_SendDisconnect();
|
||||||
SetState(CLOSED);
|
SetState(CLOSED);
|
||||||
break;
|
break;
|
||||||
case DISCONNECTING:
|
case DISCONNECTING:
|
||||||
//we timed out waiting for them to send us the disconnect reply, just give up.
|
//we timed out waiting for them to send us the disconnect reply, just give up.
|
||||||
LogNetcode(_L "Timeout expired in disconnecting state. Moving to closed state" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Timeout expired in disconnecting state. Moving to closed state." __L);
|
||||||
SetState(CLOSED);
|
SetState(CLOSED);
|
||||||
break;
|
break;
|
||||||
case CLOSED:
|
case CLOSED:
|
||||||
LogNetcode(_L "Timeout expired in closed state??" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Timeout expired in closed state??" __L);
|
||||||
break;
|
break;
|
||||||
case ESTABLISHED:
|
case ESTABLISHED:
|
||||||
//we timed out during normal operation. Try to be nice about it.
|
//we timed out during normal operation. Try to be nice about it.
|
||||||
//we will almost certainly time out again waiting for the disconnect reply, but oh well.
|
//we will almost certainly time out again waiting for the disconnect reply, but oh well.
|
||||||
LogNetcode(_L "Timeout expired in established state. Closing connection" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Timeout expired in established state. Closing connection." __L);
|
||||||
_SendDisconnect();
|
_SendDisconnect();
|
||||||
SetState(DISCONNECTING);
|
SetState(DISCONNECTING);
|
||||||
break;
|
break;
|
||||||
@@ -1342,7 +1342,7 @@ void EQStream::Decay()
|
|||||||
for (auto sitr = SequencedQueue.begin(); sitr != SequencedQueue.end(); ++sitr, count++) {
|
for (auto sitr = SequencedQueue.begin(); sitr != SequencedQueue.end(); ++sitr, count++) {
|
||||||
if (!(*sitr)->acked && (*sitr)->sent_time > 0 && ((*sitr)->sent_time + retransmittimeout) < Timer::GetCurrentTime()) {
|
if (!(*sitr)->acked && (*sitr)->sent_time > 0 && ((*sitr)->sent_time + retransmittimeout) < Timer::GetCurrentTime()) {
|
||||||
(*sitr)->sent_time = 0;
|
(*sitr)->sent_time = 0;
|
||||||
LogNetcode(_L "Timeout exceeded for seq [{}]. Flagging packet for retransmission" __L, SequencedBase + count);
|
Log(Logs::Detail, Logs::Netcode, _L "Timeout exceeded for seq %d. Flagging packet for retransmission" __L, SequencedBase + count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MOutboundQueue.unlock();
|
MOutboundQueue.unlock();
|
||||||
@@ -1384,12 +1384,12 @@ void EQStream::AdjustRates(uint32 average_delta)
|
|||||||
void EQStream::Close() {
|
void EQStream::Close() {
|
||||||
if(HasOutgoingData()) {
|
if(HasOutgoingData()) {
|
||||||
//there is pending data, wait for it to go out.
|
//there is pending data, wait for it to go out.
|
||||||
LogNetcode(_L "Stream requested to Close(), but there is pending data, waiting for it" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Stream requested to Close(), but there is pending data, waiting for it." __L);
|
||||||
SetState(CLOSING);
|
SetState(CLOSING);
|
||||||
} else {
|
} else {
|
||||||
//otherwise, we are done, we can drop immediately.
|
//otherwise, we are done, we can drop immediately.
|
||||||
_SendDisconnect();
|
_SendDisconnect();
|
||||||
LogNetcode(_L "Stream closing immediate due to Close()" __L);
|
Log(Logs::Detail, Logs::Netcode, _L "Stream closing immediate due to Close()" __L);
|
||||||
SetState(DISCONNECTING);
|
SetState(DISCONNECTING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1417,19 +1417,19 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) {
|
|||||||
} else if(p->opcode == sig->first_eq_opcode) {
|
} else if(p->opcode == sig->first_eq_opcode) {
|
||||||
//opcode matches, check length..
|
//opcode matches, check length..
|
||||||
if(p->size == sig->first_length) {
|
if(p->size == sig->first_length) {
|
||||||
LogNetcode("[StreamIdentify] [{}]:[{}]: First opcode matched {:#04x} and length matched [{}]", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size);
|
Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode matched 0x%x and length matched %d", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size);
|
||||||
res = MatchSuccessful;
|
res = MatchSuccessful;
|
||||||
} else if(sig->first_length == 0) {
|
} else if(sig->first_length == 0) {
|
||||||
LogNetcode("[StreamIdentify] [{}]:[{}]: First opcode matched {:#04x} and length ([{}]) is ignored", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size);
|
Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode matched 0x%x and length (%d) is ignored", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size);
|
||||||
res = MatchSuccessful;
|
res = MatchSuccessful;
|
||||||
} else {
|
} else {
|
||||||
//opcode matched but length did not.
|
//opcode matched but length did not.
|
||||||
LogNetcode("[StreamIdentify] [{}]:[{}]: First opcode matched {:#04x}, but length [{}] did not match expected [{}]", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size, sig->first_length);
|
Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode matched 0x%x, but length %d did not match expected %d", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size, sig->first_length);
|
||||||
res = MatchFailed;
|
res = MatchFailed;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//first opcode did not match..
|
//first opcode did not match..
|
||||||
LogNetcode("[StreamIdentify] [{}]:[{}]: First opcode {:#04x} did not match expected {:#04x}", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), p->opcode, sig->first_eq_opcode);
|
Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode 0x%x did not match expected 0x%x", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), p->opcode, sig->first_eq_opcode);
|
||||||
res = MatchFailed;
|
res = MatchFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -46,7 +46,7 @@ void EQStreamIdentifier::Process() {
|
|||||||
|
|
||||||
//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()));
|
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d before timeout.", r.stream->GetRemoteAddr().c_str(), ntohs(r.stream->GetRemotePort()));
|
||||||
r.stream->Close();
|
r.stream->Close();
|
||||||
|
|
||||||
cur = m_streams.erase(cur);
|
cur = m_streams.erase(cur);
|
||||||
@@ -62,23 +62,23 @@ void EQStreamIdentifier::Process() {
|
|||||||
}
|
}
|
||||||
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(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d before it closed.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()));
|
||||||
switch(r.stream->GetState())
|
switch(r.stream->GetState())
|
||||||
{
|
{
|
||||||
case ESTABLISHED:
|
case ESTABLISHED:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Established");
|
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Established");
|
||||||
break;
|
break;
|
||||||
case CLOSING:
|
case CLOSING:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Closing");
|
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closing");
|
||||||
break;
|
break;
|
||||||
case DISCONNECTING:
|
case DISCONNECTING:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Disconnecting");
|
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Disconnecting");
|
||||||
break;
|
break;
|
||||||
case CLOSED:
|
case CLOSED:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Closed");
|
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closed");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogNetcode("[StreamIdentify] Stream state was Unestablished or unknown");
|
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Unestablished or unknown");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
r.stream->ReleaseFromUse();
|
r.stream->ReleaseFromUse();
|
||||||
@@ -102,13 +102,13 @@ void EQStreamIdentifier::Process() {
|
|||||||
switch(res) {
|
switch(res) {
|
||||||
case EQStreamInterface::MatchNotReady:
|
case EQStreamInterface::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.LogDebugType(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, but stream is not ready for it.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
|
||||||
all_ready = false;
|
all_ready = false;
|
||||||
break;
|
break;
|
||||||
case EQStreamInterface::MatchSuccessful: {
|
case EQStreamInterface::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(Logs::General, Logs::Netcode, "[IDENTIFY] Identified stream %s:%d with signature %s", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
|
||||||
|
|
||||||
// before we assign the eqstream to an interface, let the stream recognize it is in use and the session should not be reset any further
|
// 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);
|
r.stream->SetActive(true);
|
||||||
@@ -122,7 +122,7 @@ void EQStreamIdentifier::Process() {
|
|||||||
}
|
}
|
||||||
case EQStreamInterface::MatchFailed:
|
case EQStreamInterface::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(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, and it did not match.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ 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(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d, no match found.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()));
|
||||||
r.stream->ReleaseFromUse();
|
r.stream->ReleaseFromUse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (p->GetOpcode() != OP_SpecialMesg) {
|
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::Server_Client_Packet, "[%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());
|
Log(Logs::General, Logs::Server_Client_Packet_With_Dump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size(), DumpPacketToString(p).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
EQApplicationPacket *newp = p->Copy();
|
EQApplicationPacket *newp = p->Copy();
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ void EQEmuConfig::parse_config()
|
|||||||
TerminateWait = atoi(_root["server"]["launcher"]["timers"].get("reterminate", "10000").asString().c_str());
|
TerminateWait = atoi(_root["server"]["launcher"]["timers"].get("reterminate", "10000").asString().c_str());
|
||||||
InitialBootWait = atoi(_root["server"]["launcher"]["timers"].get("initial", "20000").asString().c_str());
|
InitialBootWait = atoi(_root["server"]["launcher"]["timers"].get("initial", "20000").asString().c_str());
|
||||||
ZoneBootInterval = atoi(_root["server"]["launcher"]["timers"].get("interval", "2000").asString().c_str());
|
ZoneBootInterval = atoi(_root["server"]["launcher"]["timers"].get("interval", "2000").asString().c_str());
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
ZoneExe = _root["server"]["launcher"].get("exe", "zone.exe").asString();
|
ZoneExe = _root["server"]["launcher"].get("exe", "zone.exe").asString();
|
||||||
#else
|
#else
|
||||||
ZoneExe = _root["server"]["launcher"].get("exe", "./zone").asString();
|
ZoneExe = _root["server"]["launcher"].get("exe", "./zone").asString();
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ class EQEmuConfig
|
|||||||
fconfig >> _config->_root;
|
fconfig >> _config->_root;
|
||||||
_config->parse_config();
|
_config->parse_config();
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+44
-146
@@ -19,7 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "eqemu_logsys.h"
|
#include "eqemu_logsys.h"
|
||||||
#include "rulesys.h"
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "string_util.h"
|
#include "string_util.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
@@ -34,7 +33,7 @@
|
|||||||
|
|
||||||
std::ofstream process_log;
|
std::ofstream process_log;
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -89,12 +88,16 @@ EQEmuLogSys::EQEmuLogSys()
|
|||||||
{
|
{
|
||||||
on_log_gmsay_hook = [](uint16 log_type, const std::string &) {};
|
on_log_gmsay_hook = [](uint16 log_type, const std::string &) {};
|
||||||
on_log_console_hook = [](uint16 debug_level, uint16 log_type, const std::string &) {};
|
on_log_console_hook = [](uint16 debug_level, uint16 log_type, const std::string &) {};
|
||||||
|
bool file_logs_enabled = false;
|
||||||
|
int log_platform = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EQEmuLogSys Deconstructor
|
* EQEmuLogSys Deconstructor
|
||||||
*/
|
*/
|
||||||
EQEmuLogSys::~EQEmuLogSys() = default;
|
EQEmuLogSys::~EQEmuLogSys()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void EQEmuLogSys::LoadLogSettingsDefaults()
|
void EQEmuLogSys::LoadLogSettingsDefaults()
|
||||||
{
|
{
|
||||||
@@ -115,28 +118,15 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
|
|||||||
/**
|
/**
|
||||||
* Set Defaults
|
* Set Defaults
|
||||||
*/
|
*/
|
||||||
log_settings[Logs::WorldServer].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::World_Server].log_to_console = Logs::General;
|
||||||
log_settings[Logs::ZoneServer].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::Zone_Server].log_to_console = Logs::General;
|
||||||
log_settings[Logs::QSServer].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::QS_Server].log_to_console = Logs::General;
|
||||||
log_settings[Logs::UCSServer].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::UCS_Server].log_to_console = Logs::General;
|
||||||
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::Crash].log_to_console = Logs::General;
|
||||||
log_settings[Logs::MySQLError].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::MySQLError].log_to_console = Logs::General;
|
||||||
log_settings[Logs::Loginserver].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::Login_Server].log_to_console = Logs::General;
|
||||||
log_settings[Logs::HeadlessClient].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::Headless_Client].log_to_console = Logs::General;
|
||||||
log_settings[Logs::NPCScaling].log_to_gmsay = static_cast<uint8>(Logs::General);
|
log_settings[Logs::NPCScaling].log_to_gmsay = Logs::General;
|
||||||
log_settings[Logs::HotReload].log_to_gmsay = static_cast<uint8>(Logs::General);
|
|
||||||
log_settings[Logs::HotReload].log_to_console = static_cast<uint8>(Logs::General);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RFC 5424
|
|
||||||
*/
|
|
||||||
log_settings[Logs::Emergency].log_to_console = static_cast<uint8>(Logs::General);
|
|
||||||
log_settings[Logs::Alert].log_to_console = static_cast<uint8>(Logs::General);
|
|
||||||
log_settings[Logs::Critical].log_to_console = static_cast<uint8>(Logs::General);
|
|
||||||
log_settings[Logs::Error].log_to_console = static_cast<uint8>(Logs::General);
|
|
||||||
log_settings[Logs::Warning].log_to_console = static_cast<uint8>(Logs::General);
|
|
||||||
log_settings[Logs::Notice].log_to_console = static_cast<uint8>(Logs::General);
|
|
||||||
log_settings[Logs::Info].log_to_console = static_cast<uint8>(Logs::General);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Category enabled status on defaults
|
* Set Category enabled status on defaults
|
||||||
@@ -177,41 +167,20 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param log_category
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool EQEmuLogSys::IsRfc5424LogCategory(uint16 log_category)
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
log_category == Logs::Emergency ||
|
|
||||||
log_category == Logs::Alert ||
|
|
||||||
log_category == Logs::Critical ||
|
|
||||||
log_category == Logs::Error ||
|
|
||||||
log_category == Logs::Warning ||
|
|
||||||
log_category == Logs::Notice ||
|
|
||||||
log_category == Logs::Info ||
|
|
||||||
log_category == Logs::Debug
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param log_category
|
* @param log_category
|
||||||
* @param in_message
|
* @param in_message
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
std::string EQEmuLogSys::FormatOutMessageString(
|
std::string EQEmuLogSys::FormatOutMessageString(uint16 log_category, const std::string &in_message)
|
||||||
uint16 log_category,
|
|
||||||
const std::string &in_message
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
std::string return_string;
|
std::string ret;
|
||||||
|
ret.push_back('[');
|
||||||
if (IsRfc5424LogCategory(log_category)) {
|
ret.append(Logs::LogCategoryName[log_category]);
|
||||||
return_string = "[" + GetPlatformName() + "] ";
|
ret.push_back(']');
|
||||||
}
|
ret.push_back(' ');
|
||||||
|
ret.append(in_message);
|
||||||
return return_string + "[" + Logs::LogCategoryName[log_category] + "] " + in_message;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,11 +188,7 @@ std::string EQEmuLogSys::FormatOutMessageString(
|
|||||||
* @param log_category
|
* @param log_category
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
void EQEmuLogSys::ProcessGMSay(
|
void EQEmuLogSys::ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message)
|
||||||
uint16 debug_level,
|
|
||||||
uint16 log_category,
|
|
||||||
const std::string &message
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Enabling Netcode based GMSay output creates a feedback loop that ultimately ends in a crash
|
* Enabling Netcode based GMSay output creates a feedback loop that ultimately ends in a crash
|
||||||
@@ -245,11 +210,7 @@ void EQEmuLogSys::ProcessGMSay(
|
|||||||
* @param log_category
|
* @param log_category
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
void EQEmuLogSys::ProcessLogWrite(
|
void EQEmuLogSys::ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message)
|
||||||
uint16 debug_level,
|
|
||||||
uint16 log_category,
|
|
||||||
const std::string &message
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (log_category == Logs::Crash) {
|
if (log_category == Logs::Crash) {
|
||||||
char time_stamp[80];
|
char time_stamp[80];
|
||||||
@@ -311,8 +272,6 @@ std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category)
|
|||||||
case Logs::Normal:
|
case Logs::Normal:
|
||||||
return LC_YELLOW;
|
return LC_YELLOW;
|
||||||
case Logs::MySQLError:
|
case Logs::MySQLError:
|
||||||
case Logs::Warning:
|
|
||||||
case Logs::Critical:
|
|
||||||
case Logs::Error:
|
case Logs::Error:
|
||||||
return LC_RED;
|
return LC_RED;
|
||||||
case Logs::MySQLQuery:
|
case Logs::MySQLQuery:
|
||||||
@@ -365,7 +324,7 @@ uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category)
|
|||||||
*/
|
*/
|
||||||
void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message)
|
void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message)
|
||||||
{
|
{
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
HANDLE console_handle;
|
HANDLE console_handle;
|
||||||
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
CONSOLE_FONT_INFOEX info = { 0 };
|
CONSOLE_FONT_INFOEX info = { 0 };
|
||||||
@@ -384,42 +343,6 @@ void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category,
|
|||||||
on_log_console_hook(debug_level, log_category, message);
|
on_log_console_hook(debug_level, log_category, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param str
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
constexpr const char *str_end(const char *str)
|
|
||||||
{
|
|
||||||
return *str ? str_end(str + 1) : str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param str
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
constexpr bool str_slant(const char *str)
|
|
||||||
{
|
|
||||||
return *str == '/' ? true : (*str ? str_slant(str + 1) : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param str
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
constexpr const char *r_slant(const char *str)
|
|
||||||
{
|
|
||||||
return *str == '/' ? (str + 1) : r_slant(str - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param str
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
constexpr const char *base_file_name(const char *str)
|
|
||||||
{
|
|
||||||
return str_slant(str) ? r_slant(str_end(str)) : str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core logging function
|
* Core logging function
|
||||||
*
|
*
|
||||||
@@ -428,15 +351,7 @@ constexpr const char *base_file_name(const char *str)
|
|||||||
* @param message
|
* @param message
|
||||||
* @param ...
|
* @param ...
|
||||||
*/
|
*/
|
||||||
void EQEmuLogSys::Out(
|
void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...)
|
||||||
Logs::DebugLevel debug_level,
|
|
||||||
uint16 log_category,
|
|
||||||
const char *file,
|
|
||||||
const char *func,
|
|
||||||
int line,
|
|
||||||
const char *message,
|
|
||||||
...
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
bool log_to_console = true;
|
bool log_to_console = true;
|
||||||
if (log_settings[log_category].log_to_console < debug_level) {
|
if (log_settings[log_category].log_to_console < debug_level) {
|
||||||
@@ -458,18 +373,12 @@ void EQEmuLogSys::Out(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string prefix;
|
|
||||||
|
|
||||||
if (RuleB(Logging, PrintFileFunctionAndLine)) {
|
|
||||||
prefix = fmt::format("[{0}::{1}:{2}] ", base_file_name(file), func, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, message);
|
va_start(args, message);
|
||||||
std::string output_message = vStringFormat(message, args);
|
std::string output_message = vStringFormat(message.c_str(), args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
std::string output_debug_message = EQEmuLogSys::FormatOutMessageString(log_category, prefix + output_message);
|
std::string output_debug_message = EQEmuLogSys::FormatOutMessageString(log_category, output_message);
|
||||||
|
|
||||||
if (log_to_console) {
|
if (log_to_console) {
|
||||||
EQEmuLogSys::ProcessConsoleMessage(debug_level, log_category, output_debug_message);
|
EQEmuLogSys::ProcessConsoleMessage(debug_level, log_category, output_debug_message);
|
||||||
@@ -499,13 +408,13 @@ void EQEmuLogSys::SetCurrentTimeStamp(char *time_stamp)
|
|||||||
*/
|
*/
|
||||||
void EQEmuLogSys::MakeDirectory(const std::string &directory_name)
|
void EQEmuLogSys::MakeDirectory(const std::string &directory_name)
|
||||||
{
|
{
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
struct _stat st;
|
struct _stat st;
|
||||||
if (_stat(directory_name.c_str(), &st) == 0) // exists
|
if (_stat(directory_name.c_str(), &st) == 0) // exists
|
||||||
return;
|
return;
|
||||||
_mkdir(directory_name.c_str());
|
_mkdir(directory_name.c_str());
|
||||||
#else
|
#else
|
||||||
struct stat st{};
|
struct stat st;
|
||||||
if (stat(directory_name.c_str(), &st) == 0) { // exists
|
if (stat(directory_name.c_str(), &st) == 0) { // exists
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -546,7 +455,12 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("Starting File Log [logs/{}_{}.log]", platform_file_name.c_str(), getpid());
|
EQEmuLogSys::Out(
|
||||||
|
Logs::General,
|
||||||
|
Logs::Status,
|
||||||
|
"Starting File Log 'logs/%s_%i.log'",
|
||||||
|
platform_file_name.c_str(),
|
||||||
|
getpid());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make directory if not exists
|
* Make directory if not exists
|
||||||
@@ -566,11 +480,17 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name)
|
|||||||
/**
|
/**
|
||||||
* All other processes
|
* All other processes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (platform_file_name.empty()) {
|
if (platform_file_name.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("Starting File Log [logs/{}_{}.log]", platform_file_name.c_str(), getpid());
|
EQEmuLogSys::Out(
|
||||||
|
Logs::General,
|
||||||
|
Logs::Status,
|
||||||
|
"Starting File Log 'logs/%s_%i.log'",
|
||||||
|
platform_file_name.c_str(),
|
||||||
|
getpid());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open file pointer
|
* Open file pointer
|
||||||
@@ -581,25 +501,3 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Silence console logging
|
|
||||||
*/
|
|
||||||
void EQEmuLogSys::SilenceConsoleLogging()
|
|
||||||
{
|
|
||||||
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
|
||||||
log_settings[log_index].log_to_console = 0;
|
|
||||||
log_settings[log_index].is_category_enabled = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables console logging
|
|
||||||
*/
|
|
||||||
void EQEmuLogSys::EnableConsoleLogging()
|
|
||||||
{
|
|
||||||
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
|
||||||
log_settings[log_index].log_to_console = Logs::General;
|
|
||||||
log_settings[log_index].is_category_enabled = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+29
-138
@@ -25,14 +25,6 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#ifdef utf16_to_utf8
|
|
||||||
#undef utf16_to_utf8
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <fmt/format.h>
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
namespace Logs {
|
namespace Logs {
|
||||||
@@ -53,7 +45,7 @@ namespace Logs {
|
|||||||
AI,
|
AI,
|
||||||
Aggro,
|
Aggro,
|
||||||
Attack,
|
Attack,
|
||||||
PacketClientServer,
|
Client_Server_Packet,
|
||||||
Combat,
|
Combat,
|
||||||
Commands,
|
Commands,
|
||||||
Crash,
|
Crash,
|
||||||
@@ -67,54 +59,40 @@ namespace Logs {
|
|||||||
Normal,
|
Normal,
|
||||||
Object,
|
Object,
|
||||||
Pathing,
|
Pathing,
|
||||||
QSServer,
|
QS_Server,
|
||||||
Quests,
|
Quests,
|
||||||
Rules,
|
Rules,
|
||||||
Skills,
|
Skills,
|
||||||
Spawns,
|
Spawns,
|
||||||
Spells,
|
Spells,
|
||||||
Status,
|
Status,
|
||||||
TCPConnection,
|
TCP_Connection,
|
||||||
Tasks,
|
Tasks,
|
||||||
Tradeskills,
|
Tradeskills,
|
||||||
Trading,
|
Trading,
|
||||||
Tribute,
|
Tribute,
|
||||||
UCSServer,
|
UCS_Server,
|
||||||
WebInterfaceServer,
|
WebInterface_Server,
|
||||||
WorldServer,
|
World_Server,
|
||||||
ZoneServer,
|
Zone_Server,
|
||||||
MySQLError,
|
MySQLError,
|
||||||
MySQLQuery,
|
MySQLQuery,
|
||||||
Mercenaries,
|
Mercenaries,
|
||||||
QuestDebug,
|
QuestDebug,
|
||||||
PacketServerClient,
|
Server_Client_Packet,
|
||||||
PacketClientServerUnhandled,
|
Client_Server_Packet_Unhandled,
|
||||||
PacketServerClientWithDump,
|
Server_Client_Packet_With_Dump,
|
||||||
PacketClientServerWithDump,
|
Client_Server_Packet_With_Dump,
|
||||||
Loginserver,
|
Login_Server,
|
||||||
ClientLogin,
|
Client_Login,
|
||||||
HeadlessClient,
|
Headless_Client,
|
||||||
HPUpdate,
|
HP_Update,
|
||||||
FixZ,
|
FixZ,
|
||||||
Food,
|
Food,
|
||||||
Traps,
|
Traps,
|
||||||
NPCRoamBox,
|
NPCRoamBox,
|
||||||
NPCScaling,
|
NPCScaling,
|
||||||
MobAppearance,
|
MobAppearance,
|
||||||
Info,
|
|
||||||
Warning,
|
|
||||||
Critical,
|
|
||||||
Emergency,
|
|
||||||
Alert,
|
|
||||||
Notice,
|
|
||||||
AIScanClose,
|
|
||||||
AIYellForHelp,
|
|
||||||
AICastBeneficialClose,
|
|
||||||
AoeCast,
|
|
||||||
EntityManagement,
|
|
||||||
Flee,
|
|
||||||
Aura,
|
|
||||||
HotReload,
|
|
||||||
MaxCategoryID /* Don't Remove this */
|
MaxCategoryID /* Don't Remove this */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -174,25 +152,19 @@ namespace Logs {
|
|||||||
"Traps",
|
"Traps",
|
||||||
"NPC Roam Box",
|
"NPC Roam Box",
|
||||||
"NPC Scaling",
|
"NPC Scaling",
|
||||||
"Mob Appearance",
|
"Mob Appearance"
|
||||||
"Info",
|
|
||||||
"Warning",
|
|
||||||
"Critical",
|
|
||||||
"Emergency",
|
|
||||||
"Alert",
|
|
||||||
"Notice",
|
|
||||||
"AI Scan Close",
|
|
||||||
"AI Yell For Help",
|
|
||||||
"AI Cast Beneficial Close",
|
|
||||||
"AOE Cast",
|
|
||||||
"Entity Management",
|
|
||||||
"Flee",
|
|
||||||
"Aura",
|
|
||||||
"HotReload",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "eqemu_logsys_log_aliases.h"
|
#define Log(debug_level, log_category, message, ...) do {\
|
||||||
|
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
||||||
|
LogSys.Out(debug_level, log_category, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define LogF(debug_level, log_category, message, ...) do {\
|
||||||
|
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
||||||
|
OutF(LogSys, debug_level, log_category, message, ##__VA_ARGS__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
class EQEmuLogSys {
|
class EQEmuLogSys {
|
||||||
public:
|
public:
|
||||||
@@ -205,10 +177,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void CloseFileLogs();
|
void CloseFileLogs();
|
||||||
void LoadLogSettingsDefaults();
|
void LoadLogSettingsDefaults();
|
||||||
|
|
||||||
/**
|
|
||||||
* @param directory_name
|
|
||||||
*/
|
|
||||||
void MakeDirectory(const std::string &directory_name);
|
void MakeDirectory(const std::string &directory_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,25 +188,12 @@ public:
|
|||||||
* - This would pipe the same category and debug level to all output formats, but the internal memory reference of log_settings would
|
* - This would pipe the same category and debug level to all output formats, but the internal memory reference of log_settings would
|
||||||
* be checked against to see if that piped output is set to actually process it for the category and debug level
|
* be checked against to see if that piped output is set to actually process it for the category and debug level
|
||||||
*/
|
*/
|
||||||
void Out(
|
void Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...);
|
||||||
Logs::DebugLevel debug_level,
|
|
||||||
uint16 log_category,
|
|
||||||
const char *file,
|
|
||||||
const char *func,
|
|
||||||
int line,
|
|
||||||
const char *message,
|
|
||||||
...
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in file logs to prepend a timestamp entry for logs
|
* Used in file logs to prepend a timestamp entry for logs
|
||||||
* @param time_stamp
|
|
||||||
*/
|
*/
|
||||||
void SetCurrentTimeStamp(char* time_stamp);
|
void SetCurrentTimeStamp(char* time_stamp);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param log_name
|
|
||||||
*/
|
|
||||||
void StartFileLogs(const std::string &log_name = "");
|
void StartFileLogs(const std::string &log_name = "");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,14 +218,14 @@ public:
|
|||||||
* These are loaded via DB and have defaults loaded in LoadLogSettingsDefaults
|
* These are loaded via DB and have defaults loaded in LoadLogSettingsDefaults
|
||||||
* Database loaded via Database::LoadLogSettings(log_settings)
|
* Database loaded via Database::LoadLogSettings(log_settings)
|
||||||
*/
|
*/
|
||||||
LogSettings log_settings[Logs::LogCategory::MaxCategoryID]{};
|
LogSettings log_settings[Logs::LogCategory::MaxCategoryID];
|
||||||
|
|
||||||
bool file_logs_enabled = false;
|
bool file_logs_enabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets Executable platform (Zone/World/UCS) etc.
|
* Sets Executable platform (Zone/World/UCS) etc.
|
||||||
*/
|
*/
|
||||||
int log_platform = 0;
|
int log_platform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File name used in writing logs
|
* File name used in writing logs
|
||||||
@@ -285,26 +240,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
uint16 GetGMSayColorFromCategory(uint16 log_category);
|
uint16 GetGMSayColorFromCategory(uint16 log_category);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param f
|
|
||||||
*/
|
|
||||||
void SetGMSayHandler(std::function<void(uint16 log_type, const std::string&)> f) { on_log_gmsay_hook = f; }
|
void SetGMSayHandler(std::function<void(uint16 log_type, const std::string&)> f) { on_log_gmsay_hook = f; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @param f
|
|
||||||
*/
|
|
||||||
void SetConsoleHandler(std::function<void(uint16 debug_level, uint16 log_type, const std::string&)> f) { on_log_console_hook = f; }
|
void SetConsoleHandler(std::function<void(uint16 debug_level, uint16 log_type, const std::string&)> f) { on_log_console_hook = f; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Silence console logging
|
|
||||||
*/
|
|
||||||
void SilenceConsoleLogging();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn on all console logging
|
|
||||||
*/
|
|
||||||
void EnableConsoleLogging();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -320,7 +258,6 @@ private:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Linux console color messages mapped by category
|
* Linux console color messages mapped by category
|
||||||
*
|
|
||||||
* @param log_category
|
* @param log_category
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -331,57 +268,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
uint16 GetWindowsConsoleColorFromCategory(uint16 log_category);
|
uint16 GetWindowsConsoleColorFromCategory(uint16 log_category);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param debug_level
|
|
||||||
* @param log_category
|
|
||||||
* @param message
|
|
||||||
*/
|
|
||||||
void ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message);
|
void ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param debug_level
|
|
||||||
* @param log_category
|
|
||||||
* @param message
|
|
||||||
*/
|
|
||||||
void ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message);
|
void ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param debug_level
|
|
||||||
* @param log_category
|
|
||||||
* @param message
|
|
||||||
*/
|
|
||||||
void ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message);
|
void ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param log_category
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool IsRfc5424LogCategory(uint16 log_category);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EQEmuLogSys LogSys;
|
extern EQEmuLogSys LogSys;
|
||||||
|
|
||||||
/**
|
|
||||||
template<typename... Args>
|
|
||||||
void OutF(
|
|
||||||
EQEmuLogSys &ls,
|
|
||||||
Logs::DebugLevel debug_level,
|
|
||||||
uint16 log_category,
|
|
||||||
const char *file,
|
|
||||||
const char *func,
|
|
||||||
int line,
|
|
||||||
const char *fmt,
|
|
||||||
const Args &... args
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::string log_str = fmt::format(fmt, args...);
|
|
||||||
ls.Out(debug_level, log_category, file, func, line, log_str.c_str());
|
|
||||||
}
|
|
||||||
**/
|
|
||||||
|
|
||||||
#define OutF(ls, debug_level, log_category, file, func, line, formatStr, ...) \
|
|
||||||
do { \
|
|
||||||
ls.Out(debug_level, log_category, file, func, line, fmt::format(formatStr, ##__VA_ARGS__).c_str()); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,21 +16,15 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EQEMU_IP_UTIL_H
|
#pragma once
|
||||||
#define EQEMU_IP_UTIL_H
|
|
||||||
|
|
||||||
#include "types.h"
|
#include <fmt/format.h>
|
||||||
#include "iostream"
|
|
||||||
|
|
||||||
class IpUtil {
|
template <typename... Args>
|
||||||
public:
|
void OutF(EQEmuLogSys &ls, Logs::DebugLevel debug_level, uint16 log_category, const char *fmt, const Args&... args)
|
||||||
|
{
|
||||||
static uint32_t IPToUInt(const std::string &ip);
|
std::string log_str = fmt::format(fmt, args...);
|
||||||
static bool IsIpInRange(const std::string &ip, const std::string &network, const std::string &mask);
|
ls.Out(debug_level, log_category, log_str);
|
||||||
static bool IsIpInPrivateRfc1918(const std::string &ip);
|
}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //EQEMU_IP_UTIL_H
|
|
||||||
@@ -1,920 +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_LOGSYS_LOG_ALIASES_H
|
|
||||||
#define EQEMU_EQEMU_LOGSYS_LOG_ALIASES_H
|
|
||||||
|
|
||||||
#ifdef BUILD_LOGGING
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RFC 5424
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LogEmergency(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Emergency].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Emergency, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAlert(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Alert].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Alert, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCritical(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Critical].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Critical, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogError(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Error].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Error, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogWarning(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Warning].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Warning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNotice(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Notice].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Notice, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogInfo(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Info].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Info, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogDebug(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Debug].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Debug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Category
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LogAA(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AA].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::AA, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAADetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AA].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::AA, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAI(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AI].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::AI, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AI].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::AI, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAggro(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Aggro].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Aggro, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAggroDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Aggro].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Aggro, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAttack(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Attack].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Attack, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAttackDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Attack].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Attack, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogPacketClientServer(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::PacketClientServer].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::PacketClientServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogPacketClientServerDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::PacketClientServer].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::PacketClientServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCombat(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Combat].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Combat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCombatDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Combat].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Combat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCommands(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Commands].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Commands, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCommandsDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Commands].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Commands, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCrash(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Crash].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Crash, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCrashDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Crash].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Crash, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogDoors(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Doors].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Doors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogDoorsDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Doors].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Doors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogGuilds(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Guilds].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Guilds, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogGuildsDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Guilds].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Guilds, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogInventory(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Inventory].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Inventory, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogInventoryDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Inventory].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Inventory, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogLauncher(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Launcher].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Launcher, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogLauncherDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Launcher].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Launcher, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNetcode(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Netcode].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Netcode, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNetcodeDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Netcode].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Netcode, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNormal(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Normal].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Normal, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNormalDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Normal].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Normal, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogObject(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Object].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Object, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogObjectDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Object].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Object, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogPathing(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Pathing].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Pathing, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogPathingDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Pathing].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Pathing, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQSServer(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::QSServer].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::QSServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQSServerDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::QSServer].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::QSServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQuests(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Quests].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Quests, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQuestsDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Quests].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Quests, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogRules(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Rules].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Rules, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogRulesDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Rules].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Rules, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSkills(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Skills].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Skills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSkillsDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Skills].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Skills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSpawns(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Spawns].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Spawns, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSpawnsDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Spawns].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Spawns, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSpells(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Spells].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Spells, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSpellsDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Spells].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Spells, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTCPConnection(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::TCPConnection].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::TCPConnection, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTCPConnectionDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::TCPConnection].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::TCPConnection, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTasks(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Tasks].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Tasks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTasksDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Tasks].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Tasks, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTradeskills(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Tradeskills].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Tradeskills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTradeskillsDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Tradeskills].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Tradeskills, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTrading(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Trading].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Trading, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTradingDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Trading].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Trading, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTribute(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Tribute].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Tribute, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTributeDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Tribute].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Tribute, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMySQLError(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::MySQLError].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::MySQLError, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMySQLErrorDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::MySQLError].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::MySQLError, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMySQLQuery(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::MySQLQuery].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::MySQLQuery, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMySQLQueryDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::MySQLQuery].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::MySQLQuery, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMercenaries(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Mercenaries].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Mercenaries, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMercenariesDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Mercenaries].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Mercenaries, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQuestDebug(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::QuestDebug].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::QuestDebug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQuestDebugDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::QuestDebug].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::QuestDebug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogLoginserver(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Loginserver].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Loginserver, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogLoginserverDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Loginserver].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Loginserver, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogClientLogin(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::ClientLogin].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::ClientLogin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogClientLoginDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::ClientLogin].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::ClientLogin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHeadlessClient(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::HeadlessClient].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::HeadlessClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHeadlessClientDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::HeadlessClient].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::HeadlessClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHPUpdate(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::HPUpdate].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::HPUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHPUpdateDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::HPUpdate].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::HPUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFixZ(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::FixZ].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::FixZ, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFixZDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::FixZ].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::FixZ, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFood(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Food].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Food, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFoodDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Food].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Food, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTraps(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Traps].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Traps, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTrapsDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Traps].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Traps, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNPCRoamBox(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::NPCRoamBox].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::NPCRoamBox, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNPCRoamBoxDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::NPCRoamBox].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::NPCRoamBox, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNPCScaling(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::NPCScaling].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::NPCScaling, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNPCScalingDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::NPCScaling].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::NPCScaling, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMobAppearance(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::MobAppearance].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::MobAppearance, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMobAppearanceDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::MobAppearance].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::MobAppearance, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogStatus(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Status].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Status, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogStatusDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Status].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Status, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIScanClose(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AIScanClose].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::AIScanClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIScanCloseDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AIScanClose].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::AIScanClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIYellForHelp(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AIYellForHelp].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::AIYellForHelp, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIYellForHelpDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AIYellForHelp].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::AIYellForHelp, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAICastBeneficialClose(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AICastBeneficialClose].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::AICastBeneficialClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAICastBeneficialCloseDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AICastBeneficialClose].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::AICastBeneficialClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAoeCast(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AoeCast].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::AoeCast, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAoeCastDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::AoeCast].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::AoeCast, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogEntityManagement(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::EntityManagement].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::EntityManagement, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogEntityManagementDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::EntityManagement].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::EntityManagement, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFlee(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Flee].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Flee, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFleeDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Flee].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Flee, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAura(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Aura].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::Aura, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAuraDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::Aura].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::Aura, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHotReload(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::HotReload].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::General, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHotReloadDetail(message, ...) do {\
|
|
||||||
if (LogSys.log_settings[Logs::HotReload].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, Logs::Detail, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define Log(debug_level, log_category, message, ...) do {\
|
|
||||||
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
|
||||||
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogF(debug_level, log_category, message, ...) do {\
|
|
||||||
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
|
|
||||||
OutF(LogSys, debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define LogEmergency(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAlert(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCritical(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogError(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogWarning(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNotice(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogInfo(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogDebug(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Category
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LogAA(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAADetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAI(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAggro(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAggroDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAttack(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAttackDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogPacketClientServer(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogPacketClientServerDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCombat(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCombatDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCommands(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCommandsDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCrash(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogCrashDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogDoors(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogDoorsDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogGuilds(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogGuildsDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogInventory(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogInventoryDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogLauncher(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogLauncherDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNetcode(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNetcodeDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNormal(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNormalDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogObject(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogObjectDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogPathing(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogPathingDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQSServer(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQSServerDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQuests(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQuestsDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogRules(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogRulesDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSkills(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSkillsDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSpawns(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSpawnsDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSpells(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogSpellsDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTCPConnection(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTCPConnectionDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTasks(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTasksDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTradeskills(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTradeskillsDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTrading(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTradingDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTribute(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTributeDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMySQLError(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMySQLErrorDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMySQLQuery(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMySQLQueryDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMercenaries(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMercenariesDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQuestDebug(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogQuestDebugDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogLoginserver(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogLoginserverDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogClientLogin(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogClientLoginDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHeadlessClient(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHeadlessClientDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHPUpdate(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHPUpdateDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFixZ(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFixZDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFood(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFoodDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTraps(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogTrapsDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNPCRoamBox(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNPCRoamBoxDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNPCScaling(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogNPCScalingDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMobAppearance(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogMobAppearanceDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogStatus(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogStatusDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIScanClose(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIScanCloseDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIYellForHelp(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAIYellForHelpDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAICastBeneficialClose(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAICastBeneficialCloseDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAoeCast(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAoeCastDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogEntityManagement(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogEntityManagementDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFlee(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogFleeDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAura(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogAuraDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHotReload(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogHotReloadDetail(message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define Log(debug_level, log_category, message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LogF(debug_level, log_category, message, ...) do {\
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //EQEMU_EQEMU_LOGSYS_LOG_ALIASES_H
|
|
||||||
+11
-19
@@ -8,38 +8,30 @@ namespace EQ
|
|||||||
class EventLoop
|
class EventLoop
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static EventLoop &Get() {
|
EventLoop() {
|
||||||
static thread_local EventLoop inst;
|
memset(&m_loop, 0, sizeof(uv_loop_t));
|
||||||
return inst;
|
uv_loop_init(&m_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
~EventLoop() {
|
~EventLoop() {
|
||||||
uv_loop_close(&m_loop);
|
uv_loop_close(&m_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventLoop(const EventLoop&) = delete;
|
||||||
|
EventLoop& operator=(const EventLoop&) = delete;
|
||||||
|
|
||||||
|
static EventLoop &GetDefault() {
|
||||||
|
static thread_local EventLoop inst;
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
void Process() {
|
void Process() {
|
||||||
uv_run(&m_loop, UV_RUN_NOWAIT);
|
uv_run(&m_loop, UV_RUN_NOWAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run() {
|
|
||||||
uv_run(&m_loop, UV_RUN_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shutdown() {
|
|
||||||
uv_stop(&m_loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
uv_loop_t* Handle() { return &m_loop; }
|
uv_loop_t* Handle() { return &m_loop; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventLoop() {
|
|
||||||
memset(&m_loop, 0, sizeof(uv_loop_t));
|
|
||||||
uv_loop_init(&m_loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
EventLoop(const EventLoop&);
|
|
||||||
EventLoop& operator=(const EventLoop&);
|
|
||||||
|
|
||||||
uv_loop_t m_loop;
|
uv_loop_t m_loop;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-17
@@ -24,8 +24,12 @@ namespace EQ {
|
|||||||
std::exception error;
|
std::exception error;
|
||||||
};
|
};
|
||||||
|
|
||||||
Task(TaskFn fn) {
|
Task(EventLoop &loop, TaskFn fn) : _loop(loop) {
|
||||||
m_fn = fn;
|
_fn = fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
Task(TaskFn fn) : _loop(EventLoop::GetDefault()) {
|
||||||
|
_fn = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Task() {
|
~Task() {
|
||||||
@@ -33,34 +37,34 @@ namespace EQ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Task& Then(ResolveFn fn) {
|
Task& Then(ResolveFn fn) {
|
||||||
m_then = fn;
|
_then = fn;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task& Catch(RejectFn fn) {
|
Task& Catch(RejectFn fn) {
|
||||||
m_catch = fn;
|
_catch = fn;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task& Finally(FinallyFn fn) {
|
Task& Finally(FinallyFn fn) {
|
||||||
m_finally = fn;
|
_fin = fn;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run() {
|
void Run() {
|
||||||
uv_work_t *m_work = new uv_work_t;
|
uv_work_t *work = new uv_work_t;
|
||||||
memset(m_work, 0, sizeof(uv_work_t));
|
memset(work, 0, sizeof(uv_work_t));
|
||||||
TaskBaton *baton = new TaskBaton();
|
TaskBaton *baton = new TaskBaton();
|
||||||
baton->fn = m_fn;
|
baton->fn = _fn;
|
||||||
baton->on_then = m_then;
|
baton->on_then = _then;
|
||||||
baton->on_catch = m_catch;
|
baton->on_catch = _catch;
|
||||||
baton->on_finally = m_finally;
|
baton->on_finally = _fin;
|
||||||
baton->has_result = false;
|
baton->has_result = false;
|
||||||
baton->has_error = false;
|
baton->has_error = false;
|
||||||
|
|
||||||
m_work->data = baton;
|
work->data = baton;
|
||||||
|
|
||||||
uv_queue_work(EventLoop::Get().Handle(), m_work, [](uv_work_t* req) {
|
uv_queue_work(_loop.Handle(), work, [](uv_work_t* req) {
|
||||||
TaskBaton *baton = (TaskBaton*)req->data;
|
TaskBaton *baton = (TaskBaton*)req->data;
|
||||||
|
|
||||||
baton->fn([baton](const EQEmu::Any& result) {
|
baton->fn([baton](const EQEmu::Any& result) {
|
||||||
@@ -92,9 +96,10 @@ namespace EQ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TaskFn m_fn;
|
TaskFn _fn;
|
||||||
ResolveFn m_then;
|
ResolveFn _then;
|
||||||
RejectFn m_catch;
|
RejectFn _catch;
|
||||||
FinallyFn m_finally;
|
FinallyFn _fin;
|
||||||
|
EventLoop &_loop;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,114 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
#include <thread>
|
|
||||||
#include <mutex>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <functional>
|
|
||||||
#include <queue>
|
|
||||||
#include <future>
|
|
||||||
|
|
||||||
namespace EQ
|
|
||||||
{
|
|
||||||
namespace Event
|
|
||||||
{
|
|
||||||
class TaskScheduler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const int DefaultThreadCount = 4;
|
|
||||||
|
|
||||||
TaskScheduler() : _running(false)
|
|
||||||
{
|
|
||||||
Start(DefaultThreadCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskScheduler(size_t threads) : _running(false)
|
|
||||||
{
|
|
||||||
Start(threads);
|
|
||||||
}
|
|
||||||
|
|
||||||
~TaskScheduler() {
|
|
||||||
Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Start(size_t threads) {
|
|
||||||
if (true == _running) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_running = true;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < threads; ++i) {
|
|
||||||
_threads.push_back(std::thread(std::bind(&TaskScheduler::ProcessWork, this)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stop() {
|
|
||||||
if (false == _running) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::unique_lock<std::mutex> lock(_lock);
|
|
||||||
_running = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_cv.notify_all();
|
|
||||||
|
|
||||||
for (auto &t : _threads) {
|
|
||||||
t.join();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Fn, typename... Args>
|
|
||||||
auto Enqueue(Fn&& fn, Args&&... args) -> std::future<typename std::result_of<Fn(Args...)>::type> {
|
|
||||||
using return_type = typename std::result_of<Fn(Args...)>::type;
|
|
||||||
|
|
||||||
auto task = std::make_shared<std::packaged_task<return_type()>>(
|
|
||||||
std::bind(std::forward<Fn>(fn), std::forward<Args>(args)...)
|
|
||||||
);
|
|
||||||
|
|
||||||
std::future<return_type> res = task->get_future();
|
|
||||||
{
|
|
||||||
std::unique_lock<std::mutex> lock(_lock);
|
|
||||||
|
|
||||||
if (false == _running) {
|
|
||||||
throw std::runtime_error("Enqueue on stopped scheduler.");
|
|
||||||
}
|
|
||||||
|
|
||||||
_tasks.emplace([task]() { (*task)(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
_cv.notify_one();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ProcessWork() {
|
|
||||||
for (;;) {
|
|
||||||
std::function<void()> work;
|
|
||||||
|
|
||||||
{
|
|
||||||
std::unique_lock<std::mutex> lock(_lock);
|
|
||||||
_cv.wait(lock, [this] { return !_running || !_tasks.empty(); });
|
|
||||||
|
|
||||||
if (false == _running) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
work = std::move(_tasks.front());
|
|
||||||
_tasks.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
work();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _running = true;
|
|
||||||
std::vector<std::thread> _threads;
|
|
||||||
std::mutex _lock;
|
|
||||||
std::condition_variable _cv;
|
|
||||||
std::queue<std::function<void()>> _tasks;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+34
-20
@@ -6,16 +6,29 @@ namespace EQ {
|
|||||||
class Timer
|
class Timer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Timer(std::function<void(Timer *)> cb)
|
Timer(EventLoop &loop, std::function<void(Timer *)> cb) : _loop(loop)
|
||||||
{
|
{
|
||||||
m_timer = nullptr;
|
_timer = nullptr;
|
||||||
m_cb = cb;
|
_cb = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer(uint64_t duration_ms, bool repeats, std::function<void(Timer *)> cb)
|
Timer(EventLoop &loop, uint64_t duration_ms, bool repeats, std::function<void(Timer *)> cb) : _loop(loop)
|
||||||
{
|
{
|
||||||
m_timer = nullptr;
|
_timer = nullptr;
|
||||||
m_cb = cb;
|
_cb = cb;
|
||||||
|
Start(duration_ms, repeats);
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer(std::function<void(Timer *)> cb) : _loop(EventLoop::GetDefault())
|
||||||
|
{
|
||||||
|
_timer = nullptr;
|
||||||
|
_cb = cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer(uint64_t duration_ms, bool repeats, std::function<void(Timer *)> cb) : _loop(EventLoop::GetDefault())
|
||||||
|
{
|
||||||
|
_timer = nullptr;
|
||||||
|
_cb = cb;
|
||||||
Start(duration_ms, repeats);
|
Start(duration_ms, repeats);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,21 +38,21 @@ namespace EQ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Start(uint64_t duration_ms, bool repeats) {
|
void Start(uint64_t duration_ms, bool repeats) {
|
||||||
auto loop = EventLoop::Get().Handle();
|
auto loop = EventLoop::GetDefault().Handle();
|
||||||
if (!m_timer) {
|
if (!_timer) {
|
||||||
m_timer = new uv_timer_t;
|
_timer = new uv_timer_t;
|
||||||
memset(m_timer, 0, sizeof(uv_timer_t));
|
memset(_timer, 0, sizeof(uv_timer_t));
|
||||||
uv_timer_init(loop, m_timer);
|
uv_timer_init(loop, _timer);
|
||||||
m_timer->data = this;
|
_timer->data = this;
|
||||||
|
|
||||||
if (repeats) {
|
if (repeats) {
|
||||||
uv_timer_start(m_timer, [](uv_timer_t *handle) {
|
uv_timer_start(_timer, [](uv_timer_t *handle) {
|
||||||
Timer *t = (Timer*)handle->data;
|
Timer *t = (Timer*)handle->data;
|
||||||
t->Execute();
|
t->Execute();
|
||||||
}, duration_ms, duration_ms);
|
}, duration_ms, duration_ms);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uv_timer_start(m_timer, [](uv_timer_t *handle) {
|
uv_timer_start(_timer, [](uv_timer_t *handle) {
|
||||||
Timer *t = (Timer*)handle->data;
|
Timer *t = (Timer*)handle->data;
|
||||||
t->Stop();
|
t->Stop();
|
||||||
t->Execute();
|
t->Execute();
|
||||||
@@ -49,19 +62,20 @@ namespace EQ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Stop() {
|
void Stop() {
|
||||||
if (m_timer) {
|
if (_timer) {
|
||||||
uv_close((uv_handle_t*)m_timer, [](uv_handle_t* handle) {
|
uv_close((uv_handle_t*)_timer, [](uv_handle_t* handle) {
|
||||||
delete handle;
|
delete handle;
|
||||||
});
|
});
|
||||||
m_timer = nullptr;
|
_timer = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void Execute() {
|
void Execute() {
|
||||||
m_cb(this);
|
_cb(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_timer_t *m_timer;
|
EventLoop &_loop;
|
||||||
std::function<void(Timer*)> m_cb;
|
uv_timer_t *_timer;
|
||||||
|
std::function<void(Timer*)> _cb;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,67 +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 <fstream>
|
|
||||||
#include "file_util.h"
|
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
#include <direct.h>
|
|
||||||
#include <conio.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <dos.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <process.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool FileUtil::exists(const std::string &name)
|
|
||||||
{
|
|
||||||
std::ifstream f(name.c_str());
|
|
||||||
|
|
||||||
return f.good();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param directory_name
|
|
||||||
*/
|
|
||||||
void FileUtil::mkdir(const std::string& directory_name)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
struct _stat st;
|
|
||||||
if (_stat(directory_name.c_str(), &st) == 0) // exists
|
|
||||||
return;
|
|
||||||
_mkdir(directory_name.c_str());
|
|
||||||
#else
|
|
||||||
struct stat st{};
|
|
||||||
if (stat(directory_name.c_str(), &st) == 0) { // exists
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
::mkdir(directory_name.c_str(), 0755);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@@ -1,32 +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_FILE_UTIL_H
|
|
||||||
#define EQEMU_FILE_UTIL_H
|
|
||||||
|
|
||||||
|
|
||||||
class FileUtil {
|
|
||||||
public:
|
|
||||||
static bool exists(const std::string &name);
|
|
||||||
static void mkdir(const std::string& directory_name);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //EQEMU_FILE_UTIL_H
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// WHY IS THIS UP HERE
|
// WHY IS THIS UP HERE
|
||||||
#if defined(_DEBUG) && defined(WIN32)
|
#if defined(_DEBUG) && defined(_WIN32)
|
||||||
#ifndef _CRTDBG_MAP_ALLOC
|
#ifndef _CRTDBG_MAP_ALLOC
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
#ifndef EQDEBUG_H
|
#ifndef EQDEBUG_H
|
||||||
#define EQDEBUG_H
|
#define EQDEBUG_H
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+47
-47
@@ -46,7 +46,7 @@ bool BaseGuildManager::LoadGuilds() {
|
|||||||
ClearGuilds();
|
ClearGuilds();
|
||||||
|
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested to load guilds when we have no database object");
|
Log(Logs::Detail, Logs::Guilds, "Requested to load guilds when we have no database object.");
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,13 +77,13 @@ bool BaseGuildManager::LoadGuilds() {
|
|||||||
uint8 rankn = atoi(row[1]);
|
uint8 rankn = atoi(row[1]);
|
||||||
|
|
||||||
if(rankn > GUILD_MAX_RANK) {
|
if(rankn > GUILD_MAX_RANK) {
|
||||||
LogGuilds("Found invalid (too high) rank [{}] for guild [{}], skipping", rankn, guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end()) {
|
if(res == m_guilds.end()) {
|
||||||
LogGuilds("Found rank [{}] for non-existent guild [{}], skipping", rankn, guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Found rank %d for non-existent guild %d, skipping.", rankn, guild_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ bool BaseGuildManager::LoadGuilds() {
|
|||||||
|
|
||||||
bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested to refresh guild [{}] when we have no database object", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Requested to refresh guild %d when we have no database object.", guild_id);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
|||||||
|
|
||||||
if (results.RowCount() == 0)
|
if (results.RowCount() == 0)
|
||||||
{
|
{
|
||||||
LogGuilds("Unable to find guild [{}] in the database", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Unable to find guild %d in the database.", guild_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
|||||||
uint8 rankn = atoi(row[1]);
|
uint8 rankn = atoi(row[1]);
|
||||||
|
|
||||||
if(rankn > GUILD_MAX_RANK) {
|
if(rankn > GUILD_MAX_RANK) {
|
||||||
LogGuilds("Found invalid (too high) rank [{}] for guild [{}], skipping", rankn, guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
|||||||
rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1') ? true: false;
|
rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1') ? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogGuilds("Successfully refreshed guild [{}] from the database", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Successfully refreshed guild %d from the database.", guild_id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -214,14 +214,14 @@ BaseGuildManager::GuildInfo *BaseGuildManager::_CreateGuild(uint32 guild_id, con
|
|||||||
|
|
||||||
bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested to store guild [{}] when we have no database object", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Requested to store guild %d when we have no database object.", guild_id);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end()) {
|
if(res == m_guilds.end()) {
|
||||||
LogGuilds("Requested to store non-existent guild [{}]", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Requested to store non-existent guild %d", guild_id);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
GuildInfo *info = res->second;
|
GuildInfo *info = res->second;
|
||||||
@@ -289,14 +289,14 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
|||||||
safe_delete_array(title_esc);
|
safe_delete_array(title_esc);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogGuilds("Stored guild [{}] in the database", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Stored guild %d in the database", guild_id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 BaseGuildManager::_GetFreeGuildID() {
|
uint32 BaseGuildManager::_GetFreeGuildID() {
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested find a free guild ID when we have no database object");
|
Log(Logs::Detail, Logs::Guilds, "Requested find a free guild ID when we have no database object.");
|
||||||
return(GUILD_NONE);
|
return(GUILD_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,12 +330,12 @@ uint32 BaseGuildManager::_GetFreeGuildID() {
|
|||||||
|
|
||||||
if (results.RowCount() == 0)
|
if (results.RowCount() == 0)
|
||||||
{
|
{
|
||||||
LogGuilds("Located free guild ID [{}] in the database", index);
|
Log(Logs::Detail, Logs::Guilds, "Located free guild ID %d in the database", index);
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogGuilds("Unable to find a free guild ID when requested");
|
Log(Logs::Detail, Logs::Guilds, "Unable to find a free guild ID when requested.");
|
||||||
return GUILD_NONE;
|
return GUILD_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,11 +505,11 @@ uint32 BaseGuildManager::DBCreateGuild(const char* name, uint32 leader) {
|
|||||||
|
|
||||||
//now store the resulting guild setup into the DB.
|
//now store the resulting guild setup into the DB.
|
||||||
if(!_StoreGuildDB(new_id)) {
|
if(!_StoreGuildDB(new_id)) {
|
||||||
LogGuilds("Error storing new guild. It may have been partially created which may need manual removal");
|
Log(Logs::Detail, Logs::Guilds, "Error storing new guild. It may have been partially created which may need manual removal.");
|
||||||
return(GUILD_NONE);
|
return(GUILD_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogGuilds("Created guild [{}] in the database", new_id);
|
Log(Logs::Detail, Logs::Guilds, "Created guild %d in the database.", new_id);
|
||||||
|
|
||||||
return(new_id);
|
return(new_id);
|
||||||
}
|
}
|
||||||
@@ -525,7 +525,7 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested to delete guild [{}] when we have no database object", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Requested to delete guild %d when we have no database object.", guild_id);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,14 +545,14 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) {
|
|||||||
query = StringFormat("DELETE FROM guild_bank WHERE guildid=%lu", (unsigned long)guild_id);
|
query = StringFormat("DELETE FROM guild_bank WHERE guildid=%lu", (unsigned long)guild_id);
|
||||||
QueryWithLogging(query, "deleting guild bank");
|
QueryWithLogging(query, "deleting guild bank");
|
||||||
|
|
||||||
LogGuilds("Deleted guild [{}] from the database", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Deleted guild %d from the database.", guild_id);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
|
bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested to rename guild [{}] when we have no database object", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Requested to rename guild %d when we have no database object.", guild_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,13 +573,13 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
|
|||||||
|
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
{
|
{
|
||||||
LogGuilds("Error renaming guild [{}] [{}]: [{}]", guild_id, query.c_str(), results.Success());
|
Log(Logs::Detail, Logs::Guilds, "Error renaming guild %d '%s': %s", guild_id, query.c_str(), results.Success());
|
||||||
safe_delete_array(esc);
|
safe_delete_array(esc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
safe_delete_array(esc);
|
safe_delete_array(esc);
|
||||||
|
|
||||||
LogGuilds("Renamed guild [{}] ([{}]) to [{}] in database", info->name.c_str(), guild_id, name);
|
Log(Logs::Detail, Logs::Guilds, "Renamed guild %s (%d) to %s in database.", info->name.c_str(), guild_id, name);
|
||||||
|
|
||||||
info->name = name; //update our local record.
|
info->name = name; //update our local record.
|
||||||
|
|
||||||
@@ -588,7 +588,7 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
|
|||||||
|
|
||||||
bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
|
bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested to set the leader for guild [{}] when we have no database object", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Requested to set the leader for guild %d when we have no database object.", guild_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,7 +614,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
|
|||||||
if(!DBSetGuildRank(leader, GUILD_LEADER))
|
if(!DBSetGuildRank(leader, GUILD_LEADER))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LogGuilds("Set guild leader for guild [{}] to [{}] in the database", guild_id, leader);
|
Log(Logs::Detail, Logs::Guilds, "Set guild leader for guild %d to %d in the database", guild_id, leader);
|
||||||
|
|
||||||
info->leader_char_id = leader; //update our local record.
|
info->leader_char_id = leader; //update our local record.
|
||||||
|
|
||||||
@@ -623,7 +623,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
|
|||||||
|
|
||||||
bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const char *setter) {
|
bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const char *setter) {
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested to set the MOTD for guild [{}] when we have no database object", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Requested to set the MOTD for guild %d when we have no database object.", guild_id);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,7 +654,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
|
|||||||
safe_delete_array(esc);
|
safe_delete_array(esc);
|
||||||
safe_delete_array(esc_set);
|
safe_delete_array(esc_set);
|
||||||
|
|
||||||
LogGuilds("Set MOTD for guild [{}] in the database", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Set MOTD for guild %d in the database", guild_id);
|
||||||
|
|
||||||
info->motd = motd; //update our local record.
|
info->motd = motd; //update our local record.
|
||||||
info->motd_setter = setter; //update our local record.
|
info->motd_setter = setter; //update our local record.
|
||||||
@@ -688,7 +688,7 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
|
|||||||
}
|
}
|
||||||
safe_delete_array(esc);
|
safe_delete_array(esc);
|
||||||
|
|
||||||
LogGuilds("Set URL for guild [{}] in the database", GuildID);
|
Log(Logs::Detail, Logs::Guilds, "Set URL for guild %d in the database", GuildID);
|
||||||
|
|
||||||
info->url = URL; //update our local record.
|
info->url = URL; //update our local record.
|
||||||
|
|
||||||
@@ -722,7 +722,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
|
|||||||
}
|
}
|
||||||
safe_delete_array(esc);
|
safe_delete_array(esc);
|
||||||
|
|
||||||
LogGuilds("Set Channel for guild [{}] in the database", GuildID);
|
Log(Logs::Detail, Logs::Guilds, "Set Channel for guild %d in the database", GuildID);
|
||||||
|
|
||||||
info->channel = Channel; //update our local record.
|
info->channel = Channel; //update our local record.
|
||||||
|
|
||||||
@@ -731,7 +731,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
|
|||||||
|
|
||||||
bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
|
bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested to set char to guild [{}] when we have no database object", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Requested to set char to guild %d when we have no database object.", guild_id);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,7 +753,7 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogGuilds("Set char [{}] to guild [{}] and rank [{}] in the database", charid, guild_id, rank);
|
Log(Logs::Detail, Logs::Guilds, "Set char %d to guild %d and rank %d in the database.", charid, guild_id, rank);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,7 +845,7 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogGuilds("Set public not for char [{}]", charid);
|
Log(Logs::Detail, Logs::Guilds, "Set public not for char %d", charid);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -912,7 +912,7 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo
|
|||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
//load up the rank info for each guild.
|
//load up the rank info for each guild.
|
||||||
std::string query = StringFormat(GuildMemberBaseQuery " WHERE g.guild_id=%d AND c.deleted_at IS NULL", guild_id);
|
std::string query = StringFormat(GuildMemberBaseQuery " WHERE g.guild_id=%d", guild_id);
|
||||||
auto results = m_db->QueryDatabase(query);
|
auto results = m_db->QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -924,14 +924,14 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo
|
|||||||
members.push_back(ci);
|
members.push_back(ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogGuilds("Retreived entire guild member list for guild [{}] from the database", guild_id);
|
Log(Logs::Detail, Logs::Guilds, "Retreived entire guild member list for guild %d from the database", guild_id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested char info on [{}] when we have no database object", char_name);
|
Log(Logs::Detail, Logs::Guilds, "Requested char info on %s when we have no database object.", char_name);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -941,7 +941,7 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
|||||||
m_db->DoEscapeString(esc, char_name, nl);
|
m_db->DoEscapeString(esc, char_name, nl);
|
||||||
|
|
||||||
//load up the rank info for each guild.
|
//load up the rank info for each guild.
|
||||||
std::string query = StringFormat(GuildMemberBaseQuery " WHERE c.name='%s' AND c.deleted_at IS NULL", esc);
|
std::string query = StringFormat(GuildMemberBaseQuery " WHERE c.name='%s'", esc);
|
||||||
safe_delete_array(esc);
|
safe_delete_array(esc);
|
||||||
auto results = m_db->QueryDatabase(query);
|
auto results = m_db->QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
@@ -953,7 +953,7 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
|||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
ProcessGuildMember(row, into);
|
ProcessGuildMember(row, into);
|
||||||
LogGuilds("Retreived guild member info for char [{}] from the database", char_name);
|
Log(Logs::Detail, Logs::Guilds, "Retreived guild member info for char %s from the database", char_name);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -962,16 +962,16 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
|||||||
|
|
||||||
bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
||||||
if(m_db == nullptr) {
|
if(m_db == nullptr) {
|
||||||
LogGuilds("Requested char info on [{}] when we have no database object", char_id);
|
Log(Logs::Detail, Logs::Guilds, "Requested char info on %d when we have no database object.", char_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//load up the rank info for each guild.
|
//load up the rank info for each guild.
|
||||||
std::string query;
|
std::string query;
|
||||||
#ifdef BOTS
|
#ifdef BOTS
|
||||||
query = StringFormat(GuildMemberBaseQuery " WHERE c.id=%d AND c.mob_type = 'C' AND c.deleted_at IS NULL", char_id);
|
query = StringFormat(GuildMemberBaseQuery " WHERE c.id=%d AND c.mob_type = 'C'", char_id);
|
||||||
#else
|
#else
|
||||||
query = StringFormat(GuildMemberBaseQuery " WHERE c.id=%d AND c.deleted_at IS NULL", char_id);
|
query = StringFormat(GuildMemberBaseQuery " WHERE c.id=%d", char_id);
|
||||||
#endif
|
#endif
|
||||||
auto results = m_db->QueryDatabase(query);
|
auto results = m_db->QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
@@ -983,7 +983,7 @@ bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
|||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
ProcessGuildMember(row, into);
|
ProcessGuildMember(row, into);
|
||||||
LogGuilds("Retreived guild member info for char [{}]", char_id);
|
Log(Logs::Detail, Logs::Guilds, "Retreived guild member info for char %d", char_id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -1098,16 +1098,16 @@ bool BaseGuildManager::GuildExists(uint32 guild_id) const {
|
|||||||
|
|
||||||
bool BaseGuildManager::IsGuildLeader(uint32 guild_id, uint32 char_id) const {
|
bool BaseGuildManager::IsGuildLeader(uint32 guild_id, uint32 char_id) const {
|
||||||
if(guild_id == GUILD_NONE) {
|
if(guild_id == GUILD_NONE) {
|
||||||
LogGuilds("Check leader for char [{}]: not a guild", char_id);
|
Log(Logs::Detail, Logs::Guilds, "Check leader for char %d: not a guild.", char_id);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
std::map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end()) {
|
if(res == m_guilds.end()) {
|
||||||
LogGuilds("Check leader for char [{}]: invalid guild", char_id);
|
Log(Logs::Detail, Logs::Guilds, "Check leader for char %d: invalid guild.", char_id);
|
||||||
return(false); //invalid guild
|
return(false); //invalid guild
|
||||||
}
|
}
|
||||||
LogGuilds("Check leader for guild [{}], char [{}]: leader id=[{}]", guild_id, char_id, res->second->leader_char_id);
|
Log(Logs::Detail, Logs::Guilds, "Check leader for guild %d, char %d: leader id=%d", guild_id, char_id, res->second->leader_char_id);
|
||||||
return(char_id == res->second->leader_char_id);
|
return(char_id == res->second->leader_char_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1137,20 +1137,20 @@ uint8 BaseGuildManager::GetDisplayedRank(uint32 guild_id, uint8 rank, uint32 cha
|
|||||||
|
|
||||||
bool BaseGuildManager::CheckGMStatus(uint32 guild_id, uint8 status) const {
|
bool BaseGuildManager::CheckGMStatus(uint32 guild_id, uint8 status) const {
|
||||||
if(status >= 250) {
|
if(status >= 250) {
|
||||||
LogGuilds("Check permission on guild [{}] with user status [{}] > 250, granted", guild_id, status);
|
Log(Logs::Detail, Logs::Guilds, "Check permission on guild %d with user status %d > 250, granted.", guild_id, status);
|
||||||
return(true); //250+ as allowed anything
|
return(true); //250+ as allowed anything
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end()) {
|
if(res == m_guilds.end()) {
|
||||||
LogGuilds("Check permission on guild [{}] with user status [{}], no such guild, denied", guild_id, status);
|
Log(Logs::Detail, Logs::Guilds, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status);
|
||||||
return(false); //invalid guild
|
return(false); //invalid guild
|
||||||
}
|
}
|
||||||
|
|
||||||
bool granted = (res->second->minstatus <= status);
|
bool granted = (res->second->minstatus <= status);
|
||||||
|
|
||||||
LogGuilds("Check permission on guild [{}] ([{}]) with user status [{}]. Min status [{}]: [{}]",
|
Log(Logs::Detail, Logs::Guilds, "Check permission on guild %s (%d) with user status %d. Min status %d: %s",
|
||||||
res->second->name.c_str(), guild_id, status, res->second->minstatus, granted?"granted":"denied");
|
res->second->name.c_str(), guild_id, status, res->second->minstatus, granted?"granted":"denied");
|
||||||
|
|
||||||
return(granted);
|
return(granted);
|
||||||
@@ -1158,21 +1158,21 @@ bool BaseGuildManager::CheckGMStatus(uint32 guild_id, uint8 status) const {
|
|||||||
|
|
||||||
bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction act) const {
|
bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction act) const {
|
||||||
if(rank > GUILD_MAX_RANK) {
|
if(rank > GUILD_MAX_RANK) {
|
||||||
LogGuilds("Check permission on guild [{}] and rank [{}] for action [{}] ([{}]): Invalid rank, denied",
|
Log(Logs::Detail, Logs::Guilds, "Check permission on guild %d and rank %d for action %s (%d): Invalid rank, denied.",
|
||||||
guild_id, rank, GuildActionNames[act], act);
|
guild_id, rank, GuildActionNames[act], act);
|
||||||
return(false); //invalid rank
|
return(false); //invalid rank
|
||||||
}
|
}
|
||||||
std::map<uint32, GuildInfo *>::const_iterator res;
|
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||||
res = m_guilds.find(guild_id);
|
res = m_guilds.find(guild_id);
|
||||||
if(res == m_guilds.end()) {
|
if(res == m_guilds.end()) {
|
||||||
LogGuilds("Check permission on guild [{}] and rank [{}] for action [{}] ([{}]): Invalid guild, denied",
|
Log(Logs::Detail, Logs::Guilds, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.",
|
||||||
guild_id, rank, GuildActionNames[act], act);
|
guild_id, rank, GuildActionNames[act], act);
|
||||||
return(false); //invalid guild
|
return(false); //invalid guild
|
||||||
}
|
}
|
||||||
|
|
||||||
bool granted = res->second->ranks[rank].permissions[act];
|
bool granted = res->second->ranks[rank].permissions[act];
|
||||||
|
|
||||||
LogGuilds("Check permission on guild [{}] ([{}]) and rank [{}] ([{}]) for action [{}] ([{}]): [{}]",
|
Log(Logs::Detail, Logs::Guilds, "Check permission on guild %s (%d) and rank %s (%d) for action %s (%d): %s",
|
||||||
res->second->name.c_str(), guild_id,
|
res->second->name.c_str(), guild_id,
|
||||||
res->second->ranks[rank].name.c_str(), rank,
|
res->second->ranks[rank].name.c_str(), rank,
|
||||||
GuildActionNames[act], act,
|
GuildActionNames[act], act,
|
||||||
|
|||||||
+1
-1
@@ -23,6 +23,6 @@
|
|||||||
#include "eq_packet_structs.h"
|
#include "eq_packet_structs.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
#include <netinet/in.h> //for htonl
|
#include <netinet/in.h> //for htonl
|
||||||
#endif
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1381,7 +1381,7 @@ int16 EQEmu::InventoryProfile::_PutItem(int16 slot_id, ItemInstance* inst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result == INVALID_INDEX) {
|
if (result == INVALID_INDEX) {
|
||||||
LogError("InventoryProfile::_PutItem: Invalid slot_id specified ({}) with parent slot id ({})", slot_id, parentSlot);
|
Log(Logs::General, Logs::Error, "InventoryProfile::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot);
|
||||||
InventoryProfile::MarkDirty(inst); // Slot not found, clean up
|
InventoryProfile::MarkDirty(inst); // Slot not found, clean up
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,72 +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 "ip_util.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ip
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
uint32_t IpUtil::IPToUInt(const std::string &ip)
|
|
||||||
{
|
|
||||||
int a, b, c, d;
|
|
||||||
uint32_t addr = 0;
|
|
||||||
|
|
||||||
if (sscanf(ip.c_str(), "%d.%d.%d.%d", &a, &b, &c, &d) != 4) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
addr = a << 24;
|
|
||||||
addr |= b << 16;
|
|
||||||
addr |= c << 8;
|
|
||||||
addr |= d;
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ip
|
|
||||||
* @param network
|
|
||||||
* @param mask
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool IpUtil::IsIpInRange(const std::string &ip, const std::string &network, const std::string &mask)
|
|
||||||
{
|
|
||||||
uint32_t ip_addr = IpUtil::IPToUInt(ip);
|
|
||||||
uint32_t network_addr = IpUtil::IPToUInt(network);
|
|
||||||
uint32_t mask_addr = IpUtil::IPToUInt(mask);
|
|
||||||
|
|
||||||
uint32_t net_lower = (network_addr & mask_addr);
|
|
||||||
uint32_t net_upper = (net_lower | (~mask_addr));
|
|
||||||
|
|
||||||
return ip_addr >= net_lower && ip_addr <= net_upper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ip
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool IpUtil::IsIpInPrivateRfc1918(const std::string &ip)
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
IpUtil::IsIpInRange(ip, "10.0.0.0", "255.0.0.0") ||
|
|
||||||
IpUtil::IsIpInRange(ip, "172.16.0.0", "255.240.0.0") ||
|
|
||||||
IpUtil::IsIpInRange(ip, "192.168.0.0", "255.255.0.0")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ipc_mutex.h"
|
#include "ipc_mutex.h"
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#undef WIN32_LEAN_AND_MEAN
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
namespace EQEmu {
|
namespace EQEmu {
|
||||||
struct IPCMutex::Implementation {
|
struct IPCMutex::Implementation {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
HANDLE mut_;
|
HANDLE mut_;
|
||||||
#else
|
#else
|
||||||
int fd_;
|
int fd_;
|
||||||
@@ -42,7 +42,7 @@ namespace EQEmu {
|
|||||||
|
|
||||||
IPCMutex::IPCMutex(std::string name) : locked_(false) {
|
IPCMutex::IPCMutex(std::string name) : locked_(false) {
|
||||||
imp_ = new Implementation;
|
imp_ = new Implementation;
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
auto Config = EQEmuConfig::get();
|
auto Config = EQEmuConfig::get();
|
||||||
std::string final_name = Config->SharedMemDir + "EQEmuMutex_";
|
std::string final_name = Config->SharedMemDir + "EQEmuMutex_";
|
||||||
final_name += name;
|
final_name += name;
|
||||||
@@ -82,7 +82,7 @@ namespace EQEmu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPCMutex::~IPCMutex() {
|
IPCMutex::~IPCMutex() {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
if(locked_) {
|
if(locked_) {
|
||||||
ReleaseMutex(imp_->mut_);
|
ReleaseMutex(imp_->mut_);
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ namespace EQEmu {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
DWORD wait_result = WaitForSingleObject(imp_->mut_, INFINITE);
|
DWORD wait_result = WaitForSingleObject(imp_->mut_, INFINITE);
|
||||||
if(wait_result != WAIT_OBJECT_0) {
|
if(wait_result != WAIT_OBJECT_0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -121,7 +121,7 @@ namespace EQEmu {
|
|||||||
if(!locked_) {
|
if(!locked_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
if(!ReleaseMutex(imp_->mut_)) {
|
if(!ReleaseMutex(imp_->mut_)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -413,7 +413,7 @@ namespace EQEmu
|
|||||||
int32 SkillModMax; // Max skill point modification
|
int32 SkillModMax; // Max skill point modification
|
||||||
uint32 SkillModType; // Type of skill for SkillModValue to apply to
|
uint32 SkillModType; // Type of skill for SkillModValue to apply to
|
||||||
uint32 BaneDmgRace; // Bane Damage Race
|
uint32 BaneDmgRace; // Bane Damage Race
|
||||||
int32 BaneDmgAmt; // Bane Damage Body Amount
|
int8 BaneDmgAmt; // Bane Damage Body Amount
|
||||||
uint32 BaneDmgBody; // Bane Damage Body
|
uint32 BaneDmgBody; // Bane Damage Body
|
||||||
bool Magic; // True=Magic Item, False=not
|
bool Magic; // True=Magic Item, False=not
|
||||||
int32 CastTime_;
|
int32 CastTime_;
|
||||||
|
|||||||
@@ -5277,7 +5277,7 @@ void StreamWriterBuilder::setDefaults(Json::Value* settings)
|
|||||||
{
|
{
|
||||||
//! [StreamWriterBuilderDefaults]
|
//! [StreamWriterBuilderDefaults]
|
||||||
(*settings)["commentStyle"] = "All";
|
(*settings)["commentStyle"] = "All";
|
||||||
(*settings)["indentation"] = " ";
|
(*settings)["indentation"] = "\t";
|
||||||
(*settings)["enableYAMLCompatibility"] = false;
|
(*settings)["enableYAMLCompatibility"] = false;
|
||||||
(*settings)["dropNullPlaceholders"] = false;
|
(*settings)["dropNullPlaceholders"] = false;
|
||||||
(*settings)["useSpecialFloats"] = false;
|
(*settings)["useSpecialFloats"] = false;
|
||||||
|
|||||||
+17
-89
@@ -1,29 +1,26 @@
|
|||||||
#include "json_config.h"
|
#include "json_config.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
EQ::JsonConfigFile::JsonConfigFile() = default;
|
EQ::JsonConfigFile::JsonConfigFile()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
EQ::JsonConfigFile::JsonConfigFile(const Json::Value &value)
|
EQ::JsonConfigFile::JsonConfigFile(const Json::Value &value)
|
||||||
{
|
{
|
||||||
m_root = value;
|
m_root = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
EQ::JsonConfigFile::~JsonConfigFile() = default;
|
EQ::JsonConfigFile::~JsonConfigFile()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
EQ::JsonConfigFile EQ::JsonConfigFile::Load(const std::string &filename)
|
||||||
* @param file_name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
EQ::JsonConfigFile EQ::JsonConfigFile::Load(
|
|
||||||
const std::string &file_name
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
JsonConfigFile ret;
|
JsonConfigFile ret;
|
||||||
ret.m_root = Json::Value();
|
ret.m_root = Json::Value();
|
||||||
|
|
||||||
std::ifstream ifs;
|
std::ifstream ifs;
|
||||||
ifs.open(file_name, std::ifstream::in);
|
ifs.open(filename, std::ifstream::in);
|
||||||
|
|
||||||
if (!ifs.good()) {
|
if (!ifs.good()) {
|
||||||
return ret;
|
return ret;
|
||||||
@@ -32,128 +29,59 @@ EQ::JsonConfigFile EQ::JsonConfigFile::Load(
|
|||||||
try {
|
try {
|
||||||
ifs >> ret.m_root;
|
ifs >> ret.m_root;
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
std::string EQ::JsonConfigFile::GetVariableString(const std::string &title, const std::string ¶meter, const std::string &default_value) {
|
||||||
* @param file_name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void EQ::JsonConfigFile::Save(
|
|
||||||
const std::string &file_name
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::ofstream opened_config_file;
|
|
||||||
opened_config_file.open(file_name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Grab and build config contents
|
|
||||||
*/
|
|
||||||
Json::StreamWriterBuilder write_builder;
|
|
||||||
write_builder["indentation"] = " ";
|
|
||||||
std::string document = Json::writeString(write_builder, m_root);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write current contents and close
|
|
||||||
*/
|
|
||||||
opened_config_file << document;
|
|
||||||
opened_config_file.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param title
|
|
||||||
* @param parameter
|
|
||||||
* @param default_value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
std::string EQ::JsonConfigFile::GetVariableString(
|
|
||||||
const std::string &title,
|
|
||||||
const std::string ¶meter,
|
|
||||||
const std::string &default_value
|
|
||||||
)
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
if (m_root.isMember(title) && m_root[title].isMember(parameter)) {
|
if (m_root.isMember(title) && m_root[title].isMember(parameter)) {
|
||||||
return m_root[title][parameter].asString();
|
return m_root[title][parameter].asString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
int EQ::JsonConfigFile::GetVariableInt(const std::string &title, const std::string ¶meter, const int default_value) {
|
||||||
* @param title
|
|
||||||
* @param parameter
|
|
||||||
* @param default_value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int EQ::JsonConfigFile::GetVariableInt(
|
|
||||||
const std::string &title,
|
|
||||||
const std::string ¶meter,
|
|
||||||
const int default_value
|
|
||||||
)
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
if (m_root.isMember(title) && m_root[title].isMember(parameter)) {
|
if (m_root.isMember(title) && m_root[title].isMember(parameter)) {
|
||||||
return m_root[title][parameter].asInt();
|
return m_root[title][parameter].asInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
bool EQ::JsonConfigFile::GetVariableBool(const std::string &title, const std::string ¶meter, const bool default_value) {
|
||||||
* @param title
|
|
||||||
* @param parameter
|
|
||||||
* @param default_value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool EQ::JsonConfigFile::GetVariableBool(
|
|
||||||
const std::string &title,
|
|
||||||
const std::string ¶meter,
|
|
||||||
const bool default_value
|
|
||||||
)
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
if (m_root.isMember(title) && m_root[title].isMember(parameter)) {
|
if (m_root.isMember(title) && m_root[title].isMember(parameter)) {
|
||||||
return m_root[title][parameter].asBool();
|
return m_root[title][parameter].asBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
double EQ::JsonConfigFile::GetVariableDouble(const std::string &title, const std::string ¶meter, const double default_value) {
|
||||||
* @param title
|
|
||||||
* @param parameter
|
|
||||||
* @param default_value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
double EQ::JsonConfigFile::GetVariableDouble(
|
|
||||||
const std::string &title,
|
|
||||||
const std::string ¶meter,
|
|
||||||
const double default_value
|
|
||||||
)
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
if (m_root.isMember(title) && m_root[title].isMember(parameter)) {
|
if (m_root.isMember(title) && m_root[title].isMember(parameter)) {
|
||||||
return m_root[title][parameter].asDouble();
|
return m_root[title][parameter].asDouble();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,10 @@ namespace EQ
|
|||||||
class JsonConfigFile
|
class JsonConfigFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JsonConfigFile();
|
|
||||||
JsonConfigFile(const Json::Value &value);
|
JsonConfigFile(const Json::Value &value);
|
||||||
~JsonConfigFile();
|
~JsonConfigFile();
|
||||||
|
|
||||||
static JsonConfigFile Load(const std::string &file_name);
|
static JsonConfigFile Load(const std::string &filename);
|
||||||
void Save(const std::string &file_name);
|
|
||||||
|
|
||||||
std::string GetVariableString(const std::string &title, const std::string ¶meter, const std::string &default_value);
|
std::string GetVariableString(const std::string &title, const std::string ¶meter, const std::string &default_value);
|
||||||
int GetVariableInt(const std::string &title, const std::string ¶meter, const int default_value);
|
int GetVariableInt(const std::string &title, const std::string ¶meter, const int default_value);
|
||||||
@@ -21,6 +19,7 @@ namespace EQ
|
|||||||
|
|
||||||
Json::Value& RawHandle() { return m_root; }
|
Json::Value& RawHandle() { return m_root; }
|
||||||
private:
|
private:
|
||||||
|
JsonConfigFile();
|
||||||
Json::Value m_root;
|
Json::Value m_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -278,6 +278,12 @@ void LinkedListIterator<TYPE>::Replace(const TYPE& new_data)
|
|||||||
template<class TYPE>
|
template<class TYPE>
|
||||||
void LinkedListIterator<TYPE>::Reset()
|
void LinkedListIterator<TYPE>::Reset()
|
||||||
{
|
{
|
||||||
|
if (!(&list))
|
||||||
|
{
|
||||||
|
current_element=0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (dir == FORWARD)
|
if (dir == FORWARD)
|
||||||
{
|
{
|
||||||
current_element = list.first;
|
current_element = list.first;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "memory_mapped_file.h"
|
#include "memory_mapped_file.h"
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
namespace EQEmu {
|
namespace EQEmu {
|
||||||
|
|
||||||
struct MemoryMappedFile::Implementation {
|
struct MemoryMappedFile::Implementation {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
HANDLE mapped_object_;
|
HANDLE mapped_object_;
|
||||||
#else
|
#else
|
||||||
int fd_;
|
int fd_;
|
||||||
@@ -47,7 +47,7 @@ namespace EQEmu {
|
|||||||
: filename_(filename), size_(size) {
|
: filename_(filename), size_(size) {
|
||||||
imp_ = new Implementation;
|
imp_ = new Implementation;
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
DWORD total_size = size + sizeof(shared_memory_struct);
|
DWORD total_size = size + sizeof(shared_memory_struct);
|
||||||
HANDLE file = CreateFile(filename.c_str(),
|
HANDLE file = CreateFile(filename.c_str(),
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
@@ -116,7 +116,7 @@ namespace EQEmu {
|
|||||||
size_ = size;
|
size_ = size;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
DWORD total_size = size + sizeof(shared_memory_struct);
|
DWORD total_size = size + sizeof(shared_memory_struct);
|
||||||
HANDLE file = CreateFile(filename.c_str(),
|
HANDLE file = CreateFile(filename.c_str(),
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
@@ -172,7 +172,7 @@ namespace EQEmu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MemoryMappedFile::~MemoryMappedFile() {
|
MemoryMappedFile::~MemoryMappedFile() {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
if(imp_->mapped_object_) {
|
if(imp_->mapped_object_) {
|
||||||
CloseHandle(imp_->mapped_object_);
|
CloseHandle(imp_->mapped_object_);
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-4
@@ -1,4 +1,4 @@
|
|||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
// VS6 doesn't like the length of STL generated names: disabling
|
// VS6 doesn't like the length of STL generated names: disabling
|
||||||
#pragma warning(disable:4786)
|
#pragma warning(disable:4786)
|
||||||
#endif
|
#endif
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -19,9 +19,12 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#define ENC(c) (((c) & 0x3f) + ' ')
|
||||||
|
#define DEC(c) (((c) - ' ') & 0x3f)
|
||||||
|
|
||||||
std::map<int,std::string> DBFieldNames;
|
std::map<int,std::string> DBFieldNames;
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
#if defined(FREEBSD) || defined(__CYGWIN__)
|
#if defined(FREEBSD) || defined(__CYGWIN__)
|
||||||
int print_stacktrace()
|
int print_stacktrace()
|
||||||
{
|
{
|
||||||
@@ -330,6 +333,64 @@ void LoadItemDBFieldNames() {
|
|||||||
DBFieldNames[113]="unknown115"; // ? (end quote)
|
DBFieldNames[113]="unknown115"; // ? (end quote)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void encode_length(unsigned long length, char *out)
|
||||||
|
{
|
||||||
|
char buf[4];
|
||||||
|
memcpy(buf,&length,sizeof(unsigned long));
|
||||||
|
encode_chunk(buf,3,out);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long encode(char *in, unsigned long length, char *out)
|
||||||
|
{
|
||||||
|
unsigned long used=0,len=0;
|
||||||
|
while(used<length) {
|
||||||
|
encode_chunk(in+used,length-used,out+len);
|
||||||
|
used+=3;
|
||||||
|
len+=4;
|
||||||
|
}
|
||||||
|
*(out+len)=0;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long decode_length(char *in)
|
||||||
|
{
|
||||||
|
int length;
|
||||||
|
char buf[4];
|
||||||
|
decode_chunk(in,&buf[0]);
|
||||||
|
buf[3]=0;
|
||||||
|
memcpy(&length,buf,sizeof(unsigned long));
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
void decode(char *in, char *out)
|
||||||
|
{
|
||||||
|
char *ptr=in;
|
||||||
|
char *outptr=out;
|
||||||
|
while(*ptr) {
|
||||||
|
decode_chunk(ptr,outptr);
|
||||||
|
ptr+=4;
|
||||||
|
outptr+=3;
|
||||||
|
}
|
||||||
|
*outptr=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void encode_chunk(char *in, int len, char *out)
|
||||||
|
{
|
||||||
|
*out=ENC(in[0] >> 2);
|
||||||
|
*(out+1)=ENC((in[0] << 4)|(((len<2 ? 0 : in[1]) >> 4) & 0xF));
|
||||||
|
*(out+2)=ENC(((len<2 ? 0 : in[1]) << 2)|(((len<3 ? 0 : in[2]) >> 6) & 0x3));
|
||||||
|
*(out+3)=ENC((len<3 ? 0 : in[2]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void decode_chunk(char *in, char *out)
|
||||||
|
{
|
||||||
|
*out = DEC(*in) << 2 | DEC(in[1]) >> 4;
|
||||||
|
*(out+1) = DEC(in[1]) << 4 | DEC(in[2]) >> 2;
|
||||||
|
*(out+2) = DEC(in[2]) << 6 | DEC(in[3]);
|
||||||
|
}
|
||||||
|
|
||||||
void dump_message_column(unsigned char *buffer, unsigned long length, std::string leader, FILE *to)
|
void dump_message_column(unsigned char *buffer, unsigned long length, std::string leader, FILE *to)
|
||||||
{
|
{
|
||||||
unsigned long i,j;
|
unsigned long i,j;
|
||||||
@@ -465,7 +526,7 @@ std::string generate_key(int length)
|
|||||||
{
|
{
|
||||||
std::string key;
|
std::string key;
|
||||||
//TODO: write this for win32...
|
//TODO: write this for win32...
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
int i;
|
int i;
|
||||||
timeval now;
|
timeval now;
|
||||||
static const char *chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
static const char *chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
|
|||||||
+8
-1
@@ -17,7 +17,14 @@ int Tokenize(std::string s, std::map<int,std::string> & tokens, char delim='|');
|
|||||||
|
|
||||||
void LoadItemDBFieldNames();
|
void LoadItemDBFieldNames();
|
||||||
|
|
||||||
#ifndef WIN32
|
void encode_length(unsigned long length, char *out);
|
||||||
|
unsigned long decode_length(char *in);
|
||||||
|
unsigned long encode(char *in, unsigned long length, char *out);
|
||||||
|
void decode(char *in, char *out);
|
||||||
|
void encode_chunk(char *in, int len, char *out);
|
||||||
|
void decode_chunk(char *in, char *out);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
int print_stacktrace();
|
int print_stacktrace();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -22,19 +22,19 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
#include "../common/seperator.h"
|
#include "../common/seperator.h"
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
@@ -73,7 +73,7 @@ void CoutTimestamp(bool ms) {
|
|||||||
|
|
||||||
|
|
||||||
int32 filesize(FILE* fp) {
|
int32 filesize(FILE* fp) {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
return _filelength(_fileno(fp));
|
return _filelength(_fileno(fp));
|
||||||
#else
|
#else
|
||||||
struct stat file_stat;
|
struct stat file_stat;
|
||||||
@@ -88,7 +88,7 @@ int32 filesize(FILE* fp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ResolveIP(const char* hostname, char* errbuf) {
|
uint32 ResolveIP(const char* hostname, char* errbuf) {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
static InitWinsock ws;
|
static InitWinsock ws;
|
||||||
#endif
|
#endif
|
||||||
if (errbuf)
|
if (errbuf)
|
||||||
@@ -99,14 +99,14 @@ uint32 ResolveIP(const char* hostname, char* errbuf) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
struct sockaddr_in server_sin;
|
struct sockaddr_in server_sin;
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
PHOSTENT phostent = nullptr;
|
PHOSTENT phostent = nullptr;
|
||||||
#else
|
#else
|
||||||
struct hostent *phostent = nullptr;
|
struct hostent *phostent = nullptr;
|
||||||
#endif
|
#endif
|
||||||
server_sin.sin_family = AF_INET;
|
server_sin.sin_family = AF_INET;
|
||||||
if ((phostent = gethostbyname(hostname)) == nullptr) {
|
if ((phostent = gethostbyname(hostname)) == nullptr) {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
if (errbuf)
|
if (errbuf)
|
||||||
snprintf(errbuf, ERRBUF_SIZE, "Unable to get the host name. Error: %i", WSAGetLastError());
|
snprintf(errbuf, ERRBUF_SIZE, "Unable to get the host name. Error: %i", WSAGetLastError());
|
||||||
#else
|
#else
|
||||||
@@ -115,7 +115,7 @@ uint32 ResolveIP(const char* hostname, char* errbuf) {
|
|||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
memcpy ((char FAR *)&(server_sin.sin_addr), phostent->h_addr, phostent->h_length);
|
memcpy ((char FAR *)&(server_sin.sin_addr), phostent->h_addr, phostent->h_length);
|
||||||
#else
|
#else
|
||||||
memcpy ((char*)&(server_sin.sin_addr), phostent->h_addr, phostent->h_length);
|
memcpy ((char*)&(server_sin.sin_addr), phostent->h_addr, phostent->h_length);
|
||||||
@@ -136,7 +136,7 @@ bool ParseAddress(const char* iAddress, uint32* oIP, uint16* oPort, char* errbuf
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
InitWinsock::InitWinsock() {
|
InitWinsock::InitWinsock() {
|
||||||
WORD version = MAKEWORD (1,1);
|
WORD version = MAKEWORD (1,1);
|
||||||
WSADATA wsadata;
|
WSADATA wsadata;
|
||||||
@@ -157,7 +157,7 @@ const char * itoa(int num) {
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
const char * itoa(int num, char* a,int b) {
|
const char * itoa(int num, char* a,int b) {
|
||||||
static char temp[_ITOA_BUFLEN];
|
static char temp[_ITOA_BUFLEN];
|
||||||
memset(temp,0,_ITOA_BUFLEN);
|
memset(temp,0,_ITOA_BUFLEN);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#define VERIFY_PACKET_LENGTH(OPCode, Packet, StructName) \
|
#define VERIFY_PACKET_LENGTH(OPCode, Packet, StructName) \
|
||||||
if(Packet->size != sizeof(StructName)) \
|
if(Packet->size != sizeof(StructName)) \
|
||||||
{ \
|
{ \
|
||||||
LogNetcode("Size mismatch in " #OPCode " expected [{}] got [{}]", sizeof(StructName), Packet->size); \
|
Log(Logs::Detail, Logs::Netcode, "Size mismatch in " #OPCode " expected %i got %i", sizeof(StructName), Packet->size); \
|
||||||
DumpPacket(Packet); \
|
DumpPacket(Packet); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ uint32 Catch22(uint32 mask);
|
|||||||
|
|
||||||
#define _ITOA_BUFLEN 25
|
#define _ITOA_BUFLEN 25
|
||||||
const char *itoa(int num); //not thread safe
|
const char *itoa(int num); //not thread safe
|
||||||
#ifndef _WINDOWS
|
#ifndef _WIN32
|
||||||
const char *itoa(int num, char* a,int b);
|
const char *itoa(int num, char* a,int b);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
bool IsTryLockSupported();
|
bool IsTryLockSupported();
|
||||||
bool TrylockSupported = IsTryLockSupported();
|
bool TrylockSupported = IsTryLockSupported();
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ Mutex::Mutex() {
|
|||||||
#if DEBUG_MUTEX_CLASS >= 7
|
#if DEBUG_MUTEX_CLASS >= 7
|
||||||
std::cout << "Constructing Mutex" << std::endl;
|
std::cout << "Constructing Mutex" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
InitializeCriticalSection(&CSMutex);
|
InitializeCriticalSection(&CSMutex);
|
||||||
#else
|
#else
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
@@ -85,7 +85,7 @@ Mutex::Mutex() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Mutex::~Mutex() {
|
Mutex::~Mutex() {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
DeleteCriticalSection(&CSMutex);
|
DeleteCriticalSection(&CSMutex);
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
@@ -95,14 +95,14 @@ void Mutex::lock() {
|
|||||||
#if DEBUG_MUTEX_CLASS >= 5
|
#if DEBUG_MUTEX_CLASS >= 5
|
||||||
if (!trylock()) {
|
if (!trylock()) {
|
||||||
std::cout << "Locking Mutex: Having to wait" << std::endl;
|
std::cout << "Locking Mutex: Having to wait" << std::endl;
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
EnterCriticalSection(&CSMutex);
|
EnterCriticalSection(&CSMutex);
|
||||||
#else
|
#else
|
||||||
pthread_mutex_lock(&CSMutex);
|
pthread_mutex_lock(&CSMutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
EnterCriticalSection(&CSMutex);
|
EnterCriticalSection(&CSMutex);
|
||||||
#else
|
#else
|
||||||
pthread_mutex_lock(&CSMutex);
|
pthread_mutex_lock(&CSMutex);
|
||||||
@@ -111,7 +111,7 @@ void Mutex::lock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Mutex::trylock() {
|
bool Mutex::trylock() {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#if(_WIN32_WINNT >= 0x0400)
|
#if(_WIN32_WINNT >= 0x0400)
|
||||||
if (TrylockSupported)
|
if (TrylockSupported)
|
||||||
return TryEnterCriticalSection(&CSMutex);
|
return TryEnterCriticalSection(&CSMutex);
|
||||||
@@ -129,7 +129,7 @@ bool Mutex::trylock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mutex::unlock() {
|
void Mutex::unlock() {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
LeaveCriticalSection(&CSMutex);
|
LeaveCriticalSection(&CSMutex);
|
||||||
#else
|
#else
|
||||||
pthread_mutex_unlock(&CSMutex);
|
pthread_mutex_unlock(&CSMutex);
|
||||||
|
|||||||
+2
-2
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef MYMUTEX_H
|
#ifndef MYMUTEX_H
|
||||||
#define MYMUTEX_H
|
#define MYMUTEX_H
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
bool trylock();
|
bool trylock();
|
||||||
protected:
|
protected:
|
||||||
private:
|
private:
|
||||||
#if defined WIN32 || defined WIN64
|
#if defined _WIN32
|
||||||
CRITICAL_SECTION CSMutex;
|
CRITICAL_SECTION CSMutex;
|
||||||
#else
|
#else
|
||||||
pthread_mutex_t CSMutex;
|
pthread_mutex_t CSMutex;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef MYSQL_REQUEST_RESULT_H
|
#ifndef MYSQL_REQUEST_RESULT_H
|
||||||
#define MYSQL_REQUEST_RESULT_H
|
#define MYSQL_REQUEST_RESULT_H
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef MYSQL_REQUEST_ROW_H
|
#ifndef MYSQL_REQUEST_ROW_H
|
||||||
#define MYSQL_REQUEST_ROW_H
|
#define MYSQL_REQUEST_ROW_H
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -116,21 +116,17 @@ bool EQ::Net::ConsoleServerConnection::SendChannelMessage(const ServerChannelMes
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (scm->chan_num) {
|
switch (scm->chan_num) {
|
||||||
case 4: {
|
|
||||||
if (RuleB(Chat, ServerWideAuction)) {
|
if (RuleB(Chat, ServerWideAuction)) {
|
||||||
|
case 4: {
|
||||||
QueueMessage(fmt::format("{0} auctions, '{1}'", scm->from, scm->message));
|
QueueMessage(fmt::format("{0} auctions, '{1}'", scm->from, scm->message));
|
||||||
break;
|
break;
|
||||||
} else { // I think we want default action in this case?
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 5: {
|
|
||||||
if (RuleB(Chat, ServerWideOOC)) {
|
if (RuleB(Chat, ServerWideOOC)) {
|
||||||
|
case 5: {
|
||||||
QueueMessage(fmt::format("{0} says ooc, '{1}'", scm->from, scm->message));
|
QueueMessage(fmt::format("{0} says ooc, '{1}'", scm->from, scm->message));
|
||||||
break;
|
break;
|
||||||
} else { // I think we want default action in this case?
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ EQ::Net::DaybreakConnectionManager::DaybreakConnectionManager()
|
|||||||
memset(&m_timer, 0, sizeof(uv_timer_t));
|
memset(&m_timer, 0, sizeof(uv_timer_t));
|
||||||
memset(&m_socket, 0, sizeof(uv_udp_t));
|
memset(&m_socket, 0, sizeof(uv_udp_t));
|
||||||
|
|
||||||
Attach(EQ::EventLoop::Get().Handle());
|
Attach(EQ::EventLoop::GetDefault().Handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
EQ::Net::DaybreakConnectionManager::DaybreakConnectionManager(const DaybreakConnectionManagerOptions &opts)
|
EQ::Net::DaybreakConnectionManager::DaybreakConnectionManager(const DaybreakConnectionManagerOptions &opts)
|
||||||
@@ -23,7 +23,7 @@ EQ::Net::DaybreakConnectionManager::DaybreakConnectionManager(const DaybreakConn
|
|||||||
memset(&m_timer, 0, sizeof(uv_timer_t));
|
memset(&m_timer, 0, sizeof(uv_timer_t));
|
||||||
memset(&m_socket, 0, sizeof(uv_udp_t));
|
memset(&m_socket, 0, sizeof(uv_udp_t));
|
||||||
|
|
||||||
Attach(EQ::EventLoop::Get().Handle());
|
Attach(EQ::EventLoop::GetDefault().Handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
EQ::Net::DaybreakConnectionManager::~DaybreakConnectionManager()
|
EQ::Net::DaybreakConnectionManager::~DaybreakConnectionManager()
|
||||||
@@ -399,7 +399,7 @@ void EQ::Net::DaybreakConnection::Process()
|
|||||||
|
|
||||||
ProcessQueue();
|
ProcessQueue();
|
||||||
}
|
}
|
||||||
catch (std::exception &ex) {
|
catch (std::exception ex) {
|
||||||
if (m_owner->m_on_error_message) {
|
if (m_owner->m_on_error_message) {
|
||||||
m_owner->m_on_error_message(fmt::format("Error processing connection: {0}", ex.what()));
|
m_owner->m_on_error_message(fmt::format("Error processing connection: {0}", ex.what()));
|
||||||
}
|
}
|
||||||
@@ -1047,14 +1047,12 @@ void EQ::Net::DaybreakConnection::Compress(Packet &p, size_t offset, size_t leng
|
|||||||
uint8_t new_buffer[2048] = { 0 };
|
uint8_t new_buffer[2048] = { 0 };
|
||||||
uint8_t *buffer = (uint8_t*)p.Data() + offset;
|
uint8_t *buffer = (uint8_t*)p.Data() + offset;
|
||||||
uint32_t new_length = 0;
|
uint32_t new_length = 0;
|
||||||
bool send_uncompressed = true;
|
|
||||||
|
|
||||||
if (length > 30) {
|
if (length > 30) {
|
||||||
new_length = Deflate(buffer, (uint32_t)length, new_buffer + 1, 2048) + 1;
|
new_length = Deflate(buffer, (uint32_t)length, new_buffer + 1, 2048) + 1;
|
||||||
new_buffer[0] = 0x5a;
|
new_buffer[0] = 0x5a;
|
||||||
send_uncompressed = (new_length > length);
|
|
||||||
}
|
}
|
||||||
if (send_uncompressed) {
|
else {
|
||||||
memcpy(new_buffer + 1, buffer, length);
|
memcpy(new_buffer + 1, buffer, length);
|
||||||
new_buffer[0] = 0xa5;
|
new_buffer[0] = 0xa5;
|
||||||
new_length = length + 1;
|
new_length = length + 1;
|
||||||
@@ -1382,7 +1380,7 @@ void EQ::Net::DaybreakConnection::InternalQueuePacket(Packet &p, int stream_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto stream = &m_streams[stream_id];
|
auto stream = &m_streams[stream_id];
|
||||||
auto max_raw_size = m_max_packet_size - m_crc_bytes - DaybreakReliableHeader::size() - 1; // -1 for compress flag
|
auto max_raw_size = m_max_packet_size - m_crc_bytes - DaybreakReliableHeader::size();
|
||||||
size_t length = p.Length();
|
size_t length = p.Length();
|
||||||
if (length > max_raw_size) {
|
if (length > max_raw_size) {
|
||||||
DaybreakReliableFragmentHeader first_header;
|
DaybreakReliableFragmentHeader first_header;
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ namespace EQ
|
|||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_protocol = IPPROTO_TCP;
|
hints.ai_protocol = IPPROTO_TCP;
|
||||||
|
|
||||||
auto loop = EQ::EventLoop::Get().Handle();
|
auto loop = EQ::EventLoop::GetDefault().Handle();
|
||||||
uv_getaddrinfo_t *resolver = new uv_getaddrinfo_t();
|
uv_getaddrinfo_t *resolver = new uv_getaddrinfo_t();
|
||||||
memset(resolver, 0, sizeof(uv_getaddrinfo_t));
|
memset(resolver, 0, sizeof(uv_getaddrinfo_t));
|
||||||
auto port_str = std::to_string(port);
|
auto port_str = std::to_string(port);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "eqstream.h"
|
#include "eqstream.h"
|
||||||
#include "../eqemu_logsys.h"
|
#include "../eqemu_logsys.h"
|
||||||
|
#include "../eqemu_logsys_fmt.h"
|
||||||
|
|
||||||
EQ::Net::EQStreamManager::EQStreamManager(const EQStreamManagerInterfaceOptions &options) : EQStreamManagerInterface(options), m_daybreak(options.daybreak_options)
|
EQ::Net::EQStreamManager::EQStreamManager(const EQStreamManagerInterfaceOptions &options) : EQStreamManagerInterface(options), m_daybreak(options.daybreak_options)
|
||||||
{
|
{
|
||||||
@@ -184,23 +185,23 @@ EQStreamInterface::MatchState EQ::Net::EQStream::CheckSignature(const Signature
|
|||||||
|
|
||||||
if (opcode == sig->first_eq_opcode) {
|
if (opcode == sig->first_eq_opcode) {
|
||||||
if (length == sig->first_length) {
|
if (length == sig->first_length) {
|
||||||
LogF(Logs::General, Logs::Netcode, "[StreamIdentify] {0}:{1}: First opcode matched {2:#x} and length matched {3}",
|
LogF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode matched {2:#x} and length matched {3}",
|
||||||
m_connection->RemoteEndpoint(), m_connection->RemotePort(), sig->first_eq_opcode, length);
|
m_connection->RemoteEndpoint(), m_connection->RemotePort(), sig->first_eq_opcode, length);
|
||||||
return MatchSuccessful;
|
return MatchSuccessful;
|
||||||
}
|
}
|
||||||
else if (length == 0) {
|
else if (length == 0) {
|
||||||
LogF(Logs::General, Logs::Netcode, "[StreamIdentify] {0}:{1}: First opcode matched {2:#x} and length is ignored.",
|
LogF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode matched {2:#x} and length is ignored.",
|
||||||
m_connection->RemoteEndpoint(), m_connection->RemotePort(), sig->first_eq_opcode);
|
m_connection->RemoteEndpoint(), m_connection->RemotePort(), sig->first_eq_opcode);
|
||||||
return MatchSuccessful;
|
return MatchSuccessful;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogF(Logs::General, Logs::Netcode, "[StreamIdentify] {0}:{1}: First opcode matched {2:#x} but length {3} did not match expected {4}",
|
LogF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode matched {2:#x} but length {3} did not match expected {4}",
|
||||||
m_connection->RemoteEndpoint(), m_connection->RemotePort(), sig->first_eq_opcode, length, sig->first_length);
|
m_connection->RemoteEndpoint(), m_connection->RemotePort(), sig->first_eq_opcode, length, sig->first_length);
|
||||||
return MatchFailed;
|
return MatchFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogF(Logs::General, Logs::Netcode, "[StreamIdentify] {0}:{1}: First opcode {1:#x} did not match expected {2:#x}",
|
LogF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode {1:#x} did not match expected {2:#x}",
|
||||||
m_connection->RemoteEndpoint(), m_connection->RemotePort(), opcode, sig->first_eq_opcode);
|
m_connection->RemoteEndpoint(), m_connection->RemotePort(), opcode, sig->first_eq_opcode);
|
||||||
return MatchFailed;
|
return MatchFailed;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-279
@@ -1,279 +1,16 @@
|
|||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
#include "endian.h"
|
#include <fmt/format.h>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
void EQ::Net::Packet::PutInt8(size_t offset, int8_t value)
|
bool EQ::Net::StaticPacket::Resize(size_t new_size)
|
||||||
{
|
{
|
||||||
if (Length() < offset + 1) {
|
if (new_size > _max_len) {
|
||||||
if (!Resize(offset + 1)) {
|
return false;
|
||||||
throw std::out_of_range("Packet::PutInt8(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*(int8_t*)((char*)Data() + offset) = value;
|
_len = new_size;
|
||||||
}
|
return true;
|
||||||
|
|
||||||
void EQ::Net::Packet::PutInt16(size_t offset, int16_t value)
|
|
||||||
{
|
|
||||||
if (Length() < offset + 2) {
|
|
||||||
if (!Resize(offset + 2)) {
|
|
||||||
throw std::out_of_range("Packet::PutInt16(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*(int16_t*)((char*)Data() + offset) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutInt32(size_t offset, int32_t value)
|
|
||||||
{
|
|
||||||
if (Length() < offset + 4) {
|
|
||||||
if (!Resize(offset + 4)) {
|
|
||||||
throw std::out_of_range("Packet::PutInt32(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*(int32_t*)((char*)Data() + offset) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutInt64(size_t offset, int64_t value)
|
|
||||||
{
|
|
||||||
if (Length() < offset + 8) {
|
|
||||||
if (!Resize(offset + 8)) {
|
|
||||||
throw std::out_of_range("Packet::PutInt64(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*(int64_t*)((char*)Data() + offset) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutUInt8(size_t offset, uint8_t value)
|
|
||||||
{
|
|
||||||
if (Length() < offset + 1) {
|
|
||||||
if (!Resize(offset + 1)) {
|
|
||||||
throw std::out_of_range("Packet::PutUInt8(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*(uint8_t*)((char*)Data() + offset) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutUInt16(size_t offset, uint16_t value)
|
|
||||||
{
|
|
||||||
if (Length() < offset + 2) {
|
|
||||||
if (!Resize(offset + 2)) {
|
|
||||||
throw std::out_of_range("Packet::PutUInt16(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*(uint16_t*)((char*)Data() + offset) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutUInt32(size_t offset, uint32_t value)
|
|
||||||
{
|
|
||||||
if (Length() < offset + 4) {
|
|
||||||
if (!Resize(offset + 4)) {
|
|
||||||
throw std::out_of_range("Packet::PutUInt32(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*(uint32_t*)((char*)Data() + offset) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutUInt64(size_t offset, uint64_t value)
|
|
||||||
{
|
|
||||||
if (Length() < offset + 8) {
|
|
||||||
if (!Resize(offset + 8)) {
|
|
||||||
throw std::out_of_range("Packet::PutUInt64(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*(uint64_t*)((char*)Data() + offset) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutFloat(size_t offset, float value)
|
|
||||||
{
|
|
||||||
if (Length() < offset + 4) {
|
|
||||||
if (!Resize(offset + 4)) {
|
|
||||||
throw std::out_of_range("Packet::PutFloat(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*(float*)((char*)Data() + offset) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutDouble(size_t offset, double value)
|
|
||||||
{
|
|
||||||
if (Length() < offset + 8) {
|
|
||||||
if (!Resize(offset + 8)) {
|
|
||||||
throw std::out_of_range("Packet::PutDouble(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*(double*)((char*)Data() + offset) = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutString(size_t offset, const std::string &str)
|
|
||||||
{
|
|
||||||
if (Length() < offset + str.length()) {
|
|
||||||
if (!Resize(offset + str.length())) {
|
|
||||||
throw std::out_of_range("Packet::PutString(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(((char*)Data() + offset), str.c_str(), str.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutCString(size_t offset, const char *str)
|
|
||||||
{
|
|
||||||
size_t sz = strlen(str);
|
|
||||||
if (Length() < offset + sz + 1) {
|
|
||||||
if (!Resize(offset + sz + 1)) {
|
|
||||||
throw std::out_of_range("Packet::PutCString(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(((char*)Data() + offset), str, sz);
|
|
||||||
*((char*)Data() + offset + sz) = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutPacket(size_t offset, const Packet &p)
|
|
||||||
{
|
|
||||||
if (p.Length() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Length() < offset + p.Length()) {
|
|
||||||
if (!Resize(offset + p.Length())) {
|
|
||||||
throw std::out_of_range("Packet::PutPacket(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(((char*)Data() + offset), p.Data(), p.Length());
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::Net::Packet::PutData(size_t offset, void *data, size_t length)
|
|
||||||
{
|
|
||||||
if (length == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Length() < offset + length) {
|
|
||||||
if (!Resize(offset + length)) {
|
|
||||||
throw std::out_of_range("Packet::PutData(), could not resize packet and would of written past the end.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(((char*)Data() + offset), data, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t EQ::Net::Packet::GetInt8(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 1) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(int8_t*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t EQ::Net::Packet::GetInt16(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 2) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(int16_t*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t EQ::Net::Packet::GetInt32(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 4) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(int32_t*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t EQ::Net::Packet::GetInt64(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 8) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(int64_t*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t EQ::Net::Packet::GetUInt8(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 1) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(uint8_t*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t EQ::Net::Packet::GetUInt16(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 2) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(uint16_t*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t EQ::Net::Packet::GetUInt32(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 4) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(uint32_t*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t EQ::Net::Packet::GetUInt64(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 8) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(uint64_t*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
float EQ::Net::Packet::GetFloat(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 4) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(float*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
double EQ::Net::Packet::GetDouble(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 8) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(double*)((char*)Data() + offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string EQ::Net::Packet::GetString(size_t offset, size_t length) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + length) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::string((char*)Data() + offset, (char*)Data() + offset + length);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string EQ::Net::Packet::GetCString(size_t offset) const
|
|
||||||
{
|
|
||||||
if (Length() < offset + 1) {
|
|
||||||
throw std::out_of_range("Packet read out of range.");
|
|
||||||
}
|
|
||||||
|
|
||||||
char *str = ((char*)Data() + offset);
|
|
||||||
return std::string(str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char ToSafePrint(unsigned char in) {
|
char ToSafePrint(unsigned char in) {
|
||||||
@@ -342,13 +79,3 @@ std::string EQ::Net::Packet::ToString(size_t line_length) const
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EQ::Net::StaticPacket::Resize(size_t new_size)
|
|
||||||
{
|
|
||||||
if (new_size > m_max_data_length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_data_length = new_size;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|||||||
+692
-68
@@ -13,8 +13,7 @@ namespace EQ {
|
|||||||
class Packet
|
class Packet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Packet() : m_stream(std::ios::out | std::ios::binary) { }
|
Packet() = default;
|
||||||
virtual ~Packet() { }
|
|
||||||
|
|
||||||
virtual const void *Data() const = 0;
|
virtual const void *Data() const = 0;
|
||||||
virtual void *Data() = 0;
|
virtual void *Data() = 0;
|
||||||
@@ -24,6 +23,617 @@ namespace EQ {
|
|||||||
virtual bool Resize(size_t new_size) = 0;
|
virtual bool Resize(size_t new_size) = 0;
|
||||||
virtual void Reserve(size_t new_size) = 0;
|
virtual void Reserve(size_t new_size) = 0;
|
||||||
|
|
||||||
|
std::string ToString() const;
|
||||||
|
std::string ToString(size_t line_length) const;
|
||||||
|
|
||||||
|
void SetWritePos(size_t offset) { _wpos = offset; }
|
||||||
|
void SetReadPos(size_t offset) { _rpos = offset; }
|
||||||
|
|
||||||
|
//Position Independent Output Interface
|
||||||
|
void PutInt8(size_t offset, int8_t value) {
|
||||||
|
if (Length() < offset + sizeof(int8_t)) {
|
||||||
|
if (!Resize(offset + sizeof(int8_t))) {
|
||||||
|
throw std::out_of_range("Packet::PutInt8(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<int8_t*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(int8_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutInt16(size_t offset, int16_t value) {
|
||||||
|
if (Length() < offset + sizeof(int16_t)) {
|
||||||
|
if (!Resize(offset + sizeof(int16_t))) {
|
||||||
|
throw std::out_of_range("Packet::PutInt16(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<int16_t*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(int16_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutInt32(size_t offset, int32_t value) {
|
||||||
|
if (Length() < offset + sizeof(int32_t)) {
|
||||||
|
if (!Resize(offset + sizeof(int32_t))) {
|
||||||
|
throw std::out_of_range("Packet::PutInt32(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<int32_t*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(int32_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutInt64(size_t offset, int64_t value) {
|
||||||
|
if (Length() < offset + sizeof(int64_t)) {
|
||||||
|
if (!Resize(offset + sizeof(int64_t))) {
|
||||||
|
throw std::out_of_range("Packet::PutInt64(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<int64_t*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(int64_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutUInt8(size_t offset, uint8_t value) {
|
||||||
|
if (Length() < offset + sizeof(uint8_t)) {
|
||||||
|
if (!Resize(offset + sizeof(uint8_t))) {
|
||||||
|
throw std::out_of_range("Packet::PutUInt8(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<uint8_t*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(uint8_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutUInt16(size_t offset, uint16_t value) {
|
||||||
|
if (Length() < offset + sizeof(uint16_t)) {
|
||||||
|
if (!Resize(offset + sizeof(uint16_t))) {
|
||||||
|
throw std::out_of_range("Packet::PutUInt16(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<uint16_t*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(uint16_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutUInt32(size_t offset, uint32_t value) {
|
||||||
|
if (Length() < offset + sizeof(uint32_t)) {
|
||||||
|
if (!Resize(offset + sizeof(uint32_t))) {
|
||||||
|
throw std::out_of_range("Packet::PutUInt32(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<uint32_t*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(uint32_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutUInt64(size_t offset, uint64_t value) {
|
||||||
|
if (Length() < offset + sizeof(uint64_t)) {
|
||||||
|
if (!Resize(offset + sizeof(uint64_t))) {
|
||||||
|
throw std::out_of_range("Packet::PutUInt64(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<uint64_t*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(uint64_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutFloat(size_t offset, float value) {
|
||||||
|
if (Length() < offset + sizeof(float)) {
|
||||||
|
if (!Resize(offset + sizeof(float))) {
|
||||||
|
throw std::out_of_range("Packet::PutFloat(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<float*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(float);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutDouble(size_t offset, double value) {
|
||||||
|
if (Length() < offset + sizeof(double)) {
|
||||||
|
if (!Resize(offset + sizeof(double))) {
|
||||||
|
throw std::out_of_range("Packet::PutDouble(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*reinterpret_cast<double*>(static_cast<char*>(Data()) + offset) = value;
|
||||||
|
_wpos = offset + sizeof(double);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutString(size_t offset, const std::string &str) {
|
||||||
|
if (Length() < offset + str.length()) {
|
||||||
|
if (!Resize(offset + str.length())) {
|
||||||
|
throw std::out_of_range("Packet::PutString(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::memcpy((static_cast<char*>(Data()) + offset), str.c_str(), str.length());
|
||||||
|
_wpos = offset + str.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutCString(size_t offset, const char *str) {
|
||||||
|
size_t sz = strlen(str);
|
||||||
|
if (Length() < offset + sz + sizeof(int8_t)) {
|
||||||
|
if (!Resize(offset + sz + sizeof(int8_t))) {
|
||||||
|
throw std::out_of_range("Packet::PutCString(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::memcpy((static_cast<char*>(Data()) + offset), str, sz);
|
||||||
|
*(static_cast<char*>(Data()) + offset + sz) = 0;
|
||||||
|
_wpos = offset + sz + sizeof(int8_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutPacket(size_t offset, const Packet &p) {
|
||||||
|
if (p.Length() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Length() < offset + p.Length()) {
|
||||||
|
if (!Resize(offset + p.Length())) {
|
||||||
|
throw std::out_of_range("Packet::PutPacket(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::memcpy((static_cast<char*>(Data()) + offset), p.Data(), p.Length());
|
||||||
|
_wpos = offset + p.Length();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutData(size_t offset, void *data, size_t length) {
|
||||||
|
if (length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Length() < offset + length) {
|
||||||
|
if (!Resize(offset + length)) {
|
||||||
|
throw std::out_of_range("Packet::PutData(), could not resize packet and would of written past the end.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::memcpy((static_cast<char*>(Data()) + offset), data, length);
|
||||||
|
_wpos = offset + length;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Position Dependent Output Interface
|
||||||
|
void PutInt8(int8_t value) {
|
||||||
|
PutInt8(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutInt16(int16_t value) {
|
||||||
|
PutInt16(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutInt32(int32_t value) {
|
||||||
|
PutInt32(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutInt64(int64_t value) {
|
||||||
|
PutInt64(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutUInt8(uint8_t value) {
|
||||||
|
PutUInt8(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutUInt16(uint16_t value) {
|
||||||
|
PutUInt16(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutUInt32(uint32_t value) {
|
||||||
|
PutUInt32(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutUInt64(uint64_t value) {
|
||||||
|
PutUInt64(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutFloat(float value) {
|
||||||
|
PutFloat(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutDouble(double value) {
|
||||||
|
PutDouble(_wpos, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutString(const std::string &str) {
|
||||||
|
PutString(_wpos, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutCString(const char *str) {
|
||||||
|
PutCString(_wpos, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutPacket(const Packet &p) {
|
||||||
|
PutPacket(_wpos, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PutData(void *data, size_t length) {
|
||||||
|
PutData(_wpos, data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Position Independent Input Interface
|
||||||
|
int8_t GetInt8(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(int8_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const int8_t*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t GetInt16(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(int16_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const int16_t*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t GetInt32(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(int32_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const int32_t*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t GetInt64(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(int64_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const int64_t*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t GetUInt8(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(uint8_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const uint8_t*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t GetUInt16(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(uint16_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const uint16_t*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t GetUInt32(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(uint32_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const uint32_t*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t GetUInt64(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(uint64_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const uint64_t*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetFloat(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(float)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const float*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
double GetDouble(size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(double)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const double*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetString(size_t offset, size_t length) const {
|
||||||
|
if (Length() < offset + length) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(reinterpret_cast<const int8_t*>(Data()) + offset, reinterpret_cast<const int8_t*>(Data()) + offset + length);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetCString(size_t offset) const {
|
||||||
|
if (Length() < offset) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sz = strlen(static_cast<const char*>(Data()));
|
||||||
|
|
||||||
|
if (Length() < offset + sz + sizeof(int8_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *str = reinterpret_cast<const char*>(reinterpret_cast<const int8_t*>(Data()) + offset);
|
||||||
|
return std::string(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Position Dependent Input Interface
|
||||||
|
int8_t GetInt8() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(int8_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(int8_t);
|
||||||
|
return *reinterpret_cast<int8_t*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t GetInt16() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(int16_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(int16_t);
|
||||||
|
return *reinterpret_cast<int16_t*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t GetInt32() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(int32_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(int32_t);
|
||||||
|
return *reinterpret_cast<int32_t*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t GetInt64() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(int64_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(int64_t);
|
||||||
|
return *reinterpret_cast<int64_t*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t GetUInt8() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(uint8_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(uint8_t);
|
||||||
|
return *reinterpret_cast<uint8_t*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t GetUInt16() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(uint16_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(uint16_t);
|
||||||
|
return *reinterpret_cast<uint16_t*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t GetUInt32() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(uint32_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(uint32_t);
|
||||||
|
return *reinterpret_cast<uint32_t*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t GetUInt64() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(uint64_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(uint64_t);
|
||||||
|
return *reinterpret_cast<uint64_t*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetFloat() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(float)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(float);
|
||||||
|
return *reinterpret_cast<float*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
double GetDouble() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(double)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sizeof(double);
|
||||||
|
return *reinterpret_cast<double*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetString(size_t length) {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + length) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + length;
|
||||||
|
return std::string(static_cast<char*>(Data()) + offset, static_cast<char*>(Data()) + offset + length);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetCString() {
|
||||||
|
auto offset = _rpos;
|
||||||
|
|
||||||
|
if (Length() < offset + sizeof(int8_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sz = strlen(static_cast<const char*>(Data()));
|
||||||
|
|
||||||
|
if (Length() < offset + sz + sizeof(int8_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_rpos = offset + sz + sizeof(int8_t);
|
||||||
|
char *str = (static_cast<char*>(Data()) + offset);
|
||||||
|
return std::string(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t& operator[](size_t offset) {
|
||||||
|
if (Length() < offset + sizeof(int8_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<int8_t*>(static_cast<char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int8_t& operator[](size_t offset) const {
|
||||||
|
if (Length() < offset + sizeof(int8_t)) {
|
||||||
|
throw std::out_of_range("Packet read out of range.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<const int8_t*>(static_cast<const char*>(Data()) + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Stream Output Interface
|
||||||
|
Packet &operator<<(int8_t v) {
|
||||||
|
PutInt8(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(int16_t v) {
|
||||||
|
PutInt16(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(int32_t v) {
|
||||||
|
PutInt32(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(int64_t v) {
|
||||||
|
PutInt64(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(uint8_t v) {
|
||||||
|
PutUInt8(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(uint16_t v) {
|
||||||
|
PutUInt16(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(uint32_t v) {
|
||||||
|
PutUInt32(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(uint64_t v) {
|
||||||
|
PutUInt64(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(float v) {
|
||||||
|
PutFloat(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(double v) {
|
||||||
|
PutDouble(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(const std::string &v) {
|
||||||
|
PutString(v.data());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(const char *v) {
|
||||||
|
PutCString(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator<<(const Packet &v) {
|
||||||
|
PutPacket(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Stream Input Interface
|
||||||
|
Packet &operator>>(int8_t &v) {
|
||||||
|
v = GetInt8();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(int16_t &v) {
|
||||||
|
v = GetInt16();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(int32_t &v) {
|
||||||
|
v = GetInt32();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(int64_t &v) {
|
||||||
|
v = GetInt64();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(uint8_t &v) {
|
||||||
|
v = GetUInt8();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(uint16_t &v) {
|
||||||
|
v = GetUInt16();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(uint32_t &v) {
|
||||||
|
v = GetUInt32();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(uint64_t &v) {
|
||||||
|
v = GetUInt64();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(float &v) {
|
||||||
|
v = GetFloat();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(double &v) {
|
||||||
|
v = GetDouble();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet &operator>>(std::string &v) {
|
||||||
|
v = GetCString();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seriliazation
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T GetSerialize(size_t offset) const
|
T GetSerialize(size_t offset) const
|
||||||
{
|
{
|
||||||
@@ -36,11 +646,12 @@ namespace EQ {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void PutSerialize(size_t offset, const T &value) {
|
void PutSerialize(size_t offset, const T &value) {
|
||||||
m_stream.clear();
|
std::stringstream stream;
|
||||||
cereal::BinaryOutputArchive output(m_stream);
|
|
||||||
|
cereal::BinaryOutputArchive output(stream);
|
||||||
output(value);
|
output(value);
|
||||||
|
|
||||||
auto str = m_stream.str();
|
auto str = stream.str();
|
||||||
if (Length() < offset + str.length()) {
|
if (Length() < offset + str.length()) {
|
||||||
if (!Resize(offset + str.length())) {
|
if (!Resize(offset + str.length())) {
|
||||||
throw std::out_of_range("Packet::PutSerialize(), could not resize packet and would of written past the end.");
|
throw std::out_of_range("Packet::PutSerialize(), could not resize packet and would of written past the end.");
|
||||||
@@ -49,82 +660,95 @@ namespace EQ {
|
|||||||
|
|
||||||
memcpy((char*)Data() + offset, &str[0], str.length());
|
memcpy((char*)Data() + offset, &str[0], str.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PutInt8(size_t offset, int8_t value);
|
|
||||||
void PutInt16(size_t offset, int16_t value);
|
|
||||||
void PutInt32(size_t offset, int32_t value);
|
|
||||||
void PutInt64(size_t offset, int64_t value);
|
|
||||||
void PutUInt8(size_t offset, uint8_t value);
|
|
||||||
void PutUInt16(size_t offset, uint16_t value);
|
|
||||||
void PutUInt32(size_t offset, uint32_t value);
|
|
||||||
void PutUInt64(size_t offset, uint64_t value);
|
|
||||||
void PutFloat(size_t offset, float value);
|
|
||||||
void PutDouble(size_t offset, double value);
|
|
||||||
void PutString(size_t offset, const std::string &str);
|
|
||||||
void PutCString(size_t offset, const char *str);
|
|
||||||
void PutPacket(size_t offset, const Packet &p);
|
|
||||||
void PutData(size_t offset, void *data, size_t length);
|
|
||||||
|
|
||||||
int8_t GetInt8(size_t offset) const;
|
|
||||||
int16_t GetInt16(size_t offset) const;
|
|
||||||
int32_t GetInt32(size_t offset) const;
|
|
||||||
int64_t GetInt64(size_t offset) const;
|
|
||||||
uint8_t GetUInt8(size_t offset) const;
|
|
||||||
uint16_t GetUInt16(size_t offset) const;
|
|
||||||
uint32_t GetUInt32(size_t offset) const;
|
|
||||||
uint64_t GetUInt64(size_t offset) const;
|
|
||||||
float GetFloat(size_t offset) const;
|
|
||||||
double GetDouble(size_t offset) const;
|
|
||||||
std::string GetString(size_t offset, size_t length) const;
|
|
||||||
std::string GetCString(size_t offset) const;
|
|
||||||
|
|
||||||
std::string ToString() const;
|
|
||||||
std::string ToString(size_t line_length) const;
|
|
||||||
protected:
|
protected:
|
||||||
std::stringstream m_stream;
|
size_t _rpos{ 0 };
|
||||||
|
size_t _wpos{ 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class StaticPacket : public Packet
|
class StaticPacket : public Packet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StaticPacket(void *data, size_t size) { m_data = data; m_data_length = size; m_max_data_length = size; }
|
StaticPacket(void *data, size_t len) : _data(data), _len(len), _max_len(len) {
|
||||||
virtual ~StaticPacket() { }
|
}
|
||||||
StaticPacket(const StaticPacket &o) { m_data = o.m_data; m_data_length = o.m_data_length; m_max_data_length = o.m_max_data_length; }
|
|
||||||
StaticPacket& operator=(const StaticPacket &o) { m_data = o.m_data; m_data_length = o.m_data_length; return *this; }
|
|
||||||
StaticPacket(StaticPacket &&o) noexcept { m_data = o.m_data; m_data_length = o.m_data_length; }
|
|
||||||
|
|
||||||
virtual const void *Data() const { return m_data; }
|
StaticPacket(const StaticPacket &o) : _data(o._data), _len(o._len), _max_len(o._max_len) {
|
||||||
virtual void *Data() { return m_data; }
|
_rpos = o._rpos;
|
||||||
virtual size_t Length() const { return m_data_length; }
|
_wpos = o._wpos;
|
||||||
virtual size_t Length() { return m_data_length; }
|
}
|
||||||
virtual bool Clear() { return false; }
|
|
||||||
virtual bool Resize(size_t new_size);
|
StaticPacket& operator=(const StaticPacket& o) {
|
||||||
virtual void Reserve(size_t new_size) { }
|
_data = o._data;
|
||||||
|
_len = o._len;
|
||||||
|
_max_len = o._max_len;
|
||||||
|
_rpos = o._rpos;
|
||||||
|
_wpos = o._wpos;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
StaticPacket(StaticPacket &&o) noexcept : _data(o._data), _len(o._len), _max_len(o._max_len) {
|
||||||
|
_rpos = o._rpos;
|
||||||
|
_wpos = o._wpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void *Data() const override { return _data; }
|
||||||
|
void *Data() override { return _data; }
|
||||||
|
size_t Length() const override { return _len; }
|
||||||
|
size_t Length() override { return _len; }
|
||||||
|
bool Clear() override { return false; }
|
||||||
|
bool Resize(size_t new_size) override;
|
||||||
|
void Reserve(size_t new_size) override { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void *m_data;
|
void *_data;
|
||||||
size_t m_data_length;
|
size_t _len;
|
||||||
size_t m_max_data_length;
|
size_t _max_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DynamicPacket : public Packet
|
class DynamicPacket : public Packet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DynamicPacket() { }
|
const static size_t DefaultSize = 4096;
|
||||||
virtual ~DynamicPacket() { }
|
|
||||||
DynamicPacket(DynamicPacket &&o) noexcept { m_data = std::move(o.m_data); }
|
|
||||||
DynamicPacket(const DynamicPacket &o) { m_data = o.m_data; }
|
|
||||||
DynamicPacket& operator=(const DynamicPacket &o) { m_data = o.m_data; return *this; }
|
|
||||||
|
|
||||||
virtual const void *Data() const { return &m_data[0]; }
|
DynamicPacket() {
|
||||||
virtual void *Data() { return &m_data[0]; }
|
_data.reserve(DefaultSize);
|
||||||
virtual size_t Length() const { return m_data.size(); }
|
|
||||||
virtual size_t Length() { return m_data.size(); }
|
|
||||||
virtual bool Clear() { m_data.clear(); return true; }
|
|
||||||
virtual bool Resize(size_t new_size) { m_data.resize(new_size, 0); return true; }
|
|
||||||
virtual void Reserve(size_t new_size) { m_data.reserve(new_size); }
|
|
||||||
protected:
|
|
||||||
std::vector<char> m_data;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
DynamicPacket(size_t size) {
|
||||||
|
_data.reserve(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicPacket(const DynamicPacket& o) : _data(o._data) {
|
||||||
|
_rpos = o._rpos;
|
||||||
|
_wpos = o._wpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicPacket& operator=(const DynamicPacket& o) {
|
||||||
|
_data = o._data;
|
||||||
|
_rpos = o._rpos;
|
||||||
|
_wpos = o._wpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicPacket(DynamicPacket &&o) noexcept : _data(o.MoveData()) {
|
||||||
|
_rpos = o._rpos;
|
||||||
|
_wpos = o._wpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int8_t>&& MoveData() {
|
||||||
|
_rpos = 0;
|
||||||
|
_wpos = 0;
|
||||||
|
return std::move(_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
const void *Data() const override { return _data.data(); }
|
||||||
|
void *Data() override { return _data.data(); }
|
||||||
|
size_t Length() const override { return _data.size(); }
|
||||||
|
size_t Length() override { return _data.size(); }
|
||||||
|
bool Clear() override { _data.clear(); return true; }
|
||||||
|
bool Resize(size_t new_size) override { _data.resize(new_size); return true; }
|
||||||
|
void Reserve(size_t new_size) override { _data.reserve(new_size); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::vector<int8_t> _data;
|
||||||
|
};
|
||||||
|
} // namespace Net
|
||||||
|
} // namespace EQ
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "servertalk_client_connection.h"
|
#include "servertalk_client_connection.h"
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "../eqemu_logsys.h"
|
#include "../eqemu_logsys.h"
|
||||||
|
#include "../eqemu_logsys_fmt.h"
|
||||||
|
|
||||||
EQ::Net::ServertalkClient::ServertalkClient(const std::string &addr, int port, bool ipv6, const std::string &identifier, const std::string &credentials)
|
EQ::Net::ServertalkClient::ServertalkClient(const std::string &addr, int port, bool ipv6, const std::string &identifier, const std::string &credentials)
|
||||||
: m_timer(std::unique_ptr<EQ::Timer>(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkClient::Connect, this))))
|
: m_timer(std::unique_ptr<EQ::Timer>(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkClient::Connect, this))))
|
||||||
@@ -78,15 +79,15 @@ void EQ::Net::ServertalkClient::Connect()
|
|||||||
m_connecting = true;
|
m_connecting = true;
|
||||||
EQ::Net::TCPConnection::Connect(m_addr, m_port, false, [this](std::shared_ptr<EQ::Net::TCPConnection> connection) {
|
EQ::Net::TCPConnection::Connect(m_addr, m_port, false, [this](std::shared_ptr<EQ::Net::TCPConnection> connection) {
|
||||||
if (connection == nullptr) {
|
if (connection == nullptr) {
|
||||||
LogF(Logs::General, Logs::TCPConnection, "Error connecting to {0}:{1}, attempting to reconnect...", m_addr, m_port);
|
LogF(Logs::General, Logs::TCP_Connection, "Error connecting to {0}:{1}, attempting to reconnect...", m_addr, m_port);
|
||||||
m_connecting = false;
|
m_connecting = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogF(Logs::General, Logs::TCPConnection, "Connected to {0}:{1}", m_addr, m_port);
|
LogF(Logs::General, Logs::TCP_Connection, "Connected to {0}:{1}", m_addr, m_port);
|
||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
m_connection->OnDisconnect([this](EQ::Net::TCPConnection *c) {
|
m_connection->OnDisconnect([this](EQ::Net::TCPConnection *c) {
|
||||||
LogF(Logs::General, Logs::TCPConnection, "Connection lost to {0}:{1}, attempting to reconnect...", m_addr, m_port);
|
LogF(Logs::General, Logs::TCP_Connection, "Connection lost to {0}:{1}, attempting to reconnect...", m_addr, m_port);
|
||||||
m_encrypted = false;
|
m_encrypted = false;
|
||||||
m_connection.reset();
|
m_connection.reset();
|
||||||
});
|
});
|
||||||
@@ -213,7 +214,7 @@ void EQ::Net::ServertalkClient::ProcessHello(EQ::Net::Packet &p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogError("Could not process hello, size != {0}", 1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES);
|
LogF(Logs::General, Logs::Error, "Could not process hello, size != {0}", 1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -225,7 +226,7 @@ void EQ::Net::ServertalkClient::ProcessHello(EQ::Net::Packet &p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &ex) {
|
catch (std::exception &ex) {
|
||||||
LogError("Error parsing hello from server: {0}", ex.what());
|
LogF(Logs::General, Logs::Error, "Error parsing hello from server: {0}", ex.what());
|
||||||
m_connection->Disconnect();
|
m_connection->Disconnect();
|
||||||
|
|
||||||
if (m_on_connect_cb) {
|
if (m_on_connect_cb) {
|
||||||
@@ -252,7 +253,7 @@ void EQ::Net::ServertalkClient::ProcessHello(EQ::Net::Packet &p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &ex) {
|
catch (std::exception &ex) {
|
||||||
LogError("Error parsing hello from server: {0}", ex.what());
|
LogF(Logs::General, Logs::Error, "Error parsing hello from server: {0}", ex.what());
|
||||||
m_connection->Disconnect();
|
m_connection->Disconnect();
|
||||||
|
|
||||||
if (m_on_connect_cb) {
|
if (m_on_connect_cb) {
|
||||||
@@ -275,7 +276,7 @@ void EQ::Net::ServertalkClient::ProcessMessage(EQ::Net::Packet &p)
|
|||||||
std::unique_ptr<unsigned char[]> decrypted_text(new unsigned char[message_len]);
|
std::unique_ptr<unsigned char[]> decrypted_text(new unsigned char[message_len]);
|
||||||
if (crypto_box_open_easy_afternm(&decrypted_text[0], (unsigned char*)&data[0], length, m_nonce_theirs, m_shared_key))
|
if (crypto_box_open_easy_afternm(&decrypted_text[0], (unsigned char*)&data[0], length, m_nonce_theirs, m_shared_key))
|
||||||
{
|
{
|
||||||
LogError("Error decrypting message from server");
|
LogF(Logs::General, Logs::Error, "Error decrypting message from server");
|
||||||
(*(uint64_t*)&m_nonce_theirs[0])++;
|
(*(uint64_t*)&m_nonce_theirs[0])++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -323,7 +324,7 @@ void EQ::Net::ServertalkClient::ProcessMessage(EQ::Net::Packet &p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &ex) {
|
catch (std::exception &ex) {
|
||||||
LogError("Error parsing message from server: {0}", ex.what());
|
LogF(Logs::General, Logs::Error, "Error parsing message from server: {0}", ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "servertalk_legacy_client_connection.h"
|
#include "servertalk_legacy_client_connection.h"
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "../eqemu_logsys.h"
|
#include "../eqemu_logsys.h"
|
||||||
|
#include "../eqemu_logsys_fmt.h"
|
||||||
|
|
||||||
EQ::Net::ServertalkLegacyClient::ServertalkLegacyClient(const std::string &addr, int port, bool ipv6)
|
EQ::Net::ServertalkLegacyClient::ServertalkLegacyClient(const std::string &addr, int port, bool ipv6)
|
||||||
: m_timer(std::unique_ptr<EQ::Timer>(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkLegacyClient::Connect, this))))
|
: m_timer(std::unique_ptr<EQ::Timer>(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkLegacyClient::Connect, this))))
|
||||||
@@ -58,15 +59,15 @@ void EQ::Net::ServertalkLegacyClient::Connect()
|
|||||||
m_connecting = true;
|
m_connecting = true;
|
||||||
EQ::Net::TCPConnection::Connect(m_addr, m_port, false, [this](std::shared_ptr<EQ::Net::TCPConnection> connection) {
|
EQ::Net::TCPConnection::Connect(m_addr, m_port, false, [this](std::shared_ptr<EQ::Net::TCPConnection> connection) {
|
||||||
if (connection == nullptr) {
|
if (connection == nullptr) {
|
||||||
LogF(Logs::General, Logs::TCPConnection, "Error connecting to {0}:{1}, attempting to reconnect...", m_addr, m_port);
|
LogF(Logs::General, Logs::TCP_Connection, "Error connecting to {0}:{1}, attempting to reconnect...", m_addr, m_port);
|
||||||
m_connecting = false;
|
m_connecting = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogF(Logs::General, Logs::TCPConnection, "Connected to {0}:{1}", m_addr, m_port);
|
LogF(Logs::General, Logs::TCP_Connection, "Connected to {0}:{1}", m_addr, m_port);
|
||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
m_connection->OnDisconnect([this](EQ::Net::TCPConnection *c) {
|
m_connection->OnDisconnect([this](EQ::Net::TCPConnection *c) {
|
||||||
LogF(Logs::General, Logs::TCPConnection, "Connection lost to {0}:{1}, attempting to reconnect...", m_addr, m_port);
|
LogF(Logs::General, Logs::TCP_Connection, "Connection lost to {0}:{1}, attempting to reconnect...", m_addr, m_port);
|
||||||
m_connection.reset();
|
m_connection.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "servertalk_server_connection.h"
|
#include "servertalk_server_connection.h"
|
||||||
#include "servertalk_server.h"
|
#include "servertalk_server.h"
|
||||||
#include "../eqemu_logsys.h"
|
#include "../eqemu_logsys.h"
|
||||||
|
#include "../eqemu_logsys_fmt.h"
|
||||||
#include "../util/uuid.h"
|
#include "../util/uuid.h"
|
||||||
|
|
||||||
EQ::Net::ServertalkServerConnection::ServertalkServerConnection(std::shared_ptr<EQ::Net::TCPConnection> c, EQ::Net::ServertalkServer *parent, bool encrypted, bool allow_downgrade)
|
EQ::Net::ServertalkServerConnection::ServertalkServerConnection(std::shared_ptr<EQ::Net::TCPConnection> c, EQ::Net::ServertalkServer *parent, bool encrypted, bool allow_downgrade)
|
||||||
@@ -201,7 +202,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b
|
|||||||
{
|
{
|
||||||
#ifdef ENABLE_SECURITY
|
#ifdef ENABLE_SECURITY
|
||||||
if (downgrade_security && m_allow_downgrade && m_encrypted) {
|
if (downgrade_security && m_allow_downgrade && m_encrypted) {
|
||||||
LogF(Logs::General, Logs::TCPConnection, "Downgraded encrypted connection to plaintext because otherside didn't support encryption {0}:{1}",
|
LogF(Logs::General, Logs::TCP_Connection, "Downgraded encrypted connection to plaintext because otherside didn't support encryption {0}:{1}",
|
||||||
m_connection->RemoteIP(), m_connection->RemotePort());
|
m_connection->RemoteIP(), m_connection->RemotePort());
|
||||||
m_encrypted = false;
|
m_encrypted = false;
|
||||||
}
|
}
|
||||||
@@ -220,7 +221,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b
|
|||||||
|
|
||||||
if (crypto_box_open_easy_afternm(&decrypted_text[0], (unsigned char*)p.Data() + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES, cipher_len, m_nonce_theirs, m_shared_key))
|
if (crypto_box_open_easy_afternm(&decrypted_text[0], (unsigned char*)p.Data() + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES, cipher_len, m_nonce_theirs, m_shared_key))
|
||||||
{
|
{
|
||||||
LogError("Error decrypting handshake from client, dropping connection.");
|
LogF(Logs::General, Logs::Error, "Error decrypting handshake from client, dropping connection.");
|
||||||
m_connection->Disconnect();
|
m_connection->Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -229,7 +230,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b
|
|||||||
std::string credentials = (const char*)&decrypted_text[0] + (m_identifier.length() + 1);
|
std::string credentials = (const char*)&decrypted_text[0] + (m_identifier.length() + 1);
|
||||||
|
|
||||||
if (!m_parent->CheckCredentials(credentials)) {
|
if (!m_parent->CheckCredentials(credentials)) {
|
||||||
LogError("Got incoming connection with invalid credentials during handshake, dropping connection.");
|
LogF(Logs::General, Logs::Error, "Got incoming connection with invalid credentials during handshake, dropping connection.");
|
||||||
m_connection->Disconnect();
|
m_connection->Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -239,7 +240,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &ex) {
|
catch (std::exception &ex) {
|
||||||
LogError("Error parsing handshake from client: {0}", ex.what());
|
LogF(Logs::General, Logs::Error, "Error parsing handshake from client: {0}", ex.what());
|
||||||
m_connection->Disconnect();
|
m_connection->Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,7 +250,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b
|
|||||||
auto credentials = p.GetCString(m_identifier.length() + 1);
|
auto credentials = p.GetCString(m_identifier.length() + 1);
|
||||||
|
|
||||||
if (!m_parent->CheckCredentials(credentials)) {
|
if (!m_parent->CheckCredentials(credentials)) {
|
||||||
LogError("Got incoming connection with invalid credentials during handshake, dropping connection.");
|
LogF(Logs::General, Logs::Error, "Got incoming connection with invalid credentials during handshake, dropping connection.");
|
||||||
m_connection->Disconnect();
|
m_connection->Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -257,7 +258,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b
|
|||||||
m_parent->ConnectionIdentified(this);
|
m_parent->ConnectionIdentified(this);
|
||||||
}
|
}
|
||||||
catch (std::exception &ex) {
|
catch (std::exception &ex) {
|
||||||
LogError("Error parsing handshake from client: {0}", ex.what());
|
LogF(Logs::General, Logs::Error, "Error parsing handshake from client: {0}", ex.what());
|
||||||
m_connection->Disconnect();
|
m_connection->Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,7 +268,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b
|
|||||||
auto credentials = p.GetCString(m_identifier.length() + 1);
|
auto credentials = p.GetCString(m_identifier.length() + 1);
|
||||||
|
|
||||||
if (!m_parent->CheckCredentials(credentials)) {
|
if (!m_parent->CheckCredentials(credentials)) {
|
||||||
LogError("Got incoming connection with invalid credentials during handshake, dropping connection.");
|
LogF(Logs::General, Logs::Error, "Got incoming connection with invalid credentials during handshake, dropping connection.");
|
||||||
m_connection->Disconnect();
|
m_connection->Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -275,7 +276,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b
|
|||||||
m_parent->ConnectionIdentified(this);
|
m_parent->ConnectionIdentified(this);
|
||||||
}
|
}
|
||||||
catch (std::exception &ex) {
|
catch (std::exception &ex) {
|
||||||
LogError("Error parsing handshake from client: {0}", ex.what());
|
LogF(Logs::General, Logs::Error, "Error parsing handshake from client: {0}", ex.what());
|
||||||
m_connection->Disconnect();
|
m_connection->Disconnect();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -295,7 +296,7 @@ void EQ::Net::ServertalkServerConnection::ProcessMessage(EQ::Net::Packet &p)
|
|||||||
|
|
||||||
if (crypto_box_open_easy_afternm(&decrypted_text[0], (unsigned char*)&data[0], length, m_nonce_theirs, m_shared_key))
|
if (crypto_box_open_easy_afternm(&decrypted_text[0], (unsigned char*)&data[0], length, m_nonce_theirs, m_shared_key))
|
||||||
{
|
{
|
||||||
LogError("Error decrypting message from client");
|
LogF(Logs::General, Logs::Error, "Error decrypting message from client");
|
||||||
(*(uint64_t*)&m_nonce_theirs[0])++;
|
(*(uint64_t*)&m_nonce_theirs[0])++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -343,6 +344,6 @@ void EQ::Net::ServertalkServerConnection::ProcessMessage(EQ::Net::Packet &p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &ex) {
|
catch (std::exception &ex) {
|
||||||
LogError("Error parsing message from client: {0}", ex.what());
|
LogF(Logs::General, Logs::Error, "Error parsing message from client: {0}", ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ void EQ::Net::TCPConnection::Connect(const std::string &addr, int port, bool ipv
|
|||||||
std::function<void(std::shared_ptr<EQ::Net::TCPConnection>)> cb;
|
std::function<void(std::shared_ptr<EQ::Net::TCPConnection>)> cb;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto loop = EQ::EventLoop::Get().Handle();
|
auto loop = EQ::EventLoop::GetDefault().Handle();
|
||||||
uv_tcp_t *socket = new uv_tcp_t;
|
uv_tcp_t *socket = new uv_tcp_t;
|
||||||
memset(socket, 0, sizeof(uv_tcp_t));
|
memset(socket, 0, sizeof(uv_tcp_t));
|
||||||
uv_tcp_init(loop, socket);
|
uv_tcp_init(loop, socket);
|
||||||
@@ -142,7 +142,7 @@ void EQ::Net::TCPConnection::Write(const char *data, size_t count)
|
|||||||
|
|
||||||
WriteBaton *baton = new WriteBaton;
|
WriteBaton *baton = new WriteBaton;
|
||||||
baton->connection = this;
|
baton->connection = this;
|
||||||
baton->buffer = new char[count];;
|
baton->buffer = new char[count];
|
||||||
|
|
||||||
uv_write_t *write_req = new uv_write_t;
|
uv_write_t *write_req = new uv_write_t;
|
||||||
memset(write_req, 0, sizeof(uv_write_t));
|
memset(write_req, 0, sizeof(uv_write_t));
|
||||||
@@ -203,10 +203,6 @@ int EQ::Net::TCPConnection::LocalPort() const
|
|||||||
|
|
||||||
std::string EQ::Net::TCPConnection::RemoteIP() const
|
std::string EQ::Net::TCPConnection::RemoteIP() const
|
||||||
{
|
{
|
||||||
if (!m_socket) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
sockaddr_storage addr;
|
sockaddr_storage addr;
|
||||||
int addr_len = sizeof(addr);
|
int addr_len = sizeof(addr);
|
||||||
uv_tcp_getpeername(m_socket, (sockaddr*)&addr, &addr_len);
|
uv_tcp_getpeername(m_socket, (sockaddr*)&addr, &addr_len);
|
||||||
@@ -224,10 +220,6 @@ std::string EQ::Net::TCPConnection::RemoteIP() const
|
|||||||
|
|
||||||
int EQ::Net::TCPConnection::RemotePort() const
|
int EQ::Net::TCPConnection::RemotePort() const
|
||||||
{
|
{
|
||||||
if (!m_socket) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sockaddr_storage addr;
|
sockaddr_storage addr;
|
||||||
int addr_len = sizeof(addr);
|
int addr_len = sizeof(addr);
|
||||||
uv_tcp_getpeername(m_socket, (sockaddr*)&addr, &addr_len);
|
uv_tcp_getpeername(m_socket, (sockaddr*)&addr, &addr_len);
|
||||||
@@ -244,11 +236,3 @@ int EQ::Net::TCPConnection::RemotePort() const
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool EQ::Net::TCPConnection::IsConnected() const
|
|
||||||
{
|
|
||||||
return m_socket != nullptr;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -24,12 +24,10 @@ namespace EQ
|
|||||||
void Read(const char *data, size_t count);
|
void Read(const char *data, size_t count);
|
||||||
void Write(const char *data, size_t count);
|
void Write(const char *data, size_t count);
|
||||||
|
|
||||||
bool IsConnected() const;
|
|
||||||
std::string LocalIP() const;
|
std::string LocalIP() const;
|
||||||
int LocalPort() const;
|
int LocalPort() const;
|
||||||
std::string RemoteIP() const;
|
std::string RemoteIP() const;
|
||||||
int RemotePort() const;
|
int RemotePort() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TCPConnection();
|
TCPConnection();
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void EQ::Net::TCPServer::Listen(const std::string &addr, int port, bool ipv6, st
|
|||||||
|
|
||||||
m_on_new_connection = cb;
|
m_on_new_connection = cb;
|
||||||
|
|
||||||
auto loop = EQ::EventLoop::Get().Handle();
|
auto loop = EQ::EventLoop::GetDefault().Handle();
|
||||||
m_socket = new uv_tcp_t;
|
m_socket = new uv_tcp_t;
|
||||||
memset(m_socket, 0, sizeof(uv_tcp_t));
|
memset(m_socket, 0, sizeof(uv_tcp_t));
|
||||||
uv_tcp_init(loop, m_socket);
|
uv_tcp_init(loop, m_socket);
|
||||||
@@ -53,7 +53,7 @@ void EQ::Net::TCPServer::Listen(const std::string &addr, int port, bool ipv6, st
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto loop = EQ::EventLoop::Get().Handle();
|
auto loop = EQ::EventLoop::GetDefault().Handle();
|
||||||
uv_tcp_t *client = new uv_tcp_t;
|
uv_tcp_t *client = new uv_tcp_t;
|
||||||
memset(client, 0, sizeof(uv_tcp_t));
|
memset(client, 0, sizeof(uv_tcp_t));
|
||||||
uv_tcp_init(loop, client);
|
uv_tcp_init(loop, client);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ EQ::Net::WebsocketServer::WebsocketServer(const std::string &addr, int port)
|
|||||||
auto &connection = iter->second;
|
auto &connection = iter->second;
|
||||||
connection->GetWebsocketConnection()->ping("keepalive");
|
connection->GetWebsocketConnection()->ping("keepalive");
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
iter->second->GetTCPConnection()->Disconnect();
|
iter->second->GetTCPConnection()->Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ void EQ::Net::WebsocketServer::DispatchEvent(WebsocketSubscriptionEvent evt, Jso
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ Json::Value EQ::Net::WebsocketServer::Login(WebsocketServerConnection *connectio
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
throw WebsocketException("Unable to process login request");
|
throw WebsocketException("Unable to process login request");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,7 @@ Json::Value EQ::Net::WebsocketServer::Subscribe(WebsocketServerConnection *conne
|
|||||||
catch (WebsocketException &ex) {
|
catch (WebsocketException &ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
throw WebsocketException("Unable to process unsubscribe request");
|
throw WebsocketException("Unable to process unsubscribe request");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ Json::Value EQ::Net::WebsocketServer::Unsubscribe(WebsocketServerConnection *con
|
|||||||
catch (WebsocketException &ex) {
|
catch (WebsocketException &ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
catch (std::exception &) {
|
catch (std::exception) {
|
||||||
throw WebsocketException("Unable to process unsubscribe request");
|
throw WebsocketException("Unable to process unsubscribe request");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ OpcodeManager::OpcodeManager() {
|
|||||||
bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors) {
|
bool OpcodeManager::LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors) {
|
||||||
FILE *opf = fopen(filename, "r");
|
FILE *opf = fopen(filename, "r");
|
||||||
if(opf == nullptr) {
|
if(opf == nullptr) {
|
||||||
LogError("Unable to open opcodes file [{}]", filename);
|
Log(Logs::General, Logs::Error, "Unable to open opcodes file '%s'", filename);
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
//#endif
|
//#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WIN32
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "packet_dump.h"
|
#include "packet_dump.h"
|
||||||
#include "packet_functions.h"
|
#include "packet_functions.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+13
-15
@@ -85,7 +85,7 @@ namespace RoF
|
|||||||
//TODO: figure out how to support shared memory with multiple patches...
|
//TODO: figure out how to support shared memory with multiple patches...
|
||||||
opcodes = new RegularOpcodeManager();
|
opcodes = new RegularOpcodeManager();
|
||||||
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error loading opcodes file [{}]. Not registering patch [{}]", opfile.c_str(), name);
|
Log(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ namespace RoF
|
|||||||
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
signature.first_length = sizeof(structs::ClientZoneEntry_Struct);
|
||||||
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry);
|
||||||
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy);
|
||||||
LogNetcode("[StreamIdentify] Registered patch [{}]", name);
|
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reload()
|
void Reload()
|
||||||
@@ -125,10 +125,10 @@ namespace RoF
|
|||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
Log(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogNetcode("[OPCODES] Reloaded opcodes for patch [{}]", name);
|
Log(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ namespace RoF
|
|||||||
|
|
||||||
if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0)
|
if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0)
|
||||||
{
|
{
|
||||||
LogNetcode("[STRUCTS] Wrong size on outbound [{}]: Got [{}], expected multiple of [{}]", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct));
|
Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct));
|
||||||
delete in;
|
delete in;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -589,7 +589,7 @@ namespace RoF
|
|||||||
for (int index = 0; index < item_count; ++index, ++eq) {
|
for (int index = 0; index < item_count; ++index, ++eq) {
|
||||||
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0, ItemPacketCharInventory);
|
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0, ItemPacketCharInventory);
|
||||||
if (ob.tellp() == last_pos)
|
if (ob.tellp() == last_pos)
|
||||||
LogNetcode("RoF::ENCODE(OP_CharInventory) Serialization failed on item slot [{}] during OP_CharInventory. Item skipped", eq->slot_id);
|
Log(Logs::General, Logs::Netcode, "RoF::ENCODE(OP_CharInventory) Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||||
|
|
||||||
last_pos = ob.tellp();
|
last_pos = ob.tellp();
|
||||||
}
|
}
|
||||||
@@ -624,7 +624,6 @@ namespace RoF
|
|||||||
SETUP_DIRECT_ENCODE(PlayerPositionUpdateServer_Struct, structs::PlayerPositionUpdateServer_Struct);
|
SETUP_DIRECT_ENCODE(PlayerPositionUpdateServer_Struct, structs::PlayerPositionUpdateServer_Struct);
|
||||||
|
|
||||||
OUT(spawn_id);
|
OUT(spawn_id);
|
||||||
OUT(vehicle_id);
|
|
||||||
OUT(x_pos);
|
OUT(x_pos);
|
||||||
OUT(delta_x);
|
OUT(delta_x);
|
||||||
OUT(delta_y);
|
OUT(delta_y);
|
||||||
@@ -1522,7 +1521,7 @@ namespace RoF
|
|||||||
|
|
||||||
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0, old_item_pkt->PacketType);
|
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0, old_item_pkt->PacketType);
|
||||||
if (ob.tellp() == last_pos) {
|
if (ob.tellp() == last_pos) {
|
||||||
LogNetcode("RoF::ENCODE(OP_ItemPacket) Serialization failed on item slot [{}]", int_struct->slot_id);
|
Log(Logs::General, Logs::Netcode, "RoF::ENCODE(OP_ItemPacket) Serialization failed on item slot %d.", int_struct->slot_id);
|
||||||
delete in;
|
delete in;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2603,7 +2602,7 @@ namespace RoF
|
|||||||
|
|
||||||
outapp->WriteUInt8(0); // Unknown
|
outapp->WriteUInt8(0); // Unknown
|
||||||
|
|
||||||
LogNetcode("[STRUCTS] Player Profile Packet is [{}] bytes", outapp->GetWritePosition());
|
Log(Logs::General, Logs::Netcode, "[STRUCTS] Player Profile Packet is %i bytes", outapp->GetWritePosition());
|
||||||
|
|
||||||
auto NewBuffer = new unsigned char[outapp->GetWritePosition()];
|
auto NewBuffer = new unsigned char[outapp->GetWritePosition()];
|
||||||
memcpy(NewBuffer, outapp->pBuffer, outapp->GetWritePosition());
|
memcpy(NewBuffer, outapp->pBuffer, outapp->GetWritePosition());
|
||||||
@@ -3454,7 +3453,7 @@ namespace RoF
|
|||||||
|
|
||||||
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
||||||
{
|
{
|
||||||
LogNetcode("[STRUCTS] Wrong size on outbound [{}]: Got [{}], expected multiple of [{}]", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
||||||
delete in;
|
delete in;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3805,7 +3804,7 @@ namespace RoF
|
|||||||
//determine and verify length
|
//determine and verify length
|
||||||
int entrycount = in->size / sizeof(Spawn_Struct);
|
int entrycount = in->size / sizeof(Spawn_Struct);
|
||||||
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
||||||
LogNetcode("[STRUCTS] Wrong size on outbound [{}]: Got [{}], expected multiple of [{}]", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
||||||
delete in;
|
delete in;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4053,7 +4052,7 @@ namespace RoF
|
|||||||
Buffer += 29;
|
Buffer += 29;
|
||||||
if (Buffer != (BufferStart + PacketSize))
|
if (Buffer != (BufferStart + PacketSize))
|
||||||
{
|
{
|
||||||
LogNetcode("[ERROR] SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now [{}] from end", Buffer - (BufferStart + PacketSize));
|
Log(Logs::General, Logs::Netcode, "[ERROR] SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now %i from end", Buffer - (BufferStart + PacketSize));
|
||||||
}
|
}
|
||||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending zone spawn for %s packet is %i bytes", emu->name, outapp->size);
|
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending zone spawn for %s packet is %i bytes", emu->name, outapp->size);
|
||||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||||
@@ -4315,7 +4314,6 @@ namespace RoF
|
|||||||
SETUP_DIRECT_DECODE(PlayerPositionUpdateClient_Struct, structs::PlayerPositionUpdateClient_Struct);
|
SETUP_DIRECT_DECODE(PlayerPositionUpdateClient_Struct, structs::PlayerPositionUpdateClient_Struct);
|
||||||
|
|
||||||
IN(spawn_id);
|
IN(spawn_id);
|
||||||
IN(vehicle_id);
|
|
||||||
IN(sequence);
|
IN(sequence);
|
||||||
IN(x_pos);
|
IN(x_pos);
|
||||||
IN(y_pos);
|
IN(y_pos);
|
||||||
@@ -4623,7 +4621,7 @@ namespace RoF
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
LogNetcode("Unhandled OP_GuildBank action");
|
Log(Logs::Detail, Logs::Netcode, "Unhandled OP_GuildBank action");
|
||||||
__packet->SetOpcode(OP_Unknown); /* invalidate the packet */
|
__packet->SetOpcode(OP_Unknown); /* invalidate the packet */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -5680,7 +5678,7 @@ namespace RoF
|
|||||||
RoFSlot = server_corpse_slot;
|
RoFSlot = server_corpse_slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogNetcode("Convert Server Corpse Slot [{}] to RoF Corpse Main Slot [{}]", server_corpse_slot, RoFSlot);
|
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to RoF Corpse Main Slot %i", server_corpse_slot, RoFSlot);
|
||||||
|
|
||||||
return RoFSlot;
|
return RoFSlot;
|
||||||
}
|
}
|
||||||
|
|||||||
+66
-27
@@ -37,7 +37,6 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cinttypes>
|
|
||||||
|
|
||||||
|
|
||||||
namespace RoF2
|
namespace RoF2
|
||||||
@@ -86,7 +85,7 @@ namespace RoF2
|
|||||||
//TODO: figure out how to support shared memory with multiple patches...
|
//TODO: figure out how to support shared memory with multiple patches...
|
||||||
opcodes = new RegularOpcodeManager();
|
opcodes = new RegularOpcodeManager();
|
||||||
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error loading opcodes file [{}]. Not registering patch [{}]", opfile.c_str(), name);
|
Log(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +111,7 @@ namespace RoF2
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
LogNetcode("[StreamIdentify] Registered patch [{}]", name);
|
Log(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reload()
|
void Reload()
|
||||||
@@ -129,10 +128,10 @@ namespace RoF2
|
|||||||
opfile += name;
|
opfile += name;
|
||||||
opfile += ".conf";
|
opfile += ".conf";
|
||||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
Log(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogNetcode("[OPCODES] Reloaded opcodes for patch [{}]", name);
|
Log(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,7 +419,7 @@ namespace RoF2
|
|||||||
|
|
||||||
if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0)
|
if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0)
|
||||||
{
|
{
|
||||||
LogNetcode("[STRUCTS] Wrong size on outbound [{}]: Got [{}], expected multiple of [{}]", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct));
|
Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct));
|
||||||
delete in;
|
delete in;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -658,7 +657,7 @@ namespace RoF2
|
|||||||
for (int index = 0; index < item_count; ++index, ++eq) {
|
for (int index = 0; index < item_count; ++index, ++eq) {
|
||||||
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0, ItemPacketCharInventory);
|
SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0, ItemPacketCharInventory);
|
||||||
if (ob.tellp() == last_pos)
|
if (ob.tellp() == last_pos)
|
||||||
LogNetcode("RoF2::ENCODE(OP_CharInventory) Serialization failed on item slot [{}] during OP_CharInventory. Item skipped", eq->slot_id);
|
Log(Logs::General, Logs::Netcode, "RoF2::ENCODE(OP_CharInventory) Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||||
|
|
||||||
last_pos = ob.tellp();
|
last_pos = ob.tellp();
|
||||||
}
|
}
|
||||||
@@ -687,6 +686,25 @@ namespace RoF2
|
|||||||
FINISH_ENCODE();
|
FINISH_ENCODE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ENCODE(OP_ClientUpdate)
|
||||||
|
{
|
||||||
|
ENCODE_LENGTH_EXACT(PlayerPositionUpdateServer_Struct);
|
||||||
|
SETUP_DIRECT_ENCODE(PlayerPositionUpdateServer_Struct, structs::PlayerPositionUpdateServer_Struct);
|
||||||
|
|
||||||
|
OUT(spawn_id);
|
||||||
|
OUT(x_pos);
|
||||||
|
OUT(delta_x);
|
||||||
|
OUT(delta_y);
|
||||||
|
OUT(z_pos);
|
||||||
|
OUT(delta_heading);
|
||||||
|
OUT(y_pos);
|
||||||
|
OUT(delta_z);
|
||||||
|
OUT(animation);
|
||||||
|
OUT(heading);
|
||||||
|
|
||||||
|
FINISH_ENCODE();
|
||||||
|
}
|
||||||
|
|
||||||
ENCODE(OP_Consider)
|
ENCODE(OP_Consider)
|
||||||
{
|
{
|
||||||
ENCODE_LENGTH_EXACT(Consider_Struct);
|
ENCODE_LENGTH_EXACT(Consider_Struct);
|
||||||
@@ -1571,7 +1589,7 @@ namespace RoF2
|
|||||||
|
|
||||||
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0, old_item_pkt->PacketType);
|
SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0, old_item_pkt->PacketType);
|
||||||
if (ob.tellp() == last_pos) {
|
if (ob.tellp() == last_pos) {
|
||||||
LogNetcode("RoF2::ENCODE(OP_ItemPacket) Serialization failed on item slot [{}]", int_struct->slot_id);
|
Log(Logs::General, Logs::Netcode, "RoF2::ENCODE(OP_ItemPacket) Serialization failed on item slot %d.", int_struct->slot_id);
|
||||||
delete in;
|
delete in;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2670,7 +2688,7 @@ namespace RoF2
|
|||||||
// Think we need 1 byte of padding at the end
|
// Think we need 1 byte of padding at the end
|
||||||
outapp->WriteUInt8(0); // Unknown
|
outapp->WriteUInt8(0); // Unknown
|
||||||
|
|
||||||
LogNetcode("[STRUCTS] Player Profile Packet is [{}] bytes", outapp->GetWritePosition());
|
Log(Logs::General, Logs::Netcode, "[STRUCTS] Player Profile Packet is %i bytes", outapp->GetWritePosition());
|
||||||
|
|
||||||
auto NewBuffer = new unsigned char[outapp->GetWritePosition()];
|
auto NewBuffer = new unsigned char[outapp->GetWritePosition()];
|
||||||
memcpy(NewBuffer, outapp->pBuffer, outapp->GetWritePosition());
|
memcpy(NewBuffer, outapp->pBuffer, outapp->GetWritePosition());
|
||||||
@@ -3502,7 +3520,7 @@ namespace RoF2
|
|||||||
|
|
||||||
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
||||||
{
|
{
|
||||||
LogNetcode("[STRUCTS] Wrong size on outbound [{}]: Got [{}], expected multiple of [{}]", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
||||||
delete in;
|
delete in;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3549,7 +3567,7 @@ namespace RoF2
|
|||||||
{
|
{
|
||||||
eq->items[i].Unknown18 = 0;
|
eq->items[i].Unknown18 = 0;
|
||||||
if (i < 80) {
|
if (i < 80) {
|
||||||
snprintf(eq->items[i].SerialNumber, sizeof(eq->items[i].SerialNumber), "%016" PRId64, emu->SerialNumber[i]);
|
snprintf(eq->items[i].SerialNumber, sizeof(eq->items[i].SerialNumber), "%016d", emu->SerialNumber[i]);
|
||||||
eq->ItemCost[i] = emu->ItemCost[i];
|
eq->ItemCost[i] = emu->ItemCost[i];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -3612,7 +3630,7 @@ namespace RoF2
|
|||||||
|
|
||||||
OUT(TraderID);
|
OUT(TraderID);
|
||||||
snprintf(eq->SerialNumber, sizeof(eq->SerialNumber), "%016d", emu->ItemID);
|
snprintf(eq->SerialNumber, sizeof(eq->SerialNumber), "%016d", emu->ItemID);
|
||||||
LogTrading("ENCODE(OP_TraderDelItem): TraderID [{}], SerialNumber: [{}]", emu->TraderID, emu->ItemID);
|
Log(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderDelItem): TraderID %d, SerialNumber: %d", emu->TraderID, emu->ItemID);
|
||||||
|
|
||||||
FINISH_ENCODE();
|
FINISH_ENCODE();
|
||||||
}
|
}
|
||||||
@@ -3643,7 +3661,7 @@ namespace RoF2
|
|||||||
eq->Traders2 = emu->Traders;
|
eq->Traders2 = emu->Traders;
|
||||||
eq->Items2 = emu->Items;
|
eq->Items2 = emu->Items;
|
||||||
|
|
||||||
LogTrading("ENCODE(OP_TraderShop): BazaarWelcome_Struct Code [{}], Traders [{}], Items [{}]",
|
Log(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderShop): BazaarWelcome_Struct Code %d, Traders %d, Items %d",
|
||||||
eq->Code, eq->Traders, eq->Items);
|
eq->Code, eq->Traders, eq->Items);
|
||||||
|
|
||||||
FINISH_ENCODE();
|
FINISH_ENCODE();
|
||||||
@@ -3666,14 +3684,14 @@ namespace RoF2
|
|||||||
OUT(Quantity);
|
OUT(Quantity);
|
||||||
snprintf(eq->SerialNumber, sizeof(eq->SerialNumber), "%016d", emu->ItemID);
|
snprintf(eq->SerialNumber, sizeof(eq->SerialNumber), "%016d", emu->ItemID);
|
||||||
|
|
||||||
LogTrading("ENCODE(OP_TraderShop): Buy Action [{}], Price [{}], Trader [{}], ItemID [{}], Quantity [{}], ItemName, [{}]",
|
Log(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderShop): Buy Action %d, Price %d, Trader %d, ItemID %d, Quantity %d, ItemName, %s",
|
||||||
eq->Action, eq->Price, eq->TraderID, eq->ItemID, eq->Quantity, emu->ItemName);
|
eq->Action, eq->Price, eq->TraderID, eq->ItemID, eq->Quantity, emu->ItemName);
|
||||||
|
|
||||||
FINISH_ENCODE();
|
FINISH_ENCODE();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogTrading("ENCODE(OP_TraderShop): Encode Size Unknown ([{}])", psize);
|
Log(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderShop): Encode Size Unknown (%d)", psize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3928,7 +3946,7 @@ namespace RoF2
|
|||||||
//determine and verify length
|
//determine and verify length
|
||||||
int entrycount = in->size / sizeof(Spawn_Struct);
|
int entrycount = in->size / sizeof(Spawn_Struct);
|
||||||
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
||||||
LogNetcode("[STRUCTS] Wrong size on outbound [{}]: Got [{}], expected multiple of [{}]", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
||||||
delete in;
|
delete in;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4260,7 +4278,7 @@ namespace RoF2
|
|||||||
Buffer += 29;
|
Buffer += 29;
|
||||||
if (Buffer != (BufferStart + PacketSize))
|
if (Buffer != (BufferStart + PacketSize))
|
||||||
{
|
{
|
||||||
LogNetcode("[ERROR] SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now [{}] from end", Buffer - (BufferStart + PacketSize));
|
Log(Logs::General, Logs::Netcode, "[ERROR] SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now %i from end", Buffer - (BufferStart + PacketSize));
|
||||||
}
|
}
|
||||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending zone spawn for %s packet is %i bytes", emu->name, outapp->size);
|
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending zone spawn for %s packet is %i bytes", emu->name, outapp->size);
|
||||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||||
@@ -4527,6 +4545,27 @@ namespace RoF2
|
|||||||
FINISH_DIRECT_DECODE();
|
FINISH_DIRECT_DECODE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECODE(OP_ClientUpdate)
|
||||||
|
{
|
||||||
|
// for some odd reason, there is an extra byte on the end of this on occasion..
|
||||||
|
DECODE_LENGTH_ATLEAST(structs::PlayerPositionUpdateClient_Struct);
|
||||||
|
SETUP_DIRECT_DECODE(PlayerPositionUpdateClient_Struct, structs::PlayerPositionUpdateClient_Struct);
|
||||||
|
|
||||||
|
IN(spawn_id);
|
||||||
|
IN(sequence);
|
||||||
|
IN(x_pos);
|
||||||
|
IN(y_pos);
|
||||||
|
IN(z_pos);
|
||||||
|
IN(heading);
|
||||||
|
IN(delta_x);
|
||||||
|
IN(delta_y);
|
||||||
|
IN(delta_z);
|
||||||
|
IN(delta_heading);
|
||||||
|
IN(animation);
|
||||||
|
|
||||||
|
FINISH_DIRECT_DECODE();
|
||||||
|
}
|
||||||
|
|
||||||
DECODE(OP_Consider)
|
DECODE(OP_Consider)
|
||||||
{
|
{
|
||||||
DECODE_LENGTH_EXACT(structs::Consider_Struct);
|
DECODE_LENGTH_EXACT(structs::Consider_Struct);
|
||||||
@@ -4820,7 +4859,7 @@ namespace RoF2
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
LogNetcode("Unhandled OP_GuildBank action");
|
Log(Logs::Detail, Logs::Netcode, "Unhandled OP_GuildBank action");
|
||||||
__packet->SetOpcode(OP_Unknown); /* invalidate the packet */
|
__packet->SetOpcode(OP_Unknown); /* invalidate the packet */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4973,7 +5012,7 @@ namespace RoF2
|
|||||||
emu->to_slot = RoF2ToServerSlot(eq->to_slot);
|
emu->to_slot = RoF2ToServerSlot(eq->to_slot);
|
||||||
IN(number_in_stack);
|
IN(number_in_stack);
|
||||||
|
|
||||||
//LogNetcode("[RoF2] MoveItem Slot from [{}] to [{}], Number [{}]", emu->from_slot, emu->to_slot, emu->number_in_stack);
|
//Log(Logs::General, Logs::Netcode, "[RoF2] MoveItem Slot from %u to %u, Number %u", emu->from_slot, emu->to_slot, emu->number_in_stack);
|
||||||
|
|
||||||
FINISH_DIRECT_DECODE();
|
FINISH_DIRECT_DECODE();
|
||||||
}
|
}
|
||||||
@@ -5206,7 +5245,7 @@ namespace RoF2
|
|||||||
IN(Code);
|
IN(Code);
|
||||||
IN(TraderID);
|
IN(TraderID);
|
||||||
IN(Approval);
|
IN(Approval);
|
||||||
LogTrading("DECODE(OP_TraderShop): TraderClick_Struct Code [{}], TraderID [{}], Approval [{}]",
|
Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): TraderClick_Struct Code %d, TraderID %d, Approval %d",
|
||||||
eq->Code, eq->TraderID, eq->Approval);
|
eq->Code, eq->TraderID, eq->Approval);
|
||||||
|
|
||||||
FINISH_DIRECT_DECODE();
|
FINISH_DIRECT_DECODE();
|
||||||
@@ -5220,7 +5259,7 @@ namespace RoF2
|
|||||||
emu->Beginning.Action = eq->Code;
|
emu->Beginning.Action = eq->Code;
|
||||||
IN(Traders);
|
IN(Traders);
|
||||||
IN(Items);
|
IN(Items);
|
||||||
LogTrading("DECODE(OP_TraderShop): BazaarWelcome_Struct Code [{}], Traders [{}], Items [{}]",
|
Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): BazaarWelcome_Struct Code %d, Traders %d, Items %d",
|
||||||
eq->Code, eq->Traders, eq->Items);
|
eq->Code, eq->Traders, eq->Items);
|
||||||
|
|
||||||
FINISH_DIRECT_DECODE();
|
FINISH_DIRECT_DECODE();
|
||||||
@@ -5237,20 +5276,20 @@ namespace RoF2
|
|||||||
memcpy(emu->ItemName, eq->ItemName, sizeof(emu->ItemName));
|
memcpy(emu->ItemName, eq->ItemName, sizeof(emu->ItemName));
|
||||||
IN(ItemID);
|
IN(ItemID);
|
||||||
IN(Quantity);
|
IN(Quantity);
|
||||||
LogTrading("DECODE(OP_TraderShop): TraderBuy_Struct (Unknowns) Unknown004 [{}], Unknown008 [{}], Unknown012 [{}], Unknown076 [{}], Unknown276 [{}]",
|
Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): TraderBuy_Struct (Unknowns) Unknown004 %d, Unknown008 %d, Unknown012 %d, Unknown076 %d, Unknown276 %d",
|
||||||
eq->Unknown004, eq->Unknown008, eq->Unknown012, eq->Unknown076, eq->Unknown276);
|
eq->Unknown004, eq->Unknown008, eq->Unknown012, eq->Unknown076, eq->Unknown276);
|
||||||
LogTrading("DECODE(OP_TraderShop): TraderBuy_Struct Buy Action [{}], Price [{}], Trader [{}], ItemID [{}], Quantity [{}], ItemName, [{}]",
|
Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): TraderBuy_Struct Buy Action %d, Price %d, Trader %d, ItemID %d, Quantity %d, ItemName, %s",
|
||||||
eq->Action, eq->Price, eq->TraderID, eq->ItemID, eq->Quantity, eq->ItemName);
|
eq->Action, eq->Price, eq->TraderID, eq->ItemID, eq->Quantity, eq->ItemName);
|
||||||
|
|
||||||
FINISH_DIRECT_DECODE();
|
FINISH_DIRECT_DECODE();
|
||||||
}
|
}
|
||||||
else if (psize == 4)
|
else if (psize == 4)
|
||||||
{
|
{
|
||||||
LogTrading("DECODE(OP_TraderShop): Forwarding packet as-is with size 4");
|
Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): Forwarding packet as-is with size 4");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogTrading("DECODE(OP_TraderShop): Decode Size Unknown ([{}])", psize);
|
Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): Decode Size Unknown (%d)", psize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5927,7 +5966,7 @@ namespace RoF2
|
|||||||
RoF2Slot = server_corpse_slot;
|
RoF2Slot = server_corpse_slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogNetcode("Convert Server Corpse Slot [{}] to RoF2 Corpse Main Slot [{}]", server_corpse_slot, RoF2Slot);
|
Log(Logs::Detail, Logs::Netcode, "Convert Server Corpse Slot %i to RoF2 Corpse Main Slot %i", server_corpse_slot, RoF2Slot);
|
||||||
|
|
||||||
return RoF2Slot;
|
return RoF2Slot;
|
||||||
}
|
}
|
||||||
@@ -6110,7 +6149,7 @@ namespace RoF2
|
|||||||
ServerSlot = rof2_corpse_slot;
|
ServerSlot = rof2_corpse_slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogNetcode("Convert RoF2 Corpse Main Slot [{}] to Server Corpse Slot [{}]", rof2_corpse_slot, ServerSlot);
|
Log(Logs::Detail, Logs::Netcode, "Convert RoF2 Corpse Main Slot %i to Server Corpse Slot %i", rof2_corpse_slot, ServerSlot);
|
||||||
|
|
||||||
return ServerSlot;
|
return ServerSlot;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ E(OP_CastSpell)
|
|||||||
E(OP_ChannelMessage)
|
E(OP_ChannelMessage)
|
||||||
E(OP_CharInventory)
|
E(OP_CharInventory)
|
||||||
E(OP_ClickObjectAction)
|
E(OP_ClickObjectAction)
|
||||||
|
E(OP_ClientUpdate)
|
||||||
E(OP_Consider)
|
E(OP_Consider)
|
||||||
E(OP_Damage)
|
E(OP_Damage)
|
||||||
E(OP_DeleteCharge)
|
E(OP_DeleteCharge)
|
||||||
@@ -154,6 +155,7 @@ D(OP_BuffRemoveRequest)
|
|||||||
D(OP_CastSpell)
|
D(OP_CastSpell)
|
||||||
D(OP_ChannelMessage)
|
D(OP_ChannelMessage)
|
||||||
D(OP_CharacterCreate)
|
D(OP_CharacterCreate)
|
||||||
|
D(OP_ClientUpdate)
|
||||||
D(OP_Consider)
|
D(OP_Consider)
|
||||||
D(OP_ConsiderCorpse)
|
D(OP_ConsiderCorpse)
|
||||||
D(OP_Consume)
|
D(OP_Consume)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user