Author Topic: Authorative Server Questions  (Read 2547 times)

Siretu

  • Guest
Authorative Server Questions
« on: August 08, 2013, 05:42:40 AM »
Hi,

I'd like to know how to set up an authoritative server, where the game logic is handled by the server and the clients just do prediction.

Basically, I want a setup with a master server, showing all the active servers, where players can create their own servers. Then you pick one of them and join. In the game, all the traffic goes through the server. The clients send their actions to the server, which calculates the logic and sends back the state of the game to the clients. The game is basically a RTS.

What I'm wondering is: How should I write the server code?

* Should I trust on having an authoritative "host" player? That seems like a bad idea since the owner of the server might not be on all the time and all other players can't be trusted due to being potential hackers.

* Should I modify the ServerMain.cs code and do all the game logic there? That seems like it'll be frustrating since the ServerMain doesn't have any connection to the Unity API so I lose a lot of Unity's functionality. In addition, it will increase the size of the executable which I thought were supposed to stay lightweight. I'm also not sure how to build the ServerMain.cs into the TNServer.exe. Instructions on that would be nice.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Authorative Server Questions
« Reply #1 on: August 08, 2013, 09:04:58 AM »
As I frequently say, create a game worth hacking, and only then worry about hackers. It's generally a lot easier to create verification / validation than it is to create a fully authoritative environment. For example, instead of having the server always run the logic, you can have the server only validate the data sent through it -- or better yet, have other players validate it. So if you get some noob hacker trying to teleport, other players will see it and go "wtf?" -- and when you see that happen, act accordingly.

To build the server, extract the solution and the server source files that you can find in the ZIP folder -- they goes outside of the Assets folder, in your game project folder.

Siretu

  • Guest
Re: Authorative Server Questions
« Reply #2 on: August 08, 2013, 11:00:50 AM »
Thanks for the reply.

Your saying about first creating the game before worrying about that kind of stuff is something I'd generally agree with. However, networking is such an integrated part of the game. You don't just patch it in later on. Not if you want good and stable multiplayer. So rewriting the entire network code later on is not something I would prefer.

I'm all for verification / validation, however I don't think it is as easy as you think. Let's say a player wants to cast a fireball spell. He sends his order to the server for validation. However, since the server isn't running the game logic, it doesn't know how much mana the unit has. Sure, it could send a request and ask the client, but that breaks the first rule of game network programming. Never trust the client.

Now sure, you could validate this with the other players instead. My game is divided into two teams of 6 players. Assuming an entire team hacked, they could confirm their own team mates' hacks. So maybe you should only be able to validate enemies orders? That has two problems. What if a player denies all enemy orders so they cant e.g cast their fireball. Also, it creates information problems. Let's say a player wants to build a new base. The resource verification is sent to the enemy. The only way the enemy will be able to confirm/deny that the player has enough resources is if the enemy's client knows the resource count. This is something that could possibly be accessed by the enemy.

In other words, just validating without running the logic creates a lot of problems and is a lot of work to get done. Not to mention the extra traffic from sending verifications to several different players to confirm orders.

Because of this, despite what you think is easiest, I would really like to know if there's a good way to run the game logic on the server, and to get it to interact with the Unity API.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Authorative Server Questions
« Reply #3 on: August 08, 2013, 08:38:52 PM »
For a MMO RPG, sure you will certainly want the "mana" checks to be on the server. For an RTS game like you said you were doing though, the rules of the game are fairly rigid. Move from point A to point B. Create unit C. Place a building D. It's up to you though, you know the game you want to make better than I.

You can add anything you want to the TNet server, and expand the Player class to suit your needs.