Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SFML Game Development.pdf
Скачиваний:
194
Добавлен:
28.03.2016
Размер:
4.19 Mб
Скачать

Chapter 10

 

Peer

Peer

Peer

 

Peer

These inter-connections between all the clients, which somehow resemble a spider's web, mean that every client has a connection with every client. This way, they effectively communicate correctly, allowing chatting with each other, seeing each other's movements, and other actions. When a client means to do something, such as when the jump key is pressed and the character should jump, it notifies every other client of this, so they can see it happen too.

However, while this approach can be efficient, as the network processing is done among all clients, it introduces a nasty set of disadvantages that unfortunately can't be avoided.

The major problem with the technique is that cheating cannot be prevented. A client will just do whatever it wants to do and notify all the others of it. Players can and they will exploit your game's weaknesses whenever there are any and destroy the fun of the game to other players.

So, how will we make sure the clients can't do anything outside of the allowed actions? That's where the other network architecture kicks in!

Client-server architecture

Alright, this is a very, very important subject. This is nearly the standard as far as multiplayer gaming goes. Learn this concept well and you're gold. This will be particularly useful for nearly all networking tasks you will be doing and not exclusively games.

[ 243 ]

www.it-ebooks.info

Company Atop the Clouds – Co-op Multiplayer

Why is it so important? First, because it allows a central instance to control everything, and therefore provides the possibility to implement means of security.

The following figure shows how computers are laid in such architecture:

 

Server

 

Peer

Peer

Peer

Here, you see there is a central server, or group of servers (distributed systems) that communicate with all the clients. Now, a client does not know, under any

circumstances, about other client's address or information. The server acts as a proxy, or a bridge between the client's communications. However, saying the server is merely a bridge for communication is a reductive view of what it really does.

Authoritative servers

In reality, having one server manage all of the clients and be in charge of all their

communications easily puts the server application under a heavy processing and networking load. It is hard to develop and maintain efficient and fast servers that can hold many clients at once. However, this cost is easily compensated by the advantages this architecture inherently gives us. The most notable feature is the authority of the

server, entirely preventing the cheating and exploiting by the players.

How is this achieved, you may ask? It is easy to explain and a bit harder to get right while developing, but what happens, in essence, is that the server holds the true and absolute state of the simulation, and only the data being simulated in the server application is considered valid. This way, each client will only receive valid

state information about the server and will always have correct and proper values in the simulation.

On the other hand, the server may check for every packet received from clients, and easily deduce what is possible to do under the constraints of the simulation. When the server checks a client input, it is possible to analyze it in order to know if that input is valid or is an attempt at cheating. If the server is programmed well to do these checks, its internal state remains valid and accurate. A player may modify

its client to do weird things that were not programmed that way initially, that we cannot prevent, but as long as the input that comes from that client is checked, the

other players won't even notice a difference, because what the cheating client sees is merely a local version and the server, which is still intact.

[ 244 ]

www.it-ebooks.info

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]