-
-
-
-/* Return pointer to newly allocated map object struct of size "size". If first
- * in map object chain ("first" pointing to !0), point "start" to it.
- */
-static struct MapObj * get_next_map_obj(struct World * world,
- void * start, char * first,
- size_t size, struct MapObj * map_obj);
-
-
-
-/* Map-object-type-specific helpers to (build|write|read)_map_objects(). */
-static void build_map_objects_itemdata(struct MapObjDef * map_obj_def,
- void * start);
-static void build_map_objects_monsterdata(struct MapObjDef * map_obj_def,
- void * start);
-static uint8_t write_map_objects_monsterdata(void * start, FILE * file);
-static uint8_t read_map_objects_monsterdata( void * start, FILE * file);
-
-
-
-static struct MapObj * get_next_map_obj(struct World * world,
- void * start, char * first,
- size_t size, struct MapObj * map_obj)
-{
- char * f_name = "get_next_map_obj()";
- if (* first)
- {
- struct MapObj * * z = start;
- map_obj = try_malloc(size, world, f_name);
- * z = map_obj;
- * first = 0;
- }
- else
- {
- map_obj->next = try_malloc(size, world, f_name);
- map_obj = map_obj->next;
- }
- return map_obj;
-}
-
-
-
-static void build_map_objects_itemdata(struct MapObjDef * map_obj_def,
- void * start)
-{
- struct Item * i = (struct Item *) start;
- i->map_obj.type = map_obj_def->id;
-}
-
-
-
-static void build_map_objects_monsterdata(struct MapObjDef * map_obj_def,
- void * start)
-{
- struct Monster * m = (struct Monster *) start;
- m->map_obj.type = map_obj_def->id;
- struct MonsterDef * md = (struct MonsterDef *) map_obj_def;
- m->hitpoints = md->hitpoints_start;
-}
-
-
-
-static uint8_t write_map_objects_monsterdata(void * start, FILE * file)
-{
- struct Monster * m = (struct Monster *) start;
- return write_uint8(m->hitpoints, file);
-}
-
-
-
-static uint8_t read_map_objects_monsterdata (void * start, FILE * file)
-{
- struct Monster * m = (struct Monster *) start;
- return read_uint8(file, &m->hitpoints);
-}