diff -ru emp4/Make.sysdefs emp4/Make.sysdefs --- emp4/Make.sysdefs Fri Aug 23 20:51:39 2002 +++ emp4/Make.sysdefs Mon Feb 10 20:06:30 2003 @@ -40,6 +40,9 @@ FREEBSDLFLAGS = FREEBSDMASTER = GLOBALCFLAGS="$(FREEBSDCFLAGS)" GLOBALLFLAGS="$(FREEBSDLFLAGS)" RANLIB="$(FREEBSDRANLIB)" +FREEBSDCFLAGSINET6 = -DRel4 -DFBSD -DINET6 -ansi -pedantic #-Wall +FREEBSDMASTERINET6 = GLOBALCFLAGS="$(FREEBSDCFLAGSINET6)" GLOBALLFLAGS="$(FREEBSDLFLAGS)" RANLIB="$(FREEBSDRANLIB)" + APOLLOCFLAGS = -g APOLLOLFLAGS = APOLLOMASTER = GLOBALCFLAGS="$(APOLLOCFLAGS)" GLOBALLFLAGS="$(APOLLOLFLAGS)" diff -ru emp4/Makefile emp4/Makefile --- emp4/Makefile Fri Aug 23 20:55:15 2002 +++ emp4/Makefile Mon Feb 10 20:06:30 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 -ru emp4/build.conf emp4/build.conf --- emp4/build.conf Mon Aug 13 22:40:13 2001 +++ emp4/build.conf Mon Feb 10 20:06:30 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 = 8989 # 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 = 128 +WORLDY = 64 # 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 -ru emp4/include/player.h emp4/include/player.h --- emp4/include/player.h Sat Mar 11 05:14:52 2000 +++ emp4/include/player.h Mon Feb 10 20:06:30 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 -ru emp4/include/prototypes.h emp4/include/prototypes.h --- emp4/include/prototypes.h Mon Aug 7 20:59:08 2000 +++ emp4/include/prototypes.h Mon Feb 10 20:06:30 2003 @@ -520,7 +520,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 -ru emp4/src/doconfig/Makefile emp4/src/doconfig/Makefile --- emp4/src/doconfig/Makefile Sat Mar 11 05:41:24 2000 +++ emp4/src/doconfig/Makefile Mon Feb 10 20:06:30 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 -ru emp4/src/doconfig/doconfig.c emp4/src/doconfig/doconfig.c --- emp4/src/doconfig/doconfig.c Thu Dec 21 20:59:40 2000 +++ emp4/src/doconfig/doconfig.c Mon Feb 10 20:06:30 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 -ru emp4/src/lib/player/accept.c emp4/src/lib/player/accept.c --- emp4/src/lib/player/accept.c Sat Mar 11 05:36:28 2000 +++ emp4/src/lib/player/accept.c Mon Feb 10 20:06: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 = "empire"; +#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,