void
attack(piece_info_t *att_obj, loc_t loc)
{
- if (map[loc].contents == '*') /* attacking a city? */
+ if (map[loc].contents == MAP_CITY) /* attacking a city? */
attack_city (att_obj, loc);
else attack_obj (att_obj, loc); /* attacking a piece */
}
/* Make sure we have army producers for current continent. */
/* map out city's continent */
- vmap_cont (cont_map, comp_map, cityp->loc, '.');
+ vmap_cont (cont_map, comp_map, cityp->loc, MAP_SEA);
/* count items of interest on the continent */
counts = vmap_cont_scan (cont_map, comp_map);
int cont_map[MAP_SIZE];
scan_counts_t counts;
- vmap_cont (cont_map, emap, loc, '+'); /* map lake */
+ vmap_cont (cont_map, emap, loc, MAP_LAND); /* map lake */
counts = vmap_cont_scan (cont_map, emap);
return !(counts.unowned_cities || counts.user_cities || counts.unexplored);
if (new_loc != obj->loc) { /* something to attack? */
attack (obj, new_loc); /* attack it */
- if (map[new_loc].contents == '.' /* moved to ocean? */
+ if (map[new_loc].contents == MAP_SEA /* moved to ocean? */
&& obj->hits > 0) { /* object still alive? */
kill_obj (obj, new_loc);
scan (user_map, new_loc); /* rescan for user */
case 'O':
cross_cost = 60; /* high cost if enemy present */
break;
- case '*':
+ case MAP_CITY:
cross_cost = 30; /* medium cost for attackable city */
break;
case ' ':
for (i = 0; i < NUM_CITY; i++)
if (city[i].owner == COMP)
- vmap_mark_up_cont (owncont_map, xmap, city[i].loc, '.');
+ vmap_mark_up_cont (owncont_map, xmap, city[i].loc, MAP_SEA);
for (i = 0; i < MAP_SIZE; i++)
if (strchr ("O*", vmap[i].contents)) {
int total_cities;
- vmap_cont (tcont_map, xmap, i, '.'); /* map continent */
+ vmap_cont (tcont_map, xmap, i, MAP_SEA); /* map continent */
counts = vmap_cont_scan (tcont_map, xmap);
total_cities = counts.unowned_cities
switch(vp->contents)
{
- case '+':
+ case MAP_LAND:
attr = COLOR_PAIR(COLOR_GREEN);
break;
- case '.':
+ case MAP_SEA:
attr = COLOR_PAIR(COLOR_CYAN);
break;
case 'a':
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;
default:
- if (debug) c_debug (orders); /* debug */
- else huh (); /* illegal command */
+ if (debug)
+ c_debug (orders); /* debug */
+ else
+ huh (); /* illegal command */
break;
}
}
#define NUM_CITY ((100 * (MAP_WIDTH + MAP_HEIGHT)) / 228)
typedef struct real_map { /* a cell of the actual map */
- char contents; /* '+', '.', or '*' */
+ char contents; /* MAP_LAND, MAP_SEA, or MAP_CITY */
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;
typedef struct view_map { /* a cell of one player's world view */
- char contents; /* '+', '.', '*', 'A', 'a', etc */
+ char contents; /* MAP_LAND, MAP_SEA, MAP_CITY, 'A', 'a', etc */
long seen; /* date when last updated */
} view_map_t;
enum win_t {no_win, wipeout_win, ratio_win};
+#define MAP_LAND '+'
+#define MAP_SEA '.'
+#define MAP_CITY '*'
+
/* end */
do {
for (i = 0; i < MAP_SIZE; i ++) { /* remove cities */
- if (map[i].contents == '*')
- map[i].contents = '+'; /* land */
+ if (map[i].contents == MAP_CITY)
+ map[i].contents = MAP_LAND; /* land */
}
place_cities (); /* place cities on map */
} while
/* mark the land and water */
for (i = 0; i < MAP_SIZE; i ++) {
if (height[from][i] > loc)
- map[i].contents = '+'; /* land */
- else map[i].contents = '.'; /* water */
+ map[i].contents = MAP_LAND;
+ else map[i].contents = MAP_SEA;
map[i].objp = NULL; /* nothing in cell yet */
map[i].cityp = NULL;
for (i = 0; i < NUM_OBJECTS; i++)
city[placed].func[i] = NOFUNC; /* no function */
- map[loc].contents = '*';
+ map[loc].contents = MAP_CITY;
map[loc].cityp = &(city[placed]);
placed++;
num_land = 0;
for (i = 0; i < MAP_SIZE; i++) {
- if (map[i].on_board && map[i].contents == '+') {
+ if (map[i].on_board && map[i].contents == MAP_LAND) {
land[num_land] = i; /* remember piece of land */
num_land++; /* remember number of pieces */
}
if (*mapi >= MAP_SIZE) return (false);
if (!map[*mapi].on_board || marked[*mapi]
- || map[*mapi].contents == '.') *mapi += 1;
+ || map[*mapi].contents == MAP_SEA)
+ *mapi += 1;
else if (good_cont (*mapi)) {
rank_tab[ncont] = ncont; /* insert cont in rank tab */
val = cont_tab[ncont].value;
{
int i;
- if (marked[mapi] || map[mapi].contents == '.'
- || !map[mapi].on_board) return;
+ if (marked[mapi]
+ || map[mapi].contents == MAP_SEA
+ || !map[mapi].on_board)
+ return;
marked[mapi] = 1; /* mark this cell seen */
nland++; /* count land on continent */
- if (map[mapi].contents == '*') { /* a city? */
+ if (map[mapi].contents == MAP_CITY) { /* a city? */
cont_tab[ncont].cityp[ncity] = map[mapi].cityp;
ncity++;
if (rmap_shore (mapi)) nshore++;
if (vmap[new_loc].contents == ' ')
cont_map[new_loc] = 1;
else {
- if (vmap[new_loc].contents == '+') this_terrain = '+';
- else if (vmap[new_loc].contents == '.') this_terrain = '.';
+ if (vmap[new_loc].contents == MAP_LAND)
+ this_terrain = MAP_LAND;
+ else if (vmap[new_loc].contents == MAP_SEA)
+ this_terrain = MAP_SEA;
else this_terrain = map[new_loc].contents;
if (this_terrain != bad_terrain) { /* on continent? */
COUNT ('t', counts.comp_objects[TRANSPORT]);
COUNT ('c', counts.comp_objects[CARRIER]);
COUNT ('b', counts.comp_objects[BATTLESHIP]);
- COUNT ('*', counts.unowned_cities);
- case '+': break;
- case '.': break;
+ COUNT (MAP_CITY, counts.unowned_cities);
+ case MAP_LAND: break;
+ case MAP_SEA: break;
default: /* check for city underneath */
- if (map[i].contents == '*') {
+ if (map[i].contents == MAP_CITY) {
switch (map[i].cityp->owner) {
COUNT (USER, counts.user_cities);
COUNT (COMP, counts.comp_cities);
for (i = 0; i < MAP_SIZE; i++) {
if (cont_map[i]) { /* cell on continent? */
counts.size += 1;
- if (map[i].contents == '*')
+ if (map[i].contents == MAP_CITY)
counts.unowned_cities += 1;
}
}
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;
- if (vmap[to_loc].contents == '.') return T_WATER;
+ if (vmap[to_loc].contents == MAP_LAND) return T_LAND;
+ if (vmap[to_loc].contents == MAP_SEA) return T_WATER;
if (vmap[to_loc].contents == '%') return T_UNKNOWN; /* magic objective */
if (vmap[to_loc].contents == ' ') return pmap[from_loc].terrain;
switch (map[to_loc].contents) {
- case '.': return T_WATER;
- case '+': return T_LAND;
- case '*':
+ case MAP_SEA: return T_WATER;
+ case MAP_LAND: return T_LAND;
+ case MAP_CITY:
if (map[to_loc].cityp->owner == move_info->city_owner)
return T_WATER;
- else return T_UNKNOWN; /* cannot cross */
+ else
+ return T_UNKNOWN; /* cannot cross */
}
ABORT;
/*NOTREACHED*/
FOR_ADJ (loc, new_loc, i) {
if (new_loc < 0 || new_loc >= MAP_SIZE); /* ignore off map */
else if (vmap[new_loc].contents == ' '); /* ignore adjacent unexplored */
- else if (map[new_loc].contents != '.')
+ else if (map[new_loc].contents != MAP_SEA)
pmap[loc].cost += 1; /* count land */
else pmap[loc].inc_cost += 1; /* count water */
}
*explored += 1;
- if (type == T_LAND) vmap[loc].contents = '+';
- else vmap[loc].contents = '.';
+ if (type == T_LAND)
+ vmap[loc].contents = MAP_LAND;
+ else
+ vmap[loc].contents = MAP_SEA;
FOR_ADJ (loc, new_loc, i)
if (new_loc >= 0 && new_loc < MAP_SIZE && vmap[new_loc].contents == ' ') {
loc_t i, j;
FOR_ADJ_ON (loc, j, i)
- if (map[j].contents == '.') return (true);
+ if (map[j].contents == MAP_SEA)
+ return (true);
return (false);
}
loc_t i, j;
FOR_ADJ_ON (loc, j, i)
- if (vmap[j].contents != ' ' && vmap[j].contents != '+' && map[j].contents == '.')
+ if (vmap[j].contents != ' ' &&
+ vmap[j].contents != MAP_LAND &&
+ map[j].contents == MAP_SEA)
return (true);
return (false);
{
loc_t i, j;
- if (map[loc].contents != '.') return (false);
+ if (map[loc].contents != MAP_SEA)
+ return (false);
FOR_ADJ_ON (loc, j, i)
- if (vmap[j].contents == ' ' || vmap[j].contents == '+' || map[j].contents != '.')
+ if (vmap[j].contents == ' '
+ || vmap[j].contents == MAP_LAND
+ || map[j].contents != MAP_SEA)
return (false);
return (true);
{
loc_t i, j;
- if (map[loc].contents != '.') return (false);
+ if (map[loc].contents != MAP_SEA)
+ return (false);
FOR_ADJ_ON (loc, j, i) {
- if (map[j].contents != '.') return (false);
+ if (map[j].contents != MAP_SEA)
+ return (false);
}
return (true);
}
city type.
*/
-char city_char[] = {'*', 'O', 'X'};
+char city_char[] = {MAP_CITY, 'O', 'X'};
void
update(view_map_t vmap[], loc_t loc)
"Sorry, sir. There is no more room on the transport. Do you insist? ",
"Your army jumped into the briny and drowned.");
- else if (map[loc].contents == '.') { /* going for a swim? */
+ else if (map[loc].contents == MAP_SEA) { /* going for a swim? */
bool enemy_killed = false;
if (!getyn ( /* thanks to Craig Hansen for this next message */
comment ("Your army jumped into the briny and drowned.");
ksend ("Your army jumped into the briny and drowned.\n");
}
- else if (user_map[loc].contents == '.')
+ else if (user_map[loc].contents == MAP_SEA)
{
comment ("Your army marched dutifully into the sea and drowned.");
ksend ("Your army marched dutifully into the sea and drowned.\n");
void
user_dir_fighter(piece_info_t *obj, loc_t loc)
{
- if (map[loc].contents == '*')
+ if (map[loc].contents == MAP_CITY)
fatal (obj, loc,
"That's never worked before, sir. Do you really want to try? ",
"Your fighter was shot down.");
void
user_dir_ship(piece_info_t *obj, loc_t loc)
{
- if (map[loc].contents == '*') {
+ if (map[loc].contents == MAP_CITY) {
(void) sprintf (jnkbuf, "Your %s broke up on shore.",
piece_attr[obj->type].name);
jnkbuf);
}
- else if (map[loc].contents == '+') { /* moving ashore? */
+ else if (map[loc].contents == MAP_LAND) { /* moving ashore? */
bool enemy_killed = false;
if (!getyn ("Ships need sea to float, sir. Do you really want to go ashore? ")) return;
- if (user_map[loc].contents == '+')
+ if (user_map[loc].contents == MAP_LAND)
{
comment ("Your %s broke up on shore.", piece_attr[obj->type].name);
ksend ("Your %s broke up on shore.", piece_attr[obj->type].name);
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 (islower (c) || c == MAP_CITY || c == 'X') {
if (obj->func < 0) obj->func = NOFUNC; /* awaken */
return (true);
}