Author Topic: Modifying GameServer for an authoritative server  (Read 263 times)

Zivix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Modifying GameServer for an authoritative server
« on: November 07, 2017, 01:49:53 PM »
Hello, I've loaded up the GameServer solution and have gone through the code a bit, though I'm still not sure of the best way to go about modifying the GameServer to my needs.

So I'm aiming to make a competitive 1v1 turn based tactics game with dummy clients and an authoritative server. Upon startup, the client will connect to a master server(potentially connected to a service like GameSparks) for authentication and to retrieve player data (likely level, all obtained units, currency, stored teams, etc). Any menu actions (modifying or creating new teams, purchasing new units, etc) are triggered by the client, checked server side, and then either completed or rejected by the server. When loading into a match, the server will tell each client which map to load and which units + information to display to the player. I'd like for any action taken by the player to send an RFC out to the server, which will then perform validation and calculations before sending out the necessary information to either or both client(s). For example, if player 1 clicks on their unit, the server triggers an OnClick which will return to the client all information and available options, such as all hexes the unit may move to.

Essentially, what I'm aiming for is a completely untrusted client that will send the proper RFC to the server, which will process the packet(s) and then utilize the classes in a GameLogic folder I will have added to the solution. The functions called from the GameLogic classes will return information that will be packaged into a packet and sent to either one or both clients, along with an RFC id that will trigger the functions necessary to display the data to the user. This is at least my understanding or best guess in regards to what kind of solution I will need.

It sounds like the only modifications I need are to adapt the current RFC based structure such that the server processes the packets and then uses the RFC data to call the proper functions located in the GameLogic classes, and then have the server stream the resulting information or changes to the game state to the clients(Is it possible for the server to be sent one RFC id and then send out a different one because the server and clients are performing different functions? And would it even be necessary?).

My question is how I should go about modifying the GameServer solution to work this way? It seems like a very minimal amount of changes need to be made to the GameServer due to my attempts to make it as flexible as possible(potentially being able to reuse the customized executable for another game with a different set of classes in the GameLogic folder). Do you have any advice regarding which classes and methods to change and a general idea of how to go about changing them?

I hope I have included enough information, as other responses in regards to modifying the GameServer executable have only said it's possible and easy, but that it shouldn't be done; I was hoping I might be able to get a more insightful or thorough answer that provides a better idea of how one would actually go about implementing these changes. In regards to the question of why I need an authoritative server, I want to maintain competitive integrity of the game, as there are only going to be 2 clients per channel. I want to build some safety against cheating into the system from the start, and from my understanding, an authoritative server should be one of the best options for doing so (or at least it seems to be the best fit for my game specifically).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 336
  • -Receive: 1160
  • Posts: 22,121
  • Toronto, Canada
    • View Profile
Re: Modifying GameServer for an authoritative server
« Reply #1 on: November 07, 2017, 05:24:32 PM »
The "it's possible and easy but shouldn't be done" response is because I always advise keeping as much work on the client side as possible. By default, TNet's server is basically there to echo packets, forwarding them to their correct destination in the correct order, and remembering states of everything important. It's like a post office forwarding mail. You can certainly modify the TNet.GameServer class to add your own custom logic for custom packets defined in the TNPacket.cs file, but I generally question the need for it.

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 141
  • Posts: 259
  • TNet Alchemist
    • View Profile
Re: Modifying GameServer for an authoritative server
« Reply #2 on: November 07, 2017, 11:36:06 PM »
How will the server set up the world? Will you be running a headless Unity client? Or is your game simple enough that you can perform all the logic without relying on Unity? I guess just answering those questions will give you a good starting point.

The GameServer has an onCustomPacket handler.

Zivix

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Modifying GameServer for an authoritative server
« Reply #3 on: November 08, 2017, 10:28:19 PM »
The game should be simple enough to run server side, but I was able to have a conversation at length with Aren, which greatly improved my understanding of what TNet is actually capable of as well as how to implement the asset to fit my needs while maintaining the current client-authoritative structure.