天行健 君子当自强而不息

Getting Online with Multiplayer Gaming(7)

 

Looking at Clients

Once connected, clients just need to collect local player control information and
send it up to the server. Between the updates received from the server, the clients
guess (using dead reckoning) how to handle all the game characters based on their
last known state.

For example, all characters that were walking at the last update keep walking until
the server signals them to stop. In this way, the game-play appears smooth, and with
a good network connection, server updates are received fast enough for the game
to stay entirely in sync.

As illustrated in Figure 19.8, whenever a client makes a change in action (such as
walking in a different direction than in the last known state), that change in state is
immediately relayed to the server, which immediately sends that action to all connected
clients. In that way, synchronization is much better.

Speaking of changes in player actions, exactly what actions can a player perform?
Navigation for one. As players walk around the map, their direction of travel is sent
up to the server. Notice that only the direction of travel is sent.

If you allow clients to specify their coordinates when they move, you’re inviting
cheaters to mess with the values. Instead, the server will modify the coordinates of
the player and send those coordinates back to the clients (at which time, it doesn’t
matter whether cheaters modify the values, because the server can’t be affected).

For specific actions, such as walking, clients are allowed to change their own states.
As a result, players can move between server updates. For actions such as attacking,
only the state change is sent to the server, which in turn processes the attack and
sends out the appropriate state changes to all clients.

Players can be updated only every 33ms. The updates are time-limited in order to
make sure the clients don’t flood the server with thousands of actions. By keeping
actions to a minimum, the server can process things more quickly, and the gameplay
stays smooth.

Whenever the server does send those crucial updates to the client, the client will
immediately change the state of the characters (or characters) in question (no
need for a message queue here). This update can also include the local player, so
as you’re moving around, some jumps in the action can occur due to the client synchronizing
to the server.

Well, enough of the explanations; let’s get on to making an actual network game!

posted on 2007-12-18 18:52 lovedday 阅读(135) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


公告

导航

统计

常用链接

随笔分类(178)

3D游戏编程相关链接

搜索

最新评论