# gunnyii/basegunnyii architecture

> Architecture diagram of the GitHub repository gunnyii/basegunnyii, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gunnyii/basegunnyii
- Repository: https://github.com/gunnyii/basegunnyii

## Overview

1. **What this repo is**
   - This is a multi-project .NET game platform for the “GunnyII” base, not a single app.
   - The architecture is split into shared libraries, long-running servers, web request endpoints, and front-end ASP.NET pages/Flash assets.

2. **Core shared foundation**
   - `Game.Base`, `Game.Logic`, `SqlDataProvider`, and `Bussiness` are the main reusable layers.
   - `Game.Base` provides server/runtime infrastructure such as packet parsing, command dispatch, events, config loading, queues, and script management.
   - `Game.Logic` contains the core game rules: physics, maps, objects, skills/spells, AI, missions, PvE/PvP logic, and effect processing.
   - `SqlDataProvider` is the typed data/model layer for database entities like players, items, quests, consortia, maps, logs, and rates.
   - `Bussiness` wraps higher-level domain operations and service references used by the web and server tiers.

3. **Main server runtime: `Game.Server`**
   - This is the central gameplay server and the largest runtime boundary.
   - It handles scene gameplay, room management, inventory, chat, quests, marriage, hot spring rooms, login integration, battle integration, and packet dispatch.
   - The packet layer is very explicit: there are many `Packets/Client/*Handler.cs` classes and `Packets/Server/*` abstractions, showing a message-driven architecture.
   - It also contains multiple gameplay domains that can be diagrammed as submodules: `Rooms`, `SceneGames`, `SceneMarryRooms`, `HotSpringRooms`, `Battle`, `Managers`, `Quests`, and `Statics`.

4. **Battle-specific runtime: `Fighting.Server`**
   - This is a dedicated combat server for match/battle execution.
   - It has its own room manager, game manager, guild integration, server client, and battle/game objects.
   - The presence of `Games`, `Rooms`, `Servers`, and `ProxyPlayer` indicates it can host or proxy combat sessions independently from the main game server.
   - Conceptually, `Game.Server` coordinates player/world state, while `Fighting.Server` runs the fight instance itself.

5. **Center/coordination runtime: `Center.Server`**
   - `Center.Server` appears to be the central coordination and registry service.
   - It has server/client management, login management, consortium management, static configuration, logging, and a WCF-style service boundary (`Services/ICenterService.cs`, `CenterService.cs`).
   - This is likely used to publish server info, manage cross-server metadata, and support login/server selection flows.

6. **Request/API tier: `Tank.Request` and `Road.Request`**
   - These projects are ASP.NET request gateways made up of many `.ashx` handlers and some `.aspx` pages.
   - They expose account/login, server list, item lists, quest data, mail, consortia, ranking, rewards, and payment-related endpoints.
   - `Tank.Request` is the larger production-facing endpoint layer for game services; `Road.Request` looks like a related/older or alternate request surface with similar responsibilities.
   - These layers are the main bridge between browser/client-facing flows and the backend servers/database.

7. **Client-facing web UI / launchers**
   - `Tank.Flash` is the main web front-end and launcher surface, containing Flash-era pages, loading screens, login entry points, scripts, and image assets.
   - `RenRenAssistant` and `Tank.Assistant` are auxiliary ASP.NET apps for login transfer or platform integration.
   - These are presentation and entry layers; they do not hold the core game rules.

8. **Service hosts / background processes**
   - `Game.Service`, `Fighting.Service`, and `Center.Service` are service-hosting projects used to run or manage the server processes.
   - They include console/service start actions, install/uninstall routines, and in some cases Lua or config assets.
   - This suggests the servers can be launched as Windows services or console processes depending on deployment.

9. **Gameplay domain boundaries inside the servers**
   - The repo cleanly separates major gameplay concerns:
     - scene/world play: `SceneGames`, `Games`, `MapMgr`, `WorldMgr`
     - room/session flow: `Rooms`, `ProxyRoom`, `RoomMgr`
     - combat and physics: `Phy`, `Battle`, `TankGameLogicProcessor`
     - social systems: consortia/guild, marriage, IM/chat, hot spring
     - economy/inventory: items, shops, auctions, strengthen/fusion/refinery, drops
     - progression: quests, achievements, levels, daily awards, active events
   - That structure matters for architecture diagrams because each area can be shown as a separate bounded subsystem feeding the same player state and database.

10. **Content, AI, and script layer**
   - `GameServerScript` and parts of `Game.Logic` contain game-specific AI/missions/NPC logic.
   - There are many script classes for maps, NPCs, missions, and difficulty variants, plus Lua support in `Game.Logic/LuaMgr.cs` and `Game.Service/ai`.
   - This is effectively the content scripting layer over the engine, distinct from the server transport and persistence layers.

11. **Data and persistence path**
   - Persistent data originates in `SqlDataProvider` entity types and is used by `Bussiness`, server managers, and request handlers.
   - `RoadDatabase` contains LINQ/DB helper infrastructure and the DBML/DataSet artifacts that back the persistence model.
   - Many request endpoints and server managers appear to read/write player, item, quest, log, and configuration data through this shared data layer.
   - From a diagram perspective, the database sits behind the request layer and the game servers, with `SqlDataProvider` as the common contract.

12. **External service dependencies**
   - There are WCF service references to `CenterService` and `WebLogin`, showing that parts of the system depend on centralized login and center coordination services.
   - This is a distributed system, not a monolith: login, server selection, and center metadata are shared across multiple processes.
   - Logging is also a visible cross-cutting concern via `log4net` config files and per-server log configurations.

13. **Tools, tests, and maintenance**
   - `Game.Config`, `Game.Tools`, and `RoadTest` are supporting utilities for configuration, admin tooling, and validation.
   - `Game.Test` and `RoadTest` contain unit/multi-thread tests for marshalling, DB access, crypto, XML, and buffering.
   - These projects help validate infrastructure pieces rather than game-play features.

14. **How to diagram the data flow**
   - A useful architecture diagram would show:
     - browser/Flash client and admin tools on the left
     - ASP.NET request gateways in front of them
     - shared business/data layers in the middle
     - `Game.Server`, `Fighting.Server`, and `Center.Server` as the main runtime services
     - the database and shared WCF login/center services on the right/back end
   - The key runtime flow is: client request or socket message -> packet/handler dispatch -> domain manager/business logic -> shared data provider/database and/or inter-server service -> response back through the same boundary.

Main entry points: [`Game.Server`](https://github.com/gunnyii/basegunnyii/blob/master/Game.Server) (Game Server), [`Bussiness`](https://github.com/gunnyii/basegunnyii/tree/master/Bussiness) (Bussiness), [`Tank.Request`](https://github.com/gunnyii/basegunnyii/blob/master/Tank.Request) (Tank Request), [`Center.Server`](https://github.com/gunnyii/basegunnyii/blob/master/Center.Server) (Center Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client / UI"]
  node_tank_flash["Tank Flash<br/>launcher/ui<br/>[Tank.Flash]"]
  node_tank_assistant["Tank Assistant<br/>aux web app<br/>[Tank.Assistant]"]
  node_renren_assistant["RenRen Assistant<br/>aux web app"]
end

subgraph group_api["Request Gateways"]
  node_tank_request["Tank Request<br/>ASP.NET gateway<br/>[Tank.Request]"]
  node_road_request["Road Request<br/>ASP.NET gateway<br/>[Road.Request]"]
end

subgraph group_shared["Shared Foundation"]
  node_game_base["Game Base<br/>runtime infra<br/>[Game.Base]"]
  node_game_logic["Game Logic<br/>game engine<br/>[Game.Logic]"]
  node_business["Bussiness<br/>domain services"]
  node_sql_data[("SqlDataProvider<br/>data models")]
  node_scripts["Game Scripts<br/>content/ai"]
end

subgraph group_runtime["Server Runtimes"]
  node_center_server["Center Server<br/>coordination svc<br/>[Center.Server]"]
  node_game_server["Game Server<br/>game runtime<br/>[Game.Server]"]
  node_fighting_server["Fighting Server<br/>combat runtime<br/>[Fighting.Server]"]
end

subgraph group_data["Backend Services"]
  node_road_db[("RoadDatabase<br/>db helpers")]
  node_game_service["Game Service<br/>service host<br/>[Game.Service]"]
  node_fighting_service["Fighting Service<br/>service host<br/>[Fighting.Service]"]
  node_center_service["Center Service<br/>service host<br/>[Center.Service]"]
  node_game_config["Game Config<br/>tooling<br/>[Game.Config]"]
  node_game_tools["Game Tools<br/>tooling<br/>[Game.Tools]"]
  node_game_test["Game Test<br/>tests<br/>[Game.Test]"]
  node_road_test["Road Test<br/>tests"]
end

node_tank_flash -->|"HTTP"| node_tank_request
node_tank_assistant -->|"HTTP"| node_tank_request
node_renren_assistant -->|"HTTP"| node_tank_request
node_tank_request -->|"domain ops"| node_business
node_road_request -->|"domain ops"| node_business
node_tank_request -->|"models"| node_sql_data
node_road_request -->|"db access"| node_road_db
node_business -->|"entities"| node_sql_data
node_business -->|"persistence"| node_road_db
node_game_server -->|"infra"| node_game_base
node_game_server -->|"rules"| node_game_logic
node_game_server -->|"services"| node_business
node_game_server -->|"state"| node_sql_data
node_game_server -->|"coordination"| node_center_server
node_game_server -->|"battle link"| node_fighting_server
node_fighting_server -->|"combat rules"| node_game_logic
node_fighting_server -->|"infra"| node_game_base
node_center_server -->|"config/state"| node_sql_data
node_center_server -->|"registry ops"| node_business
node_game_service -->|"host"| node_game_server
node_fighting_service -->|"host"| node_fighting_server
node_center_service -->|"host"| node_center_server
node_scripts -->|"content"| node_game_logic
node_scripts -->|"content"| node_game_server
node_game_config -->|"config"| node_game_base
node_game_tools -->|"admin"| node_game_server
node_game_test -->|"validation"| node_game_base
node_road_test -->|"validation"| node_road_db

click node_tank_flash "https://github.com/gunnyii/basegunnyii/blob/master/Tank.Flash"
click node_tank_assistant "https://github.com/gunnyii/basegunnyii/blob/master/Tank.Assistant"
click node_renren_assistant "https://github.com/gunnyii/basegunnyii/tree/master/RenRenAssistant"
click node_tank_request "https://github.com/gunnyii/basegunnyii/blob/master/Tank.Request"
click node_road_request "https://github.com/gunnyii/basegunnyii/blob/master/Road.Request"
click node_game_base "https://github.com/gunnyii/basegunnyii/blob/master/Game.Base"
click node_game_logic "https://github.com/gunnyii/basegunnyii/blob/master/Game.Logic"
click node_business "https://github.com/gunnyii/basegunnyii/tree/master/Bussiness"
click node_sql_data "https://github.com/gunnyii/basegunnyii/tree/master/SqlDataProvider"
click node_road_db "https://github.com/gunnyii/basegunnyii/tree/master/RoadDatabase"
click node_center_server "https://github.com/gunnyii/basegunnyii/blob/master/Center.Server"
click node_game_server "https://github.com/gunnyii/basegunnyii/blob/master/Game.Server"
click node_fighting_server "https://github.com/gunnyii/basegunnyii/blob/master/Fighting.Server"
click node_game_service "https://github.com/gunnyii/basegunnyii/blob/master/Game.Service"
click node_fighting_service "https://github.com/gunnyii/basegunnyii/blob/master/Fighting.Service"
click node_center_service "https://github.com/gunnyii/basegunnyii/blob/master/Center.Service"
click node_scripts "https://github.com/gunnyii/basegunnyii/tree/master/GameServerScript"
click node_game_config "https://github.com/gunnyii/basegunnyii/blob/master/Game.Config"
click node_game_tools "https://github.com/gunnyii/basegunnyii/blob/master/Game.Tools"
click node_game_test "https://github.com/gunnyii/basegunnyii/blob/master/Game.Test"
click node_road_test "https://github.com/gunnyii/basegunnyii/tree/master/RoadTest"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tank_flash,node_tank_assistant,node_renren_assistant toneBlue
class node_tank_request,node_road_request toneAmber
class node_game_base,node_game_logic,node_business,node_sql_data,node_scripts toneMint
class node_center_server,node_game_server,node_fighting_server toneRose
class node_road_db,node_game_service,node_fighting_service,node_center_service,node_game_config,node_game_tools,node_game_test,node_road_test toneIndigo
```

## Components

### Client / UI

Browser, Flash-era launcher, and auxiliary login-assistant front ends.

- [Tank Flash](https://github.com/gunnyii/basegunnyii/blob/master/Tank.Flash): launcher/ui · Flash-era web front end, loading flow, and game entry surface. · `Tank.Flash`
- [Tank Assistant](https://github.com/gunnyii/basegunnyii/blob/master/Tank.Assistant): aux web app · Auxiliary ASP.NET login-transfer and platform integration app. · `Tank.Assistant`
- [RenRen Assistant](https://github.com/gunnyii/basegunnyii/tree/master/RenRenAssistant): aux web app · Auxiliary ASP.NET app for transfer/login/payment integration. · `RenRenAssistant`

### Request Gateways

ASP.NET handlers and pages that expose account, server, inventory, quest, and payment flows.

- [Tank Request](https://github.com/gunnyii/basegunnyii/blob/master/Tank.Request): ASP.NET gateway · Main request surface with handlers for login, server list, items, quests, mail, consortia, ranking, and payments. · `Tank.Request`
- [Road Request](https://github.com/gunnyii/basegunnyii/blob/master/Road.Request): ASP.NET gateway · Alternate/older request surface with similar data-loading and account flows. · `Road.Request`

### Shared Foundation

Reusable business, logic, and data-model layers consumed by servers and request projects.

- [Game Base](https://github.com/gunnyii/basegunnyii/blob/master/Game.Base): runtime infra · Core server infrastructure for packet parsing, command dispatch, config, events, queues, and scripts. · `Game.Base`
- [Game Logic](https://github.com/gunnyii/basegunnyii/blob/master/Game.Logic): game engine · Core gameplay rules: physics, maps, objects, spells, AI, missions, PvE/PvP, and effects. · `Game.Logic`
- [Bussiness](https://github.com/gunnyii/basegunnyii/tree/master/Bussiness): domain services · Higher-level domain operations and service wrappers used by web and server tiers. · `Bussiness`
- [SqlDataProvider](https://github.com/gunnyii/basegunnyii/tree/master/SqlDataProvider): data models · Typed database entities and shared persistence contract for players, items, quests, logs, and rates. · `SqlDataProvider`
- [Game Scripts](https://github.com/gunnyii/basegunnyii/tree/master/GameServerScript): content/ai · GameServerScript content layer for AI, missions, NPC behavior, and scenario-specific logic. · `GameServerScript`

### Server Runtimes

Long-running gameplay, combat, and coordination processes.

- [Center Server](https://github.com/gunnyii/basegunnyii/blob/master/Center.Server): coordination svc · Central registry/login coordination service with server management, config, and WCF boundary. · `Center.Server`
- [Game Server](https://github.com/gunnyii/basegunnyii/blob/master/Game.Server): game runtime · Main gameplay runtime for scene play, rooms, inventory, chat, quests, social systems, and packet dispatch. · `Game.Server`
- [Fighting Server](https://github.com/gunnyii/basegunnyii/blob/master/Fighting.Server): combat runtime · Dedicated combat server for battle sessions, room management, proxies, and fight execution. · `Fighting.Server`

### Backend Services

Persistence, center/login coordination, and supporting hosts.

- [RoadDatabase](https://github.com/gunnyii/basegunnyii/tree/master/RoadDatabase): db helpers · LINQ, DBML, and database helper infrastructure supporting the shared persistence model. · `RoadDatabase`
- [Game Service](https://github.com/gunnyii/basegunnyii/blob/master/Game.Service): service host · Windows service / console host for Game.Server deployment and lifecycle control. · `Game.Service`
- [Fighting Service](https://github.com/gunnyii/basegunnyii/blob/master/Fighting.Service): service host · Windows service / console host for Fighting.Server deployment and lifecycle control. · `Fighting.Service`
- [Center Service](https://github.com/gunnyii/basegunnyii/blob/master/Center.Service): service host · Windows service / console host for the center coordination process. · `Center.Service`
- [Game Config](https://github.com/gunnyii/basegunnyii/blob/master/Game.Config): tooling · Configuration utility for managing server and game settings. · `Game.Config`
- [Game Tools](https://github.com/gunnyii/basegunnyii/blob/master/Game.Tools): tooling · Admin and maintenance client tooling for operational tasks. · `Game.Tools`
- [Game Test](https://github.com/gunnyii/basegunnyii/blob/master/Game.Test): tests · Infrastructure and data-access tests for marshaling, crypto, XML, buffering, and DB access. · `Game.Test`
- [Road Test](https://github.com/gunnyii/basegunnyii/tree/master/RoadTest): tests · Database and service tests for the Road stack. · `RoadTest`

## Connections

- Tank Flash → Tank Request: HTTP · Browser/launcher flows call request endpoints for login, loading, and game metadata.
- Tank Assistant → Tank Request: HTTP · Auxiliary app uses the request tier for login transfer and integration flows.
- RenRen Assistant → Tank Request: HTTP · Platform integration app routes through the request tier.
- Tank Request → Bussiness: domain ops · Handlers delegate account, item, quest, consortia, and payment operations to business services.
- Road Request → Bussiness: domain ops · Alternate request surface also uses the shared business layer.
- Tank Request → SqlDataProvider: models · Request handlers read and write shared entity models.
- Road Request → RoadDatabase: db access · Road request endpoints lean on database helper infrastructure.
- Bussiness → SqlDataProvider: entities · Business services operate on shared persistence entities.
- Bussiness → RoadDatabase: persistence · Higher-level services use database helpers and generated mappings.
- Game Server → Game Base: infra · Gameplay runtime builds on shared server infrastructure and packet/command machinery.
- Game Server → Game Logic: rules · Scene, room, inventory, and quest code execute against the shared game engine.
- Game Server → Bussiness: services · Server-side gameplay operations call into shared domain services when needed.
- Game Server → SqlDataProvider: state · Player, item, quest, social, and log state persists through shared data models.
- Game Server → Center Server: coordination · Gameplay server depends on center services for login and cross-server metadata.
- Game Server → Fighting Server: battle link · Main server connects to dedicated combat sessions and proxies fights to the combat runtime.
- Fighting Server → Game Logic: combat rules · Combat server reuses shared game physics, spells, and battle logic.
- Fighting Server → Game Base: infra · Combat runtime uses the same packet and command foundation.
- Center Server → SqlDataProvider: config/state · Center service manages shared server, login, and consortium metadata.
- Center Server → Bussiness: registry ops · Center coordination uses business/domain wrappers for management tasks.
- Game Service → Game Server: host · Service host starts and manages the main gameplay process.
- Fighting Service → Fighting Server: host · Service host starts and manages the combat process.
- Center Service → Center Server: host · Service host starts and manages the center process.
- Game Scripts → Game Logic: content · Scenario AI, missions, and NPC scripts extend the shared game logic.
- Game Scripts → Game Server: content · Server gameplay processors consume scripted content and AI definitions.
- Game Config → Game Base: config · Configuration tool targets shared runtime settings and XML config infrastructure.
- Game Tools → Game Server: admin · Operational tooling interacts with the main runtime for administration.
- Game Test → Game Base: validation · Tests cover shared infrastructure pieces such as marshalling and buffering.
- Road Test → RoadDatabase: validation · Road tests exercise database and service integration.
