- FILE * file = try_fopen(filename, "r", f_name);
- uint16_t linemax = textfile_sizes(file, NULL);
- struct MapObjDef ** last_mod_ptr_ptr = &world.map_obj_defs;
- char * delim = " ";
- char line[linemax + 1];
- while (try_fgets(line, linemax + 1, file, f_name))
- {
- struct MapObjDef * mod = try_malloc(sizeof(struct MapObjDef), 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, f_name);
- memcpy(mod->name, name, strlen(name) + 1);
- * last_mod_ptr_ptr = mod;
- last_mod_ptr_ptr = &mod->next;
- }
- try_fclose(file, f_name);
- set_cleanup_flag(CLEANUP_MAP_OBJECT_DEFS);
+ struct MapObjDef * mod = (struct MapObjDef *) entry;
+ err_try_fgets(line, linemax, file, context, "0nfi8");
+ mod->corpse_id = atoi(line);
+ err_try_fgets(line, linemax, file, context, "0nfs");
+ mod->char_on_map = line[0];
+ err_try_fgets(line, linemax, file, context, "0nfi8");
+ mod->lifepoints = atoi(line);
+ err_try_fgets(line, linemax, file, context, "0nf");
+ line[strlen(line) - 1] = '\0';
+ mod->name = try_malloc(strlen(line) + 1, f_name);
+ memcpy(mod->name, line, strlen(line) + 1);
+ err_try_fgets(line, linemax, file, context, "0nfi8");
+ mod->consumable = atoi(line);