Next: , Previous: libsys, Up: C API


5.42 libtsk

5.42.1 Overview

View lcov test coverage results on http://www.gnu.org/software/liquidwar6/coverage/src/lib/tsk/index.html.

5.42.2 API

— Function: void lw6tsk_loader_push (lw6tsk_loader_t * loader, char * map_path, char * relative_path, lw6sys_assoc_t * default_param, lw6sys_assoc_t * forced_param, int display_w, int display_h, int bench_value, int magic_number)

loader: loader object

map_path: map-path config entry

relative_path: relative map path

default_param: default parameters to use for load

forced_param: parameters to be forced and their values

display_w: display width

display_h: display height

magic_number: used to calibrate speed

Pushes a load request to the loader. Will stop the current load and push a new one.

Return value: none.

— Function: int lw6tsk_loader_pop (lw6map_level_t ** level, lw6ker_game_struct_t ** game_struct, lw6ker_game_state_t ** game_state, lw6tsk_loader_t * loader)

level: loaded level (out param)

game_struct: loaded struct (out param)

game_state: loaded state (out param)

loader: loader object

Pops data from the loader, will allocate everything dynamically. Function can either return just level or level and game struct and game state (3 of them together). It's safe to use the received level, display it right away, then wait for the rest. If things are loaded fast enough, you just receive everything at once.

Return value: 1 if some data, 0 if none.

— Function: lw6tsk_loader_t * lw6tsk_loader_new (float sleep, char * user_dir, float * progress)

sleep: how many seconds to wait between every poll

user_dir: user directory

progress: progress indicator to use

Creates a new loader. This object is used to do some reputed slow calculus in the background, in a separated thread. Typical example is map loading. This is a high-level objects which encapsulates threads and other wizardry.

Return value: a pointer to the loader, NULL if failed.

— Function: void lw6tsk_loader_free (lw6tsk_loader_t * loader)

loader: the loader to free.

Deletes a loader. Will automatically stop the child thread, free data, and so on.

Return value: none.

— Function: char * lw6tsk_loader_repr (lw6tsk_loader_t * loader)

loader: the loader to represent.

Creates a string which briefly describes the loader.

Return value: a dynamically allocated pointer, must be freed.

— Function: int lw6tsk_loader_get_stage (lw6tsk_loader_t * loader)

loader: the loader to query.

Returns the current stage of the loader.

Return value: 0 if idle, 1 if loading the map from disk, 2 if build dynamic stuff such as game_state.

— Function: int lw6tsk_test (int mode)

mode: 0 for check only, 1 for full test

Runs the tsk module test suite.

Return value: 1 if test is successfull, 0 on error.