Next: libvox, Previous: libsys, Up: C API [Contents][Index]

### 5.48 libtsk

#### 5.48.1 Overview

View lcov test coverage results on http://www.ufoot.org/liquidwar/v6/doc/coverage/src/lib/tsk/index.html.

#### 5.48.2 API

Function: void lw6tsk_loader_push_ldr (lw6tsk_loader_t * loader, const char * map_path, const 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

  bench_value: bench value, reflecting computer CPU power

  magic_number: used to calibrate speed

  Pushes a load request to the loader. Will stop the current load and push a new one. The request concerns a map which should be loaded from a map directory on the filesystem.

  Return value: none.

Function: void lw6tsk_loader_push_gen (lw6tsk_loader_t * loader, const char * seed, int display_w, int display_h, int bench_value, int magic_number)

  loader: loader object

  seed: seed string used to create the map

  display_w: display width

  display_h: display height

  bench_value: bench value, reflecting computer CPU power

  magic_number: used to calibrate speed

  Pushes a load request to the loader. Will stop the current load and push a new one. The request is forwarded to the pseudo-random map generation module.

  Return value: none.

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

  level: loaded level (out param)

  game_struct: loaded struct (out param)

  game_state: loaded state (out param)

  bench_value: the bench_value used (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, volatile 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 (const 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_register (int mode)

  mode: test mode (bitmask)

  Registers all tests for the libtsk module.

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

Function: int lw6tsk_test_run (int mode)

  mode: test mode (bitmask)

  Runs the `tsk` module test suite, testing most (if not all...) functions.

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

Struct: lw6tsk_loader_s

  Loader object, allows asynchronous map loading.

Member of lw6tsk_loader_s: id

  Type: `u_int32_t`

  Definition: `u_int32_t lw6tsk_loader_s::id`

  The id of the object, this is non-zero and unique within one run session, incremented at each object creation.

Member of lw6tsk_loader_s: thread

  Type: `lw6sys_thread_handler_t *`

  Definition: `lw6sys_thread_handler_t* lw6tsk_loader_s::thread`

  Thread used to run the loader.

Member of lw6tsk_loader_s: data

  Type: `void *`

  Definition: `void* lw6tsk_loader_s::data`

  Data used by the loader.

Next: libvox, Previous: libsys, Up: C API [Contents][Index]