Home | Rules | Authors | Mailing lists | Game options and menus | Network game | Command line parameters | Platform specific issues | User levels | Core algorithm | Source code | Bugs | To do | Copying

# Source code

## General remarks

Liquid War 5 is basically a big C program, and this section explains what you can find in source files. I've splitted the source code in many small files for I do not like to have to handle big monolithic sources, but this does not mean Liquid War is very modular. In fact Liquid War 5 is quite bloated with global variables and other ugly stuff 8-(

## List of C source files

### about.c / about.h

contains the code for the about menu.

### advanced.c / advanced.h

Contains the GUI advanced options menu.

### alleg2.c / alleg2.h

Contains some tweaked allegro functions. I wanted to use bitmaps with sevral colors for my fonts, and change some of the allegro default behavior. So rather than modifying the allegro source code right in the library I copied it in this file and then modified it.

### area.c / area.h

Contains functions to create the game area. Basically it contains functions to create the data structures in which the level is stored during the game.

### army.c / army.h

Functions to create the armies, and place them on the battlefield.

### autoplay.c / autoplay.h

Contains the code for the computer AI. This module simulates keypresses from the computer, then the computer is handled as any other player.

### back.c / back.h

This modules displays the background image.

### base.h

Contains global constants used in many different files.

### basicopt.c / basicopt.h

Handles basic command line parameters such as "-v" or "-h".

### bigdata.c / bigdata.h

I had a really hard time with the malloc function with DJGPP under Win95 dos box. I tried to have it working for hours and hours but my program kept being buggy. So I decided to allocate the memory myself, in a memory zone I create at startup. This is what this module does: create a huge memory zone and then give parts of it to the rest of the program.

### code.c / code.h

This file contains the code to handle key presses during the game. That's to say the pause key for instance.

### config.c / config.h

Contains everything that is related to the game configuration. This module contains in global variables all the parameters that are stored in the config file.

### connect.c / connect.h

Contains code for the "connect" menu which displays which players are connected to the server, before the game actually starts.

### controls.c / controls.h

Contains the code for the controls menu.

### cursor.c / cursor.h

Contains the code to init the cursors and place them on the battlefield at the beginning of the game.

### decal.c / decal.h

This module makes the link between teams and players. Its coding is quite ugly, for some modules in LW assume that when 2 teams are playing they are always teams 0 and 1. So when 3 teams are playing are playing and the second team loses, one has to make team 2 become team 1. That's what this module is for.

### dialog.c / dialog.h

Contains code for standard dialog boxes.

### disk.c / disk.h

Contains all the code to access data from the hard drive. In fact, all the HD access is done at startup.

### disp.c / disp.h

Contains functions to display the battlefield.

### distor.c / distor.h

This module contains code to create the "wave effect". It uses a lot of data tables, and is quite complicated to understand...

### dnsutil.c / dnsutil.h

Wrapper code to issue DNS requests, without having to handle the hostent struct.

### error.c / error.h

Contains functions to display error messages once the game is in graphical mode.

### exit.c / exit.h

Contains code that is executed when the game ends, it shuts down Allegro and displays messages on the console.

### fighter.c / fighter.h

Contains code to move the armies, once the gradient has been calculated.

### game.c / game.h

Contains the main game loop.

### gfxmode.c / gfxmode.h

Contains code to set up the various video modes, and defines which modes are available for each platform.

### glouglou.s / glouglou.h

Assembly module, it is a replacement for some functions of distor.c. It goes much faster but does the same.

### grad.c / grad.h

This module calculates the gradient for each team. One could say it's the "kernel" of the game, since most of the CPU time is spent in this module (except if you have a slow display...).

### graphics.c / graphics.h

Code for the graphic options menu.

### help.c / help.h

Generic functions to display the various help pages.

### httputil.c / httputil.h

Low level functions to handle http requests to www.ufoot.org.

### info.c / info.h

Contains code to display the info bar. The info bar is the bar which display the time left and the amount of players for each team while the game is running.

### init.c / init.h

Contains code to initialize Allegro with proper options and analyze failures.

### internet.c / internet.h

Contains the code for the "Search for Internet games" menu, where one can pick up a running server automatically with the help of the meta-server.

### joystick.c / joystick.h

Contains code to support joystick input. It wraps joystick buttons to virtual keyboard keys, so that joystick and keyboard behave exactly the same.

### keyboard.c / keyboard.h

Contains code to handle key presses.

### keyexch.c / keyexch.h

Functions to send and receive keys to the server. Used on the client.

### lang.c / lang.h

Contains code to handle language dependant stuff.

### langen.c / langen.h

Contains code to handle English specific stuff.

### langfr.c / langfr.h

Contains code to handle French specific stuff.

### language.c / language.h

Contains the code for the "Language" menu.

### level.c / level.h

Contains code for the menu where the player can select a level and its options (texture or color).

### log.h

Common header for logcli.c and logsrv.c.

### logcli.c

Contains code to display messages on the console. It's usefull for console may have different behaviors when the games is used on different platforms. This file is used to compile the client.

### logsrv.c

Contains code to display messages on the console. This file is used to compile the server, which does not use Allegro at all.

### main.c / main.h

The file where the main C function is declared. Doesn't contain much except calling init functions and running the GUI.

### map.c / map.h

Contains code to load the maps from a datafile raw data or a user defined bitmap to a usable structure in RAM.

### menu.c / menu.h

Contains the code for the main menu.

### mesh.c / mesh.h

Contains code to set up a usable mesh with a map. Mesh are re-calculated at each time a new game is started, the reason for this being that meshes are *very* big so it would not be reasonnable to save them directly on the HD.

### message.c / message.h

Provides an API to display messages during the game. Very useful if you want to debug the game: you can trace and display anything.

### monster.s / monster.h

Assembly functions to speed-up the game. It's a replacement for some fighter.c functions.

### mouse.c / mouse.h

Wraps the mouse movements to virtual keyboard keys. This way the mouse can be used to control the players.

### move.c / move.h

Provides an API to move the cursors.

### music.c / music.h

Contains the code to control MIDI playback.

### netconf.c / netconf.h

Code to send and receive the config of the clients over the network.

### netgame.c / netgame.h

Contains the code for the net game menu.

### netkey.c / netkey.h

Contains some tools to manipulate key strokes over the network.

### netmap.c / netmap.h

Code to send and receive the maps over the network.

### netmess.c / netmess.h

Contains a parser to interpret plain text messages. Used when exhanging information over the network.

### netplay.c / netplay.h

Contains the code to set up and start network games.

### network.c / network.h

Contains some network related functions and constants used on the client.

### options.c / options.h

Contains the code for the options menu.

### palette.c / palette.h

Contains function to set up the current color palette. Liquid War uses different palettes, depending on what colors are chosen for teams.

### parser.c / parser.h

Contains code to parse and analyze the command line parameters.

### pion.c / pion.h

Contains code to display the cursors.

### play.c / play.h

Contains the code which ties the menu to the main gameloop.

### profile.c / profile.h

Provides tools to calculate how fast the game is runnning and what operations slow it down.

### protocol.c / protocol.h

Contains the sequence of messages send and recevied by the client when connecting on the server.

### rules.c / rules.h

Code for the rules menu.

### score.c / score.h

Functions to display the scores at the end of the game.

### server.c / server.h

Main code for the server (equivalent of main.c for the client).

### sock2cli.c

Code used to wrap low-level network function on the client.

### sock2gen.h

Header for sock2cli.c and sock2srv.c.

### sock2srv.c

Code used to wrap low-level network function on the server.

### sockdos.c

Network API for DOS.

### sockex.c

Netowrk routines shared by sockunix and sockw32.

### sockgen.h

header for sockdos.c, sockunix.c and sockw32.c.

### sockunix.c

Network API for UNIX.

### sockw32.c

Network API for Win32.

### sound.c / sound.h

Functions to play sound.

### speeds.c / speeds.h

Contains the code for the speeds menu.

### spread.s / spread.h

Contains assembly replacements for some functions of grad.c. These replacements do the same than the original ones from grad.c, but faster. Could still be optimized.

### srvchan.c / srvchan.h

Code used to handles channels on the server. A channel is associated to a given computer and may manage several teams.

### srvcont.c / srvcont.h

Global network controler used on the server.

### srvteam.c / srvteam.h

Code used to handle teams on the server.

### srvtime.c / srvtime.h

Code used to handle time on the server, where Allegro's functions are not available.

### startinf.c / startinf.h

Contains struct and tools to handle some network informations while starting a network game.

### startup.c / startup.h

Analyzes the command line parameters and stores them into global variables.

### team.c / team.h

Code for the team menu.

### texture.c / texture.h

Contains code to handle textures. Textures are stored in a special format which uses 5 bits per pixel.

### thrddos.c

Provides fake thread support under DOS. This module is here only to make compilation easier.

### thrdgen.h

Header fo,r thrdunix.c and thrdw32.c.

### thrdunix.c

Provides thread support on UNIX.

### thrdw32.c

Provides thread support on Win32.

### ticker.c / ticker.h

Sets up a timer callback.

### time.c / time.h

Functions to know how long the game has been running, knowing that it can be interrupted.

### volume.c / volume.h

Code for the sound menu.

### disk.c / disk.h

Contains all the code to access data from the hard drive. In fact, all the HD access is done at startup.

### watchdog.c / watchdog.h

This module waits for "secret codes" to be typed while the game is running, and traps them.

### wave.c / wave.h

Code for the wave menu.

### wwwcli.c / wwwcli.h

Code used on the client to communicate with www.ufoot.org.

### wwwsrv.c / wwwsrv.h

Code used on the server to communicate with www.ufoot.org.

This documentation is also available on: www.ufoot.org/liquidwar.