Compare commits

...

71 Commits

Author SHA1 Message Date
Exynox d4fa88b7e2 Removed Boost dependency, changed MySQL library to MariaDB 2024-10-12 08:59:16 +03:00
Exynox 7cc9550efc Fixed db crash when MySQL connection wasn't possible 2024-09-22 09:55:32 +03:00
Exynox c6177d9c73 Added Laravel-style URL signing for mall authentication 2024-09-05 21:53:32 +03:00
Exynox 903b3bb3a5 Fixed old ENV syntax 2024-09-01 20:45:53 +03:00
Exynox b3a83c5238 Fixed "FromAsCasing: 'as' and 'FROM' keywords' casing do not match" 2024-08-31 11:39:50 +03:00
Exynox fafa828b27 Fixed incorrect resource de-allocation, closes #29 2024-08-24 22:02:33 +03:00
Exynox 7e8009b45d Removed "INSERT DELAYED" queries in order for database future proofing/InnoDB databases 2024-08-24 16:48:39 +03:00
Exynox 170be95dc5 Configuration files are automatically generated based on env variables in the Docker image 2024-06-02 21:45:51 +03:00
Exynox 6d65fae7e4 Argon2ID improvements 2024-06-01 14:34:27 +03:00
Exynox 8ed1e7879e Merge pull request 'Use Argon2ID as the password hashing algorithm' (#26) from WildEgo/server:master into nightly
Reviewed-on: #26
2024-06-01 14:32:21 +03:00
WildEgo 65a81ec4a1 change: Ignore build files, replace mysql password with Argon2.
add: Missing .gitignore.
2024-05-31 10:49:21 +01:00
WildEgo ae708d9315 Merge pull request 'nightly' (#2) from metin2/server:nightly into master
Reviewed-on: WildEgo/server#2
2024-05-30 22:43:22 +03:00
Exynox 48ee253534 Restructured gamefiles, locale data loading refactoring, docker build fixes 2024-05-25 20:00:26 +03:00
Exynox 27108d629a Merge pull request 'Merge changes from master' (#25) from master into nightly
Reviewed-on: #25
2024-05-25 17:55:22 +03:00
WildEgo 21e028f186 Merge pull request 'nightly' (#1) from metin2/server:nightly into master
Reviewed-on: WildEgo/server#1
2024-04-23 13:17:19 +03:00
Exynox 175816c81d Merge pull request 'Default all localized behavior to European logic' (#22) from Tr0n/server:localization/default-gf-eu into nightly
Reviewed-on: #22
2024-04-09 21:47:22 +03:00
Tr0n b15eb7f3fe
fix: wrong delay used for item drop despawn. 2024-04-09 20:33:14 +02:00
Tr0n 3a8d9e38e8
remove duplicate variable definition 2024-04-09 18:13:38 +02:00
Tr0n 4074c3b96a
fix out of order access of variables 2024-04-09 18:13:14 +02:00
Tr0n 854fef68e8
revert removal of locale initialization per country. default to English 2024-04-09 18:12:58 +02:00
Tr0n cf66bb3310
revert name change removal 2024-04-09 17:25:39 +02:00
Tr0n 254f6f6664
remove division by 1 for party exp bonus 2024-04-09 17:24:09 +02:00
Tr0n 0072bc5e14
revert removal of spam db 2024-04-09 17:21:46 +02:00
Tr0n 62f3635b86
revert removed warning for disabled version checks 2024-04-09 17:10:53 +02:00
Tr0n 2c37b2009d
revert local testing of string localization 2024-04-09 17:10:38 +02:00
Tr0n e0701ed5bd
restore accidentally removed login logic 2024-04-09 17:04:10 +02:00
Tr0n 21381a4e3a
restore accidentally removed fish logic 2024-04-09 17:03:42 +02:00
Tr0n ba44269071
remove redundant condition for skill book exp consumption 2024-04-09 16:58:02 +02:00
Tr0n f5ccb17736
remove redundant pointer to lucky pouch loot table 2024-04-09 16:56:43 +02:00
Tr0n bb52a57ffc
remove unreachable branch 2024-04-09 16:53:47 +02:00
Tr0n 8360d6939f
set damage penalty on foreign empire maps to constant 9% 2024-04-09 16:53:37 +02:00
Tr0n 1e362d8507
remove isLimitedItem 2024-04-09 16:51:51 +02:00
Tr0n 0a907f41d2
remove unnecessary leftover closures 2024-04-07 22:11:12 +02:00
Tr0n dbcabd7fa9
reduce LC_InitLocalization logic, purge LC_Is* definitions 2024-04-07 18:10:16 +02:00
Exynox fcc2a9e4a0 Logout error messages are now being sent, closes #18 2024-04-07 18:36:10 +03:00
Tr0n 12b6abf373
remove IS_BOTARYABLE_ZONE 2024-04-07 14:19:29 +02:00
Tr0n e1daa48366
remove all localization 2024-04-07 12:54:57 +02:00
Exynox 83707434ee Fix small UTF-8 conversion mistakes, converted locale_strings, added KR locale_string file 2024-04-07 10:14:51 +03:00
Exynox 042414a499 Merge pull request 'encoding' (#20) from Tr0n/server:encoding into nightly
Reviewed-on: #20
2024-04-07 08:59:36 +03:00
Tr0n 68c7c4bc4f
fix config comment 2024-04-06 18:04:29 +02:00
Tr0n eafbee616f
english locale as base 2024-04-06 17:58:03 +02:00
Tr0n 026cb861a8
fix missing quote mark 2024-04-06 17:57:30 +02:00
Tr0n 1ba21fb1f9
translate remaining SPDLOG calls 2024-04-06 17:57:14 +02:00
Tr0n 8fede9a1df
manual translation of non-localized strings 2024-04-06 17:28:22 +02:00
Tr0n dfb3d08998
manual translation of non-localized strings 2024-04-06 12:50:34 +02:00
Tr0n 326c134f9e
manual translation of non-localized strings 2024-04-06 11:13:11 +02:00
Tr0n 9b7536ee9a
Initial pass of converting string literals to english 2024-04-06 10:31:54 +02:00
Tr0n 9056f6c6c6
convert some more comments to utf8 2024-04-06 10:24:46 +02:00
Tr0n 8685b02fdc
libthecore encoding conversion 2024-04-06 10:20:42 +02:00
Tr0n 341bef9aba
Merge branch 'nightly' into comment-encoding 2024-04-06 01:09:03 +02:00
sdgmt2 8a1acefeeb
move encoding tool to separate repo 2024-04-06 00:42:30 +02:00
sdgmt2 eacc808366
convert comments to utf-8 2024-04-05 23:34:45 +02:00
sdgmt2 4a1460f36e
convert korean characters in string literals to string encoded bytes 2024-04-05 22:24:46 +02:00
sdgmt2 aae9b169df
encoding fix script 2024-04-05 21:57:49 +02:00
sdgmt2 dd74eafc24
fix db cpp encoding 2024-04-01 14:20:00 +02:00
sdgmt2 d471d99a24
fix libthecore header encoding 2024-04-01 12:48:58 +02:00
sdgmt2 350fb0d424
fix libsql header encoding 2024-04-01 12:48:16 +02:00
sdgmt2 869720f9e6
fix libgame header encoding 2024-04-01 12:46:52 +02:00
sdgmt2 4fc612552a
fix common header encoding 2024-04-01 12:45:35 +02:00
sdgmt2 248205ae01
fix db header encoding 2024-04-01 12:43:31 +02:00
sdgmt2 82317e6c4d
fix game header encoding 2024-04-01 12:39:34 +02:00
Exynox 847ab2ef89 Fixed erroneous database table parsing due to incorrect SMS phone number removal 2024-03-31 15:30:43 +03:00
Exynox ebc479b7df Fixed "Invalid Socket Count 3, set to maximum" error 2024-03-31 09:09:35 +03:00
Exynox 1ee687f269 Removed unused PROTECT_CHILD_FOR_NEWCIBN 2024-03-31 08:54:34 +03:00
Exynox d85ef28eac Removed messenger SMS 2024-03-30 21:14:50 +02:00
Exynox 01cc27a7df Removed Billing/VCard 2024-03-30 19:58:21 +02:00
Exynox 72b495c03c Removed PCBang/iCafe code 2024-03-30 18:55:44 +02:00
Exynox 0c86f802ca Removed unused highscore Lua & DB functions 2024-03-30 18:06:36 +02:00
Exynox 05a1406c7c Removed database strings and automatic greeting 2024-03-30 17:50:04 +02:00
Exynox 00c5634c09 Removed country blocking (and exceptions) 2024-03-30 17:09:03 +02:00
Exynox 42079d56b7 Removed hotbackup 2024-03-30 16:57:24 +02:00
1303 changed files with 28656 additions and 44790 deletions

View File

@ -2,6 +2,10 @@
cmake-build-debug/
cmake-build-release/
# IDE folders
.vscode/
.idea/
# Dockerfile (in order to allow changes without rebuilding)
Dockerfile
@ -10,9 +14,12 @@ Dockerfile
.gitkeep
# Compiled quests
gamefiles/locale/english/quest/object/
gamefiles/locale/english/quest/pre_qc/
gamefiles/locale/english/quest/qc
gamefiles/data/quest/object/
gamefiles/data/quest/pre_qc/
gamefiles/data/quest/qc
# Test folder
test/
# Built files
build/

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="EUC-KR" />
</component>
</project>

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"cmake.configureOnOpen": true
}

View File

@ -1,6 +1,11 @@
FROM ubuntu:22.04 as build
FROM ubuntu:22.04 AS build
WORKDIR /app
# Set up the CMake repository
RUN apt-get update && apt-get install -y ca-certificates gpg wget
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
RUN echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null
# Update the system and install various dependencies
RUN apt-get update && \
apt-get install -y git cmake ninja-build build-essential tar curl zip unzip pkg-config autoconf python3 \
@ -12,7 +17,7 @@ ENV VCPKG_FORCE_SYSTEM_BINARIES=1
# Install vcpkg and the required libraries
RUN git clone https://github.com/Microsoft/vcpkg.git
RUN bash ./vcpkg/bootstrap-vcpkg.sh
RUN ./vcpkg/vcpkg install boost-system cryptopp effolkronium-random libmysql libevent lzo fmt spdlog
RUN ./vcpkg/vcpkg install cryptopp effolkronium-random libmariadb libevent lzo fmt spdlog argon2
COPY . .
@ -21,10 +26,10 @@ RUN mkdir build/
RUN cd build && cmake -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake ..
RUN cd build && make -j $(nproc)
FROM ubuntu:22.04 as app
FROM ubuntu:22.04 AS app
WORKDIR /app
RUN apt-get update && apt-get install -y python2 libdevil-dev libbsd-dev && apt-get clean
RUN apt-get update && apt-get install -y gettext python2 libdevil-dev libbsd-dev && apt-get clean
# Copy the binaries from the build stage
COPY --from=build /app/build/src/db/db /bin/db
@ -34,8 +39,11 @@ COPY --from=build /app/build/src/quest/qc /bin/qc
# Copy the game files
COPY ./gamefiles/ .
# Copy the auxiliary files
COPY ./docker/ .
# Compile the quests
RUN cd /app/locale/english/quest && python2 make.py
RUN cd /app/data/quest && python2 make.py
# Symlink the configuration files
RUN ln -s "./conf/CMD" "CMD"
@ -43,3 +51,9 @@ RUN ln -s ./conf/item_names_en.txt item_names.txt
RUN ln -s ./conf/item_proto.txt item_proto.txt
RUN ln -s ./conf/mob_names_en.txt mob_names.txt
RUN ln -s ./conf/mob_proto.txt mob_proto.txt
# Set up default environment variables
ENV PUBLIC_BIND_IP=0.0.0.0
ENV INTERNAL_BIND_IP=0.0.0.0
ENTRYPOINT ["/usr/bin/bash", "docker-entrypoint.sh"]

View File

@ -7,14 +7,34 @@ For-profit usage of this material is certainly illegal without the proper
licensing agreements and is hereby discouraged (not legal advice). Even so, the
nature of this project is HIGHLY EXPERIMENTAL - bugs are to be expected for now.
## 1. Building and usage
### A. Use Docker to instantly bring up a server (recommended)
## 1. Usage
We aim to provide Docker images which _just work_ for your convenience.
A Docker Compose project is maintained in the [Deployment project](https://git.old-metin2.com/metin2/deploy).
Please head over there for further instructions.
### B. Build the binaries yourself (for advanced users)
## 2. Building
### A. Building Docker images
#### Building a Docker image from the repository
In order to build a local Docker image on your local architecture, just build the
provided Dockerfile in this project:
```shell
docker build -t metin2/server:test --provenance=false .
```
#### Publishing a multiplatform Docker image manually
This command is reserved only for repository maintainers in order to publish
new Docker images for public use with the Deployment project.
**WARNING:** Using WSL for building might lead to QEMU segmentation fault issues;
this can be worked around by using `binfmt` and `qemu-user-static` as described
[here](https://github.com/docker/buildx/issues/1170#issuecomment-1159350550).
```shell
docker build --push -t git.old-metin2.com/metin2/server:<IMAGE-TAG-HERE> --platform linux/amd64,linux/arm64 --provenance=false .
```
### B. Building the binaries yourself (for advanced users)
_Sadly, we're unable to provide hand-holding services. You should have some C++ development experience
going forward with this route._
@ -23,6 +43,7 @@ variety. This project is also compatible with WSL, even though WSL can be buggy
at times. FreeBSD/Windows compatibility is untested and unsupported for the
time being - there are other projects out there if that's what you want.
#### Setting up the requirements
On your Linux box, install the dependencies for `vcpkg` and the other libraries
we're going to install.
```shell
@ -35,22 +56,25 @@ Also install DevIL (1.7.8) and the BSD compatibility library:
apt-get install -y libdevil-dev libbsd-dev
```
Install `vcpkg` according to the [lastest instructions](https://vcpkg.io/en/getting-started.html).
Install `vcpkg` according to the [latest instructions](https://vcpkg.io/en/getting-started.html).
Build and install the required libraries:
```shell
vcpkg install boost-system cryptopp effolkronium-random libmysql libevent lzo fmt spdlog
vcpkg install cryptopp effolkronium-random libmariadb libevent lzo fmt spdlog argon2
```
Then, it's time to build your binaries. Your commands should look along the lines of:
#### Building the binaries
Instead of building the binaries directly from the CLI, we recommend using an IDE, since
you're probably doing some kind of development anyway. See the "Development" section for more information on that.
If you decide do build from the command line, make sure to find the right path for `vcpkg.cmake` and run the following:
```shell
mkdir build/
cd build && cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake ..
make -j $(nproc)
```
If everything goes right, you should now have compiled binaries you should just be able to use
as a drop-in replacement for your BSD binaries in your favourite serverfiles.
If everything goes right, you should now have compiled binaries in the `build/` directory.
## 2. Development
The preferred IDE in order to develop and debug the server is [CLion](https://www.jetbrains.com/clion/),
@ -79,8 +103,9 @@ goodies you wish. Also, a lot of time.
- Removed unused functionalities (time bombs, activation servers, other Korean stuff)
- Switched to the [effolkronium/random PRNG](https://github.com/effolkronium/random) instead of the standard C functions.
- Refactored macros to modern C++ functions.
- Network settings are manually configurable through the `PUBLIC_IP`, `PUBLIC_BIND_IP`, `INTERNAL_IP`, `INTERNAL_BIND_IP` settings in the `CONFIG` file. (Might need further work)
- Network settings are manually configurable through the `PUBLIC_IP`, `PUBLIC_BIND_IP`, `INTERNAL_IP`, `INTERNAL_BIND_IP` settings in the `game.conf` file. (Might need further work)
- Refactored logging to use [spdlog](https://github.com/gabime/spdlog) for more consistent function calls.
- Refactored login code to use Argon2ID.
## 4. Bugfixes
**WARNING: This project is based on the "kraizy" leak. That was over 10 years ago.
@ -101,8 +126,7 @@ This is a very serious security risk and one of the reasons this project is stil
- Fixed buffer overruns and integer overflows in SQL queries.
## 5. Further plans
- Migrate `conf.txt` and `CONFIG` to a modern dotenv-like format, which would enable pretty nice Docker images.
- Add a health check to the Docker image.
- Migrate `db.conf` and `game.conf` to a modern dotenv-like format, which would enable pretty nice Docker images.
- Use the [fmt](https://fmt.dev/latest/index.html) library for safe and modern string formatting.
- Handle kernel signals (SIGTERM, SIGHUP etc.) for gracefully shutting down the game server.
- Improve memory safety.

18
docker/conf/db.conf.tmpl Normal file
View File

@ -0,0 +1,18 @@
WELCOME_MSG = "DB Server has been started"
SQL_ACCOUNT = "${MYSQL_HOST} ${MYSQL_DB_ACCOUNT} ${MYSQL_USER} ${MYSQL_PASSWORD} ${MYSQL_PORT}"
SQL_COMMON = "${MYSQL_HOST} ${MYSQL_DB_COMMON} ${MYSQL_USER} ${MYSQL_PASSWORD} ${MYSQL_PORT}"
SQL_PLAYER = "${MYSQL_HOST} ${MYSQL_DB_PLAYER} ${MYSQL_USER} ${MYSQL_PASSWORD} ${MYSQL_PORT}"
TABLE_POSTFIX = ""
BIND_PORT = ${DB_PORT}
DB_SLEEP_MSEC = 10
CLIENT_HEART_FPS = 10
HASH_PLAYER_LIFE_SEC = 600
BACKUP_LIMIT_SEC = 3600
PLAYER_ID_START = 100
PLAYER_DELETE_LEVEL_LIMIT = 70
ITEM_ID_RANGE = 10000001 20000000
TEST_SERVER = ${TEST_SERVER}

View File

@ -0,0 +1,42 @@
HOSTNAME: ${GAME_HOSTNAME}
CHANNEL: ${GAME_CHANNEL}
PUBLIC_IP: ${PUBLIC_IP}
PUBLIC_BIND_IP: ${PUBLIC_BIND_IP}
INTERNAL_IP: ${INTERNAL_IP}
INTERNAL_BIND_IP: ${INTERNAL_BIND_IP}
PORT: ${GAME_PORT}
P2P_PORT: ${GAME_P2P_PORT}
DB_ADDR: ${DB_ADDR}
DB_PORT: ${DB_PORT}
COMMON_SQL: ${MYSQL_HOST} ${MYSQL_USER} ${MYSQL_PASSWORD} ${MYSQL_DB_COMMON} ${MYSQL_PORT}
LOG_SQL: ${MYSQL_HOST} ${MYSQL_USER} ${MYSQL_PASSWORD} ${MYSQL_DB_LOG} ${MYSQL_PORT}
PLAYER_SQL: ${MYSQL_HOST} ${MYSQL_USER} ${MYSQL_PASSWORD} ${MYSQL_DB_PLAYER} ${MYSQL_PORT}
TABLE_POSTFIX:
AUTH_SERVER: ${GAME_AUTH_SERVER}
MARK_SERVER: ${GAME_MARK_SERVER}
MAP_ALLOW: ${GAME_MAP_ALLOW}
MAX_LEVEL: ${GAME_MAX_LEVEL}
PK_PROTECT_LEVEL: 15
SPAM_BLOCK_MAX_LEVEL: 90
GOLD_DROP_LIMIT_TIME: 10
WEB_APP_URL: ${WEB_APP_URL}
WEB_APP_KEY: ${WEB_APP_KEY}
CHECK_MULTIHACK: 0
SPEEDHACK_LIMIT_COUNT: 300
SPEEDHACK_LIMIT_BONUS: 80
ADMINPAGE_IP: 127.0.0.1
ADMINPAGE_PASSWORD: metin2adminpass
PASSES_PER_SEC: 25
SAVE_EVENT_SECOND_CYCLE: 180
PING_EVENT_SECOND_CYCLE: 180
VIEW_RANGE: 8000
TEST_SERVER: ${TEST_SERVER}

View File

@ -0,0 +1,9 @@
#!/bin/sh
# docker-entrypoint.sh
# Generate configuration files based on environment variables
envsubst <"/app/conf/db.conf.tmpl" >"/app/db.conf"
envsubst <"/app/conf/game.conf.tmpl" >"/app/game.conf"
# Run the standard container command.
exec "$@"

View File

@ -41,8 +41,6 @@ tstr IMPLEMENTOR
tint IMPLEMENTOR
tcon IMPLEMENTOR
mob_ld IMPLEMENTOR
pcbang_check IMPLEMENTOR
pcbang_update IMPLEMENTOR
setqf IMPLEMENTOR
delqf IMPLEMENTOR
effect IMPLEMENTOR

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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