|
| 1 | +<p align="center"> |
| 2 | + English | <a href="./README_JP.md">日本語</a> |
| 3 | +</p> |
| 4 | + |
| 5 | +# TriggerOn Server |
| 6 | + |
| 7 | +Authoritative game server for TriggerOn — a multiplayer networked FPS. Runs on Linux, deployed via Docker. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Server-authoritative** physics, movement, and combat simulation |
| 12 | +- **32 Hz fixed tick rate** with accumulator-based timestep |
| 13 | +- **UDP networking** via ENet |
| 14 | +- **Team-based combat** — RED vs BLUE with asymmetric weapon stats |
| 15 | +- **Up to 4 players** concurrent |
| 16 | +- **Docker-ready** with multi-stage build |
| 17 | + |
| 18 | +## Requirements |
| 19 | + |
| 20 | +**Native build:** |
| 21 | +- Linux (Debian/Ubuntu recommended) |
| 22 | +- g++ with C++17 support |
| 23 | +- make |
| 24 | + |
| 25 | +**Docker build:** |
| 26 | +- Docker |
| 27 | + |
| 28 | +## Quick Start |
| 29 | + |
| 30 | +```bash |
| 31 | +make |
| 32 | +./game_server --port=7777 |
| 33 | +``` |
| 34 | + |
| 35 | +## Docker |
| 36 | + |
| 37 | +```bash |
| 38 | +# Build |
| 39 | +docker build -t triggeron-server . |
| 40 | + |
| 41 | +# Run |
| 42 | +docker run -p 7777:7777/udp triggeron-server |
| 43 | +``` |
| 44 | + |
| 45 | +### Docker Compose |
| 46 | + |
| 47 | +To pull and run the published image from Docker Hub: |
| 48 | + |
| 49 | +```yaml |
| 50 | +# docker-compose.yml |
| 51 | +services: |
| 52 | + game-server: |
| 53 | + image: pisto3/triggeron_game_server:latest |
| 54 | + ports: |
| 55 | + - "7777:7777/udp" |
| 56 | + restart: unless-stopped |
| 57 | +``` |
| 58 | +
|
| 59 | +```bash |
| 60 | +docker compose up -d |
| 61 | +``` |
| 62 | + |
| 63 | +## CLI Options |
| 64 | + |
| 65 | +| Option | Default | Description | |
| 66 | +|--------|---------|-------------| |
| 67 | +| `--port=XXXX` | 7777 | UDP port to listen on | |
| 68 | + |
| 69 | +## Server Parameters |
| 70 | + |
| 71 | +### General |
| 72 | + |
| 73 | +| Parameter | Value | |
| 74 | +|-----------|-------| |
| 75 | +| Tick rate | 32 Hz (31.25 ms/tick) | |
| 76 | +| Max players | 4 | |
| 77 | + |
| 78 | +## Architecture |
| 79 | + |
| 80 | +The server follows a **server-authoritative** model: |
| 81 | + |
| 82 | +- **Client → Server**: `InputCmd` (24 bytes) — player intent only (movement axes, yaw/pitch, button bitfield) |
| 83 | +- **Server → Client**: `Snapshot` — authoritative world state (positions, velocities, health, flags) |
| 84 | + |
| 85 | +The server never trusts client positions. All movement, collision, and combat are simulated server-side from input commands. |
| 86 | + |
| 87 | +Key components: |
| 88 | +- `ENetServerNetwork` — UDP peer management, packet routing |
| 89 | +- `GameServer` — Per-player state (`unordered_map<uint8_t, PlayerData>`), physics tick, combat resolution |
| 90 | +- `server_collision.h` — Header-only pure-math collision library (no DirectXMath) |
| 91 | +- `server_raycast.h` — Weapon hit detection via raycasting |
| 92 | + |
| 93 | +## Project Structure |
| 94 | + |
| 95 | +``` |
| 96 | +main.cpp Entry point, signal handling, main loop |
| 97 | +Network/ |
| 98 | +├── game_server.h/cpp Core game logic, physics, combat |
| 99 | +├── enet_server_network.h/cpp ENet UDP server implementation |
| 100 | +├── net_common.h Protocol structs (shared with client) |
| 101 | +├── net_packet.h Packet type enum (shared with client) |
| 102 | +├── i_network.h Abstract network interface (shared with client) |
| 103 | +├── map_colliders.h Map geometry (shared with client) |
| 104 | +├── server_collision.h Collision math (server-only) |
| 105 | +└── server_raycast.h Raycast hit detection (server-only) |
| 106 | +ThirdParty/ |
| 107 | +├── enet/ ENet networking library |
| 108 | +└── toml++/ TOML config parser (header-only) |
| 109 | +``` |
| 110 | + |
0 commit comments