home *** CD-ROM | disk | FTP | other *** search
- diff -c -w ./oldxtb/Makefile ./newxtb/Makefile
- *** ./oldxtb/Makefile Mon Dec 14 12:13:16 1992
- --- ./newxtb/Makefile Wed Dec 16 11:08:33 1992
- ***************
- *** 6,24 ****
- CC = cc
- # wherever your X11 include files are
- XINCS = -I/usr/openwin/include
-
- SOURCES = xtb.c rtb.c xtbd.c dgram.c common.c
- INCLUDES = defs.h comms.h
- MISC = xtb.6 README TODO
-
- rtb : rtb.o dgram.o common.o
- ! $(CC) -o rtb rtb.o dgram.o common.o -lm
-
- xtb : xtb.o dgram.o common.o
- ! $(CC) -o xtb xtb.o dgram.o common.o -lX11 -lm
-
- xtbd : xtbd.o dgram.o common.o
- ! $(CC) -o xtbd xtbd.o dgram.o common.o -lm
-
- xtb.o : xtb.c $(INCLUDES)
- cc -c xtb.c $(XINCS)
- --- 6,29 ----
- CC = cc
- # wherever your X11 include files are
- XINCS = -I/usr/openwin/include
- + XLIBS = -L/usr/openwin/lib
-
- + # HP-UX users may want to add -lBSD to the next line.
- + LDOPTS = -lm
- + #LDOPTS = -lm -lBSD
- +
- SOURCES = xtb.c rtb.c xtbd.c dgram.c common.c
- INCLUDES = defs.h comms.h
- MISC = xtb.6 README TODO
-
- rtb : rtb.o dgram.o common.o
- ! $(CC) -o rtb rtb.o dgram.o common.o $(LDOPTS)
-
- xtb : xtb.o dgram.o common.o
- ! $(CC) -o xtb xtb.o dgram.o common.o $(XLIBS) -lX11 $(LDOPTS)
-
- xtbd : xtbd.o dgram.o common.o
- ! $(CC) -o xtbd xtbd.o dgram.o common.o $(LDOPTS)
-
- xtb.o : xtb.c $(INCLUDES)
- cc -c xtb.c $(XINCS)
- diff -c -w ./oldxtb/README ./newxtb/README
- *** ./oldxtb/README Mon Dec 14 12:13:05 1992
- --- ./newxtb/README Wed Dec 16 16:31:29 1992
- ***************
- *** 1,3 ****
- --- 1,4 ----
- + README FILE FOR XTANKBATTLE 15th Dec 1992
-
- WHAT YOU NEED TO HAVE
- =====================
- ***************
- *** 9,15 ****
-
- A three button mouse (It's playable with a two button mouse).
-
- ! A fastish (and unloaded) CPU and reasonable drawing speed.
-
- A fastish network.
-
- --- 10,17 ----
-
- A three button mouse (It's playable with a two button mouse).
-
- ! A fastish (and unloaded) CPU and reasonable drawing speed. (X terminals
- ! may have problems)
-
- A fastish network.
-
- ***************
- *** 40,45 ****
- --- 42,50 ----
- COMPILING
- =========
-
- + You may need to edit the Makefile to point to where your X11 include files
- + and X11 librarys live.
- +
- Type
- make
-
- ***************
- *** 57,67 ****
- workstation% xtb -h hostname
- (ignore messages about datagrams and fielddata)
-
- RUNNING TWO (OR MORE) PLAYERS ON THE SAME NODE
- ==============================================
-
- ! The second and further players, should pick different port numbers to
- ! the default (and each other). eg the second player might type
-
- workstation% xtb -h hostname -i 1624
-
- --- 62,76 ----
- workstation% xtb -h hostname
- (ignore messages about datagrams and fielddata)
-
- + (It seems that on HP-UX if you want to refer to your own host, you must
- + use the hostname 'localhost')
- +
- RUNNING TWO (OR MORE) PLAYERS ON THE SAME NODE
- ==============================================
-
- ! For second and further players *on the same workstation*, should pick
- ! different port numbers to the default (and each other). eg the second
- ! player might type
-
- workstation% xtb -h hostname -i 1624
-
- ***************
- *** 182,187 ****
- --- 191,220 ----
-
- The program comes with no warranty. I would like the conditions that
- apply to GNU software to apply to this software.
- +
- + Bugs fixed in version 8
- + =======================
- +
- + Now works on hosts with hostnames of up to 63 chars.
- + xtbd now works on HP-UX, (used to fail with 'Alarm clock')
- + You are now notified immediatly when your damage is zeroed when you kill
- + another player (Fixed by Jonathan Bayer (jbayer@ispi.COM))
- + Now works properly on NCD X terminuals (Fixed by Martin Boyer
- + (mboyer@ireq-robot.hydro.qc.ca))
- +
- +
- + There is a work around (in this REAME file) for the problem with using
- + your own host for xtb and xtbd on HP-UX.
- +
- + I have now changed the README file to make it more obvious when you need
- + to specify port numbers to xtb/rtb/xtbd. (ie. you shouldn't need to in
- + most cases)
- +
- + Note that version 7 programs won't work with version 8 programs.
- +
- + If you mail me about problems/bug-reports/suggestions for improvement,
- + please say what type of machine you are using, which revision of the
- + operating system, and what verson of X-windows you are using.
-
- Good Luck!
-
- diff -c -w ./oldxtb/comms.h ./newxtb/comms.h
- *** ./oldxtb/comms.h Mon Dec 14 12:13:18 1992
- --- ./newxtb/comms.h Wed Dec 16 11:08:17 1992
- ***************
- *** 1,7 ****
- /* comms and common data structures */
-
- /*
- ! * $Header: /morpork/home/bmh/xtest2/RCS/comms.h,v 1.18 92/10/19 15:34:38 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- --- 1,7 ----
- /* comms and common data structures */
-
- /*
- ! * $Header: /morpork/home/bmh/xtest2/RCS/comms.h,v 1.19 92/12/16 11:08:14 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- ***************
- *** 34,39 ****
- --- 34,45 ----
- char hostname[HOSTLEN]; /* sending hostname */
- } USER;
-
- + typedef struct struct_ip
- + {
- + int len;
- + char addr[8]; /* no one should have an IP address longer than this! */
- + } IP;
- +
- typedef struct struct_position
- {
- int x; /* x position on battlefield */
- ***************
- *** 47,54 ****
- {
- int port; /* callback port no. */
- int version; /* program version */
- ! char hostname[HOSTLEN]; /* sending hostname */
- ! char username[NAMELEN];
- } SIGNON;
-
- typedef struct accept_struct
- --- 53,61 ----
- {
- int port; /* callback port no. */
- int version; /* program version */
- ! char hostname[FULLHOSTLEN]; /* sending hostname */
- ! char username[FULLNAMELEN];
- ! IP ip;
- } SIGNON;
-
- typedef struct accept_struct
- diff -c -w ./oldxtb/defs.h ./newxtb/defs.h
- *** ./oldxtb/defs.h Mon Dec 14 12:13:21 1992
- --- ./newxtb/defs.h Wed Dec 16 11:08:20 1992
- ***************
- *** 1,6 ****
- /* common defines */
- /*
- ! * $Header: /morpork/home/bmh/xtest2/RCS/defs.h,v 1.20 92/10/19 15:34:40 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- --- 1,6 ----
- /* common defines */
- /*
- ! * $Header: /morpork/home/bmh/xtest2/RCS/defs.h,v 1.21 92/12/16 11:08:16 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- ***************
- *** 10,16 ****
-
- /* increment this version no. if the client/server protocol is */
- /* changed in any way */
- ! #define VERSION 7
-
- #define DEFSPORT 1622 /* default server UDP port no. */
- #define DEFCPORT 1623 /* default client UDP port no. */
- --- 10,16 ----
-
- /* increment this version no. if the client/server protocol is */
- /* changed in any way */
- ! #define VERSION 8
-
- #define DEFSPORT 1622 /* default server UDP port no. */
- #define DEFCPORT 1623 /* default client UDP port no. */
- ***************
- *** 31,38 ****
- #define MAINX 768 /* X and Y of main battlefield */
- #define MAINY 768
-
- ! #define HOSTLEN 16 /* max chars in hostname */
- ! #define NAMELEN 16 /* max chars in username */
- #define BUFLEN 128 /* general purpose char buffer */
-
- #define MAINSIZE 2048 /* size of field in pixels */
- --- 31,41 ----
- #define MAINX 768 /* X and Y of main battlefield */
- #define MAINY 768
-
- ! #define HOSTLEN 10 /* max chars in hostname */
- ! #define FULLHOSTLEN 64 /* length of full hostname */
- !
- ! #define NAMELEN 10 /* max chars in username */
- ! #define FULLNAMELEN 64
- #define BUFLEN 128 /* general purpose char buffer */
-
- #define MAINSIZE 2048 /* size of field in pixels */
- diff -c -w ./oldxtb/dgram.c ./newxtb/dgram.c
- *** ./oldxtb/dgram.c Mon Dec 14 12:13:22 1992
- --- ./newxtb/dgram.c Wed Dec 16 11:07:48 1992
- ***************
- *** 1,7 ****
- /*
- * Comms.
- *
- ! * $Header: /morpork/home/bmh/xtest2/RCS/dgram.c,v 1.10 92/10/19 15:34:27 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- --- 1,7 ----
- /*
- * Comms.
- *
- ! * $Header: /morpork/home/bmh/xtest2/RCS/dgram.c,v 1.11 92/12/16 11:07:35 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- ***************
- *** 56,64 ****
- }
-
- int
- ! opensend(host,port)
- char *host;
- int port;
- {
- int ret,sd;
- struct sockaddr_in name;
- --- 56,65 ----
- }
-
- int
- ! opensend(host,port,ip)
- char *host;
- int port;
- + IP *ip;
- {
- int ret,sd;
- struct sockaddr_in name;
- ***************
- *** 73,81 ****
-
- hent=gethostbyname(host);
- if(hent==NULL)
- return(-1);
- !
- bcopy(hent->h_addr,&name.sin_addr,hent->h_length);
- name.sin_family=AF_INET;
- name.sin_port=htons(port);
-
- --- 74,95 ----
-
- hent=gethostbyname(host);
- if(hent==NULL)
- + {
- + if(ip==NULL)
- + {
- return(-1);
- ! }
- ! else
- ! {
- ! fprintf(stderr,"Can't find host %s's IP address trying %d.%d.%d.%d\n",host,ip->addr[0]&0xff,ip->addr[1]&0xff,ip->addr[2]&0xff,ip->addr[3]&0xff);
- ! bcopy(ip->addr,&name.sin_addr,INSWAP(ip->len));
- ! }
- ! }
- ! else
- ! {
- bcopy(hent->h_addr,&name.sin_addr,hent->h_length);
- + }
- +
- name.sin_family=AF_INET;
- name.sin_port=htons(port);
-
- ***************
- *** 95,98 ****
- --- 109,128 ----
- DATA *data;
- {
- return(write(sd,data,sizeof(DATA)));
- + }
- +
- + int
- + getipaddr(host,ip)
- + char *host;
- + IP *ip;
- + {
- + struct hostent *hent;
- +
- + hent=gethostbyname(host);
- + if(hent==NULL)
- + return(-1);
- +
- + bcopy(hent->h_addr,ip->addr,hent->h_length);
- + ip->len=OUTSWAP(hent->h_length);
- + return(0);
- }
- diff -c -w ./oldxtb/rtb.c ./newxtb/rtb.c
- *** ./oldxtb/rtb.c Mon Dec 14 12:13:08 1992
- --- ./newxtb/rtb.c Wed Dec 16 11:08:07 1992
- ***************
- *** 1,7 ****
- /*
- * Robot tank
- *
- ! * $Header: /morpork/home/bmh/xtest2/RCS/rtb.c,v 1.7 92/10/19 15:34:30 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- --- 1,7 ----
- /*
- * Robot tank
- *
- ! * $Header: /morpork/home/bmh/xtest2/RCS/rtb.c,v 1.8 92/12/16 11:07:47 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- ***************
- *** 14,20 ****
- #include <sys/ioctl.h>
- #include <sys/time.h>
- #include <netinet/in.h>
- - #include <unistd.h>
- #include <fcntl.h>
- #include <signal.h>
- #include <ctype.h>
- --- 14,19 ----
- ***************
- *** 502,508 ****
- exit(1);
- }
-
- ! ssd=opensend(server,outport);
- if(ssd==(-1))
- {
- fprintf(stderr,"%s: Connecting to %s/%d failed\n",argv[0],server,outport);
- --- 501,507 ----
- exit(1);
- }
-
- ! ssd=opensend(server,outport,NULL);
- if(ssd==(-1))
- {
- fprintf(stderr,"%s: Connecting to %s/%d failed\n",argv[0],server,outport);
- ***************
- *** 515,522 ****
- sdata.type=OUTSWAP(T_SIGNON);
- sdata.extra.signon.version=OUTSWAP(VERSION);
- sdata.extra.signon.port=OUTSWAP(inport); /* could be different to server port */
- ! gethostname(sdata.extra.signon.hostname,HOSTLEN);
- sprintf(sdata.extra.signon.username,"ROBOT%04d",inport);
-
- signal(SIGALRM,timeout);
- alarm(3);
- --- 514,529 ----
- sdata.type=OUTSWAP(T_SIGNON);
- sdata.extra.signon.version=OUTSWAP(VERSION);
- sdata.extra.signon.port=OUTSWAP(inport); /* could be different to server port */
- !
- ! gethostname(sdata.extra.signon.hostname,FULLHOSTLEN-1);
- ! sdata.extra.signon.hostname[FULLHOSTLEN-1]='\0';
- sprintf(sdata.extra.signon.username,"ROBOT%04d",inport);
- +
- + if(getipaddr(sdata.extra.signon.hostname,&(sdata.extra.signon.ip)))
- + {
- + fprintf(stderr,"%s: Couldn't get my own IP address\n",progname);
- + exit(1);
- + }
-
- signal(SIGALRM,timeout);
- alarm(3);
- diff -c -w ./oldxtb/xtb.6 ./newxtb/xtb.6
- *** ./oldxtb/xtb.6 Mon Dec 14 12:13:23 1992
- --- ./newxtb/xtb.6 Wed Dec 16 11:08:24 1992
- ***************
- *** 1,4 ****
- ! .TH XTB 6 "13 January 1991"
- .SH NAME
- xtb, xtbd \- X11 Tank battle program and server
- .SH SYNOPSIS
- --- 1,4 ----
- ! .TH XTB 6 "13 January 1992"
- .SH NAME
- xtb, xtbd \- X11 Tank battle program and server
- .SH SYNOPSIS
- diff -c -w ./oldxtb/xtb.c ./newxtb/xtb.c
- *** ./oldxtb/xtb.c Mon Dec 14 12:13:09 1992
- --- ./newxtb/xtb.c Wed Dec 16 16:16:50 1992
- ***************
- *** 1,7 ****
- /*
- * X Client
- *
- ! * $Header: /morpork/home/bmh/xtest2/RCS/xtb.c,v 1.41 92/10/19 15:34:32 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- --- 1,7 ----
- /*
- * X Client
- *
- ! * $Header: /morpork/home/bmh/xtest2/RCS/xtb.c,v 1.42 92/12/16 11:08:07 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- ***************
- *** 14,20 ****
- #include <sys/ioctl.h>
- #include <sys/time.h>
- #include <netinet/in.h>
- - #include <unistd.h>
- #include <fcntl.h>
- #include <signal.h>
- #include <ctype.h>
- --- 14,19 ----
- ***************
- *** 1115,1124 ****
- XSetForeground(Disp,GcB,bg);
- XSetBackground(Disp,GcB,fg);
-
- ! gcv.function = GXor;
- GcTF=XCreateGC(Disp,Win,(GCFunction | GCPlaneMask | GCFillStyle),&gcv);
-
- ! gcv.function = GXandInverted;
- GcTB=XCreateGC(Disp,Win,(GCFunction | GCPlaneMask | GCFillStyle),&gcv);
-
- XSetForeground(Disp,GcTF,fg);
- --- 1114,1123 ----
- XSetForeground(Disp,GcB,bg);
- XSetBackground(Disp,GcB,fg);
-
- ! gcv.function = fg > bg ? GXor : GXand;
- GcTF=XCreateGC(Disp,Win,(GCFunction | GCPlaneMask | GCFillStyle),&gcv);
-
- ! gcv.function = fg > bg ? GXandInverted : GXorInverted;
- GcTB=XCreateGC(Disp,Win,(GCFunction | GCPlaneMask | GCFillStyle),&gcv);
-
- XSetForeground(Disp,GcTF,fg);
- ***************
- *** 1258,1264 ****
- exit(1);
- }
-
- ! ssd=opensend(server,outport);
- if(ssd==(-1))
- {
- fprintf(stderr,"%s: Connecting to %s/%d failed\n",argv[0],server,outport);
- --- 1257,1263 ----
- exit(1);
- }
-
- ! ssd=opensend(server,outport,NULL);
- if(ssd==(-1))
- {
- fprintf(stderr,"%s: Connecting to %s/%d failed\n",argv[0],server,outport);
- ***************
- *** 1274,1283 ****
- sdata.type=OUTSWAP(T_SIGNON);
- sdata.extra.signon.version=OUTSWAP(VERSION);
- sdata.extra.signon.port=OUTSWAP(inport); /* could be different to server port */
- - gethostname(sdata.extra.signon.hostname,HOSTLEN);
- - strncpy(sdata.extra.signon.username,((struct passwd*)getpwuid(getuid()))->pw_name,NAMELEN-1);
- - sdata.extra.signon.username[NAMELEN]='\0';
-
- signal(SIGALRM,timeout);
- alarm(3);
- senddata(ssd,&sdata);
- --- 1273,1292 ----
- sdata.type=OUTSWAP(T_SIGNON);
- sdata.extra.signon.version=OUTSWAP(VERSION);
- sdata.extra.signon.port=OUTSWAP(inport); /* could be different to server port */
-
- + gethostname(sdata.extra.signon.hostname,FULLHOSTLEN-1);
- + sdata.extra.signon.hostname[FULLHOSTLEN-1]='\0';
- +
- + strncpy(sdata.extra.signon.username,((struct passwd*)getpwuid(getuid()))->pw_name,FULLNAMELEN-1);
- + sdata.extra.signon.username[FULLNAMELEN-1]='\0';
- +
- + if(getipaddr(sdata.extra.signon.hostname,&(sdata.extra.signon.ip)))
- + {
- + fprintf(stderr,"%s: Couldn't get my own IP address\n",progname);
- + exit(1);
- + }
- +
- +
- signal(SIGALRM,timeout);
- alarm(3);
- senddata(ssd,&sdata);
- ***************
- *** 1284,1290 ****
-
- if(readdata(rsd,&rdata)!=sizeof(DATA))
- {
- ! fprintf(stderr,"%s: Recieved bad data\n");
- exit(1);
- }
- alarm(0);
- --- 1293,1299 ----
-
- if(readdata(rsd,&rdata)!=sizeof(DATA))
- {
- ! fprintf(stderr,"%s: Recieved bad data\n",progname);
- exit(1);
- }
- alarm(0);
- diff -c -w ./oldxtb/xtbd.c ./newxtb/xtbd.c
- *** ./oldxtb/xtbd.c Mon Dec 14 12:13:24 1992
- --- ./newxtb/xtbd.c Wed Dec 16 11:08:14 1992
- ***************
- *** 1,7 ****
- /*
- * Server
- *
- ! * $Header: /morpork/home/bmh/xtest2/RCS/xtbd.c,v 1.28 92/10/19 15:34:36 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- --- 1,7 ----
- /*
- * Server
- *
- ! * $Header: /morpork/home/bmh/xtest2/RCS/xtbd.c,v 1.29 92/12/16 11:08:11 bmh Exp Locker: bmh $
- *
- * Bernard Hatt
- * Camtec Electronics (Ericsson), Leicester, England, LE1 4SA
- ***************
- *** 179,185 ****
- int srot,dist;
- int sx,sy;
- int dx,dy;
- ! int hflag=0,kflag=0,killed;
-
- newtime=gettime();
- if((newtime>(250+player[id].firetime))&&(player[id].damage<MAXDAMAGE))
- --- 179,185 ----
- int srot,dist;
- int sx,sy;
- int dx,dy;
- ! int hflag=0,kflag=0,killed=0;
-
- newtime=gettime();
- if((newtime>(250+player[id].firetime))&&(player[id].damage<MAXDAMAGE))
- ***************
- *** 239,244 ****
- --- 239,245 ----
- if(kflag&&(killed!=id))
- {
- player[id].damage=0;
- + sdata.extra.explosion.damage[id]=OUTSWAP(player[id].damage);
- player[id].kills++;
- }
-
- ***************
- *** 274,280 ****
- id=i;
- break;
- }
- ! ssd=opensend(rdata.extra.signon.hostname,INSWAP(rdata.extra.signon.port));
- if(ssd==(-1))
- {
- fprintf(stderr,"%s: Connecting to %s/%d failed\n",progname,rdata.extra.signon.hostname,INSWAP(rdata.extra.signon.port));
- --- 275,281 ----
- id=i;
- break;
- }
- ! ssd=opensend(rdata.extra.signon.hostname,INSWAP(rdata.extra.signon.port),&(rdata.extra.signon.ip));
- if(ssd==(-1))
- {
- fprintf(stderr,"%s: Connecting to %s/%d failed\n",progname,rdata.extra.signon.hostname,INSWAP(rdata.extra.signon.port));
- ***************
- *** 336,343 ****
- player[id].t=gettime();
- player[id].restime=gettime();
- player[id].damage=0;
- ! strcpy(player[id].user.username,rdata.extra.signon.username);
- ! strcpy(player[id].user.hostname,rdata.extra.signon.hostname);
- getscore(id);
- printf("Sent accept (id=%d)\n",id);
- sdata.extra.accept.id=OUTSWAP(id);
- --- 337,346 ----
- player[id].t=gettime();
- player[id].restime=gettime();
- player[id].damage=0;
- ! strncpy(player[id].user.username,rdata.extra.signon.username,HOSTLEN);
- ! player[id].user.username[NAMELEN-1]='\0';
- ! strncpy(player[id].user.hostname,rdata.extra.signon.hostname,NAMELEN);
- ! player[id].user.hostname[HOSTLEN-1]='\0';
- getscore(id);
- printf("Sent accept (id=%d)\n",id);
- sdata.extra.accept.id=OUTSWAP(id);
- ***************
- *** 552,557 ****
- --- 555,561 ----
- }
- moveplayers();
- sendplayers();
- + signal(SIGALRM,doalarm);
- myualarm(100000); /* reset 1/10th sec alarm */
- }
-
-
-