Complete C# server cutover

This commit is contained in:
Nomads_Reach
2026-08-16 02:36:32 -04:00
parent ddadf87423
commit 757e614cdd
79 changed files with 923 additions and 13129 deletions
+31 -99
View File
@@ -1,118 +1,50 @@
# Qt GUI Host Development
# Development
This directory contains the native C++ Qt6 GUI application for hosting Commonwealth Online servers.
## Server
## Quick Start for Developers
The dedicated server is a C#/.NET project at `server/CommonwealthOnline.Server.csproj`.
### Prerequisites
Core files:
1. **Qt6.4+**
- Download from https://www.qt.io/download-open-source
- Install to default location (C:\Qt\6.4.0) or adjust `build.bat`
- `AuthoritativeServer.cs`: sessions, authoritative gameplay state, security, interest filtering
- `ProtocolCore.cs`: JSON codec, transport policy, snapshot sequencing/envelope
- `ProtocolValidation.cs`: Protocol V2 packet validation
- `Domain.cs`: sessions, bans, NPC authority, world presets
- `TcpTransport.cs`: newline-framed TCP compatibility transport
- `GnsTransport.cs`: C# wrapper over the native GameNetworkingSockets bridge
- `AdminDiscovery.cs`: authenticated localhost admin channel and LAN discovery
- `Program.cs`: CLI, interactive server, management commands and synthetic load command
2. **Visual Studio 2022**
- Install C++ development tools
- Required for MSVC compiler
3. **CMake 3.20+**
- Download from https://cmake.org/download
4. **Python 3.9+**
- Required for running the relay server subprocess
- Add to PATH
### Building
Build and test:
```bash
cd host-gui
build.bat
cd server
dotnet build CommonwealthOnline.Server.csproj -c Release
dotnet run --project tests/CommonwealthOnline.Server.Tests.csproj -c Release
```
Or manually:
The test harness uses in-memory connections for authoritative behavior and contains no external test-framework package dependency.
```bash
cd host-gui
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022"
cmake --build . --config Release
```
## Native GNS bridge
### Running
`server/native_transport` remains C++. Keep it transport-only. Do not move validation, identity, interest filtering, NPC authority, combat, world state or caching into the bridge.
```bash
.\build\bin\Release\CommonwealthOnlineHost.exe
```
The C ABI is the boundary consumed from `GnsTransport.cs`.
## Project Structure
## Qt Host
- `CMakeLists.txt` - Qt6 build configuration
- `src/main.cpp` - Application entry point
- `src/MainWindow.h/cpp` - Main UI window
- `src/ServerProcess.h/cpp` - Subprocess manager for relay
- `src/resources/` - Icons and resources
- `build.bat` - Windows build script
- `README.md` - User documentation
The Qt host remains C++. `ServerProcess` launches the published C# server and communicates through the authenticated localhost admin channel. It must not invoke a scripting runtime.
## Architecture
CMake publishes a self-contained server as part of the Host GUI post-build step.
### MainWindow
- Handles all UI elements (buttons, tables, labels, text areas)
- Manages server start/stop through ServerProcess
- Updates stats and client list in real-time
- Displays logs with timestamps
## Protocol changes
### ServerProcess
- Spawns Python relay server as subprocess
- Captures stdout/stderr in real-time
- Parses log output
- Handles process lifecycle (start, stop, errors)
Protocol behavior is intentionally independent from transport. If adding a packet type:
### Communication
- Uses `QProcess` for subprocess management
- Parses CLI output for stats and client data
- Emits Qt signals for UI updates
1. Define validation and normalization in C#.
2. Decide its delivery policy in `TransportPolicy`.
3. Default new control/state traffic to reliable/ordered.
4. Use unreliable/sequenced only for latest-wins snapshot families.
5. Add tests before changing the client.
## Design Decisions
1. **Subprocess Architecture**: Server runs in separate process so GUI can restart/crash without affecting active connections
2. **Python Relay**: Uses existing Python CLI to avoid duplicating networking logic in C++
3. **Live Logs**: Captures and displays all server output for debugging and transparency
4. **Minimal Dependencies**: Qt6 core only, no additional frameworks or heavy dependencies
5. **Dark Theme**: Fallout 4-inspired styling with amber/green accents matches game aesthetic
## Performance
- **Startup**: <1 second (just Qt6 initialization)
- **Memory**: ~50-100 MB baseline
- **Executable Size**: ~15-20 MB (with Qt6 DLLs included)
- **CPU**: Minimal, only updates on events
## Next Steps
- [ ] Implement stats fetching via CLI JSON output
- [ ] Add admin command buttons (set time/weather)
- [ ] Config file editor panel
- [ ] System tray icon
- [ ] Settings panel
- [ ] Player kick/ban interface
- [ ] Logging export functionality
- [ ] Performance profiling and optimization
## Troubleshooting
### CMake can't find Qt6
Ensure Qt6 path is set in `build.bat` or CMake cache.
### Build fails with MSVC errors
Check that Visual Studio 2022 with C++ tools is installed.
### Python not found at runtime
Ensure Python 3.9+ is installed and in PATH. Restart the GUI or set `PYTHON` environment variable.
### Application window appears but doesn't respond
Check console output or run from command line to see error messages.
Never cache/replay discrete action events, accept stale NPC authority epochs, accept stale snapshot sequences, or bypass server-owned identity and interest validation.