void
attack_city (att_obj, loc)
piece_info_t *att_obj;
-long loc;
+loc_t loc;
{
city_info_t *cityp;
int att_owner, city_owner;
void
attack_obj (att_obj, loc)
piece_info_t *att_obj;
-long loc;
+loc_t loc;
{
void describe(), survive();
void
attack (att_obj, loc)
piece_info_t *att_obj;
-long loc;
+loc_t loc;
{
if (map[loc].contents == '*') /* attacking a city? */
attack_city (att_obj, loc);
void
survive (obj, loc)
piece_info_t *obj;
-long loc;
+loc_t loc;
{
while (obj_capacity (obj) < obj->count)
kill_obj (obj->cargo, loc);
void
describe (win_obj, lose_obj, loc)
piece_info_t *win_obj, *lose_obj;
-long loc;
+loc_t loc;
{
char buf[STRSIZE];
char buf2[STRSIZE];
static view_map_t emap[MAP_SIZE]; /* pruned explore map */
int load_army(piece_info_t *obj);
-int lake( long loc );
+int lake( loc_t loc );
int overproduced( city_info_t *cityp, int *city_count );
-int nearby_load( piece_info_t *obj, long loc );
-int nearby_count( long loc );
-void move_objective(piece_info_t *obj,path_map_t pathmap[],long new_loc,char *adj_list);
+int nearby_load( piece_info_t *obj, loc_t loc );
+int nearby_count( loc_t loc );
+void move_objective(piece_info_t *obj,path_map_t pathmap[],loc_t new_loc,char *adj_list);
void
comp_move (nmoves)
int city_count[NUM_OBJECTS]; /* # of cities producing each piece */
int cont_map[MAP_SIZE];
int total_cities;
- long i;
+ count_t i;
int comp_ac;
city_info_t *p;
int need_count, interest;
comp_ac = 0; /* no army producing computer cities */
for (i = 0; i < MAP_SIZE; i++)
- if (cont_map[i]) { /* for each cell of continent */
- if (comp_map[i].contents == 'X') {
- p = find_city (i);
- ASSERT (p != NULL && p->owner == COMP);
- if (p->prod == ARMY) comp_ac += 1;
- }
+ if (cont_map[i]) { /* for each cell of continent */
+ if (comp_map[i].contents == 'X') {
+ p = find_city (i);
+ ASSERT (p != NULL && p->owner == COMP);
+ if (p->prod == ARMY) comp_ac += 1;
+ }
}
/* see if anything of interest is on continent */
interest = (counts.unexplored || counts.user_cities
int
lake (loc)
-long loc;
+loc_t loc;
{
int cont_map[MAP_SIZE];
scan_counts_t counts;
int changed_loc;
int max_hits;
- long saved_loc;
+ loc_t saved_loc;
city_info_t *cityp;
if (obj->type == SATELLITE) {
army_move (obj)
piece_info_t *obj;
{
- long move_away();
- long find_attack();
+ loc_t move_away();
+ loc_t find_attack();
void make_army_load_map(), make_unload_map(), make_tt_load_map();
void board_ship();
- long new_loc;
+ loc_t new_loc;
path_map_t path_map2[MAP_SIZE];
- long new_loc2;
+ loc_t new_loc2;
int cross_cost; /* cost to enter water */
obj->func = 0; /* army doesn't want a tt */
unmark_explore_locs (xmap)
view_map_t *xmap;
{
- long i;
+ count_t i;
for (i = 0; i < MAP_SIZE; i++)
- if (map[i].on_board && xmap[i].contents == ' ')
- xmap[i].contents = emap[i].contents;
+ if (map[i].on_board && xmap[i].contents == ' ')
+ xmap[i].contents = emap[i].contents;
}
/*
int
nearby_load (obj, loc)
piece_info_t *obj;
-long loc;
+loc_t loc;
{
return obj->func == 1 && dist (obj->loc, loc) <= 2;
}
int
nearby_count (loc)
-long loc;
+loc_t loc;
{
piece_info_t *obj;
int count;
view_map_t *xmap;
view_map_t *vmap;
{
- long i;
+ count_t i;
scan_counts_t counts;
(void) memcpy (xmap, vmap, sizeof (view_map_t) * MAP_SIZE);
board_ship (obj, pmap, dest)
piece_info_t *obj;
path_map_t *pmap;
-long dest;
+loc_t dest;
{
if (!load_army (obj)) {
obj->func = 1; /* loading */
piece_info_t *
find_best_tt (best, loc)
piece_info_t *best;
-long loc;
+loc_t loc;
{
piece_info_t *p;
{
piece_info_t *p;
int i;
- long x_loc;
+ loc_t x_loc;
p = find_best_tt (obj->ship, obj->loc); /* look here first */
the correct terrain.
*/
-long
+loc_t
move_away (vmap, loc, terrain)
view_map_t *vmap;
-long loc;
+loc_t loc;
char *terrain;
{
- long new_loc;
+ loc_t new_loc;
int i;
for (i = 0; i < 8; i++) {
best of these.
*/
-long
+loc_t
find_attack (loc, obj_list, terrain)
-long loc;
+loc_t loc;
char *obj_list;
char *terrain;
{
- long new_loc, best_loc;
+ loc_t new_loc, best_loc;
int i, best_val;
char *p;
{
void tt_do_move();
- long new_loc;
+ loc_t new_loc;
/* empty transports can attack */
if (obj->count == 0) { /* empty? */
fighter_move (obj)
piece_info_t *obj;
{
- long new_loc;
+ loc_t new_loc;
new_loc = find_attack (obj->loc, fighter_attack, ".+");
if (new_loc != obj->loc) { /* something to attack? */
ship_move (obj)
piece_info_t *obj;
{
- long new_loc;
+ loc_t new_loc;
char *adj_list;
if (obj->hits < piece_attr[obj->type].max_hits) { /* head to port */
move_objective (obj, pathmap, new_loc, adj_list)
piece_info_t *obj;
path_map_t pathmap[];
-long new_loc;
+loc_t new_loc;
char *adj_list;
{
char *terrain;
char *attack_list;
int d;
int reuse; /* true iff we should reuse old map */
- long old_loc;
- long old_dest;
+ loc_t old_loc;
+ loc_t old_dest;
if (new_loc == obj->loc) {
obj->moved = piece_attr[obj->type].speed;
static int save_cursor; /* currently displayed cursor position */
static int change_ok = TRUE; /* true if new sector may be displayed */
-static void show_loc(view_map_t vmap[],long loc);
+static void show_loc(view_map_t vmap[],loc_t loc);
static void disp_square(view_map_t *vp);
-int on_screen(long loc);
+int on_screen(loc_t loc);
#ifdef A_COLOR
void init_colors(void)
is not on the screen, we return -1.
*/
-long cur_cursor (void) {
+loc_t cur_cursor (void) {
if (whose_map != USER) return (-1);
return (save_cursor);
}
display_loc (whose, vmap, loc)
int whose; /* whose map to display */
view_map_t vmap[];
-long loc; /* location to display */
+loc_t loc; /* location to display */
{
if (change_ok || whose != whose_map || !on_screen (loc))
print_sector (whose, vmap, loc_sector (loc));
display_locx (whose, vmap, loc)
int whose; /* whose map to display */
view_map_t vmap[];
-long loc; /* location to display */
+loc_t loc; /* location to display */
{
if (whose == whose_map && on_screen (loc))
show_loc (vmap, loc);
void
show_loc (vmap, loc)
view_map_t vmap[];
-long loc;
+loc_t loc;
{
int r, c;
{
int display_rows, display_cols;
int r, c;
- long t;
+ loc_t t;
display_rows = lines - NUMTOPS - 1; /* num lines to display */
display_cols = cols - NUMSIDES;
int
move_cursor (cursor, offset)
-long *cursor; /* current cursor position */
+loc_t *cursor; /* current cursor position */
int offset; /* offset to add to cursor */
{
- long t;
+ loc_t t;
int r, c;
t = *cursor + offset; /* proposed location */
*/
int on_screen (loc)
-long loc;
+loc_t loc;
{
int new_r, new_c;
#include "empire.h"
#include "extern.h"
-void e_move(long *path_start, long loc);
+void e_move(loc_t *path_start, loc_t loc);
extern int get_piece_name(void);
void
edit(edit_cursor)
-long edit_cursor;
+loc_t edit_cursor;
{
char e_cursor();
void e_leave(), e_print(), e_random();
void e_fill(), e_land(), e_city_func(), e_transport();
void e_attack(), e_repair();
- long path_start;
+ loc_t path_start;
int path_type;
char e;
char
e_cursor (edit_cursor)
-long *edit_cursor;
+loc_t *edit_cursor;
{
chtype e;
int p;
void
e_print (edit_cursor)
-long *edit_cursor;
+loc_t *edit_cursor;
{
int sector;
void
e_set_func (loc, func)
-long loc;
+loc_t loc;
long func;
{
piece_info_t *obj;
void
e_random (loc)
-long loc;
+loc_t loc;
{
e_set_func (loc, RANDOM);
}
void
e_fill (loc)
-long loc;
+loc_t loc;
{
if (user_map[loc].contents == 'T' || user_map[loc].contents == 'C')
e_set_func (loc, FILL);
void
e_explore (loc)
-long loc;
+loc_t loc;
{
e_set_func (loc, EXPLORE);
}
void
e_land (loc)
-long loc;
+loc_t loc;
{
if (user_map[loc].contents == 'F')
e_set_func (loc, LAND);
void
e_transport (loc)
-long loc;
+loc_t loc;
{
if (user_map[loc].contents == 'A')
e_set_func (loc, WFTRANSPORT);
void
e_attack (loc)
-long loc;
+loc_t loc;
{
if (user_map[loc].contents == 'A')
e_set_func (loc, ARMYATTACK);
void
e_repair (loc)
-long loc;
+loc_t loc;
{
if (strchr ("PDSTBC", user_map[loc].contents))
e_set_func (loc, REPAIR);
void
e_stasis (loc)
-long loc;
+loc_t loc;
{
char e;
char *p;
void
e_wake (loc)
-long loc;
+loc_t loc;
{
city_info_t *cityp;
piece_info_t *obj;
void
e_city_func (path_start, loc, path_type)
-long *path_start;
-long loc;
+loc_t *path_start;
+loc_t loc;
int *path_type;
{
int type;
void
e_move (path_start, loc)
-long *path_start;
-long loc;
+loc_t *path_start;
+loc_t loc;
{
if (!isupper(user_map[loc].contents)) huh (); /* nothing there? */
else if (user_map[loc].contents == 'X') huh (); /* enemy city? */
void
e_end (path_start, loc, path_type)
-long *path_start;
-long loc;
+loc_t *path_start;
+loc_t loc;
int path_type;
{
city_info_t *cityp;
void
e_sleep (loc)
-long loc;
+loc_t loc;
{
if (user_map[loc].contents == 'O') huh (); /* can't sleep a city */
else e_set_func (loc, SENTRY);
void
e_info (edit_cursor)
-long edit_cursor;
+loc_t edit_cursor;
{
void e_city_info(), e_piece_info();
void
e_piece_info (edit_cursor, ab)
-long edit_cursor;
+loc_t edit_cursor;
char ab;
{
piece_info_t *obj;
void
e_city_info (edit_cursor)
-long edit_cursor;
+loc_t edit_cursor;
{
piece_info_t *obj;
city_info_t *cityp;
void
e_prod (loc)
-long loc;
+loc_t loc;
{
city_info_t *cityp;
void
c_give () {
int unowned[NUM_CITY];
- long i, count;
+ count_t i, count;
count = 0; /* nothing in list yet */
for (i = 0; i < NUM_CITY; i++) {
typedef unsigned char uchar;
+typedef long loc_t; /* represent a board location in 4-digit form */
+
+typedef long count_t; /* for iterating over or counting board locations */
+
#define ASSERT(x) if (!(x)) assert ("x", __FILE__, __LINE__);
#define ABORT assert ("aborting", __FILE__, __LINE__)
#define LIST_SIZE 5000 /* max number of pieces on board */
typedef struct city_info {
- long loc; /* location of city */
+ loc_t loc; /* location of city */
uchar owner; /* UNOWNED, USER, COMP */
long func[NUM_OBJECTS]; /* function for each object */
long work; /* units of work performed */
link_t cargo_link; /* linked list of cargo pieces */
int owner; /* owner of piece */
int type; /* type of piece */
- long loc; /* location of piece */
+ loc_t loc; /* location of piece */
long func; /* programmed type of movement */
short hits; /* hits left */
int moved; /* moves made */
#include "empire.h"
#include "extern.h"
-long remove_land(long loc, long num_land);
+count_t remove_land(loc_t loc, count_t num_land);
int select_cities(void);
-int find_next(long *mapi);
-int good_cont(long mapi);
+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);
void stat_display( char *mbuf, int round);
void init_game (void) {
void make_map(void), place_cities(void);
- long i;
+ count_t i;
kill_display (); /* nothing on screen */
automove = FALSE;
void make_map (void) {
int from, to, k;
- long i, j, sum, loc;
+ count_t i, j, sum;
+ loc_t loc;
for (i = 0; i < MAP_SIZE; i++) /* fill map with random sand */
height[0][i] = irand (MAX_HEIGHT);
*/
/* avoid compiler problems with large automatic arrays */
-static long land[MAP_SIZE];
+static loc_t land[MAP_SIZE];
void place_cities (void) {
- long regen_land();
+ count_t regen_land();
- long placed, i, loc;
- long num_land;
+ count_t placed, i;
+ loc_t loc;
+ count_t num_land;
num_land = 0; /* nothing in land array yet */
placed = 0; /* nothing placed yet */
remove any land which is too close to a city.
*/
-long regen_land (placed)
-long placed;
+count_t regen_land (placed)
+count_t placed;
{
- long num_land;
- long i;
+ count_t num_land;
+ count_t i;
num_land = 0;
for (i = 0; i < MAP_SIZE; i++) {
Remove land that is too close to a city.
*/
-long remove_land (loc, num_land)
-long loc, num_land;
+count_t remove_land (loc, num_land)
+loc_t loc;
+count_t num_land;
{
- long new, i;
+ count_t new, i;
new = 0; /* nothing kept yet */
for (i = 0; i < num_land; i++) {
int select_cities (void) {
void find_cont(void), make_pair(void);
- long compi, useri;
+ loc_t compi, useri;
city_info_t *compp, *userp;
int comp_cont, user_cont;
int pair;
*/
void find_cont (void) {
- long i;
- long mapi;
+ loc_t i;
+ loc_t mapi;
for (i = 0; i < MAP_SIZE; i++) marked[i] = 0; /* nothing marked yet */
*/
int find_next (mapi)
-long *mapi;
+loc_t *mapi;
{
- long i, val;
+ count_t i;
+ long val;
for (;;) {
if (*mapi >= MAP_SIZE) return (FALSE);
continent and return true. Otherwise we return false.
*/
-static long ncity, nland, nshore;
-static void mark_cont(long);
+static count_t ncity, nland, nshore;
+static void mark_cont(loc_t);
int good_cont (mapi)
-long mapi;
+loc_t mapi;
{
long val;
static void
mark_cont (mapi)
-long mapi;
+loc_t mapi;
{
int i;
save_movie_screen (void)
{
FILE *f; /* file to save game in */
- long i;
+ count_t i;
piece_info_t *p;
f = fopen ("empmovie.dat", "a"); /* open for append */
char *mbuf;
int round;
{
- long i;
+ count_t i;
int counts[2*NUM_OBJECTS+2];
int user_cost, comp_cost;
char *p;
}
STATIC void 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);
-STATIC void expand_prune(view_map_t *vmap,path_map_t *pmap,long loc,int type,perimeter_t *to,int *explored);
-STATIC int objective_cost(view_map_t *vmap,move_info_t *move_info,long loc,int base_cost);
-STATIC int terrain_type(path_map_t *pmap,view_map_t *vmap,move_info_t *move_info,long from_loc,long to_loc);
-STATIC void start_perimeter(path_map_t *pmap,perimeter_t *perim,long loc,int terrain);
-STATIC void add_cell(path_map_t *pmap,long new_loc,perimeter_t *perim,int terrain,int cur_cost,int inc_cost);
-STATIC int vmap_count_path (path_map_t *pmap,long loc);
+STATIC void expand_prune(view_map_t *vmap,path_map_t *pmap,loc_t loc,int type,perimeter_t *to,int *explored);
+STATIC int objective_cost(view_map_t *vmap,move_info_t *move_info,loc_t loc,int base_cost);
+STATIC int terrain_type(path_map_t *pmap,view_map_t *vmap,move_info_t *move_info,loc_t from_loc,loc_t to_loc);
+STATIC void start_perimeter(path_map_t *pmap,perimeter_t *perim,loc_t loc,int terrain);
+STATIC void add_cell(path_map_t *pmap,loc_t new_loc,perimeter_t *perim,int terrain,int cur_cost,int inc_cost);
+STATIC int vmap_count_path (path_map_t *pmap,loc_t loc);
static perimeter_t p1; /* perimeter list for use as needed */
static perimeter_t p2;
static perimeter_t p4;
static int best_cost; /* cost and location of best objective */
-static long best_loc;
+static loc_t best_loc;
/*
Map out a continent. We are given a location on the continent.
vmap_cont (cont_map, vmap, loc, bad_terrain)
int *cont_map;
view_map_t *vmap;
-long loc;
+loc_t loc;
char bad_terrain;
{
(void) bzero ((char *)cont_map, MAP_SIZE * sizeof (int));
vmap_mark_up_cont (cont_map, vmap, loc, bad_terrain)
int *cont_map;
view_map_t *vmap;
-long loc;
+loc_t loc;
char bad_terrain;
{
int i, j;
- long new_loc;
+ loc_t new_loc;
char this_terrain;
perimeter_t *from, *to;
void
rmap_cont (cont_map, loc, bad_terrain)
int *cont_map;
-long loc;
+loc_t loc;
char bad_terrain;
{
(void) bzero ((char *)cont_map, MAP_SIZE * sizeof (int));
static void
rmap_mark_up_cont (cont_map, loc, bad_terrain)
int *cont_map;
-long loc;
+loc_t loc;
char bad_terrain;
{
int i;
- long new_loc;
+ loc_t new_loc;
if (!map[loc].on_board) return; /* off board */
if (cont_map[loc]) return; /* already marked */
view_map_t *vmap;
{
scan_counts_t counts;
- long i;
+ count_t i;
(void) bzero ((char *)&counts, sizeof (scan_counts_t));
int *cont_map;
{
scan_counts_t counts;
- long i;
+ count_t i;
(void) bzero ((char *)&counts, sizeof (scan_counts_t));
int
map_cont_edge (cont_map, loc)
int *cont_map;
-long loc;
+loc_t loc;
{
- long i, j;
+ loc_t i, j;
if (!cont_map[loc]) return FALSE; /* not on continent */
/* Find an objective over a single type of terrain. */
-long
+loc_t
vmap_find_xobj (path_map, vmap, loc, move_info, start, expand)
path_map_t path_map[];
view_map_t *vmap;
-long loc;
+loc_t loc;
move_info_t *move_info;
int start;
int expand;
/* Find an objective for a piece that crosses land and water. */
-long
+loc_t
vmap_find_aobj (path_map, vmap, loc, move_info)
path_map_t path_map[];
view_map_t *vmap;
-long loc;
+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. */
-long
+loc_t
vmap_find_wobj (path_map, vmap, loc, move_info)
path_map_t path_map[];
view_map_t *vmap;
-long loc;
+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. */
-long
+loc_t
vmap_find_lobj (path_map, vmap, loc, move_info)
path_map_t path_map[];
view_map_t *vmap;
-long loc;
+loc_t loc;
move_info_t *move_info;
{
return vmap_find_xobj (path_map, vmap, loc, move_info, T_LAND, T_LAND);
is being approached from the land or the water.
*/
-long
+loc_t
vmap_find_lwobj (path_map, vmap, loc, move_info, beat_cost)
path_map_t path_map[];
view_map_t *vmap;
-long loc;
+loc_t loc;
move_info_t *move_info;
int beat_cost;
{
STATIC int
best_adj (pmap, loc, type)
path_map_t *pmap;
-long loc;
+loc_t loc;
int type;
{
int i;
- long new_loc;
+ loc_t new_loc;
int best;
best = INFINITY;
but the second time, we only expand water (tt taking its second move).
*/
-long
+loc_t
vmap_find_wlobj (path_map, vmap, loc, move_info)
path_map_t path_map[];
view_map_t *vmap;
-long loc;
+loc_t loc;
move_info_t *move_info;
{
perimeter_t *cur_land;
start_perimeter (pmap, perim, loc, terrain)
path_map_t *pmap;
perimeter_t *perim;
-long loc;
+loc_t loc;
int terrain;
{
int i;
{
register long i;
register int j;
- long new_loc;
+ loc_t new_loc;
int obj_cost;
register int new_type;
for (i = 0; i < curp->len; i++) /* for each perimeter cell... */
- FOR_ADJ_ON (curp->list[i], new_loc, j) {/* for each adjacent cell... */
- register path_map_t *pm = pmap + new_loc;
-
- if (pm->cost == INFINITY) {
- new_type = terrain_type (pmap, vmap, move_info, curp->list[i], new_loc);
-
- if (new_type == T_LAND && (type & T_LAND))
- add_cell (pmap, new_loc, landp, new_type, cur_cost, inc_lcost);
- else if (new_type == T_WATER && (type & T_WATER))
- add_cell (pmap, new_loc, waterp, new_type, cur_cost, inc_wcost);
- else if (new_type == T_UNKNOWN) { /* unreachable cell? */
- pm->terrain = new_type;
- pm->cost = cur_cost + INFINITY/2;
- pm->inc_cost = INFINITY/2;
- }
- if (pmap[new_loc].cost != INFINITY) { /* did we expand? */
- obj_cost = objective_cost (vmap, move_info, new_loc, cur_cost);
- if (obj_cost < best_cost) {
- best_cost = obj_cost;
- best_loc = new_loc;
- if (new_type == T_UNKNOWN) {
- pm->cost=cur_cost+2;
- pm->inc_cost = 2;
+ FOR_ADJ_ON (curp->list[i], new_loc, j) {/* for each adjacent cell... */
+ register path_map_t *pm = pmap + new_loc;
+
+ if (pm->cost == INFINITY) {
+ new_type = terrain_type (pmap, vmap, move_info, curp->list[i], new_loc);
+
+ if (new_type == T_LAND && (type & T_LAND))
+ add_cell (pmap, new_loc, landp, new_type, cur_cost, inc_lcost);
+ else if (new_type == T_WATER && (type & T_WATER))
+ add_cell (pmap, new_loc, waterp, new_type, cur_cost, inc_wcost);
+ else if (new_type == T_UNKNOWN) { /* unreachable cell? */
+ pm->terrain = new_type;
+ pm->cost = cur_cost + INFINITY/2;
+ pm->inc_cost = INFINITY/2;
+ }
+ if (pmap[new_loc].cost != INFINITY) { /* did we expand? */
+ obj_cost = objective_cost (vmap, move_info, new_loc, cur_cost);
+ if (obj_cost < best_cost) {
+ best_cost = obj_cost;
+ best_loc = new_loc;
+ if (new_type == T_UNKNOWN) {
+ pm->cost=cur_cost+2;
+ pm->inc_cost = 2;
+ }
}
}
}
}
- }
}
/* Add a cell to a perimeter list. */
STATIC void
add_cell (pmap, new_loc, perim, terrain, cur_cost, inc_cost)
path_map_t *pmap;
-long new_loc;
+loc_t new_loc;
perimeter_t *perim;
int terrain;
int cur_cost;
objective_cost (vmap, move_info, loc, base_cost)
view_map_t *vmap;
move_info_t *move_info;
-long loc;
+loc_t loc;
int base_cost;
{
char *p;
path_map_t *pmap;
view_map_t *vmap;
move_info_t *move_info;
-long from_loc;
-long to_loc;
+loc_t from_loc;
+loc_t to_loc;
{
if (vmap[to_loc].contents == '+') return T_LAND;
if (vmap[to_loc].contents == '.') return T_WATER;
path_map_t pmap[MAP_SIZE];
perimeter_t *from, *to;
int explored;
- long loc, new_loc;
- long i;
+ loc_t loc, new_loc;
+ count_t i;
long copied;
(void) bzero (pmap, sizeof (pmap));
expand_prune (vmap, pmap, loc, type, to, explored)
view_map_t *vmap;
path_map_t *pmap;
-long loc;
+loc_t loc;
int type;
perimeter_t *to;
int *explored;
{
int i;
- long new_loc;
+ loc_t new_loc;
*explored += 1;
This is similar to 'find_objective' except that we know our destination.
*/
-long
+loc_t
vmap_find_dest (path_map, vmap, cur_loc, dest_loc, owner, terrain)
path_map_t path_map[];
view_map_t vmap[];
-long cur_loc; /* current location of piece */
-long dest_loc; /* destination of piece */
+loc_t cur_loc; /* current location of piece */
+loc_t dest_loc; /* destination of piece */
int owner; /* owner of piece being moved */
int terrain; /* terrain we can cross */
{
vmap_mark_path (path_map, vmap, dest)
path_map_t *path_map;
view_map_t *vmap;
-long dest;
+loc_t dest;
{
int n;
- long new_dest;
+ loc_t new_dest;
if (path_map[dest].cost == 0) return; /* reached end of path */
if (path_map[dest].terrain == T_PATH) return; /* already marked */
void
vmap_mark_adjacent (path_map, loc)
path_map_t path_map[];
-long loc;
+loc_t loc;
{
int i;
- long new_loc;
+ loc_t new_loc;
FOR_ADJ_ON (loc, new_loc, i)
path_map[new_loc].terrain = T_PATH;
void
vmap_mark_near_path (path_map, loc)
path_map_t path_map[];
-long loc;
+loc_t loc;
{
int i, j;
- long new_loc, xloc;
+ loc_t new_loc, xloc;
int hit_loc[8];
(void) bzero ((char *)hit_loc, sizeof(int)*8);
static int order[] = {NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST,
WEST, EAST, NORTH, SOUTH};
-long
+loc_t
vmap_find_dir (path_map, vmap, loc, terrain, adj_char)
path_map_t path_map[];
view_map_t *vmap;
-long loc;
+loc_t loc;
char *terrain;
char *adj_char;
{
int i, count, bestcount;
- long bestloc, new_loc;
+ loc_t bestloc, new_loc;
int path_count, bestpath;
char *p;
int
vmap_count_adjacent (vmap, loc, adj_char)
view_map_t *vmap;
-long loc;
+loc_t loc;
char *adj_char;
{
int i, count;
- long new_loc;
+ loc_t new_loc;
char *p;
int len;
int
vmap_count_path (pmap, loc)
path_map_t *pmap;
-long loc;
+loc_t loc;
{
int i, count;
- long new_loc;
+ loc_t new_loc;
count = 0;
int
rmap_shore (loc)
-long loc;
+loc_t loc;
{
- long i, j;
+ loc_t i, j;
FOR_ADJ_ON (loc, j, i)
- if (map[j].contents == '.') return (TRUE);
+ if (map[j].contents == '.') return (TRUE);
return (FALSE);
}
int
vmap_shore (vmap, loc)
view_map_t *vmap;
-long loc;
+loc_t loc;
{
- long i, j;
+ loc_t i, j;
FOR_ADJ_ON (loc, j, i)
- if (vmap[j].contents != ' ' && vmap[j].contents != '+' && map[j].contents == '.')
- return (TRUE);
+ if (vmap[j].contents != ' ' && vmap[j].contents != '+' && map[j].contents == '.')
+ return (TRUE);
return (FALSE);
}
int
vmap_at_sea (vmap, loc)
view_map_t *vmap;
-long loc;
+loc_t loc;
{
- long i, j;
+ loc_t i, j;
if (map[loc].contents != '.') return (FALSE);
- FOR_ADJ_ON (loc, j, i)
- if (vmap[j].contents == ' ' || vmap[j].contents == '+' || map[j].contents != '.')
- return (FALSE);
+ FOR_ADJ_ON (loc, j, i)
+ if (vmap[j].contents == ' ' || vmap[j].contents == '+' || map[j].contents != '.')
+ return (FALSE);
return (TRUE);
}
int
rmap_at_sea (loc)
-long loc;
+loc_t loc;
{
- long i, j;
+ loc_t i, j;
if (map[loc].contents != '.') return (FALSE);
- FOR_ADJ_ON (loc, j, i) {
- if (map[j].contents != '.') return (FALSE);
- }
+ FOR_ADJ_ON (loc, j, i) {
+ if (map[j].contents != '.') return (FALSE);
+ }
return (TRUE);
}
int
dist (a, b)
-long a, b;
+loc_t a, b;
{
int ax, ay, bx, by;
int
find_nearest_city (loc, owner, city_loc)
-long loc;
+loc_t loc;
int owner;
-long *city_loc;
+loc_t *city_loc;
{
- long best_dist, best_loc;
+ loc_t best_loc;
+ long best_dist;
long new_dist, i;
best_dist = INFINITY;
*/
city_info_t *find_city (loc)
-long loc;
+loc_t loc;
{
return (map[loc].cityp);
}
piece_info_t *find_obj (type, loc)
int type;
-long loc;
+loc_t loc;
{
piece_info_t *p;
piece_info_t *find_nfull (type, loc)
int type;
-long loc;
+loc_t loc;
{
piece_info_t *p;
of the transport if there is one.
*/
-long
+loc_t
find_transport (owner, loc)
int owner;
-long loc;
+loc_t loc;
{
int i;
- long new_loc;
+ loc_t new_loc;
piece_info_t *t;
for (i = 0; i < 8; i++) { /* look around */
piece_info_t *
find_obj_at_loc (loc)
-long loc;
+loc_t loc;
{
piece_info_t *p, *best;
void kill_obj (obj, loc)
piece_info_t *obj;
-long loc;
+loc_t loc;
{
void kill_one();
void move_obj (obj, new_loc)
piece_info_t *obj;
-long new_loc;
+loc_t new_loc;
{
view_map_t *vmap;
- long old_loc;
+ loc_t old_loc;
piece_info_t *p;
ASSERT (obj->hits);
/* Return next direction for a sattellite to travel. */
-static long
+static loc_t
bounce (loc, dir1, dir2, dir3)
-long loc, dir1, dir2, dir3;
+loc_t loc, dir1, dir2, dir3;
{
int new_loc;
piece_info_t *obj;
{
int dir;
- long new_loc;
+ loc_t new_loc;
dir = MOVE_DIR(obj->func);
new_loc = obj->loc + dir_offset[dir];
int good_loc (obj, loc)
piece_info_t *obj;
-long loc;
+loc_t loc;
{
view_map_t *vmap;
piece_info_t *p;
void
scan (vmap, loc)
view_map_t vmap[];
-long loc;
+loc_t loc;
{
void update(), check(void);
int i;
- long xloc;
+ loc_t xloc;
#ifdef DEBUG
check (); /* perform a consistency check */
void
scan_sat (vmap, loc)
view_map_t *vmap;
-long loc;
+loc_t loc;
{
int i;
- long xloc;
+ loc_t xloc;
ASSERT (map[loc].on_board);
void
update (vmap, loc)
view_map_t vmap[];
-long loc;
+loc_t loc;
{
piece_info_t *p;
#include "empire.h"
#include "extern.h"
-void fatal(piece_info_t *obj,long loc,char *message,char *response);
-void move_to_dest(piece_info_t *obj,long dest);
-void move_army_to_city(piece_info_t *obj,long city_loc);
+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);
extern int get_piece_name(void);
int speed, max_hits;
int saved_moves;
int need_input;
- long saved_loc;
+ loc_t saved_loc;
city_info_t *cityp;
/* set func for piece if on city */
void move_random (obj)
piece_info_t *obj;
{
- long loc_list[8];
+ loc_t loc_list[8];
int i, nloc;
- long loc;
+ loc_t loc;
nloc = 0;
piece_info_t *obj;
{
path_map_t path_map[MAP_SIZE];
- long loc;
+ loc_t loc;
char *terrain;
switch (obj->type) {
move_transport (obj)
piece_info_t *obj;
{
- long loc;
+ loc_t loc;
/* look for an adjacent transport */
loc = find_transport (USER, obj->loc);
move_armyload (obj)
piece_info_t *obj;
{
- long loc;
+ loc_t loc;
piece_info_t *p;
int i;
piece_info_t *obj;
{
path_map_t path_map[MAP_SIZE];
- long loc;
+ loc_t loc;
ASSERT (obj->type == ARMY);
piece_info_t *obj;
{
path_map_t path_map[MAP_SIZE];
- long loc;
+ loc_t loc;
ASSERT (obj->type > FIGHTER);
move_land (obj)
piece_info_t *obj;
{
- long best_dist, best_loc;
+ long best_dist;
+ loc_t best_loc;
long new_dist;
piece_info_t *p;
void move_dir (obj)
piece_info_t *obj;
{
- long loc;
+ loc_t loc;
int dir;
dir = MOVE_DIR (obj->func);
void move_to_dest (obj, dest)
piece_info_t *obj;
-long dest;
+loc_t dest;
{
path_map_t path_map[MAP_SIZE];
int fterrain;
char *mterrain;
- long new_loc;
+ loc_t new_loc;
switch (obj->type) {
case ARMY:
{
void user_dir_army(), user_dir_fighter(), user_dir_ship();
- long loc;
+ loc_t loc;
loc = obj->loc + dir_offset[dir];
void
user_dir_army (obj, loc)
piece_info_t *obj;
-long loc;
+loc_t loc;
{
int enemy_killed;
void
user_dir_fighter (obj, loc)
piece_info_t *obj;
-long loc;
+loc_t loc;
{
if (map[loc].contents == '*')
fatal (obj, loc,
void
user_dir_ship (obj, loc)
piece_info_t *obj;
-long loc;
+loc_t loc;
{
int enemy_killed;
void
move_army_to_city (obj, city_loc)
piece_info_t *obj;
-long city_loc;
+loc_t city_loc;
{
piece_info_t *tt;
void
fatal (obj, loc, message, response)
piece_info_t *obj;
-long loc;
+loc_t loc;
char *message;
char *response;
{