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 * New animate objects are never placed in the same square with other animated
56 extern void add_map_object(struct World * world, uint8_t type);
57 extern void add_map_objects(struct World * world, uint8_t type, uint8_t n);
61 /* Write map objects chain to "file". */
62 extern void write_map_objects(struct World * world, FILE * file);
64 /* Read from "file" map objects chain; use "line" as char array for fgets() and
65 * expect strings of max. "linemax" length.
67 extern void read_map_objects(struct World * world, FILE * file,
68 char * line, int linemax);
72 /* Free map objects in map object chain starting at "mo_start. */
73 extern void free_map_objects(struct MapObj * mo_start);
77 /* Get pointer to the MapObj struct that represents the player. */
78 extern struct MapObj * get_player(struct World * world);
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);