*/
#include <string.h>
-#include <stdbool.h>
#include "empire.h"
#include "extern.h"
bool load_army(piece_info_t *obj);
bool lake( loc_t loc );
-int overproduced( city_info_t *cityp, int *city_count );
+bool overproduced( city_info_t *cityp, int *city_count );
bool nearby_load( piece_info_t *obj, loc_t loc );
count_t nearby_count( loc_t loc );
void move_objective(piece_info_t *obj,path_map_t pathmap[],loc_t new_loc,char *adj_list);
See if a city is producing an object which is being overproduced.
*/
-int
+bool
overproduced(city_info_t *cityp, int *city_count)
{
int i;
if (i != cityp->prod
&& ((city_count[(int)cityp->prod] - 1) * ratio[i]
> (city_count[i] + 1) * ratio[(int)cityp->prod]))
- return (TRUE);
+ return true;
}
- return (FALSE);
+ return false;
}
/*
{
void move1();
- int changed_loc;
+ bool changed_loc;
int max_hits;
loc_t saved_loc;
city_info_t *cityp;
}
obj->moved = 0; /* not moved yet */
- changed_loc = FALSE; /* not changed yet */
+ changed_loc = false; /* not changed yet */
max_hits = piece_attr[obj->type].max_hits;
if (obj->type == FIGHTER) { /* init fighter range */
while (obj->moved < obj_moves (obj)) {
saved_loc = obj->loc; /* remember starting location */
move1 (obj);
- if (saved_loc != obj->loc) changed_loc = TRUE;
+ if (saved_loc != obj->loc) changed_loc = true;
if (obj->type == FIGHTER && obj->hits > 0) {
if (comp_map[obj->loc].contents == 'X')
p = find_best_tt (p, x_loc);
}
- if (!p) return FALSE; /* no tt to be found */
+ if (!p) return false; /* no tt to be found */
if (p->loc == obj->loc) { /* stay in same place */
obj->moved = piece_attr[ARMY].speed;
disembark (obj);
embark (p, obj);
}
- return TRUE;
+ return true;
}
/*
announce ("\nThe enemy inadvertantly revealed its code used for");
announce ("\nreceiving battle information. You can display what");
announce ("\nthey've learned with the ''E'' command.");
- resigned = TRUE;
+ resigned = true;
win = 2;
- automove = FALSE;
+ automove = false;
}
else if (ncomp_city == 0 && ncomp_army == 0) {
clear_screen ();
announce ("There may be, however, remnants of the enemy fleet\n");
announce ("to be routed out and destroyed.\n");
win = 1;
- automove = FALSE;
+ automove = false;
}
else if (nuser_city == 0 && nuser_army == 0) {
clear_screen ();
announce ("empire is lost. If you have any ships left, you\n");
announce ("may attempt to harass enemy shipping.");
win = 1;
- automove = FALSE;
+ automove = false;
}
}
switch (orders) {
case 'A': /* turn on auto move mode */
- automove = TRUE;
+ automove = true;
error ("Now in Auto-Mode",0,0,0,0,0,0,0,0);
user_move ();
comp_move (1);
case '+': /* change debug state */
e = get_chx();
- if ( e == '+' ) debug = TRUE;
- else if ( e == '-' ) debug = FALSE;
+ if ( e == '+' ) debug = true;
+ else if ( e == '-' ) debug = false;
else huh ();
break;
case '@': /* change trace state */
e = get_chx();
- if ( e == '+' ) trace_pmap = TRUE;
- else if ( e == '-' ) trace_pmap = FALSE;
+ if ( e == '+' ) trace_pmap = true;
+ else if ( e == '-' ) trace_pmap = false;
else huh ();
break;
case '$': /* change print_debug state */
e = get_chx();
- if ( e == '+' ) print_debug = TRUE;
- else if ( e == '-' ) print_debug = FALSE;
+ if ( e == '+' ) print_debug = true;
+ else if ( e == '-' ) print_debug = false;
else huh ();
break;
empire.h -- type and constant declarations
*/
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
+#include <stdbool.h>
#ifndef NULL
#define NULL 0
typedef struct real_map { /* a cell of the actual map */
char contents; /* '+', '.', or '*' */
- uchar on_board; /* TRUE iff on the board */
+ bool on_board; /* TRUE iff on the board */
city_info_t *cityp; /* ptr to city at this location */
piece_info_t *objp; /* list of objects at this location */
} real_map_t;
/* miscellaneous */
long date; /* number of game turns played */
-char automove; /* TRUE iff user is in automove mode */
-char resigned; /* TRUE iff computer resigned */
-char debug; /* TRUE iff in debugging mode */
-char print_debug; /* TRUE iff we print debugging stuff */
-char print_vmap; /* TRUE iff we print view maps */
-char trace_pmap; /* TRUE if we are tracing pmaps */
+bool automove; /* true iff user is in automove mode */
+bool resigned; /* true iff computer resigned */
+bool debug; /* true iff in debugging mode */
+bool print_debug; /* true iff we print debugging stuff */
+bool print_vmap; /* true iff we print view maps */
+bool trace_pmap; /* true if we are tracing pmaps */
int win; /* set when game is over */
char jnkbuf[STRSIZE]; /* general purpose temporary buffer */
-char save_movie; /* TRUE iff we should save movie screens */
+bool save_movie; /* true iff we should save movie screens */
int user_score; /* "score" for user and computer */
int comp_score;
char *savefile;
void vmap_mark_up_cont (int *cont_map, view_map_t *vmap, long loc, char bad_terrain);
scan_counts_t vmap_cont_scan (int *cont_map, view_map_t *vmap);
scan_counts_t rmap_cont_scan (int *cont_map);
-int map_cont_edge (int *cont_map, long loc);
+bool map_cont_edge (int *cont_map, long loc);
long vmap_find_aobj (path_map_t path_map[], view_map_t *vmap, long loc, move_info_t *move_info);
long vmap_find_wobj (path_map_t path_map[], view_map_t *vmap, long loc, move_info_t *move_info);
long vmap_find_lobj (path_map_t path_map[], view_map_t *vmap, long loc, move_info_t *move_info);
void vmap_mark_near_path (path_map_t path_map[], long loc);
long vmap_find_dir (path_map_t path_map[], view_map_t *vmap, long loc, char *terrain, char *adjchar);
int vmap_count_adjacent (view_map_t *vmap, long loc, char *adj_char);
-int vmap_shore (view_map_t *vmap, long loc);
-int rmap_shore (long loc);
-int vmap_at_sea (view_map_t *vmap, long loc);
-int rmap_at_sea (long loc);
+bool vmap_shore (view_map_t *vmap, long loc);
+bool rmap_shore (long loc);
+bool vmap_at_sea (view_map_t *vmap, long loc);
+bool rmap_at_sea (long loc);
/* display routines */
void announce (char *);
void produce (city_info_t *cityp);
void move_obj (piece_info_t *obj, long new_loc);
void move_sat (piece_info_t *obj);
-int good_loc (piece_info_t *obj, long loc);
+bool good_loc (piece_info_t *obj, long loc);
void embark (piece_info_t *ship, piece_info_t *obj);
void disembark (piece_info_t *obj);
void describe_obj (piece_info_t *obj);
#include "extern.h"
count_t remove_land(loc_t loc, count_t num_land);
-int select_cities(void);
-int find_next(loc_t *mapi);
-int good_cont(loc_t mapi);
-int xread(FILE *f, char *buf, int size);
-int xwrite(FILE *f, char *buf, int size);
+bool select_cities(void);
+bool find_next(loc_t *mapi);
+bool good_cont(loc_t mapi);
+bool xread(FILE *f, char *buf, int size);
+bool xwrite(FILE *f, char *buf, int size);
void stat_display( char *mbuf, int round);
/*
count_t i;
kill_display (); /* nothing on screen */
- automove = FALSE;
- resigned = FALSE;
- debug = FALSE;
- print_debug = FALSE;
- print_vmap = FALSE;
- trace_pmap = FALSE;
- save_movie = FALSE;
+ automove = false;
+ resigned = false;
+ debug = false;
+ print_debug = false;
+ print_vmap = false;
+ trace_pmap = false;
+ save_movie = false;
win = 0;
date = 0; /* no date yet */
user_score = 0;
First we make a list of continents which contain at least two cities, one
or more of which is on the coast. If there are no such continents, we return
-FALSE, and our caller should decide again where cities should be placed
+false, and our caller should decide again where cities should be placed
on the map. While making this list, we will rank the continents. Our ranking
is based on the thought that shore cities are better than inland cities,
that any city is very important, and that the land area of a continent
static int rank_tab[MAX_CONT]; /* indices to cont_tab in order of rank */
static pair_t pair_tab[MAX_CONT*MAX_CONT]; /* ranked pairs of continents */
-int select_cities(void) {
+bool select_cities(void) {
void find_cont(void), make_pair(void);
loc_t compi, useri;
int pair;
find_cont (); /* find and rank the continents */
- if (ncont == 0) return (FALSE); /* there are no good continents */
+ if (ncont == 0) return (false); /* there are no good continents */
make_pair (); /* create list of ranked pairs */
userp->work = 0;
scan (user_map, userp->loc);
set_prod (userp);
- return (TRUE);
+ return (true);
}
/*
If there are no more continents, we return false.
*/
-int find_next(loc_t *mapi)
+bool find_next(loc_t *mapi)
{
count_t i;
long val;
for (;;) {
- if (*mapi >= MAP_SIZE) return (FALSE);
+ if (*mapi >= MAP_SIZE) return (false);
if (!map[*mapi].on_board || marked[*mapi]
|| map[*mapi].contents == '.') *mapi += 1;
else break;
}
ncont++; /* count continents */
- return (TRUE);
+ return (true);
}
}
}
static count_t ncity, nland, nshore;
static void mark_cont(loc_t);
-int good_cont(loc_t mapi)
+bool good_cont(loc_t mapi)
{
long val;
mark_cont (mapi);
- if (nshore < 1 || ncity < 2) return (FALSE);
+ if (nshore < 1 || ncity < 2) return (false);
/* The first two cities, one of which must be a shore city,
don't contribute to the value. Otherwise shore cities are
val += nland;
cont_tab[ncont].value = val;
cont_tab[ncont].ncity = ncity;
- return (TRUE);
+ return (true);
}
/*
/*
Recover a saved game from emp_save.dat.
-We return TRUE if we succeed, otherwise FALSE.
+We return TRUE if we succeed, otherwise false.
*/
-#define rbuf(buf) if (!xread (f, (char *)buf, sizeof(buf))) return (FALSE);
-#define rval(val) if (!xread (f, (char *)&val, sizeof(val))) return (FALSE);
+#define rbuf(buf) if (!xread (f, (char *)buf, sizeof(buf))) return (false);
+#define rval(val) if (!xread (f, (char *)&val, sizeof(val))) return (false);
int restore_game(void) {
void read_embark();
f = fopen (savefile, "r"); /* open for input */
if (f == NULL) {
perror ("Cannot open saved game");
- return (FALSE);
+ return (false);
}
rbuf (map);
rbuf (comp_map);
(void) fclose (f);
kill_display (); /* what we had is no longer good */
topmsg (3, "Game restored from save file.",0,0,0,0,0,0,0,0);
- return (TRUE);
+ return (true);
}
/*
Also, tell the user why the write did not work if it didn't.
*/
-int xwrite(FILE *f, char *buf, int size)
+bool xwrite(FILE *f, char *buf, int size)
{
int bytes;
bytes = fwrite (buf, 1, size, f);
if (bytes == -1) {
perror ("Write to save file failed");
- return (FALSE);
+ return (false);
}
if (bytes != size) {
perror ("Cannot complete write to save file.\n");
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
/*
Read a buffer from a file. If the read fails, we tell the user why
-and return FALSE.
+and return false.
*/
-int xread(FILE *f, char *buf, int size)
+bool xread(FILE *f, char *buf, int size)
{
int bytes;
bytes = fread (buf, 1, size, f);
if (bytes == -1) {
perror ("Read from save file failed");
- return (FALSE);
+ return (false);
}
if (bytes != size) {
perror ("Saved file is too short.\n");
- return (FALSE);
+ return (false);
}
- return (TRUE);
+ return (true);
}
/*
*/
void
-vmap_mark_up_cont (int *cont_map, view_map_t *vmap, loc_t loc, char bad_terrain)
+vmap_mark_up_cont(int *cont_map, view_map_t *vmap, loc_t loc, char bad_terrain)
{
int i, j;
loc_t new_loc;
static void rmap_mark_up_cont(int *cont_map, loc_t loc, char bad_terrain);
void
-rmap_cont (int *cont_map, loc_t loc, char bad_terrain)
+rmap_cont(int *cont_map, loc_t loc, char bad_terrain)
{
(void) bzero ((char *)cont_map, MAP_SIZE * sizeof (int));
rmap_mark_up_cont (cont_map, loc, bad_terrain);
*/
static void
-rmap_mark_up_cont (int *cont_map, loc_t loc, char bad_terrain)
+rmap_mark_up_cont(int *cont_map, loc_t loc, char bad_terrain)
{
int i;
loc_t new_loc;
#define COUNT(c,item) case c: item += 1; break
scan_counts_t
-vmap_cont_scan (int *cont_map, view_map_t *vmap)
+vmap_cont_scan(int *cont_map, view_map_t *vmap)
{
scan_counts_t counts;
count_t i;
*/
scan_counts_t
-rmap_cont_scan (int *cont_map)
+rmap_cont_scan(int *cont_map)
{
scan_counts_t counts;
count_t i;
}
/*
-Return TRUE if a location is on the edge of a continent.
+Return true if a location is on the edge of a continent.
*/
-int
-map_cont_edge (int *cont_map, loc_t loc)
+bool
+map_cont_edge(int *cont_map, loc_t loc)
{
loc_t i, j;
- if (!cont_map[loc]) return FALSE; /* not on continent */
+ if (!cont_map[loc]) return false; /* not on continent */
FOR_ADJ (loc, j, i)
- if (!cont_map[j]) return TRUE; /* edge of continent */
+ if (!cont_map[j]) return true; /* edge of continent */
- return FALSE;
+ return false;
}
/*
/* Find an objective over a single type of terrain. */
loc_t
-vmap_find_xobj (path_map_t path_map[], view_map_t *vmap,
+vmap_find_xobj(path_map_t path_map[], view_map_t *vmap,
loc_t loc, move_info_t *move_info, int start, int expand)
{
perimeter_t *from;
/* Find an objective for a piece that crosses land and water. */
loc_t
-vmap_find_aobj (path_map_t path_map[], view_map_t *vmap,
+vmap_find_aobj(path_map_t path_map[], view_map_t *vmap,
loc_t loc, move_info_t *move_info)
{
return vmap_find_xobj (path_map, vmap, loc, move_info, T_LAND, T_AIR);
/* Find an objective for a piece that crosses only water. */
loc_t
-vmap_find_wobj (path_map_t path_map[], view_map_t *vmap,
+vmap_find_wobj(path_map_t path_map[], view_map_t *vmap,
loc_t loc, move_info_t *move_info)
{
return vmap_find_xobj (path_map, vmap, loc, move_info, T_WATER, T_WATER);
/* Find an objective for a piece that crosses only land. */
loc_t
-vmap_find_lobj (path_map_t path_map[], view_map_t *vmap,
+vmap_find_lobj(path_map_t path_map[], view_map_t *vmap,
loc_t loc, move_info_t *move_info)
{
return vmap_find_xobj (path_map, vmap, loc, move_info, T_LAND, T_LAND);
*/
loc_t
-vmap_find_lwobj (path_map_t path_map[], view_map_t *vmap,
+vmap_find_lwobj(path_map_t path_map[], view_map_t *vmap,
loc_t loc, move_info_t *move_info, int beat_cost)
{
perimeter_t *cur_land;
*/
STATIC int
-best_adj (path_map_t *pmap, loc_t loc, int type)
+best_adj(path_map_t *pmap, loc_t loc, int type)
{
int i;
loc_t new_loc;
*/
loc_t
-vmap_find_wlobj (path_map_t path_map[], view_map_t *vmap,
+vmap_find_wlobj(path_map_t path_map[], view_map_t *vmap,
loc_t loc, move_info_t *move_info)
{
perimeter_t *cur_land;
static int init_done = 0;
STATIC void
-start_perimeter (path_map_t *pmap, perimeter_t *perim, loc_t loc, int terrain)
+start_perimeter(path_map_t *pmap, perimeter_t *perim, loc_t loc, int terrain)
{
int i;
*/
STATIC void
-expand_perimeter (path_map_t *pmap, view_map_t *vmap, move_info_t *move_info,
+expand_perimeter(path_map_t *pmap, view_map_t *vmap, move_info_t *move_info,
perimeter_t *curp,
int type, int cur_cost, int inc_wcost, int inc_lcost,
perimeter_t *waterp, perimeter_t *landp)
/* Add a cell to a perimeter list. */
STATIC void
-add_cell (path_map_t *pmap, loc_t new_loc,
+add_cell(path_map_t *pmap, loc_t new_loc,
perimeter_t *perim, int terrain, int cur_cost, int inc_cost)
{
register path_map_t *pm = &pmap[new_loc];
/* Compute the cost to move to an objective. */
STATIC int
-objective_cost (view_map_t *vmap, move_info_t *move_info,
+objective_cost(view_map_t *vmap, move_info_t *move_info,
loc_t loc, int base_cost)
{
char *p;
*/
STATIC int
-terrain_type (path_map_t *pmap, view_map_t *vmap, move_info_t *move_info,
+terrain_type(path_map_t *pmap, view_map_t *vmap, move_info_t *move_info,
loc_t from_loc, loc_t to_loc)
{
if (vmap[to_loc].contents == '+') return T_LAND;
*/
void
-vmap_prune_explore_locs (view_map_t *vmap)
+vmap_prune_explore_locs(view_map_t *vmap)
{
path_map_t pmap[MAP_SIZE];
perimeter_t *from, *to;
*/
STATIC void
-expand_prune (view_map_t *vmap, path_map_t *pmap,
+expand_prune(view_map_t *vmap, path_map_t *pmap,
loc_t loc, int type, perimeter_t *to, int *explored)
{
int i;
*/
loc_t
-vmap_find_dest (path_map_t path_map[], view_map_t vmap[],
+vmap_find_dest(path_map_t path_map[], view_map_t vmap[],
loc_t cur_loc, loc_t dest_loc, int owner, int terrain)
/* cur_loc = current location of piece */
/* dest_loc = destination of piece */
*/
void
-vmap_mark_path (path_map_t *path_map, view_map_t *vmap, loc_t dest)
+vmap_mark_path(path_map_t *path_map, view_map_t *vmap, loc_t dest)
{
int n;
loc_t new_dest;
*/
void
-vmap_mark_adjacent (path_map_t path_map[], loc_t loc)
+vmap_mark_adjacent(path_map_t path_map[], loc_t loc)
{
int i;
loc_t new_loc;
*/
void
-vmap_mark_near_path (path_map_t path_map[], loc_t loc)
+vmap_mark_near_path(path_map_t path_map[], loc_t loc)
{
int i, j;
loc_t new_loc, xloc;
WEST, EAST, NORTH, SOUTH};
loc_t
-vmap_find_dir (path_map, vmap, loc, terrain, adj_char)
-path_map_t path_map[];
-view_map_t *vmap;
-loc_t loc;
-char *terrain;
-char *adj_char;
+vmap_find_dir(path_map_t path_map[], view_map_t *vmap,
+ loc_t loc, char *terrain, char *adj_char)
{
int i, count, bestcount;
loc_t bestloc, new_loc;
*/
int
-vmap_count_adjacent (vmap, loc, adj_char)
-view_map_t *vmap;
-loc_t loc;
-char *adj_char;
+vmap_count_adjacent(view_map_t *vmap, loc_t loc, char *adj_char)
{
int i, count;
loc_t new_loc;
*/
int
-vmap_count_path (pmap, loc)
-path_map_t *pmap;
-loc_t loc;
+vmap_count_path(path_map_t *pmap, loc_t loc)
{
int i, count;
loc_t new_loc;
cell contains water and is on the board.
*/
-int
-rmap_shore (loc)
-loc_t loc;
+bool
+rmap_shore(loc_t loc)
{
loc_t i, j;
FOR_ADJ_ON (loc, j, i)
- if (map[j].contents == '.') return (TRUE);
+ if (map[j].contents == '.') return (true);
- return (FALSE);
+ return (false);
}
-int
-vmap_shore (vmap, loc)
-view_map_t *vmap;
-loc_t loc;
+bool
+vmap_shore(view_map_t *vmap, loc_t loc)
{
loc_t i, j;
FOR_ADJ_ON (loc, j, i)
if (vmap[j].contents != ' ' && vmap[j].contents != '+' && map[j].contents == '.')
- return (TRUE);
+ return (true);
- return (FALSE);
+ return (false);
}
/*
which cannot be moved to are treated as ocean.
*/
-int
-vmap_at_sea (vmap, loc)
-view_map_t *vmap;
-loc_t loc;
+bool
+vmap_at_sea(view_map_t *vmap, loc_t loc)
{
loc_t i, j;
- if (map[loc].contents != '.') return (FALSE);
+ if (map[loc].contents != '.') return (false);
FOR_ADJ_ON (loc, j, i)
if (vmap[j].contents == ' ' || vmap[j].contents == '+' || map[j].contents != '.')
- return (FALSE);
+ return (false);
- return (TRUE);
+ return (true);
}
-int
-rmap_at_sea (loc)
-loc_t loc;
+bool
+rmap_at_sea (loc_t loc)
{
loc_t i, j;
- if (map[loc].contents != '.') return (FALSE);
+ if (map[loc].contents != '.') return (false);
FOR_ADJ_ON (loc, j, i) {
- if (map[j].contents != '.') return (FALSE);
+ if (map[j].contents != '.') return (false);
}
- return (TRUE);
+ return (true);
}
move onto transports, and fighters may move onto cities or carriers.
*/
-int good_loc(piece_info_t *obj, loc_t loc)
+bool good_loc(piece_info_t *obj, loc_t loc)
{
view_map_t *vmap;
piece_info_t *p;
- if (!map[loc].on_board) return (FALSE);
+ if (!map[loc].on_board) return (false);
vmap = MAP (obj->owner);
if (strchr (piece_attr[obj->type].terrain, vmap[loc].contents) != NULL)
- return (TRUE);
+ return (true);
/* armies can move into unfull transports */
if (obj->type == ARMY) {
/* ships and fighters can move into cities */
if (map[loc].cityp && map[loc].cityp->owner == obj->owner)
- return (TRUE);
+ return (true);
/* fighters can move onto unfull carriers */
if (obj->type == FIGHTER) {
return (p != NULL && p->owner == obj->owner);
}
- return (FALSE);
+ return (false);
}
void describe_obj(piece_info_t *obj)
void fatal(piece_info_t *obj,loc_t loc,char *message,char *response);
void move_to_dest(piece_info_t *obj,loc_t dest);
void move_army_to_city(piece_info_t *obj,loc_t city_loc);
-int awake(piece_info_t *obj);
+bool awake(piece_info_t *obj);
extern int get_piece_name(void);
void
void move_armyattack(), move_ttload(), move_repair();
void move_transport();
- int changed_loc;
+ bool changed_loc;
int speed, max_hits;
int saved_moves;
- int need_input;
+ bool need_input;
loc_t saved_loc;
city_info_t *cityp;
if (cityp->func[obj->type] != NOFUNC)
obj->func = cityp->func[obj->type];
- changed_loc = FALSE; /* not changed yet */
+ changed_loc = false; /* not changed yet */
speed = piece_attr[obj->type].speed;
max_hits = piece_attr[obj->type].max_hits;
- need_input = FALSE; /* don't require user input yet */
+ need_input = false; /* don't require user input yet */
while (obj->moved < obj_moves (obj)) {
saved_moves = obj->moved; /* save moves made */
topini (); /* clear info lines */
display_loc_u (obj->loc); /* let user see result */
(void) redisplay ();
- need_input = FALSE; /* we got it */
+ need_input = false; /* we got it */
}
if (obj->moved == saved_moves) /* user set function? */
default: move_path (obj); break;
}
- if (obj->moved == saved_moves) need_input = TRUE;
+ if (obj->moved == saved_moves) need_input = true;
/* handle fighters specially. If in a city or carrier, turn
is over and reset range to max. Otherwise, if
}
}
- if (saved_loc != obj->loc) changed_loc = TRUE;
+ if (saved_loc != obj->loc) changed_loc = true;
}
/* if a boat is in port, damaged, and never moved, fix some damage */
if (obj->hits > 0 /* still alive? */
void
user_dir_army(piece_info_t *obj, loc_t loc)
{
- int enemy_killed;
+ bool enemy_killed;
- enemy_killed = FALSE;
+ enemy_killed = false;
if (user_map[loc].contents == 'O') /* attacking own city */
move_army_to_city (obj, loc);
void
user_dir_ship(piece_info_t *obj, loc_t loc)
{
- int enemy_killed;
+ bool enemy_killed;
- enemy_killed = FALSE;
+ enemy_killed = false;
if (map[loc].contents == '*') {
(void) sprintf (jnkbuf, "Your %s broke up on shore.",
if (!automove)
comment ("Not in auto mode!",0,0,0,0,0,0,0,0);
else {
- automove = FALSE;
+ automove = false;
comment ("Auto mode cancelled.",0,0,0,0,0,0,0,0);
}
}
will return TRUE if we want the user to have control.
*/
-int
+bool
awake(piece_info_t *obj)
{
int i;
if (obj->type == ARMY && vmap_at_sea (user_map, obj->loc)) {
obj->moved = piece_attr[ARMY].range;
- return (FALSE);
+ return (false);
}
- if (obj->func == NOFUNC) return (TRUE); /* object is awake */
+ if (obj->func == NOFUNC) return (true); /* object is awake */
if (obj->type == FIGHTER /* wake fighters */
&& obj->func != LAND /* that aren't returning to base */
&& obj->func < 0 /* and which don't have a path */
&& obj->range <= find_nearest_city (obj->loc, USER, &t) + 2) {
obj->func = NOFUNC; /* wake piece */
- return (TRUE);
+ return (true);
}
for (i = 0; i < 8; i++) { /* for each surrounding cell */
c = user_map[obj->loc+dir_offset[i]].contents;
if (islower (c) || c == '*' || c == 'X') {
if (obj->func < 0) obj->func = NOFUNC; /* awaken */
- return (TRUE);
+ return (true);
}
}
- return (FALSE);
+ return (false);
}
/*