diff -ur --exclude info.nr emp4.2.11/Make.sysdefs emp4.7th/Make.sysdefs --- emp4.2.11/Make.sysdefs Fri Aug 23 20:51:39 2002 +++ emp4.7th/Make.sysdefs Sat May 3 14:56:57 2003 @@ -36,9 +36,12 @@ OSXMASTER = GLOBALCFLAGS="$(OSXCFLAGS)" GLOBALLFLAGS="$(OSXLFLAGS)" FREEBSDRANLIB = /usr/bin/ranlib -FREEBSDCFLAGS = -DRel4 -DFBSD -ansi -pedantic #-Wall +FREEBSDCFLAGS = -DRel4 -DFBSD -ansi -pedantic -g -Wall -W FREEBSDLFLAGS = FREEBSDMASTER = GLOBALCFLAGS="$(FREEBSDCFLAGS)" GLOBALLFLAGS="$(FREEBSDLFLAGS)" RANLIB="$(FREEBSDRANLIB)" + +FREEBSDCFLAGSINET6 = -DRel4 -DFBSD -DINET6 -ansi -pedantic -g -Wall -W +FREEBSDMASTERINET6 = GLOBALCFLAGS="$(FREEBSDCFLAGSINET6)" GLOBALLFLAGS="$(FREEBSDLFLAGS)" RANLIB="$(FREEBSDRANLIB)" APOLLOCFLAGS = -g APOLLOLFLAGS = diff -ur --exclude info.nr emp4.2.11/Makefile emp4.7th/Makefile --- emp4.2.11/Makefile Fri Aug 23 20:55:15 2002 +++ emp4.7th/Makefile Mon Feb 10 20:37:18 2003 @@ -51,6 +51,7 @@ @echo ' alpha-pthreads' @echo ' apollo' @echo ' freebsd' + @echo ' freebsd-inet6' @echo ' hp' @echo ' hpux' @echo ' irix' @@ -105,6 +106,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 --exclude info.nr emp4.2.11/build.conf emp4.7th/build.conf --- emp4.2.11/build.conf Mon Aug 13 22:40:13 2001 +++ emp4.7th/build.conf Mon Mar 3 21:28:34 2003 @@ -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.7th/ # 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 = 152 +WORLDY = 76 # 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 --exclude info.nr emp4.2.11/include/map.h emp4.7th/include/map.h --- emp4.2.11/include/map.h Sat Mar 11 05:14:55 2000 +++ emp4.7th/include/map.h Mon Feb 10 20:37:25 2003 @@ -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 --exclude info.nr emp4.2.11/include/nat.h emp4.7th/include/nat.h --- emp4.2.11/include/nat.h Sun Sep 1 17:44:45 2002 +++ emp4.7th/include/nat.h Wed Mar 5 21:03:49 2003 @@ -72,7 +72,7 @@ time_t nat_last_logout; /* time of last logout */ time_t nat_newstim; /* date news last read */ time_t nat_annotim; /* date annos last read */ - float nat_level[4]; /* technology, etc */ + float nat_level[5]; /* technology, etc */ struct boundstr nat_b[MAXNOR]; /* realm bounds */ short nat_relate[MAXNOC]; short nat_contact[MAXNOC]; /* short for everyone */ @@ -128,6 +128,7 @@ #define NAT_RLEV 1 #define NAT_ELEV 2 #define NAT_HLEV 3 +#define NAT_VLEV 4 #define NF_CHAR 1 #define NF_UCHAR 2 diff -ur --exclude info.nr emp4.2.11/include/player.h emp4.7th/include/player.h --- emp4.2.11/include/player.h Sat Mar 11 05:14:52 2000 +++ emp4.7th/include/player.h Mon Feb 10 20:37:18 2003 @@ -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]; diff -ur --exclude info.nr emp4.2.11/include/product.h emp4.7th/include/product.h --- emp4.2.11/include/product.h Sat Mar 11 05:14:52 2000 +++ emp4.7th/include/product.h Wed Mar 5 20:19:26 2003 @@ -67,6 +67,7 @@ #define P_HLEV 14 #define P_URAN 15 #define P_MDUST 16 +#define P_VLEV 17 extern struct pchrstr pchr[]; diff -ur --exclude info.nr emp4.2.11/include/prototypes.h emp4.7th/include/prototypes.h --- emp4.2.11/include/prototypes.h Mon Aug 7 20:59:08 2000 +++ emp4.7th/include/prototypes.h Tue Dec 9 00:15:50 2003 @@ -170,7 +170,8 @@ extern int foll(void ); extern int force(void ); extern int fort(void ); -extern int is_engineer(int , int ); +extern int has_friendly_engineer(int , int , natid); +extern int land_harden(struct lndstr *, int ); extern int fuel(void ); extern int give(void ); extern int grin(void ); @@ -383,6 +384,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 +522,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 --exclude info.nr emp4.2.11/include/sect.h emp4.7th/include/sect.h --- emp4.2.11/include/sect.h Wed Aug 8 23:18:18 2001 +++ emp4.7th/include/sect.h Wed Mar 5 20:22:36 2003 @@ -47,6 +47,7 @@ #define _SECT_H_ #define MAXSCTV 42 +#include "misc.h" /* The order of the following elements is there to match up with genitem */ @@ -149,11 +150,12 @@ #define SCT_BANK 29 /* financial */ #define SCT_REFINE 30 /* refinery */ #define SCT_ENLIST 31 /* enlistment center */ -#define SCT_PLAINS 32 /* plains sector */ -#define SCT_BTOWER 33 /* Bridge tower */ +#define SCT_PLAINS 32 /* plains sector */ +#define SCT_BTOWER 33 /* Bridge tower */ +#define SCT_VENT 34 /* venture enterprise */ -#define SCT_EFFIC 34 /* used in update & budget */ -#define SCT_MAXDEF 34 /* highest sector type in header files */ +#define SCT_EFFIC 35 /* used in update & budget */ +#define SCT_MAXDEF 35 /* highest sector type in header files */ #define getsect(x, y, p) \ ef_read(EF_SECTOR, sctoff((int) x, (int) y), (caddr_t)p) diff -ur --exclude info.nr emp4.2.11/info/Commands/fortify.t emp4.7th/info/Commands/fortify.t --- emp4.2.11/info/Commands/fortify.t Mon Feb 21 15:19:29 2000 +++ emp4.7th/info/Commands/fortify.t Sat May 3 15:44:26 2003 @@ -11,8 +11,11 @@ A fully fortified unit is twice as hard to hurt as it normally would be, and is twice as strong on the defense. .s1 -Units fortifying in a sector containing an engineering unit -are better at it. Experiment and find out. +Supplying a negative amount as the number of mobility to use, fortifies +the units for all mobility available above the absolute amount given. +.s1 +Units fortifying in a sector containing a friendly engineering unit +are better at it. Mobility cost is only 2/3 of the normal cost. .s1 If a unit moves or retreats, it loses all fortification value. A unit that reacts to defend a sector, on the other hand, does NOT @@ -23,5 +26,9 @@ Note that fortification will not help a unit fight Guerrillas in an occupied sector (see info Guerrilla). Also note that fortifying a unit does not affect it's mission status. +.s1 +During the update units will use "spare" mobility to fortify themselves +automatically. It is as if "fortify * -67" were issued just before the +update. .s1 .SA "bomb, Unit-types, LandUnits" diff -ur --exclude info.nr emp4.2.11/info/Concepts/Update-sequence.t emp4.7th/info/Concepts/Update-sequence.t --- emp4.2.11/info/Concepts/Update-sequence.t Thu Feb 4 03:43:08 1999 +++ emp4.7th/info/Concepts/Update-sequence.t Sat May 3 15:59:56 2003 @@ -45,11 +45,12 @@ c) If ship maintenance is not yet done, do it now d) If ship building is not yet done, do it now - e) If plane maintenance is not yet done, do it now - f) If plane building is not yet done, do it now - g) If unit maintenance is not yet done, do it now - h) If unit building is not yet done, do it now - i) produce for all sectors that have not yet produced + e) sail paths are sailed and orders are carried out + f) If plane maintenance is not yet done, do it now + g) If plane building is not yet done, do it now + h) If unit maintenance is not yet done, do it now + i) If unit building is not yet done, do it now + j) produce for all sectors that have not yet produced a) if the sector is a cap, it costs $$ equal to the # of etus: np->nat_money -= etus; b) people in non-sanctuary sectors eat @@ -93,6 +94,8 @@ d) Add mobility to land units 1) Units with negative mobility have their mob halved (-100 goes to -50) 2) Mobility is added + 3) If new mobility of a unit is greater than maximum, try using the + surplus for fortifying it. .fi .s1 .SA "Innards, Update" diff -ur --exclude info.nr emp4.2.11/src/doconfig/Makefile emp4.7th/src/doconfig/Makefile --- emp4.2.11/src/doconfig/Makefile Sat Mar 11 05:41:24 2000 +++ emp4.7th/src/doconfig/Makefile Mon Feb 10 20:37:18 2003 @@ -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 --exclude info.nr emp4.2.11/src/doconfig/doconfig.c emp4.7th/src/doconfig/doconfig.c --- emp4.2.11/src/doconfig/doconfig.c Thu Dec 21 20:59:40 2000 +++ emp4.7th/src/doconfig/doconfig.c Mon Feb 10 20:37:18 2003 @@ -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 --exclude info.nr emp4.2.11/src/lib/commands/budg.c emp4.7th/src/lib/commands/budg.c --- emp4.2.11/src/lib/commands/budg.c Sat Mar 11 05:36:46 2000 +++ emp4.7th/src/lib/commands/budg.c Wed Mar 5 20:29:56 2003 @@ -78,7 +78,7 @@ s_char stype=0, *pq; int priority, x; long p_sect[SCT_MAXDEF+1][2]; - int taxes=0, bars=0, mil=0; + int taxes=0, bars=0, mil=0, vent=0; int Ncivs=0, Nuws=0, Nbars=0; int n, etu; int income = 0, expenses = 0; @@ -167,9 +167,12 @@ &smaint,&units,&lbuild,&nlbuild,&lmaint,&planes,&pbuild, &npbuild,&pmaint); - income = taxes + bars; + if (np->nat_priorities[SCT_VENT] != 0) + vent = 100000 * p_sect[SCT_VENT][0] / (p_sect[SCT_VENT][0] + 4000); + income = taxes + bars + vent; pr("Sector Type\t\tAbbr\tProduction\tPriority\t Cost\n"); for(x=0;xnat_priorities[x] == -1) continue; if (!pchr[dchr[x].d_prd].p_cost && @@ -287,6 +290,11 @@ in, taxes); } + sprintf(in, "%d goods",p_sect[SCT_VENT][0]); + if (vent) pr("Income from venture capital\t%-32s%+8d\n", in, vent); + if (np->nat_priorities[SCT_VENT] == 0) + pr("Income from venture capital\t%-32s(%+7d)\n", in, + 100000 * p_sect[SCT_VENT][0] / (p_sect[SCT_VENT][0] + 4000)); if (bars) { sprintf(in, "%d bar%s", Nbars, splur(Nbars)); pr("Income from bars\t\t%-32s%+8d\n", diff -ur --exclude info.nr emp4.2.11/src/lib/commands/fort.c emp4.7th/src/lib/commands/fort.c --- emp4.2.11/src/lib/commands/fort.c Sat Mar 11 05:36:44 2000 +++ emp4.7th/src/lib/commands/fort.c Sat May 3 14:58:55 2003 @@ -50,8 +50,7 @@ int nunits; struct nstr_item ni; struct lndstr land; - int fort_amt, hard_amt, mob_used; - int eng; + int fort_amt, hard_amt; s_char *p; extern int land_mob_max; s_char buf[1024]; @@ -95,38 +94,7 @@ nunits++; - hard_amt = min(land.lnd_mobil, hard_amt); - - if ((land.lnd_harden + hard_amt) > land_mob_max) - hard_amt = land_mob_max - land.lnd_harden; - - eng = is_engineer(land.lnd_x, land.lnd_y); - - if (eng) - hard_amt = ((float)hard_amt * 1.5); - - if ((land.lnd_harden + hard_amt) > land_mob_max) - hard_amt = land_mob_max - land.lnd_harden; - - /* Ok, set the mobility used */ - mob_used = hard_amt; - - /* Now, if an engineer helped, it's really only 2/3rds of - that */ - if (eng) - mob_used = (int)((float)mob_used / 1.5); - - /* If we increased it, but not much, we gotta take at least 1 - mob point. */ - if (mob_used <= 0 && hard_amt > 0) - mob_used = 1; - - land.lnd_mobil -= mob_used; - if (land.lnd_mobil < 0) - land.lnd_mobil = 0; - - land.lnd_harden += hard_amt; - land.lnd_harden = min(land.lnd_harden, land_mob_max); + land_harden(&land, hard_amt); pr("%s hardened to %d\n", prland(&land), land.lnd_harden); @@ -142,19 +110,4 @@ }else pr("%d unit%s\n", nunits, splur(nunits)); return RET_OK; -} - -int -is_engineer(int x, int y) -{ - struct nstr_item ni; - struct lndstr land; - - snxtitem_xy(&ni, EF_LAND, x,y); - while(nxtitem(&ni, (s_char *)&land)){ - if (lchr[(int)land.lnd_type].l_flags & L_ENGINEER) - return 1; - } - - return 0; } diff -ur --exclude info.nr emp4.2.11/src/lib/commands/map.c emp4.7th/src/lib/commands/map.c --- emp4.2.11/src/lib/commands/map.c Sat Mar 11 05:36:42 2000 +++ emp4.7th/src/lib/commands/map.c Mon Feb 10 20:37:25 2003 @@ -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 --exclude info.nr emp4.2.11/src/lib/commands/prod.c emp4.7th/src/lib/commands/prod.c --- emp4.2.11/src/lib/commands/prod.c Sat Mar 11 05:36:40 2000 +++ emp4.7th/src/lib/commands/prod.c Wed Mar 5 20:30:24 2003 @@ -355,6 +355,7 @@ break; case NAT_ELEV: case NAT_HLEV: + case NAT_VLEV: pr(" %4.0f", real); break; default: diff -ur --exclude info.nr emp4.2.11/src/lib/common/land.c emp4.7th/src/lib/common/land.c --- emp4.2.11/src/lib/common/land.c Sat Mar 11 05:36:34 2000 +++ emp4.7th/src/lib/common/land.c Sat May 3 15:26:54 2003 @@ -96,3 +96,66 @@ return 0; } + +int +has_friendly_engineer(int x, int y, natid cn) +{ + struct nstr_item ni; + struct lndstr land; + + snxtitem_xy(&ni, EF_LAND, x,y); + while(nxtitem(&ni, (s_char *)&land)) { + if ((lchr[(int)land.lnd_type].l_flags & L_ENGINEER) + && (land.lnd_own == cn + || getrel(getnatp(land.lnd_own), cn) >= FRIENDLY)) + { + return 1; + } + } + + return 0; +} + +/* returns amount of mob actually used to harden. */ +int +land_harden(struct lndstr * lp, int mob_to_use) +{ + int amount, eng; + extern int land_mob_max; + + /* units on a ship can't be fortified. */ + if (lp->lnd_ship >= 0) + return 0; + + mob_to_use = min(mob_to_use, lp->lnd_mobil); + + amount = mob_to_use; + + eng = has_friendly_engineer(lp->lnd_x, lp->lnd_y, lp->lnd_own); + + if (eng) + amount = (int)((float)amount * 1.5); + + if (amount + lp->lnd_harden > land_mob_max) + amount = land_mob_max - lp->lnd_harden; + + lp->lnd_harden += amount; + + mob_to_use = amount; + + /* Now, if an engineer helped, it's really only 2/3rds of + that */ + if (eng) + mob_to_use = (int)((float)mob_to_use / 1.5); + + /* If we increased it, but not much, we gotta take at least 1 + mob point. */ + if (mob_to_use <= 0 && amount > 0) + mob_to_use = 1; + + lp->lnd_mobil -= mob_to_use; + if (lp->lnd_mobil < 0) + lp->lnd_mobil = 0; + + return amount; +} diff -ur --exclude info.nr emp4.2.11/src/lib/common/maps.c emp4.7th/src/lib/common/maps.c --- emp4.2.11/src/lib/common/maps.c Fri Oct 6 20:19:51 2000 +++ emp4.7th/src/lib/common/maps.c Mon Feb 10 20:37:25 2003 @@ -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 --exclude info.nr emp4.2.11/src/lib/global/product.c emp4.7th/src/lib/global/product.c --- emp4.2.11/src/lib/global/product.c Sat Mar 11 05:36:29 2000 +++ emp4.7th/src/lib/global/product.c Wed Mar 5 20:33:12 2003 @@ -91,6 +91,9 @@ { 0, { 0 }, { 0 }, V_DUST, -1, 0,OFFSET(sctstr, sct_gmin),20, -1, 0, 0, 75, "gold dust", "dust",}, +{ 2, { V_LCM, V_HCM}, { 1, 2 }, +0, NAT_VLEV, 0, 0, 0, -1, 0, 0, 100, + "venture goods", "goods", }, { 0, {0}, {0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "",} }; diff -ur --exclude info.nr emp4.2.11/src/lib/global/sect.c emp4.7th/src/lib/global/sect.c --- emp4.2.11/src/lib/global/sect.c Sat Mar 11 05:36:29 2000 +++ emp4.7th/src/lib/global/sect.c Wed Mar 5 21:07:33 2003 @@ -82,6 +82,7 @@ { 'e', 0, 2, 0, NPKG,1.0, 2.0, 7, 0, 1, 0, 0, "enlistment center" }, { '~', 0, 2, 0, NPKG,1.0, 1.5, 1, 0, 1, 0, 0, "plains" }, { '@', 0, 1, 0, NPKG,1.0, 1.5, 4, 0, 1, 0, 0, "bridge tower" }, +{ 'v', P_VLEV, 2, 0, NPKG,1.0, 1.5, 7, 0, 1, 0, 0, "venture enterprise" }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; diff -ur --exclude info.nr emp4.2.11/src/lib/player/accept.c emp4.7th/src/lib/player/accept.c --- emp4.2.11/src/lib/player/accept.c Sat Mar 11 05:36:28 2000 +++ emp4.7th/src/lib/player/accept.c Mon Mar 3 21:10:30 2003 @@ -44,6 +44,9 @@ #include "common.h" #include "gen.h" #include "optlist.h" +#if 0 +#include "inet6.h" +#endif /* 0 */ #if !defined(_WIN32) #include @@ -72,13 +75,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 +135,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 +235,12 @@ { extern s_char *loginport; extern int errno; +#ifdef INET6 + struct addrinfo hints; + struct addrinfo *res; + int return_error; + char *service = "empire7"; +#endif /* INET6 */ struct sockaddr_in sin; struct servent *sp; int s; @@ -207,6 +260,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 +282,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 +292,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 +318,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 +337,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 --exclude info.nr emp4.2.11/src/lib/player/empmod.c emp4.7th/src/lib/player/empmod.c --- emp4.2.11/src/lib/player/empmod.c Thu Aug 29 15:00:01 2002 +++ emp4.7th/src/lib/player/empmod.c Mon Feb 10 20:37:25 2003 @@ -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(); @@ -245,6 +246,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 }, @@ -324,6 +326,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 }, @@ -340,6 +343,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 --exclude info.nr emp4.2.11/src/lib/subs/satmap.c emp4.7th/src/lib/subs/satmap.c --- emp4.2.11/src/lib/subs/satmap.c Mon Aug 7 21:16:00 2000 +++ emp4.7th/src/lib/subs/satmap.c Wed Jul 2 21:58:32 2003 @@ -199,9 +199,9 @@ else rx = deltax(x, ns.range.lx) + rx; if (ship.shp_y < y) - ry = deltay(y, ns.range.ly) + ry; - else ry = deltay(y, ns.range.ly) - ry; + else + ry = deltay(y, ns.range.ly) + ry; /* &~0x20 makes it a cap letter */ rad[ry][rx] = (*mchr[(int)ship.shp_type].m_name) & ~0x20; } @@ -255,9 +255,9 @@ else rx = deltax(x, ns.range.lx) + rx; if (land.lnd_y < y) - ry = deltay(y, ns.range.ly) + ry; - else ry = deltay(y, ns.range.ly) - ry; + else + ry = deltay(y, ns.range.ly) + ry; /* &~0x20 makes it a cap letter */ rad[ry][rx] = (*lchr[(int)land.lnd_type].l_name) & ~0x20; } diff -ur --exclude info.nr emp4.2.11/src/lib/update/main.c emp4.7th/src/lib/update/main.c --- emp4.2.11/src/lib/update/main.c Sun Sep 1 17:45:41 2002 +++ emp4.7th/src/lib/update/main.c Wed Mar 5 20:35:39 2003 @@ -72,6 +72,7 @@ int x; int *bp; int cn,cn2,rel; + int vent; struct natstr *cnp; struct natstr *np; @@ -125,6 +126,9 @@ } np->nat_money += (int) (np->nat_reserve * money_res * etu); + produce_sect(x, etu, bp, p_sect, -2); + vent = venture_money(x,0); + np->nat_money += vent; for(y=1; ynat_priorities[z] == y) { @@ -144,6 +148,7 @@ /* produce all sects that haven't produced yet */ produce_sect(x, etu, bp, p_sect, -1); np->nat_money -= p_sect[SCT_CAPIT][1]; + np->nat_money += venture_money(x,vent); } logerror("done producing for countries."); diff -ur --exclude info.nr emp4.2.11/src/lib/update/mobility.c emp4.7th/src/lib/update/mobility.c --- emp4.2.11/src/lib/update/mobility.c Sat Mar 11 05:36:22 2000 +++ emp4.7th/src/lib/update/mobility.c Sat May 3 15:29:12 2003 @@ -398,17 +398,27 @@ extern int land_mob_max; extern float land_mob_scale; int newfuel=0; - register int value; - int can_add,have_fuel_for,total_add; double d; extern int fuel_mult; + /* + * We must use these variables because lnd_mobil and lnd_harden + * are of type s_char and might not be large enough to contain + * temporary results. + */ + register int value; + int can_add,have_fuel_for,total_add; + if (lp->lnd_own == 0) return; if (lp->lnd_mobil >= land_mob_max) { - lp->lnd_mobil = land_mob_max; - return; + lp->lnd_mobil = land_mob_max; + if (lp->lnd_harden >= land_mob_max) + { + lp->lnd_harden = land_mob_max; + return; + } } /* @@ -435,8 +445,15 @@ } else { value = lp->lnd_mobil + ((float)etus * land_mob_scale); } + if (value > land_mob_max) + { + if (lp->lnd_harden < land_mob_max) + land_harden(lp, value - land_mob_max); + value = land_mob_max; + } + lp->lnd_mobil = value; return; /* Done! */ @@ -453,7 +470,12 @@ value = lp->lnd_mobil + ((float)etus * land_mob_scale); } if (value > land_mob_max) + { + if (lp->lnd_harden < land_mob_max) + land_harden(lp, value - land_mob_max); + value = land_mob_max; + } lp->lnd_mobil = value; } else { @@ -513,7 +535,11 @@ lp->lnd_fuel -= (u_char)ldround(d,1); lp->lnd_fuel = (u_char)min(lp->lnd_fuel, lp->lnd_fuelc); - if(total_add + lp->lnd_mobil > land_mob_max) { + + if (total_add + lp->lnd_mobil > land_mob_max) { + if (lp->lnd_harden < land_mob_max) + land_harden(lp, total_add + lp->lnd_mobil - land_mob_max); + total_add = land_mob_max - lp->lnd_mobil; } diff -ur --exclude info.nr emp4.2.11/src/lib/update/nat.c emp4.7th/src/lib/update/nat.c --- emp4.2.11/src/lib/update/nat.c Sat Aug 11 00:39:32 2001 +++ emp4.7th/src/lib/update/nat.c Wed Mar 5 20:37:17 2003 @@ -45,7 +45,7 @@ #include "update.h" #include "subs.h" -float levels[MAXNOC][4]; +float levels[MAXNOC][5]; /* * hap and edu avg mean that the weight on current happiness is @@ -226,6 +226,8 @@ wu((natid)0, n, "Army delta $%d, Navy delta $%d, Air force delta $%d\n", lnd_money[n], sea_money[n], air_money[n]); + wu((natid)0, n, "venture capital was $%d for this update\n", + venture_money(n,0)); wu((natid)0, n, "money delta was $%d for this update\n", np->nat_money - money[n]); if (opt_LOSE_CONTACT) { @@ -307,3 +309,9 @@ } } +int +venture_money(int n, int cur) +{ + int money = 100000 * levels[n][NAT_VLEV] / (levels[n][NAT_VLEV] + 4000); + return (money - cur); +} diff -ur --exclude info.nr emp4.2.11/src/lib/update/prepare.c emp4.7th/src/lib/update/prepare.c --- emp4.2.11/src/lib/update/prepare.c Sat Mar 11 05:36:21 2000 +++ emp4.7th/src/lib/update/prepare.c Wed Mar 5 20:37:31 2003 @@ -52,7 +52,7 @@ #include "gen.h" #include "common.h" -extern float levels[MAXNOC][4]; +extern float levels[MAXNOC][5]; void prepare_sects(int etu, int *bp) diff -ur --exclude info.nr emp4.2.11/src/lib/update/produce.c emp4.7th/src/lib/update/produce.c --- emp4.2.11/src/lib/update/produce.c Sat Mar 11 05:36:21 2000 +++ emp4.7th/src/lib/update/produce.c Wed Mar 5 20:37:56 2003 @@ -50,7 +50,7 @@ int produce(struct natstr *np, struct sctstr *sp, int *vec, int work, int sctwork, int desig, int neweff, int *cost, int *amount) { - extern float levels[MAXNOC][4]; + extern float levels[MAXNOC][5]; extern long tpops[]; register struct pchrstr *product; int vtype; diff -ur --exclude info.nr emp4.2.11/src/lib/update/sect.c emp4.7th/src/lib/update/sect.c --- emp4.2.11/src/lib/update/sect.c Sat Mar 11 05:36:13 2000 +++ emp4.7th/src/lib/update/sect.c Wed Mar 5 20:42:38 2003 @@ -55,7 +55,7 @@ #include "lost.h" #include "gen.h" -extern float levels[MAXNOC][4]; +extern float levels[MAXNOC][5]; int dodeliver(struct sctstr *sp, int *vec) @@ -352,7 +352,7 @@ putvec(VT_COND, cvec, (s_char *)sp, EF_SECTOR); } -#define SHOULD_PRODUCE(sp,t) (((sp->sct_type == t) || (t == -1)) ? 1 : 0) +#define SHOULD_PRODUCE(sp,t) (((sp->sct_type == t) || (t == -1) || ((t == -2) && (sp->sct_newtype == SCT_VENT))) ? 1 : 0) /* * Produce only a set sector type for a specific nation @@ -416,7 +416,7 @@ putvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR); sp->sct_off = 0; } - continue; + if (sp->sct_off || sp->sct_newtype != SCT_VENT) continue; } if ((np->nat_priorities[sp->sct_type] == 0) && (sp->sct_type == sp->sct_newtype) && @@ -437,7 +437,7 @@ desig = sp->sct_type; if ((sp->sct_effic < 100 || sp->sct_type != sp->sct_newtype) && - np->nat_money > 0) { + (np->nat_money > 0 || sp->sct_newtype == SCT_VENT)) { neweff = upd_buildeff(np, sp, &work, vec, etu, &desig, sctwork, &cost); pt_bg_nmbr(bp, sp, I_LCM, vec[I_LCM]); pt_bg_nmbr(bp, sp, I_HCM, vec[I_HCM]); @@ -489,7 +489,7 @@ */ if (neweff >= 60) { - if (np->nat_money > 0 && dchr[desig].d_prd) + if (sp->sct_type == SCT_VENT || np->nat_money > 0 && dchr[desig].d_prd) work -= produce(np, sp, vec, work, sctwork, desig, neweff, &pcost, &amount); }