星际争霸如果是多人对战模式,就会遇到一个问题:如何降低网络延时和负担。
为了确保数据的一致性,我们应该将每个玩家的发生变化的数据不停的传送到开地图的主机进行保存,一旦任何某个玩家的客户机读取数据,就必须向主机请求数据。
尽管大多数数据是交互性的,即使某个玩家的人口也是这样的,如果某个敌人的部队杀死了这个玩家的一个部队,立即影响了他的人口数量。
不过水晶矿和气矿有所不同,除了玩家自己的建造操作和农民采集,别的玩家影响不了这个数据。
所以我们考虑在客户机也放一个数据存储,玩家改变或者读取他的资源的时候,先操作本机数据,再通知主机。
代理(Proxy)模式示例:
为了方便,假设客户机已经通过远程包含或其他方法获取了主机上的php代码,它的代码如下:
也就是代理类 class ProxyDataProcess implements iDataProcess { //主机操作数据的对象 private $dataProcess; //构造函数 public function

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.