#include <stdio.h> /* for FILE typedef */
+#include <stdint.h> /* for uint8_t */
#include "yx_uint16.h" /* for yx_uint16 coordinates */
struct World;
struct Player
{
struct yx_uint16 pos;
- unsigned char hitpoints;
+ uint8_t hitpoints;
};
struct MapObj
{
void * next;
+ uint8_t id; /* Unique identifier of individual map object. */
char type; /* Map object type identifier (see MapObjDef.id). */
struct yx_uint16 pos; /* Coordinate of object on map. */
};
struct Monster
{
struct MapObj map_obj;
- unsigned char hitpoints;
+ uint8_t hitpoints;
};
struct MonsterDef
{
struct MapObjDef map_obj_def;
- unsigned char hitpoints_start; /* Hitpoints each monster starts with. */
+ uint8_t corpse_id; /* ID of object type killed monster changes to. */
+ uint8_t hitpoints_start; /* Hitpoints each monster starts with. */
};
+/* Free item / monster definitions in map object chain starting at "md_start" /
+ * "id_start".
+ */
+extern void free_item_defs(struct ItemDef * id_start);
+extern void free_monster_defs(struct MonsterDef * md_start);
+
+
+
/* Build into memory starting at "start" chain of "n" map objects of type
* "def_id".
*/
extern void * build_map_objects(struct World * world, void * start, char def_id,
- unsigned char n);
+ uint8_t n);
*/
extern uint8_t write_map_objects(struct World * world, void * start,
FILE * file);
-extern uint8_t read_map_objects(struct World * world, void * start, FILE * file);
+extern uint8_t read_map_objects(struct World * world, void * start,
+ FILE * file);
+/* Free items / monsters in map object chain starting at "item" / "monster". */
+extern void free_items(struct Item * item);
+extern void free_monsters(struct Monster * monster);
/* Get pointer to the map object definition of identifier "def_id". */
extern struct MapObjDef * get_map_obj_def(struct World * world, char def_id);