Question about what code goes on servers

Started by
0 comments, last by frob 8 years, 3 months ago

Disclaimer: I have no multiplayer (server) coding experience.

I have learned how to program offline games with some proficiency, and am now looking to make a multiplayer game, but I am confused as to what code exactly goes on the server.

Do all graphics go on client side? Do some go on server side? Can you do a little bit on both?

what other kind of things might go on server side?

Advertisement
The details depend on the game. What are the servers doing? What are the clients doing?

Usually the servers need some authentication (so you know you are talking to the right people), some logic about account information and such. You always want to provide a server that runs as a service between your clients and your databases, never allowing a client direct access to databases.

Graphics are usually entirely on the client side. The server is just a box in a datacenter with no real display attached, so it doesn't need to do anything with graphics. Unless you've got a drawing guessing game where the server needs to know what was drawn, so the server keeps a copy of that image to be transferred.

For some games the servers are nothing more than high score leaderboards, matchmakers, and a chat system. Once a game is put together the servers are out of the loop and the clients play among themselves, then at the end of the game the clients come back and all report the results to the server. The server verifies that the players all agree on the results and files the stats away for the future.

For some games all information is shared and common, an online chess server could blindly transmit all the game board information to anyone who asks. But it still needs the server to restrict access so an attacker doesn't have unfettered access to the database directly; they still need to authenticate and you still need to make sure good data hygiene practices are followed.

In general you want to transfer as little as possible, only what is necessary to the clients. In games with 3D worlds you should assume the clients have cheated, replaced textures with transparency, added outlines and highlights, so with that sort of assumption you only notify the client with positions of objects they can actually see. In that case, it means the server doesn't need to display the graphics but know enough about the world to do line-of-sight tests and know if the object should be visible or hidden behind walls, and only if visible should be transferred.

This topic is closed to new replies.

Advertisement