From: Christian Heller Date: Fri, 19 Jul 2013 23:39:05 +0000 (+0200) Subject: Replaced dummy function by just passing NULL and checking for it. X-Git-Tag: tce~1147 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/bar%20baz.html?a=commitdiff_plain;h=2e690e2500e66535018bb6e01222442c074cb298;p=plomrogue Replaced dummy function by just passing NULL and checking for it. --- diff --git a/src/main.c b/src/main.c index b65108b..a720191 100644 --- a/src/main.c +++ b/src/main.c @@ -50,7 +50,7 @@ int main (int argc, char *argv[]) { player.pos.x = read_uint16_bigendian(file) - 1; player.hitpoints = fgetc(file); read_map_objects (&world.monster, file, sizeof(struct Monster), read_map_objects_monsterdata); - read_map_objects (&world.item, file, sizeof(struct Item), readwrite_map_objects_dummy); + read_map_objects (&world.item, file, sizeof(struct Item), NULL); fclose(file); } // For non-interactive mode, try to load world state from record file. diff --git a/src/map_objects.c b/src/map_objects.c index 6aeb13b..747b718 100644 --- a/src/map_objects.c +++ b/src/map_objects.c @@ -49,10 +49,6 @@ extern void init_map_object_defs (struct World * world, char * filename) { free(defline); fclose(file); }; -extern void readwrite_map_objects_dummy (void * dummy, FILE * file) { -// Dummy function for calls of (write|read)_map_objects on map objects without specific attributes. - ; } - extern void write_map_objects_monsterdata (void * start, FILE * file) { // Write to file data specific to map objects of type monster. struct Monster * m = (struct Monster *) start; @@ -65,7 +61,8 @@ extern void write_map_objects (void * start, FILE * file, void (* w_typedata) (v write_uint16_bigendian(map_obj->pos.y + 1, file); write_uint16_bigendian(map_obj->pos.x + 1, file); fputc(map_obj->type, file); - w_typedata (map_obj, file); } + if (w_typedata) + w_typedata (map_obj, file); } write_uint16_bigendian(0, file); } extern void read_map_objects_monsterdata (void * start, FILE * file) { @@ -98,7 +95,8 @@ extern void read_map_objects (void * start, FILE * file, size_t size, void (* r_ map_obj->pos.y = test - 1; map_obj->pos.x = read_uint16_bigendian(file) - 1; map_obj->type = fgetc(file); - r_typedata (map_obj, file); } + if (r_typedata) + r_typedata (map_obj, file); } if (!first) map_obj->next = 0; } diff --git a/src/map_objects.h b/src/map_objects.h index abf77eb..f39df0d 100644 --- a/src/map_objects.h +++ b/src/map_objects.h @@ -36,7 +36,6 @@ struct MonsterDef { unsigned char hitpoints_start; }; extern void init_map_object_defs (struct World *, char *); -extern void readwrite_map_objects_dummy (void *, FILE *); extern void write_map_objects_monsterdata (void *, FILE *); extern void write_map_objects (void * start, FILE *, void (*) (void *, FILE *) ); extern void read_map_objects_monsterdata (void *, FILE *); diff --git a/src/misc.c b/src/misc.c index 8d38d59..cff4264 100644 --- a/src/misc.c +++ b/src/misc.c @@ -93,7 +93,7 @@ extern void save_game(struct World * world) { write_uint16_bigendian(world->player->pos.x + 1, file); fputc(world->player->hitpoints, file); write_map_objects (world->monster, file, write_map_objects_monsterdata); - write_map_objects (world->item, file, readwrite_map_objects_dummy); + write_map_objects (world->item, file, NULL); fclose(file); } extern void toggle_window (struct WinMeta * win_meta, struct Win * win) {