diff --git a/README.md b/README.md new file mode 100644 index 0000000..91a3e20 --- /dev/null +++ b/README.md @@ -0,0 +1,110 @@ +

+ English | 日本語 +

+ +# TriggerOn Server + +Authoritative game server for TriggerOn — a multiplayer networked FPS. Runs on Linux, deployed via Docker. + +## Features + +- **Server-authoritative** physics, movement, and combat simulation +- **32 Hz fixed tick rate** with accumulator-based timestep +- **UDP networking** via ENet +- **Team-based combat** — RED vs BLUE with asymmetric weapon stats +- **Up to 4 players** concurrent +- **Docker-ready** with multi-stage build + +## Requirements + +**Native build:** +- Linux (Debian/Ubuntu recommended) +- g++ with C++17 support +- make + +**Docker build:** +- Docker + +## Quick Start + +```bash +make +./game_server --port=7777 +``` + +## Docker + +```bash +# Build +docker build -t triggeron-server . + +# Run +docker run -p 7777:7777/udp triggeron-server +``` + +### Docker Compose + +To pull and run the published image from Docker Hub: + +```yaml +# docker-compose.yml +services: + game-server: + image: pisto3/triggeron_game_server:latest + ports: + - "7777:7777/udp" + restart: unless-stopped +``` + +```bash +docker compose up -d +``` + +## CLI Options + +| Option | Default | Description | +|--------|---------|-------------| +| `--port=XXXX` | 7777 | UDP port to listen on | + +## Server Parameters + +### General + +| Parameter | Value | +|-----------|-------| +| Tick rate | 32 Hz (31.25 ms/tick) | +| Max players | 4 | + +## Architecture + +The server follows a **server-authoritative** model: + +- **Client → Server**: `InputCmd` (24 bytes) — player intent only (movement axes, yaw/pitch, button bitfield) +- **Server → Client**: `Snapshot` — authoritative world state (positions, velocities, health, flags) + +The server never trusts client positions. All movement, collision, and combat are simulated server-side from input commands. + +Key components: +- `ENetServerNetwork` — UDP peer management, packet routing +- `GameServer` — Per-player state (`unordered_map`), physics tick, combat resolution +- `server_collision.h` — Header-only pure-math collision library (no DirectXMath) +- `server_raycast.h` — Weapon hit detection via raycasting + +## Project Structure + +``` +main.cpp Entry point, signal handling, main loop +Network/ +├── game_server.h/cpp Core game logic, physics, combat +├── enet_server_network.h/cpp ENet UDP server implementation +├── net_common.h Protocol structs (shared with client) +├── net_packet.h Packet type enum (shared with client) +├── i_network.h Abstract network interface (shared with client) +├── map_colliders.h Map geometry (shared with client) +├── server_collision.h Collision math (server-only) +└── server_raycast.h Raycast hit detection (server-only) +ThirdParty/ +├── enet/ ENet networking library +└── toml++/ TOML config parser (header-only) +``` + diff --git a/README_JP.md b/README_JP.md new file mode 100644 index 0000000..a5e17e0 --- /dev/null +++ b/README_JP.md @@ -0,0 +1,109 @@ +

+ English | 日本語 +

+ +# TriggerOn Server + +マルチプレイヤー FPS「TriggerOn」のサーバー権威型ゲームサーバー。Linux 上で動作し、Docker によるデプロイに対応。 + +## 主な機能 + +- **サーバー権威型** — 物理演算、移動処理、当たり判定をすべてサーバー側で実行 +- **固定ティックレート 32 Hz** — アキュムレータ方式による安定した更新間隔 +- **ENet による UDP 通信** +- **チーム戦** — RED vs BLUE、チームごとに異なる武器性能 +- **最大 4 人** 同時接続 +- **Docker 対応** — マルチステージビルドによる軽量イメージ + +## 動作環境 + +**ネイティブビルド:** +- Linux(Debian / Ubuntu 推奨) +- C++17 対応の g++ +- make + +**Docker ビルド:** +- Docker + +## クイックスタート + +```bash +make +./game_server --port=7777 +``` + +## Docker + +```bash +# ビルド +docker build -t triggeron-server . + +# 実行 +docker run -p 7777:7777/udp triggeron-server +``` + +### Docker Compose + +Docker Hub から公開イメージを取得して実行する場合: + +```yaml +# docker-compose.yml +services: + game-server: + image: pisto3/triggeron_game_server:latest + ports: + - "7777:7777/udp" + restart: unless-stopped +``` + +```bash +docker compose up -d +``` + +## コマンドラインオプション + +| オプション | デフォルト値 | 説明 | +|-----------|------------|------| +| `--port=XXXX` | 7777 | 待ち受け UDP ポート | + +## サーバーパラメータ + +### 全般 + +| パラメータ | 値 | +|-----------|-----| +| ティックレート | 32 Hz(31.25 ms / tick) | +| 最大プレイヤー数 | 4 | + +## アーキテクチャ + +本サーバーは **サーバー権威型モデル** を採用しています。 + +- **クライアント → サーバー**: `InputCmd`(24 バイト) — 移動入力、視点角度、ボタン操作のみ送信 +- **サーバー → クライアント**: `Snapshot` — 位置、速度、HP、状態フラグなどのワールドステートを配信 + +クライアントからの座標は一切信頼せず、すべての移動・衝突判定・戦闘処理をサーバー側で算出します。 + +主要コンポーネント: +- `ENetServerNetwork` — UDP ピア管理、パケットルーティング +- `GameServer` — プレイヤーごとの状態管理(`unordered_map`)、物理ティック、戦闘処理 +- `server_collision.h` — ヘッダーオンリーの純粋数学ベース当たり判定ライブラリ(DirectXMath 非依存) +- `server_raycast.h` — 射撃ヒット判定用レイキャスト + +## ディレクトリ構成 + +``` +main.cpp エントリーポイント、シグナルハンドリング、メインループ +Network/ +├── game_server.h/cpp ゲームロジック、物理演算、戦闘処理 +├── enet_server_network.h/cpp ENet UDP サーバー実装 +├── net_common.h プロトコル構造体(クライアントと共有) +├── net_packet.h パケットタイプ列挙型(クライアントと共有) +├── i_network.h ネットワーク抽象インターフェース(クライアントと共有) +├── map_colliders.h マップジオメトリ(クライアントと共有) +├── server_collision.h 当たり判定(サーバー専用) +└── server_raycast.h レイキャストヒット判定(サーバー専用) +ThirdParty/ +├── enet/ ENet ネットワークライブラリ +└── toml++/ TOML パーサー(ヘッダーオンリー) +```