Server

From WinBolo

Jump to: navigation, search

The server design is very similar to the frontend/backend design the client uses. More information to be added to here.


Contents

Modules/Files

servercore.c

Runs the game simulation. Similar to screen.c. The two big differences are:

  • Rather then one tank ADT contains a tank ADT per player.

Main functions:

/*********************************************************
*NAME:          serverCoreCreate
*AUTHOR:        John Morrison
*CREATION DATE: 10/8/99
*LAST MODIFIED:  5/5/00
*PURPOSE:
*  Creates a new server. Returns FALSE if an error occured
*  such as error loading map
*
*ARGUMENTS:
*  fileName - Points to the map file
*  game - The game type-Open/tournament/strict tournament
*  hiddenMines - Are hidden mines allowed
*  srtDelay    - Game start delay (50th second increments)
*  gmeLen      - Length of the game (in 50ths)
*                (-1 =unlimited)
*********************************************************/
bool serverCoreCreate(char *fileName, gameType game, bool hiddenMines, int srtDelay, long gmeLen);

Starts the simulation.

void serverCoreDestroy()

Shuts down the simulation.

void serverCoreGameTick();

Runs the game simulation. Called every 20ms. Front ends that get behind must call repeatedly till it is caught up.

Also contains a bunch of helper functions for the server front end. e.g.

long serverCoreGetTimeGameCreated(void);
void serverCoreGetMapName(char *value);
BYTE serverCoreGetNumNeutralBases(void);
...
etc.

It may be possible to one day combine screen.c and servercore.c

servernet.c

Equivilient to network.c for a game client. Handles processing of incoming packets etc. todo: more details.

See also Networking.

servermain.c

Main application.

  • Sets up game - In the main function.
  • Runs game - In (serverGameTimer();)
  • Shuts game down - In the main() function
  • Listens for keyboard commands and signals. (on linux)

serverfrontend.c

A front end stub that null ops all frontend callback functions required by the backend.

servermessage.c

Displays messages to the console or writes to the console log file.

servertransport.c

Low level sock communication functions for sending data to/from the network.

threads.c

Provides server thread synchronization code (i.e. mutex) and threadsGetContext(). For more information see Bolo#Client vs Server


Debugging the Linux Server

Within the makefile, make sure you have the following line uncommented. This will denote that the binary is in debug mode.

CFLAGS = -g `sdl-config --cflags`

In your shell before executing LinBoloDS, execute the following command. This will set the max coredump file size.

ulimit -c 100000

Then, when you have a core file (assuming it and the binary is in the same directory), execute the below. The first command runs the debugger and the second command runs a backtrace.

# gdb linbolods <corefile>
# bt
Personal tools