diff --git a/src/bind_eressea.c b/src/bind_eressea.c index ac04ce36b..7848255f3 100755 --- a/src/bind_eressea.c +++ b/src/bind_eressea.c @@ -28,52 +28,65 @@ void eressea_free_game(void) { } int eressea_read_game(const char * filename) { - return readgame(filename); + if (filename) { + return readgame(filename); + } + return -1; } int eressea_write_game(const char * filename) { - remove_empty_factions(); - return writegame(filename); + if (filename) { + remove_empty_factions(); + return writegame(filename); + } + return -1; } int eressea_read_orders(const char * filename) { - FILE * F = fopen(filename, "r"); - int result; + if (filename) { + FILE *F = fopen(filename, "r"); + int result; - if (!F) { - perror(filename); - return -1; + if (!F) { + perror(filename); + return -1; + } + log_info("reading orders from %s", filename); + result = parseorders(F); + fclose(F); + return result; } - log_info("reading orders from %s", filename); - result = parseorders(F); - fclose(F); - return result; + return -1; } int eressea_export_json(const char * filename, int flags) { - FILE *F = fopen(filename, "w"); - if (F) { - stream out = { 0 }; - int err; - fstream_init(&out, F); - err = json_export(&out, flags); - fstream_done(&out); - return err; + if (filename) { + FILE *F = fopen(filename, "w"); + if (F) { + stream out = { 0 }; + int err; + fstream_init(&out, F); + err = json_export(&out, flags); + fstream_done(&out); + return err; + } + perror(filename); } - perror(filename); return -1; } int eressea_import_json(const char * filename) { - FILE *F = fopen(filename, "r"); - if (F) { - stream out = { 0 }; - int err; - fstream_init(&out, F); - err = json_import(&out); - fstream_done(&out); - return err; + if (filename) { + FILE *F = fopen(filename, "r"); + if (F) { + stream out = { 0 }; + int err; + fstream_init(&out, F); + err = json_import(&out); + fstream_done(&out); + return err; + } + perror(filename); } - perror(filename); return -1; } diff --git a/src/volcano.c b/src/volcano.c index 293b98fd5..f20cc413d 100644 --- a/src/volcano.c +++ b/src/volcano.c @@ -80,7 +80,7 @@ int volcano_damage(unit* u, const char* dice) { int hp = u->hp / u->number; int remain = u->hp % u->number; - int ac, i, dead = 0, total = 0; + int ac = 0, i, dead = 0, total = 0; int healings = 0; const struct race* rc_cat = get_race(RC_CAT); int protect = inside_building(u) ? (building_protection(u->building) + 1) : 0;