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 */
21 struct MapObj * next; /* pointer to next one in map object chain */
22 uint8_t id; /* individual map object's unique identifier */
23 uint8_t type; /* ID of appropriate map object definition */
24 uint8_t lifepoints; /* 0: object is inanimate; >0: hitpoints */
25 struct yx_uint16 pos; /* coordinate on map */
32 struct MapObjDef * next;
33 uint8_t id; /* unique identifier of map object type */
34 uint8_t corpse_id; /* id of type to change into upon destruction */
35 char char_on_map; /* map object symbol to appear on map */
36 char * name; /* string to describe object in game log*/
37 uint8_t lifepoints; /* default value for map object lifepoints member */
42 /* Initialize map object defnitions chain from file at path "filename". */
43 extern void init_map_object_defs(struct World * world, char * filename);
47 /* Free map object definitions chain starting at "mod_start". */
48 extern void free_map_object_defs(struct MapObjDef * mod_start);
52 /* Add new object(s) ("n": how many?) of "type" to map on random position(s). */
53 extern void add_map_object(struct World * world, uint8_t type);
54 extern void add_map_objects(struct World * world, uint8_t type, uint8_t n);
58 /* Write map objects chain to "file". */
59 extern void write_map_objects(struct World * world, FILE * file);
61 /* Read from "file" map objects chain; use "line" as char array for fgets() and
62 * expect strings of max. "linemax" length.
64 extern void read_map_objects(struct World * world, FILE * file,
65 char * line, int linemax);
69 /* Free map objects in map object chain starting at "mo_start. */
70 extern void free_map_objects(struct MapObj * mo_start);
74 /* Get pointer to the MapObj struct that represents the player. */
75 extern struct MapObj * get_player(struct World * world);
79 /* Get pointer to the map object definition of identifier "def_id". */
80 extern struct MapObjDef * get_map_object_def(struct World * w, uint8_t id);