If Starcraft is a multiplayer mode, it will encounter a problem: how to reduce network latency and burden. To ensure data consistency, we should continuously transmit the changed data of each player to the host on which the map is opened for storage. Once any player's client reads the data, you must request data from the host. If Starcraft is a multiplayer mode, it will encounter a problem: how to reduce network latency and burden.
To ensure data consistency, we should continuously transmit the changed data of each player to the host on which the map is opened for storage. Once any player's client reads the data, you must request data from the host.
Although most of the data is interactive, even if a player's population is the same, if an enemy's troops have killed a player's troops, the number of his population is immediately affected.
However, the crystal mines and gas mines are different. Apart from the players' own construction operations and farmer collection, other players cannot influence this data.
Therefore, we want to put a data storage on the client. When a player changes or reads his/her resources, it first operates the local data and then notifies the host.
Proxy mode example:
For convenience, assuming that the client has obtained the php code on the host through remote inclusion or other methods, its code is as follows: