Files
nexus/wiki/concepts/Server-AuthoritativeModel.md
2026-05-03 05:42:12 +08:00

40 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Server-Authoritative Model"
type: concept
tags: ["game-networking", "multiplayer", "security"]
sources: ["unreal-multiplayer-architect", "unreal-multiplayer-architect"]
last_updated: 2026-04-30
---
## Aliases
- 服务器权威模型
- Server Authority
- Authority Model
## 定义
多人游戏中的服务器权威模型是指所有游戏状态变更必须在服务器端执行客户端仅发送请求RPC服务器验证后执行并通过复制同步状态。
## 核心原则
1. **服务器拥有真相**:客户端显示的状态仅供参考,服务器状态为最终权威
2. **客户端预测**:客户端本地预测操作以减少延迟感知,服务器确认或回滚
3. **验证不可省略**:每个 Server RPC 必须实现 `_Validate()` 函数,否则为作弊漏洞
## 架构模式
```
客户端 → 发送 RPC (Client Request)
服务器 → 验证输入 (Validate)
服务器 → 执行逻辑 (Simulate/Execute)
服务器 → 复制状态 (Replicate)
客户端 → 接收更新 (Receive/Reconcile)
```
## 在 UE5 中的实现
- `UFUNCTION(Server, Reliable, WithValidation)` 标记服务器 RPC
- `ServerRequestInteract_Validate()` 必须实现所有游戏逻辑输入验证
- `HasAuthority()` 检查确保在服务器端执行状态变更
## 相关概念
- [[Actor Replication]] — 服务器向客户端同步状态的机制
- [[Network Prediction]] — 客户端本地预测以减少延迟感知
- [[GAS (Gameplay Ability System)]] — UE5 能力系统,包含网络预测支持