{
if (cityp->prod == type) return;
- pdebug ("Changing city prod at %d from %d to %d\n",cityp->loc, cityp->prod, type,0,0,0,0,0);
+ pdebug ("Changing city prod at %d from %d to %d\n",loc_disp(cityp->loc), cityp->prod, type,0,0,0,0,0);
cityp->prod = type;
cityp->work = -(piece_attr[type].build_time / 5);
}
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,0,0,0,0,0,0,0);
- ksend ("Fighter at %d crashed and burned\n", obj->loc,0,0,0,0,0,0,0);
+ pdebug ("Fighter at %d crashed and burned\n", loc_disp(obj->loc),0,0,0,0,0,0,0);
+ ksend ("Fighter at %d crashed and burned\n", loc_disp(obj->loc),0,0,0,0,0,0,0);
kill_obj (obj, obj->loc); /* crash & burn */
}
}
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,0,0,0,0,0);
+ pdebug ("No destination found for %d at %d; func=%d\n", obj->type, loc_disp(obj->loc), obj->func,0,0,0,0,0);
return;
}
old_loc = obj->loc; /* remember where we are */
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,0,0,0,0,0);
+ else pdebug ("Cannot move %d at %d toward objective; func=%d\n", obj->type, loc_disp(obj->loc), obj->func,0,0,0,0,0);
}
else move_obj (obj, new_loc);
func_name[FUNCI(cityp->func[s])]);
else (void) sprintf (temp_buf, "%c: %ld;",
piece_attr[s].sname,
- cityp->func[s]);
+ loc_disp(cityp->func[s]));
(void) strcat (func_buf, temp_buf);
}
(void) sprintf (junk_buf2,
"City at location %ld will complete %s on round %ld",
- cityp->loc,
+ loc_disp(cityp->loc),
piece_attr[(int)cityp->prod].article,
date + piece_attr[(int)cityp->prod].build_time - cityp->work);
/* Information we maintain about cities. */
-#define NUM_CITY 70
#define UNOWNED 0
#define USER 1
#define COMP 2
'user_map' describes the user's view of the world. 'comp_map' describes
the computer's view of the world.
+
+As of the 1.7 version, MAP_WIDTH and MAP_HEIGHT are now free paramaters.
+You can change them and the code will adjust properly.
*/
#define MAP_WIDTH 100
#define MAP_HEIGHT 60
#define MAP_SIZE (MAP_WIDTH * MAP_HEIGHT)
+/* #define NUM_CITY 70 */
+/* #define NUM_CITY (MAP_SIZE / 85) */
+#define NUM_CITY ((100 * (MAP_WIDTH + MAP_HEIGHT)) / 228)
+
typedef struct real_map { /* a cell of the actual map */
char contents; /* '+', '.', or '*' */
uchar on_board; /* TRUE iff on the board */
-/* $Id: extern.h,v 1.5 2002/04/19 09:17:01 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
+/* $Id: extern.h,v 1.6 2002/08/01 18:58:21 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
/*
* Copyright (C) 1987, 1988 Chuck Simmons
char upper (char c);
void tupper (char *str);
void check ();
+int loc_disp (int loc);
/* randon routines we use */
long time();
userp = cont_tab[user_cont].cityp[useri];
} while (userp == compp);
- addprintf ("Your city is at %d.", userp->loc,0,0,0,0,0,0,0);
+ addprintf ("Your city is at %d.", loc_disp(userp->loc),0,0,0,0,0,0,0);
delay (); /* let user see output before we set_prod */
/* update city and map */
*/
static long ncity, nland, nshore;
+static void mark_cont();
int good_cont (mapi)
long mapi;
{
- static void mark_cont();
-
long val;
ncity = 0; /* nothing seen yet */
-/* $Id: map.c,v 1.4 2000/07/28 05:12:53 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
+/* $Id: map.c,v 1.5 2002/04/19 09:17:01 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
/*
* Copyright (C) 1987, 1988 Chuck Simmons
{
long 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);
{
long i, j;
+ if (map[loc].contents != '.') return (FALSE);
FOR_ADJ_ON (loc, j, i) {
if (map[j].contents != '.') return (FALSE);
}
(void) refresh ();
}
+#define COL_DIGITS ((MAP_WIDTH <= 100) ? 2 : ((MAP_WIDTH <= 1000 ? 3 : (1 / 0))))
-
+int
+loc_disp (int loc)
+{
+ int row = loc / MAP_WIDTH;
+ int nrow = row;
+ int col = loc % MAP_WIDTH;
+ ASSERT (loc == (row * MAP_WIDTH) + col);
+ int i;
+ for (i = COL_DIGITS; i > 0; i--) {
+ nrow *= 10; }
+ move (LINES - 1, 0);
+ /*
+ {
+ char junkbuf[STRSIZE];
+ (void) snprintf (junkbuf, STRSIZE, "loc: %d, row: %d, col: %d, nrow: %d, nrow+col: %d", loc, row, col, nrow, nrow + col);
+ (void) addstr (junkbuf);
+ napms(500);
+ }
+ */
+ return nrow + col;
+}
}
else if (city[i].work++ >= (long)piece_attr[prod].build_time) {
/* kermyt begin */
- ksend1("%s has been completed at city %d.\n", piece_attr[prod].article,city[i].loc,0,0,0,0,0,0);
+ ksend1("%s has been completed at city %d.\n", piece_attr[prod].article,loc_disp(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);
+ comment1 ("%s has been completed at city %d.\n", piece_attr[prod].article,loc_disp(city[i].loc),0,0,0,0,0,0);
produce (&city[i]);
/* produce should set object.moved to 0 */
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,0,0,0,0,0,0,0);
+ comment ("Fighter at %d crashed and burned.",loc_disp(obj->loc),0,0,0,0,0,0,0);
kill_obj (obj, obj->loc);
}
}