here requirements and other stuff for ROO 20GB:
Later I will create a detailed video tutorial from 0 to 100.
here small update:
# RO Game — Setup, Build & Run Guide
## Project Overview
**Type:** MMORPG — Unity game client + C++ multi-process server backend
**Client:** C# + Unity 2018.4.32f1 (LTS), Lua scripting via LuaJIT 2.1
**Server:** C++11, Linux, CMake, multi-process microservice architecture
**Network Protocol:** Protocol Buffers 3.3.0
---
## Repository Structure
```
RO/
├── clientcode/ → C# source code (Visual Studio solution)
├── clientproj/ → Unity project (open this in Unity Hub)
├── config/ → Game data tables (Excel/JSON), Lua scripts, export tools
├── rogamelibs/ → C++ core game library (battle, AI, skills, scene)
├── roserver/ → C++ multi-process server backend
├── rosdk/ → Third-party SDK integrations (MSDK, GCloud, etc.)
├── roab/ → Compiled Unity Asset Bundles (per platform)
├── build/ → Platform build output (Android Gradle project, iOS zip)
├── sql/ → MySQL database initialization scripts
├── rodoc/ → All project documentation
└── sys_env1.json → Local path configuration for cross-repo tools
```
> Keep all repos as **flat siblings** in one base directory. Build tools rely on relative paths between them.
---
## Requirements
### Server (Linux)
| Tool | Version | Notes |
|------|---------|-------|
| OS | Linux x86_64 | CentOS / Ubuntu |
| CMake | 3.0.2+ | Required |
| GCC / G++ | 4.8.5+ | Default; 9.2.0 recommended |
| Make | Any | |
| SWIG | 3.0.12 | Wrapper/interface generation |
| MySQL | 5.6.5+ | JSON support required; UTF-8; max_allowed_packet ≥ 16MB |
| Redis | Any | Caching and session management |
| screen | Any | Terminal multiplexing for server processes |
| Python | 2.7 or 3.x | For `conf_create.py` and build scripts |
| ccache | Optional | `/usr/local/bin/ccache` — speeds up recompilation |
| curl | Any | Runtime HTTP client |
**LD_LIBRARY_PATH must include the path to `libnetwork.so` at runtime — servers will not start without it.**
```bash
yum install cmake gcc-c++ make swig mysql-devel mysql-community-server.x86_64 screen
```
### Client (Windows / macOS)
| Tool | Version | Notes |
|------|---------|-------|
| Unity | **2018.4.32f1 (LTS)** | Exact version required |
| Visual Studio | 2017 or 2019 | .NET desktop development workload |
| .NET Framework SDK | 4.6 | Included with Visual Studio |
| CMake | 3.0.2+ | For building rogamelibs on Windows |
| Android Studio | Latest stable | For Android builds |
| Android SDK | API 28 | Via Android Studio SDK Manager |
| Android Build Tools | 28.0.3 | Via Android Studio SDK Manager |
| Android NDK | r16b+ | Via Android Studio SDK Manager |
| JDK | 1.8+ | For Android Gradle builds |
| Xcode | 11+ | macOS only, for iOS builds |
**Unity Hub modules to install with Unity 2018.4.32f1:**
- Android Build Support (includes Android SDK & NDK tools)
- iOS Build Support
- Windows Build Support (default)
---
## Step 1 — Configure `sys_env1.json`
This file tells all build tools and Unity Editor scripts where sibling repos are on your machine.
Edit **both** copies to match your local paths:
- `sys_env1.json` (repo root)
- `clientproj/sys_env.json` (Unity project)
```json
{
"MoonGameLibPath" : "C:/Projects/RO/rogamelibs",
"MoonServerPath" : "C:/Projects/RO/roserver",
"MoonClientProjPath" : "C:/Projects/RO/clientproj",
"MoonResPath" : "C:/Projects/RO/clientproj/Assets/artres",
"MoonClientCodePath" : "C:/Projects/RO/clientcode",
"MoonClientConfigPath" : "C:/Projects/RO/config",
"MoonABPath" : "C:/Projects/RO/roab",
"MoonClientPackProjPath": "C:/Projects/RO/clientpackproj",
"MoonSdkLibPath" : "C:/Projects/RO/rosdk"
}
```
> Replace all paths with your actual base directory. This file should be in `.gitignore` — each developer sets their own.
---
## Server Setup
### Step 2 — Clone Repositories
```bash
git clone
To view the content, you need to sign in or register
git clone
To view the content, you need to sign in or register
```
### Step 3 — Initialize Build Directory
> **`config/` IS the resource repo** (`rores` in the original dev setup). Pass it directly to `111.sh`.
```bash
cd roserver
./111.sh ../config
```
This creates `Build/Debug/bin`, copies startup scripts, and symlinks the resources the server needs at runtime:
| Symlink created | Points to |
|----------------|-----------|
| `lua_script` | `config/LuaGame/`

|
| `lua_server` | `config/LuaServer/`

|
| `rogameslib_table` | `config/Table/ServerBytes/`

|
| `Tlog` | `config/TLog/`

|
| `SkillData` | `config/Assets/Resources/SkillData/`

deleted from git |
| `AI` | `config/Assets/Resources/AI/`

deleted from git |
| `scene_spawner` | `config/Assets/Resources/SceneDatas/`

deleted from git |
| `nav_datas` | `config/Assets/Resources/NavDatas/`

deleted from git |
**For the deleted dirs** — they were removed from `config`'s git history. You have two options:
Option A — Restore from git history (if the commit that deleted them exists):
```bash
cd config
git log --all --diff-filter=D --summary | grep "delete mode" | grep SkillData | head -3
# find the commit hash before deletion, then:
git checkout <commit-hash>^ -- Assets/Resources/SkillData
git checkout <commit-hash>^ -- Assets/Resources/AI
# etc.
```
Option B — Generate from Unity (proper approach): export from the Unity Editor using the tools in `clientproj/Assets/Editor/` and `config/Table/Tools/`. These dirs are runtime binary data built from source assets.
The missing dirs are only needed to **run the gameserver**. Compilation works without them — comment them out in `111.sh` if they cause errors:
```bash
# In 111.sh, comment out the missing symlinks:
#ln -s $RES_PATH/Assets/Resources/SkillData .
#ln -s $RES_PATH/Assets/Resources/SceneDatas scene_spawner
# etc.
```
**Then run cmake:**
```bash
cd roserver/Build/Debug
cmake -DCMAKE_BUILD_TYPE=Debug -DGCC=9.2.0 ../..
```
### Step 4 — Configure MySQL
```sql
SET GLOBAL max_allowed_packet = 16777216;
SET GLOBAL interactive_timeout = 2600000;
SET GLOBAL wait_timeout = 2600000;
SET sql_mode = '';
```
Character set must be **UTF-8**. Start MySQL first:
```bash
systemctl start mysqld
grep "temporary password" /var/log/mysqld.log
mysqladmin -u root -p oldpasswd password newpasswd
```
### Step 5 — Initialize Databases
Run SQL scripts in this order:
```bash
# Login database
mysql -u root -p < roserver/exe/loginconf/dbinit.sql
# World / player databases
mysql -u root -p < roserver/exe/dbconf/dbinit.sql
mysql -u root -p < roserver/exe/dbconf/db_R

nline_init.sql
# Full schema from sql/ directory
mysql -u root -p < sql/login.sql
mysql -u root -p < sql/player.sql
mysql -u root -p < sql/player_template.sql
mysql -u root -p < sql/world.sql
mysql -u root -p < sql/globalworld.sql
mysql -u root -p < sql/db_R

nline.sql
```
**Required databases:** `login`, `player`, `player_template`, `world`, `globalworld`, `db_R

nline`
### Step 6 — Register Server in `gateinfo`
```sql
INSERT INTO login.gateinfo VALUES (
11, 'channel1', 1, 1, 'ServerName', 'ZoneName',
'10.0.128.138:11110', '', 0, 0,
'2017-05-04 08:00:00', '2017-05-04 08:00:00', 0
);
```
The port in this table **must match** the port in `gateserver.xml`.
### Step 7 — Compile Servers
```bash
cd roserver/Build/Debug
./build_all.sh # Debug build (all servers)
# OR
./build_all_release.sh # Release build
```
Servers compiled (in order): gameserver, gateserver, controlserver, dbserver, masterserver, loginserver, tradeserver, audioserver, battleserver, idipserver, payserver, rankserver, authserver, fmserver.
If a specific server fails due to a missing file, **comment out the relevant `#include`** in the source as noted in `服务器配置.md`.
To build only `gameserver`:
```bash
cmake -DBUILD_GAME=ON -DCMAKE_BUILD_TYPE=Debug ../..
make -j$(nproc)
```
### Step 8 — Generate Config Files
```bash
cd roserver/Build/Debug/bin
python conf_create.py
# Enter a numeric server_id when prompted
```
Generated config files in `conf/`:
| File | Server |
|------|--------|
| `gs_conf1.xml`, `gs_conf2.xml` | gameserver instances |
| `gate_conf.xml` | gateserver |
| `db_conf.xml` | dbserver |
| `ms_conf.xml` | masterserver |
| `ctrl_conf.xml` | controlserver |
| `audio_conf.xml` | audioserver |
| `tr_conf.xml` | tradeserver |
| `bt_conf.xml` | battleserver |
| `pay_conf.xml` | payserver |
| `rank_conf.xml` | rankserver |
| `login_conf.xml` | loginserver |
### Step 9 — Edit Config Files
In each `conf/*.xml` set:
- MySQL username / password (default template uses `111111` — **change this**)
- Database names: `rologin`, `roworld`, `roplayer0`–`roplayer4`, `roonline`
- Host/IP addresses and ports
Also edit `conf.template/loginserver.xml` with the loginserver connection info.
### Step 10 — Set LD_LIBRARY_PATH
```bash
export LD_LIBRARY_PATH=/path/to/libnetwork.so/dir:$LD_LIBRARY_PATH
```
Add this to your shell profile so it persists across sessions. Without it, servers will not start.
---
## Running the Server
### Start All Servers
```bash
cd roserver/Build/Debug/bin
./start myserver
```
Uses `screen` to launch each server in a named session. Startup order (handled automatically):
1. dbserver
2. gameserver (instances 1 & 2)
3. gateserver
4. masterserver
5. controlserver
6. audioserver
7. tradeserver
8. battleserver
9. payserver
10. rankserver
Then start loginserver separately:
```bash
./loginserver conf.template/loginserver.xml
```
### Monitor and Control
```bash
./status myserver # check process status
screen -ls # list all screen sessions
screen -r myserver_db # attach to dbserver
screen -r myserver_gsa # attach to gameserver instance 1
screen -r myserver_gsb # attach to gameserver instance 2
screen -r myserver_gt # attach to gateserver
screen -r myserver_ms # attach to masterserver
screen -r myserver_ns # attach to controlserver
# Ctrl+A then D to detach
./stop myserver # stop all servers
```
### Default Ports
| Server | Port |
|--------|------|
| gateserver (client) | 10110 |
| loginserver (client) | 25001 |
| gameserver (master link) | 10502 |
| dbserver (game link) | 10011 |
| masterserver (gate link) | 10501 |
| controlserver | 10602–10604 |
| battleserver (master) | 10505 |
| audioserver (master) | 10504 |
| tradeserver (master) | 10503 |
| payserver (master) | 10506 |
| rankserver (master) | 10507 |
---
## Local Development Server (Docker / Windows)
For local testing without a Linux server, use the Docker scripts in `build/Android/Tools/LocalServer/`:
```bat
REM 1. Copy and set up local server (choose a branch)
1.拷贝本地服.bat
REM 2. Start Docker container
2.启动docker.bat
REM 3. Install server inside Docker
安装服务器.bat
REM 4. Start all game servers
开启服务器-本地自编译.bat
```
Control commands: `停止服务器.bat` (stop), `3.关闭docker.bat` (stop Docker), `重新编译服务器.bat` (full recompile).
---
## Client Setup (Unity)
### Step 1 — Install Unity 2018.4.32f1 (LTS)
Download via Unity Hub. Use the **exact** version `2018.4.32f1`.
### Step 2 — Open the Unity Project
Open `clientproj/` as a Unity project from Unity Hub.
### Step 3 — Build the C# DLLs
Open `clientcode/CSProject/clientcode.sln` in Visual Studio.
Projects in the solution:
| Project | Purpose |
|---------|---------|
| `MoonClient` | Core game logic, UI, networking |
| `MoonCommonLib` | Shared utilities |
| `MoonSerializable` | Data serialization |
| `SDKLib` | Platform SDK abstraction |
Build configurations:
| Config | Use for |
|--------|---------|
| `UNITY_EDITOR` | Unity Editor development |
| `UNITY_PC` | Windows standalone build |
| `UNITY_ANDROID_DEBUG` / `UNITY_ANDROID_RELEASE` | Android builds |
| `UNITY_IOS_DEBUG` / `UNITY_IOS_RELEASE` | iOS builds |
Build `UNITY_EDITOR` config → copy DLLs to `clientproj/Assets/Plugins/`.
Or use the automated script for Windows:
```bat
clientproj/Tools/BuildForPC/build_pc_dll.bat
```
### Step 4 — Play in the Editor
1. Ensure servers are running (or use Docker local server)
2. Confirm `login.gateinfo` has the correct server IP/port
3. Press **Play** in Unity
---
## Building for Target Platforms
### Windows (PC Standalone)
1. Unity → File → Build Settings → **PC, Mac & Linux Standalone**
2. Target Platform: **Windows**, Architecture: **x86_64**
3. Click **Build**
Or from command line: run `Tools/BuildForPC/build_pc_dll.bat`, then trigger `AutoBuild.BuildStandaloneBundle()` from Unity Editor.
### Android
1. Unity → File → Build Settings → **Android**
2. Configure: Target API 28, Min API 17, Architectures `armeabi-v7a` + `arm64-v8a`
3. Click **Export Project** → open result in Android Studio
From Android Studio / command line:
```bash
cd build/Android
./gradlew assembleDebug # debug APK
./gradlew assembleRelease # release APK
./gradlew bundleRelease # AAB for Play Store
```
Configure `build/Android/local.properties` with your SDK/NDK paths:
```properties
sdk.dir=C\:\\Users\\YourName\\AppData\\Local\\Android\\Sdk
ndk.dir=C\:\\Users\\YourName\\AppData\\Local\\Android\\Sdk\\ndk\\16.1.4479499
```
Key Android values: `compileSdkVersion 28`, `buildToolsVersion 28.0.3`, `applicationId com.joyyou.ro`, min SDK 16.
### iOS
1. Unity → File → Build Settings → **iOS**
2. Configure: SDK iOS 11.1, Deployment Target 7.0+, Architecture ARM64
3. Click **Build** → generates Xcode project
```bash
cd build
unzip RoIOSPrj.zip -d RoIOSPrj
# Open RoIOSPrj/Unity-iPhone.xcodeproj in Xcode
# Set your Team under Signing & Capabilities
# Set Bundle Identifier: com.joyyou.ro (or your own)
```
iOS builds **must** be compiled on macOS with Xcode. Bundle ID: `com.joyyou.ro`, version `2.7.4`, min iOS `10.0`.
---
## Server Architecture
```
Client
│
▼
GateServer ← client connection gateway (port 10110)
│
├─► LoginServer ← authentication (port 25001)
├─► GameServer ← main game logic, Lua + C++ (port 10502)
├─► DBServer ← database access layer (port 10011)
├─► MasterServer ← global server coordinator (port 10501)
├─► ControlServer← monitoring and control
├─► BattleServer ← PvP battle coordination
├─► TradeServer ← economy and trading
├─► AudioServer ← voice communication
├─► PayServer ← payment processing
└─► RankServer ← leaderboards
```
---
## Complete Setup Checklist
### Server
- [ ] Clone `roserver` (`config/` is the resource repo — no separate `rores` needed)
- [ ] Install: cmake, gcc-c++, make, swig, mysql-devel, screen, Python
- [ ] Run `./111.sh ../config` from `roserver/` (comment out missing symlinks if needed)
- [ ] Configure MySQL: UTF-8 charset, sql_mode='', timeouts, max_allowed_packet=16MB
- [ ] Run all SQL init scripts in order
- [ ] Insert server entry into `login.gateinfo`
- [ ] Run `build_all.sh` to compile all servers
- [ ] Run `conf_create.py` to generate config XML files
- [ ] Edit `conf/*.xml` with correct DB credentials and host/port values
- [ ] Set `LD_LIBRARY_PATH` to include `libnetwork.so` directory
- [ ] Run `./start <prefix>` then start loginserver separately
### Client
- [ ] Install Unity **2018.4.32f1 (LTS)** via Unity Hub
- [ ] Edit `sys_env1.json` (root) and `clientproj/sys_env.json` with local paths
- [ ] Open `clientcode/CSProject/clientcode.sln` in Visual Studio
- [ ] Build `UNITY_EDITOR` config → copy DLLs to `clientproj/Assets/Plugins/`
- [ ] Open `clientproj/` in Unity Hub
- [ ] Confirm servers are running and `gateinfo` has correct IP/port
- [ ] Press Play or build for target platform
---
## Key File Reference
| File | Purpose |
|------|---------|
| `roserver/111.sh` | Initialize build directory and symlinks |
| `roserver/exe/build_all.sh` | Compile all servers (Debug) |
| `roserver/exe/build_all_release.sh` | Compile all servers (Release) |
| `roserver/Build/Debug/bin/conf_create.py` | Generate server config XML files |
| `roserver/Build/Debug/bin/start` | Start all servers via screen |
| `roserver/Build/Debug/bin/stop` | Stop all servers |
| `roserver/Build/Debug/bin/status` | Show server process status |
| `roserver/Build/Debug/bin/conf/` | Active server config XML files |
| `roserver/exe/loginconf/dbinit.sql` | Login DB init script |
| `roserver/exe/dbconf/dbinit.sql` | World/player DB init script |
| `sql/*.sql` | Full database schema init scripts |
| `clientproj/ProjectSettings/ProjectVersion.txt` | Unity version (`2018.4.32f1`) |
| `clientproj/sys_env.json` | Unity-side path config |
| `sys_env1.json` | Root-level path config |
| `clientcode/CSProject/clientcode.sln` | C# game code Visual Studio solution |
| `build/Android/Tools/LocalServer/` | Docker-based local dev server scripts |