# Change the line below for your system. If you are on a Sun or Vax,
# you may want BSD.
+SYS = LINUX
#SYS = BSD
-SYS = SYSV
+#SYS = SYSV
# Use -g to compile the program for debugging.
-DEBUG = -g -DDEBUG
-#DEBUG = -O
+#DEBUG = -g -DDEBUG -Wall
+DEBUG = -O2
# Use -p to profile the program.
#PROFILE = -p -DPROFILE
* and warranty information.
*/
-C Empire Sources
+C Empire Sources (now called vms-empire).
Here's my change-log.
+1.3: Fri Apr 19 05:13:33 EDT 2002
+ Walt Stoneburner's clenup patch addressing all compiler errors and
+ warnings, both in debug and in production mode; works with GCC v3.0.3.
+
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 <kermyt@earthling.net>, who wrote some
- speedups, added ANSI prototypes, and cleaned
+ speedups, added ANSI prototypes, and cleaned up code.
1.1:
I colorized and speed-tuned this and added a
save-interval option.
static view_map_t emap[MAP_SIZE]; /* pruned explore map */
int load_army(piece_info_t *obj);
+int lake( long 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);
void
for (i = 0; i < NUM_CITY; i++) /* produce and change */
if (city[i].owner == COMP) {
is_lake = lake (city[i].loc);
- if (city[i].work++ >= (long)piece_attr[city[i].prod].build_time) {
+ if (city[i].work++ >= (long)piece_attr[(int)city[i].prod].build_time) {
produce (&city[i]);
comp_prod (&city[i], is_lake);
}
for (i = 0; i < NUM_CITY; i++)
if (city[i].owner == COMP && city[i].prod != NOPIECE) {
- city_count[city[i].prod] += 1;
+ city_count[(int)city[i].prod] += 1;
total_cities += 1;
}
if (total_cities <= 10) ratio = ratio1;
interest = (counts.comp_cities != 1 || interest);
if (cityp->prod == NOPIECE
- || cityp->prod == ARMY && counts.comp_cities == 1
+ || (cityp->prod == ARMY && counts.comp_cities == 1)
|| overproduced (cityp, city_count)
- || cityp->prod > FIGHTER && is_lake)
+ || (cityp->prod > FIGHTER && is_lake) )
comp_set_needed (cityp, city_count, interest, is_lake);
}
for (i = 0; i < NUM_OBJECTS; i++) {
/* return true if changing production would improve balance */
if (i != cityp->prod
- && ((city_count[cityp->prod] - 1) * ratio[i]
- > (city_count[i] + 1) * ratio[cityp->prod]))
+ && ((city_count[(int)cityp->prod] - 1) * ratio[i]
+ > (city_count[i] + 1) * ratio[(int)cityp->prod]))
return (TRUE);
}
return (FALSE);
-/* $Id: display.c,v 1.6 1994/12/01 15:54:31 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
+/* $Id: display.c,v 1.7 2000/07/28 05:12:50 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
/*
* Copyright (C) 1987, 1988 Chuck Simmons
static int change_ok = TRUE; /* true if new sector may be displayed */
static void show_loc(view_map_t vmap[],long loc);
-static disp_square(view_map_t *vp);
+static void disp_square(view_map_t *vp);
+int on_screen(long loc);
#ifdef A_COLOR
void init_colors()
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);
+ (void) sprintf (jnkbuf, "Sector %d Round %ld", sector, date);
for (r = 0; jnkbuf[r] != '\0'; r++) {
if (r+NUMTOPS >= MAP_HEIGHT) break;
(void) move (r+NUMTOPS, cols-NUMSIDES+4);
*/
-static int disp_square(vp)
+static void disp_square(vp)
view_map_t *vp;
{
#ifdef A_COLOR
#include "extern.h"
void e_move(long *path_start, long loc);
+extern int get_piece_name();
void
edit(edit_cursor)
(void) sprintf (temp_buf, "%c:%s; ",
piece_attr[s].sname,
func_name[FUNCI(cityp->func[s])]);
- else (void) sprintf (temp_buf, "%c: %d;",
+ else (void) sprintf (temp_buf, "%c: %ld;",
piece_attr[s].sname,
cityp->func[s]);
}
(void) sprintf (junk_buf2,
- "City at location %d will complete %s on round %d",
+ "City at location %ld will complete %s on round %ld",
cityp->loc,
- piece_attr[cityp->prod].article,
- date + piece_attr[cityp->prod].build_time - cityp->work);
+ piece_attr[(int)cityp->prod].article,
+ date + piece_attr[(int)cityp->prod].build_time - cityp->work);
info (junk_buf2, jnkbuf, func_buf);
}
#endif
/* Redefine some functions for portability. */
-
-#ifndef SYSV
+#ifdef LINUX
+#include <string.h>
+#elif SYSV
+char *memset();
+char *memcpy();
+#define bzero(dst,len) memset(dst,0,len)
+#else
#define memcpy(dst,src,len) bcopy((src),(dst),(len))
#define strchr(s,c) index(s,c)
typedef char chtype;
#define beep() (putchar('\7'))
#define napms(d) (usleep((d)*1000))
-#else
-char *memset();
-char *memcpy();
-#define bzero(dst,len) memset(dst,0,len)
#endif
+
+
+
typedef unsigned char uchar;
#define ASSERT(x) if (!(x)) assert ("x", __FILE__, __LINE__);
-/* $Id: extern.h,v 1.3 1994/12/01 15:54:36 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
+/* $Id: extern.h,v 1.4 2000/07/28 05:12:52 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
/*
* Copyright (C) 1987, 1988 Chuck Simmons
void exit();
void perror();
void srand();
+#ifndef LINUX
char *strcpy();
+#endif
#include "extern.h"
long remove_land(long loc, long num_land);
+int select_cities();
+int find_next(long *mapi);
+int good_cont(long mapi);
+int xread(FILE *f, char *buf, int size);
+int xwrite(FILE *f, char *buf, int size);
+void stat_display( char *mbuf, int round);
/*
Initialize a new game. Here we generate a new random map, put cities
/* in declared order, with city first */
static char *pieces = "OAFPDSTCBZXafpdstcbz";
-stat_display (mbuf, round)
+void stat_display (mbuf, round)
char *mbuf;
int round;
{
-/* $Id: main.c,v 1.2 1990/03/29 23:22:23 eric Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
+/* $Id: main.c,v 1.3 1994/12/01 15:54:38 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
/*
* Copyright (C) 1987, 1988 Chuck Simmons
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include "empire.h"
#include "extern.h"
#define OPTFLAGS "w:s:d:S:"
-main (argc, argv)
+int main (argc, argv)
int argc;
char *argv[];
{
-/* $Id: map.c,v 1.3 1994/12/01 15:54:39 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
+/* $Id: map.c,v 1.4 2000/07/28 05:12:53 esr Exp esr $ - (c) Copyright 1987, 1988 Chuck Simmons */
/*
* Copyright (C) 1987, 1988 Chuck Simmons
print_pzoom ("After lwobj loop:", path_map, vmap);
cur_cost += 2;
- if (cur_water->len == 0 && new_land->len == 0 || best_cost <= cur_cost) {
+ if ( (cur_water->len == 0 && new_land->len == 0) ||
+ (best_cost <= cur_cost) ) {
return best_loc;
}
}
}
+#ifdef FUNCTION_WAS_NEVER_CALLED
/*
Return the cost to reach the adjacent cell of the correct type
with the lowest cost.
return best;
}
+#endif
/*
Find an objective moving from water to land.
print_pzoom ("After wlobj loop:", path_map, vmap);
cur_cost += 2;
- if (cur_water->len == 0 && new_land->len == 0 || best_cost <= cur_cost) {
+ if ( (cur_water->len == 0 && new_land->len == 0) ||
+ (best_cost <= cur_cost) ) {
return best_loc;
}
SWAP (cur_land, new_land);
default:
ABORT;
/* NOTREACHED */
+ return -1;
}
}
}
ABORT;
/*NOTREACHED*/
+ return -1;
}
/*
/* remember best location */
if (count > bestcount
- || count == bestcount && path_count > bestpath) {
+ || (count == bestcount && path_count > bestpath) ) {
bestcount = count;
bestpath = path_count;
bestloc = new_loc;
dist (a, b) -- returns the straight-line distance between two locations.
*/
+#include <stdlib.h>
#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);
+int awake(piece_info_t *obj);
+extern int get_piece_name();
void
user_move () {