Next: , Previous: , Up: Hacker's guide   [Contents][Index]


3.7 Core algorithm

3.7.1 Introduction

Since Liquid War 3 the algorithm to power Liquid War is pretty much unchanged, at least, there has been no revolution, the basic principles remain the same. This has been explained in Liquid War 5 doc, but is repeated here, along with the specific Liquid War 6 stuff.

The very important things to remember are:

3.7.2 Level, game struct, game state and pilot

Most of the algorithm code has something to do with the following types (which are structs):

Most of the time, hacking on the algorithm, changing the gameplay, does not require to touch anything but the code in src/lib/ker.

See See libmap. See See libker. See See libpil.

3.7.3 Getting informations about where fighters are

One of the key functions is lw6ker_game_state_get_fighter_id, which will return the id of a fighter at a given position. Then its companion function lw6ker_game_state_get_fighter_by_id can be called, it will return a lw6ker_fighter_t, which contains the real data.

The type lw6ker_fighter_t is not opaque and can be freely accessed by the caller, which, typically, is a graphics backend trying to display informations. Try and grep for the string “lw6ker_game_state_get_fighter_id” withing the src/lib/gfx source tree for examples.

One thing that is very important when hacking on libker: you should always leave the lw6ker_game_state_t struct in a state that is compatible with a correct usage of public “getters” in src/lib/ker/ker.h. The reason is that this code can be executed by separate threads, more precisely, in “dirty read” mode, the rendering thread will try and display a “game state” while this very “game state” is being updated by another thread.


Next: , Previous: , Up: Hacker's guide   [Contents][Index]