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 struct MapObj * owns; /* chain of map objects owned / in inventory */
23 uint8_t id; /* individual map object's unique identifier */
24 uint8_t type; /* ID of appropriate map object definition */
25 uint8_t lifepoints; /* 0: object is inanimate; >0: hitpoints */
26 struct yx_uint16 pos; /* coordinate on map */
33 struct MapObjDef * next;
34 uint8_t id; /* unique identifier of map object type */
35 uint8_t corpse_id; /* id of type to change into upon destruction */
36 char char_on_map; /* map object symbol to appear on map */
37 char * name; /* string to describe object in game log*/
38 uint8_t lifepoints; /* default value for map object lifepoints member */
43 /* Initialize map object defnitions chain from file at path "filename". */
44 extern void init_map_object_defs(struct World * world, char * filename);
48 /* Free map object definitions chain starting at "mod_start". */
49 extern void free_map_object_defs(struct MapObjDef * mod_start);
53 /* Add new object(s) ("n": how many?) of "type" to map on random position(s).
54 * New animate objects are never placed in the same square with other animated
57 extern void add_map_object(struct World * world, uint8_t type);
58 extern void add_map_objects(struct World * world, uint8_t type, uint8_t n);
62 /* Write map objects chain to "file". */
63 extern void write_map_objects(struct World * world, FILE * file);
65 /* Read from "file" map objects chain; use "line" as char array for fgets() and
66 * expect strings of max. "linemax" length.
68 extern void read_map_objects(struct World * world, FILE * file,
69 char * line, int linemax);
73 /* Free map objects in map object chain starting at "mo_start. */
74 extern void free_map_objects(struct MapObj * mo_start);
78 /* Move object of "id" from "source" inventory to "target" inventory. */
79 extern void own_map_object(struct MapObj ** target, struct MapObj ** source,
84 /* Get pointer to the MapObj struct that represents the player. */
85 extern struct MapObj * get_player(struct World * world);
89 /* Get pointer to the map object definition of identifier "def_id". */
90 extern struct MapObjDef * get_map_object_def(struct World * w, uint8_t id);
94 /* Move not only "mo" to "pos", but also all map objects owned by it. */
95 extern void set_object_position(struct MapObj * mo, struct yx_uint16 pos);