From 9ecbac312d8486d15a13191bde3e58824cd1daa1 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 25 Aug 2013 11:10:08 -0400 Subject: [PATCH] Use bools and enums where appropriate. --- compmove.c | 4 ++-- empire.h | 4 ++++ game.c | 2 +- map.c | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/compmove.c b/compmove.c index 3695768..39b2780 100644 --- a/compmove.c +++ b/compmove.c @@ -1115,7 +1115,7 @@ check_endgame(void) announce ("\nreceiving battle information. You can display what"); announce ("\nthey've learned with the ''E'' command."); resigned = true; - win = 2; + win = ratio_win; automove = false; } else if (ncomp_city == 0 && ncomp_army == 0) { @@ -1124,7 +1124,7 @@ check_endgame(void) announce ("You are free to rape the empire as you wish.\n"); announce ("There may be, however, remnants of the enemy fleet\n"); announce ("to be routed out and destroyed.\n"); - win = 1; + win = wipeout_win; automove = false; } else if (nuser_city == 0 && nuser_army == 0) { diff --git a/empire.h b/empire.h index 11665bf..3a60468 100644 --- a/empire.h +++ b/empire.h @@ -261,3 +261,7 @@ typedef struct { long len; /* number of items in list */ long list[MAP_SIZE]; /* list of locations */ } perimeter_t; + +enum win_t {no_win, wipeout_win, ratio_win}; + +/* end */ diff --git a/game.c b/game.c index d2d132b..f0de9d2 100644 --- a/game.c +++ b/game.c @@ -44,7 +44,7 @@ void init_game(void) print_vmap = false; trace_pmap = false; save_movie = false; - win = 0; + win = no_win; date = 0; /* no date yet */ user_score = 0; comp_score = 0; diff --git a/map.c b/map.c index 43fdb99..aaacb22 100644 --- a/map.c +++ b/map.c @@ -481,7 +481,7 @@ constant and 'memcpy'. */ static path_map_t pmap_init[MAP_SIZE]; -static int init_done = 0; +static bool init_done = false; STATIC void start_perimeter(path_map_t *pmap, perimeter_t *perim, loc_t loc, int terrain) @@ -490,7 +490,7 @@ start_perimeter(path_map_t *pmap, perimeter_t *perim, loc_t loc, int terrain) if (!init_done) { int i; - init_done = 1; + init_done = true; for (i = 0; i < MAP_SIZE; i++) { pmap_init[i].cost = INFINITY; /* everything lies outside perim */ pmap_init[i].terrain = T_UNKNOWN; -- 2.43.0