_Networking


Back-end "Server" and Front-end "client" are two separate programs that send messages to each other.

By default, both server and client are running on the same computer, but once a server is running, any client with network access to the server can connect -- this allows for a validated high scores list where savescumming and memory injections are not allowed.

Server
  • mostly original code, though could make use of certain aspects of libtcod such as the built-in pathfinding and LOS algorithms
  • all turns are calculated on the server, but server does not render any graphics
  • server only sends information to the client that the player would be able to "know" about. -If an enemy goes outside LOS, server will cease to send that enemy's location info to the client; unless, of course, the player has some other means of tracking that enemy

Client
  • renders the screen based on the information it has available.
  • libtcod, "Doryen Library" is an ideal option due to its great support for colors and lighting
  • only sends player input to server
  • most actions that don't use up any turns can be done without pinging the server, so you can for instance look in your inventory and check the map without having to wait for the server
  • Client front-end can be modded to any extent while still working with a remote default game server

Implementation

Start Game:
  • client sends player base info to server, waits for response
  • server creates player and map, etc, sends initial data set to client

Server / Client Loop:
  • 1. client reads player input command, relays it to server
  • 2. server crunches data until player's action is completed
  • 3. server sends a package containing a list of each applied turn's changed player-known info
  • 4. client renders this sequence of perceived events, then awaits player input
  • 5. goto 1