From: Christian Heller Date: Thu, 15 Aug 2013 11:36:58 +0000 (+0200) Subject: Renamed all "fail" variables to "err", to reduce line lengths. X-Git-Tag: tce~1096 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/decks/test?a=commitdiff_plain;h=4d9b6ac142740aa337fc3e622902c9595c36f6d0;p=plomrogue Renamed all "fail" variables to "err", to reduce line lengths. --- diff --git a/src/main.c b/src/main.c index d2fb9bf..eaddfa6 100644 --- a/src/main.c +++ b/src/main.c @@ -60,22 +60,22 @@ int main(int argc, char *argv[]) world.monster = 0; world.item = 0; init_map_object_defs(&world, "defs"); - uint8_t fail = 0; + uint8_t err = 0; /* For interactive mode, try to load world state from savefile. */ FILE * file; if (1 == world.interactive && 0 == access("savefile", F_OK)) { file = fopen("savefile", "r"); - fail = fail | read_uint32_bigendian(file, &world.seed); - fail = fail | read_uint32_bigendian(file, &world.turn); - fail = fail | read_uint16_bigendian(file, &player.pos.y); - fail = fail | read_uint16_bigendian(file, &player.pos.x); + err = err | read_uint32_bigendian(file, &world.seed); + err = err | read_uint32_bigendian(file, &world.turn); + err = err | read_uint16_bigendian(file, &player.pos.y); + err = err | read_uint16_bigendian(file, &player.pos.x); player.pos.y--; player.pos.x--; - fail = fail | read_uint8(file, &player.hitpoints); - fail = fail | read_map_objects(&world, &world.monster, file); - fail = fail | read_map_objects(&world, &world.item, file); + err = err | read_uint8(file, &player.hitpoints); + err = err | read_map_objects(&world, &world.monster, file); + err = err | read_map_objects(&world, &world.item, file); fclose(file); } @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) if (0 == world.interactive) { file = fopen("record", "r"); - fail = fail | read_uint32_bigendian(file, &world.seed); + err = err | read_uint32_bigendian(file, &world.seed); } /* For interactive-mode in newly started world, generate a start seed @@ -96,12 +96,12 @@ int main(int argc, char *argv[]) { file = fopen("record", "w"); world.seed = time(NULL); - fail = fail | write_uint32_bigendian(world.seed, file); + err = err | write_uint32_bigendian(world.seed, file); fclose(file); } } - exit_err(fail, &world, "Failure initializing game."); + exit_err(err, &world, "Failure initializing game."); /* Generate map from seed and, if newly generated world, start positions of diff --git a/src/map_objects.c b/src/map_objects.c index c4b9048..a6f527d 100644 --- a/src/map_objects.c +++ b/src/map_objects.c @@ -142,19 +142,19 @@ extern uint8_t write_map_objects(struct World * world, void * start, { struct MapObj * map_obj; struct MapObjDef * mod; - uint8_t fail = 0; + uint8_t err = 0; for (map_obj = start; map_obj != 0; map_obj = map_obj->next) { - fail = fail | write_uint8(map_obj->type, file); - fail = fail | write_uint16_bigendian(map_obj->pos.y + 1, file); - fail = fail | write_uint16_bigendian(map_obj->pos.x + 1, file); + err = err | write_uint8(map_obj->type, file); + err = err | write_uint16_bigendian(map_obj->pos.y + 1, file); + err = err | write_uint16_bigendian(map_obj->pos.x + 1, file); mod = get_map_obj_def(world, map_obj->type); if ('m' == mod->m_or_i) { - fail = fail | write_map_objects_monsterdata(map_obj, file); + err = err | write_map_objects_monsterdata(map_obj, file); } } - return (fail | write_uint16_bigendian(0, file)); + return (err | write_uint16_bigendian(0, file)); } @@ -168,17 +168,17 @@ extern uint8_t read_map_objects(struct World * world, void * start, FILE * file) char first = 1; long pos; uint16_t read_uint16 = 0; - uint8_t fail = 0; + uint8_t err = 0; while (1) { pos = ftell(file); - fail = fail | read_uint16_bigendian(file, &read_uint16); + err = err | read_uint16_bigendian(file, &read_uint16); if (0 == read_uint16) { break; } fseek(file, pos, SEEK_SET); - fail = fail | read_uint8(file, &type); + err = err | read_uint8(file, &type); mod = get_map_obj_def(world, type); if ('m' == mod->m_or_i) { @@ -190,20 +190,20 @@ extern uint8_t read_map_objects(struct World * world, void * start, FILE * file) } map_obj = get_next_map_obj(start, &first, size, map_obj); map_obj->type = type; - fail = fail | read_uint16_bigendian(file, &map_obj->pos.y); - fail = fail | read_uint16_bigendian(file, &map_obj->pos.x); + err = err | read_uint16_bigendian(file, &map_obj->pos.y); + err = err | read_uint16_bigendian(file, &map_obj->pos.x); map_obj->pos.y--; map_obj->pos.x--; if ('m' == mod->m_or_i) { - fail = fail | read_map_objects_monsterdata(map_obj, file); + err = err | read_map_objects_monsterdata(map_obj, file); } } if (!first) { map_obj->next = 0; } - return fail; + return err; } diff --git a/src/misc.c b/src/misc.c index ec05acc..082819f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -132,16 +132,16 @@ extern void turn_over(struct World * world, char action) extern void save_game(struct World * world) { - uint8_t fail; + uint8_t err; FILE * file = fopen("savefile", "w"); - fail = write_uint32_bigendian(world->seed, file); - fail = fail | write_uint32_bigendian(world->turn, file); - fail = fail | write_uint16_bigendian(world->player->pos.y + 1, file); - fail = fail | write_uint16_bigendian(world->player->pos.x + 1, file); - fail = fail | write_uint8(world->player->hitpoints, file); - fail = fail | write_map_objects(world, world->monster, file); - fail = fail | write_map_objects(world, world->item, file); - exit_err(fail, world, "Error saving game."); + err = write_uint32_bigendian(world->seed, file); + err = err | write_uint32_bigendian(world->turn, file); + err = err | write_uint16_bigendian(world->player->pos.y + 1, file); + err = err | write_uint16_bigendian(world->player->pos.x + 1, file); + err = err | write_uint8(world->player->hitpoints, file); + err = err | write_map_objects(world, world->monster, file); + err = err | write_map_objects(world, world->item, file); + exit_err(err, world, "Error saving game."); fclose(file); } diff --git a/src/readwrite.c b/src/readwrite.c index 6d24992..039dade 100644 --- a/src/readwrite.c +++ b/src/readwrite.c @@ -59,9 +59,9 @@ static uint8_t write_uintX_bigendian(FILE * file, uint32_t x, uint8_t size) extern uint8_t read_uint8(FILE * file, uint8_t * x) { uint32_t y = * x; - uint8_t fail = read_uintX_bigendian(file, &y, 8); + uint8_t err = read_uintX_bigendian(file, &y, 8); * x = (uint8_t) y; - return fail; + return err; } @@ -69,9 +69,9 @@ extern uint8_t read_uint8(FILE * file, uint8_t * x) extern uint8_t read_uint16_bigendian(FILE * file, uint16_t * x) { uint32_t y = * x; - uint8_t fail = read_uintX_bigendian(file, &y, 16); + uint8_t err = read_uintX_bigendian(file, &y, 16); * x = (uint16_t) y; - return fail; + return err; } diff --git a/src/rexit.c b/src/rexit.c index 223c79b..b9da482 100644 --- a/src/rexit.c +++ b/src/rexit.c @@ -59,9 +59,9 @@ extern void exit_game(struct World * world) -extern void exit_err(unsigned char fail, struct World * world, char * msg) +extern void exit_err(unsigned char err, struct World * world, char * msg) { - if (0 == fail) + if (0 == err) { return; } diff --git a/src/rexit.h b/src/rexit.h index d4b19d7..e4c2eb5 100644 --- a/src/rexit.h +++ b/src/rexit.h @@ -34,11 +34,11 @@ extern void exit_game(struct World * world); -/* If fail != 0, exit with an error message "msg" and clean up. (For "fail", +/* If "err" != 0, exit with an error message "msg" and clean up. (For "err", * pass the result of functions that return non-zero as an error status and * thereby avoid bloating up the code with if-error-conditionals.) */ -extern void exit_err(unsigned char fail, struct World * world, char * msg); +extern void exit_err(unsigned char err, struct World * world, char * msg);