X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fmap_objects.h;h=2307fb51fe776bb09f52e816b7294be86554dd49;hb=cff4ca6783209fdf4272ae83b23b18e7ddf2a4df;hp=7fcf1c7df63087df887c2076cffb3cbe7a99c223;hpb=b9082c113c43afe5c6a11c2b72f845ee2f8c6aea;p=plomrogue diff --git a/src/map_objects.h b/src/map_objects.h index 7fcf1c7..2307fb5 100644 --- a/src/map_objects.h +++ b/src/map_objects.h @@ -10,6 +10,7 @@ #include /* for FILE typedef */ +#include /* for uint8_t */ #include "yx_uint16.h" /* for yx_uint16 coordinates */ struct World; @@ -19,7 +20,7 @@ struct World; struct Player { struct yx_uint16 pos; - unsigned char hitpoints; + uint8_t hitpoints; }; @@ -29,6 +30,7 @@ struct Player 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. */ }; @@ -41,7 +43,7 @@ struct Item struct Monster { struct MapObj map_obj; - unsigned char hitpoints; + uint8_t hitpoints; }; @@ -67,7 +69,8 @@ struct ItemDef 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. */ }; @@ -77,11 +80,19 @@ extern void init_map_object_defs(struct World * world, char * filename); +/* 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); @@ -90,9 +101,13 @@ extern void * build_map_objects(struct World * world, void * start, char def_id, */ 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);