3 * Structs for objects on the map and their type definitions, and routines to
4 * initialize these and load and save them from/to files.
12 #include <stdio.h> /* for FILE typedef */
13 #include <stdint.h> /* for uint8_t */
14 #include "yx_uint16.h" /* for yx_uint16 coordinates */
19 /* Player is non-standard: single and of a hard-coded type. */
30 struct MapObj * next; /* pointer to next one in map object chain */
31 uint8_t id; /* individual map object's unique identifier */
32 uint8_t type; /* ID of appropriate map object definition */
33 uint8_t lifepoints; /* 0: object is inanimate; >0: hitpoints */
34 struct yx_uint16 pos; /* coordinate on map */
41 struct MapObjDef * next;
42 uint8_t id; /* unique identifier of map object type */
43 uint8_t corpse_id; /* id of type to change into upon destruction */
44 char char_on_map; /* map object symbol to appear on map */
45 char * name; /* string to describe object in game log*/
46 uint8_t lifepoints; /* default value for map object lifepoints member */
51 /* Initialize map object defnitions chain from file at path "filename". */
52 extern void init_map_object_defs(struct World * world, char * filename);
56 /* Free map object definitions chain starting at "mod_start". */
57 extern void free_map_object_defs(struct MapObjDef * mod_start);
60 /* Build chain of "n" map objects of "tpye" to start at "mo_ptr_ptr". */
61 extern struct MapObj ** build_map_objects(struct World * w,
62 struct MapObj ** mo_ptr_ptr,
63 uint8_t type, uint8_t n);
66 /* Write map objects chain to "file". */
67 extern void write_map_objects(struct World * world, FILE * file);
69 /* Read from "file" map objects chain; use "line" as char array for fgets() and
70 * expect strings of max. "linemax" length.
72 extern void read_map_objects(struct World * world, FILE * file,
73 char * line, int linemax);
77 /* Free map objects in map object chain starting at "mo_start. */
78 extern void free_map_objects(struct MapObj * mo_start);
82 /* Get pointer to the map object definition of identifier "def_id". */
83 extern struct MapObjDef * get_map_object_def(struct World * w, uint8_t id);