X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=src%2Fmap_objects.c;h=0407352e8e494ebf95078eeac1401cb971e0b964;hb=10680a2398daf76e6a0cd261c2b247e6902f2ad0;hp=0107aff4d1d97b1fa9c464127a4d4b8807410421;hpb=2dccba703435158681552b8a8aefccab79eb13f3;p=plomrogue diff --git a/src/map_objects.c b/src/map_objects.c index 0107aff..0407352 100644 --- a/src/map_objects.c +++ b/src/map_objects.c @@ -5,8 +5,8 @@ #include /* for uint8_t */ #include /* for FILE typedef */ #include /* for strchr(), strlen(), memcpy(), strtok() */ -#include "readwrite.h" /* for get_linemax(), try_fopen(), try_fclose() - * [read/write]_uint[8/16/23][_bigendian]() +#include "readwrite.h" /* for textfile_sizes(), try_fopen(), try_fclose(), + * try_fgets() */ #include "misc.h" /* for try_malloc(), find_passable_pos() */ #include "main.h" /* for world global */ @@ -33,7 +33,7 @@ static void write_map_object(FILE * file, struct MapObj * mo) char line[size]; sprintf(line, "%d %d %d %d %d %d %d %d", mo->id, mo->type, mo->lifepoints, mo->pos.y, mo->pos.x, - mo->progress, mo->command, mo->arg); + mo->command, mo->arg, mo->progress); for (mo_ptr = mo->owns; NULL != mo_ptr; mo_ptr = mo_ptr->next) { sprintf(line + strlen(line), " %d", mo_ptr->id); @@ -72,7 +72,7 @@ extern void init_map_object_defs(char * filename) { char * f_name = "init_map_object_defs()"; FILE * file = try_fopen(filename, "r", f_name); - uint16_t linemax = get_linemax(file, 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]; @@ -138,9 +138,9 @@ extern void read_map_objects(FILE * file, char * line, int linemax) mo->lifepoints = atoi(strtok(NULL, delim)); mo->pos.y = atoi(strtok(NULL, delim)); mo->pos.x = atoi(strtok(NULL, delim)); - mo->progress = atoi(strtok(NULL, delim));; mo->command = atoi(strtok(NULL, delim));; mo->arg = atoi(strtok(NULL, delim));; + mo->progress = atoi(strtok(NULL, delim));; mo->owns = NULL; if (mo->id > world.map_obj_count) {