From f4bfa05a114222346f287478ab5cea726244e659 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 28 Jul 2000 05:12:54 +0000 Subject: [PATCH] This folds in James Jordan's changes. --- README | 18 ++++- compmove.c | 32 ++++---- display.c | 22 +++--- edit.c | 6 +- empire.c | 25 +++--- empire.h | 2 +- extern.h | 220 +++++++++++++++++++++++++++------------------------ game.c | 18 ++--- map.c | 19 +++-- math.c | 1 + usermove.c | 61 ++++++++------ util.c | 36 ++++++++- vms-empire.6 | 21 +++-- 13 files changed, 269 insertions(+), 212 deletions(-) diff --git a/README b/README index b9c17f2..6c82544 100644 --- a/README +++ b/README @@ -9,10 +9,20 @@ C Empire Sources -Eric S. Raymond colorized and speed-tuned this and added a -save-interval option. Also, the victory-odds table in previous -versions was seriously buggy. The rest of this history is Chuck Simmons's -original notes. +Here's my change-log. + +1.2: Fri Jul 28 01:10:00 EDT 2000 + The victory-odds table in previous versions was seriously buggy. + I folded in corrections from Michael Self. I also took changes + from James T. Jordan , who wrote some + speedups, added ANSI prototypes, and cleaned +1.1: + I colorized and speed-tuned this and added a + save-interval option. + +The rest of this history is Chuck Simmons's original notes. + + -- Eric S. Raymond History diff --git a/compmove.c b/compmove.c index a4b0533..21e40e7 100644 --- a/compmove.c +++ b/compmove.c @@ -29,8 +29,8 @@ For each move the user wants us to make, we do the following: static view_map_t emap[MAP_SIZE]; /* pruned explore map */ -int load_army(); - void move_objective(); +int load_army(piece_info_t *obj); +void move_objective(piece_info_t *obj,path_map_t pathmap[],long new_loc,char *adj_list); void comp_move (nmoves) @@ -48,7 +48,7 @@ int nmoves; scan (comp_map, obj->loc); /* refresh comp's view of world */ for (i = 1; i <= nmoves; i++) { /* for each move we get... */ - comment ("Thinking..."); + comment ("Thinking...",0,0,0,0,0,0,0,0); (void) memcpy (emap, comp_map, MAP_SIZE * sizeof (view_map_t)); vmap_prune_explore_locs (emap); @@ -271,9 +271,7 @@ int type; { if (cityp->prod == type) return; - pdebug ("Changing city prod at %d from %d to %d\n", - cityp->loc, cityp->prod, type); - + pdebug ("Changing city prod at %d from %d to %d\n",cityp->loc, cityp->prod, type,0,0,0,0,0); cityp->prod = type; cityp->work = -(piece_attr[type].build_time / 5); } @@ -435,7 +433,8 @@ piece_info_t *obj; if (comp_map[obj->loc].contents == 'X') obj->moved = piece_attr[FIGHTER].speed; else if (obj->range == 0) { - pdebug ("Fighter at %d crashed and burned\n", obj->loc); + pdebug ("Fighter at %d crashed and burned\n", obj->loc,0,0,0,0,0,0,0); + ksend ("Fighter at %d crashed and burned\n", obj->loc,0,0,0,0,0,0,0); kill_obj (obj, obj->loc); /* crash & burn */ } } @@ -916,7 +915,7 @@ piece_info_t *obj; (void) memcpy (amap, comp_map, MAP_SIZE * sizeof (view_map_t)); unmark_explore_locs (amap); if (print_vmap == 'S') print_xzoom (amap); - new_loc = vmap_find_wobj (path_map, amap, obj->loc, &tt_explore); + new_loc = vmap_find_wobj (path_map, amap, obj->loc,&tt_explore); } move_objective (obj, path_map, new_loc, "a "); @@ -985,8 +984,7 @@ piece_info_t *obj; obj->moved = piece_attr[obj->type].speed; return; } - new_loc = vmap_find_wobj (path_map, comp_map, obj->loc, - &ship_repair); + new_loc = vmap_find_wobj (path_map, comp_map, obj->loc, &ship_repair); adj_list = "."; } @@ -1001,8 +999,7 @@ piece_info_t *obj; unmark_explore_locs (amap); if (print_vmap == 'S') print_xzoom (amap); - new_loc = vmap_find_wobj (path_map, amap, obj->loc, - &ship_fight); + new_loc = vmap_find_wobj (path_map, amap, obj->loc,&ship_fight); adj_list = ship_fight.objectives; } @@ -1030,8 +1027,7 @@ char *adj_list; if (new_loc == obj->loc) { obj->moved = piece_attr[obj->type].speed; obj->range -= 1; - pdebug ("No destination found for %d at %d; func=%d\n", - obj->type, obj->loc, obj->func); + pdebug ("No destination found for %d at %d; func=%d\n", obj->type, obj->loc, obj->func,0,0,0,0,0); return; } old_loc = obj->loc; /* remember where we are */ @@ -1074,8 +1070,7 @@ char *adj_list; obj->moved = piece_attr[obj->type].speed; if (obj->type == ARMY && obj->ship) ; - else pdebug ("Cannot move %d at %d toward objective; func=%d\n", - obj->type, obj->loc, obj->func); + else pdebug ("Cannot move %d at %d toward objective; func=%d\n", obj->type, obj->loc, obj->func,0,0,0,0,0); } else move_obj (obj, new_loc); @@ -1155,8 +1150,9 @@ check_endgame () { /* see if game is over */ if (ncomp_city < nuser_city/3 && ncomp_army < nuser_army/3) { clear_screen (); - prompt ("The computer acknowledges defeat. Do"); - error ("you wish to smash the rest of the enemy? "); + prompt ("The computer acknowledges defeat. Do",0,0,0,0,0,0,0,0); + ksend ("The computer acknowledges defeat.",0,0,0,0,0,0,0,0); + error ("you wish to smash the rest of the enemy? ",0,0,0,0,0,0,0,0); if (get_chx() != 'Y') empend (); (void) addstr ("\nThe enemy inadvertantly revealed its code used for"); diff --git a/display.c b/display.c index 3aabdfa..bf99a28 100644 --- a/display.c +++ b/display.c @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.5 1992/08/18 22:39:00 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: display.c,v 1.6 1994/12/01 15:54:31 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -35,8 +35,8 @@ static int save_sector; /* the currently displayed sector */ static int save_cursor; /* currently displayed cursor position */ static int change_ok = TRUE; /* true if new sector may be displayed */ -static void show_loc(); -static disp_square(); +static void show_loc(view_map_t vmap[],long loc); +static disp_square(view_map_t *vp); #ifdef A_COLOR void init_colors() @@ -223,13 +223,13 @@ int sector; /* sector to display */ /* print x-coordinates along bottom of screen */ for (c = ref_col; c < ref_col + display_cols && c < MAP_WIDTH; c++) if (c % 10 == 0) { - pos_str (lines-1, c-ref_col, "%d", c); + pos_str (lines-1, c-ref_col, "%d", c,0,0,0,0,0,0,0); } /* print y-coordinates along right of screen */ for (r = ref_row; r < ref_row + display_rows && r < MAP_HEIGHT; r++) { if (r % 2 == 0) - pos_str (r-ref_row+NUMTOPS, cols-NUMSIDES+1, "%2d", r); - else pos_str (r-ref_row+NUMTOPS, cols-NUMSIDES+1, " "); + pos_str (r-ref_row+NUMTOPS, cols-NUMSIDES+1, "%2d", r,0,0,0,0,0,0,0); + else pos_str (r-ref_row+NUMTOPS, cols-NUMSIDES+1, " ",0,0,0,0,0,0,0,0); } /* print round number */ (void) sprintf (jnkbuf, "Sector %d Round %d", sector, date); @@ -365,7 +365,7 @@ view_map_t *vmap; { print_zoom (vmap); #if 0 - prompt ("Hit a key: "); + prompt ("Hit a key: ",0,0,0,0,0,0,0,0); (void) get_chx (); /* wait for user */ #endif } @@ -394,7 +394,7 @@ view_map_t *vmap; for (c = 0; c < MAP_WIDTH; c += col_inc) print_zoom_cell (vmap, r, c, row_inc, col_inc); - pos_str (0, 0, "Round #%d", date); + pos_str (0, 0, "Round #%d", date,0,0,0,0,0,0,0); (void) refresh (); } @@ -447,7 +447,7 @@ view_map_t *vmap; for (c = 0; c < MAP_WIDTH; c += col_inc) print_pzoom_cell (pmap, vmap, r, c, row_inc, col_inc); - prompt (s); + prompt (s,0,0,0,0,0,0,0,0); (void) get_chx (); /* wait for user */ (void) refresh (); @@ -509,6 +509,6 @@ Display the score off in the corner of the screen. void display_score () { - pos_str (0, cols-12, " User Comp"); - pos_str (1, cols-12, "%5d %5d", user_score, comp_score); + pos_str (1, cols-12, " User Comp",0,0,0,0,0,0,0,0); + pos_str (2, cols-12, "%5d %5d", user_score, comp_score,0,0,0,0,0,0); } diff --git a/edit.c b/edit.c index cfb917d..e532e52 100644 --- a/edit.c +++ b/edit.c @@ -22,7 +22,7 @@ edit.c -- Routines to handle edit mode commands. #include "empire.h" #include "extern.h" -void e_move(); +void e_move(long *path_start, long loc); void edit(edit_cursor) @@ -571,7 +571,7 @@ long edit_cursor; char temp_buf[STRSIZE]; char junk_buf2[STRSIZE]; - error (0); /* clear line */ + error (0,0,0,0,0,0,0,0,0); /* clear line */ f = 0; /* no fighters counted yet */ for (obj = map[edit_cursor].objp; obj != NULL; @@ -639,6 +639,6 @@ get help void e_help () { help (help_edit, edit_lines); - prompt ("Press any key to continue: "); + prompt ("Press any key to continue: ",0,0,0,0,0,0,0,0); (void) get_chx (); } diff --git a/empire.c b/empire.c index a485975..79e415f 100644 --- a/empire.c +++ b/empire.c @@ -1,4 +1,4 @@ -/* $Id: empire.c,v 1.2 1990/03/29 23:22:07 eric Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: empire.c,v 1.3 1994/12/01 15:54:33 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -33,7 +33,7 @@ empire () { clear_screen (); /* nothing on screen */ (void) move (7, 0); ver (); - pos_str (8, 0, "Detailed directions are in EMPIRE.DOC\n"); + pos_str (8, 0, "Detailed directions are in EMPIRE.DOC\n",0,0,0,0,0,0,0,0); (void) refresh (); if (!restore_game ()) /* try to restore previous game */ @@ -49,9 +49,9 @@ empire () { save_game (); } else { - prompt (0); /* blank top line */ + prompt (0,0,0,0,0,0,0,0,0); /* blank top line */ (void) refresh (); - prompt ("Your orders? "); + prompt ("Your orders? ",0,0,0,0,0,0,0,0); order = get_chx (); /* get a command */ do_command (order); } @@ -75,7 +75,7 @@ char orders; switch (orders) { case 'A': /* turn on auto move mode */ automove = TRUE; - error ("Now in Auto-Mode"); + error ("Now in Auto-Mode",0,0,0,0,0,0,0,0); user_move (); comp_move (1); save_game (); @@ -86,7 +86,7 @@ char orders; break; case 'D': /* display round number */ - error ("Round #%d", date); + error ("Round #%d", date,0,0,0,0,0,0,0); break; case 'E': /* examine enemy map */ @@ -144,13 +144,13 @@ char orders; case 'T': /* trace: toggle save_movie flag */ save_movie = !save_movie; - if (save_movie) comment ("Saving movie screens to 'empmovie.dat'."); - else comment ("No longer saving movie screens."); + if (save_movie) comment ("Saving movie screens to 'empmovie.dat'.",0,0,0,0,0,0,0,0); + else comment ("No longer saving movie screens.",0,0,0,0,0,0,0,0); break; case 'W': /* watch movie */ if (resigned || debug) replay_movie (); - else error ("You cannot watch movie until computer resigns."); + else error ("You cannot watch movie until computer resigns.",0,0,0,0,0,0,0,0); break; case 'Z': /* print compressed map */ @@ -197,7 +197,8 @@ c_give () { } } if (count == 0) { - error ("There are no unowned cities."); + error ("There are no unowned cities.",0,0,0,0,0,0,0,0); + ksend ("There are no unowned cities.",0,0,0,0,0,0,0,0); return; } i = irand (count); @@ -282,12 +283,12 @@ c_map () { int i, j; char line[MAP_HEIGHT+2]; - prompt ("Filename? "); + prompt ("Filename? ",0,0,0,0,0,0,0,0); get_str (jnkbuf, STRSIZE); f = fopen (jnkbuf, "w"); if (f == NULL) { - error ("I can't open that file."); + error ("I can't open that file.",0,0,0,0,0,0,0,0); return; } for (i = 0; i < MAP_WIDTH; i++) { /* for each column */ diff --git a/empire.h b/empire.h index 08fb94d..adc0691 100644 --- a/empire.h +++ b/empire.h @@ -177,7 +177,7 @@ but the way has been paved to allow user's to change attributes at the beginning of a game. */ -#define INFINITY 1000000 /* a large number */ +#define INFINITY 10000000 /* a large number */ typedef struct piece_attr { char sname; /* eg 'C' */ diff --git a/extern.h b/extern.h index 934ebe9..f41786a 100644 --- a/extern.h +++ b/extern.h @@ -1,4 +1,4 @@ -/* $Id: extern.h,v 1.2 1990/03/29 23:22:44 eric Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: extern.h,v 1.3 1994/12/01 15:54:36 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -109,120 +109,130 @@ int comp_score; void empire(); -void attack(); -void comp_move(); +void attack(piece_info_t *att_obj, long loc); +void comp_move(int nmoves); void user_move(); -void edit(); +void edit(long edit_cursor); /* map routines */ -void vmap_cont(); -void rmap_cont(); -void vmap_mark_up_cont(); -scan_counts_t vmap_cont_scan(); -scan_counts_t rmap_cont_scan(); -int map_cont_edge(); -long vmap_find_aobj(); -long vmap_find_wobj(); -long vmap_find_lobj(); -long vmap_find_lwobj(); -long vmap_find_wlobj(); -long vmap_find_dest(); -void vmap_prune_explore_locs(); -void vmap_mark_path(); -void vmap_mark_adjacent(); -void vmap_mark_near_path(); -long vmap_find_dir(); -int vmap_count_adjacent(); -int vmap_shore(); -int rmap_shore(); -int vmap_at_sea(); -int rmap_at_sea(); - -void kill_display(); /* display routines */ -void sector_change(); -int cur_sector(); -long cur_cursor(); -void display_loc(); -void display_locx(); -void print_sector(); -int move_cursor(); -void print_zoom(); -void print_pzoom(); -void print_xzoom(); -void display_score(); +void vmap_cont (int *cont_map, view_map_t *vmap, long loc, char bad_terrain); +void rmap_cont (int *cont_map, long loc, char bad_terrain); +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); +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); +long vmap_find_lwobj (path_map_t path_map[],view_map_t *vmap,long loc,move_info_t *move_info,int beat_cost); +long vmap_find_wlobj (path_map_t path_map[], view_map_t *vmap, long loc, move_info_t *move_info); +long vmap_find_dest (path_map_t path_map[], view_map_t vmap[], long cur_loc, long dest_loc, int owner, int terrain); +void vmap_prune_explore_locs (view_map_t *vmap); +void vmap_mark_path (path_map_t *path_map, view_map_t *vmap, long dest); +void vmap_mark_adjacent (path_map_t path_map[], long loc); +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); + +void kill_display (); /* display routines */ +void sector_change (); +int cur_sector (); +long cur_cursor (); +void display_loc (int whose, view_map_t vmap[], long loc); +void display_locx (int whose, view_map_t vmap[], long loc); +void print_sector (int whose, view_map_t vmap[], int sector); +int move_cursor (long *cursor, int offset); +void print_zoom (view_map_t *vmap); +void print_pzoom (char *s, path_map_t *pmap, view_map_t *vmap); +void print_xzoom (view_map_t *vmap); +void display_score (); #ifdef A_COLOR -void init_colors(); +void init_colors (); #endif /* A_COLOR */ -void init_game(); /* game routines */ -void save_game(); -int restore_game(); -void save_movie_screen(); -void replay_movie(); - -void get_str(); /* input routines */ -void get_strq(); -char get_chx(); -int getint(); -char get_c(); -char get_cq(); -int getyn(); -int get_range(); - -void rndini(); /* math routines */ -long irand(); -int dist(); -int isqrt(); - -int find_nearest_city(); -city_info_t *find_city(); /* object routines */ -piece_info_t *find_obj(); -piece_info_t *find_nfull(); -long find_transport(); -piece_info_t *find_obj_at_loc(); -int obj_moves(); -int obj_capacity(); -void kill_obj(); -void kill_city(); -void produce(); -void move_obj(); -void move_sat(); -int good_loc(); -void embark(); -void disembark(); -void describe_obj(); -void scan(); -void scan_sat(); -void set_prod(); +void init_game (); /* game routines */ +void save_game (); +int restore_game (); +void save_movie_screen (); +void replay_movie (); + +void get_str (char *buf, int sizep); /* input routines */ +void get_strq (char *buf, int sizep); +char get_chx (); +int getint (char *message); +char get_c (); +char get_cq (); +int getyn (char *message); +int get_range (char *message, int low, int high); + +void rndini (); /* math routines */ +long irand (long high); +int dist (long a, long b); +int isqrt (int n); + +int find_nearest_city (long loc, int owner, long *city_loc); +city_info_t *find_city (long loc); /* object routines */ +piece_info_t *find_obj (int type, long loc); +piece_info_t *find_nfull (int type, long loc); +long find_transport (int owner, long loc); +piece_info_t *find_obj_at_loc (long loc); +int obj_moves (piece_info_t *obj); +int obj_capacity (piece_info_t *obj); +void kill_obj (piece_info_t *obj, long loc); +void kill_city (city_info_t *cityp); +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); +void embark (piece_info_t *ship, piece_info_t *obj); +void disembark (piece_info_t *obj); +void describe_obj (piece_info_t *obj); +void scan (view_map_t vmap[], long loc); +void scan_sat (view_map_t *vmap, long loc); +void set_prod (city_info_t *cityp); /* terminal routines */ -void pdebug(); -void topini(); -void clreol(); -void topmsg(); -void prompt(); -void error(); -void info(); -void comment(); -void extra(); -void huh(); -void help(); -void set_need_delay(); +void pdebug (char *s, int a, int b, int c, int d, int e, int f, int g, int h); +void topini (); +void clreol (int linep, int colp); +void topmsg (int linep, char *buf, int a, int b, int c, int d, int e, int f, int g, int h); +void topmsg1 (int linep, char *buf, char *a, int b, int c, int d, int e, int f, int g, int h); +void topmsg2 (int linep, char *buf, char *a, int b, int c, int d, char *e, char *f, int g, int h); +void prompt (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); +void prompt1 (char *buf, char *a, int b, int c, int d, int e, int f, int g, int h); +void prompt2 (char *buf, char *a, int b, int c, int d, char *e, char *f, int g, int h); +void error (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); +void info (char *a, char *b, char *c); +void comment (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); +void comment1 (char *buf,char *a, int b, int c, int d, int e, int f, int g, int h); +void extra (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); +void huh (); +void help (char **text, int nlines); +void set_need_delay (); +void ksend (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); +void ksend1 (char *buf, char *a, int b, int c, int d, int e, int f, int g, int h); /* utility routines */ -void ttinit(); -void redraw(); -void clear_screen(); -void delay(); -void close_disp(); -void pos_str(); -void addprintf(); -void assert(); -void empend(); -void ver(); -char upper(); -void tupper(); -void check(); +void ttinit (); +void redraw (); +void clear_screen (); +void delay (); +void close_disp (); +void pos_str (int row, int col, char *str, int a, int b, int c, int d, int e, int f, int g, int h); +void pos_str1 (int row, int col, char *str, char *a, int b, int c, int d, int e, int f, int g, int h); +void addprintf (char *str, int a, int b, int c, int d, int e, int f, int g, int h); +void addprintf1 (char *str, char *a, int b, int c, int d, int e, int f, int g, int h); +void addprintf2 (char *str, char *a, int b, int c, int d, char *e, char *f, int g, int h); +void assert (char *expression, char *file, int line); +void empend (); +void ver (); +char upper (char c); +void tupper (char *str); +void check (); /* randon routines we use */ long time(); diff --git a/game.c b/game.c index 8b2adba..a5e20db 100644 --- a/game.c +++ b/game.c @@ -22,7 +22,7 @@ game.c -- Routines to initialize, save, and restore a game. #include "empire.h" #include "extern.h" -long remove_land(); +long remove_land(long loc, long num_land); /* Initialize a new game. Here we generate a new random map, put cities @@ -323,7 +323,7 @@ int select_cities () { userp = cont_tab[user_cont].cityp[useri]; } while (userp == compp); - addprintf ("Your city is at %d.", userp->loc); + addprintf ("Your city is at %d.", userp->loc,0,0,0,0,0,0,0); delay (); /* let user see output before we set_prod */ /* update city and map */ @@ -525,7 +525,7 @@ void save_game () { wval (comp_score); (void) fclose (f); - topmsg (3, "Game saved."); + topmsg (3, "Game saved.",0,0,0,0,0,0,0,0); } /* @@ -613,7 +613,7 @@ int restore_game () { (void) fclose (f); kill_display (); /* what we had is no longer good */ - topmsg (3, "Game restored from empsave.dat."); + topmsg (3, "Game restored from empsave.dat.",0,0,0,0,0,0,0,0); return (TRUE); } @@ -818,13 +818,13 @@ int round; comp_cost += counts[i] * piece_attr[i-NUM_OBJECTS-2].build_time; for (i = 0; i < NUM_OBJECTS+1; i++) { - pos_str (1, (int) i * 6, "%2d %c ", counts[i], pieces[i]); - pos_str (2,(int) i * 6, "%2d %c ", counts[i+NUM_OBJECTS+1], pieces[i+NUM_OBJECTS+1]); + pos_str (1, (int) i * 6, "%2d %c ", counts[i], pieces[i],0,0,0,0,0,0); + pos_str (2,(int) i * 6, "%2d %c ", counts[i+NUM_OBJECTS+1], pieces[i+NUM_OBJECTS+1],0,0,0,0,0,0); } - pos_str (1, (int) i * 6, "%5d", user_cost); - pos_str (2, (int) i * 6, "%5d", comp_cost); - pos_str (0, 0, "Round %3d", (round + 1) / 2); + pos_str (1, (int) i * 6, "%5d", user_cost,0,0,0,0,0,0,0); + pos_str (2, (int) i * 6, "%5d", comp_cost,0,0,0,0,0,0,0); + pos_str (0, 0, "Round %3d", (round + 1) / 2,0,0,0,0,0,0,0); } /* diff --git a/map.c b/map.c index f2727d9..4f7d7a6 100644 --- a/map.c +++ b/map.c @@ -1,4 +1,4 @@ -/* $Id: map.c,v 1.2 1990/03/30 11:23:26 eric Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: map.c,v 1.3 1994/12/01 15:54:39 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -35,14 +35,13 @@ real_maps, path_maps, and cont_maps. x = a; a = b; b = x; \ } -STATIC void expand_perimeter(); -STATIC void expand_prune(); -STATIC void expand_dest_perimeter(); -STATIC int objective_cost(); -STATIC int terrain_type(); -STATIC void start_perimeter(); -STATIC void add_cell(); -STATIC int vmap_count_path (); +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 perimeter_t p1; /* perimeter list for use as needed */ static perimeter_t p2; @@ -1140,7 +1139,7 @@ char *adj_char; Count the number of adjacent cells that are on the path. */ -static int +int vmap_count_path (pmap, loc) path_map_t *pmap; long loc; diff --git a/math.c b/math.c index 9d33f2e..9ec635c 100644 --- a/math.c +++ b/math.c @@ -57,6 +57,7 @@ the max of the absolute differnce between the x and y coordinates. #define MAX(a,b) ((a)>(b) ? (a) : (b)) #define ABS(a) ((a) < 0 ? -(a) : (a)) +int dist (a, b) long a, b; { diff --git a/usermove.c b/usermove.c index dcc7c4e..ef802cb 100644 --- a/usermove.c +++ b/usermove.c @@ -16,9 +16,9 @@ usermove.c -- Let the user move her troops. #include "empire.h" #include "extern.h" -void fatal(); -void move_to_dest(); -void move_army_to_city(); +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 user_move () { @@ -51,8 +51,10 @@ user_move () { set_prod (&(city[i])); /* ask user what to produce */ } else if (city[i].work++ >= (long)piece_attr[prod].build_time) { - comment ("City at %d has completed %s.", - city[i].loc, piece_attr[prod].article); + /* kermyt begin */ + ksend1("%s has been completed at city %d.\n", piece_attr[prod].article,city[i].loc,0,0,0,0,0,0); + /* kermyt end */ + comment1 ("%s has been completed at city %d.\n", piece_attr[prod].article,city[i].loc,0,0,0,0,0,0); produce (&city[i]); /* produce should set object.moved to 0 */ @@ -176,11 +178,10 @@ piece_info_t *obj; obj->range = piece_attr[FIGHTER].range; obj->moved = speed; obj->func = NOFUNC; - comment ("Landing confirmed."); + comment ("Landing confirmed.",0,0,0,0,0,0,0,0); } else if (obj->range == 0) { - comment ("Fighter at %d crashed and burned.", - obj->loc); + comment ("Fighter at %d crashed and burned.",obj->loc,0,0,0,0,0,0,0); kill_obj (obj, obj->loc); } } @@ -628,7 +629,7 @@ user_help () { char c; help (help_user, user_lines); - prompt ("Press any key to continue: "); + prompt ("Press any key to continue: ",0,0,0,0,0,0,0,0); c = get_chx (); c = c; /* keep lint happy */ } @@ -847,7 +848,7 @@ int dir; return; } if (!map[loc].on_board) { - error ("You cannot move to the edge of the world."); + error ("You cannot move to the edge of the world.",0,0,0,0,0,0,0,0); delay (); return; } @@ -887,17 +888,24 @@ long loc; return; if (user_map[obj->loc].contents == 'T') - comment ("Your army jumped into the briny and drowned."); - + { + comment ("Your army jumped into the briny and drowned.",0,0,0,0,0,0,0,0); + ksend ("Your army jumped into the briny and drowned.\n",0,0,0,0,0,0,0,0); + } else if (user_map[loc].contents == '.') - comment ("Your army marched dutifully into the sea and drowned."); - + { + comment ("Your army marched dutifully into the sea and drowned.",0,0,0,0,0,0,0,0); + ksend ("Your army marched dutifully into the sea and drowned.\n",0,0,0,0,0,0,0,0); + } else { /* attack something at sea */ enemy_killed = islower (user_map[loc].contents); attack (obj, loc); if (obj->hits > 0) /* ship won? */ - comment ("Your army regretfully drowns after its successful assault."); + { + comment ("Your army regretfully drowns after its successful assault.",0,0,0,0,0,0,0,0); + ksend ("Your army regretfully drowns after it's successful assault.",0,0,0,0,0,0,0,0); + } } if (obj->hits > 0) { kill_obj (obj, loc); @@ -968,21 +976,22 @@ long loc; } else if (map[loc].contents == '+') { /* moving ashore? */ - if (!getyn ( - "Ships need sea to float, sir. Do you really want to go ashore? ")) - return; + if (!getyn ("Ships need sea to float, sir. Do you really want to go ashore? ")) return; if (user_map[loc].contents == '+') - comment ("Your %s broke up on shore.", - piece_attr[obj->type].name); - + { + comment1 ("Your %s broke up on shore.", piece_attr[obj->type].name,0,0,0,0,0,0,0); + ksend1 ("Your %s broke up on shore.", piece_attr[obj->type].name,0,0,0,0,0,0,0); + } else { /* attack something on shore */ enemy_killed = islower (user_map[loc].contents); attack (obj, loc); if (obj->hits > 0) /* ship won? */ - comment ("Your %s breaks up after its successful assault.", - piece_attr[obj->type].name); + { + comment1 ("Your %s breaks up after its successful assault.", piece_attr[obj->type].name,0,0,0,0,0,0,0); + ksend1 ("Your %s breaks up after its successful assault.", piece_attr[obj->type].name,0,0,0,0,0,0,0); + } } if (obj->hits > 0) { kill_obj (obj, loc); @@ -1030,10 +1039,10 @@ Cancel automove mode. void user_cancel_auto () { if (!automove) - comment ("Not in auto mode!"); + comment ("Not in auto mode!",0,0,0,0,0,0,0,0); else { automove = FALSE; - comment ("Auto mode cancelled."); + comment ("Auto mode cancelled.",0,0,0,0,0,0,0,0); } } @@ -1100,7 +1109,7 @@ char *message; char *response; { if (getyn (message)) { - comment (response); + comment (response,0,0,0,0,0,0,0,0); kill_obj (obj, loc); } } diff --git a/util.c b/util.c index 5e959d2..38d52b8 100644 --- a/util.c +++ b/util.c @@ -1,4 +1,4 @@ -/* $Id$ - (c) Copyright 1987, 1988 Chuck Simmons */ +/* $Id: util.c,v 1.2 1990/03/29 23:21:50 eric Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ /* * Copyright (C) 1987, 1988 Chuck Simmons @@ -133,7 +133,15 @@ Position the cursor and output a string. */ void -/* VARARGS3 */ +pos_str1 (row, col, str, a, b, c, d, e, f, g, h) +int row, col; +char *str, *a; +int b, c, d, e, f, g, h; +{ + (void) move (row, col); + addprintf1 (str, a, b, c, d, e, f, g, h); +} +void pos_str (row, col, str, a, b, c, d, e, f, g, h) int row, col; char *str; @@ -154,6 +162,30 @@ int a, b, c, d, e, f, g, h; (void) sprintf (junkbuf, str, a, b, c, d, e, f, g, h); (void) addstr (junkbuf); } +void +/* VARARGS1 */ +addprintf1 (str, a, b, c, d, e, f, g, h) +char *str; +char *a; +int b, c, d, e, f, g, h; +{ + char junkbuf[STRSIZE]; + + (void) sprintf (junkbuf, str, a, b, c, d, e, f, g, h); + (void) addstr (junkbuf); +} +void +/* VARARGS1 */ +addprintf2 (str, a, b, c, d, e, f, g, h) +char *str; +char *a, *e, *f; +int b, c, d, g, h; +{ + char junkbuf[STRSIZE]; + + (void) sprintf (junkbuf, str, a, b, c, d, e, f, g, h); + (void) addstr (junkbuf); +} /* Report a bug. diff --git a/vms-empire.6 b/vms-empire.6 index 003b96a..57f7c4c 100644 --- a/vms-empire.6 +++ b/vms-empire.6 @@ -1,4 +1,4 @@ -.\" $Id$ - (c) Copyright 1987, 1988 Chuck Simmons */ +.\" $Id: empire.6,v 1.2 1990/03/29 23:36:04 eric Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */ .\" .\" Copyright (C) 1987, 1988 Chuck Simmons .\" @@ -217,17 +217,14 @@ on the side will defeat the piece listed at the top in a battle. .P .TS center box tab(;); -l | c | c | c | c | c | c | c | c. -;A;F;P;D;S;T;C;B +l | c | c | c | c | c. +AFPT;D;S;C;B _ -A;50%;50%;50%;25%;33%;50%;13%;10% -F;50%;50%;50%;25%;33%;50%;13%;10% -P;50%;50%;50%;25%;33%;50%;13%;10% -D;75%;75%;75%;50%;33%;75%;27%;17% -S;67%;67%;67%;67%;50%;67%;40%;20% -T;50%;50%;50%;25%;33%;50%;13%;10% -C;88%;88%;88%;73%;60%;88%;50%;29% -B;90%;90%;90%;84%;80%;90%;71%;50% +AFPT;50.0%;12.5%;25.0%;00.391%;00.0977% +D;87.5%;50.0%;25.0%;05.47%;00.537% +S;75.0%;75.0%;50.0%;31.3%;06.25% +C;99.6%;94.5%;68.7%;50.0%;04.61% +B;99.9%;99.5%;93.8%;95.4%;50.0% .TE .P Notice, however, that when a ship has been damaged, the odds of @@ -670,6 +667,8 @@ Original concept by Mario DeNobili and Thomas N. Paulson. Support for different terminal types added by Craig Leres. Curses support added by Ed James. C/Unix version written by Chuck Simmons +Colorization by Eric S. Raymond. +Probability table corrected by Michael Self. .fi .SH COPYLEFT .fn -- 2.43.0