0
\$\begingroup\$

I am currently working on a networked first person shooter. I have created a server implementation that can synchronize player data. But while implementing a damage system, I realized that I almost simply sent a packet with

PLAYER DAMAGE [target id] [amount]

But that would likely be open for any player to save a list of IDs and inject that packet to damage every ID. Unfortunately the server is unable to know what the environment is like -- meaning it cannot check if there is something between the two players or likewise.

How would I keep this from being possible?

\$\endgroup\$
  • \$\begingroup\$ If your server doesn't know what the environment is like, how does it keep players' views of the game world synchronised? \$\endgroup\$ – Anko May 21 '15 at 23:20
  • \$\begingroup\$ @Anko The client side is unmodifiable, so the server just stores the player position and distributes it to the other players. \$\endgroup\$ – rtainc May 22 '15 at 1:43
2
\$\begingroup\$

I don't understand why you use server client model, if your server has 0 authority and lacks capability to enforce rules. Your server have to know the map. How else could it stop player from walking through walls. You say "client side is unmodifiable", I say you are misinformed. There is no such thing as "unmodifiable client". You are trusting too much on client and without map/world awareness, the server cannot do anything.

Heres example of client server communication:

Client: "I am clicking my mouse 1 now"

Server:"Ok, based on my memory, you stand at x y and aim towards x2 y2, you click mouse 1 and your selected weapon is desert eagle with 2 bullets in clip, lets shoot and check if you hit someone"

Server-again: "based on calculations, player1 hit player2, so lets update everyone to let them know this happened."

See the difference? If you wanna have authoritative server, you have to give more information for it. This is the way, the modern server client games work. Client is just a remote input device with display. Server is the one who does all the decisions. Your client should not be able to send damage packets or kill packets or anything at all. Only packets, that tell the server what the client did after last update.

\$\endgroup\$
  • \$\begingroup\$ See, that is almost exactly the issue. The game has almost completely been made in Unity, and remaking the game in another engine would be completely unavailable at this point. And in Unity, there is no logical way for the server to know the environment. \$\endgroup\$ – rtainc May 22 '15 at 23:10
  • \$\begingroup\$ Unity does not restrict this from you. Embed server code in your game. When client connects, spawn player to spawn point, local and remote. Now you know on server side, where the player is and what happens if he moves forward or left. Wait for player input update. When it comes, check the input and move local players according to that data and send updated positions to remote players. This way, you can let Unity use physics, triggers and everything, to be authoritative. You can definitely do it in Unity. I just feel like you should do a bit reading about authoritative servers or server clients \$\endgroup\$ – Katu May 23 '15 at 5:12
  • \$\begingroup\$ The server is not made inside of Unity. My goal up until now was to make the server code completely modifiable to encourage fun modifications on player-hosted servers. I assume it would be better to just make the server inside of Unity at the cost of modifiable servers. \$\endgroup\$ – rtainc May 25 '15 at 1:05
  • \$\begingroup\$ I have the client made with Unity, and the server written in just pure C#, this does not restrict the server from having knowledge of the world. For example my client has no knowledge of the world unless the server informs the client what the world is like. Yes my client has the specific algorithms to make the bandwidth cost small by just sending a seed on how to generate certain stuff. Combat for example, should be server-side if you don't want the information to be tampered with. If the server only acts as a relay, you're going to have a bunch of problems with people tampering with the data. \$\endgroup\$ – Frement Aug 26 '16 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.