-/* 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(void * start, char * first,
- size_t size, struct MapObj * map_obj);
+extern void init_map_object_defs(struct World * world, char * filename)
+{
+ char * f_name = "init_map_object_defs()";
+ FILE * file = try_fopen(filename, "r", world, f_name);
+ uint16_t linemax = get_linemax(file, world, f_name);
+ struct MapObjDef ** last_mod_ptr_ptr = &world->map_obj_defs;
+ char * delim = " ";
+ char line[linemax + 1];
+ while (try_fgets(line, linemax + 1, file, world, f_name))
+ {
+ struct MapObjDef * mod;
+ mod = try_malloc(sizeof(struct MapObjDef), world, f_name);
+ mod->next = NULL;
+ mod->id = atoi(strtok(line, delim));
+ mod->corpse_id = atoi(strtok(NULL, delim));
+ mod->char_on_map = * strtok(NULL, delim);
+ mod->lifepoints = atoi(strtok(NULL, delim));
+ char * name = strtok(NULL, "\n");
+ mod->name = try_malloc(strlen(name) + 1, world, f_name);
+ memcpy(mod->name, name, strlen(name) + 1);
+ * last_mod_ptr_ptr = mod;
+ last_mod_ptr_ptr = &mod->next;
+ }
+ try_fclose(file, world, f_name);
+}