- 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;
+ 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);