/* Give short description of command ("dsc_short"), get long description. */
extern char * get_command_longdsc(char * dsc_short);
-
-
/* Read in CommandDB from file "config/commands" to world.cmd_db. */
extern void init_command_db();
/* Return keycode to action of "name" if available in current window config. */
extern uint16_t get_available_keycode_to_action(char * name);
-
-
/* Control the player character, either via action id "action" or pressed "key".
* Return 1 on success, 0 if no appropriate action to trigger was found.
*/
extern uint8_t player_control_by_key(int key);
extern uint8_t player_control_by_id(int action);
-
-
/* Control via "key" active window's geometry / keybindings in respective config
* view.
*/
extern uint8_t wingeom_control(int key);
extern uint8_t winkeyb_control(int key);
-
-
/* Call by "key" further game / window management actions that don't influence
* the player character. If the "quit" action is called, return 1 (instead of
* exiting directly).
extern void draw_win_keybindings_winconf_geometry(struct Win * win);
extern void draw_win_keybindings_winconf_keybindings(struct Win * win);
-
-
/* Routines to draw windows' configuration views. */
extern void draw_winconf_keybindings(struct Win * win);
extern void draw_winconf_geometry(struct Win * win);
char * name; /* name of functionality bound to keycode */
};
-
-
/* Wrapper to keybinding chain, contains some keybinding editing metadata. */
struct KeyBiData
{
/* Return "n"-th keybinding in keybindings chain from "kb_p" on. */
extern struct KeyBinding * get_keyb_of_n(struct KeyBinding * kb_p, uint16_t n);
-
-
/* Initialize/save keybindings data from/to file at "path" to/from keybindings
* data pointer "kbd".
*/
/* Free keybinding chain starting at "kb_start". */
extern void free_keybindings(struct KeyBinding * kb_start);
-
-
/* Mark keybinding selected for modification as being edited, get user input to
* modify it, then unmark it again. Ensure there are max. three digits in the
* keycode ASCII representation.
*/
extern struct Map init_map();
-
-
/* Try to change the view center of map into directino described by "d" (north
* = "N", east = "E" etc.).
*/
extern void map_scroll(char d);
-
-
/* Center map on player. */
extern void map_center();
*/
extern uint8_t move_actor(struct MapObj * actor, char d);
-
-
/* Wrapper for using move_actor() on the MapObj representing the player; updates
* the game log with appropriate messages on the move attempt and its results;
* turns over to turn_over() when finished.
*/
extern void move_player(char d);
-
-
/* Make player wait one turn, i.e. only update_log with a "you wait" message
* and turn control over to the enemy.
*/
extern void player_wait();
-
-
/* Check if coordinate pos on (or beyond) map is accessible to map object
* movement.
*/
extern char is_passable(struct Map * map, struct yx_uint16 pos);
-
-
/* Make player drop to ground map ojbect indexed by world.inventory_select. */
extern void player_drop();
/* Write representation of "mo" and all of the map objects it owns to "file". */
static void write_map_object(FILE * file, struct MapObj * mo);
-
-
/* Return pointer to map object of "id" in chain starting at "ptr". */
static struct MapObj * get_map_object(struct MapObj * ptr, uint8_t id);
struct yx_uint16 pos; /* coordinate on map */
};
-
-
struct MapObjDef
{
struct MapObjDef * next;
/* Initialize map object defnitions chain from file at path "filename". */
extern void init_map_object_defs(char * filename);
-
-
/* Free map object definitions chain starting at "mod_start". */
extern void free_map_object_defs(struct MapObjDef * mod_start);
-
-
/* Add new object(s) ("n": how many?) of "type" to map on random position(s).
* New animate objects are never placed in the same square with other animated
* ones.
extern void add_map_object(uint8_t type);
extern void add_map_objects(uint8_t type, uint8_t n);
-
-
/* Write map objects chain to "file". */
extern void write_map_objects(FILE * file);
*/
extern void read_map_objects(FILE * file, char * line, int linemax);
-
-
/* Free map objects in map object chain starting at "mo_start. */
extern void free_map_objects(struct MapObj * mo_start);
-
-
/* Move object of "id" from "source" inventory to "target" inventory. */
extern void own_map_object(struct MapObj ** target, struct MapObj ** source,
uint8_t id);
-
-
/* Get pointer to the MapObj struct that represents the player. */
extern struct MapObj * get_player();
-
-
/* Get pointer to the map object definition of identifier "def_id". */
extern struct MapObjDef * get_map_object_def(uint8_t id);
-
-
/* Move not only "mo" to "pos", but also all map objects owned by it. */
extern void set_object_position(struct MapObj * mo, struct yx_uint16 pos);
extern void * try_malloc(size_t size, char * f);
extern void * try_calloc(size_t nmemb, size_t size, char * f);
-
-
/* Check if tempfile "path" exists, and if so, exit with explanation that. */
extern void check_tempfile(char * path);
/* If one and only one of files at "p1", "p2" exists, fail with explanation. */
extern void check_files_xor(char * p1, char * p2);
-
-
/* Save / load / unload (free) / reload interface configuration data. */
extern void save_interface_conf();
extern void load_interface_conf();
extern void unload_interface_conf();
extern void reload_interface_conf();
-
-
/* Update game log by appending "text", or by appending a "." if "text" is the
* same as the last one passed.
*/
extern void update_log(char * text);
-
-
/* Return the offset necessary to center a map of "mapsize" on position "pos" in
* a frame of "framesize.
*/
extern uint16_t center_offset(uint16_t pos,
uint16_t mapsize, uint16_t framesize);
-
-
/* Record last player "action" in game record file "record, increment the game
* turn and trigger enemy movement.
*/
extern void turn_over(char action);
-
-
/* Save or load current game data to / from file "savefile". */
extern void save_game();
extern void load_game();
-
-
/* Return a random position on the map "map" that is passable (as determined by
* is_passable().
*/
extern struct yx_uint16 find_passable_pos(struct Map * map);
-
-
/* Navigate (as far as possible) up (dir=='u') or (else) down in player's
* inventory selection.
*/
extern void try_fwrite(void * ptr, size_t size, size_t nmemb, FILE * stream,
char * f);
-
-
/* Wrapper to calling fgets() from function called "f". The return code of
* fgets() is returned unless it is NULL *and* ferror() indicates that an error
* occured; otherwise end of file is assumed and NULL is returned properly.
*/
extern char * try_fgets(char * line, int size, FILE * file, char * f);
-
-
/* Wrapper to successive call of fclose() from function called "f" on "file",
* then unlink() on file at "p2" if it exists, then rename() on "p1" to "p2".
* Used for handling atomic saving of files via temp files.
extern void try_fclose_unlink_rename(FILE * file, char * p1, char * p2,
char * f);
-
-
/* Wrapper: Call textfile_sizes() from function called "f" to get max line
* length of "file", exit via exit_err() with trouble_msg()-generated error
* message on failure.
*/
extern uint16_t get_linemax(FILE * file, char * f);
-
-
/* Learn from "file" the largest line length (pointed to by "linemax_p"; length
* includes newline chars) and (pointed to by "n_lines_p" if it is not set to
* NULL) the number of lines (= number of newline chars).
extern uint8_t textfile_sizes(FILE * file, uint16_t * linemax_p,
uint16_t * n_lines_p);
-
-
/* These routines for reading values "x" from / writing values to "file" ensure
* a defined endianness and consistent error codes: return 0 on success and 1 on
* fgetc()/fputc() failure.
/* Exit orderly, clean up. */
extern void exit_game();
-
-
/* If "err" == 0, do nothing. Else, clean up and exit with an error message that
* consists, first, of "msg" or (if "msg" is a NULL pointer) a generic "Details
* unknown", secondly of "err" as the "internal error code", and thirdly of
/* Return 16-bit number pseudo-randomly generated. */
extern uint16_t rrand();
-
-
/* Set seed that rrand() starts from. */
extern void rrand_seed(uint32_t new_seed);
/* Return string "prefix" + "id"; malloc()'s string, remember to call free()! */
static char * string_prefixed_id(char * prefix, char id);
-
-
/* Create Winconf, init ->view/height_type/width_type to 0, ->id to "id". */
static void create_winconf(char id, struct WinConf * wcp);
/* Free data pointed to inside WinConf struct. */
static void free_winconf_data(char id);
-
-
/* Write geometry of a window to its WinConf, as positive or negative values
* (dependent on state ofWinConf->height_type / WinConf->width_type).
*/
static void set_winconf_geometry(char id);
-
-
/* Get WinConf by "id"; get id of WinConf mothering "win". */
static struct WinConf * get_winconf_by_id(char id);
extern struct WinConf * get_winconf_by_win(struct Win * win);
extern struct Win * get_win_by_id(char id);
-
-
/* Create/initialize (from config files)/free Winconf structs. */
extern void init_winconfs();
extern void free_winconfs();
extern void init_wins();
-
-
/* Toggle windows in world.wins in the order desribed by the first line of
* config/windows/toggle_order_and_active, wherein each character should
* correspond to one window whose ID is found in world.winconf_ids. Unknown
*/
extern void sorted_wintoggle_and_activate();
-
-
/* Save all window's configurations to their configuration files. */
extern void save_win_configs();
-
-
/* Toggle "window configuration" view for active window. This also sets sensible
* values for Win->center for the various configuration views (y=0, x=0 for
* winconf_geometry and x= for winconf_keys).
*/
extern void toggle_winconfig();
-
-
/* Toggle interpretation type for active Win's width/height in WinConf. Width
* only toggles to 1 if terminal window is at least as wide as WinConf->width.
*/
extern void toggle_win_height_type();
extern void toggle_win_width_type();
-
-
/* Toggle display of a window identified by "id". */
extern void toggle_window(char id);
-
-
/* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"),
* subject to the limitations provided by the window manager via
* reset_pad_offset().
*/
extern void scroll_pad(char dir);
-
-
/* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
* vertically ("change = "+"/"-") by one cell size, subject to the limitations
* provided by the window manager via resize_active_win().
*/
static void refit_pad();
-
-
/* Update geometry (sizes, positions) of window "w" and its successors in the
* window chain. For the positioning algorithm place_win() is used.
*/
static void update_wins(struct Win * w);
static void place_win(struct Win * w);
-
-
/* Draw scroll hint (a line saying that there are "dist" more elements of
* "unit" further into the direction symbolized by the "dir" char) into virtual
* screen pad, onto an appropriate edge of either a window or the screen; the
static void winscroll_hint(struct Win * w, char dir, uint16_t dist);
static void padscroll_hint(char dir, uint16_t dist);
-
-
/* Draw contents of all windows in window chain from window "w" onwards. */
static void draw_wins(struct Win * w);
-
-
/* draw_win_borderlines() draws the vertical and horizontal borders of window
* "w" sans corners into the virtual screen "pad", and draws the top border
* line as the windows' title bar (highlighted if the window is described
WINDOW * pad);
static void draw_wins_bordercorners(struct Win * w, WINDOW * pad);
-
-
/* Shift active window forwards / backwards in window chain. */
static void shift_win_forward();
static void shift_win_backward();
extern void init_win(struct Win ** wp, char * title, int16_t height,
int16_t width, void * func);
-
-
/* Free allocated memory for an initialized Win / WinMeta structs. */
extern void free_winmeta();
extern void free_win(struct Win * win);
-
-
/* Append/suspend window "w" to/from chain of visible windows below "wmeta".
* Appended windows will become active. Suspended active windows will move the
* active window selection to their successor in the window chain or, failing
extern void append_win(struct Win * w);
extern void suspend_win(struct Win * w);
-
-
/* Apply scrolling offset "new_offset" to virtual screen if it is sane, i.e.
* it's equal/greater zero and does not push the view (further) beyond the
* virtual screen's border. If the view is already beyond the virtual screen's
*/
extern void reset_pad_offset(uint16_t new_offset);
-
-
/* Apply new size "size" to the active window, but only if it provides for at
* least one cell width/height and is in height at least one cell smaller than
* the screen's vertical height (to provide space for the title bar). Does
*/
extern void resize_active_win(struct yx_uint16 size);
-
-
/* Cycle active window selection forwards ("dir" == "f") or backwards (any
* other "dir"). Wrap around in the windows chain if start / end of it is met.
* Does nothing if no window is active.
*/
extern void cycle_active_win(char dir);
-
-
/* Move active window forwards ("dir" == "f") or backwards (any other "dir").
* Wrap around in the window chain if start / end of it is met. Does nothing if
* no window is active.
*/
extern void shift_active_win(char dir);
-
-
/* Draw virtual screen including all windows. Also add scroll hints for where
* the edges of the terminal screen hit non-edges of and inside the virtual
* screen. Then update the terminal screen.
/* Return 1 if two yx_uint16 coordinates at "a" and "b" are equal, else 0. */
extern uint8_t yx_uint16_cmp(struct yx_uint16 * a, struct yx_uint16 * b);
-
-
/* Return yx_uint16 coordinate one step from coordinate yx in direction "dir"
* (east: 'E', west: 'W', north: 'N', south: 'S').
*