diff -ur emp4.2.10/Make.sysdefs emp4.6th/Make.sysdefs --- emp4.2.10/Make.sysdefs Mon Aug 7 20:54:44 2000 +++ emp4.6th/Make.sysdefs Thu May 23 20:47:15 2002 @@ -36,6 +36,9 @@ FREEBSDLFLAGS = FREEBSDMASTER = GLOBALCFLAGS="$(FREEBSDCFLAGS)" GLOBALLFLAGS="$(FREEBSDLFLAGS)" RANLIB="$(FREEBSDRANLIB)" +FREEBSDCFLAGSINET6 = -DRel4 -DFBSD -DINET6 -ansi -pedantic -Wall -g +FREEBSDMASTERINET6 = GLOBALCFLAGS="$(FREEBSDCFLAGSINET6)" GLOBALLFLAGS="$(FREEBSDLFLAGS)" RANLIB="$(FREEBSDRANLIB)" + APOLLOCFLAGS = -g APOLLOLFLAGS = APOLLOMASTER = GLOBALCFLAGS="$(APOLLOCFLAGS)" GLOBALLFLAGS="$(APOLLOLFLAGS)" diff -ur emp4.2.10/Makefile emp4.6th/Makefile --- emp4.2.10/Makefile Mon Sep 25 07:11:49 2000 +++ emp4.6th/Makefile Thu May 9 17:40:38 2002 @@ -51,6 +51,7 @@ @echo ' alpha-pthreads' @echo ' apollo' @echo ' freebsd' + @echo ' freebsd-inet6' @echo ' hp' @echo ' hpux' @echo ' irix' @@ -104,6 +105,14 @@ ($(MAKE) genlibs $(FREEBSDMASTER)) (cd src/lib/lwp; $(MAKE) $(FREEBSDMASTER)) ($(MAKE) binaries $(FREEBSDMASTER)) + ($(MAKE) install) + +freebsd-inet6: + @echo 'building a $(WORLDX) by $(WORLDY) server...' + (cd src/doconfig; $(MAKE) $(FREEBSDMASTERINET6)) + ($(MAKE) genlibs $(FREEBSDMASTERINET6)) + (cd src/lib/lwp; $(MAKE) $(FREEBSDMASTERINET6)) + ($(MAKE) binaries $(FREEBSDMASTERINET6)) ($(MAKE) install) hp: diff -ur emp4.2.10/build.conf emp4.6th/build.conf --- emp4.2.10/build.conf Mon Aug 13 22:40:13 2001 +++ emp4.6th/build.conf Mon Jul 1 18:46:43 2002 @@ -5,57 +5,49 @@ # # Please enter your name: -MYNAME = Wolfpack +MYNAME = marcolz # Please enter your user name: # (For NT and the basic emp_client build, use "USERNAME = win-empcl2.8") -USERNAME = wolfpack +USERNAME = marcolz # Please enter your e-mail address: -EMAIL = wolfpack@empire.cx +EMAIL = marcolz@stack.nl # Please enter the host name you will be running on: # (For NT you can use "HOSTNAME = localhost" as this seems to be what it -# always resolves to if you use 127.0.0.1 below) -HOSTNAME = dns.empire.cx +# resolves to if you use 127.0.0.1 below) +HOSTNAME = toad.stack.nl # Please enter the ip address of the host you will be running on: # (For NT you can use "IPADDR = 127.0.0.1") -IPADDR = 207.170.212.245 +IPADDR = 131.155.140.135 +IPV6ADDR = 2001:610:1108:5010:202:b3ff:fe17:9e1a # Please enter the port you will be running on: -PORTNUM = 6665 +PORTNUM = 9898 # Please enter the directory where you want the files for the game: -# (Note: Use a '/' to delimit directories. For NT, include a -# drive letter.) -EMPDIR = /home/wolfpack/emp4 - -# Ignore this next value for all builds except NT builds. -# For NT builds, use the above path, but replace the '/' with a '\'. -# Note that NTINSTDIR is not used for non-NT builds, and can be ignored. -# This is needed for the 'copy' comamnds, since they get very confused -# with the normal path names. -NTINSTDIR = C:\home\wolfpack\emp4 +# (For NT builds, use two \'s and make sure you include a drive letter) +EMPDIR = /home/marcolz/empire.6th/ # Please enter the C-compiler you are using (full path is allowed): -# (For NT builds using MSVC, use "CC = CL") +# (For NT builds using MSVC 5.0, use "CC = CL") CC = gcc # Please enter the linker you are using (full path is allowed): -# (For NT builds using MSVC, using "LD = ld" works fine.) LD = ld # Please enter the maximum number of countries you want: -MAXNOC = 99 +MAXNOC = 16 # Please enter the world size you would like (WORLDX must be # divisible by 2): -WORLDX = 64 -WORLDY = 32 +WORLDX = 76 +WORLDY = 38 # Please enter if you are setting up a blitz (1 - yes, 0 - no) -BLITZ = 1 +BLITZ = 0 # Please enter the number of ETUs per update (must be divisible by 4): ETUS = 60 @@ -64,7 +56,7 @@ # Once per day - 1d # Once every 20 minutes - 20m # Once every 4 hours - 4h -ETUFREQ = 10m +ETUFREQ = 3d # That's it... Save this file, and type "make " to build the # server. If you are not sure of what architectures are supported, diff -ur emp4.2.10/include/map.h emp4.6th/include/map.h --- emp4.2.10/include/map.h Sat Mar 11 05:14:55 2000 +++ emp4.6th/include/map.h Sat May 25 17:35:38 2002 @@ -52,6 +52,7 @@ #define MAP_SHIP bit(0) #define MAP_LAND bit(1) #define MAP_PLANE bit(2) +#define MAP_HIGH bit(3) #define MAP_ALL MAP_SHIP | MAP_LAND | MAP_PLANE struct mapstr { diff -ur emp4.2.10/include/options.h emp4.6th/include/options.h --- emp4.2.10/include/options.h Mon Sep 25 06:16:51 2000 +++ emp4.6th/include/options.h Thu May 16 23:36:50 2002 @@ -52,7 +52,7 @@ #define LANDSPIES /* Enable the land unit type spies */ -#define START_CASH 25000 /* set starting cash when capitol created */ +#define START_CASH 5000 /* set starting cash when capitol created */ /* Setting BLITZ sets a couple of things. 1. BTU's always max when you login. diff -ur emp4.2.10/include/player.h emp4.6th/include/player.h --- emp4.2.10/include/player.h Sat Mar 11 05:14:52 2000 +++ emp4.6th/include/player.h Tue May 21 21:55:13 2002 @@ -39,6 +39,9 @@ #if !defined(_WIN32) #include #endif +#ifdef INET6 +#include +#endif /* INET6 */ #include "prototype.h" #include "queue.h" #include "misc.h" @@ -48,7 +51,11 @@ struct player { struct emp_qelem queue; empth_t *proc; +#ifdef INET6 + s_char hostaddr[40]; +#else /* INET6 */ s_char hostaddr[32]; +#endif /* INET6 */ s_char hostname[512]; s_char client[128]; s_char userid[32]; @@ -98,9 +105,3 @@ #include "prototypes.h" /* must come at end, after defines and typedefs */ #endif /* _PLAYER_H_ */ - - - - - - diff -ur emp4.2.10/include/prototypes.h emp4.6th/include/prototypes.h --- emp4.2.10/include/prototypes.h Mon Aug 7 20:59:08 2000 +++ emp4.6th/include/prototypes.h Wed Jul 31 19:40:15 2002 @@ -383,6 +383,7 @@ extern int bmaps_intersect(natid , natid ); extern int share_bmap(natid , natid , struct nstr_sect * , s_char , s_char * ); +extern int dump_map(int , s_char , int , struct nstr_sect * , int ); /* move.c */ extern double sector_mcost(struct sctstr * , int ); /* nstr_subs.c */ @@ -520,7 +521,11 @@ */ /* accept.c */ extern void player_init(void ); +#ifdef INET6 +extern struct player * player_new(int , struct sockaddr * ); +#else /* INET6 */ extern struct player * player_new(int , struct sockaddr_in * ); +#endif /* INET6 */ extern struct player * player_delete(struct player * ); extern struct player * player_next(struct player * ); extern struct player * player_prev(struct player * ); diff -ur emp4.2.10/info.nr/map emp4.6th/info.nr/map --- emp4.2.10/info.nr/map Mon Aug 13 22:24:39 2001 +++ emp4.6th/info.nr/map Sat May 25 22:02:37 2002 @@ -66,7 +66,10 @@ MAP FLAGS If you give an 's' flag, all your ships will be shown on the map. An 'l' flag -does the same for land units, and a 'p' for planes. +does the same for land units, and a 'p' for planes. '*' shows all in this +order: land units, ships, planes. + +To highlight sectors owned by yourself, use the 'h' flag. SEE ALSO census, commodity, radar, realm, route, update, Maps diff -ur emp4.2.10/src/doconfig/Makefile emp4.6th/src/doconfig/Makefile --- emp4.2.10/src/doconfig/Makefile Sat Mar 11 05:41:24 2000 +++ emp4.6th/src/doconfig/Makefile Thu May 9 17:44:51 2002 @@ -43,9 +43,10 @@ DET = -DET=$(ETUS) DEF = -DEF="\"$(ETUFREQ)\"" DIP = -DIP="\"$(IPADDR)\"" +DIP6 = -DIP6="\"$(IPV6ADDR)\"" DUN = -DUN="\"$(USERNAME)\"" -DALL = $(DPV) $(DHN) $(DPN) $(DEM) $(DEP) $(DMC) $(DWX) $(DWY) $(DBL) $(DET) $(DEF) $(DIP) $(DUN) +DALL = $(DPV) $(DHN) $(DPN) $(DEM) $(DEP) $(DMC) $(DWX) $(DWY) $(DBL) $(DET) $(DEF) $(DIP) $(DUN) $(DIP6) all: doconfig diff -ur emp4.2.10/src/doconfig/doconfig.c emp4.6th/src/doconfig/doconfig.c --- emp4.2.10/src/doconfig/doconfig.c Thu Dec 21 20:59:40 2000 +++ emp4.6th/src/doconfig/doconfig.c Thu May 9 17:45:31 2002 @@ -198,6 +198,10 @@ fprintf(fp, "nowhere.land.edu\nnowhereman\n"); fprintf(fp, "%s\n%s\n", HN, UN); fprintf(fp, "%s\n%s\n", IP, UN); +#ifdef INET6 + fprintf(fp, "%s\n%s\n", IP6, UN); + fprintf(fp, "::1\n%s\n", UN); +#endif /* INET6 */ fprintf(fp, "127.0.0.1\n%s\n", UN); fclose(fp); } diff -ur emp4.2.10/src/lib/commands/carg.c emp4.6th/src/lib/commands/carg.c --- emp4.2.10/src/lib/commands/carg.c Sat Mar 11 05:36:46 2000 +++ emp4.6th/src/lib/commands/carg.c Wed Sep 4 20:46:10 2002 @@ -117,7 +117,7 @@ continue; if ((player->cnum != land.lnd_own) && !player->god) continue; - if (land.lnd_type < 0 || land.lnd_type > shp_maxno) { + if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) { pr("bad unit type %d (#%d)\n", land.lnd_type, ni.cur); continue; diff -ur emp4.2.10/src/lib/commands/decl.c emp4.6th/src/lib/commands/decl.c --- emp4.2.10/src/lib/commands/decl.c Sat Mar 11 05:36:45 2000 +++ emp4.6th/src/lib/commands/decl.c Wed Sep 4 20:46:33 2002 @@ -91,6 +91,7 @@ if (player->god){ who = natarg(player->argp[3], "for which country? "); } + if (who == 255) return RET_SYN; natp = getnatp(who); while (nxtitem(&ni, (s_char *) &nat)) { diff -ur emp4.2.10/src/lib/commands/map.c emp4.6th/src/lib/commands/map.c --- emp4.2.10/src/lib/commands/map.c Sat Mar 11 05:36:42 2000 +++ emp4.6th/src/lib/commands/map.c Wed Jul 31 20:07:34 2002 @@ -112,6 +112,8 @@ case 'L': map_flags |= MAP_LAND; break; case 'p': case 'P': map_flags |= MAP_PLANE; break; + case 'H': + case 'h': map_flags |= MAP_HIGH; break; case '*': map_flags |= MAP_ALL; break; case '0': case '1': @@ -142,4 +144,85 @@ } return draw_map(bmap, origin, map_flags, &ns, as_country); +} + +int +mdump(void) +{ + register s_char *b; + int unit_type = 0; + int bmap = 0; + struct natstr *np; + s_char *str; + struct nstr_sect ns; + s_char origin = '\0'; + int as_country; + int map_flags = 0; + int i; + int where = 2; + s_char what[64]; + s_char buf[1024]; + + if (**player->argp != 'm') { + if (**player->argp == 'b') + bmap = EF_BMAP; + else if (**player->argp == 'n') + bmap = EF_NMAP; + else { + if (player->argp[0][1] == 'b') + bmap = EF_BMAP; + } + } + + if (player->argp[1] == (s_char *) 0) { + if ((str = getstring("(sects)? ", buf)) == 0) + return RET_SYN; + } else { + str = player->argp[1]; + } + + np = getnatp(player->cnum); + if (*str == '*') { + sprintf(what, "%d:%d,%d:%d", + -WORLD_X/2, WORLD_X/2-1, + -WORLD_Y/2, WORLD_Y/2-1); + if (!snxtsct(&ns, what)) + return RET_FAIL; + } else if (!snxtsct(&ns, str)) { + i=atoi(str); + if (unit_map(unit_type, i, &ns, &origin)) + return RET_FAIL; + } + b = player->argp[2]; + while (b != (s_char *)0 && (*b)){ + where = 3; + switch(*b){ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': where = 2; break; + case 't': bmap = EF_MAP; *(b+1)=0;break; + default: pr("Bad flag %c!\n",*b); + break; + } + b++; + } + + as_country = player->cnum; + if (player->god){ + if (player->argp[where] != (s_char *) 0) { + as_country=atoi(player->argp[where]); + if ((as_country < 0) || (as_country > MAXNOC)){ + as_country = player->cnum; + } + } + } + + return dump_map(bmap, origin, map_flags, &ns, as_country); } diff -ur emp4.2.10/src/lib/commands/offe.c emp4.6th/src/lib/commands/offe.c --- emp4.2.10/src/lib/commands/offe.c Sat Mar 11 05:36:41 2000 +++ emp4.6th/src/lib/commands/offe.c Wed Sep 4 20:47:55 2002 @@ -195,6 +195,10 @@ amt = onearg(player->argp[3], prompt); if (amt <= 0) return RET_FAIL; + if (amt > MAXLOAN) { + pr("You can only loan $%d at a time.\n",MAXLOAN); + return RET_FAIL; + } if (amt > maxloan) { pr("You can't afford that much.\n"); return RET_FAIL; diff -ur emp4.2.10/src/lib/commands/reje.c emp4.6th/src/lib/commands/reje.c --- emp4.2.10/src/lib/commands/reje.c Sat Mar 11 05:36:39 2000 +++ emp4.6th/src/lib/commands/reje.c Wed Sep 4 20:49:04 2002 @@ -51,7 +51,8 @@ struct nstr_item ni; s_char buf[1024]; - p = getstarg(player->argp[1], "reject or accept? ", buf); + if ((p = getstarg(player->argp[1], "reject or accept? ", buf)) == 0) + return RET_SYN; switch (*p) { case 'r': do_undo = 1; @@ -63,7 +64,8 @@ pr("That's not one of the choices!\n"); return RET_SYN; } - p = getstarg(player->argp[2], "mail, treaties, loans, or announcements? ", buf); + if ((p = getstarg(player->argp[2], "mail, treaties, loans, or announcements? ", buf)) == 0) + return RET_SYN; switch (*p) { case 'a': rel = REJ_ANNO; diff -ur emp4.2.10/src/lib/commands/rout.c emp4.6th/src/lib/commands/rout.c --- emp4.2.10/src/lib/commands/rout.c Sat Mar 11 05:36:39 2000 +++ emp4.6th/src/lib/commands/rout.c Wed Sep 4 20:49:41 2002 @@ -101,7 +101,7 @@ } } if (!buf) - buf = (s_char *)malloc((MAPWIDTH(3) + 10) * sizeof(s_char)); + buf = (s_char *)malloc((MAPWIDTH(3) + 12) * sizeof(s_char)); if (!mapbuf || !map || !buf) { pr("Memory error, tell the deity.\n"); logerror("malloc failed in rout\n"); diff -ur emp4.2.10/src/lib/commands/trad.c emp4.6th/src/lib/commands/trad.c --- emp4.2.10/src/lib/commands/trad.c Sat Oct 7 01:49:02 2000 +++ emp4.6th/src/lib/commands/trad.c Wed Sep 4 20:49:58 2002 @@ -254,7 +254,7 @@ pr("Bad sector designation; try again!\n"); continue; } - if (!player->owner && !(plflags & P_O)) { + if (!player->owner) { pr("You don't own that sector; try again!\n"); continue; } diff -ur emp4.2.10/src/lib/commands/upgr.c emp4.6th/src/lib/commands/upgr.c --- emp4.2.10/src/lib/commands/upgr.c Sat Mar 11 05:36:35 2000 +++ emp4.6th/src/lib/commands/upgr.c Wed Sep 4 20:58:19 2002 @@ -339,6 +339,10 @@ prplane(&plane)); continue; } + if (plane.pln_flags & PLN_LAUNCHED) { + pr("Plane %s is in orbit!\n", prplane(&plane)); + continue; + } sect.sct_avail = (sect.sct_avail * 100 - w_p_eff * 20) / 100; plane.pln_effic -= 35; diff -ur emp4.2.10/src/lib/common/maps.c emp4.6th/src/lib/common/maps.c --- emp4.2.10/src/lib/common/maps.c Fri Oct 6 20:19:51 2000 +++ emp4.6th/src/lib/common/maps.c Wed Jul 31 21:09:45 2002 @@ -252,6 +252,25 @@ wmap[y][x] = (*lchr[(int)land.lnd_type].l_name) & ~0x20; } } + if (map_flags & MAP_HIGH){ + register s_char *ptr; + struct sctstr sect; + + snxtsct_rewind(nsp); + if ((!player->god || country)) { + bzero((s_char *)bitmap, (WORLD_X * WORLD_Y) / 8); + bitinit2(nsp, bitmap, country); + } + while (nxtsct(nsp, §) && !player->aborted) { + if ((!player->god || country) && !emp_getbit(nsp->x, nsp->y, bitmap)) { + if (!player->god) + continue; + } + ptr = &wmap[nsp->dy][nsp->dx]; + if (sect.sct_own == player->cnum) + *ptr |= 0x80; + } + } if (origin) wmap[5][10] = origin & ~0x20; for (y=nsp->range.ly, i=0; i < nsp->range.height; y++, i++) { @@ -418,3 +437,183 @@ return n; } +int +dump_map(int bmap, s_char origin, int map_flags, struct nstr_sect *nsp, int country) +{ + struct natstr *np; + struct range range; + struct nstr_item ni; + struct shpstr ship; + struct lndstr land; + struct plnstr plane; + coord x,y; + int i, count; + time_t now; + /* Note this is not re-entrant anyway, so we keep the buffers + around */ + static u_char *bitmap = (u_char *)0; + static s_char *wmapbuf = (s_char *)0; + static s_char **wmap = (s_char **)0; + + if (!wmapbuf) + wmapbuf = (s_char *)malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); + if (!wmap) { + wmap = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + if (wmap && wmapbuf) { + for (i = 0; i < WORLD_Y; i++) + wmap[i] = &wmapbuf[MAPWIDTH(1) * i]; + } else if (wmap) { + free((s_char *)wmap); + wmap = (s_char **)0; + } + } + if (!bitmap) + bitmap = (u_char *)malloc((WORLD_X * WORLD_Y) / 8); + if (!wmapbuf || !wmap || !bitmap) { + pr("Memory error, tell the deity.\n"); + logerror("malloc failed in draw_map\n"); + return RET_FAIL; + } + + if (bmap == EF_MAP + EF_BMAP) { + if (!confirm("Are you sure you want to revert your bmap? ")) + return RET_OK; + } + if (!player->command->c_flags & C_MOD) { + logerror("%s command needs C_MOD flag set",player->command->c_form); + player->command->c_flags |= C_MOD; + } + np = getnatp(country); + /* zap any conditionals */ + nsp->ncond = 0; + xyrelrange(np, &nsp->range, &range); + blankfill((s_char *)wmapbuf, &nsp->range, 1); + if (bmap) { + register int c; + switch (bmap) { + case EF_BMAP: + while (bmnxtsct(nsp) && !player->aborted) { + if (0 != (c = player->bmap[sctoff(nsp->x, nsp->y)])) + wmap[nsp->dy][nsp->dx] = c; + } + break; + case EF_MAP: + while (bmnxtsct(nsp) && !player->aborted) { + if (0 != (c = player->map[sctoff(nsp->x, nsp->y)])) + wmap[nsp->dy][nsp->dx] = c; + } + break; + case EF_NMAP: + do { + register s_char *ptr; + struct sctstr sect; + + if ((!player->god || country)) { + bzero((s_char *)bitmap, (WORLD_X * WORLD_Y) / 8); + bitinit2(nsp, bitmap, country); + } + while (nxtsct(nsp, §) && !player->aborted) { + if ((!player->god || country) && + !emp_getbit(nsp->x, nsp->y, bitmap)) { + if (!player->god) + continue; + } + ptr = &wmap[nsp->dy][nsp->dx]; + if (sect.sct_newtype > SCT_MAXDEF) { + *ptr = '?'; + } else { + *ptr = dchr[sect.sct_newtype].d_mnem; + switch (sect.sct_newtype) { + case SCT_WATER: + case SCT_RURAL: + case SCT_MOUNT: + case SCT_WASTE: + case SCT_PLAINS: + break; + default: + if (sect.sct_own != country && + (!player->god || country)) { + if (!player->god) + *ptr = '?'; + } + break; + } + } + } + } while (0); + break; + } + } else { + register s_char *ptr; + struct sctstr sect; + int changed = 0; + + if ((!player->god || country)) { + bzero((s_char *)bitmap, (WORLD_X * WORLD_Y) / 8); + bitinit2(nsp, bitmap, country); + } + while (nxtsct(nsp, §) && !player->aborted) { + if ((!player->god || country) && !emp_getbit(nsp->x, nsp->y, bitmap)) { + if (!player->god) + continue; + } + ptr = &wmap[nsp->dy][nsp->dx]; + if (sect.sct_type > SCT_MAXDEF) { + *ptr = '?'; + } else { + *ptr = dchr[sect.sct_type].d_mnem; + switch (sect.sct_type) { + case SCT_WATER: + case SCT_RURAL: + case SCT_MOUNT: + case SCT_WASTE: + case SCT_PLAINS: + break; + default: + if (sect.sct_own != country && + (!player->god || country)) { + if(!player->god) + *ptr = '?'; + } + break; + } + changed += map_set(player->cnum, nsp->x, nsp->y, *ptr, 0); + } + } + if (changed) + writemap(player->cnum); + } + if (player->aborted) + return RET_OK; + if (origin) + wmap[5][10] = origin & ~0x20; + + prdate(); + time(&now); + pr("DUMP MSECTOR %d\n", now); + pr("x y des\n"); + count = 0; + for (y=nsp->range.ly, i=0; i < nsp->range.height; y++, i++) { + int xval, yval, j; + + if (y >= WORLD_Y) + y -= WORLD_Y; + yval = yrel(np, y); + for (j=0; j < nsp->range.width; j++) + { + if (wmap[i][j] != ' ') + { + xval = xrel(np, nsp->range.lx + 2 * (j / 2)); + xval += ((xval + yval) & 0x1); + if (xval >= WORLD_X) + x -= WORLD_X; + + pr("%d %d %c\n", xval, yval, wmap[i][j]); + count++; + } + } + wmap[i][nsp->range.width] = '\0'; + } + pr("%d sector%s\n", count, ((1 == count) ? "" : "s")); + return RET_OK; +} diff -ur emp4.2.10/src/lib/gen/mapdist.c emp4.6th/src/lib/gen/mapdist.c --- emp4.2.10/src/lib/gen/mapdist.c Sat Mar 11 05:36:31 2000 +++ emp4.6th/src/lib/gen/mapdist.c Thu May 30 23:12:56 2002 @@ -45,7 +45,7 @@ { int dx; - dx = abs(x1 - x2); + dx = abs(x1 - x2) % WORLD_X; if (dx > WORLD_X/2) dx = WORLD_X - dx; return dx; @@ -56,7 +56,7 @@ { int dy; - dy = abs(y1 - y2); + dy = abs(y1 - y2) % WORLD_Y; if (dy > WORLD_Y/2) dy = WORLD_Y - dy; return dy; diff -ur emp4.2.10/src/lib/global/constants.c emp4.6th/src/lib/global/constants.c --- emp4.2.10/src/lib/global/constants.c Sat Aug 11 00:34:33 2001 +++ emp4.6th/src/lib/global/constants.c Fri May 24 19:42:35 2002 @@ -166,8 +166,8 @@ /* money gained from taxes, paid to military, and reservists */ double money_civ = 0.0083333; double money_uw = 0.0017777; -double money_mil = -0.0833333; -double money_res = -0.0083333; +double money_mil = -0.833333; +double money_res = -0.083333; /* pct cost per ETU for maintaining a ship or plane or land unit */ double money_plane = -0.001; @@ -175,8 +175,8 @@ double money_land = -0.001; /* edu and hap consumption factors -- hap_cons civs need 1 hap --> hlev++ */ -double hap_cons = 600000.0; -double edu_cons = 600000.0; +double hap_cons = 60000.0; +double edu_cons = 30000.0; /* hap and edu avg mean that the weight on current happiness is * (cur_hap * hap_avg + hap_prod * etu) / (hap_avg + etu); */ diff -ur emp4.2.10/src/lib/global/land.c emp4.6th/src/lib/global/land.c --- emp4.2.10/src/lib/global/land.c Sat Mar 11 05:36:30 2000 +++ emp4.6th/src/lib/global/land.c Tue Jul 16 20:13:10 2002 @@ -49,6 +49,15 @@ { 2, { V_FOOD, V_MILIT }, + { ((int)((ETUS)/20)), 5 }, +"spd Spud mk II", + 2, 1, 0, 0, 0, 0, 80, + 0.1, 0.1, 250, 40, 15, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + L_LIGHT, + }, + +{ 2, + { V_FOOD, V_MILIT }, { ((int)((ETUS*4)/20)), 20 }, "cav cavalry", 10, 5, 0, 0, 0, 30, 500, diff -ur emp4.2.10/src/lib/global/plane.c emp4.6th/src/lib/global/plane.c --- emp4.2.10/src/lib/global/plane.c Sat Mar 11 05:36:29 2000 +++ emp4.6th/src/lib/global/plane.c Wed Sep 4 20:52:29 2002 @@ -269,7 +269,7 @@ /* name lcm hcm $$$ tch acc ld at/df ran mil gas stlth flags */ { "mi naval missile", -"mi Tomahawk cruise missile", +"mi Harpoon", 8, 2, 300, 160, 50, 6, 0,5, 6, 0, 0, 0, P_L|P_T|P_M|P_MAR }, @@ -284,7 +284,7 @@ /* name lcm hcm $$$ tch acc ld at/df ran mil gas stlth flags */ { "ssm", -"ssm V1", +"ssm V2", 15, 15, 800, 145, 60, 3, 0,3, 4, 0, 0, 0, P_T|P_M }, diff -ur emp4.2.10/src/lib/global/sect.c emp4.6th/src/lib/global/sect.c --- emp4.2.10/src/lib/global/sect.c Sat Mar 11 05:36:29 2000 +++ emp4.6th/src/lib/global/sect.c Fri May 17 00:23:20 2002 @@ -49,7 +49,7 @@ /* mnem prd mcst flg pkg ostr dstr value $ bld lcm hcm name */ { '.', 0, 0, NAVOK, NPKG,0.0, 0.0, 0, 0, 0, 0, 0, "sea" }, -{ '^', P_MDUST, 25, 0, NPKG,1.0, 4.0, 5, 0, 1, 0, 0, "mountain" }, +{ '^', P_MDUST, 30, 0, NPKG,1.0, 4.0, 5, 0, 1, 0, 0, "mountain" }, { 's', 0, 0, 0, NPKG,0.0,99.0, 127, 0, 0, 0, 0, "sanctuary" }, { '\\',0, 0, 0, NPKG,0.0,99.0, 0, 0, 0, 0, 0, "wasteland" }, { '-', 0, 3, 0, NPKG,1.0, 2.0, 1, 0, 0, 0, 0, "wilderness" }, diff -ur emp4.2.10/src/lib/player/accept.c emp4.6th/src/lib/player/accept.c --- emp4.2.10/src/lib/player/accept.c Sat Mar 11 05:36:28 2000 +++ emp4.6th/src/lib/player/accept.c Thu May 9 18:10:01 2002 @@ -72,13 +72,56 @@ } struct player * +#ifdef INET6 +player_new(int s, struct sockaddr *saddr) +#else /* INET6 */ player_new(int s, struct sockaddr_in *sin) +#endif /* INET6 */ { struct player *lp; struct hostent *hostp; +#ifdef INET6 + char *pname; + int plen; +#endif /* INET6 */ lp = (struct player *) calloc(1, sizeof(struct player)); bzero((s_char *)lp, sizeof(struct player)); +#ifdef INET6 + if (saddr) { + /* update uses dummy player */ + /* so does the market updater */ + emp_insque(&lp->queue, &Players); + getnameinfo(saddr, saddr->sa_len, lp->hostaddr, strlen(lp->hostaddr), NULL, 0, NI_NUMERICHOST); +#ifdef RESOLVE_IPADDRESS + switch(saddr->sa_family) + { + case AF_INET: + pname = (char *) &((struct sockaddr_in *)saddr)->sin_addr; + plen = sizeof(struct in_addr); + break; + case AF_INET6: + pname = (char *) &((struct sockaddr_in6 *)saddr)->sin6_addr; + plen = sizeof(struct in6_addr); + break; + default: + pname = NULL; + break; + } + if (pname) { + hostp = gethostbyaddr(pname, plen, saddr->sa_family); + } else hostp = NULL; + if (hostp) { + strcpy(lp->hostname, hostp->h_name); + } +#endif /* RESOLVE_IPADDRESS */ + lp->cnum = 255; + lp->curid = -1; + time(&lp->curup); + lp->iop = io_open(s, IO_READ|IO_WRITE|IO_NBLOCK, + IO_BUFSIZE, 0, 0); + } +#else /* INET6 */ if (sin) { /* update uses dummy player */ /* so does the market updater */ @@ -89,11 +132,12 @@ strcpy(lp->hostname, hostp->h_name); #endif /* RESOLVE_IPADDRESS */ lp->cnum = 255; - lp->curid = -1; + lp->curid = -1; time(&lp->curup); lp->iop = io_open(s, IO_READ|IO_WRITE|IO_NBLOCK, IO_BUFSIZE, 0, 0); } +#endif /* INET6 */ return lp; } @@ -188,6 +232,12 @@ { extern s_char *loginport; extern int errno; +#ifdef INET6 + struct addrinfo hints; + struct addrinfo *res; + int return_error; + char *service = "empire"; +#endif /* INET6 */ struct sockaddr_in sin; struct servent *sp; int s; @@ -207,6 +257,21 @@ port = htons(atoi(loginport)); else port = sp->s_port; +#ifdef INET6 + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_flags = AI_PASSIVE; + hints.ai_socktype = SOCK_STREAM; + return_error = getaddrinfo(NULL, service, &hints, &res); + if (return_error) { + logerror("inet6 getaddrinfo"); + exit(1); + } + if ((s = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) { + logerror("inet6 socket create"); + exit(1); + } +#else /* INET6 */ sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = port; sin.sin_family = AF_INET; @@ -214,6 +279,7 @@ logerror("inet socket create"); exit(1); } +#endif /* INET6 */ val = 1; #if !(defined(__linux__) && defined(__alpha__)) if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val)) < 0) { @@ -223,10 +289,17 @@ #else logerror("Alpha/Linux? You don't support SO_REUSEADDR yet, do you?\n"); #endif +#ifdef INET6 + if (bind(s, res->ai_addr, res->ai_addrlen) < 0) { + logerror("inet6 socket bind"); + exit(1); + } +#else /* INET6 */ if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) { logerror("inet socket bind"); exit(1); } +#endif /* INET6 */ #ifdef LISTENMAXCONN /* because someone in linux world didn't want to use * SOMAXCONN as defined in the header files... */ if (listen(s, LISTENMAXCONN) < 0) { @@ -242,8 +315,13 @@ maxfd = getfdtablesize() - 1; while (1) { empth_select(s, EMPTH_FD_READ); +#ifdef INET6 + len = res->ai_addrlen; + ns = accept(s, res->ai_addr, &len); +#else /* INET6 */ len = sizeof(sin); ns = accept(s, (struct sockaddr *) &sin, &len); +#endif /* INET6 */ if (ns < 0) { logerror("new socket accept"); continue; @@ -256,7 +334,11 @@ close(ns); continue; } +#ifdef INET6 + np = player_new(ns, res->ai_addr); +#else /* INET6 */ np = player_new(ns, &sin); +#endif /* INET6 */ /* XXX may not be big enough */ stacksize = 100000 /* budget */ + max(WORLD_X*WORLD_Y/2 * sizeof(int) * 7, diff -ur emp4.2.10/src/lib/player/empmod.c emp4.6th/src/lib/player/empmod.c --- emp4.2.10/src/lib/player/empmod.c Thu Aug 9 01:01:45 2001 +++ emp4.6th/src/lib/player/empmod.c Wed Sep 4 20:52:56 2002 @@ -70,6 +70,7 @@ extern int load(); extern int look(); extern int map(); +extern int mdump(); extern int mine(); extern int move(); extern int nati(); @@ -244,6 +245,7 @@ { "bestpath ", 0, best, 0, NORM }, { "bestdistpath ", 0, best, 0, NORM }, { "bmap [s|l|p|r|t*]", 0, map, C_MOD, NORM }, +{ "bmdump [t]", 0, mdump, C_MOD, NORM }, { "board [|]", 3, boar, C_MOD, NORM+MONEY+CAP }, { "bomb ",2,bomb,C_MOD, NORM+MONEY+CAP }, { "break {sanctuary}", 1, brea, C_MOD, SANCT }, @@ -262,7 +264,7 @@ { "collect ", 2, coll, C_MOD, NORM+MONEY+CAP }, { "commodity ", 0, comm, 0, VIS }, { "consider ",1,cons,C_MOD, NORM+CAP }, -{ "convert [sure?]", 2, conv, C_MOD, NORM+MONEY+CAP }, +{ "convert [sure?]", 2, conv, C_MOD, GOD }, { "country ", 0, coun, 0, NORM }, { "cutoff ", 0, cuto, C_MOD, NORM }, { "declare ", 2, decl, C_MOD, NORM+CAP }, @@ -276,7 +278,7 @@ { "drop ",1,drop,C_MOD, NORM+MONEY+CAP }, { "dump []", 0, dump, 0, NORM }, { "echo []", 0, echo, 0, NORM }, -{ "edit ", 0, edit, C_MOD, GOD }, +{ "edit ", 0, edit, C_MOD, GOD }, { "enable", 0, enab, C_MOD, GOD }, { "enlist ", 2, enli, C_MOD, NORM+MONEY+CAP }, { "execute ", 0, execute,0, VIS }, @@ -323,6 +325,7 @@ { "market [COMM]", 0, mark, 0, VIS }, { "map ", 0, map, C_MOD, VIS }, { "march ", 1, march, C_MOD, NORM+CAP }, +{ "mdump ", 0, mdump, C_MOD, NORM }, { "mine ", 2, mine, C_MOD, NORM+MONEY+CAP }, { "mission []", 2,mission,C_MOD, NORM+CAP }, { "mobupdate ", 0, mobupdate, C_MOD, GOD }, @@ -339,6 +342,7 @@ { "neweff ", 0, newe, C_MOD, NORM }, { "newspaper [days]", 0, news, 0, VIS }, { "nmap ", 0, map, C_MOD, VIS }, +{ "nmdump ", 0, mdump, C_MOD, NORM }, { "nuke ", 0, nuke, 0, NORM }, { "offer [ ]",1,offe,C_MOD, NORM+MONEY+CAP }, { "offset ", 0, offs, C_MOD, GOD }, diff -ur emp4.2.10/src/lib/player/player.c emp4.6th/src/lib/player/player.c --- emp4.2.10/src/lib/player/player.c Sun Oct 8 02:36:00 2000 +++ emp4.6th/src/lib/player/player.c Wed Sep 4 20:58:19 2002 @@ -150,10 +150,12 @@ * randomly round up to the nearest minute, * charging at least 15 seconds. */ - secs = max(player->curup - player->lasttime, 15); + time(&natp->nat_last_logout); + secs = max(natp->nat_last_logout - player->lasttime, 15); + natp->nat_minused += secs / 60; + secs = secs % 60; if (chance(secs / 60.0)) natp->nat_minused += 1; - time(&natp->nat_last_logout); natp->nat_connected = 0; putnat(natp); pr("Bye-bye\n"); diff -ur emp4.2.10/src/lib/subs/attsub.c emp4.6th/src/lib/subs/attsub.c --- emp4.2.10/src/lib/subs/attsub.c Wed Jun 27 19:57:09 2001 +++ emp4.6th/src/lib/subs/attsub.c Sat Sep 7 15:51:13 2002 @@ -1299,7 +1299,9 @@ if (off[n].type == EF_BAD || (check && att_get_combat(&off[n], 0) <= 0)) continue; +#if 0 ototal += off[n].troops * att_combat_eff(off + n); +#endif /* 0 */ } /* @@ -1348,7 +1350,10 @@ if (check && att_get_combat(def, 1) < 0) return 0; eff = att_combat_eff(def); + +#if 0 dtotal = def->troops * eff; +#endif /* 0 */ /* * next, add in the defense_values of all @@ -1894,19 +1899,31 @@ * recalculate the odds every 8-50 casualties, not every cacsualty, * since a single dead guy normally wouldn't cause a commander to * rethink his strategies, but 50 dead guys might. */ - odds = odds + (double)((double)((random() % 11) - 5) / 100.0); - if (odds < 0.0) - odds = 0.1; - if (odds > 1.0) - odds = 1.0; + if (!success || (combat_mode == A_PARA)) + { + odds = odds + (double)((double)((random() % 11) - 5) / 100.0); + if (odds < 0.0) + odds = 0.1; + else if (odds > 1.0) + odds = 1.0; + } recalctime = 8 + (random() % 43); - while (!success && ototal){ + while (!success && ototal) { if (chance(odds)) { pr("!"); d_cas += take_casualty(A_DEFEND,def,dlist); dtotal = get_dtotal(def,dlist,dsupport,0); if (!dtotal) - ++success; + { + while (take_casualty(A_DEFEND,def,dlist)) + { + pr("!"); + d_cas += CASUALTY_LUMP; + if (((a_cas + d_cas) % 70) == 69) + pr("\n"); + } + success = 1; + } } else { pr("@"); a_cas += take_casualty(combat_mode,off,olist); @@ -1914,7 +1931,7 @@ } if (((a_cas + d_cas) % 70) == 69) pr("\n"); - if (recalctime-- <= 0) { + if ((recalctime-- <= 0) && (!success || (combat_mode == A_PARA))) { recalctime = 8 + (random() % 43); odds = att_calcodds(ototal,dtotal); odds = odds + (double)((double)((random() % 11) - 5) / 100.0); @@ -1925,6 +1942,9 @@ } } pr("\n"); + if (a_cas == a_bodies) + success = 0; + /* update defense mobility & mil */ if (success) def->mil = 0; @@ -2196,7 +2216,7 @@ int att_empty_attack(int combat_mode, int ototal, struct combat *def) { - if (ototal <= 0) { + if ((ototal <= 0) && (combat_mode != A_PARA)) { if (def->own && player->cnum != def->own) { wu(0, def->own, "%s (#%d) considered %sing you @%s\n", diff -ur emp4.2.10/src/lib/subs/shpsub.c emp4.6th/src/lib/subs/shpsub.c --- emp4.2.10/src/lib/subs/shpsub.c Sat Mar 11 05:36:23 2000 +++ emp4.6th/src/lib/subs/shpsub.c Wed Sep 4 20:58:19 2002 @@ -855,7 +855,11 @@ (mobcost + techfact(mlp->ship.shp_tech, mobcost)); mlp->ship.shp_x = newx; mlp->ship.shp_y = newy; - mlp->mobil -= mobcost; + if (mlp->mobil - mobcost < -127) { + mlp->mobil = -127; + } else { + mlp->mobil -= mobcost; + } mlp->ship.shp_mobil = (int)mlp->mobil; putship(mlp->ship.shp_uid, &mlp->ship); mlp->done = 0; /* We haven't interdicted this ship yet */ diff -ur emp4.2.10/src/server/main.c emp4.6th/src/server/main.c --- emp4.2.10/src/server/main.c Thu Dec 21 20:40:03 2000 +++ emp4.6th/src/server/main.c Wed Sep 4 20:56:18 2002 @@ -421,7 +421,7 @@ /* Fix up the military values */ for (j = 0; j < lchr[i].l_nv; j++) { if (lchr[i].l_vtype[j] == V_MILIT) - lchr[i].l_mil = lchr[i].l_vtype[j]; + lchr[i].l_mil = lchr[i].l_vamt[j]; } } for (i = 0; i < shp_maxno; i++) { diff -ur emp4.2.10/src/util/Makefile emp4.6th/src/util/Makefile --- emp4.2.10/src/util/Makefile Sat Mar 11 05:41:24 2000 +++ emp4.6th/src/util/Makefile Thu May 9 18:44:35 2002 @@ -32,6 +32,8 @@ include ../make.src include ../make.defs +CFLAGS += -Dlinux + LIBDIR = $(SRCDIR)/lib LIBS = $(LIBDIR)/libsubs.a \ diff -ur emp4.2.10/src/util/fairland.c emp4.6th/src/util/fairland.c --- emp4.2.10/src/util/fairland.c Sat Mar 11 05:36:48 2000 +++ emp4.6th/src/util/fairland.c Thu May 16 20:55:07 2002 @@ -800,12 +800,17 @@ void grow_islands() { - int c, x, y, isiz; + int i, c, x, y, isiz; for (c = nc; c < nc+ni; ++c) { secs = 0; - if (!place_island(c, &x, &y)) - return; + i = 0; + while (!place_island(c, &x, &y) && (i < 10)) + { + i++; + } + if (i == 10) + continue; isiz = 1 + rnd(2*is - 1); do { ++secs; @@ -1057,7 +1062,7 @@ write_sects(void) { register struct sctstr *sct; - int c, x, y, total; + int c, o, x, y, total; /* sct = §s[0][0];*/ sct = sectsbuf; @@ -1065,20 +1070,66 @@ for (x = 0; x < XSIZE; x++, sct++) { fl_sct_init(x*2 + (y & 01), y, (s_char *) sct); total = elev[sct->sct_x][y]; - if (total < LANDMIN) { + o = own[x * 2 + (y & 01)][y]; + + if (total < LANDMIN) sct->sct_type = SCT_WATER; - } else if (total < HILLMIN) - sct->sct_type = SCT_RURAL; + else if ((o < nc) || (total < HILLMIN)) + sct->sct_type = SCT_RURAL; else if (total < PLATMIN) sct->sct_type = SCT_MOUNT; else if (total < HIGHMIN) sct->sct_type = SCT_RURAL; else sct->sct_type = SCT_MOUNT; + sct->sct_elev = total; sct->sct_newtype = sct->sct_type; - if (ORE) + + if ((o < nc) && (o >= 0)) + { + sct->sct_terr = o + 1; + sct->sct_own = o + 1; + } + + if (sct->sct_type == SCT_RURAL) + { + sct->sct_min = 100; + sct->sct_gmin = 0; + sct->sct_fertil = 100; + sct->sct_oil = 100; + sct->sct_uran = 75; + } else if (sct->sct_type == SCT_WATER) + { + sct->sct_type = SCT_MOUNT; + sct->sct_min = 0; + sct->sct_gmin = 75; + sct->sct_fertil = 50; + sct->sct_oil = 0; + sct->sct_uran = 0; + } else if (sct->sct_type == SCT_MOUNT) + { + /* water or plains */ + if (rnd(100) > 50) + { + sct->sct_type = SCT_PLAINS; + sct->sct_min = 0; + sct->sct_gmin = 0; + sct->sct_fertil = 25; + sct->sct_oil = 0; + sct->sct_uran = 0; + } else + { + sct->sct_type = SCT_WATER; + sct->sct_min = 0; + sct->sct_gmin = 0; + sct->sct_fertil = 100; + sct->sct_oil = 100; + sct->sct_uran = 0; + } + } else add_resources(sct); + sct->sct_newtype = sct->sct_type; } } if (AIRPORT_MARKER) @@ -1122,7 +1173,7 @@ for (i = 0; i < WORLD_Y; ++i) { puts(""); if (i%2) - printf(" "); + putchar(' '); for (j = i%2; j < WORLD_X; j += 2) { if (own[j][i] == -1) printf(". "); @@ -1190,11 +1241,14 @@ { int c, iscap = 0; + for (c = 0; c < nc; ++c) if ((x == capx[c] && y == capy[c]) || (x == new_x(capx[c]+2) && y == capy[c])) iscap = 1; if ((elev[x][y] >= HILLMIN && elev[x][y] < PLATMIN) || elev[x][y] >= HIGHMIN) - return '^'; + if ((own[x][y] >= nc) || (own[x][y] < 0)) + return '^'; + return own[x][y]>=nc?'%':iscap?'#':numletter[own[x][y] % 62]; }