Compare commits

...

45 Commits

Author SHA1 Message Date
vstumpf
fd1e582156 It kinda works! 2024-07-05 09:07:17 +00:00
vstumpf
920b6a78c5 Merge branch 'refactor/cmake' into refactor/skills 2024-07-05 08:26:47 +00:00
vstumpf
34bdb49db9 Merge remote-tracking branch 'origin/refactor/cmake' into refactor/cmake 2024-07-05 01:02:10 +00:00
vstumpf
f54a204a7d Merge branch 'master' into refactor/cmake 2024-07-05 01:01:11 +00:00
Vincent Stumpf
b1a2d74b54
Merge pull request #4 from secretdataz/refactor/cmake
Added some Windows fixes, Added MAXXCON option to CMake
2024-05-09 00:10:14 -07:00
Jittapan Pluemsumran
d16dccf994 Added some Windows fixes, Added MAXXCON option to CMake 2024-05-04 19:47:01 +07:00
vstumpf
2e69ccedea Merge branch 'master' into refactor/cmake 2024-04-21 05:23:58 +00:00
Vincent Stumpf
b01e7da68d Merge branch 'master' into refactor/cmake 2024-02-17 01:50:56 +00:00
Vincent Stumpf
008d25cfb2 Merge remote-tracking branch 'upstream/master' into refactor/cmake 2023-12-24 00:26:14 +00:00
Vincent Stumpf
f4c9ed691c Merge remote-tracking branch 'upstream/master' into refactor/cmake 2023-12-12 07:43:50 +00:00
Vincent Stumpf
cc397167ab Enable configurable multi-threaded compilation 2023-12-12 07:43:19 +00:00
Vincent Stumpf
8f15bc2117 Merge remote-tracking branch 'upstream/master' into refactor/cmake 2023-11-26 05:45:27 +00:00
Vincent Stumpf
bf36dd4b1f Merge remote-tracking branch 'upstream/master' into refactor/cmake 2023-11-05 01:13:39 +00:00
Vincent Stumpf
fc242d0472 remove commented code 2023-08-06 06:24:33 +00:00
Vincent Stumpf
f41a80ca59 Remove redundant ubuntu-latest build 2023-07-20 03:34:32 +00:00
Vincent Stumpf
eadff3366d Fix cmake arg order 2023-07-12 03:27:56 +00:00
Vincent Stumpf
9636aa020d Remove deprecated builds 2023-07-12 03:23:48 +00:00
Vincent Stumpf
5c2718de03 Add concurrency and dependency on CMakeLists.txt 2023-07-12 03:22:52 +00:00
Vincent Stumpf
1b3357611b Merge remote-tracking branch 'upstream/master' into refactor/cmake 2023-07-03 07:44:30 +00:00
Vincent Stumpf
b3f6ad41ba Merge branch 'master' of github.com:rathena/rathena into refactor/cmake 2023-06-19 05:44:33 +00:00
Vincent Stumpf
c789cdbadd Merge remote-tracking branch 'upstream/master' into refactor/cmake 2023-06-18 22:28:19 +00:00
Vincent Stumpf
98ac59a940 change to oop 2023-06-17 02:00:01 +00:00
Vincent Stumpf
f73e6658ca Add deprecation notice in rAthena.sln 2023-06-15 03:01:39 +00:00
Vincent Stumpf
d98166383c Add .sh filetype to athena-start 2023-06-14 07:19:05 +00:00
Vincent Stumpf
b1520ea969 Add new line after tools 2023-06-14 07:10:48 +00:00
Vincent Stumpf
ee456d8af6 Add HAVE_STRNLEN and HAVE_SETRLIMIT 2023-06-14 07:08:14 +00:00
Vincent Stumpf
1545d483c0 Build tools in cmake workflow 2023-06-14 04:57:28 +00:00
Vincent Stumpf
b6ce15af00 Don't need to copy the configure files, they're being replaced by cmake 2023-06-13 07:34:08 +00:00
Vincent Stumpf
1f474a62cf enable PCRE for mapserver 2023-06-11 07:22:21 +00:00
Vincent Stumpf
9024cc7ef8 Change most github workflows to cmake 2023-06-11 06:41:37 +00:00
Vincent Stumpf
026c014eb2 Add ENABLE_VIP option to cmake 2023-06-11 06:39:36 +00:00
Vincent Stumpf
26dee6891b Fix windows cmake 2023-06-11 05:03:44 +00:00
Vincent Stumpf
258a8e6be0 Let's add windows to the cmake ci 2023-06-11 03:07:36 +00:00
Vincent Stumpf
48b0b082b6 Whoops, let's leave the configure script in, and the linux scripts too for now 2023-06-11 02:33:46 +00:00
Vincent Stumpf
6ae46a7bf8 Add custom 'server' target 2023-06-11 02:29:17 +00:00
Vincent Stumpf
855cf12007 Move scripts to tools 2023-06-11 02:29:17 +00:00
Vincent Stumpf
ae862453bd Move extra cmake files to tools/cmake 2023-06-11 02:29:17 +00:00
Vincent Stumpf
c11d73d6a8 Add epoll support 2023-06-11 02:29:17 +00:00
Vincent Stumpf
ff86c7b9d1 Maybe make scripts work? 2023-06-11 02:29:17 +00:00
Vincent Stumpf
e1b9b0d9b3 Add support for import files
This will check and copy import files whenever we regenerate the build system
2023-06-11 02:29:17 +00:00
Vincent Stumpf
b3c47f043e Remove cmakelistsold (oops) and clean up httplib 2023-06-11 02:29:17 +00:00
Vincent Stumpf
c69587c2e7 Refactor CMake to be nicer, more modern, easier to understand 2023-06-11 02:29:15 +00:00
Vincent Stumpf
95ee5d04e6 Double visitor? 2023-06-10 06:41:25 +00:00
Vincent Stumpf
28383ee332 Initial commit of skills 2023-06-04 05:45:11 +00:00
Vincent Stumpf
857f335729 Fix cmake stuff 2023-05-26 01:58:55 +00:00
41 changed files with 8812 additions and 8723 deletions

View File

@ -18,6 +18,8 @@ on:
# This workflow should run when a file in a source directory has been modified. # This workflow should run when a file in a source directory has been modified.
- 'src/**' - 'src/**'
- '3rdparty/**' - '3rdparty/**'
# This workflow should run whenever a CMake related file has been modified
- '**/CMakeLists.txt'
jobs: jobs:
analyze: analyze:
@ -31,8 +33,6 @@ jobs:
# The ubuntu-latest label currently points to ubuntu-20.04. # The ubuntu-latest label currently points to ubuntu-20.04.
# Available: ubuntu-22.04, ubuntu-20.04 # Available: ubuntu-22.04, ubuntu-20.04
os: [ubuntu-latest] os: [ubuntu-latest]
# Older versions of GCC are not available via unaltered aptitude repo lists.
gcc: ['10']
# We run build checks for both Renewal and PRE-Renewal # We run build checks for both Renewal and PRE-Renewal
mode: ['PRE','RE'] mode: ['PRE','RE']
@ -64,10 +64,10 @@ jobs:
- name: Update & Install packages - name: Update & Install packages
# Ubuntu runners already have most of the packages rAthena requires to build. # Ubuntu runners already have most of the packages rAthena requires to build.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2204-Readme.md
run: | run: |
sudo apt update sudo apt update
sudo apt install zlib1g-dev libpcre3-dev gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} sudo apt install zlib1g-dev libpcre3-dev
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below) # If this step fails, then you should remove it and run the build manually (see below)
@ -77,16 +77,16 @@ jobs:
# ?? If the Autobuild fails above, remove it and uncomment the following # ?? If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your # three lines and modify them (or add more) to build your code if your
# project uses a compiled language # project uses a compiled language
- name: Command - configure - name: Create build directory
env: run: cmake -E make_directory ${{github.workspace}}/build
CONFIGURE_FLAGS: 'CC=gcc-${{ matrix.gcc }} CXX=g++-${{ matrix.gcc }} --enable-prere=${{ env.PRERE }} --enable-buildbot=yes'
run: ./configure $CONFIGURE_FLAGS
- name: Command - make clean - name: Configure CMake
run: make clean working-directory: ${{github.workspace}}/build
run: cmake .. -DENABLE_PRERENEWAL=${{env.PRERE}} -DENABLE_EXTRA_BUILDBOT_CODE=ON
- name: Command - make server - name: Build
run: make server working-directory: ${{github.workspace}}/build
run: cmake --build . -j2 --target server
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3 uses: github/codeql-action/analyze@v3

View File

@ -1,54 +0,0 @@
name: Build servers with Clang
# build_servers_clang.yml
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
paths:
# Always trigger all Github Actions if an action or something CI related was changed
- '.github/workflows/**'
- 'tools/ci/**'
# This workflow should run when a file in a source directory has been modified.
- 'src/**'
- '3rdparty/**'
jobs:
build:
# Github Actions checks for '[ci skip]', '[skip ci]', '[no ci]', '[skip actions]', or '[actions skip]' but not a hyphenated version.
# It's a catch-all incase a Pull Request has been opened and someone is on auto-pilot.
if: "!contains(github.event.head_commit.message, 'ci-skip')"
runs-on: ${{ matrix.os }}
strategy:
matrix:
# The ubuntu-latest label currently points to ubuntu-22.04.
# Available: ubuntu-22.04, ubuntu-20.04
os: [ubuntu-20.04]
# Version list can be found on https://github.com/marketplace/actions/install-clang
clang: ['6.0', '7', '8', '9', '10', '11'] #, '12', '13']
steps:
- uses: actions/checkout@v4
- name: Set up Clang
uses: egor-tensin/setup-clang@v1
with:
version: ${{ matrix.clang }}
platform: x64
- name: Command - configure
env:
CONFIGURE_FLAGS: 'CC=clang-${{ matrix.clang }} CXX=clang++-${{ matrix.clang }} --enable-buildbot=yes'
run: ./configure $CONFIGURE_FLAGS
- name: Command - make clean
run: make clean
- name: Command - make all
run: make all

View File

@ -1,61 +0,0 @@
name: Build servers with GCC
# build_servers_gcc.yml
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
paths:
# Always trigger all Github Actions if an action or something CI related was changed
- '.github/workflows/**'
- 'tools/ci/**'
# This workflow should run when a file in a source directory has been modified.
- 'src/**'
- '3rdparty/**'
jobs:
build:
# Github Actions checks for '[ci skip]', '[skip ci]', '[no ci]', '[skip actions]', or '[actions skip]' but not a hyphenated version.
# It's a catch-all incase a Pull Request has been opened and someone is on auto-pilot.
if: "!contains(github.event.head_commit.message, 'ci-skip')"
runs-on: ${{ matrix.os }}
strategy:
matrix:
# The ubuntu-latest label currently points to ubuntu-22.04.
# Available: ubuntu-22.04, ubuntu-20.04
os: [ubuntu-latest]
# Older versions of GCC are not available via unaltered aptitude repo lists.
gcc: ['9', '10', '11', '12']
# GCC 13 was removed from 22.04, include it as a separate job
include:
- os: ubuntu-24.04
gcc: 13
steps:
- uses: actions/checkout@v4
- name: Update & Install packages
# Ubuntu runners already have most of the packages rAthena requires to build.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md
run: |
sudo apt update
sudo apt install zlib1g-dev libpcre3-dev gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }}
- name: Command - configure
env:
CONFIGURE_FLAGS: 'CC=gcc-${{ matrix.gcc }} CXX=g++-${{ matrix.gcc }}'
# -Werror: to treat all warnings as errors
# -Wno-error=builtin-declaration-mismatch: otherwise ./configure checks fail
run: ./configure $CONFIGURE_FLAGS --enable-buildbot=yes CXXFLAGS='-Werror -Wno-error=builtin-declaration-mismatch'
- name: Command - make clean
run: make clean
- name: Command - make all
run: make all

View File

@ -18,6 +18,8 @@ on:
# This workflow should run when a file in a source directory has been modified. # This workflow should run when a file in a source directory has been modified.
- 'src/**' - 'src/**'
- '3rdparty/**' - '3rdparty/**'
# This workflow should run whenever a CMake related file has been modified
- '**/CMakeLists.txt'
jobs: jobs:
build: build:
@ -30,8 +32,6 @@ jobs:
# The ubuntu-latest label currently points to ubuntu-22.04. # The ubuntu-latest label currently points to ubuntu-22.04.
# Available: ubuntu-22.04, ubuntu-20.04 # Available: ubuntu-22.04, ubuntu-20.04
os: [ubuntu-latest] os: [ubuntu-latest]
# Older versions of GCC are not available via unaltered aptitude repo lists.
gcc: ['11']
# We run build checks for both Renewal and PRE-Renewal # We run build checks for both Renewal and PRE-Renewal
mode: ['PRE','RE'] mode: ['PRE','RE']
@ -42,18 +42,18 @@ jobs:
- name: Variable Parsing - PRE - name: Variable Parsing - PRE
if: ${{ matrix.mode == 'PRE' }} if: ${{ matrix.mode == 'PRE' }}
run: | run: |
echo "PRERE=yes" >> $GITHUB_ENV echo "PRERE=ON" >> $GITHUB_ENV
- name: Variable Parsing - RE - name: Variable Parsing - RE
if: ${{ matrix.mode == 'RE' }} if: ${{ matrix.mode == 'RE' }}
run: | run: |
echo "PRERE=no" >> $GITHUB_ENV echo "PRERE=OFF" >> $GITHUB_ENV
- name: Update & Install packages - name: Update & Install packages
# Ubuntu runners already have most of the packages rAthena requires to build. # Ubuntu runners already have most of the packages rAthena requires to build.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2204-Readme.md
run: | run: |
sudo apt update sudo apt update
sudo apt install zlib1g-dev libpcre3-dev gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} sudo apt install zlib1g-dev libpcre3-dev
- name: Start MySQL - name: Start MySQL
run: sudo systemctl start mysql.service run: sudo systemctl start mysql.service
@ -61,16 +61,16 @@ jobs:
- name: Setup Database and import table data - name: Setup Database and import table data
run: ./tools/ci/sql.sh run: ./tools/ci/sql.sh
- name: Command - configure - name: Create build directory
env: run: cmake -E make_directory ${{github.workspace}}/build
CONFIGURE_FLAGS: 'CC=gcc-${{ matrix.gcc }} CXX=g++-${{ matrix.gcc }} --enable-prere=${{ env.PRERE }} --enable-buildbot=yes'
run: ./configure $CONFIGURE_FLAGS
- name: Command - make clean - name: Configure CMake
run: make clean working-directory: ${{github.workspace}}/build
run: cmake .. -DENABLE_PRERENEWAL=${{env.PRERE}} -DENABLE_EXTRA_BUILDBOT_CODE=ON
- name: Command - make server - name: Build
run: make server working-directory: ${{github.workspace}}/build
run: cmake --build . -j2 --target server
- name: Run Once - login-server - name: Run Once - login-server
run: ./login-server --run-once run: ./login-server --run-once

View File

@ -1,48 +0,0 @@
name: Build servers with MSVS
# build_servers_msbuild.yml
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
paths:
# Always trigger all Github Actions if an action or something CI related was changed
- '.github/workflows/**'
- 'tools/ci/**'
# This workflow should run when a file in a source directory has been modified.
- 'src/**'
- '3rdparty/**'
jobs:
build:
# Github Actions checks for '[ci skip]', '[skip ci]', '[no ci]', '[skip actions]', or '[actions skip]' but not a hyphenated version.
# It's a catch-all incase a Pull Request has been opened and someone is on auto-pilot.
if: "!contains(github.event.head_commit.message, 'ci-skip')"
runs-on: ${{ matrix.os }}
strategy:
matrix:
# The windows-latest label currently points to windows-2019.
# Available: windows-2016, windows-2019 and windows-2022
os: [windows-latest]
# We run build checks for both Renewal and PRE-Renewal
mode: ['PRE', 'RE']
steps:
- uses: actions/checkout@v4
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build solution in Debug
if: ${{ matrix.mode == 'PRE' }}
run: msbuild rAthena.sln -t:rebuild -property:Configuration=Debug /p:DefineConstants="BUILDBOT%3BPRERE" /warnaserror
- name: Build solution in Debug
if: ${{ matrix.mode == 'RE' }}
run: msbuild rAthena.sln -t:rebuild -property:Configuration=Debug /p:DefineConstants="BUILDBOT" /warnaserror

View File

@ -18,6 +18,8 @@ on:
# This workflow should run when a file in a source directory has been modified. # This workflow should run when a file in a source directory has been modified.
- 'src/**' - 'src/**'
- '3rdparty/**' - '3rdparty/**'
# This workflow should run whenever a CMake related file has been modified
- '**/CMakeLists.txt'
jobs: jobs:
build: build:
@ -30,8 +32,6 @@ jobs:
# The ubuntu-latest label currently points to ubuntu-22.04. # The ubuntu-latest label currently points to ubuntu-22.04.
# Available: ubuntu-22.04, ubuntu-20.04 # Available: ubuntu-22.04, ubuntu-20.04
os: [ubuntu-latest] os: [ubuntu-latest]
# Older versions of GCC are not available via unaltered aptitude repo lists.
gcc: ['11']
# We run build checks for both Renewal and PRE-Renewal # We run build checks for both Renewal and PRE-Renewal
mode: ['PRE','RE'] mode: ['PRE','RE']
# Check build success for different packet-versions # Check build success for different packet-versions
@ -44,18 +44,18 @@ jobs:
- name: Variable Parsing - PRE - name: Variable Parsing - PRE
if: ${{ matrix.mode == 'PRE' }} if: ${{ matrix.mode == 'PRE' }}
run: | run: |
echo "PRERE=yes" >> $GITHUB_ENV echo "PRERE=ON" >> $GITHUB_ENV
- name: Variable Parsing - RE - name: Variable Parsing - RE
if: ${{ matrix.mode == 'RE' }} if: ${{ matrix.mode == 'RE' }}
run: | run: |
echo "PRERE=no" >> $GITHUB_ENV echo "PRERE=OFF" >> $GITHUB_ENV
- name: Update & Install packages - name: Update & Install packages
# Ubuntu runners already have most of the packages rAthena requires to build. # Ubuntu runners already have most of the packages rAthena requires to build.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md
run: | run: |
sudo apt update sudo apt update
sudo apt install zlib1g-dev libpcre3-dev gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} sudo apt install zlib1g-dev libpcre3-dev
- name: Start MySQL - name: Start MySQL
run: sudo systemctl start mysql.service run: sudo systemctl start mysql.service
@ -63,13 +63,13 @@ jobs:
- name: Setup Database and import table data - name: Setup Database and import table data
run: ./tools/ci/sql.sh run: ./tools/ci/sql.sh
- name: Command - configure - name: Create build directory
env: run: cmake -E make_directory ${{github.workspace}}/build
CONFIGURE_FLAGS: 'CC=gcc-${{ matrix.gcc }} CXX=g++-${{ matrix.gcc }} --enable-prere=${{ env.PRERE }} --enable-packetver=${{ matrix.packetver }} --enable-buildbot=yes'
run: ./configure $CONFIGURE_FLAGS
- name: Command - make clean - name: Configure CMake
run: make clean working-directory: ${{github.workspace}}/build
run: cmake .. -DENABLE_PRERENEWAL=${{env.PRERE}} -DPACKETVER=${{matrix.packetver}} -DENABLE_EXTRA_BUILDBOT_CODE=ON
- name: Command - make all - name: Build
run: make all working-directory: ${{github.workspace}}/build
run: cmake --build . -j2

View File

@ -18,6 +18,8 @@ on:
# This workflow should run when a file in a source directory has been modified. # This workflow should run when a file in a source directory has been modified.
- 'src/**' - 'src/**'
- '3rdparty/**' - '3rdparty/**'
# This workflow should run whenever a CMake related file has been modified
- '**/CMakeLists.txt'
jobs: jobs:
build: build:
@ -30,8 +32,6 @@ jobs:
# The ubuntu-latest label currently points to ubuntu-22.04. # The ubuntu-latest label currently points to ubuntu-22.04.
# Available: ubuntu-22.04, ubuntu-20.04 # Available: ubuntu-22.04, ubuntu-20.04
os: [ubuntu-latest] os: [ubuntu-latest]
# Older versions of GCC are not available via unaltered aptitude repo lists.
gcc: ['11']
# We run build checks for both Renewal and PRE-Renewal # We run build checks for both Renewal and PRE-Renewal
mode: ['PRE', 'RE'] mode: ['PRE', 'RE']
@ -42,18 +42,18 @@ jobs:
- name: Variable Parsing - PRE - name: Variable Parsing - PRE
if: ${{ matrix.mode == 'PRE' }} if: ${{ matrix.mode == 'PRE' }}
run: | run: |
echo "PRERE=yes" >> $GITHUB_ENV echo "PRERE=ON" >> $GITHUB_ENV
- name: Variable Parsing - RE - name: Variable Parsing - RE
if: ${{ matrix.mode == 'RE' }} if: ${{ matrix.mode == 'RE' }}
run: | run: |
echo "PRERE=no" >> $GITHUB_ENV echo "PRERE=OFF" >> $GITHUB_ENV
- name: Update & Install packages - name: Update & Install packages
# Ubuntu runners already have most of the packages rAthena requires to build. # Ubuntu runners already have most of the packages rAthena requires to build.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md
run: | run: |
sudo apt update sudo apt update
sudo apt install zlib1g-dev libpcre3-dev gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} sudo apt install zlib1g-dev libpcre3-dev
- name: Start MySQL - name: Start MySQL
run: sudo systemctl start mysql.service run: sudo systemctl start mysql.service
@ -61,16 +61,16 @@ jobs:
- name: Setup Database and import table data - name: Setup Database and import table data
run: ./tools/ci/sql.sh run: ./tools/ci/sql.sh
- name: Command - configure - name: Create build directory
env: run: cmake -E make_directory ${{github.workspace}}/build
CONFIGURE_FLAGS: 'CC=gcc-${{ matrix.gcc }} CXX=g++-${{ matrix.gcc }} --enable-prere=${{ env.PRERE }} --enable-buildbot=yes --enable-vip=yes'
run: ./configure $CONFIGURE_FLAGS
- name: Command - make clean - name: Configure CMake
run: make clean working-directory: ${{github.workspace}}/build
run: cmake .. -DENABLE_PRERENEWAL=${{env.PRERE}} -DENABLE_EXTRA_BUILDBOT_CODE=ON -DENABLE_VIP=ON
- name: Command - make server - name: Build
run: make server working-directory: ${{github.workspace}}/build
run: cmake --build . -j2 --target server
- name: Run Once - login-server - name: Run Once - login-server
run: ./login-server --run-once run: ./login-server --run-once

View File

@ -1,5 +1,5 @@
name: Build servers with CMake name: Build servers on Windows
# build_servers_cmake.yml # build_servers_windows.yml
concurrency: concurrency:
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }} group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}
@ -29,25 +29,19 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
# The ubuntu-latest label currently points to ubuntu-22.04. os: [windows-latest]
# Available: ubuntu-22.04, ubuntu-20.04
os: [ubuntu-latest]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
# Install latest CMake.
- uses: lukka/get-cmake@latest
- name: Create build directory - name: Create build directory
run: mkdir cbuild run: cmake -E make_directory ${{github.workspace}}/build
- name: Create Unix Makefiles - name: Configure CMake
run: | working-directory: ${{github.workspace}}/build
cd cbuild run: cmake ..
cmake -G "Unix Makefiles" ..
- name: Command - make - name: Build
run: | working-directory: ${{github.workspace}}/build
cd cbuild # Execute the build. You can specify a specific target with "--target <NAME>"
make run: cmake --build . -j2 --target server tools

View File

@ -21,6 +21,8 @@ on:
# This workflow should run when a file in either the db/ or npc/ directory has been modified. # This workflow should run when a file in either the db/ or npc/ directory has been modified.
- 'db/**' - 'db/**'
- 'npc/**' - 'npc/**'
# This workflow should run whenever a CMake related file has been modified
- '**/CMakeLists.txt'
jobs: jobs:
build: build:
@ -33,8 +35,6 @@ jobs:
# The ubuntu-latest label currently points to ubuntu-22.04. # The ubuntu-latest label currently points to ubuntu-22.04.
# Available: ubuntu-22.04, ubuntu-20.04 # Available: ubuntu-22.04, ubuntu-20.04
os: [ubuntu-latest] os: [ubuntu-latest]
# Only a single version of GCC is required for validating NPC scripts and database changes.
gcc: ['11']
# We run build checks for both Renewal and PRE-Renewal # We run build checks for both Renewal and PRE-Renewal
mode: ['PRE', 'RE'] mode: ['PRE', 'RE']
@ -45,18 +45,18 @@ jobs:
- name: Variable Parsing - PRE - name: Variable Parsing - PRE
if: ${{ matrix.mode == 'PRE' }} if: ${{ matrix.mode == 'PRE' }}
run: | run: |
echo "PRERE=yes" >> $GITHUB_ENV echo "PRERE=ON" >> $GITHUB_ENV
- name: Variable Parsing - RE - name: Variable Parsing - RE
if: ${{ matrix.mode == 'RE' }} if: ${{ matrix.mode == 'RE' }}
run: | run: |
echo "PRERE=no" >> $GITHUB_ENV echo "PRERE=OFF" >> $GITHUB_ENV
- name: Update & Install packages - name: Update & Install packages
# Ubuntu runners already have most of the packages rAthena requires to build. # Ubuntu runners already have most of the packages rAthena requires to build.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2204-Readme.md
run: | run: |
sudo apt update sudo apt update
sudo apt install zlib1g-dev libpcre3-dev gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} sudo apt install zlib1g-dev libpcre3-dev
- name: Start MySQL - name: Start MySQL
run: sudo systemctl start mysql.service run: sudo systemctl start mysql.service
@ -64,24 +64,20 @@ jobs:
- name: Setup Database and import table data - name: Setup Database and import table data
run: ./tools/ci/sql.sh run: ./tools/ci/sql.sh
- name: Command - configure - name: Create build directory
env: run: cmake -E make_directory ${{github.workspace}}/build
CONFIGURE_FLAGS: 'CC=gcc-${{ matrix.gcc }} CXX=g++-${{ matrix.gcc }} --enable-prere=${{ env.PRERE }} --enable-buildbot=yes'
run: ./configure $CONFIGURE_FLAGS - name: Configure CMake
working-directory: ${{github.workspace}}/build
run: cmake .. -DENABLE_PRERENEWAL=${{env.PRERE}} -DENABLE_EXTRA_BUILDBOT_CODE=ON
- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build . -j2 --target map-server
# npc.sh enables all NPC scripts in the custom and test folders. # npc.sh enables all NPC scripts in the custom and test folders.
- name: Enable All NPCs for Testing - name: Enable All NPCs for Testing
run: ./tools/ci/npc.sh run: ./tools/ci/npc.sh
- name: Command - make clean
run: make clean
# Create import directories
- name: Command - make import
run: make import
- name: Command - make map
run: make map
- name: Run Once - map-server - name: Run Once - map-server
run: ./map-server --run-once run: ./map-server --run-once

6
.gitignore vendored
View File

@ -139,6 +139,12 @@ Thumbs.db
/yamlupgrade.bat /yamlupgrade.bat
/navigenerator.bat /navigenerator.bat
# Linux script tools
/athena-start.sh
# /function.sh
# /install.sh
# /uninstall.sh
# dlls # dlls
/libmysql.dll /libmysql.dll
/pcre8.dll /pcre8.dll

View File

@ -1,38 +1,18 @@
cmake_minimum_required(VERSION 2.8) add_library(httplib STATIC)
if ( NOT ENABLE_WEB_SERVER ) target_sources(httplib PRIVATE "httplib.cc")
return()
endif( NOT ENABLE_WEB_SERVER )
SET (this_target httplib) target_include_directories(httplib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
PROJECT(${this_target})
find_path ( HTTPLIB_INCLUDE_DIRS "httplib.h" if(NOT WIN32)
PATHS "${CMAKE_CURRENT_SOURCE_DIR}" target_compile_definitions(httplib PUBLIC "CPPHTTPLIB_SEND_FLAGS=MSG_NOSIGNAL")
NO_DEFAULT_PATH ) endif()
find_path ( HTTPLIB_SOURCE_DIR "httplib.cc" if(WIN32)
PATHS "${CMAKE_CURRENT_SOURCE_DIR}" target_sources(httplib PRIVATE "httplib.h")
NO_DEFAULT_PATH ) set_target_properties(httplib PROPERTIES FOLDER "3rdparty")
endif()
mark_as_advanced( HTTPLIB_INCLUDE_DIRS )
mark_as_advanced( HTTPLIB_SOURCE_DIR ) if(NOT ENABLE_WEB_SERVER)
set_target_properties(httplib PROPERTIES EXCLUDE_FROM_ALL TRUE)
set ( HTTPLIB_HEADERS
"${HTTPLIB_INCLUDE_DIRS}/httplib.h"
CACHE INTERNAL "httplib headers" )
set ( HTTPLIB_SOURCES
"${HTTPLIB_SOURCE_DIR}/httplib.cc"
CACHE INTERNAL "httplib sources" )
set ( HTTPLIB_DEFINITIONS
"-std=c++11"
CACHE INTERNAL "http definitions" )
include_directories( ${HTTPLIB_INCLUDE_DIRS} ${HTTPLIB_SOURCE_DIR} )
ADD_LIBRARY( ${this_target} STATIC ${HTTPLIB_SOURCES} )
if (NOT WIN32)
target_compile_definitions(${this_target} PUBLIC "CPPHTTPLIB_SEND_FLAGS=MSG_NOSIGNAL")
endif() endif()

View File

@ -1,7 +1,3 @@
cmake_minimum_required(VERSION 2.8) add_library(json INTERFACE)
set (JSON_INCLUDE_DIRS target_include_directories(json INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
"${CMAKE_CURRENT_SOURCE_DIR}/include"
CACHE INTERNAL "json include dir" )
mark_as_advanced( JSON_INCLUDE_DIRS )

View File

@ -1,29 +1,27 @@
find_path( LIBCONFIG_INCLUDE_DIRS "libconfig.h" add_library(libconfig STATIC)
PATHS "${CMAKE_CURRENT_SOURCE_DIR}"
NO_DEFAULT_PATH )
find_path( LIBCONFIG_SOURCE_DIR "libconfig.c"
PATHS "${CMAKE_CURRENT_SOURCE_DIR}"
NO_DEFAULT_PATH )
mark_as_advanced( LIBCONFIG_INCLUDE_DIRS )
mark_as_advanced( LIBCONFIG_SOURCE_DIR )
set( LIBCONFIG_HEADERS target_sources(libconfig PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/grammar.h" "grammar.c"
"${CMAKE_CURRENT_SOURCE_DIR}/libconfig.h" "libconfig.c"
"${CMAKE_CURRENT_SOURCE_DIR}/parsectx.h" "scanctx.c"
"${CMAKE_CURRENT_SOURCE_DIR}/scanctx.h" "scanner.c"
"${CMAKE_CURRENT_SOURCE_DIR}/scanner.h" "strbuf.c"
"${CMAKE_CURRENT_SOURCE_DIR}/strbuf.h" )
"${CMAKE_CURRENT_SOURCE_DIR}/wincompat.h"
CACHE INTERNAL "libconfig headers" ) target_include_directories(libconfig PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
set( LIBCONFIG_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/grammar.c" target_compile_definitions(libconfig PUBLIC "-DLIBCONFIG_STATIC")
"${CMAKE_CURRENT_SOURCE_DIR}/libconfig.c"
"${CMAKE_CURRENT_SOURCE_DIR}/scanctx.c" if(WIN32)
"${CMAKE_CURRENT_SOURCE_DIR}/scanner.c" target_sources(libconfig PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/strbuf.c" "grammar.h"
CACHE INTERNAL "libconfig sources" ) "libconfig.h"
set( LIBCONFIG_DEFINITIONS "parsectx.h"
"-DLIBCONFIG_STATIC" "scanctx.h"
CACHE INTERNAL "libconfig definitions" ) "scanner.h"
"strbuf.h"
"wincompat.h"
)
set_target_properties(libconfig PROPERTIES FOLDER "3rdparty")
endif()

View File

@ -95,6 +95,7 @@ endif()
c4_add_dev_targets() c4_add_dev_targets()
add_custom_target(ryml-uninstall # rathena
"${CMAKE_COMMAND}" -P "${PROJECT_SOURCE_DIR}/cmake/uninstall.cmake" if(WIN32)
) set_target_properties(ryml PROPERTIES FOLDER "3rdparty")
endif()

View File

@ -78,13 +78,6 @@ endif()
set(C4CORE_AMALGAMATED ${C4CORE_SRC_DIR}/../src_singleheader/c4/c4core_all.hpp) set(C4CORE_AMALGAMATED ${C4CORE_SRC_DIR}/../src_singleheader/c4/c4core_all.hpp)
list(TRANSFORM C4CORE_SRC_FILES PREPEND "${C4CORE_SRC_DIR}/" OUTPUT_VARIABLE C4CORE_SRC_FILES_FULL) list(TRANSFORM C4CORE_SRC_FILES PREPEND "${C4CORE_SRC_DIR}/" OUTPUT_VARIABLE C4CORE_SRC_FILES_FULL)
add_custom_target(c4core-amalgamate
python ${CMAKE_CURRENT_LIST_DIR}/tools/amalgamate.py ${C4CORE_AMALGAMATED}
COMMENT "${CMAKE_CURRENT_LIST_DIR}/tools/amalgamate.py ${C4CORE_AMALGAMATED}"
BYPRODUCTS ${C4CORE_AMALGAMATED}
DEPENDS ${C4CORE_SRC_FILES_FULL}
)
c4_add_library(c4core c4_add_library(c4core
INC_DIRS INC_DIRS
$<BUILD_INTERFACE:${C4CORE_SRC_DIR}> $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${C4CORE_SRC_DIR}> $<INSTALL_INTERFACE:include>
@ -105,3 +98,8 @@ c4_install_exports()
c4_add_dev_targets() c4_add_dev_targets()
c4_pack_project(TYPE LIBRARY) c4_pack_project(TYPE LIBRARY)
# rathena
if(WIN32)
set_target_properties(c4core PROPERTIES FOLDER "3rdparty")
endif()

View File

@ -1,87 +1,78 @@
cmake_minimum_required(VERSION 2.8) set(YAML_HEADERS
"yaml.h"
"traits.h"
"stlemitter.h"
"parser.h"
"ostream_wrapper.h"
"null.h"
"noncopyable.h"
"noexcept.h"
"mark.h"
"exceptions.h"
"eventhandler.h"
"emitterstyle.h"
"emittermanip.h"
"emitter.h"
"emitterdef.h"
"emitfromevents.h"
"dll.h"
"depthguard.h"
"binary.h"
"anchor.h"
"node/type.h"
"node/ptr.h"
"node/parse.h"
"node/node.h"
"node/iterator.h"
"node/impl.h"
"node/emit.h"
"node/convert.h"
"contrib/graphbuilder.h"
"contrib/anchordict.h"
)
list(TRANSFORM YAML_HEADERS PREPEND "include/yaml-cpp/")
## start setting set(YAML_SOURCES
SET (this_target yaml-cpp) "binary.cpp"
PROJECT(${this_target}) "convert.cpp"
"depthguard.cpp"
"directives.cpp"
"emit.cpp"
"emitfromevents.cpp"
"emitter.cpp"
"emitterstate.cpp"
"emitterutils.cpp"
"exceptions.cpp"
"exp.cpp"
"memory.cpp"
"nodebuilder.cpp"
"node.cpp"
"node_data.cpp"
"nodeevents.cpp"
"null.cpp"
"ostream_wrapper.cpp"
"parse.cpp"
"parser.cpp"
"regex_yaml.cpp"
"scanner.cpp"
"scanscalar.cpp"
"scantag.cpp"
"scantoken.cpp"
"simplekey.cpp"
"singledocparser.cpp"
"stream.cpp"
"tag.cpp"
"contrib/graphbuilderadapter.cpp"
"contrib/graphbuilder.cpp"
)
list(TRANSFORM YAML_SOURCES PREPEND "src/")
find_path( YAML_INCLUDE_DIRS "yaml-cpp/yaml.h" add_library(yaml-cpp STATIC EXCLUDE_FROM_ALL ${YAML_SOURCES})
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include"
NO_DEFAULT_PATH )
find_path( YAML_SOURCE_DIR "regex_yaml.cpp"
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/src"
NO_DEFAULT_PATH )
mark_as_advanced( YAML_INCLUDE_DIRS )
mark_as_advanced( YAML_SOURCE_DIR )
set( YAML_HEADERS target_include_directories(yaml-cpp PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
"${YAML_INCLUDE_DIRS}/yaml-cpp/yaml.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/traits.h" target_compile_definitions(yaml-cpp PUBLIC "-DYAML_CPP_STATIC_DEFINE")
"${YAML_INCLUDE_DIRS}/yaml-cpp/stlemitter.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/parser.h" if(WIN32)
"${YAML_INCLUDE_DIRS}/yaml-cpp/ostream_wrapper.h" set_target_properties(yaml-cpp PROPERTIES FOLDER "3rdparty")
"${YAML_INCLUDE_DIRS}/yaml-cpp/null.h" endif()
"${YAML_INCLUDE_DIRS}/yaml-cpp/noncopyable.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/noexcept.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/mark.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/exceptions.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/eventhandler.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/emitterstyle.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/emittermanip.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/emitter.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/emitterdef.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/emitfromevents.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/dll.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/depthguard.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/binary.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/anchor.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/type.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/ptr.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/parse.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/node.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/iterator.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/impl.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/emit.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/convert.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/contrib/graphbuilder.h"
"${YAML_INCLUDE_DIRS}/yaml-cpp/contrib/anchordict.h"
CACHE INTERNAL "yaml headers" )
set( YAML_SOURCES
"${YAML_SOURCE_DIR}/binary.cpp"
"${YAML_SOURCE_DIR}/convert.cpp"
"${YAML_SOURCE_DIR}/depthguard.cpp"
"${YAML_SOURCE_DIR}/directives.cpp"
"${YAML_SOURCE_DIR}/emit.cpp"
"${YAML_SOURCE_DIR}/emitfromevents.cpp"
"${YAML_SOURCE_DIR}/emitter.cpp"
"${YAML_SOURCE_DIR}/emitterstate.cpp"
"${YAML_SOURCE_DIR}/emitterutils.cpp"
"${YAML_SOURCE_DIR}/exceptions.cpp"
"${YAML_SOURCE_DIR}/exp.cpp"
"${YAML_SOURCE_DIR}/memory.cpp"
"${YAML_SOURCE_DIR}/nodebuilder.cpp"
"${YAML_SOURCE_DIR}/node.cpp"
"${YAML_SOURCE_DIR}/node_data.cpp"
"${YAML_SOURCE_DIR}/nodeevents.cpp"
"${YAML_SOURCE_DIR}/null.cpp"
"${YAML_SOURCE_DIR}/ostream_wrapper.cpp"
"${YAML_SOURCE_DIR}/parse.cpp"
"${YAML_SOURCE_DIR}/parser.cpp"
"${YAML_SOURCE_DIR}/regex_yaml.cpp"
"${YAML_SOURCE_DIR}/scanner.cpp"
"${YAML_SOURCE_DIR}/scanscalar.cpp"
"${YAML_SOURCE_DIR}/scantag.cpp"
"${YAML_SOURCE_DIR}/scantoken.cpp"
"${YAML_SOURCE_DIR}/simplekey.cpp"
"${YAML_SOURCE_DIR}/singledocparser.cpp"
"${YAML_SOURCE_DIR}/stream.cpp"
"${YAML_SOURCE_DIR}/tag.cpp"
"${YAML_SOURCE_DIR}/contrib/graphbuilderadapter.cpp"
"${YAML_SOURCE_DIR}/contrib/graphbuilder.cpp"
CACHE INTERNAL "yaml sources" )
set( YAML_DEFINITIONS
"-std=c++11"
CACHE INTERNAL "yaml definitions" )
include_directories(${YAML_INCLUDE_DIRS} ${YAML_SOURCE_DIR})
#message(STATUS "YAML_INCLUDE_DIRS : ${YAML_INCLUDE_DIRS}, YAML_SOURCE_DIR=${YAML_SOURCE_DIR}")
ADD_LIBRARY(${this_target} STATIC ${YAML_SOURCES} )
target_compile_definitions(${this_target} PUBLIC "-DYAML_CPP_STATIC_DEFINE")

View File

@ -1,630 +1,105 @@
##################################################################### cmake_minimum_required(VERSION 3.11)
#
# "Getting Started with CMake", a tutorial video by Eric Wing. project(rAthena)
# Part 1 of 6: http://www.youtube.com/watch?v=CLvZTyji_Uw
# Part 2 of 6: http://www.youtube.com/watch?v=gUW-RrRQjEg # Configure CMake Modules
# Part 3 of 6: http://www.youtube.com/watch?v=sz6cPhbuTk4 list(APPEND CMAKE_MODULE_PATH
# Part 4 of 6: http://www.youtube.com/watch?v=JICZOkyNXbg "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake"
# Part 5 of 6: http://www.youtube.com/watch?v=lAiuLHy4dCk "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
# Part 6 of 6: http://www.youtube.com/watch?v=fAtJNzDZdH8
#
# You can use notepad++ for syntax highlighting.
# Naming conventions:
# WITH_* : option to use an external package or not
# ENABLE_* : option to use an internal feature/code or not
# HAVE_* : internal variable indicating if we have and are using something
#
# Maintainers: Flavio J. Saraiva (feel free to send complaints or suggestions)
# flaviojs @ rAthena forum/irc
# flaviojs2005 \A-T/ gmail <D.o,T> com
# lightaisme \A-T/ gmail <D.o,T> com
#
#####################################################################
#cmake_minimum_required( VERSION 2.8.4 ) # options
# Functional changes from 2.8.3 to 2.8.4: set(PACKETVER 20211103 CACHE STRING "Sets the PACKETVER define of the servers (see src/common/mmo.hpp)")
# string(SUBSTRING) works with length -1 as "rest of string" set(MAXCONN CACHE STRING "Sets the MAXCONN define of the servers. (see src/common/socket.hpp)")
# changes to some CPack generators option(ENABLE_PRERENEWAL "Whether or not to enable Pre-renewal (default=OFF)" OFF)
# CYGWIN no longer defines WIN32 option(ENABLE_WEB_SERVER "Build web-server (default=ON)" ON)
# CMP0017: Prefer files from the CMake module directory when including from there. option(ENABLE_RDTSC "Enable RDTSC instruction as a timing source (default=OFF)" OFF)
# Update to 3.1 for CMAKE_CXX_STANDARD cross support definition option(ENABLE_EXTRA_DEBUG_CODE "Enable extra debug code (default=OFF)" OFF)
set( CMAKE_LEGACY_CYGWIN_WIN32 0 ) option(ENABLE_MEMMGR "Enable memory manager (default=ON)" ON)
cmake_minimum_required( VERSION 3.1 ) # TODO(vstumpf): If no one uses this, we can just remove it
project( rAthena ) # set(ENABLE_MEMORY "system" CACHE STRING "Enable memory library (default=system)")
if( CYGWIN ) option(ENABLE_PROFILER "Enable profiler (default=OFF)" OFF)
unset( WIN32 ) option(ENABLE_EXTRA_BUILDBOT_CODE "Enable extra buildbot code (default=OFF)" OFF)
endif() option(ENABLE_EPOLL "Use epoll instead of select (default=OFF)" OFF)
set(CMAKE_CXX_STANDARD 17) # C++17... option(ENABLE_VIP "Enable VIP system (default=OFF)" OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
#set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
#actually this might be misleading for arm...
if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
set(architecture x86)
elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(architecture x64)
else()
message( FATAL_ERROR "unexpected architecture (CMAKE_SIZEOF_VOID_P is ${CMAKE_SIZEOF_VOID_P})" )
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_C_CREATE_SHARED_LIBRARY)
set(CMAKE_CXX_CREATE_SHARED_LIBRARY)
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_RELEASE_POSTFIX "r")
# Set a default build type if none was specified # Set a default build type if none was specified
set(default_build_type "Release") set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE) STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel" FORCE)
# Set the possible values of build type for cmake-gui message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif() endif()
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(ENABLE_MSVC_PARALLEL ON CACHE STRING "\
Enables /MP flag for parallel builds using MSVC. Specify an integer value to control \
the number of threads used (Only works on versions of Visual Studio). Setting to ON \
lets the toolchain decide how many threads to use. Set to OFF to disable /MP completely." )
if(ENABLE_MSVC_PARALLEL)
if(ENABLE_MSVC_PARALLEL GREATER 0)
string(APPEND CMAKE_C_FLAGS " /MP${ENABLE_MSVC_PARALLEL}")
string(APPEND CMAKE_CXX_FLAGS " /MP${ENABLE_MSVC_PARALLEL}")
else()
string(APPEND CMAKE_C_FLAGS " /MP")
string(APPEND CMAKE_CXX_FLAGS " /MP")
endif()
endif()
endif()
# #
# Prevent building in the source directory by default # Prevent building in the source directory by default
# #
option( ALLOW_SAME_DIRECTORY "Allow CMake to build in the source directory." OFF ) if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
if( ALLOW_SAME_DIRECTORY )
elseif( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" )
message( FATAL_ERROR message( FATAL_ERROR
"Do not use the source directory to build your files, instead delete CMakeCache.txt, create a separate folder and build there.\n" "Do not use the source directory to build your files, instead delete CMakeCache.txt, create a separate folder and build there.\n"
"Example: (build in subdir 'build' and install to source dir)\n" "Example: (build in subdir 'build' and install to source dir)\n"
" rm -f CMakeCache.txt\n" " rm -f CMakeCache.txt\n"
" mkdir build\n" " mkdir build\n"
" cd build\n" " cd build\n"
" cmake -G\"Unix Makefiles\" -DINSTALL_TO_SOURCE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\n" " cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\n"
" make install\n" " make install\n"
" cd ..\n" " cd ..\n"
" rm -rf build\n" " rm -rf build\n")
"To skip this check, set ALLOW_SAME_DIRECTORY to ON (-DALLOW_SAME_DIRECTORY=ON)" )
endif() endif()
if(WIN32)
# set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Global stuff
#
set( GLOBAL_LIBRARIES ${LINK_LIBRARIES} CACHE INTERNAL "" )# list (comma separated values)
set( GLOBAL_INCLUDE_DIRS ${INCLUDE_DIRECTORIES} CACHE INTERNAL "" )# list (comma separated values)
set( GLOBAL_DEFINITIONS ${COMPILE_DEFINITIONS} CACHE INTERNAL "" )# string (space separated values -DFOO=bar)
mark_as_advanced( GLOBAL_LIBRARIES GLOBAL_INCLUDE_DIRS GLOBAL_DEFINITIONS )
if( WIN32 )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DFD_SETSIZE=4096" )
endif()
if( MSVC )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} "oldnames.lib" "ws2_32.lib" )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE" )
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -fno-strict-aliasing" )
#set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -O2" ); #need more test to enable this
endif() endif()
# Configure C++ Standard
# set(CMAKE_CXX_STANDARD 17)
# 3rd party set(CMAKE_CXX_STANDARD_REQUIRED ON)
#
set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake CACHE INTERNAL "" )
include( CheckCSourceCompiles )
include( CheckCSourceRuns )
include( CheckIncludeFile )
include( CheckFunctionExists )
include( FindFunctionLibrary )
include( TestBigEndian )
# # Set build directories
# PACKETVER set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
set( PACKETVER CACHE STRING "Sets the PACKETVER define of the servers. (see src/common/mmo.h)" ) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if( PACKETVER )
list( APPEND GLOBAL_DEFINITIONS PACKETVER=${PACKETVER} )
endif()
if(WIN32)
set(RuntimeOutputDir "${CMAKE_BINARY_DIR}/..")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${RuntimeOutputDir})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${RuntimeOutputDir})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${RuntimeOutputDir})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${RuntimeOutputDir})
# if (MSVC AND NOT MSVC_VERSION VERSION_LESS 142)
# Find git add_link_options($<$<CONFIG:Debug>:/INCREMENTAL>)
# add_compile_options($<$<CONFIG:Debug>:/ZI>)
message( STATUS "Detecting git" )
find_package(Git)
if(GIT_FOUND)
if(GIT_VERSION_STRING)
message(STATUS "Found git : ${GIT_EXECUTABLE} version (${GIT_VERSION_STRING})")
else()
message(STATUS "Found git : ${GIT_EXECUTABLE}")
endif() endif()
add_compile_definitions($<$<CONFIG:DEBUG>:_ITERATOR_DEBUG_LEVEL=0>)
endif() endif()
include(GetGitVersion) add_subdirectory(db)
get_git_version() add_subdirectory(conf)
add_subdirectory(3rdparty)
add_subdirectory(src)
add_subdirectory(tools)
#include(GetSvnVersion) add_custom_target(server
#get_svn_version(SVN_VERSION) DEPENDS login-server char-server map-server web-server scripts
#message( STATUS "SVN_VERSION: ${SVN_VERSION}" ) )
#
# threads
#
message( STATUS "Detecting threads library" )
set( CMAKE_THREAD_PREFER_PTHREAD 1 )
find_package(Threads REQUIRED)
if( CMAKE_THREAD_LIBS_INIT )
message( STATUS "Adding global library: ${CMAKE_THREAD_LIBS_INIT}" )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
endif()
message( STATUS "Detecting threads library - done" )
message( STATUS "Check if supporting Thread local storage (TLS)" )
file( READ "${CMAKE_SOURCE_DIR}/3rdparty/cmake/tests/HAVE_TLS.c" _SOURCE )
CHECK_C_SOURCE_RUNS( "${_SOURCE}" HAVE_TLS )
if( HAVE_TLS )
message( STATUS "Check for TLS- yes" )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DHAVE_TLS" )
else()
message( STATUS "Check for TLS - no" )
endif()
#
# math library (FreeBSD/Linux/Solaris)
#
if( NOT WIN32 )
message( STATUS "Detecting math library (m)" )
CHECK_INCLUDE_FILE( math.h HAVE_MATH_H )
if( NOT HAVE_MATH_H )
message( FATAL_ERROR "math.h not found" )
endif()
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
find_function_library( floor FUNCTION_FLOOR_LIBRARIES m )
if( FUNCTION_FLOOR_LIBRARIES )
message( STATUS "Adding global library: ${FUNCTION_FLOOR_LIBRARIES}" )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_FLOOR_LIBRARIES} )
endif()
message( STATUS "Detecting math library (m) - done" )
endif()
#
# dynamic loading library (Linux)
#
if( NOT WIN32 )
message( STATUS "Detecting dynamic loading library (dl)" )
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
find_function_library( dlopen FUNCTION_DLOPEN_LIBRARIES dl )
if( FUNCTION_DLOPEN_LIBRARIES )
message( STATUS "Adding global library: ${FUNCTION_DLOPEN_LIBRARIES}" )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_DLOPEN_LIBRARIES} )
endif()
message( STATUS "Detecting dynamic loading library (dl) - done" )
endif()
#
# networking library (Solaris/MinGW)
#
if( NOT MSVC )
message( STATUS "Detecting networking library (socket/nsl/ws2_32)" )
#set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
#find_function_library( bind FUNCTION_BIND_LIBRARIES socket ws2_32 )
#if( FUNCTION_BIND_LIBRARIES )
# message( STATUS "Adding global library: ${FUNCTION_BIND_LIBRARIES}" )
# set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_BIND_LIBRARIES} )
#endif()
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
find_function_library( gethostbyname FUNCTION_GETHOSTBYNAME_LIBRARIES nsl )
if( FUNCTION_GETHOSTBYNAME_LIBRARIES )
message( STATUS "Adding global library: ${FUNCTION_GETHOSTBYNAME_LIBRARIES}" )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_GETHOSTBYNAME_LIBRARIES} )
endif()
message( STATUS "Detecting networking library (socket/nsl/ws2_32) - done" )
endif()
#
# enable web server?
#
option( ENABLE_WEB_SERVER "Build web-server (default=ON)" ON )
#
# Test for big endian
#
TEST_BIG_ENDIAN( BIG_ENDIAN )
if( NOT DEFINED BIG_ENDIAN )
message( WARNING "unable to determine endianness, only LITTLE ENDIAN is supported" )
elseif( BIG_ENDIAN )
message( FATAL_ERROR "bigendian is not supported" )
endif()
#
# Test monotonic clock
#
# CLOCK_MONOTONIC clock for clock_gettime
# Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
# compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
# >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
# checked but some systems define them even when they do not support it
# (ref. bugreport:1003).
#
message( STATUS "Check for monotonic clock" )
find_library( RT_LIBRARY rt )# (optional, rt on Debian)
mark_as_advanced( RT_LIBRARY )
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ${RT_LIBRARY} )
file( READ "${CMAKE_SOURCE_DIR}/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c" _SOURCE )
CHECK_C_SOURCE_RUNS( "${_SOURCE}" HAVE_MONOTONIC_CLOCK )
if( HAVE_MONOTONIC_CLOCK )
message( STATUS "Check for monotonic clock - yes" )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${RT_LIBRARY} )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DHAVE_MONOTONIC_CLOCK" )
else()
message( STATUS "Check for monotonic clock - no" )
endif()
#
# Test if function exists:
# setrlimit - used to set the socket limit
# strnlen - string length with upper scan bound
# getpid - process id
# gettid - thread id
#
CHECK_FUNCTION_EXISTS( setrlimit HAVE_SETRLIMIT )
CHECK_FUNCTION_EXISTS( strnlen HAVE_STRNLEN )
CHECK_FUNCTION_EXISTS( getpid HAVE_GETPID )
CHECK_FUNCTION_EXISTS( gettid HAVE_GETTID )
foreach( define HAVE_SETRLIMIT HAVE_STRNLEN HAVE_GETPID HAVE_GETTID )
if( ${define} )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -D${define}" )
endif()
endforeach()
#
# Use RDTSC instruction as a timing source (time stamp counter on x86 since Pentium) (default=OFF)
#
# Enable it when you've timing issues. (ex: in conjunction with XEN or Other Virtualization mechanisms)
# Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
# (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual how to disable it)
#
option( ENABLE_RDTSC "use RDTSC instruction as a timing source (default=OFF)" OFF )
if( ENABLE_RDTSC )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DENABLE_RDTSC" )
message( STATUS "Enabled RDTSC as a timing source" )
endif()
#
# Enable extra debug code (default=OFF)
#
option( ENABLE_EXTRA_DEBUG_CODE "enable extra debug code (default=OFF)" OFF )
if( ENABLE_EXTRA_DEBUG_CODE )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DDEBUG" )
message( STATUS "Enabled extra DEBUG code" )
endif()
#
# Enable EPOLL (default=OFF)
# Only for Linux
#
option( ENABLE_EXTRA_SOCKET_POLL "enable SOCKET_EPOLL (default=OFF)" OFF )
if( ENABLE_EXTRA_SOCKET_POLL )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DSOCKET_EPOLL" )
message( STATUS "Enabled SOCKET_EPOLL" )
endif()
#
# Enable builtin memory manager (default=default)
#
set( MEMMGR_OPTIONS "default;yes;no" )
set( ENABLE_MEMMGR "default" CACHE STRING "enable builtin memory manager: ${MEMMGR_OPTIONS} (default=default)" )
set_property( CACHE ENABLE_MEMMGR PROPERTY STRINGS ${MEMMGR_OPTIONS} )
if( ENABLE_MEMMGR STREQUAL "default" )
# use source code default
elseif( ENABLE_MEMMGR STREQUAL "yes" )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DUSE_MEMMGR" )
message( STATUS "Enabled the builtin memory manager" )
elseif( ENABLE_MEMMGR STREQUAL "no" )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DNO_MEMMGR" )
message( STATUS "Disabled the builtin memory manager" )
else()
message( FATAL_ERROR "invalid option ENABLE_MEMMGR=${ENABLE_MEMMGR} (valid options: ${MEMMGR_OPTIONS})" )
endif()
#
# Enable memory library (default=system)
#
set( MEMORY_OPTIONS "system;memwatch;dmalloc;gcollect" )
set( ENABLE_MEMORY "system" CACHE STRING "enable memory library: ${MEMORY_OPTIONS} (default=system)" )
set_property( CACHE ENABLE_MEMORY PROPERTY STRINGS ${MEMORY_OPTIONS} )
if( ENABLE_MEMORY STREQUAL "system" )
# use system functions
elseif( ENABLE_MEMORY STREQUAL "memwatch" )
CHECK_INCLUDE_FILE( memwatch.h HAVE_MEMWATCH_H )
find_library( MEMWATCH_LIBRARY memwatch )
mark_as_advanced( MEMWATCH_LIBRARY )
if( HAVE_MEMWATCH_H AND MEMWATCH_LIBRARY )
message( STATUS "Adding global library: ${MEMWATCH_LIBRARY}" )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${MEMWATCH_LIBRARY} )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DMEMWATCH" )
message( STATUS "Enabled the memory library memwatch" )
else()
message( FATAL_ERROR "Failed to enable the memory library memwatch" )
endif()
elseif( ENABLE_MEMORY STREQUAL "dmalloc" )
CHECK_INCLUDE_FILE( dmalloc.h HAVE_DMALLOC_H )
find_library( DMALLOC_LIBRARY dmalloc )
mark_as_advanced( DMALLOC_LIBRARY )
if( HAVE_DMALLOC_H AND DMALLOC_LIBRARY )
message( STATUS "Adding global library: ${DMALLOC_LIBRARY}" )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${DMALLOC_LIBRARY} )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DDMALLOC -DDMALLOC_FUNC_CHECK" )
message( STATUS "Enabled the memory library dmalloc" )
else()
message( FATAL_ERROR "Failed to enable the memory library dmalloc" )
endif()
elseif( ENABLE_MEMORY STREQUAL "gcollect" )
CHECK_INCLUDE_FILE( gc.h HAVE_GC_H )
find_library( GC_LIBRARY gc )
mark_as_advanced( GC_LIBRARY )
if( HAVE_GC_H AND GC_LIBRARY )
message( STATUS "Adding global library: ${GC_LIBRARY}" )
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${GC_LIBRARY} )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DGCOLLECT" )
message( STATUS "Enabled the memory library gcollect" )
else()
message( FATAL_ERROR "Failed to enable the memory library gcollect" )
endif()
else()
message( FATAL_ERROR "invalid option ENABLE_MEMORY=${ENABLE_MEMORY} (valid options: ${MEMORY_OPTIONS})" )
endif()
#
# Enable profiler (default=none)
#
set( PROFILER_OPTIONS "none;gprof" )
set( ENABLE_PROFILER "none" CACHE STRING "enable profiler: ${PROFILER_OPTIONS} (default=none)" )
set_property( CACHE ENABLE_PROFILER PROPERTY STRINGS ${PROFILER_OPTIONS} )
if( ENABLE_PROFILER STREQUAL "none" )
# no profiler
elseif( ENABLE_PROFILER STREQUAL "gprof" )
if( CMAKE_C_COMPILER_ID STREQUAL "GNU" )
if( NOT HAVE_GPROF_FLAGS )
set_property( CACHE CMAKE_C_FLAGS PROPERTY VALUE "${CMAKE_C_FLAGS} -pg" )
set_property( CACHE CMAKE_EXE_LINKER_FLAGS PROPERTY VALUE "${CMAKE_EXE_LINKER_FLAGS} -pg" )
set( HAVE_GPROF_FLAGS ON CACHE INTERNAL "" )
endif()
message( STATUS "Enabled the profiler gprof" )
else()
message( FATAL_ERROR "Failed to enable the profiler gprof - not GNU" )
endif()
else()
message( FATAL_ERROR "invalid option ENABLE_PROFILER=${ENABLE_PROFILER} (valid options: ${PROFILER_OPTIONS})" )
endif()
#
# Enable extra buildbot code (default=OFF)
#
option( ENABLE_EXTRA_BUILDBOT_CODE "enable extra buildbot code (default=OFF)" OFF )
if( ENABLE_EXTRA_BUILDBOT_CODE )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DBUILDBOT" )
message( STATUS "Enabled extra BUILDBOT code" )
endif()
#####################################################################
# package stuff
#
set( CPACK_PACKAGE_NAME "rAthena" )
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "MMORPG server package" )
set( CPACK_PACKAGE_VERSION ${SVNVERSION} )
set( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE )
#set( CPACK_MONOLITHIC_INSTALL ON )
include( CPACK OPTIONAL RESULT_VARIABLE HAVE_CPACK )
if( HAVE_CPACK )
option( WITH_CPACK "enable building packages with CPack ('package' target)" ON )
endif()
if( NOT WITH_CPACK )
# empty replacements
macro( cpack_add_component_group )
endmacro()
macro( cpack_add_component )
endmacro()
message( STATUS "Disabled package creation" )
endif()
set( Runtime "Runtime files" CACHE INTERNAL "" )
set( Runtime_base "configurations, dbs, npcs, docs, ..." CACHE INTERNAL "" )
set( Runtime_templates "conf/import and save (generated from conf/import-tmpl and save-tmpl)" CACHE INTERNAL "" )
cpack_add_component_group( Runtime DESCRIPTION ${Runtime} DISPLAY_NAME "Runtime" )
cpack_add_component( Runtime_base DESCRIPTION ${Runtime_base} DISPLAY_NAME "Base files" GROUP Runtime )
cpack_add_component( Runtime_templates DESCRIPTION ${Runtime_templates} DISPLAY_NAME "Base templates" GROUP Runtime )
set( Development "Development files" CACHE INTERNAL "" )
set( Development_base "projects, 3rdparty, sources, templates" CACHE INTERNAL "" )
cpack_add_component_group( Development DESCRIPTION ${Development} DISPLAY_NAME "Development" )
cpack_add_component( Development_base DESCRIPTION ${Development_base} DISPLAY_NAME "Base files" GROUP Development )
#
# install stuff
#
option( INSTALL_COMPONENT_RUNTIME "install/package files needed to run the project" ON )
option( INSTALL_COMPONENT_DEVELOPMENT "install/package files needed to build the project" OFF )
option( INSTALL_TO_PATH "copy files to INSTALL_PATH" OFF )
option( INSTALL_TO_SOURCE "copy files to source directory, skips what is already there (${CMAKE_CURRENT_SOURCE_DIR})" OFF )
option( INSTALL_TO_SUBDIR "copy files to subdirectory (${CMAKE_CURRENT_BINARY_DIR}/install)" OFF )
set( INSTALL_PATH "${CMAKE_INSTALL_PREFIX}" CACHE STRING "install path (only used when INSTALL_TO_PATH is set)" )
mark_as_advanced( CMAKE_INSTALL_PREFIX )
if( INSTALL_TO_PATH AND NOT ("${INSTALL_TO}" STREQUAL "path") )# changed to path
set_property( CACHE INSTALL_TO_SOURCE INSTALL_TO_SUBDIR PROPERTY VALUE OFF )
elseif( INSTALL_TO_SOURCE AND NOT ("${INSTALL_TO}" STREQUAL "source") )# changed to source
set_property( CACHE INSTALL_TO_PATH INSTALL_TO_SUBDIR PROPERTY VALUE OFF )
elseif( INSTALL_TO_SUBDIR AND NOT ("${INSTALL_TO}" STREQUAL "subdir") )# changed to subdir
set_property( CACHE INSTALL_TO_PATH INSTALL_TO_SOURCE PROPERTY VALUE OFF )
elseif( NOT INSTALL_TO_PATH AND NOT INSTALL_TO_SOURCE AND NOT INSTALL_TO_SUBDIR )# default
set_property( CACHE INSTALL_TO_SUBDIR PROPERTY VALUE ON )
endif()
if( INSTALL_TO_PATH )
set( INSTALL_TO "path" CACHE INTERNAL "" )
set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${INSTALL_PATH}" )
elseif( INSTALL_TO_SOURCE )
set( INSTALL_TO "source" CACHE INTERNAL "" )
set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_SOURCE_DIR}" )
elseif( INSTALL_TO_SUBDIR )
set( INSTALL_TO "subdir" CACHE INTERNAL "" )
set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_BINARY_DIR}/install" )
endif()
set( SVN_FOLDER_PATTERN "[\\.]svn" CACHE STRING "pattern of svn folder that we exclude from instalations" )
mark_as_advanced( SVN_FOLDER_PATTERN )
set( DEVELOPMENT_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/configure"
"${CMAKE_CURRENT_SOURCE_DIR}/configure.in"
"${CMAKE_CURRENT_SOURCE_DIR}/rAthena.sln"
)
set( DEVELOPMENT_DIRECTORIES
"3rdparty"
"conf/import-tmpl"
"conf/msg_conf/import-tmpl"
"db/import-tmpl"
"src"
)
set( RUNTIME_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/athena-start"
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
)
if (WIN32)
set (RUNTIME_FILES
${RUNTIME_FILES}
"${CMAKE_CURRENT_SOURCE_DIR}/dbghelp.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/libmysql.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/pcre3.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/zlib1.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/charserv.bat"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/logserv.bat"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/mapserv.bat"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/runserver.bat"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/serv.bat"
)
endif(WIN32)
set( RUNTIME_DIRECTORIES
"conf"
"db"
"doc"
"log"
"npc"
"sql-files"
"tools"
)
if( INSTALL_TO_SOURCE )# skip, already in the source dir
else()
if( INSTALL_COMPONENT_RUNTIME )
install( FILES ${RUNTIME_FILES}
DESTINATION "."
COMPONENT Runtime_base )
foreach( DIR IN ITEMS ${RUNTIME_DIRECTORIES} )
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}/" )
install( DIRECTORY "${DIR}/"
DESTINATION "${DIR}"
COMPONENT Runtime_base
PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE
PATTERN "conf/import-tmpl" EXCLUDE )
else()
# create empty directory
install( CODE "file(MAKE_DIRECTORY \"\${ENV}\${CMAKE_INSTALL_PREFIX}/${DIR}\")"
COMPONENT Runtime_base )
endif()
endforeach()
endif( INSTALL_COMPONENT_RUNTIME )
if( INSTALL_COMPONENT_DEVELOPMENT )
install( FILES ${DEVELOPMENT_FILES}
DESTINATION "."
COMPONENT Development_base )
foreach( DIR IN ITEMS ${DEVELOPMENT_DIRECTORIES} )
install( DIRECTORY "${DIR}/"
DESTINATION "${DIR}"
COMPONENT Development_base
PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE )
endforeach()
endif( INSTALL_COMPONENT_DEVELOPMENT )
endif()
if( INSTALL_COMPONENT_RUNTIME )
# templates
set( _TEMPLATES
"conf/import-tmpl" "conf/import"
"conf/msg_conf/import-tmpl" "conf/msg_conf/import"
"db/import-tmpl" "db/import"
)
set( INSTALL_TEMPLATES_FILE "${CMAKE_CURRENT_BINARY_DIR}/InstallTemplates.cmake" )
file( WRITE "${INSTALL_TEMPLATES_FILE}"
"macro( INSTALL_TEMPLATE _SRC _DST )\n"
" set( SRC \"${CMAKE_CURRENT_SOURCE_DIR}/\${_SRC}\" )\n"
" set( DST \"\${CMAKE_INSTALL_PREFIX}/\${_DST}\" )\n"
" if( EXISTS \"\${DST}\" )\n"
" message( \"-- Already exists: \${DST}\" )\n"
" else()\n"
" message( \"-- Installing template: \${DST}\" )\n"
" execute_process( COMMAND \"${CMAKE_COMMAND}\" -E copy \"\${SRC}\" \"\${DST}\" )\n"
" endif()\n"
"endmacro()\n"
)
while( _TEMPLATES )
list( GET _TEMPLATES 0 _SRC )
list( GET _TEMPLATES 1 _DST )
list( REMOVE_AT _TEMPLATES 0 1 )
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}" )
file( GLOB _PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}/*" )
foreach( _PATH IN ITEMS ${_PATHS} )
string( REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}/" "" _PATH "${_PATH}" )
if( NOT "${_PATH}" MATCHES "${SVN_FOLDER_PATTERN}" )
list( APPEND _TEMPLATES "${_SRC}/${_PATH}" "${_DST}/${_PATH}" )
endif()
endforeach()
else()
file( APPEND "${INSTALL_TEMPLATES_FILE}" "INSTALL_TEMPLATE( \"${_SRC}\" \"${_DST}\" )\n" )
endif()
endwhile()
install( SCRIPT "${INSTALL_TEMPLATES_FILE}"
COMPONENT Runtime_templates )
endif( INSTALL_COMPONENT_RUNTIME )
#
# sources
#
set( TARGET_LIST CACHE INTERNAL "" )
add_subdirectory( 3rdparty )
add_subdirectory( src )
#####################################################################
# final checks and warnings
#
list( LENGTH TARGET_LIST _LEN )
if( _LEN EQUAL 0 )
message( FATAL_ERROR "no targets available" )
endif()
message( STATUS "Available targets:" )
foreach( _TARGET IN ITEMS ${TARGET_LIST} )
message( STATUS "\t${_TARGET}" )
endforeach()

View File

@ -224,4 +224,5 @@ case $1 in
;; ;;
esac esac
echo "Using the configure scripts and ./athena-start is deprecated. Use CMake and ./athena-start.sh" 1>&2
exit 1

35
conf/CMakeLists.txt Normal file
View File

@ -0,0 +1,35 @@
include(CopyImportFiles)
set(CONF_FILES_TO_IMPORT
"atcommands.yml"
"battle_conf.txt"
"char_conf.txt"
"groups.yml"
"inter_conf.txt"
"inter_server.yml"
"log_conf.txt"
"login_conf.txt"
"map_conf.txt"
"packet_conf.txt"
"script_conf.txt"
"web_conf.txt")
copy_import_files(${CMAKE_CURRENT_SOURCE_DIR}/import-tmpl/
${CMAKE_CURRENT_SOURCE_DIR}/import
"${CONF_FILES_TO_IMPORT}")
set(MSG_FILES_TO_IMPORT
"map_msg_chn_conf.txt"
"map_msg_eng_conf.txt"
"map_msg_frn_conf.txt"
"map_msg_grm_conf.txt"
"map_msg_idn_conf.txt"
"map_msg_mal_conf.txt"
"map_msg_por_conf.txt"
"map_msg_rus_conf.txt"
"map_msg_spn_conf.txt"
"map_msg_tha_conf.txt")
copy_import_files(${CMAKE_CURRENT_SOURCE_DIR}/msg_conf/import-tmpl/
${CMAKE_CURRENT_SOURCE_DIR}/msg_conf/import
"${MSG_FILES_TO_IMPORT}")

72
db/CMakeLists.txt Normal file
View File

@ -0,0 +1,72 @@
include(CopyImportFiles)
# Why do we list all the files instead of using glob?
# This way, if we add a new file, the build system will know to regenerate
# and the new file will be copied over.
set(DB_FILES_TO_IMPORT
"abra_db.yml"
"achievement_db.yml"
"achievement_level_db.yml"
"attendance.yml"
"attr_fix.yml"
"battleground_db.yml"
"captcha_db.yml"
"castle_db.yml"
"const.yml"
"create_arrow_db.yml"
"elemental_db.yml"
"enchantgrade.yml"
"exp_guild.yml"
"exp_homun.yml"
"guild_skill_tree.yml"
"homunculus_db.yml"
"instance_db.yml"
"item_cash.yml"
"item_combos.yml"
"item_db.yml"
"item_enchant.yml"
"item_group_db.yml"
"item_noequip.txt"
"item_packages.yml"
"item_randomopt_db.yml"
"item_randomopt_group.yml"
"item_reform.yml"
"job_noenter_map.txt"
"job_stats.yml"
"laphine_synthesis.yml"
"laphine_upgrade.yml"
"level_penalty.yml"
"magicmushroom_db.yml"
"map_cache.dat"
"map_drops.yml"
"map_index.txt"
"mercenary_db.yml"
"mob_avail.yml"
"mob_chat_db.yml"
"mob_db.yml"
"mob_item_ratio.yml"
"mob_skill_db.txt"
"mob_summon.yml"
"pet_db.yml"
"produce_db.txt"
"quest_db.yml"
"refine.yml"
"reputation_group.yml"
"reputation.yml"
"size_fix.yml"
"skill_changematerial_db.txt"
"skill_damage_db.txt"
"skill_db.yml"
"skill_nocast_db.txt"
"skill_tree.yml"
"spellbook_db.yml"
"statpoint.yml"
"status_disabled.txt"
"status.yml"
"stylist.yml"
)
copy_import_files(${CMAKE_CURRENT_SOURCE_DIR}/import-tmpl/
${CMAKE_CURRENT_SOURCE_DIR}/import
"${DB_FILES_TO_IMPORT}")

View File

@ -106,6 +106,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yamlupgrade", "src\tool\yam
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ryml", "3rdparty\rapidyaml\ryml.vcxproj", "{492E2981-34F4-3A6A-BFD9-46096C641203}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ryml", "3rdparty\rapidyaml\ryml.vcxproj", "{492E2981-34F4-3A6A-BFD9-46096C641203}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_DEPRECATED_USE_CMAKE_INSTEAD_", "_DEPRECATED_USE_CMAKE_INSTEAD_", "{7BDFFA26-6F88-4F5B-8B7E-3B51C9FD9BA3}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32

View File

@ -1,29 +1,16 @@
#
# setup and static libraries
#
set(RA_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH set(RA_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH
"rathena include directory" "rathena include directory"
) )
mark_as_advanced( RA_INCLUDE_DIRS ) mark_as_advanced(RA_INCLUDE_DIRS)
add_subdirectory(common)
add_subdirectory(login)
add_subdirectory(char)
add_subdirectory(map)
add_subdirectory(web)
add_subdirectory( common ) add_subdirectory(tool)
if( HAVE_common )
option( BUILD_SERVERS "build server executables" ON )
else()
message( STATUS "Disabled server targets (requires common)" )
endif()
# add_subdirectory( tool )
#
# targets
#
add_subdirectory( login )
add_subdirectory( char )
add_subdirectory( map )
add_subdirectory( web )
add_subdirectory( tool )

View File

@ -1,40 +1,52 @@
# add_executable(char-server)
# setup
#
set( CHAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
target_sources(char-server PRIVATE
"char.cpp"
"char_clif.cpp"
"char_cnslif.cpp"
"char_logif.cpp"
"char_mapif.cpp"
"int_achievement.cpp"
"int_auction.cpp"
"int_clan.cpp"
"int_elemental.cpp"
"int_guild.cpp"
"int_homun.cpp"
"int_mail.cpp"
"int_mercenary.cpp"
"int_party.cpp"
"int_pet.cpp"
"int_quest.cpp"
"int_storage.cpp"
"inter.cpp"
)
# if(WIN32)
# char server target_sources(char-server PRIVATE
# "char_clif.hpp"
if( BUILD_SERVERS ) "char_cnslif.hpp"
message( STATUS "Creating target char-server" ) "char.hpp"
file(GLOB CHAR_HEADERS ${CHAR_SOURCE_DIR}/*.hpp) "char_logif.hpp"
file(GLOB CHAR_SOURCES_CXX ${CHAR_SOURCE_DIR}/*.cpp) "char_mapif.hpp"
set(CHAR_SOURCES ${CHAR_SOURCES_C} ${CHAR_SOURCES_CXX}) "int_achievement.hpp"
#message( STATUS "CHAR_SOURCES="${CHAR_SOURCES}) "int_auction.hpp"
set( DEPENDENCIES common ) "int_clan.hpp"
set( LIBRARIES ${GLOBAL_LIBRARIES} ) "int_elemental.hpp"
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} ) "inter.hpp"
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" ) "int_guild.hpp"
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ${CHAR_HEADERS} ${CHAR_SOURCES} ) "int_homun.hpp"
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ) "int_mail.hpp"
source_group( char FILES ${CHAR_HEADERS} ${CHAR_SOURCES} ) "int_mercenary.hpp"
include_directories( ${INCLUDE_DIRS} ) "int_party.hpp"
"int_pet.hpp"
"int_quest.hpp"
"int_storage.hpp"
"packets.hpp"
)
#message( STATUS "char-server SOURCE_FILES=${SOURCE_FILES}") set_target_properties(char-server PROPERTIES FOLDER "Servers")
add_executable( char-server ${SOURCE_FILES} ) endif()
#message( STATUS "char-server LIBRARIES=${LIBRARIES}, DEPENDENCIES=${DEPENDENCIES} DEFINITIONS=${DEFINITIONS}")
add_dependencies( char-server ${DEPENDENCIES} )
target_link_libraries( char-server ${LIBRARIES} ${DEPENDENCIES} )
set_target_properties( char-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
if( INSTALL_COMPONENT_RUNTIME ) target_link_libraries(char-server PUBLIC
cpack_add_component( Runtime_charserver DESCRIPTION "char-server" DISPLAY_NAME "char-server" GROUP Runtime ) common
install( TARGETS char-server )
DESTINATION "."
COMPONENT Runtime_charserver )
endif( INSTALL_COMPONENT_RUNTIME )
set( TARGET_LIST ${TARGET_LIST} char-server CACHE INTERNAL "" )
message( STATUS "Creating target char-server - done" )
endif( BUILD_SERVERS )

View File

@ -1,191 +1,226 @@
include(CheckCSourceRuns)
include(CheckFunctionExists)
# #
# Create version.hpp # Test monotonic clock
# #
message( STATUS "Creating version.hpp" ) # CLOCK_MONOTONIC clock for clock_gettime
if(GIT_VERSION) # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
# those 2 was done in parent to produce this # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
#include(GetGitVersion) # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
#get_git_version() # checked but some systems define them even when they do not support it
string(SUBSTRING ${GIT_VERSION} 0 10 SHORT_GIT_VERSION) # (ref. bugreport:1003).
string(SUBSTRING ${GIT_HEAD_VERSION} 0 10 SHORT_GIT_HEAD_VERSION) #
string(CONCAT GIT_STR_VERSIONS ${SHORT_GIT_VERSION} "_" ${SHORT_GIT_HEAD_VERSION}) message(STATUS "Check for monotonic clock")
#message( STATUS "git version=${GIT_STR_VERSIONS}" ) find_library(RT_LIBRARY rt)# (optional, rt on Debian)
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.hpp mark_as_advanced(RT_LIBRARY)
"#ifndef SVNVERSION\n#define SVNVERSION ${GIT_STR_VERSIONS}\n#endif\n" ) set(CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ${RT_LIBRARY})
elseif( SVNVERSION ) file(READ "${CMAKE_SOURCE_DIR}/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c" _SOURCE)
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.hpp CHECK_C_SOURCE_RUNS("${_SOURCE}" HAVE_MONOTONIC_CLOCK)
"#ifndef SVNVERSION\n#define SVNVERSION ${SVNVERSION}\n#endif\n" ) if(HAVE_MONOTONIC_CLOCK)
message(STATUS "Check for monotonic clock - yes")
set(MONOTONIC_CLOCK_LIBRARIES ${RT_LIBRARY})
set(MONOTONIC_CLOCK_DEFINITIONS "-DHAVE_MONOTONIC_CLOCK")
else() else()
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.hpp "" ) message(STATUS "Check for monotonic clock - no")
endif() endif()
set( GLOBAL_INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "" )
set( SVNVERSION ${SVNVERSION}
CACHE STRING "SVN version of the source code" )
if( INSTALL_COMPONENT_DEVELOPMENT )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/version.hpp
DESTINATION "src/common"
COMPONENT Development_base )
endif( INSTALL_COMPONENT_DEVELOPMENT )
message( STATUS "Creating version.hpp - done" )
set( COMMON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" # Check ENABLE_MEMORY option
CACHE PATH "common source directory" ) if(ENABLE_MEMORY STREQUAL "system")
#message( STATUS "DEBUG COMMON_SOURCE_DIR=${COMMON_SOURCE_DIR}" ) # use the normal system functions
mark_as_advanced( COMMON_SOURCE_DIR ) else()
message(STATUS "Feature not implemented, defaulting to system")
endif()
#####################################################################
# setup
#
if( WIN32 )
set( PROJECT_LIBS Ws2_32.lib )
if( MSVC ) add_library(minicore EXCLUDE_FROM_ALL)
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) add_library(common)
# add_library(core-tools)
add_library(common-win INTERFACE)
if(WIN32)
target_link_libraries(common-win INTERFACE "ws2_32.lib")
if(MSVC)
target_compile_definitions(common-win INTERFACE
_WINSOCK_DEPRECATED_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE)
endif() endif()
set( COMMON_ADDITIONALL_CPP "${COMMON_SOURCE_DIR}/winapi.cpp" ) target_sources(common-win INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/winapi.cpp"
set( COMMON_ADDITIONALL_HPP "${COMMON_SOURCE_DIR}/winapi.hpp" ) "${CMAKE_CURRENT_SOURCE_DIR}/winapi.hpp"
endif()
set( COMMON_ALL_HEADERS
"${CMAKE_CURRENT_BINARY_DIR}/version.hpp"
"${COMMON_SOURCE_DIR}/cbasetypes.hpp"
"${COMMON_SOURCE_DIR}/mmo.hpp"
) )
add_library(minicore) target_link_libraries(minicore PUBLIC common-win)
target_link_libraries(common PUBLIC common-win)
endif()
target_sources(minicore PRIVATE target_sources(minicore PRIVATE
"${COMMON_SOURCE_DIR}/core.cpp" "core.cpp"
"${COMMON_SOURCE_DIR}/malloc.cpp" "database.cpp"
"${COMMON_SOURCE_DIR}/showmsg.cpp" "des.cpp"
"${COMMON_SOURCE_DIR}/strlib.cpp" "grfio.cpp"
${LIBCONFIG_SOURCES} # needed by showmsg.cpp "malloc.cpp"
${COMMON_ADDITIONALL_CPP} # needed by Windows "nullpo.cpp"
"showmsg.cpp"
"strlib.cpp"
"utils.cpp"
)
if(WIN32)
target_sources(minicore PRIVATE
"cbasetypes.hpp"
"core.hpp"
"database.hpp"
"des.hpp"
"grfio.hpp"
"malloc.hpp"
"nullpo.hpp"
"showmsg.hpp"
"strlib.hpp"
"utils.hpp"
)
set_target_properties(minicore PROPERTIES FOLDER "Core")
endif()
target_compile_definitions(minicore PRIVATE
"-DMINICORE"
${MONOTONIC_CLOCK_DEFINITIONS}
) )
target_include_directories(minicore PUBLIC target_include_directories(minicore PUBLIC
${COMMON_SOURCE_DIR} "${RA_INCLUDE_DIRS}"
${LIBCONFIG_INCLUDE_DIRS} "${ZLIB_INCLUDE_DIRS}"
${COMMON_ADDITIONALL_HPP} # needed by Windows )
target_link_libraries(minicore PUBLIC
${MONOTONIC_CLOCK_LIBRARIES}
libconfig
ryml
${ZLIB_LIBRARIES}
yaml-cpp
)
target_sources(common PRIVATE
"cli.cpp"
"conf.cpp"
"core.cpp"
"database.cpp"
"db.cpp"
"des.cpp"
"ers.cpp"
"grfio.cpp"
"malloc.cpp"
"mapindex.cpp"
"md5calc.cpp"
"msg_conf.cpp"
"nullpo.cpp"
"random.cpp"
"showmsg.cpp"
"socket.cpp"
"sql.cpp"
"strlib.cpp"
"timer.cpp"
"utils.cpp"
"utilities.cpp"
)
if(WIN32)
target_sources(common PRIVATE
"cbasetypes.hpp"
"cli.hpp"
"conf.hpp"
"core.hpp"
"database.hpp"
"db.hpp"
"des.hpp"
"ers.hpp"
"grfio.hpp"
"malloc.hpp"
"mapindex.hpp"
"md5calc.hpp"
"mmo.hpp"
"msg_conf.hpp"
"nullpo.hpp"
"random.hpp"
"showmsg.hpp"
"socket.hpp"
"sql.hpp"
"strlib.hpp"
"timer.hpp"
"utilities.hpp"
"utils.hpp"
)
set_target_properties(common PROPERTIES FOLDER "Core")
endif()
# defines just for common
target_compile_definitions(common PRIVATE ${MONOTONIC_CLOCK_DEFINITIONS})
if(ENABLE_RDTSC)
target_compile_definitions(common PRIVATE "-DENABLE_RDTSC")
endif()
if(ENABLE_MEMMGR)
target_compile_definitions(common PRIVATE "-DUSE_MEMMGR")
else()
target_compile_definitions(common PRIVATE "-DNO_MEMMGR")
endif()
# Propagated defines
target_compile_definitions(common PUBLIC "-DPACKETVER=${PACKETVER}")
if(ENABLE_PRERENEWAL)
target_compile_definitions(common PUBLIC "-DPRERE")
endif()
if(ENABLE_EXTRA_DEBUG_CODE)
target_compile_definitions(common PUBLIC "-DDEBUG")
endif()
if(ENABLE_EXTRA_BUILDBOT_CODE)
target_compile_definitions(common PUBLIC "-DBUILDBOT")
endif()
if(ENABLE_EPOLL)
target_compile_definitions(common PRIVATE "-DSOCKET_EPOLL")
endif()
if(ENABLE_VIP)
target_compile_definitions(common INTERFACE "-DVIP_ENABLE")
endif()
if(MAXCONN)
target_compile_definitions(common PUBLIC "-DMAXCONN=${MAXCONN}")
endif()
CHECK_FUNCTION_EXISTS(setrlimit HAVE_SETRLIMIT)
if (HAVE_SETRLIMIT)
target_compile_definitions(common PUBLIC "-DHAVE_SETRLIMIT")
endif()
CHECK_FUNCTION_EXISTS(strnlen HAVE_STRNLEN)
if (HAVE_STRNLEN)
target_compile_definitions(common PUBLIC "-DHAVE_STRNLEN")
endif()
target_include_directories(common PUBLIC
"${MYSQL_INCLUDE_DIRS}"
"${ZLIB_INCLUDE_DIRS}"
"${RA_INCLUDE_DIRS}"
)
target_link_libraries(common PUBLIC
${MONOTONIC_CLOCK_LIBRARIES}
libconfig
ryml
${MYSQL_LIBRARIES}
${ZLIB_LIBRARIES}
) )
target_compile_definitions(minicore PRIVATE "-DMINICORE" ${LIBCONFIG_DEFINITIONS}) if(ENABLE_PROFILER STREQUAL "gprof")
target_compile_options(common PUBLIC "-pg")
# target_link_libraries(common PUBLIC "-pg")
# common_base
#
if( WITH_ZLIB )
message( STATUS "Creating target common_base" )
set( COMMON_BASE_HEADERS
${COMMON_ALL_HEADERS}
"${COMMON_SOURCE_DIR}/conf.hpp"
"${COMMON_SOURCE_DIR}/core.hpp"
"${COMMON_SOURCE_DIR}/database.hpp"
"${COMMON_SOURCE_DIR}/db.hpp"
"${COMMON_SOURCE_DIR}/des.hpp"
"${COMMON_SOURCE_DIR}/ers.hpp"
"${COMMON_SOURCE_DIR}/grfio.hpp"
"${COMMON_SOURCE_DIR}/malloc.hpp"
"${COMMON_SOURCE_DIR}/mapindex.hpp"
"${COMMON_SOURCE_DIR}/md5calc.hpp"
"${COMMON_SOURCE_DIR}/nullpo.hpp"
"${COMMON_SOURCE_DIR}/random.hpp"
"${COMMON_SOURCE_DIR}/showmsg.hpp"
"${COMMON_SOURCE_DIR}/socket.hpp"
"${COMMON_SOURCE_DIR}/strlib.hpp"
"${COMMON_SOURCE_DIR}/timer.hpp"
"${COMMON_SOURCE_DIR}/utils.hpp"
"${COMMON_SOURCE_DIR}/msg_conf.hpp"
"${COMMON_SOURCE_DIR}/cli.hpp"
"${COMMON_SOURCE_DIR}/utilities.hpp"
${LIBCONFIG_HEADERS} # needed by conf.hpp/showmsg.hpp
${COMMON_ADDITIONALL_HPP} # needed by Windows
CACHE INTERNAL "common_base headers" )
set( COMMON_BASE_SOURCES
"${COMMON_SOURCE_DIR}/conf.cpp"
"${COMMON_SOURCE_DIR}/core.cpp"
"${COMMON_SOURCE_DIR}/database.cpp"
"${COMMON_SOURCE_DIR}/db.cpp"
"${COMMON_SOURCE_DIR}/des.cpp"
"${COMMON_SOURCE_DIR}/ers.cpp"
"${COMMON_SOURCE_DIR}/grfio.cpp"
"${COMMON_SOURCE_DIR}/malloc.cpp"
"${COMMON_SOURCE_DIR}/mapindex.cpp"
"${COMMON_SOURCE_DIR}/md5calc.cpp"
"${COMMON_SOURCE_DIR}/nullpo.cpp"
"${COMMON_SOURCE_DIR}/random.cpp"
"${COMMON_SOURCE_DIR}/showmsg.cpp"
"${COMMON_SOURCE_DIR}/socket.cpp"
"${COMMON_SOURCE_DIR}/strlib.cpp"
"${COMMON_SOURCE_DIR}/timer.cpp"
"${COMMON_SOURCE_DIR}/utils.cpp"
"${COMMON_SOURCE_DIR}/msg_conf.cpp"
"${COMMON_SOURCE_DIR}/cli.cpp"
"${COMMON_SOURCE_DIR}/utilities.cpp"
${LIBCONFIG_SOURCES} # needed by conf.cpp/showmsg.cpp
${COMMON_ADDITIONALL_CPP} # needed by Windows
CACHE INTERNAL "common_base sources" )
set( COMMON_BASE_INCLUDE_DIRS
${LIBCONFIG_INCLUDE_DIRS}
${YAML_INCLUDE_DIRS}
CACHE INTERNAL "common_base include dirs" )
set( COMMON_BASE_DEFINITIONS
${LIBCONFIG_DEFINITIONS}
CACHE INTERNAL "common_base definitions" )
set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} yaml-cpp ryml )
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} ${YAML_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} )
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" )
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} )
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} )
add_library( common_base ${SOURCE_FILES} )
#message( STATUS "common_base LIBRARIES=${LIBRARIES}, DEFINITIONS=${DEFINITIONS}")
target_link_libraries( common_base ${LIBRARIES} )
set_target_properties( common_base PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
include_directories( ${INCLUDE_DIRS} )
set( HAVE_common_base ON CACHE INTERNAL "" )
set( TARGET_LIST ${TARGET_LIST} common_base CACHE INTERNAL "" )
message( STATUS "Creating target common_base - done" )
else()
message( STATUS "Skipping target common_base (requires ZLIB)" )
unset( HAVE_common_base CACHE )
endif()
#
# common
#
if( HAVE_common_base AND WITH_MYSQL )
message( STATUS "Creating target common" )
set( COMMON_HEADERS
${COMMON_ALL_HEADERS}
"${CMAKE_CURRENT_SOURCE_DIR}/sql.hpp"
CACHE INTERNAL "common headers" )
set( COMMON_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/sql.cpp"
CACHE INTERNAL "common sources" )
set( DEPENDENCIES common_base yaml-cpp ryml )
set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} )
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} )
set( DEFINITIONS "${GLOBAL_DEFINITIONS}" )
set( SOURCE_FILES ${COMMON_HEADERS} ${COMMON_SOURCES} )
source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} )
add_library( common ${SOURCE_FILES} )
#message( STATUS "common LIBRARIES=${LIBRARIES}, DEPENDENCIES=${DEPENDENCIES} DEFINITIONS=${DEFINITIONS}")
add_dependencies( common ${DEPENDENCIES} )
target_link_libraries( common ${LIBRARIES} ${DEPENDENCIES} )
set_target_properties( common PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
include_directories( ${INCLUDE_DIRS} ${YAML_INCLUDE_DIRS} )
set( HAVE_common ON CACHE INTERNAL "" )
set( TARGET_LIST ${TARGET_LIST} common CACHE INTERNAL "" )
message( STATUS "Creating target common - done" )
else()
message( FATAL_ERROR "Stopping target common (requires common_base and MYSQL)" )
endif() endif()

View File

@ -1,35 +1,29 @@
# add_executable(login-server)
# setup
#
set( LOGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
# login server target_sources(login-server PRIVATE
# "account.cpp"
if( BUILD_SERVERS ) "ipban.cpp"
message( STATUS "Creating target login-server" ) "login.cpp"
file(GLOB LOGIN_HEADERS ${LOGIN_SOURCE_DIR}/*.hpp) "loginchrif.cpp"
file(GLOB LOGIN_SOURCES_CXX ${LOGIN_SOURCE_DIR}/*.cpp) "loginclif.cpp"
set(LOGIN_SOURCES ${LOGIN_SOURCES_C} ${LOGIN_SOURCES_CXX}) "logincnslif.cpp"
#message( STATUS "LOGIN_SOURCES="${LOGIN_SOURCES}) "loginlog.cpp"
set( DEPENDENCIES common ) )
set( LIBRARIES ${GLOBAL_LIBRARIES} )
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} )
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS} -DWITH_SQL" )
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ${LOGIN_HEADERS} ${LOGIN_SOURCES} )
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} )
source_group( login FILES ${LOGIN_HEADERS} ${LOGIN_SOURCES} )
include_directories( ${INCLUDE_DIRS} )
add_executable( login-server ${SOURCE_FILES} ) if(WIN32)
add_dependencies( login-server ${DEPENDENCIES} ) target_sources(login-server PRIVATE
target_link_libraries( login-server ${LIBRARIES} ${DEPENDENCIES} ) "account.hpp"
set_target_properties( login-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) "ipban.hpp"
if( INSTALL_COMPONENT_RUNTIME ) "loginchrif.hpp"
cpack_add_component( Runtime_loginserver DESCRIPTION "login-server" DISPLAY_NAME "login-server" GROUP Runtime ) "loginclif.hpp"
install( TARGETS login-server "logincnslif.hpp"
DESTINATION "." "login.hpp"
COMPONENT Runtime_loginserver ) "loginlog.hpp"
endif( INSTALL_COMPONENT_RUNTIME ) )
set( TARGET_LIST ${TARGET_LIST} login-server CACHE INTERNAL "" )
message( STATUS "Creating target login-server - done" ) set_target_properties(login-server PROPERTIES FOLDER "Servers")
endif( BUILD_SERVERS ) endif()
target_link_libraries(login-server PUBLIC
common
)

View File

@ -1,45 +1,148 @@
# set(MAP_SOURCES
# setup "achievement.cpp"
# "atcommand.cpp"
set( MAP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) "battle.cpp"
"battleground.cpp"
"buyingstore.cpp"
"cashshop.cpp"
"channel.cpp"
"chat.cpp"
"chrif.cpp"
"clan.cpp"
"clif.cpp"
"date.cpp"
"duel.cpp"
"elemental.cpp"
"guild.cpp"
"homunculus.cpp"
"instance.cpp"
"intif.cpp"
"itemdb.cpp"
"log.cpp"
"mail.cpp"
"map.cpp"
"mapreg.cpp"
"mercenary.cpp"
"mob.cpp"
"navi.cpp"
"npc.cpp"
"npc_chat.cpp"
"party.cpp"
"path.cpp"
"pc.cpp"
"pc_groups.cpp"
"pet.cpp"
"quest.cpp"
"script.cpp"
"searchstore.cpp"
"skill.cpp"
"status.cpp"
"storage.cpp"
"trade.cpp"
"unit.cpp"
"vending.cpp"
"skills/skill.cpp"
"skills/skillrepository.cpp"
"skills/swordsman.cpp"
)
# set(MAP_HEADERS
# map server "achievement.hpp"
# "atcommand.hpp"
if( BUILD_SERVERS ) "battleground.hpp"
message( STATUS "Creating target map-server" ) "battle.hpp"
file(GLOB MAP_HEADERS ${MAP_SOURCE_DIR}/*.hpp) "buyingstore.hpp"
file(GLOB MAP_SOURCES ${MAP_SOURCE_DIR}/*.cpp) "cashshop.hpp"
set( DEPENDENCIES common ryml) "channel.hpp"
set( LIBRARIES ${GLOBAL_LIBRARIES}) "chat.hpp"
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} ) "chrif.hpp"
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" ) "clan.hpp"
if( WITH_PCRE ) "clif.hpp"
message( STATUS "Enabled PCRE code" ) "clif_obfuscation.hpp"
set( LIBRARIES ${LIBRARIES} ${PCRE_LIBRARIES} ) "clif_packetdb.hpp"
set( INCLUDE_DIRS ${INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS} ) "clif_shuffle.hpp"
set( DEFINITIONS "${DEFINITIONS} -DPCRE_SUPPORT" ) "date.hpp"
else() "duel.hpp"
message( STATUS "Disabled PCRE code" ) "elemental.hpp"
"guild.hpp"
"homunculus.hpp"
"instance.hpp"
"intif.hpp"
"itemdb.hpp"
"log.hpp"
"mail.hpp"
"map.hpp"
"mapreg.hpp"
"mercenary.hpp"
"mob.hpp"
"navi.hpp"
"npc.hpp"
"packets.hpp"
"packets_struct.hpp"
"party.hpp"
"path.hpp"
"pc_groups.hpp"
"pc.hpp"
"pet.hpp"
"quest.hpp"
"script_constants.hpp"
"script.hpp"
"searchstore.hpp"
"skill.hpp"
"status.hpp"
"storage.hpp"
"trade.hpp"
"unit.hpp"
"vending.hpp"
)
add_executable(map-server)
target_sources(map-server PRIVATE ${MAP_SOURCES})
if(WIN32)
target_sources(map-server PRIVATE ${MAP_HEADERS})
set_target_properties(map-server PROPERTIES FOLDER "Servers")
endif() endif()
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ${MAP_HEADERS} ${MAP_SOURCES} )
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} )
source_group( map FILES ${MAP_HEADERS} ${MAP_SOURCES} )
include_directories( ${INCLUDE_DIRS} )
#message( STATUS "map-server SOURCE_FILES=${SOURCE_FILES}") target_link_libraries(map-server PUBLIC
add_executable( map-server ${SOURCE_FILES} ) common
#message( STATUS "map-server LIBRARIES=${LIBRARIES}, DEPENDENCIES=${DEPENDENCIES} DEFINITIONS=${DEFINITIONS}") ${PCRE_LIBRARIES}
add_dependencies( map-server ${DEPENDENCIES} ) )
target_link_libraries( map-server ${LIBRARIES} ${DEPENDENCIES} )
set_target_properties( map-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) target_include_directories(map-server PUBLIC
if( INSTALL_COMPONENT_RUNTIME ) ${PCRE_INCLUDE_DIRS}
cpack_add_component( Runtime_mapserver DESCRIPTION "map-server" DISPLAY_NAME "map-server" GROUP Runtime ) )
install( TARGETS map-server
DESTINATION "." if(WITH_PCRE)
COMPONENT Runtime_mapserver ) target_compile_definitions(map-server PUBLIC "-DPCRE_SUPPORT")
endif( INSTALL_COMPONENT_RUNTIME ) endif()
set( TARGET_LIST ${TARGET_LIST} map-server CACHE INTERNAL "" )
message( STATUS "Creating target map-server - done" ) # map-server-generator
endif( BUILD_SERVERS ) add_executable(map-server-generator)
target_sources(map-server-generator PRIVATE ${MAP_SOURCES})
if(WIN32)
target_sources(map-server-generator PRIVATE ${MAP_HEADERS})
set_target_properties(map-server-generator PROPERTIES FOLDER "Tools")
endif()
set_target_properties(map-server-generator PROPERTIES EXCLUDE_FROM_ALL TRUE)
target_compile_definitions(map-server-generator PUBLIC "-DMAP_GENERATOR")
target_link_libraries(map-server-generator PUBLIC
common
json
${PCRE_LIBRARIES}
)
target_include_directories(map-server-generator PUBLIC
${PCRE_INCLUDE_DIRS}
)
if(PCRE_FOUND)
target_compile_definitions(map-server-generator PUBLIC "-DPCRE_SUPPORT")
endif()

View File

@ -46,6 +46,8 @@
#include "status.hpp" #include "status.hpp"
#include "unit.hpp" #include "unit.hpp"
#include "skills/skillrepository.hpp"
using namespace rathena; using namespace rathena;
#define SKILLUNITTIMER_INTERVAL 100 #define SKILLUNITTIMER_INTERVAL 100
@ -5135,9 +5137,18 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
map_freeblock_lock(); map_freeblock_lock();
try {
const Skill& skill = skillRepository.getSkill(static_cast<e_skill>(skill_id));
int ret = skill.castendDamage(src, bl, skill_lv, tick, flag);
if (ret != 0) {
map_freeblock_unlock();
return ret;
}
} catch (SkillRepository::SkillNotFoundException e) {
// fallback on switch
switch(skill_id) { switch(skill_id) {
case MER_CRASH: case MER_CRASH:
case SM_BASH:
case MS_BASH: case MS_BASH:
case MC_MAMMONITE: case MC_MAMMONITE:
case TF_DOUBLE: case TF_DOUBLE:
@ -5187,9 +5198,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case NPC_PETRIFYATTACK: case NPC_PETRIFYATTACK:
case NPC_CURSEATTACK: case NPC_CURSEATTACK:
case NPC_SLEEPATTACK: case NPC_SLEEPATTACK:
#ifdef RENEWAL #ifdef RENEWAL
case CR_ACIDDEMONSTRATION: case CR_ACIDDEMONSTRATION:
#endif #endif
case LK_AURABLADE: case LK_AURABLADE:
case LK_SPIRALPIERCE: case LK_SPIRALPIERCE:
case ML_SPIRALPIERCE: case ML_SPIRALPIERCE:
@ -5207,9 +5218,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case TK_COUNTER: case TK_COUNTER:
case GS_CHAINACTION: case GS_CHAINACTION:
case GS_TRIPLEACTION: case GS_TRIPLEACTION:
#ifndef RENEWAL #ifndef RENEWAL
case GS_MAGICALBULLET: case GS_MAGICALBULLET:
#endif #endif
case GS_TRACKING: case GS_TRACKING:
case GS_PIERCINGSHOT: case GS_PIERCINGSHOT:
case GS_RAPIDSHOWER: case GS_RAPIDSHOWER:
@ -5367,11 +5378,11 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case KN_CHARGEATK: case KN_CHARGEATK:
{ {
bool path = path_search_long(nullptr, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL); bool path = path_search_long(nullptr, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL);
#ifdef RENEWAL #ifdef RENEWAL
int dist = skill_get_blewcount(skill_id, skill_lv); int dist = skill_get_blewcount(skill_id, skill_lv);
#else #else
unsigned int dist = distance_bl(src, bl); unsigned int dist = distance_bl(src, bl);
#endif #endif
uint8 dir = map_calc_dir(bl, src->x, src->y); uint8 dir = map_calc_dir(bl, src->x, src->y);
// teleport to target (if not on WoE grounds) // teleport to target (if not on WoE grounds)
@ -5381,10 +5392,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
// cause damage and knockback if the path to target was a straight one // cause damage and knockback if the path to target was a straight one
if (path) { if (path) {
if(skill_attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, dist)) { if(skill_attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, dist)) {
#ifdef RENEWAL #ifdef RENEWAL
if (map_getmapdata(src->m)->getMapFlag(MF_PVP)) if (map_getmapdata(src->m)->getMapFlag(MF_PVP))
dist += 2; // Knockback is 4 on PvP maps dist += 2; // Knockback is 4 on PvP maps
#endif #endif
skill_blown(src, bl, dist, dir, BLOWN_NONE); skill_blown(src, bl, dist, dir, BLOWN_NONE);
} }
//HACK: since knockback officially defaults to the left, the client also turns to the left... therefore, //HACK: since knockback officially defaults to the left, the client also turns to the left... therefore,
@ -5409,11 +5420,11 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
} }
break; break;
#ifndef RENEWAL #ifndef RENEWAL
case SN_SHARPSHOOTING: case SN_SHARPSHOOTING:
flag |= 2; // Flag for specific mob damage formula flag |= 2; // Flag for specific mob damage formula
[[fallthrough]]; [[fallthrough]];
#endif #endif
case MA_SHARPSHOOTING: case MA_SHARPSHOOTING:
case NJ_KAMAITACHI: case NJ_KAMAITACHI:
case NPC_DARKPIERCING: case NPC_DARKPIERCING:
@ -5433,10 +5444,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
if (!(map_foreachindir(skill_attack_area, src->m, src->x, src->y, bl->x, bl->y, if (!(map_foreachindir(skill_attack_area, src->m, src->x, src->y, bl->x, bl->y,
skill_get_splash(skill_id, skill_lv), skill_get_maxcount(skill_id, skill_lv), 0, splash_target(src), skill_get_splash(skill_id, skill_lv), skill_get_maxcount(skill_id, skill_lv), 0, splash_target(src),
skill_get_type(skill_id), src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY))) { skill_get_type(skill_id), src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY))) {
#ifndef RENEWAL #ifndef RENEWAL
if (skill_id == SN_SHARPSHOOTING) if (skill_id == SN_SHARPSHOOTING)
flag &= ~2; // Only targets in the splash area are affected flag &= ~2; // Only targets in the splash area are affected
#endif #endif
//These skills hit at least the target if the AoE doesn't hit //These skills hit at least the target if the AoE doesn't hit
skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag);
@ -5458,7 +5469,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case RG_BACKSTAP: case RG_BACKSTAP:
{ {
if (!check_distance_bl(src, bl, 0)) { if (!check_distance_bl(src, bl, 0)) {
#ifdef RENEWAL #ifdef RENEWAL
uint8 dir = map_calc_dir(src, bl->x, bl->y); uint8 dir = map_calc_dir(src, bl->x, bl->y);
short x, y; short x, y;
@ -5477,17 +5488,17 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
y = 0; y = 0;
if (battle_check_target(src, bl, BCT_ENEMY) > 0 && unit_movepos(src, bl->x + x, bl->y + y, 2, true)) { // Display movement + animation. if (battle_check_target(src, bl, BCT_ENEMY) > 0 && unit_movepos(src, bl->x + x, bl->y + y, 2, true)) { // Display movement + animation.
#else #else
uint8 dir = map_calc_dir(src, bl->x, bl->y), t_dir = unit_getdir(bl); uint8 dir = map_calc_dir(src, bl->x, bl->y), t_dir = unit_getdir(bl);
if (!map_check_dir(dir, t_dir) || bl->type == BL_SKILL) { if (!map_check_dir(dir, t_dir) || bl->type == BL_SKILL) {
#endif #endif
status_change_end(src, SC_HIDING); status_change_end(src, SC_HIDING);
dir = dir < 4 ? dir+4 : dir-4; // change direction [Celest] dir = dir < 4 ? dir+4 : dir-4; // change direction [Celest]
unit_setdir(bl,dir); unit_setdir(bl,dir);
#ifdef RENEWAL #ifdef RENEWAL
clif_blown(src); clif_blown(src);
#endif #endif
skill_attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag); skill_attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag);
} }
else if (sd) else if (sd)
@ -5510,19 +5521,19 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
status_change_end(src, SC_BLADESTOP); status_change_end(src, SC_BLADESTOP);
break; break;
#ifndef RENEWAL #ifndef RENEWAL
case NJ_ISSEN: case NJ_ISSEN:
#endif #endif
case MO_EXTREMITYFIST: case MO_EXTREMITYFIST:
{ {
struct block_list *mbl = bl; // For NJ_ISSEN struct block_list *mbl = bl; // For NJ_ISSEN
short x, y, i = 2; // Move 2 cells (From target) short x, y, i = 2; // Move 2 cells (From target)
short dir = map_calc_dir(src,bl->x,bl->y); short dir = map_calc_dir(src,bl->x,bl->y);
#ifdef RENEWAL #ifdef RENEWAL
if (skill_id == MO_EXTREMITYFIST && sd && sd->spiritball_old > 5) if (skill_id == MO_EXTREMITYFIST && sd && sd->spiritball_old > 5)
flag |= 1; // Give +100% damage increase flag |= 1; // Give +100% damage increase
#endif #endif
skill_attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); skill_attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
if (skill_id == MO_EXTREMITYFIST) { if (skill_id == MO_EXTREMITYFIST) {
status_set_sp(src, 0, 0); status_set_sp(src, 0, 0);
@ -5590,9 +5601,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case MG_NAPALMBEAT: case MG_NAPALMBEAT:
case MG_FIREBALL: case MG_FIREBALL:
case RG_RAID: case RG_RAID:
#ifdef RENEWAL #ifdef RENEWAL
case SN_SHARPSHOOTING: case SN_SHARPSHOOTING:
#endif #endif
case HW_NAPALMVULCAN: case HW_NAPALMVULCAN:
case NJ_HUUMA: case NJ_HUUMA:
case ASC_METEORASSAULT: case ASC_METEORASSAULT:
@ -5765,11 +5776,11 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
status_heal(src, heal, 0, 0); status_heal(src, heal, 0, 0);
} }
break; break;
#ifdef RENEWAL #ifdef RENEWAL
case SN_SHARPSHOOTING: case SN_SHARPSHOOTING:
status_change_end(src, SC_CAMOUFLAGE); status_change_end(src, SC_CAMOUFLAGE);
break; break;
#endif #endif
case SJ_PROMINENCEKICK: // Trigger the 2nd hit. (100% fire damage.) case SJ_PROMINENCEKICK: // Trigger the 2nd hit. (100% fire damage.)
skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, sflag|8|SD_ANIMATION); skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, sflag|8|SD_ANIMATION);
break; break;
@ -5801,9 +5812,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case HN_JUPITEL_THUNDER_STORM: case HN_JUPITEL_THUNDER_STORM:
clif_skill_nodamage(src,bl,skill_id,skill_lv,1); clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
break; break;
#ifdef RENEWAL #ifdef RENEWAL
case NJ_HUUMA: case NJ_HUUMA:
#endif #endif
case LG_MOONSLASHER: case LG_MOONSLASHER:
case MH_XENO_SLASHER: case MH_XENO_SLASHER:
clif_skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, DMG_SINGLE); clif_skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, DMG_SINGLE);
@ -5984,13 +5995,13 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
} }
break; break;
#ifdef RENEWAL #ifdef RENEWAL
case KN_BRANDISHSPEAR: case KN_BRANDISHSPEAR:
skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag);
break; break;
#else #else
case KN_BRANDISHSPEAR: case KN_BRANDISHSPEAR:
#endif #endif
case ML_BRANDISH: case ML_BRANDISH:
//Coded apart for it needs the flag passed to the damage calculation. //Coded apart for it needs the flag passed to the damage calculation.
if (skill_area_temp[1] != bl->id) if (skill_area_temp[1] != bl->id)
@ -5999,7 +6010,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag);
break; break;
#ifdef RENEWAL #ifdef RENEWAL
case KN_BOWLINGBASH: case KN_BOWLINGBASH:
if (flag & 1) { if (flag & 1) {
skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, (skill_area_temp[0]) > 0 ? SD_ANIMATION | skill_area_temp[0] : skill_area_temp[0]); skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, (skill_area_temp[0]) > 0 ? SD_ANIMATION | skill_area_temp[0] : skill_area_temp[0]);
@ -6008,9 +6019,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
map_foreachinrange(skill_area_sub, bl, skill_get_splash(skill_id, skill_lv), BL_CHAR|BL_SKILL, src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill_castend_damage_id); map_foreachinrange(skill_area_sub, bl, skill_get_splash(skill_id, skill_lv), BL_CHAR|BL_SKILL, src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill_castend_damage_id);
} }
break; break;
#else #else
case KN_BOWLINGBASH: case KN_BOWLINGBASH:
#endif #endif
case MS_BOWLINGBASH: case MS_BOWLINGBASH:
{ {
int min_x,max_x,min_y,max_y,i,c,dir,tx,ty; int min_x,max_x,min_y,max_y,i,c,dir,tx,ty;
@ -6150,9 +6161,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case MG_FROSTDIVER: case MG_FROSTDIVER:
case WZ_SIGHTBLASTER: case WZ_SIGHTBLASTER:
case WZ_SIGHTRASHER: case WZ_SIGHTRASHER:
#ifdef RENEWAL #ifdef RENEWAL
case PA_PRESSURE: case PA_PRESSURE:
#endif #endif
case NJ_KOUENKA: case NJ_KOUENKA:
case NJ_HYOUSENSOU: case NJ_HYOUSENSOU:
case NJ_HUUJIN: case NJ_HUUJIN:
@ -6258,10 +6269,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break; // 50% chance break; // 50% chance
[[fallthrough]]; [[fallthrough]];
case SN_FALCONASSAULT: case SN_FALCONASSAULT:
#ifndef RENEWAL #ifndef RENEWAL
case PA_PRESSURE: case PA_PRESSURE:
case CR_ACIDDEMONSTRATION: case CR_ACIDDEMONSTRATION:
#endif #endif
case TF_THROWSTONE: case TF_THROWSTONE:
case NPC_SMOKING: case NPC_SMOKING:
case GS_FLING: case GS_FLING:
@ -6270,7 +6281,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case RL_B_TRAP: case RL_B_TRAP:
skill_attack(skill_get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag); skill_attack(skill_get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag);
break; break;
#ifdef RENEWAL #ifdef RENEWAL
case NJ_ISSEN: { case NJ_ISSEN: {
short x, y; short x, y;
short dir = map_calc_dir(src, bl->x, bl->y); short dir = map_calc_dir(src, bl->x, bl->y);
@ -6299,7 +6310,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
status_change_end(src, SC_HIDING); status_change_end(src, SC_HIDING);
} }
break; break;
#endif #endif
case RK_DRAGONBREATH_WATER: case RK_DRAGONBREATH_WATER:
case RK_DRAGONBREATH: case RK_DRAGONBREATH:
case NPC_DRAGONBREATH: case NPC_DRAGONBREATH:
@ -6535,9 +6546,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
if (sd) { if (sd) {
int i; int i;
#ifndef RENEWAL #ifndef RENEWAL
skill_toggle_magicpower(src, skill_id); // No hit will be amplified skill_toggle_magicpower(src, skill_id); // No hit will be amplified
#endif #endif
if (skill_lv == 1) { // SpellBook if (skill_lv == 1) { // SpellBook
if (sc->getSCE(SC_FREEZE_SP) == nullptr) if (sc->getSCE(SC_FREEZE_SP) == nullptr)
break; break;
@ -7142,6 +7153,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
map_freeblock_unlock(); map_freeblock_unlock();
return 1; return 1;
} }
}
if( sc && sc->getSCE(SC_CURSEDCIRCLE_ATKER) ) //Should only remove after the skill has been casted. if( sc && sc->getSCE(SC_CURSEDCIRCLE_ATKER) ) //Should only remove after the skill has been casted.
status_change_end(src,SC_CURSEDCIRCLE_ATKER); status_change_end(src,SC_CURSEDCIRCLE_ATKER);
@ -7365,6 +7377,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
return 1; //Skills that cause an status should be blocked if the target element blocks its element. return 1; //Skills that cause an status should be blocked if the target element blocks its element.
map_freeblock_lock(); map_freeblock_lock();
try {
const Skill& skill = skillRepository.getSkill(static_cast<e_skill>(skill_id));
skill.castendNoDamage(src, bl, skill_lv, tick, flag);
} catch (SkillRepository::SkillNotFoundException e) {
// fallback on switch
switch(skill_id) switch(skill_id)
{ {
case HLIF_HEAL: //[orn] case HLIF_HEAL: //[orn]
@ -7439,14 +7457,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif_skill_fail( *sd, skill_id ); clif_skill_fail( *sd, skill_id );
break; break;
} }
#ifndef RENEWAL #ifndef RENEWAL
skill_area_temp[0] = battle_config.exp_cost_redemptio_limit - skill_area_temp[0]; // The actual penalty... skill_area_temp[0] = battle_config.exp_cost_redemptio_limit - skill_area_temp[0]; // The actual penalty...
if (skill_area_temp[0] > 0 && !map_getmapflag(src->m, MF_NOEXPPENALTY) && battle_config.exp_cost_redemptio) { //Apply penalty if (skill_area_temp[0] > 0 && !map_getmapflag(src->m, MF_NOEXPPENALTY) && battle_config.exp_cost_redemptio) { //Apply penalty
//If total penalty is 1% => reduced 0.2% penalty per each revived player //If total penalty is 1% => reduced 0.2% penalty per each revived player
pc_lostexp(sd, u64min(sd->status.base_exp, (pc_nextbaseexp(sd) * skill_area_temp[0] * battle_config.exp_cost_redemptio / battle_config.exp_cost_redemptio_limit) / 100), 0); pc_lostexp(sd, u64min(sd->status.base_exp, (pc_nextbaseexp(sd) * skill_area_temp[0] * battle_config.exp_cost_redemptio / battle_config.exp_cost_redemptio_limit) / 100), 0);
} }
status_set_sp(src, 0, 0); status_set_sp(src, 0, 0);
#endif #endif
status_set_hp(src, 1, 0); status_set_hp(src, 1, 0);
break; break;
} else if (!(status_isdead(bl) && flag&1)) { } else if (!(status_isdead(bl) && flag&1)) {
@ -7753,9 +7771,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif_skill_nodamage(src,bl,skill_id,skill_lv,0); clif_skill_nodamage(src,bl,skill_id,skill_lv,0);
break; break;
} }
#ifdef RENEWAL #ifdef RENEWAL
clif_skill_nodamage(src, bl, skill_id, skill_lv, sc_start(src, bl, type, 100, skill_lv, skill_get_time(skill_id, skill_lv))); clif_skill_nodamage(src, bl, skill_id, skill_lv, sc_start(src, bl, type, 100, skill_lv, skill_get_time(skill_id, skill_lv)));
#else #else
// 100% success rate at lv4 & 5, but lasts longer at lv5 // 100% success rate at lv4 & 5, but lasts longer at lv5
if(!clif_skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,type,(60+skill_lv*10),skill_lv, skill_get_time(skill_id,skill_lv)))) { if(!clif_skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,type,(60+skill_lv*10),skill_lv, skill_get_time(skill_id,skill_lv)))) {
if (dstsd){ if (dstsd){
@ -7766,7 +7784,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (sd) if (sd)
clif_skill_fail( *sd, skill_id ); clif_skill_fail( *sd, skill_id );
} }
#endif #endif
break; break;
case PR_ASPERSIO: case PR_ASPERSIO:
@ -7854,11 +7872,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill_castend_damage_id); src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill_castend_damage_id);
clif_skill_nodamage (src,src,skill_id,skill_lv,1); clif_skill_nodamage (src,src,skill_id,skill_lv,1);
// Initiate 20% of your damage becomes fire element. // Initiate 20% of your damage becomes fire element.
#ifdef RENEWAL #ifdef RENEWAL
sc_start4(src,src,SC_SUB_WEAPONPROPERTY,100,ELE_FIRE,20,skill_id,0,skill_get_time2(skill_id, skill_lv)); sc_start4(src,src,SC_SUB_WEAPONPROPERTY,100,ELE_FIRE,20,skill_id,0,skill_get_time2(skill_id, skill_lv));
#else #else
sc_start4(src,src,SC_WATK_ELEMENT,100,ELE_FIRE,20,0,0,skill_get_time2(skill_id, skill_lv)); sc_start4(src,src,SC_WATK_ELEMENT,100,ELE_FIRE,20,0,0,skill_get_time2(skill_id, skill_lv));
#endif #endif
break; break;
case MH_BLAZING_AND_FURIOUS: case MH_BLAZING_AND_FURIOUS:
@ -7900,10 +7918,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
[[fallthrough]]; [[fallthrough]];
case PR_SLOWPOISON: case PR_SLOWPOISON:
case PR_LEXAETERNA: case PR_LEXAETERNA:
#ifndef RENEWAL #ifndef RENEWAL
case PR_IMPOSITIO: case PR_IMPOSITIO:
case PR_SUFFRAGIUM: case PR_SUFFRAGIUM:
#endif #endif
case LK_BERSERK: case LK_BERSERK:
case MS_BERSERK: case MS_BERSERK:
case KN_TWOHANDQUICKEN: case KN_TWOHANDQUICKEN:
@ -7911,9 +7929,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case MER_QUICKEN: case MER_QUICKEN:
case CR_SPEARQUICKEN: case CR_SPEARQUICKEN:
case AS_POISONREACT: case AS_POISONREACT:
#ifndef RENEWAL #ifndef RENEWAL
case MC_LOUD: case MC_LOUD:
#endif #endif
case MG_ENERGYCOAT: case MG_ENERGYCOAT:
case MO_EXPLOSIONSPIRITS: case MO_EXPLOSIONSPIRITS:
case MO_STEELBODY: case MO_STEELBODY:
@ -7922,9 +7940,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case LK_PARRYING: case LK_PARRYING:
case MS_PARRYING: case MS_PARRYING:
case LK_CONCENTRATION: case LK_CONCENTRATION:
#ifdef RENEWAL #ifdef RENEWAL
case HP_BASILICA: case HP_BASILICA:
#endif #endif
case WS_CARTBOOST: case WS_CARTBOOST:
case SN_SIGHT: case SN_SIGHT:
case WS_MELTDOWN: case WS_MELTDOWN:
@ -7940,9 +7958,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case GS_MADNESSCANCEL: case GS_MADNESSCANCEL:
case GS_ADJUSTMENT: case GS_ADJUSTMENT:
case GS_INCREASING: case GS_INCREASING:
#ifdef RENEWAL #ifdef RENEWAL
case GS_MAGICALBULLET: case GS_MAGICALBULLET:
#endif #endif
case NJ_KASUMIKIRI: case NJ_KASUMIKIRI:
case NJ_UTSUSEMI: case NJ_UTSUSEMI:
case NJ_NEN: case NJ_NEN:
@ -8044,11 +8062,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case ASC_EDP: case ASC_EDP:
clif_skill_nodamage(src,bl,skill_id,skill_lv, clif_skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(src,bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv))); sc_start(src,bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv)));
#ifdef RENEWAL #ifdef RENEWAL
sc_start4(src, src, SC_SUB_WEAPONPROPERTY, 100, ELE_POISON, 25, skill_id, 0, skill_get_time(skill_id, skill_lv)); sc_start4(src, src, SC_SUB_WEAPONPROPERTY, 100, ELE_POISON, 25, skill_id, 0, skill_get_time(skill_id, skill_lv));
#else #else
sc_start4(src, src, SC_WATK_ELEMENT, 100, ELE_POISON, 25, 0, 0, skill_get_time(skill_id, skill_lv)); sc_start4(src, src, SC_WATK_ELEMENT, 100, ELE_POISON, 25, 0, 0, skill_get_time(skill_id, skill_lv));
#endif #endif
break; break;
case LG_SHIELDSPELL: case LG_SHIELDSPELL:
@ -8247,7 +8265,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(src,bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv))); sc_start(src,bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv)));
status_change_end(bl, SC_NEN); status_change_end(bl, SC_NEN);
break; break;
/* Was modified to only affect targetted char. [Skotlex] /* Was modified to only affect targetted char. [Skotlex]
case HP_ASSUMPTIO: case HP_ASSUMPTIO:
if (flag&1) if (flag&1)
sc_start(bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv)); sc_start(bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv));
@ -8260,7 +8278,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif_skill_nodamage(src,bl,skill_id,skill_lv,1); clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
} }
break; break;
*/ */
case SM_ENDURE: case SM_ENDURE:
clif_skill_nodamage(src,bl,skill_id,skill_lv, clif_skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(src,bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv))); sc_start(src,bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv)));
@ -8328,7 +8346,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
break; break;
case SM_PROVOKE:
case SM_SELFPROVOKE: case SM_SELFPROVOKE:
case MER_PROVOKE: case MER_PROVOKE:
if( status_has_mode(tstatus,MD_STATUSIMMUNE) || battle_check_undead(tstatus->race,tstatus->def_ele) ) { if( status_has_mode(tstatus,MD_STATUSIMMUNE) || battle_check_undead(tstatus->race,tstatus->def_ele) ) {
@ -8740,11 +8757,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_IGNITIONBREAK: case NPC_IGNITIONBREAK:
case RK_IGNITIONBREAK: case RK_IGNITIONBREAK:
skill_area_temp[1] = 0; skill_area_temp[1] = 0;
#if PACKETVER >= 20180207 #if PACKETVER >= 20180207
clif_skill_nodamage(src,bl,skill_id,skill_lv,1); clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
#else #else
clif_skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, DMG_SINGLE); clif_skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, DMG_SINGLE);
#endif #endif
map_foreachinrange(skill_area_sub, bl, skill_get_splash(skill_id, skill_lv), BL_CHAR|BL_SKILL, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill_castend_damage_id); map_foreachinrange(skill_area_sub, bl, skill_get_splash(skill_id, skill_lv), BL_CHAR|BL_SKILL, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill_castend_damage_id);
break; break;
@ -8764,16 +8781,16 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
skill_castend_damage_id(src, src, skill_id, skill_lv, tick, flag); skill_castend_damage_id(src, src, skill_id, skill_lv, tick, flag);
break; break;
#ifdef RENEWAL #ifdef RENEWAL
case KN_BRANDISHSPEAR: case KN_BRANDISHSPEAR:
map_foreachindir(skill_area_sub, src->m, src->x, src->y, bl->x, bl->y, map_foreachindir(skill_area_sub, src->m, src->x, src->y, bl->x, bl->y,
skill_get_splash(skill_id, skill_lv), skill_get_maxcount(skill_id, skill_lv), 0, splash_target(src), skill_get_splash(skill_id, skill_lv), skill_get_maxcount(skill_id, skill_lv), 0, splash_target(src),
src, skill_id, skill_lv, tick, flag | BCT_ENEMY | 0, src, skill_id, skill_lv, tick, flag | BCT_ENEMY | 0,
skill_castend_damage_id); skill_castend_damage_id);
break; break;
#else #else
case KN_BRANDISHSPEAR: case KN_BRANDISHSPEAR:
#endif #endif
case ML_BRANDISH: case ML_BRANDISH:
skill_area_temp[1] = bl->id; skill_area_temp[1] = bl->id;
@ -8842,10 +8859,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
break; break;
case AL_ANGELUS: case AL_ANGELUS:
#ifdef RENEWAL #ifdef RENEWAL
case PR_SUFFRAGIUM: case PR_SUFFRAGIUM:
case PR_IMPOSITIO: case PR_IMPOSITIO:
#endif #endif
case PR_MAGNIFICAT: case PR_MAGNIFICAT:
case PR_GLORIA: case PR_GLORIA:
if (sd == nullptr || sd->status.party_id == 0 || (flag & 1)) { if (sd == nullptr || sd->status.party_id == 0 || (flag & 1)) {
@ -8859,9 +8876,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
else if (sd) else if (sd)
party_foreachsamemap(skill_area_sub, sd, skill_get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag | BCT_PARTY | 1, skill_castend_nodamage_id); party_foreachsamemap(skill_area_sub, sd, skill_get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag | BCT_PARTY | 1, skill_castend_nodamage_id);
break; break;
#ifdef RENEWAL #ifdef RENEWAL
case MC_LOUD: case MC_LOUD:
#endif #endif
case SN_WINDWALK: case SN_WINDWALK:
case CASH_BLESSING: case CASH_BLESSING:
case CASH_INCAGI: case CASH_INCAGI:
@ -9034,15 +9051,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break; break;
case BD_ADAPTATION: case BD_ADAPTATION:
#ifdef RENEWAL #ifdef RENEWAL
clif_skill_nodamage(src, bl, skill_id, skill_lv, 1); clif_skill_nodamage(src, bl, skill_id, skill_lv, 1);
sc_start(src, bl, type, 100, skill_lv, skill_get_time(skill_id, skill_lv)); sc_start(src, bl, type, 100, skill_lv, skill_get_time(skill_id, skill_lv));
#else #else
if(tsc && tsc->getSCE(SC_DANCING)){ if(tsc && tsc->getSCE(SC_DANCING)){
clif_skill_nodamage(src,bl,skill_id,skill_lv,1); clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
status_change_end(bl, SC_DANCING); status_change_end(bl, SC_DANCING);
} }
#endif #endif
break; break;
case BA_FROSTJOKER: case BA_FROSTJOKER:
@ -9061,17 +9078,17 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case BA_PANGVOICE: case BA_PANGVOICE:
clif_skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,SC_CONFUSION,70,7,skill_get_time(skill_id,skill_lv))); clif_skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,SC_CONFUSION,70,7,skill_get_time(skill_id,skill_lv)));
#ifdef RENEWAL #ifdef RENEWAL
sc_start(src, bl, SC_BLEEDING, 30, skill_lv, skill_get_time2(skill_id, skill_lv)); // TODO: Confirm success rate sc_start(src, bl, SC_BLEEDING, 30, skill_lv, skill_get_time2(skill_id, skill_lv)); // TODO: Confirm success rate
#endif #endif
break; break;
case DC_WINKCHARM: case DC_WINKCHARM:
if( dstsd ) { if( dstsd ) {
clif_skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,SC_CONFUSION,10,7,skill_get_time2(skill_id,skill_lv))); clif_skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,SC_CONFUSION,10,7,skill_get_time2(skill_id,skill_lv)));
#ifdef RENEWAL #ifdef RENEWAL
sc_start(src, bl, SC_HALLUCINATION, 30, skill_lv, skill_get_time(skill_id, skill_lv)); // TODO: Confirm success rate and duration sc_start(src, bl, SC_HALLUCINATION, 30, skill_lv, skill_get_time(skill_id, skill_lv)); // TODO: Confirm success rate and duration
#endif #endif
} else } else
if( dstmd ) if( dstmd )
{ {
@ -9087,7 +9104,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
break; break;
#ifdef RENEWAL #ifdef RENEWAL
case BD_LULLABY: case BD_LULLABY:
case BD_RICHMANKIM: case BD_RICHMANKIM:
case BD_ETERNALCHAOS: case BD_ETERNALCHAOS:
@ -9108,7 +9125,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case DC_SERVICEFORYOU: case DC_SERVICEFORYOU:
skill_castend_song(src, skill_id, skill_lv, tick); skill_castend_song(src, skill_id, skill_lv, tick);
break; break;
#endif #endif
case TF_STEAL: case TF_STEAL:
if(sd) { if(sd) {
@ -9543,10 +9560,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
} }
#ifdef RENEWAL #ifdef RENEWAL
if (bl->type == BL_HOM) if (bl->type == BL_HOM)
hp *= 3; // Heal effectiveness is 3x for Homunculus hp *= 3; // Heal effectiveness is 3x for Homunculus
#endif #endif
clif_skill_nodamage(src,bl,skill_id,skill_lv,1); clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
if( hp > 0 || (skill_id == AM_POTIONPITCHER && sp <= 0) ) if( hp > 0 || (skill_id == AM_POTIONPITCHER && sp <= 0) )
@ -9554,10 +9571,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( sp > 0 ) if( sp > 0 )
clif_skill_nodamage(nullptr,bl,MG_SRECOVERY,sp,1); clif_skill_nodamage(nullptr,bl,MG_SRECOVERY,sp,1);
if (tsc) { if (tsc) {
#ifdef RENEWAL #ifdef RENEWAL
if (tsc->getSCE(SC_EXTREMITYFIST)) if (tsc->getSCE(SC_EXTREMITYFIST))
sp = 0; sp = 0;
#endif #endif
if (tsc->getSCE(SC_NORECOVER_STATE)) { if (tsc->getSCE(SC_NORECOVER_STATE)) {
hp = 0; hp = 0;
sp = 0; sp = 0;
@ -9683,17 +9700,17 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case TF_BACKSLIDING: //This is the correct implementation as per packet logging information. [Skotlex] case TF_BACKSLIDING: //This is the correct implementation as per packet logging information. [Skotlex]
{ {
short blew_count = skill_blown(src,bl,skill_get_blewcount(skill_id,skill_lv),unit_getdir(bl),(enum e_skill_blown)(BLOWN_IGNORE_NO_KNOCKBACK short blew_count = skill_blown(src,bl,skill_get_blewcount(skill_id,skill_lv),unit_getdir(bl),(enum e_skill_blown)(BLOWN_IGNORE_NO_KNOCKBACK
#ifdef RENEWAL #ifdef RENEWAL
|BLOWN_DONT_SEND_PACKET |BLOWN_DONT_SEND_PACKET
#endif #endif
)); ));
clif_skill_nodamage(src, bl, skill_id, skill_lv, 1); clif_skill_nodamage(src, bl, skill_id, skill_lv, 1);
#ifdef RENEWAL #ifdef RENEWAL
if(blew_count > 0) if(blew_count > 0)
clif_blown(src); // Always blow, otherwise it shows a casting animation. [Lemongrass] clif_blown(src); // Always blow, otherwise it shows a casting animation. [Lemongrass]
#else #else
clif_slide(bl, bl->x, bl->y); //Show the casting animation on pre-re clif_slide(bl, bl->x, bl->y); //Show the casting animation on pre-re
#endif #endif
} }
break; break;
@ -9764,9 +9781,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break; break;
} }
} }
#ifdef RENEWAL #ifdef RENEWAL
else // HP damage does not work on bosses in renewal else // HP damage does not work on bosses in renewal
#endif #endif
if (skill_lv >= 5 && (!dstsd || map_flag_vs(bl->m))) //HP damage only on pvp-maps when against players. if (skill_lv >= 5 && (!dstsd || map_flag_vs(bl->m))) //HP damage only on pvp-maps when against players.
hp = tstatus->max_hp / 50; //Siphon 2% HP at level 5 hp = tstatus->max_hp / 50; //Siphon 2% HP at level 5
@ -9788,9 +9805,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
break; break;
case SA_MAGICROD: case SA_MAGICROD:
#ifdef RENEWAL #ifdef RENEWAL
clif_skill_nodamage(src,src,SA_MAGICROD,skill_lv,1); clif_skill_nodamage(src,src,SA_MAGICROD,skill_lv,1);
#endif #endif
sc_start(src,bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv)); sc_start(src,bl,type,100,skill_lv,skill_get_time(skill_id,skill_lv));
break; break;
case SA_AUTOSPELL: case SA_AUTOSPELL:
@ -9804,9 +9821,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if(skill_lv >= 10) { if(skill_lv >= 10) {
spellid = MG_FROSTDIVER; spellid = MG_FROSTDIVER;
// if (tsc && tsc->getSCE(SC_SPIRIT) && tsc->getSCE(SC_SPIRIT)->val2 == SA_SAGE) // if (tsc && tsc->getSCE(SC_SPIRIT) && tsc->getSCE(SC_SPIRIT)->val2 == SA_SAGE)
// maxlv = 10; // maxlv = 10;
// else // else
maxlv = skill_lv - 9; maxlv = skill_lv - 9;
} }
else if(skill_lv >=8) { else if(skill_lv >=8) {
@ -10247,9 +10264,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AS_SPLASHER: case AS_SPLASHER:
if( status_has_mode(tstatus,MD_STATUSIMMUNE) if( status_has_mode(tstatus,MD_STATUSIMMUNE)
// Renewal dropped the 3/4 hp requirement // Renewal dropped the 3/4 hp requirement
#ifndef RENEWAL #ifndef RENEWAL
|| tstatus-> hp > tstatus->max_hp*3/4 || tstatus-> hp > tstatus->max_hp*3/4
#endif #endif
) { ) {
if (sd) clif_skill_fail( *sd, skill_id ); if (sd) clif_skill_fail( *sd, skill_id );
map_freeblock_unlock(); map_freeblock_unlock();
@ -10305,12 +10322,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
sp1 = sstatus->sp; sp1 = sstatus->sp;
sp2 = tstatus->sp; sp2 = tstatus->sp;
#ifdef RENEWAL #ifdef RENEWAL
sp1 = sp1 / 2; sp1 = sp1 / 2;
sp2 = sp2 / 2; sp2 = sp2 / 2;
if (tsc && tsc->getSCE(SC_EXTREMITYFIST)) if (tsc && tsc->getSCE(SC_EXTREMITYFIST))
sp1 = tstatus->sp; sp1 = tstatus->sp;
#endif #endif
if (tsc && tsc->getSCE(SC_NORECOVER_STATE)) if (tsc && tsc->getSCE(SC_NORECOVER_STATE))
sp1 = tstatus->sp; sp1 = tstatus->sp;
status_set_sp(src, sp2, 3); status_set_sp(src, sp2, 3);
@ -10384,7 +10401,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif_skill_nodamage(src,bl,skill_id,skill_lv,1); clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
break; break;
#ifndef RENEWAL #ifndef RENEWAL
case CG_LONGINGFREEDOM: case CG_LONGINGFREEDOM:
{ {
if (tsc && !tsce && (tsce=tsc->getSCE(SC_DANCING)) && tsce->val4 if (tsc && !tsce && (tsce=tsc->getSCE(SC_DANCING)) && tsce->val4
@ -10395,7 +10412,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
} }
break; break;
#endif #endif
case CG_TAROTCARD: case CG_TAROTCARD:
{ {
@ -10406,9 +10423,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
return 0; return 0;
} }
if( rnd() % 100 > skill_lv * 8 || if( rnd() % 100 > skill_lv * 8 ||
#ifndef RENEWAL #ifndef RENEWAL
(tsc && tsc->getSCE(SC_BASILICA)) || (tsc && tsc->getSCE(SC_BASILICA)) ||
#endif #endif
(dstmd && ((dstmd->guardian_data && dstmd->mob_id == MOBID_EMPERIUM) || status_get_class_(bl) == CLASS_BATTLEFIELD)) ) { (dstmd && ((dstmd->guardian_data && dstmd->mob_id == MOBID_EMPERIUM) || status_get_class_(bl) == CLASS_BATTLEFIELD)) ) {
if( sd ) if( sd )
clif_skill_fail( *sd, skill_id ); clif_skill_fail( *sd, skill_id );
@ -10523,11 +10540,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, src,skill_id,skill_lv,tick, flag|BCT_GUILD|1,
skill_castend_nodamage_id); skill_castend_nodamage_id);
if (sd) if (sd)
#ifdef RENEWAL #ifdef RENEWAL
skill_blockpc_start(sd, skill_id, skill_get_cooldown(skill_id, skill_lv)); skill_blockpc_start(sd, skill_id, skill_get_cooldown(skill_id, skill_lv));
#else #else
guild_block_skill(sd, skill_get_time2(skill_id, skill_lv)); guild_block_skill(sd, skill_get_time2(skill_id, skill_lv));
#endif #endif
} }
break; break;
case GD_EMERGENCYCALL: case GD_EMERGENCYCALL:
@ -10565,11 +10582,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
} }
if (sd) if (sd)
#ifdef RENEWAL #ifdef RENEWAL
skill_blockpc_start(sd, skill_id, skill_get_cooldown(skill_id, skill_lv)); skill_blockpc_start(sd, skill_id, skill_get_cooldown(skill_id, skill_lv));
#else #else
guild_block_skill(sd, skill_get_time2(skill_id, skill_lv)); guild_block_skill(sd, skill_get_time2(skill_id, skill_lv));
#endif #endif
} }
break; break;
case GD_CHARGESHOUT_FLAG: case GD_CHARGESHOUT_FLAG:
@ -10659,10 +10676,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AM_CALLHOMUN: //[orn] case AM_CALLHOMUN: //[orn]
if (sd && !hom_call(sd)) if (sd && !hom_call(sd))
clif_skill_fail( *sd, skill_id ); clif_skill_fail( *sd, skill_id );
#ifdef RENEWAL #ifdef RENEWAL
else if (sd && hom_is_active(sd->hd)) else if (sd && hom_is_active(sd->hd))
skill_area_temp[0] = 1; // Already passed pre-cast checks skill_area_temp[0] = 1; // Already passed pre-cast checks
#endif #endif
break; break;
case AM_REST: case AM_REST:
@ -12335,11 +12352,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case MH_SILENT_BREEZE: case MH_SILENT_BREEZE:
{ {
int heal = 5 * status_get_lv(&hd->bl) + int heal = 5 * status_get_lv(&hd->bl) +
#ifdef RENEWAL #ifdef RENEWAL
status_base_matk_min(bl, &hd->battle_status, status_get_lv(&hd->bl)); status_base_matk_min(bl, &hd->battle_status, status_get_lv(&hd->bl));
#else #else
status_base_matk_min(&hd->battle_status); status_base_matk_min(&hd->battle_status);
#endif #endif
//Silences the homunculus and target //Silences the homunculus and target
status_change_start(src,src,SC_SILENCE,10000,skill_lv,0,0,0,skill_get_time(skill_id,skill_lv),SCSTART_NONE); status_change_start(src,src,SC_SILENCE,10000,skill_lv,0,0,0,skill_get_time(skill_id,skill_lv),SCSTART_NONE);
status_change_start(src,bl,SC_SILENCE,10000,skill_lv,0,0,0,skill_get_time(skill_id,skill_lv),SCSTART_NONE); status_change_start(src,bl,SC_SILENCE,10000,skill_lv,0,0,0,skill_get_time(skill_id,skill_lv),SCSTART_NONE);
@ -12903,11 +12920,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} }
break; break;
#ifdef RENEWAL #ifdef RENEWAL
case CG_HERMODE: case CG_HERMODE:
skill_castend_song(src, skill_id, skill_lv, tick); skill_castend_song(src, skill_id, skill_lv, tick);
break; break;
#endif #endif
case NPC_LEASH: case NPC_LEASH:
clif_skill_nodamage( src, bl, skill_id, skill_lv, 1 ); clif_skill_nodamage( src, bl, skill_id, skill_lv, 1 );
@ -12994,6 +13011,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
return 1; return 1;
} }
} }
}
if (skill_id != SR_CURSEDCIRCLE && skill_id != NPC_SR_CURSEDCIRCLE) { if (skill_id != SR_CURSEDCIRCLE && skill_id != NPC_SR_CURSEDCIRCLE) {
if (sc && sc->getSCE(SC_CURSEDCIRCLE_ATKER)) // Should only remove after the skill had been casted. if (sc && sc->getSCE(SC_CURSEDCIRCLE_ATKER)) // Should only remove after the skill had been casted.
@ -25344,6 +25363,8 @@ void do_init_skill(void)
{ {
skill_readdb(); skill_readdb();
init_skill_repository();
skillunit_db = idb_alloc(DB_OPT_BASE); skillunit_db = idb_alloc(DB_OPT_BASE);
skillusave_db = idb_alloc(DB_OPT_RELEASE_DATA); skillusave_db = idb_alloc(DB_OPT_RELEASE_DATA);
bowling_db = idb_alloc(DB_OPT_BASE); bowling_db = idb_alloc(DB_OPT_BASE);

53
src/map/skills/skill.cpp Normal file
View File

@ -0,0 +1,53 @@
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include <common/showmsg.hpp>
#include "skill.hpp"
#include "map/battle.hpp"
#include "map/skill.hpp"
#include "map/clif.hpp"
#include "map/map.hpp"
#include "map/status.hpp"
uint16_t Skill::getSkillId() const {
return skill_id_;
}
int Skill::castendDamageImpl(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const {
throw SkillNotImplementedException(skill_id_);
}
int Skill::castendNoDamageImpl(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const {
throw SkillNotImplementedException(skill_id_);
}
int Skill::castendPositionImpl() const {
throw SkillNotImplementedException(skill_id_);
}
int Skill::castendDamage(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const {
try {
return castendDamageImpl(src, target, skill_lv, tick, flag);
} catch (SkillNotImplementedException e) {
ShowWarning("castendDamage: %s\n", e.what());
clif_skill_damage(src, target, tick, status_get_amotion(src), status_get_status_data(target)->dmotion, 0, abs(skill_get_num(skill_id_, skill_lv)), skill_id_, skill_lv, skill_get_hit(skill_id_));
return 1;
}
}
int Skill::castendNoDamage(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const {
try {
return castendNoDamageImpl(src, target, skill_lv, tick, flag);
} catch (SkillNotImplementedException e) {
ShowWarning("castendNoDamage: %s\n", e.what());
clif_skill_damage(src, target, tick, status_get_amotion(src), status_get_status_data(target)->dmotion, 0, abs(skill_get_num(skill_id_, skill_lv)), skill_id_, skill_lv, skill_get_hit(skill_id_));
return 1;
}
}
int WeaponSkill::castendDamageImpl(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const {
skill_attack(BF_WEAPON, src, src, target, skill_id_, skill_lv, tick, flag);
return 0;
};

43
src/map/skills/skill.hpp Normal file
View File

@ -0,0 +1,43 @@
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#ifndef MAP_SKILL_HPP
#define MAP_SKILL_HPP
#include <array>
#include <string>
#include "map/skill.hpp"
class SkillNotImplementedException : public std::logic_error {
public:
explicit SkillNotImplementedException(const std::string &what_arg) : std::logic_error(what_arg) {};
explicit SkillNotImplementedException(uint16_t skill_id) : std::logic_error("Skill " + std::to_string(skill_id) + " not implemented") {};
};
class Skill {
public:
uint16_t getSkillId() const;
virtual ~Skill() = default;
explicit Skill(e_skill skillid) : skill_id_(static_cast<uint16_t>(skillid)) {};
int castendDamage(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const;
int castendNoDamage(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const;
protected:
virtual int castendDamageImpl(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const;
virtual int castendNoDamageImpl(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const;
virtual int castendPositionImpl() const;
uint16_t skill_id_;
};
class WeaponSkill : public Skill {
public:
explicit WeaponSkill(e_skill skill_id) : Skill(skill_id) {};
protected:
virtual int castendDamageImpl(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const override;
};
#endif // MAP_SKILL_HPP

View File

@ -0,0 +1,25 @@
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "skillrepository.hpp"
#include "swordsman.hpp"
#include <memory>
SkillRepository skillRepository;
const Skill& SkillRepository::getSkill(e_skill skill_id) {
auto skill = skill_db_.find(skill_id);
if (skill == skill_db_.end()) {
throw SkillNotFoundException{};
}
return *skill->second;
}
void SkillRepository::addSkill(e_skill skill_id, std::unique_ptr<Skill> skill) {
skill_db_.emplace(skill_id, std::move(skill));
}
void init_skill_repository() {
init_swordsman_skills(skillRepository);
}

View File

@ -0,0 +1,25 @@
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#pragma once
#include <memory>
#include "skill.hpp"
#include "map/skill.hpp"
class SkillRepository {
public:
class SkillNotFoundException : public std::exception {};
const Skill& getSkill(e_skill skill_id);
void addSkill(e_skill skill_id, std::unique_ptr<Skill> skill);
private:
std::unordered_map<e_skill, std::unique_ptr<Skill>> skill_db_;
};
extern SkillRepository skillRepository;
void init_skill_repository();

View File

@ -0,0 +1,56 @@
#include "swordsman.hpp"
#include "skillrepository.hpp"
#include "map/battle.hpp"
#include "map/clif.hpp"
#include "map/mob.hpp"
#include "map/skill.hpp"
#include "map/status.hpp"
#include "map/unit.hpp"
Provoke::Provoke() : Skill(e_skill::SM_PROVOKE) {};
int Provoke::castendNoDamageImpl(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const {
status_data *target_status = status_get_status_data(target);
if (status_has_mode(target_status, MD_STATUSIMMUNE) || battle_check_undead(target_status->race, target_status->def_ele)) {
return 1;
}
map_session_data *sd = BL_CAST(BL_PC, src);
mob_data *target_md = BL_CAST(BL_MOB, target);
sc_type type = skill_get_sc(skill_id_);
// official chance is 70% + 3% per skill level + srcBaseLevel% - targetBaseLevel%
int chance = 70 + 3 * skill_lv + status_get_lv(src) - status_get_lv(target);
int i = sc_start(src, target, type, skill_id_ == SM_SELFPROVOKE ? 100 : chance, skill_lv, skill_get_time(skill_id_, skill_lv));
if (!i) {
if (sd) {
clif_skill_fail(*sd, skill_id_);
}
return 0;
}
clif_skill_nodamage(src, target, skill_id_ == SM_SELFPROVOKE ? SM_PROVOKE : skill_id_, skill_lv, i);
unit_skillcastcancel(target, 2);
if (target_md) {
target_md->state.provoke_flag = src->id;
mob_target(target_md, src, skill_get_range2(src, skill_id_, skill_lv, true));
}
// Provoke can cause Coma even though it's a nodamage skill
if (sd && battle_check_coma(*sd, *target, BF_MISC)) {
status_change_start(src, target, SC_COMA, 10000, skill_lv, 0, src->id, 0, 0, SCSTART_NONE);
}
return 0;
}
void init_swordsman_skills(SkillRepository& repo) {
repo.addSkill(e_skill::SM_BASH, std::make_unique<WeaponSkill>(e_skill::SM_BASH));
repo.addSkill(e_skill::SM_PROVOKE, std::make_unique<Provoke>());
}

View File

@ -0,0 +1,12 @@
#pragma once
#include "skillrepository.hpp"
class Provoke : public Skill {
public:
Provoke();
virtual int castendNoDamageImpl(block_list *src, block_list *target, uint16 skill_lv, t_tick tick, int flag) const override;
};
void init_swordsman_skills(SkillRepository& repo);

View File

@ -1,80 +1,41 @@
# Define the tools interface library, all tools will inherit properties
add_library(tools INTERFACE)
target_include_directories(tools INTERFACE
${YAML_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${RA_INCLUDE_DIRS}
)
target_sources(tools INTERFACE
"${COMMON_SOURCE_DIR}/utils.cpp"
"${COMMON_SOURCE_DIR}/des.cpp"
"${COMMON_SOURCE_DIR}/grfio.cpp"
"${COMMON_SOURCE_DIR}/nullpo.cpp"
"${COMMON_SOURCE_DIR}/database.cpp"
)
target_compile_definitions(tools INTERFACE
"MINICORE"
)
target_link_libraries(tools INTERFACE
${GLOBAL_LIBRARIES}
${ZLIB_LIBRARIES}
yaml-cpp
ryml
minicore
)
# mapcache
message( STATUS "Creating target mapcache" )
add_executable(mapcache) add_executable(mapcache)
target_link_libraries(mapcache PRIVATE tools) target_link_libraries(mapcache PRIVATE minicore)
target_sources(mapcache PRIVATE "mapcache.cpp") target_sources(mapcache PRIVATE "mapcache.cpp")
set_target_properties(mapcache PROPERTIES EXCLUDE_FROM_ALL TRUE)
if(WIN32)
set_target_properties(mapcache PROPERTIES FOLDER "Tools")
endif()
# csv2yaml
message( STATUS "Creating target csv2yaml" )
add_executable(csv2yaml) add_executable(csv2yaml)
target_link_libraries(csv2yaml PRIVATE tools) target_link_libraries(csv2yaml PRIVATE minicore)
target_sources(csv2yaml PRIVATE "csv2yaml.cpp") target_sources(csv2yaml PRIVATE "csv2yaml.cpp")
set_target_properties(csv2yaml PROPERTIES EXCLUDE_FROM_ALL TRUE)
if(WIN32)
set_target_properties(csv2yaml PROPERTIES FOLDER "Tools")
target_sources(csv2yaml PRIVATE
"csv2yaml.hpp"
"yaml.hpp"
)
endif()
# yaml2sql
message( STATUS "Creating target yaml2sql" )
add_executable(yaml2sql) add_executable(yaml2sql)
target_link_libraries(yaml2sql PRIVATE tools) target_link_libraries(yaml2sql PRIVATE minicore)
target_sources(yaml2sql PRIVATE "yaml2sql.cpp") target_sources(yaml2sql PRIVATE "yaml2sql.cpp")
set_target_properties(yaml2sql PROPERTIES EXCLUDE_FROM_ALL TRUE)
if(WIN32)
set_target_properties(yaml2sql PROPERTIES FOLDER "Tools")
endif()
# yamlupgrade
message( STATUS "Creating target yamlupgrade" )
add_executable(yamlupgrade) add_executable(yamlupgrade)
target_link_libraries(yamlupgrade PRIVATE tools) target_link_libraries(yamlupgrade PRIVATE minicore)
target_sources(yamlupgrade PRIVATE "yamlupgrade.cpp") target_sources(yamlupgrade PRIVATE "yamlupgrade.cpp")
set_target_properties(yamlupgrade PROPERTIES EXCLUDE_FROM_ALL TRUE)
if(WIN32)
set_target_properties(yamlupgrade PROPERTIES FOLDER "Tools")
target_sources(yamlupgrade PRIVATE
"yamlupgrade.hpp"
"yaml.hpp"
)
endif()
set( TARGET_LIST ${TARGET_LIST} mapcache csv2yaml yaml2sql yamlupgrade CACHE INTERNAL "" ) add_custom_target(tools DEPENDS mapcache csv2yaml yaml2sql yamlupgrade map-server-generator)
if( INSTALL_COMPONENT_RUNTIME )
cpack_add_component( Runtime_mapcache DESCRIPTION "mapcache generator" DISPLAY_NAME "mapcache" GROUP Runtime )
install( TARGETS mapcache
DESTINATION "."
COMPONENT Runtime_mapcache
)
cpack_add_component( Runtime_csv2yaml DESCRIPTION "yaml converter" DISPLAY_NAME "csv2yaml" GROUP Runtime )
install( TARGETS csv2yaml
DESTINATION "."
COMPONENT Runtime_csv2yaml
)
cpack_add_component( Runtime_yaml2sql DESCRIPTION "sql converter" DISPLAY_NAME "yaml2sql" GROUP Runtime )
install( TARGETS yaml2sql
DESTINATION "."
COMPONENT Runtime_yaml2sql
)
cpack_add_component( Runtime_yamlupgrade DESCRIPTION "yaml upgrader" DISPLAY_NAME "yamlupgrade" GROUP Runtime )
install( TARGETS yamlupgrade
DESTINATION "."
COMPONENT Runtime_yamlupgrade
)
install (TARGETS )
endif( INSTALL_COMPONENT_RUNTIME )

View File

@ -1,41 +1,41 @@
# add_executable(web-server)
# setup
#
set( WEB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# target_sources(web-server PRIVATE
# web server "auth.cpp"
# "charconfig_controller.cpp"
if ( NOT ENABLE_WEB_SERVER ) "emblem_controller.cpp"
return() "merchantstore_controller.cpp"
endif ( NOT ENABLE_WEB_SERVER ) "partybooking_controller.cpp"
"sqllock.cpp"
"userconfig_controller.cpp"
"web.cpp"
"webutils.cpp"
)
if( BUILD_SERVERS AND ENABLE_WEB_SERVER ) if(WIN32)
message( STATUS "Creating target web-server" ) target_sources(web-server PRIVATE
file(GLOB WEB_HEADERS ${WEB_SOURCE_DIR}/*.hpp) "auth.hpp"
file(GLOB WEB_SOURCES ${WEB_SOURCE_DIR}/*.cpp) "charconfig_controller.hpp"
set( DEPENDENCIES common yaml-cpp httplib) "emblem_controller.hpp"
set( LIBRARIES ${GLOBAL_LIBRARIES}) "http.hpp"
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ${HTTPLIB_INCLUDE_DIRS} ${JSON_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} ) "merchantstore_controller.hpp"
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" ) "partybooking_controller.hpp"
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ${WEB_HEADERS} ${WEB_SOURCES} ) "sqllock.hpp"
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ) "userconfig_controller.hpp"
source_group( web FILES ${WEB_HEADERS} ${WEB_SOURCES} ) "webcnslif.hpp"
include_directories( ${INCLUDE_DIRS} ) "web.hpp"
"webutils.hpp"
)
#message( STATUS "web-server SOURCE_FILES=${SOURCE_FILES}") set_target_properties(web-server PROPERTIES FOLDER "Servers")
add_executable( web-server ${SOURCE_FILES} ) endif()
#message( STATUS "web-server LIBRARIES=${LIBRARIES}, DEPENDENCIES=${DEPENDENCIES} DEFINITIONS=${DEFINITIONS}")
add_dependencies( web-server ${DEPENDENCIES} ) target_link_libraries(web-server PUBLIC
target_link_libraries( web-server ${LIBRARIES} ${DEPENDENCIES} ) common
set_target_properties( web-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) httplib
if( INSTALL_COMPONENT_RUNTIME ) Threads::Threads
cpack_add_component( Runtime_webserver DESCRIPTION "web-server" DISPLAY_NAME "web-server" GROUP Runtime ) json
install( TARGETS web-server )
DESTINATION "."
COMPONENT Runtime_webserver )
endif( INSTALL_COMPONENT_RUNTIME )
set( TARGET_LIST ${TARGET_LIST} web-server CACHE INTERNAL "" )
message( STATUS "Creating target web-server - done" )
endif( BUILD_SERVERS AND ENABLE_WEB_SERVER)

38
tools/CMakeLists.txt Normal file
View File

@ -0,0 +1,38 @@
add_custom_target(scripts)
function(copy_to_source_dir FILENAMES)
foreach(FILE ${FILENAMES})
add_custom_command(
TARGET scripts POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${FILE})
endforeach()
endfunction()
if(WIN32)
set(WIN_FILES_TO_COPY
"charserv.bat"
"csv2yaml.bat"
"logserv.bat"
"mapcache.bat"
"mapserv.bat"
"runserver.bat"
"serv.bat"
"webserv.bat"
"yaml2sql.bat"
"yamlupgrade.bat"
"navigenerator.bat"
)
copy_to_source_dir("${WIN_FILES_TO_COPY}")
else()
set(LINUX_FILES_TO_COPY
"athena-start.sh"
"function.sh"
"install.sh"
"uninstall.sh"
)
copy_to_source_dir("${LINUX_FILES_TO_COPY}")
endif()

227
tools/athena-start.sh Executable file
View File

@ -0,0 +1,227 @@
#!/bin/sh
#source var/function
. ./function.sh
inst_launch_workaround
PATH=./:$PATH
LOG_DIR="./log"
print_start() {
# more << EOF
echo "rAthena is starting..."
echo " (c) 2021 rAthena Project"
echo ""
echo ""
echo "checking..."
#EOF
}
get_status(){
PIDFILE=.$1.pid
if [ -e ${PIDFILE} ]; then
PSRUN=$(pgrep -F ${PIDFILE})
fi
#return ${PSRUN} #seems to cause an issue for some os
}
#checking if already started, launch and mark in log
start_serv(){
get_status $1
if [ $2 ]; then #is logging on ?
LOGFILE="$LOG_DIR/$1.launch.log"
LOGRUN="$LOG_DIR/$1.log"
FIFO="$1_fifo"
echo "stat_serv, log is enabled"
echo "My logfile=${LOGFILE}"
if [ -z ${PSRUN} ]; then
if [ -e ./${FIFO} ]; then rm "$FIFO"; fi
mkfifo "$FIFO"; tee "$LOGRUN" < "$FIFO" & "./$1" > "$FIFO" 2>&1 & PID=$!
#"./$1" > >(tee "$LOGRUN") 2>&1 & PID=$! #bash only
echo "$PID" > .$1.pid
echo "Server '$1' started at $(date +"%m-%d-%H:%M-%S")" | tee ${LOGFILE}
else
echo "Cannot start '$1', because it is already running p${PSRUN}" | tee ${LOGFILE}
fi
else
if [ -z ${PSRUN} ]; then
./$1&
echo "$!" > .$1.pid
echo "Server '$1' started at $(date +"%m-%d-%H:%M-%S")"
else
echo "Cannot start '$1', because it is already running p${PSRUN}"
fi
fi
}
watch_serv(){
ulimit -Sc unlimited
#now checking status and looping
count=0;
while true; do
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
do
LOGFILE="$LOG_DIR/$i.launch.log"
LOGRUN="$LOG_DIR/$i.log"
FIFO=$i"_fifo"
get_status ${i}
#echo "Echo id of $i is ${PSRUN}"
if [ -z ${PSRUN} ]; then
count=$((count+1))
#echo "fifo=$FIFO"
echo "server '$i' is down"
echo "server '$i' is down" >> ${LOGFILE}
echo "restarting server at time at $(date +"%m-%d-%H:%M-%S")"
echo "restarting server at time at $(date +"%m-%d-%H:%M-%S")" >> ${LOGFILE}
if [ -e $FIFO ]; then rm $FIFO; fi
mkfifo "$FIFO"; tee "$LOGRUN" < "$FIFO" & "./$i" > "$FIFO" 2>&1 & PID=$!
echo "$PID" > .$i.pid
if [ $2 ] && [ $2 -lt $count ]; then break; fi
fi
done
sleep $1
done
}
restart(){
$0 stop
if [ $1 ]; then sleep $1; fi
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
do
FIFO="$1_fifo"
while true; do
get_status ${i}
if [ ${PSRUN} ]; then echo "'${i}' is still running p${PSRUN} waiting for the process to end"; sleep 2;
else
if [ -e ./${FIFO} ]; then rm "$FIFO"; fi
break
fi
done
done
$0 start
}
case $1 in
'start')
print_start
check_files
echo "Check complete."
echo "Looks like a good, nice rAthena!"
if [ "$2" = "--enlog" ]; then
ENLOG=1
if [ ! -d "$LOG_DIR" ]; then mkdir -p $LOG_DIR; fi
echo "Logging is enabled in $LOG_DIR"
else
echo "Logging is disabled"
fi
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
do
start_serv $i $ENLOG
done
echo "rAthena was started."
;;
'watch')
if [ ! -d "$LOG_DIR" ]; then mkdir -p $LOG_DIR; fi
if [ -z $2 ]; then Restart_count=10; else Restart_count=$2; fi
if [ -z $3 ]; then Restart_sleep=3; else Restart_sleep=$3; fi
echo "Going to watch rAthena for restart_count = $Restart_count, restart_sleep = $Restart_sleep"
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
do
start_serv $i 1
done
watch_serv $Restart_count $Restart_sleep
echo "Watching rAthena now."
;;
'stop')
for i in ${W_SRV} ${M_SRV} ${C_SRV} ${L_SRV}
do
PIDFILE=.${i}.pid
if [ -e ./${PIDFILE} ]; then
kill $(cat ${PIDFILE})
while true; do
get_status ${i}
if [ ${PSRUN} ]; then echo "'${i}' is still running p${PSRUN} waiting for the process to end"; sleep 2;
else
break
fi
done
rm ${PIDFILE}
fi
done
;;
'restart')
restart "$@"
;;
'status')
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
do
get_status ${i}
if [ ${PSRUN} ]; then echo "'${i}' is running p${PSRUN}"; else echo "'${i}' seems to be down"; fi
done
;;
'val_runonce')
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
do
valgrind --leak-check=full --show-leak-kinds=all ./$i --run-once > "log/$i.runonce.leak"
done
;;
'valchk')
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
do
valgrind --leak-check=full --show-leak-kinds=all ./$i > "log/$i.runonce.leak"
done
;;
'help')
case $2 in
'start')
echo "syntax: 'start {--enlog}'"
echo "This option will start the servers"
echo "--enlog will write all terminal output into a log/\$servname.log file"
;;
'stop')
echo "This option will shut the servers down"
;;
'restart')
echo "syntax: 'restart {<delay>}'"
echo "This option will wait for the given delay and will attempt to restart the servers afterwards"
echo "Note: Even if the delay is over it will wait until the pid is finished before attempting to restart the servers"
;;
'status')
echo "syntax: 'status'"
echo "This option will let you know whether the server are running or not"
echo "Note: This option is based on PID and requires that you have launched the servers with this script too"
echo "If this was not the case please use something like 'ps ax | grep server' to check their status"
;;
'watch')
echo "syntax: 'watch {<restart_interval> <restart_count>}'"
echo "The watch option allows you to automatically restart the servers when one of them was stopped"
echo "<restart_interval> delay in seconds before rechecking if a server is down (default 10) "
echo "<restart_count> how many times the servers should be restarted (default 3), (-1=indefinitly)"
;;
'val_runonce')
echo "syntax: 'val_runonce'"
echo "This option will run valgrind with run-once to check the servers"
;;
'valchk')
echo "syntax: 'valchk'"
echo "This option will run valgrind with the servers"
;;
*)
echo "Please specify a command you would like more info on { start | stop | restart | status | watch }"
read -p "Enter a valid command: " readEnterKey
$0 "help" $readEnterKey
;;
esac
;;
*)
echo "Usage: athena-start { start | stop | restart | status | watch | help | val_runonce | valchk }"
read -p "Enter a valid option: " readEnterKey
$0 $readEnterKey
;;
esac

View File

@ -0,0 +1,21 @@
function(copy_import_files SRC_DIR DST_DIR FILE_LIST)
file(MAKE_DIRECTORY ${DST_DIR})
file(GLOB FILES_IMPORTED
LIST_DIRECTORIES false
RELATIVE ${DST_DIR}/ ${DST_DIR}/*)
# message("files to import are: " "${FILE_LIST}")
# message("Already made fs are: " "${FILES_IMPORTED}")
list(REMOVE_ITEM FILE_LIST ${FILES_IMPORTED})
# message(" rest of files are: " ${FILE_LIST})
foreach(FILE ${FILE_LIST})
message("Importing ${FILE}")
file(COPY ${SRC_DIR}/${FILE} DESTINATION ${DST_DIR})
endforeach()
endfunction()

27
tools/function.sh Executable file
View File

@ -0,0 +1,27 @@
L_SRV=login-server
C_SRV=char-server
M_SRV=map-server
W_SRV=web-server
INST_PATH=/opt
PKG=rathena
PKG_PATH="${INST_PATH}/${PKG}"
check_files() {
for i in ${L_SRV} ${C_SRV} ${M_SRV} ${W_SRV}
do
if [ ! -f ./$i ]; then
echo "$i does not exist... exiting..."
exit 1;
fi
done
}
check_inst_right(){
if [ ! -w "${INST_PATH}" ]; then echo "You must have sudo right to use this install (write/read permission in ${INST_PATH}/ )" && exit; fi
}
inst_launch_workaround(){
if [ -d "${PKG_PATH}" ]; then
if [ "$(pwd)" != "${PKG_PATH}" ]; then cd "${PKG_PATH}"; fi
fi
}

45
tools/install.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
#source var/function
. ./function.sh
#read -p "WARNING: This script is experimental. Press Ctrl+C to cancel or Enter to continue." readEnterKey
# NOTE: This requires GNU getopt. On Mac OS X and FreeBSD, you have to install this
# separately; see below.
TEMP=$(getopt -o d: -l destdir: -- "$@")
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "${TEMP}"
eval set -- "${TEMP}"
while [ $# -gt 0 ]
do
case "$1" in
(-d | --destdir) PKG_PATH="$2"; shift;;
esac
shift
done
echo "destdir = ${PKG_PATH} "
check_inst_right
check_files
mkdir -p "${PKG_PATH}/bin/"
mkdir -p "${PKG_PATH}/etc/${PKG}/"
mkdir -p "${PKG_PATH}/usr/${PKG}/"
mkdir -p "${PKG_PATH}/var/${PKG}/log"
#we copy all file into opt/ dir and treat dir like normal unix arborescence
cp -r db/ "${PKG_PATH}/var/${PKG}/db"
if [ -d log ]; then cp -r log/* "${PKG_PATH}/var/${PKG}/log/"; fi
cp -r conf/ "${PKG_PATH}/etc/${PKG}/conf"
cp -r npc/ "${PKG_PATH}/usr/${PKG}/npc"
cp athena-start "${PKG_PATH}/"
cp *-server* "${PKG_PATH}/bin/"
ln -fs "${PKG_PATH}/var/${PKG}/db/" "${PKG_PATH}/db"
ln -fs "${PKG_PATH}/var/${PKG}/log/" "${PKG_PATH}/log"
ln -fs "${PKG_PATH}/etc/${PKG}/conf/" "${PKG_PATH}/conf"
ln -fs "${PKG_PATH}/usr/${PKG}/npc/" "${PKG_PATH}/npc"
ln -fs "${PKG_PATH}/athena-start" "/usr/bin/${PKG}"
for f in $(ls "${PKG_PATH}/bin/") ; do ln -fs "${PKG_PATH}/bin/${f}" "${PKG_PATH}/${f}"; done
echo "Installation is done. You can now control the server with '${PKG} start'"

22
tools/uninstall.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
#source var/function
. ./function.sh
echo "My pkg path is ${PKG_PATH}"
check_inst_right
read -p "WARNING: This script is experimental. Press Ctrl+C to cancel or Enter to continue." readEnterKey
case $1 in
'bin')
echo "Starting binary cleanup"
rm -rf "${PKG_PATH:?}"/bin/*
echo "Binary files have been deleted"
;;
'all')
echo "Starting uninstall"
rm -rf "${PKG_PATH:?}"
rm -rf "/usr/bin/${PKG:?}"
echo "Uninstallation has succeed"
;;
*)
echo "Usage: Please enter a target './uninstall { all | bin }'"
esac