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);
61 /* Add new object(s) ("n": how many?) of "type" to map on random position(s). */
62 extern void add_map_object(struct World * world, uint8_t type);
63 extern void add_map_objects(struct World * world, uint8_t type, uint8_t n);
67 /* Write map objects chain to "file". */
68 extern void write_map_objects(struct World * world, FILE * file);
70 /* Read from "file" map objects chain; use "line" as char array for fgets() and
71 * expect strings of max. "linemax" length.
73 extern void read_map_objects(struct World * world, FILE * file,
74 char * line, int linemax);
78 /* Free map objects in map object chain starting at "mo_start. */
79 extern void free_map_objects(struct MapObj * mo_start);
83 /* Get pointer to the map object definition of identifier "def_id". */
84 extern struct MapObjDef * get_map_object_def(struct World * w, uint8_t id);