- 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);
+ err_try_fgets(line, linemax, file, context, "nfi");
+ err_line(atoi(line) > UINT8_MAX, line, context, err_toolarge);
+ mod->id = atoi(line);
+ struct MapObjDef * mod_test = world.map_obj_defs;
+ for (; NULL != mod_test; mod_test = mod_test->next)
+ {
+ err_line(mod->id == mod_test->id, line, context, err_uniq);
+ }
+ err_try_fgets(line, linemax, file, context, "0nfi");
+ err_line(atoi(line) > UINT8_MAX, line, context, err_toolarge);
+ 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, "0nfi");
+ err_line(atoi(line) > UINT8_MAX, line, context, err_toolarge);
+ 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);