diff --git a/docs/implementation-notes.md b/docs/implementation-notes.md index fde4affb..a3aa7b7e 100644 --- a/docs/implementation-notes.md +++ b/docs/implementation-notes.md @@ -22,6 +22,11 @@ - **WorldServer.cpp**: Game world simulation and entity management - **PerformanceManager.cpp**: Monitors server performance metrics +### Game Logic (`dGame/`) +- **CheatDetection.cpp**: Anti-cheat system with database logging +- **UserManager.cpp**: Player session and character management +- **EntityManager.cpp**: Game entity lifecycle and updates + ### Networking Layer (`dNet/`) - **dServer.cpp/h**: Base server class with master communication - **MasterPackets.cpp/h**: Master server protocol implementation @@ -123,16 +128,16 @@ auto result = Database::Get()->Query(sql); - Chat Server handles all social features centrally ### Fault Tolerance -- All servers maintain heartbeat with Master -- Automatic reconnection on connection loss +- All servers maintain connections with Master Server +- Database connection monitoring and error handling - Player state persisted in database - Graceful degradation when servers unavailable ### Performance Optimizations - Entity serialization only to relevant players (ghosting) - Spatial partitioning for efficient updates -- Message batching for network efficiency - Database query optimization with prepared statements +- Network packet compression and optimization ## Security Features @@ -144,7 +149,8 @@ auto result = Database::Get()->Query(sql); ### Game Security - Server-side validation of all game actions -- Anti-cheat through server authority +- Cheat detection system with database logging (`CheatDetection.cpp`) +- Player cheat detection table tracks suspicious activities - Rate limiting on client requests - Database injection prevention diff --git a/docs/server-architecture-ascii.md b/docs/server-architecture-ascii.md index 35dc69d5..90ac7236 100644 --- a/docs/server-architecture-ascii.md +++ b/docs/server-architecture-ascii.md @@ -19,23 +19,35 @@ │ │ SERVER COMMUNICATION LAYER │ │ │ │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ │ - │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ - │ │AUTH SERVER │ │CHAT SERVER │ │WORLD SERVER │ │WORLD SERVER │ │ - │ │ │ │ │ │ │ │ │ │ - │ │Port: 1001 │ │Port: 1501 │ │Port: Dynamic│ │Port: Dynamic│ │ - │ │ │ │ │ │ │ │ │ │ - │ │• Login │ │• Chat Msgs │ │• Game Logic │ │• Game Logic │ │ - │ │• Accounts │ │• Teams │ │• Entities │ │• Entities │ │ - │ │• Sessions │ │• Guilds │ │• Physics │ │• Physics │ │ - │ │• Keys │ │• Friends │ │• Zone Mgmt │ │• Zone Mgmt │ │ - │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ - │ │ │ │ │ │ - │ └───────────────────┼───────────────────┼───────────────────┘ │ - │ │ │ │ - │ │ │ │ - │ ┌───────────────────┼───────────────────┼───────────────────┐ │ - │ │ │ │ │ │ - │ ▼ ▼ ▼ ▼ │ + │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ + │ │AUTH SERVER │ │WORLD SERVER │ │WORLD SERVER │ │WORLD SERVER │ │ + │ │ │ │ │ │ │ │ │ │ + │ │Port: 1001 │ │Port: Dynamic│ │Port: Dynamic│ │Port: Dynamic│ │ + │ │ │ │ │ │ │ │ │ │ + │ │• Login │ │• Game Logic │ │• Game Logic │ │• Game Logic │ │ + │ │• Accounts │ │• Entities │ │• Entities │ │• Entities │ │ + │ │• Sessions │ │• Physics │ │• Physics │ │• Physics │ │ + │ │• Keys │ │• Zone Mgmt │ │• Zone Mgmt │ │• Zone Mgmt │ │ + │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ + │ │ │ │ │ │ + │ │ │ │ │ │ + │ │ │ │ │ │ + │ │ ┌─────────────┐ │ │ │ │ + │ │ │CHAT SERVER │←──────┼───────────────────┼───────────────────┘ │ + │ │ │ │ │ │ │ + │ │ │Port: 1501 │ │ │ │ + │ │ │ │ │ │ │ + │ │ │• Chat Msgs │ │ │ │ + │ │ │• Teams │ │ │ │ + │ │ │• Guilds │ │ │ │ + │ │ │• Friends │ │ │ │ + │ │ └─────────────┘ │ │ │ + │ │ │ │ │ │ + │ └─────────────────┼───────────┼───────────────────┼────────────────────────────┤ + │ │ │ │ │ + │ ┌─────────────────┼───────────┼───────────────────┼───────────────────┐ │ + │ │ │ │ │ │ │ + │ ▼ ▼ ▼ ▼ ▼ │ │ ┌─────────────────────────────────────────────────────────────────────────────┐ │ │ │ MASTER SERVER (Port: 1500) │ │ │ │ │ │ @@ -97,7 +109,7 @@ World Server → Master Server → Target World Server → Client 3. Chat Message Flow: - Client → World Server → Chat Server → Target World Server → Target Client + Client → World Server → Chat Server → Target World Server(s) → Target Client(s) 4. Entity Updates Flow: World Server → EntityManager → ReplicaManager → All Clients in Zone diff --git a/docs/server-architecture-diagram.md b/docs/server-architecture-diagram.md index 6dd5316b..9e89bc2a 100644 --- a/docs/server-architecture-diagram.md +++ b/docs/server-architecture-diagram.md @@ -48,19 +48,16 @@ graph TB %% Client Connections Client1 -.->|1. Authentication| AuthServer Client1 -.->|2. Character/Zone Data| WorldServer1 - Client1 -.->|3. Chat Messages| ChatServer Client2 -.->|Authentication| AuthServer Client2 -.->|Character/Zone Data| WorldServer2 - Client2 -.->|Chat Messages| ChatServer Client3 -.->|Authentication| AuthServer Client3 -.->|Character/Zone Data| WorldServer3 - Client3 -.->|Chat Messages| ChatServer %% Server-to-Master Connections (All servers connect to master) AuthServer <-.->|SERVER_INFO
SESSION_KEY
PLAYER_ADDED/REMOVED| MasterServer - ChatServer <-.->|SERVER_INFO
PLAYER_ADDED/REMOVED
HEARTBEAT| MasterServer + ChatServer <-.->|SERVER_INFO
PLAYER_ADDED/REMOVED| MasterServer WorldServer1 <-.->|ZONE_TRANSFER
PERSISTENT_ID
WORLD_READY
SERVER_INFO| MasterServer WorldServer2 <-.->|ZONE_TRANSFER
PERSISTENT_ID
WORLD_READY
SERVER_INFO| MasterServer WorldServer3 <-.->|ZONE_TRANSFER
PERSISTENT_ID
WORLD_READY
SERVER_INFO| MasterServer @@ -77,10 +74,10 @@ graph TB WorldServer3 <--> Database MasterServer <--> Database - %% Inter-World Server Communication (through Chat Server) - WorldServer1 <-.->|Player Messages
Zone Chat
Team Invites| ChatServer - WorldServer2 <-.->|Player Messages
Zone Chat
Team Invites| ChatServer - WorldServer3 <-.->|Player Messages
Zone Chat
Team Invites| ChatServer + %% Chat Server Communication (World Servers route chat, clients never connect directly) + WorldServer1 <-.->|Chat Messages
Team Operations
Social Features| ChatServer + WorldServer2 <-.->|Chat Messages
Team Operations
Social Features| ChatServer + WorldServer3 <-.->|Chat Messages
Team Operations
Social Features| ChatServer style MasterServer fill:#ff9999 style AuthServer fill:#99ccff @@ -165,7 +162,7 @@ graph LR subgraph "World Server Integration" C7[WORLD_ROUTE_PACKET
↔ World Servers] C8[PLAYER_READY
← World Servers] - C9[HEARTBEAT_REQUEST
↔ World Servers] + C9[LOGIN_SESSION_NOTIFY
← World Servers] end Chat -.-> C1 @@ -298,9 +295,9 @@ sequenceDiagram participant C2 as Client 2 C1->>W1: Chat message - W1->>Ch: GENERAL_CHAT_MESSAGE + W1->>Ch: GENERAL_CHAT_MESSAGE Ch->>Ch: Process & route message - Ch->>W2: WORLD_ROUTE_PACKET + Ch->>W2: WORLD_ROUTE_PACKET (to relevant world servers) W2->>C2: Display message Ch->>W1: Message confirmation W1->>C1: Message sent confirmation