jojo@key.COM (Jonathan Wesener) (03/20/91)
Submitted-by: jojo@key.COM (Jonathan Wesener) Posting-number: Volume 12, Issue 49 Archive-name: stank/part02 Submitted by: jojo@largo Archive-name: stank/part 2 #!/bin/sh # this is stank.02 (part 2 of stank) # do not concatenate these parts, unpack them in order with /bin/sh # file stank/expl.c continued # touch 2>&1 | fgrep '[-amc]' > /tmp/s3_touch$$ if [ -s /tmp/s3_touch$$ ] then TOUCH=can else TOUCH=cannot fi rm -f /tmp/s3_touch$$ CurArch=2 if test ! -r s3_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s3_seq_.tmp || exit 1 echo "x - Continuing file stank/expl.c" sed 's/^X//' << 'SHAR_EOF' >> stank/expl.c X#define ESMALLSTART 4 X#define EXPLDELAY 30 X Xexplode(tp,ktp,dmg,x,y) X tank_t *tp; X tank_t *ktp; X int dmg; X{ X expl_t *ep; X int esize = ESMALL; X X X /* see if we're blowing up a tank */ X if( tp ) { X tp->t_damage -= dmg; X X if( tp->t_damage < 0 ) { X Totenergy += tp->t_energy; X esize = EBIG; X tp->t_dead++; X tank_reset(tp,EXPLDELAY); X field[tp->t_x][tp->t_y] = FSPACE; X fpts[tp->t_x][tp->t_y] = NULL; X place_bonus(tp,x,y); X place_tank(tp); X if( ktp ) X ktp->t_kills++; X } X } X X /* if we're out of explosions, just continue */ X if( !Efree ) X return; X X ep = Efree; X Efree = ep->e_next; X X ep->e_x = x; X ep->e_y = y; X ep->e_frm = (esize == ESMALL) ? ESMALLSTART : 0; X ep->e_size = esize; X ep->e_pri = EXPLPRI; X X ep->e_next = Evalid; X Evalid = ep; X} X X Xcheckexpls() X{ X expl_t *ep, *er, *en; X X X /* walk down the list */ X for( ep = Evalid ; ep ; ep = er ) { X X er = ep->e_next; X X if( ++(ep->e_pri) < EXPLPRI ) X continue; X X ep->e_pri = 0; X X X Servstate |= SSCUDFRC; X X if( ++(ep->e_frm) < EXPCNT ) X continue; X X /* remove the explosion */ X if( Evalid == ep ) X Evalid = ep->e_next; X else { X for( en = Evalid ; en->e_next != ep ; en = en->e_next ); X en->e_next = ep->e_next; X } X X /* add to free list */ X ep->e_next = Efree; X Efree = ep; X } X} X X/* Lint Output X*/ SHAR_EOF echo "File stank/expl.c is complete" chmod 0400 stank/expl.c || echo "restore of stank/expl.c fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/expl.c fi set `wc -c stank/expl.c`;Wc_c=$1 if test "$Wc_c" != "2020" then echo original size 2020, current size $Wc_c;fi # ============= stank/heat.c ============== echo "x - extracting stank/heat.c (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/heat.c && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)heat.c 1.7 :/usr/key/jojow/X/src/guts/SCCS/s.heat.c 3/19/91 10:15:51 " X X/* heat.c - routines for handling heat seekers */ X X#include "server.h" X X X#define HEATRANGE 10 X Xcheckheats() X{ X register heat_t *hp; X heat_t *hr; X X for( hp = Hvalid ; hp ; hp = hr ) { X X hr = hp->h_next; X X /* is it time to move the shell */ X if( ++(hp->h_pri) < HEATPRI ) X continue; X X hp->h_pri = 0; X X moveheat(hp); X Servstate |= SSCUDFRC; X } X} X X Xstatic int xmv[] = {0,1,0,-1}; Xstatic int ymv[] = {-1,0,1,0}; X Xmoveheat(hp) X register heat_t *hp; X{ X int nx, ny; X int dead = 0; X tank_t *tp; X X X nx = hp->h_x + xmv[hp->h_dir]; X ny = hp->h_y + ymv[hp->h_dir]; X X /* aged missile */ X if( ++(hp->h_life) >= HEATLIFE ) X dead = 1; X /* hit a wall? */ X else if( field[nx][ny] == FWALL ) { X X /* randomly change direction */ X if( rand() & 0x2) X hp->h_dir++; X else X hp->h_dir += 3; X X hp->h_dir %= MAXDIR; X nx = hp->h_x; X ny = hp->h_y; X } X /* hit a tank? */ X else if( field[nx][ny] == FTANK ) { X X tp = (tank_t *)fpts[nx][ny]; X if( !TANKSAFE(tp) ) { X dead = 1; X X explode(tp,hp->h_own,Heatdmg,nx,ny); X } X } X /* change direction for other reasons? */ X else { X int d = HEATRANGE, nd, dx, dy, dxs, dys; X tank_t *ts = NULL; X X X for( tp = Tvalid ; tp ; tp = tp->t_next ) { X /* can we seek this tank? */ X if( (hp->h_own == tp) || TANKHID(tp) ) X continue; X X /* find the distance */ X nd = abs( dx = (tp->t_x - nx) ) + abs( dy = (tp->t_y - ny) ); X if( nd >= d ) X continue; X X d = nd; X ts = tp; X dxs = dx; X dys = dy; X } X X if( ts ) { X int xdir, ydir, odir; X X xdir = ( dxs > 0 ) ? 1 : 3; X ydir = ( dys > 0 ) ? 2 : 0; X X odir = hp->h_dir; X X if( !dxs ) X hp->h_dir = ydir; X else if( !dys ) X hp->h_dir = xdir; X else if( (xdir != odir) && (ydir != odir) ) X hp->h_dir = (abs(dxs) > abs(dys))? ydir: xdir; X X#if NOTDEF X /* see if changing the direction dead ends the missile */ X if( field[nx+xmv[hp->h_dir]][ny+ymv[hp->h_dir]] == FWALL ) X hp->h_dir = odir; X#endif /* NOTDEF */ X } X } X X if( !dead ) { X hp->h_x = nx; X hp->h_y = ny; X } X /* shell gone? */ X else { X heat_t *hr; X X X hp->h_own->t_heatf--; X X /* kill it */ X if( Hvalid == hp ) X Hvalid = hp->h_next; X else { X for( hr = Hvalid ; hr->h_next != hp ; hr = hr->h_next ); X hr->h_next = hp->h_next; X } X X hp->h_next = Hfree; X Hfree = hp; X } X} X X Xfire_heat(tp) X register tank_t *tp; X{ X heat_t *hp; X X X /* any shells to fire? */ X if( tp->t_energy < Heatcost ) X return; X X tp->t_energy -= Heatcost; X Totenergy += Heatcost; X X hp = Hfree; X Hfree = hp->h_next; X X tp->t_heatf++; X X hp->h_x = tp->t_x; X hp->h_y = tp->t_y; X hp->h_dir = tp->t_dir; X hp->h_pri = 0; X hp->h_life = 0; X hp->h_own = tp; X X hp->h_next = Hvalid; X Hvalid = hp; X} X X Xrm_heats(tp) X tank_t *tp; X{ X heat_t *hp, *hr, *hn; X X /* remove all the mines belonging to tp */ X for( hp = Hvalid ; hp ; hp = hn ) { X X hn = hp->h_next; X X if( hp->h_own != tp ) X continue; X X /* kill it */ X if( Hvalid == hp ) X Hvalid = hp->h_next; X else { X for( hr = Hvalid ; hr->h_next != hp ; hr = hr->h_next ); X hr->h_next = hp->h_next; X } X X hp->h_next = Hfree; X Hfree = hp; X } X} X X Xheatdest() X{ X register heat_t *hp, *hr; X X X /* Walk down the list and remove them */ X for( hr = hp = Hvalid ; hp ; hp = hp->h_next ) { X hr = hp; X X hp->h_own->t_heatf--; X } X X if( Hvalid ) { X hr->h_next = Hfree; X Hfree = Hvalid; X Hvalid = NULL; X } X} X X X/* Lint Output X*/ SHAR_EOF chmod 0400 stank/heat.c || echo "restore of stank/heat.c fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/heat.c fi set `wc -c stank/heat.c`;Wc_c=$1 if test "$Wc_c" != "3931" then echo original size 3931, current size $Wc_c;fi # ============= stank/mine.c ============== echo "x - extracting stank/mine.c (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/mine.c && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)mine.c 1.7 :/usr/key/jojow/X/src/guts/SCCS/s.mine.c 3/19/91 10:15:55 " X X/* mine.c - routines for handling mines */ X X#include "server.h" X X Xmineblow(tp,mp,nx,ny) X tank_t *tp; X mine_t *mp; X int nx, ny; X{ X mine_t *mr; X tank_t *to; X X X /* remove the mine */ X to = mp->m_own; X to->t_minef--; X X /* kill it */ X if( Mvalid == mp ) X Mvalid = mp->m_next; X else { X for( mr = Mvalid ; mr->m_next != mp ; mr = mr->m_next ); X mr->m_next = mp->m_next; X } X X field[nx][ny] = FSPACE; X fpts[nx][ny] = (void *)NULL; X X mp->m_next = Mfree; X Mfree = mp; X X explode(tp,mp->m_own,(tp && TANKSAFE(tp))?0:Minedmg,nx,ny); X} X X Xarm_mine(tp) X register tank_t *tp; X{ X /* can we afford it? */ X if( (tp->t_energy < Minecost) || (tp->t_state & TMINE) ) X return; X X tp->t_energy -= Minecost; X Totenergy += Minecost; X X tp->t_state |= TMINE; X X tp->t_minef++; X Servstate |= SSCUDFRC; X} X X Xdrop_mine(tp,x,y) X register tank_t *tp; X int x,y; X{ X mine_t *mp; X X X tp->t_state &= ~TMINE; X X mp = Mfree; X Mfree = mp->m_next; X X mp->m_x = x; X mp->m_y = y; X mp->m_own = tp; X field[x][y] = FMINE; X fpts[x][y] = (void *)mp; X X mp->m_next = Mvalid; X Mvalid = mp; X X Servstate |= SSCUDFRC; X} X X Xrm_mines(tp) X tank_t *tp; X{ X mine_t *mp, *mr, *mn; X int nx, ny; X X X /* remove all the mines belonging to tp */ X for( mp = Mvalid ; mp ; mp = mn ) { X X mn = mp->m_next; X X if( mp->m_own != tp ) X continue; X X /* kill it */ X if( Mvalid == mp ) X Mvalid = mp->m_next; X else { X for( mr = Mvalid ; mr->m_next != mp ; mr = mr->m_next ); X mr->m_next = mp->m_next; X } X X mp->m_next = Mfree; X Mfree = mp; X X /* remove the mine from the field */ X nx = mp->m_x; X ny = mp->m_y; X field[nx][ny] = FSPACE; X fpts[nx][ny] = (void *)NULL; X } X} X X Xminedest() X{ X register mine_t *mp, *mr; X X X /* Walk down the list and remove them */ X for( mp = Mvalid ; mp ; mp = mr ) { X mr = mp->m_next; X X mineblow((tank_t *)NULL,mp,mp->m_x,mp->m_y); X } X} X X/* Lint Output X*/ SHAR_EOF chmod 0400 stank/mine.c || echo "restore of stank/mine.c fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/mine.c fi set `wc -c stank/mine.c`;Wc_c=$1 if test "$Wc_c" != "2441" then echo original size 2441, current size $Wc_c;fi # ============= stank/pow.c ============== echo "x - extracting stank/pow.c (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/pow.c && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)pow.c 1.6 :/usr/key/jojow/X/src/guts/SCCS/s.pow.c 3/19/91 10:15:59 " X X/* pow.c - routines for handling power pellets */ X X#include "server.h" X X#define ENERGYSTORM 200 X Xpowblow(tp,pp,x,y) X tank_t *tp; X pow_t *pp; X int x, y; X{ X if( tp->t_energy < Tmaxenergy ) X tp->t_energy += pp->p_val; X else X Totenergy += pp->p_val; X X /* remove it from the list */ X if( Pvalid == pp ) X Pvalid = pp->p_next; X else { X pow_t *pr; X X for( pr = Pvalid ; pr->p_next != pp ; pr = pr->p_next ); X pr->p_next = pp->p_next; X } X X pp->p_next = Pfree; X Pfree = pp; X X field[x][y] = FSPACE; X fpts[x][y] = NULL; X} X X X#define VALCNT 10 Xstatic int powposvals[VALCNT] = {1,10,10,10,20,20,50,50,75,100}; X Xcheckpows() X{ X pow_t *pp; X int x, y, pv; X X X if( Totenergy < ENERGYSTORM ) X return; X X while( Totenergy >= 0 ) { X if( !(pp = Pfree) ) X break; X X Pfree = pp->p_next; X X do { X x = random() % MAZE_XL; X y = random() % MAZE_YL; X } while( field[x][y] != FSPACE ); X X field[x][y] = FPOW; X fpts[x][y] = (void *)pp; X pp->p_x = x; X pp->p_y = y; X pv = random() % VALCNT; X pp->p_val = powposvals[pv]; X Totenergy -= powposvals[pv]; X X pp->p_next = Pvalid; X Pvalid = pp; X } X} X Xpowdest(tp) X tank_t *tp; X{ X register pow_t *pp, *pr = NULL; X X X /* Walk down the list and remove them */ X for( pr = pp = Pvalid ; pp ; pp = pp->p_next ) { X pr = pp; X tp->t_energy += pp->p_val; X field[pp->p_x][pp->p_y] = FSPACE; X fpts[pp->p_x][pp->p_y] = NULL; X } X X /* move the entire list */ X if( Pvalid ) { X pr->p_next = Pfree; X Pfree = Pvalid; X Pvalid = NULL; X } X} X X/* Lint Output X*/ SHAR_EOF chmod 0400 stank/pow.c || echo "restore of stank/pow.c fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/pow.c fi set `wc -c stank/pow.c`;Wc_c=$1 if test "$Wc_c" != "2094" then echo original size 2094, current size $Wc_c;fi # ============= stank/server.c ============== echo "x - extracting stank/server.c (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/server.c && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)server.c 1.25 :/usr/key/jojow/X/src/guts/SCCS/s.server.c 3/19/91 10:16:03 " X X/* server.c - tank server */ X X X#include <stdio.h> X#include <rpc/rpc.h> X#include <sys/time.h> X#include <strings.h> X X#define SERVER 1 X X#include "server.h" X#include "tankmsg.h" X X#define MASK 0x40 X Xstruct timeval ctv, ntv; X Xint Playercnt = 0; X Xchar maze[MAZE_XL*MAZE_YL + 1]; X X/* Initialize and array and pass it in to initstate. */ Xstatic long state1[32] = { 3, 0x9a319039, X 0x32d9c024, 0x9b663182, 0x5da1f342, 0x7449e56b, X 0xbeb1dbb0, 0xab5c5918, 0x946554fd, 0x8c2e680f, X 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 0xda672e2a, X 0x1588ca88, 0xe369735d, 0x904f35f7, 0xd7158fd6, X 0x6fa6f051, 0x616e6b96, 0xac94efdc, 0xde3b81e0, X 0xdf0a6fb5, 0xf103bc02, 0x48f340fb, 0x36413f93, X 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, X 0x8999220b, 0x27fb47b9 }; X Xchar *initstate(), *setstate(); X X Xserverinit() X{ X unsigned seed = 1; X int n = 128; X int i; X extern char *Mazefnm; X X X /* load the maze */ X if( load_field(Mazefnm) ) { X (void)fprintf(stderr,"serverinit: unable to load maze\n"); X exit( 1 ); X } X X Totenergy = 0; X Svalid = Sfree = NULL; X Mvalid = Mfree = NULL; X Hvalid = Hfree = NULL; X Evalid = Efree = NULL; X Tvalid = Tfree = NULL; X Pvalid = Pfree = NULL; X Bvalid = Bfree = NULL; X X /* set up tanks */ X for( i = 0 ; i < MAXTANK ; i++ ) { X tanks[i].t_id = i; X tanks[i].t_msg = tanks[i].t_msgb; X tanks[i].t_next = Tfree; X Tfree = &tanks[i]; X } X X /* set up shells */ X for( i = 0 ; i < MAXSHELL ; i++ ) { X shells[i].s_next = Sfree; X Sfree = &shells[i]; X } X X /* set up mines */ X for( i = 0 ; i < MAXMINE ; i++ ) { X mines[i].m_next = Mfree; X Mfree = &mines[i]; X } X X /* set up heats */ X for( i = 0 ; i < MAXHEAT ; i++ ) { X heats[i].h_next = Hfree; X Hfree = &heats[i]; X } X X /* set up expls */ X for( i = 0 ; i < MAXEXPL ; i++ ) { X expls[i].e_next = Efree; X Efree = &expls[i]; X } X X /* set up pows */ X for( i = 0 ; i < MAXPOW ; i++ ) { X pows[i].p_next = Pfree; X Pfree = &pows[i]; X } X X /* set up bonus's */ X for( i = 0 ; i < MAXBON ; i++ ) { X bons[i].b_next = Bfree; X Bfree = &bons[i]; X } X X Servstate = 0; X X (void)gettimeofday(&ctv,(struct timezone *)NULL); X nextupdtime(); X X /* I am having greivous problems with this fucking random X * number generator... */ X (void)initstate(seed, (char *)state1, n); X (void)setstate((char *)state1); X (void)srandom((int)ctv.tv_sec & 0xf); X} X X X/* to enter, pass in username */ Xchar ** Xtenter_1(msg) X char **msg; X{ X tank_t *tp; X static char *failres; X X X /* first ever initialization */ X if( !Playercnt ) X serverinit(); X X /* see if we can fit player into the game */ X if( !Tfree ) { X failres = "iF"; X return &failres; X } X X /* set up the new player */ X tp = Tfree; X Tfree = tp->t_next; X X tp->t_state = TVALID; X tp->t_kills = tp->t_dead = 0; X tp->t_dir = 0; X tp->t_cmd = 0; X tp->t_shellf = tp->t_minef = tp->t_heatf = 0; X tp->t_hbmiss = tp->t_hbxs = 0; X (void)strncpy(tp->t_name,*msg,MAXNM); X X place_tank(tp); X tank_reset(tp,0); X X /* send back the id */ X (void)sprintf(tp->t_msgb,"i%c",tp->t_id+'0'); X X (void)fprintf(stdout,"%s entering game with id = %d\n",*msg,tp->t_id); X (void)fflush(stdout); X X /* link it into the game */ X tp->t_next = Tvalid; X Tvalid = tp; X X Servstate |= SSCUDFRC | SSTUDFRC; X X Playercnt++; X X Totenergy += Energypt + Tenergy + Tenergy; X X return &tp->t_msg; X} X X X/* ARGSUSED */ Xint * Xgetplyrcnt_1(dum) X void *dum; X{ X return &Playercnt; X} X X Xchar ** Xtexit_1(msg) X char **msg; X{ X int id; X char *mp = *msg; X tank_t *tp, *tr; X X id = mp[1] - '0'; X X if( (id >= MAXTANK) || !(tanks[id].t_state & TVALID) ) { X static char *fail = "Messed up!"; X X (void)printf("texit_1: invalid id %d\n",id); X return &fail; X } X X tp = &tanks[id]; X X (void)fprintf(stdout,"%s leaving game\n",tp->t_name); X (void)fflush(stdout); X X explode(tp,(tank_t *)NULL,tp->t_damage + 1,tp->t_x,tp->t_y); X X tp->t_state = 0; X X /* remove from the valid queue */ X if( tp == Tvalid ) X Tvalid = tp->t_next; X else { X for( tr = Tvalid ; tr->t_next != tp ; tr = tr->t_next ); X tr->t_next = tp->t_next; X } X X tp->t_next = Tfree; X Tfree = tp; X X field[tp->t_x][tp->t_y] = FSPACE; X fpts[tp->t_x][tp->t_y] = NULL; X X (void)sprintf(tp->t_msgb,"%s: died %d, kills %d\n", X tp->t_name,tp->t_dead - 1, tp->t_kills); X X Servstate |= SSCUDFRC | SSTUDFRC; X X Playercnt--; X X Totenergy -= (Energypt + Tenergy); X X /* remove players resources */ X tank_cleanup(tp); X X return &tp->t_msg; X} X X X/* ARGSUSED */ Xchar ** Xgetmaze_1(msg) X int **msg; X{ X static char *mazep = maze; X X return &mazep; X} X X Xchar ** Xgetpos_1(msg) X char **msg; X{ X int id = 0; X char *mp = *msg; X tank_t *tp; X X /* find out who we are talking to */ X id = mp[1] - '0'; X X#if DEBUG X if( (id >= MAXTANK) || !(tanks[id].t_state & TVALID) ) { X static char *failres; X X (void)printf("getpos_1: invalid id %d\n",id); X failres = "T"; X return &failres; X } X#endif /* DEBUG */ X X tp = &tanks[id]; X X /* save away their move */ X if( mp[2] ) X tp->t_cmd = mp[2]; X X tp->t_state |= THRTBEAT; X X /* time to update the screen? */ X if( timecheck() ) X recompute_screen(); X X if( Servstate & SSCUDFRC ) { X update_screen(); X Servstate &= ~SSCUDFRC; X } X X /* send back screen info */ X if( tp->t_state & TSCUD ) X tp->t_state &= ~TSCUD; X else X tp->t_msgb[0] = '\0'; X X return &tp->t_msg; X} X X Xnextupdtime() X{ X /* add TIMESTEP to ctv */ X ntv.tv_usec = ctv.tv_usec + TIMESTEP; X X ntv.tv_sec = ctv.tv_sec; X X if( ntv.tv_usec > 1000000L ) { X ntv.tv_usec -= 1000000L; X ntv.tv_sec++; X } X} X X Xtimecheck() X{ X (void)gettimeofday(&ctv,(struct timezone *)NULL); X X if( ((ctv.tv_sec == ntv.tv_sec) && ctv.tv_usec > ntv.tv_usec) || X (ctv.tv_sec > ntv.tv_sec) ) { X nextupdtime(); X return 1; X } X X return 0; X} X X Xrecompute_screen() X{ X checktanks(); X checkshells(); X checkheats(); X checkpows(); X checkexpls(); X checkbons(); X} X X Xupdate_screen() X{ X register char *cp; X register tank_t *tp; X register shell_t *sp; X register mine_t *mp; X register heat_t *hp; X register expl_t *ep; X register pow_t *pp; X bon_t *bp; X char pbuf[MAXBUF]; X int i = 0; X static int status = 0; X X X cp = pbuf; X X /* draw tanks and explosions */ X for( tp = Tvalid ; tp ; tp = tp->t_next ) { X X /* clear the current screen message */ X tp->t_msgb[0] = '\0'; X X if( tp->t_state & (TEXP | TCLOAK) ) X continue; X X if( !(tp->t_state & TSAFE) || (tp->t_pri & 2) ) { X X *cp++ = 't'; X *cp++ = tp->t_x | CSAFE; X *cp++ = tp->t_y | CSAFE; X *cp++ = (tp->t_id & 3) | CSAFE; X *cp++ = tp->t_dir | CSAFE; X } X } X X /* draw shells */ X for( sp = Svalid ; sp ; sp = sp->s_next ) { X *cp++ = 's'; X *cp++ = sp->s_x | CSAFE; X *cp++ = sp->s_y | CSAFE; X *cp++ = '-'; X *cp++ = sp->s_dir | CSAFE; X } X X /* draw heats */ X for( hp = Hvalid ; hp ; hp = hp->h_next ) { X *cp++ = 'h'; X *cp++ = hp->h_x | CSAFE; X *cp++ = hp->h_y | CSAFE; X *cp++ = '-'; X *cp++ = hp->h_dir | CSAFE; X } X X /* draw bonus's */ X for( bp = Bvalid ; bp ; bp = bp->b_next ) { X *cp++ = 'b'; X *cp++ = bp->b_x | CSAFE; X *cp++ = bp->b_y | CSAFE; X *cp++ = '-'; X *cp++ = ((Bonfrm)?1:0) | CSAFE; X } X X /* draw expls */ X for( ep = Evalid ; ep ; ep = ep->e_next ) { X *cp++ = 'e'; X *cp++ = ep->e_x | CSAFE; X *cp++ = ep->e_y | CSAFE; X *cp++ = '-'; X *cp++ = ep->e_frm | CSAFE; X } X X /* draw power pellets */ X for( pp = Pvalid ; pp ; pp = pp->p_next ) { X *cp++ = 'p'; X *cp++ = pp->p_x | CSAFE; X *cp++ = pp->p_y | CSAFE; X *cp++ = '-'; X *cp++ = pp->p_val | CSAFE; X } X X /* display status of tanks */ X *cp = '\0'; X X if( status++ > STATUPD ) { X *cp++ = 'S'; X *cp = '\0'; X for( tp = Tvalid ; tp ; tp = tp->t_next ) { X i = strlen(pbuf); X (void)sprintf(&pbuf[i],"%c%s#",tp->t_id | CSAFE,tp->t_name); X i = strlen(pbuf); X (void)sprintf(&pbuf[i],"killed %d died %d#",tp->t_kills,tp->t_dead); X } X (void)strcat(pbuf,"$"); X status = 0; X } X X if( strlen(pbuf) > MAXBUF ) { X (void)fprintf(stderr,"pbuf overrun\n"); X exit( 1 ); X } X X /* draw players cloaked tanked and their energy */ X for( tp = Tvalid ; tp ; tp = tp->t_next ) { X cp = tp->t_msgb; X if( (tp->t_state & TCLOAK) && (tp->t_pri & 1) ) { X *cp++ = 't'; X *cp++ = tp->t_x | CSAFE; X *cp++ = tp->t_y | CSAFE; X *cp++ = (tp->t_id & 3) | CSAFE; X *cp++ = tp->t_dir | CSAFE; X } X (void)sprintf(cp,"EEnergy %d Dmg %d #",tp->t_energy,tp->t_damage); X } X X X /* draw players own mines on the field */ X for( mp = Mvalid ; mp ; mp = mp->m_next ) { X tp = mp->m_own; X i = strlen(tp->t_msgb); X cp = &tp->t_msgb[i]; X *cp++ = 'm'; X *cp++ = mp->m_x | CSAFE; X *cp++ = mp->m_y | CSAFE; X *cp++ = '-'; X *cp++ = '-'; X *cp = '\0'; X } X X /* set up individual tank buffers */ X for( tp = Tvalid ; tp ; tp = tp->t_next ) { X (void)strcat(tp->t_msgb,pbuf); X if( !(tp->t_msgb[0]) ) X (void)strcpy(tp->t_msgb,"FORCE"); X tp->t_state |= TSCUD; X } X} X X Xload_field(mazenm) X char *mazenm; X{ X int x, y, off; X char buf[128]; X FILE *fp; X X X /* read maze */ X if( !(fp = fopen(mazenm,"r")) ) { X (void)printf("init_field: unable to open maze\n"); X return 1; X } X X off = 0; X for( y = 0 ; y < MAZE_YL ; y++ ) { X X if( !fgets(buf,128,fp) ) { X (void)printf("init_field: short maze file\n"); X return 1; X } X X if( strlen(buf) != (MAZE_XL + 1) ) { X (void)printf("init_field: invalid maze item\n"); X return 1; X } X X for( x = 0 ; x < MAZE_XL ; x++ ) { X if( buf[x] == '#' ) { X field[x][y] = FWALL; X maze[off] = 'w'; X } X else { X field[x][y] = FSPACE; X maze[off] = ' '; X } X X /* clear the field ptrs */ X fpts[x][y] = NULL; X X off++; X } X X } X (void)fclose(fp); X maze[off] = '\0'; X X return 0; X} X X Xload_profile(profnm) X char *profnm; X{ X FILE *fp; X char pstr[64]; X int pvar, vcnt, ln = 1; X X X /* read profile */ X if( !(fp = fopen(profnm,"r")) ) { X (void)printf("init_field: unable to open maze\n"); X return 1; X } X X while( (vcnt = fscanf(fp,"%s %d\n",pstr,&pvar)) != EOF ) { X if( vcnt != 2 ) { X (void)fprintf(stderr,"load_profile: line %d invalid\n",ln); X continue; X } X X /* slowly walk through the list and assign values */ X if( !strcmp(pstr,"CLOAKCOST") ) X Cloakcost = pvar; X else if( !strcmp(pstr,"SHELLCOST") ) X Shellcost = pvar; X else if( !strcmp(pstr,"MINECOST") ) X Minecost = pvar; X else if( !strcmp(pstr,"HEATCOST") ) X Heatcost = pvar; X else if( !strcmp(pstr,"SHELLDMG") ) X Shelldmg = pvar; X else if( !strcmp(pstr,"MINEDMG") ) X Minedmg = pvar; X else if( !strcmp(pstr,"HEATDMG") ) X Heatdmg = pvar; X else if( !strcmp(pstr,"TANKENERGY") ) X Tenergy = pvar; X else if( !strcmp(pstr,"ENERGYPERTANK") ) X Energypt = pvar; X else if( !strcmp(pstr,"TANKDAMAGE") ) X Tdamage = pvar; X else if( !strcmp(pstr,"TANKMAXENERGY") ) X Tmaxenergy = pvar; X else if( !strcmp(pstr,"DMGREGENPRI") ) X Regenpri = pvar; X else if( !strcmp(pstr,"DMGREGENAMT") ) X Regenamt = pvar; X else X (void)fprintf(stderr,"load_profile: line %d invalid\n",ln); X X ln++; X } X X (void)fclose(fp); X return 0; X} X X/* Lint Output X*/ SHAR_EOF chmod 0400 stank/server.c || echo "restore of stank/server.c fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/server.c fi set `wc -c stank/server.c`;Wc_c=$1 if test "$Wc_c" != "11344" then echo original size 11344, current size $Wc_c;fi # ============= stank/server.h ============== echo "x - extracting stank/server.h (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/server.h && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)server.h 1.20 :/usr/key/jojow/X/src/guts/SCCS/s.server.h 3/19/91 10:16:09 " X X/* server.h - server specific includes */ X#include "tank.h" X X X/* DEFS */ X X/* screen object speeds */ X#define TANKPRI 4 X#define HEATPRI 3 X#define SHELLPRI 1 X#define EXPLPRI 4 X#define MINEPRI 2 X#define BONUSPRI 3 X#define STATUPD 40 X X#define MAXNM 40 X#define MAXBUF 512 X X#define MAXSHELLF 4 X#define MAXSHELL (MAXSHELLF * MAXTANK) X X#define MAXMINEF 10 X#define MAXMINE (MAXMINEF * MAXTANK) X X#define MAXHEATF 3 X#define MAXHEAT (MAXHEATF * MAXTANK) X X#define MAXEXPL 130 X#define MAXHBMISS 100 X#define MAXPOW 30 X#define HEATLIFE 20 X#define MAXBON 5 X X#define CSAFE 0x40 X X#define TSAFECNT 60 X X X/* field items */ X#define FWALL '#' X#define FSPACE ' ' X#define FTANK 'T' X#define FMINE 'M' X#define FPOW 'P' X#define FBON 'B' X X X/* server state flags */ X#define SSCUDFRC 0x2 X#define SSTUDFRC 0x4 X X#define TIMESTEP 40000L X Xstruct bon { X char b_x; X char b_y; /* position */ X struct bon *b_next; /* chain */ X}; Xtypedef struct bon bon_t; X Xstruct pow { X char p_x; X char p_y; /* position */ X char p_val; /* amount of energy */ X struct pow *p_next; /* chain */ X}; Xtypedef struct pow pow_t; X Xstruct expl { X char e_x; X char e_y; /* position */ X char e_pri; /* priority */ X char e_frm; /* expl frame */ X char e_size; /* size of explosion */ X struct expl *e_next; /* chain */ X}; Xtypedef struct expl expl_t; X Xstruct mine { X char m_x; X char m_y; /* position */ X char m_id; /* mine id */ X struct mine *m_next; /* chain */ X struct tank *m_own; /* owner (leash?) */ X}; Xtypedef struct mine mine_t; X Xstruct heat { X char h_x; X char h_y; /* position */ X char h_dir; /* direction shell is moving */ X char h_pri; /* shell speed/priority */ X char h_life; /* max distance */ X struct heat *h_next; /* chain */ X struct tank *h_own; /* owner (leash?) */ X}; Xtypedef struct heat heat_t; X Xstruct shell { X char s_x; X char s_y; /* position */ X char s_dir; /* direction shell is moving */ X char s_pri; /* shell speed/priority */ X struct shell *s_next; /* chain */ X struct tank *s_own; /* owner (leash?) */ X}; Xtypedef struct shell shell_t; X Xstruct tank { X int t_state; /* tank state */ X#define TSCUD 0x1 X#define THRTBEAT 0x2 X#define TVALID 0x4 X#define TEXP 0x8 X#define TSAFE 0x10 X#define TCLOAK 0x40 X#define TMINE 0x100 X int t_kills; /* Number of kills */ X int t_dead; /* Number of times killed */ X int t_wait; /* time to wait for explosion */ X int t_energy; /* players energy count */ X int t_damage; /* allowable damage */ X char t_id; /* id number */ X char t_x; X char t_y; /* position */ X char t_dir; /* direction tank is facing */ X char t_cmd; /* players requested command */ X char t_shellf; /* number of shells fired */ X char t_minef; /* number of mines fired */ X char t_heatf; /* number of heats fired */ X char t_safe; /* period of time tank is safe */ X char t_pri; /* tank speed/priority */ X char t_regpri; /* damage regen priority */ X char t_hbmiss; /* Number of missed heart beats */ X char t_hbxs; /* Number of heart beats/period */ X char t_name[MAXNM]; /* players name and host */ X char t_msgb[MAXBUF]; /* reply message buffer */ X char *t_msg; /* pointer to reply message */ X struct tank *t_next; /* chain */ X}; Xtypedef struct tank tank_t; X X#define TANKSAFE(tp) ((tp)->t_state & (TSAFE|TEXP)) X#define TANKHID(tp) ((tp)->t_state & (TSAFE|TEXP|TCLOAK)) X X X#if SERVER X X/* EXTERNALS */ Xtank_t tanks[MAXTANK]; Xheat_t heats[MAXHEAT]; Xshell_t shells[MAXSHELL]; Xmine_t mines[MAXMINE]; Xexpl_t expls[MAXEXPL]; Xpow_t pows[MAXPOW]; Xbon_t bons[MAXBON]; Xtank_t *Tfree, *Tvalid; Xshell_t *Svalid, *Sfree; Xmine_t *Mvalid, *Mfree; Xheat_t *Hvalid, *Hfree; Xexpl_t *Evalid, *Efree; Xpow_t *Pvalid, *Pfree; Xbon_t *Bvalid, *Bfree; Xchar field[MAZE_XL][MAZE_YL]; Xvoid *fpts[MAZE_XL][MAZE_YL]; Xint Servstate; Xint Totenergy; Xint Bonfrm = 0; X Xint Cloakcost = 3; Xint Shellcost = 1; Xint Shelldmg = 10; Xint Minecost = 5; Xint Minedmg = 20; Xint Heatcost = 15; Xint Heatdmg = 10; Xint Tenergy = 100; Xint Energypt = 300; Xint Tdamage = 100; Xint Tmaxenergy = 300; Xint Regenpri = 80; Xint Regenamt = 3; X X#else X Xextern tank_t tanks[MAXTANK]; Xextern heat_t heats[MAXHEAT]; Xextern shell_t shells[MAXSHELL]; Xextern mine_t mines[MAXMINE]; Xextern expl_t expls[MAXEXPL]; Xextern pow_t pows[MAXPOW]; Xextern bon_t bons[MAXBON]; Xextern tank_t *Tfree, *Tvalid; Xextern shell_t *Svalid, *Sfree; Xextern mine_t *Mvalid, *Mfree; Xextern heat_t *Hvalid, *Hfree; Xextern expl_t *Evalid, *Efree; Xextern pow_t *Pvalid, *Pfree; Xextern bon_t *Bvalid, *Bfree; Xextern char field[MAZE_XL][MAZE_YL]; Xextern void *fpts[MAZE_XL][MAZE_YL]; Xextern int Servstate; Xextern int Totenergy; Xextern int Bonfrm; X Xextern int Cloakcost; Xextern int Shellcost; Xextern int Shelldmg; Xextern int Minecost; Xextern int Minedmg; Xextern int Heatcost; Xextern int Heatdmg; Xextern int Tenergy; Xextern int Energypt; Xextern int Tdamage; Xextern int Tmaxenergy; Xextern int Regenpri; Xextern int Regenamt; X X#endif /* SERVER */ X X#ifndef NULL X#define NULL 0 X#endif /* NULL */ X Xextern char *sprintf(); Xextern long random(); SHAR_EOF chmod 0400 stank/server.h || echo "restore of stank/server.h fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/server.h fi set `wc -c stank/server.h`;Wc_c=$1 if test "$Wc_c" != "5643" then echo original size 5643, current size $Wc_c;fi # ============= stank/shell.c ============== echo "x - extracting stank/shell.c (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/shell.c && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)shell.c 1.6 :/usr/key/jojow/X/src/guts/SCCS/s.shell.c 3/19/91 10:16:16 " X X/* shell.c - routines for handling shells */ X X#include "server.h" X X Xcheckshells() X{ X register shell_t *sp; X shell_t *sr; X X for( sp = Svalid ; sp ; sp = sr ) { X X sr = sp->s_next; X X /* is it time to move the shell */ X if( ++(sp->s_pri) < SHELLPRI ) X continue; X X sp->s_pri = 0; X X moveshell(sp); X Servstate |= SSCUDFRC; X } X} X X Xstatic int xmv[] = {0,1,0,-1}; Xstatic int ymv[] = {-1,0,1,0}; X Xmoveshell(sp) X register shell_t *sp; X{ X int nx, ny; X int dead = 0; X tank_t *tp; X X X nx = sp->s_x + xmv[sp->s_dir]; X ny = sp->s_y + ymv[sp->s_dir]; X X /* check new position */ X if( field[nx][ny] == FWALL ) X dead = 1; X else if( field[nx][ny] == FTANK ) { X X tp = (tank_t *)fpts[nx][ny]; X if( !TANKSAFE(tp) ) { X dead = 1; X explode(tp,sp->s_own,Shelldmg,nx,ny); X } X } X X if( !dead ) { X sp->s_x = nx; X sp->s_y = ny; X } X /* shell gone? */ X else { X shell_t *sr; X X X /* remove from active list */ X if( Svalid == sp ) X Svalid = sp->s_next; X else { X for( sr = Svalid ; sr->s_next != sp ; sr = sr->s_next ); X sr->s_next = sp->s_next; X } X X /* put it back on the free list */ X sp->s_next = Sfree; X sp->s_own->t_shellf--; X Sfree = sp; X } X} X X Xfire_shell(tp) X register tank_t *tp; X{ X shell_t *sp; X X X /* any shells to fire? */ X if( tp->t_energy < Shellcost ) X return; X X tp->t_energy -= Shellcost; X Totenergy += Shellcost; X tp->t_shellf++; X X sp = Sfree; X Sfree = sp->s_next; X X sp->s_x = tp->t_x; X sp->s_y = tp->t_y; X sp->s_dir = tp->t_dir; X sp->s_pri = 0; X sp->s_own = tp; X X sp->s_next = Svalid; X Svalid = sp; X} X X Xrm_shells(tp) X tank_t *tp; X{ X shell_t *sp, *sr, *sn; X X /* remove all the mines belonging to tp */ X for( sp = Svalid ; sp ; sp = sn ) { X X sn = sp->s_next; X X if( sp->s_own != tp ) X continue; X X /* kill it */ X if( Svalid == sp ) X Svalid = sp->s_next; X else { X for( sr = Svalid ; sr->s_next != sp ; sr = sr->s_next ); X sr->s_next = sp->s_next; X } X X sp->s_next = Sfree; X Sfree = sp; X } X} X X Xshelldest() X{ X register shell_t *sp, *sr; X X X /* Walk down the list and remove them */ X for( sr = sp = Svalid ; sp ; sp = sp->s_next ) { X sr = sp; X X sp->s_own->t_shellf--; X } X X if( Svalid ) { X sr->s_next = Sfree; X Sfree = Svalid; X Svalid = NULL; X } X} X X/* Lint Output X*/ SHAR_EOF chmod 0400 stank/shell.c || echo "restore of stank/shell.c fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/shell.c fi set `wc -c stank/shell.c`;Wc_c=$1 if test "$Wc_c" != "2813" then echo original size 2813, current size $Wc_c;fi # ============= stank/tank.c ============== echo "x - extracting stank/tank.c (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/tank.c && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)tank.c 1.11 :/usr/key/jojow/X/src/guts/SCCS/s.tank.c 3/19/91 10:16:20 " X X/* tank.c - routines for handling tanks */ X X#include "server.h" X X Xchecktanks() X{ X register tank_t *tp, *tr; X X for( tp = Tvalid ; tp ; tp = tr ) { X X tr = tp->t_next; X X /* wait to enter */ X if( (tp->t_state & TEXP) ) { X if( --(tp->t_wait) ) X continue; X tp->t_state &= ~TEXP; X } X X /* check for dropped players */ X if( tp->t_state & THRTBEAT ) X tp->t_hbmiss = 0; X X else if( ++(tp->t_hbmiss) > MAXHBMISS ){ X (void)printf("recompute: dropping player %s\n",tp->t_name); X (void)sprintf(tp->t_msgb,"i%c",tp->t_id+'0'); X (void)texit_1(&tp->t_msg); X continue; X } X X tp->t_state &= ~THRTBEAT; X X /* turn off safety period */ X if( tp->t_state & (TSAFE | TCLOAK) ) { X Servstate |= SSCUDFRC; X if( !(--(tp->t_safe)) ) X tp->t_state &= ~TSAFE; X } X X /* regenerate damage */ X if( ++(tp->t_regpri) >= Regenpri ) { X if( (tp->t_damage < Tdamage) && X (tp->t_damage += Regenamt) > Tdamage ) X tp->t_damage = Tdamage; X tp->t_regpri = 0; X } X X /* is it time to move the tank */ X if( ++(tp->t_pri) < TANKPRI ) X continue; X X tp->t_pri = 0; X X if( movetank(tp) ) X Servstate |= SSCUDFRC; X } X} X X Xmovetank(tp) X register tank_t *tp; X{ X int nx, ny, cmd; X int ox, oy; X X X /* time to cloak? */ X if( tp->t_state & TCLOAK ) { X if( tp->t_energy > Cloakcost ) { X tp->t_energy -= Cloakcost; X Totenergy += Cloakcost; X } X else X tp->t_state &= ~TCLOAK; X Servstate |= SSCUDFRC; X } X X ox = nx = tp->t_x; X oy = ny = tp->t_y; X X cmd = tp->t_cmd; X tp->t_cmd = 0; X switch (cmd) { X case 'h': X if( tp->t_dir != 3) { X tp->t_dir = 3; X return 1; X } X nx--; X break; X case 'j': X if( tp->t_dir != 2) { X tp->t_dir = 2; X return 1; X } X ny++; X break; X case 'k': X if( tp->t_dir != 0) { X tp->t_dir = 0; X return 1; X } X ny--; X break; X case 'l': X if( tp->t_dir != 1) { X tp->t_dir = 1; X return 1; X } X nx++; X break; X case 'f': X case ' ': X tp->t_state &= ~TCLOAK; X if( !TANKSAFE(tp) && (tp->t_shellf < MAXSHELLF) ) X fire_shell(tp); X return 0; X case 'd': X if( !TANKSAFE(tp) && (tp->t_minef < MAXMINEF) ) X arm_mine(tp); X return 0; X case 's': X tp->t_state &= ~TCLOAK; X if( !TANKSAFE(tp) && (tp->t_heatf < MAXHEATF) ) X fire_heat(tp); X return 0; X case 'c': X if( !(tp->t_state & TSAFE) ) X cloak_mode(tp); X return 0; X case 0 : X return 0; X default: X (void)printf("invalid command %c - %d\n",cmd,cmd); X return 0; X } X X /* check out the new position */ X switch( (int)field[nx][ny] ) { X Xnowspace: X /* no problem! */ X case FSPACE: X if( !(tp->t_state & TEXP) ) { X field[nx][ny] = FTANK; X fpts[nx][ny] = (void *)tp; X tp->t_x = nx; X tp->t_y = ny; X } X field[ox][oy] = FSPACE; X fpts[ox][oy] = NULL; X X X if( tp->t_state & TMINE ) X drop_mine(tp,ox,oy); X X return 1; X X /* toe poppers */ X case FMINE: X mineblow(tp,(mine_t *)fpts[nx][ny],nx,ny); X goto nowspace; X X /* power pellet */ X case FPOW: X powblow(tp,(pow_t *)fpts[nx][ny],nx,ny); X goto nowspace; X X case FBON: X bonblow(tp,(bon_t *)fpts[nx][ny],nx,ny); X goto nowspace; X X /* Don't move */ X default: X return 0; X } X} X X Xplace_tank(tp) X tank_t *tp; X{ X int x, y; X X do { X x = random() % MAZE_XL; X y = random() % MAZE_YL; X } while( field[x][y] != FSPACE ); X X tp->t_x = x; X tp->t_y = y; X field[x][y] = FTANK; X fpts[x][y] = (void *)tp; X} X X Xcloak_mode(tp) X tank_t *tp; X{ X /* turn it on or off? */ X if( tp->t_state & TCLOAK) { X tp->t_state &= ~TCLOAK; X return; X } X X /* enough energy for the drain? */ X if( tp->t_energy < Cloakcost ) X return; X X tp->t_energy -= Cloakcost; X Totenergy += Cloakcost; X tp->t_state |= TCLOAK; X X Servstate |= SSCUDFRC; X} X Xtank_reset(tp,delay) X tank_t *tp; X int delay; X{ X if( tp->t_state & TMINE ) X tp->t_minef--; X X tp->t_state = TVALID | TSAFE; X X if( delay ) { X tp->t_state |= TEXP; X tp->t_wait = delay; X } X X tp->t_safe = TSAFECNT; X tp->t_pri = 0; X X tp->t_energy = Tenergy; X tp->t_damage = Tdamage; X Totenergy -= Tenergy; X} X X Xtank_cleanup(tp) X tank_t *tp; X{ X /* remove mines */ X rm_mines(tp); X X /* remove shells */ X rm_shells(tp); X X /* remove heats */ X rm_heats(tp); X} X X Xtankdest(tp) X tank_t *tp; X{ X register tank_t *tr; X X for( tr = Tvalid ; tr ; tr = tr->t_next ) { X if( tr != tp ) X explode(tr,tp,tr->t_damage+1,tr->t_x,tr->t_y); X } X} X X/* Lint Output X*/ SHAR_EOF chmod 0400 stank/tank.c || echo "restore of stank/tank.c fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/tank.c fi set `wc -c stank/tank.c`;Wc_c=$1 if test "$Wc_c" != "4881" then echo original size 4881, current size $Wc_c;fi # ============= stank/tank.h ============== echo "x - extracting stank/tank.h (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/tank.h && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)tank.h 1.10 :/usr/key/jojow/X/src/guts/SCCS/s.tank.h 3/19/91 10:16:24 " X X/* tank.h - common defs for server and client */ X X#define TANK_LEN 16 X/* #define WIN_LEN 32 */ X#define MAZE_XL 32 X#define MAZE_YL 32 X#define STAT_XL 150 X#define WIN_XL (MAZE_XL * TANK_LEN + STAT_XL) X#define WIN_YL (MAZE_YL * TANK_LEN) X#define EXPCNT 7 X#define BONCNT 2 X#define MAXDIR 4 X#define MAXTANK 8 X#define MAXWALL 16 X#define MAXSTRLEN 40 X#define MAXMINEANIM 2 X#define MAXSTAT (MAXTANK * 2) SHAR_EOF chmod 0400 stank/tank.h || echo "restore of stank/tank.h fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/tank.h fi set `wc -c stank/tank.h`;Wc_c=$1 if test "$Wc_c" != "1029" then echo original size 1029, current size $Wc_c;fi # ============= stank/tankmsg.h ============== echo "x - extracting stank/tankmsg.h (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/tankmsg.h && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)tankmsg.h 1.1 :/usr/key/jojow/X/src/guts/SCCS/s.tankmsg.h 3/19/91 10:14:43 " X X#define MESSAGEPROG ((u_long)0x20000002) X#define MESSAGEVERS ((u_long)1) X#define TENTER ((u_long)1) Xextern char **tenter_1(); X#define GETPOS ((u_long)2) Xextern char **getpos_1(); X#define GETMAZE ((u_long)3) Xextern char **getmaze_1(); X#define TEXIT ((u_long)4) Xextern char **texit_1(); X#define GETPLYRCNT ((u_long)5) Xextern int *getplyrcnt_1(); X SHAR_EOF chmod 0400 stank/tankmsg.h || echo "restore of stank/tankmsg.h fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/tankmsg.h fi set `wc -c stank/tankmsg.h`;Wc_c=$1 if test "$Wc_c" != "973" then echo original size 973, current size $Wc_c;fi # ============= stank/tankmsg.x ============== echo "x - extracting stank/tankmsg.x (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/tankmsg.x && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)tankmsg.x 1.7 :/usr/key/jojow/X/src/guts/SCCS/s.tankmsg.x 3/19/91 10:16:29 " X X/* msg.x: remote message printing protocol */ X Xprogram MESSAGEPROG { X version MESSAGEVERS { X string TENTER(string) = 1; X string GETPOS(string) = 2; X string GETMAZE(int) = 3; X string TEXIT(string) = 4; X int GETPLYRCNT(void) = 5; X } = 1; X} = 0x20000002; SHAR_EOF chmod 0400 stank/tankmsg.x || echo "restore of stank/tankmsg.x fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/tankmsg.x fi set `wc -c stank/tankmsg.x`;Wc_c=$1 if test "$Wc_c" != "885" then echo original size 885, current size $Wc_c;fi # ============= stank/tankmsg_clnt.c ============== echo "x - extracting stank/tankmsg_clnt.c (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/tankmsg_clnt.c && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)tankmsg_clnt.c 1.2 :/usr/key/jojow/X/src/guts/SCCS/s.tankmsg_clnt.c 3/19/91 10:16:32 " X X#include <rpc/rpc.h> X#include <sys/time.h> X#include "tankmsg.h" X X/* Default timeout can be changed using clnt_control() */ Xstatic struct timeval TIMEOUT = { 25, 0 }; X Xchar ** Xtenter_1(argp, clnt) X char **argp; X CLIENT *clnt; X{ X static char *res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, TENTER, xdr_wrapstring, argp, xdr_wrapstring, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return (&res); X} X X Xchar ** Xgetpos_1(argp, clnt) X char **argp; X CLIENT *clnt; X{ X static char *res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, GETPOS, xdr_wrapstring, argp, xdr_wrapstring, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return (&res); X} X X Xchar ** Xgetmaze_1(argp, clnt) X int *argp; X CLIENT *clnt; X{ X static char *res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, GETMAZE, xdr_int, argp, xdr_wrapstring, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return (&res); X} X X Xchar ** Xtexit_1(argp, clnt) X char **argp; X CLIENT *clnt; X{ X static char *res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, TEXIT, xdr_wrapstring, argp, xdr_wrapstring, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return (&res); X} X X Xint * Xgetplyrcnt_1(argp, clnt) X void *argp; X CLIENT *clnt; X{ X static int res; X X bzero((char *)&res, sizeof(res)); X if (clnt_call(clnt, GETPLYRCNT, xdr_void, argp, xdr_int, &res, TIMEOUT) != RPC_SUCCESS) { X return (NULL); X } X return (&res); X} X SHAR_EOF chmod 0400 stank/tankmsg_clnt.c || echo "restore of stank/tankmsg_clnt.c fails" if [ $TOUCH = can ] then touch -am 0319105291 stank/tankmsg_clnt.c fi set `wc -c stank/tankmsg_clnt.c`;Wc_c=$1 if test "$Wc_c" != "2060" then echo original size 2060, current size $Wc_c;fi # ============= stank/tankmsg_svc.c ============== echo "x - extracting stank/tankmsg_svc.c (Text)" sed 's/^X//' << 'SHAR_EOF' > stank/tankmsg_svc.c && X X/* X * Copyright (c) 1991 Jon Wesener X * Gaming Software X * X * Permission to use, copy, modify, and distribute this X * software and its documentation for any purpose and without X * fee is hereby granted, provided that the above copyright X * notice appear in all copies and that both that copyright X * notice and this permission notice appear in supporting X * documentation. No representations are made about the X * suitability of this software for any purpose. It is X * provided "as is" without express or implied warranty. X * X */ X X#ident "@(#)tankmsg_svc.c 1.4 :/usr/key/jojow/X/src/guts/SCCS/s.tankmsg_svc.c 3/19/91 10:16:36 " X X#include <stdio.h> X#include <rpc/rpc.h> X#include "tankmsg.h" X Xstatic void messageprog_1(); Xchar *Mazefnm; X Xmain(ac,av) X int ac; X char *av[]; X{ X SVCXPRT *transp; X X /* usage line */ X if( ac < 2 ) { X (void)fprintf(stderr,"usage: %s maze [profile]\n",av[0]); X exit( 1 ); X } X X Mazefnm = av[1]; X X /* load the profile */ X if( (ac >= 3) && load_profile(av[2]) ) { X (void)fprintf(stderr,"%s: invalid profile\n",av[0]); X exit( 1 ); X } X X (void)pmap_unset(MESSAGEPROG, MESSAGEVERS); X X transp = svcudp_create(RPC_ANYSOCK); X if (transp == NULL) { X (void)fprintf(stderr, "cannot create udp service.\n"); X exit(1); X } X if (!svc_register(transp, MESSAGEPROG, MESSAGEVERS, messageprog_1, IPPROTO_UDP)) { X (void)fprintf(stderr, "unable to register (MESSAGEPROG, MESSAGEVERS, udp).\n"); X exit(1); X } X X transp = svctcp_create(RPC_ANYSOCK, 0, 0); X if (transp == NULL) { X (void)fprintf(stderr, "cannot create tcp service.\n"); X exit(1); X } X if (!svc_register(transp, MESSAGEPROG, MESSAGEVERS, messageprog_1, IPPROTO_TCP)) { X (void)fprintf(stderr, "unable to register (MESSAGEPROG, MESSAGEVERS, tcp).\n"); X exit(1); X } X svc_run(); X (void)fprintf(stderr, "svc_run returned\n"); X exit(1); X} X Xstatic void Xmessageprog_1(rqstp, transp) X struct svc_req *rqstp; X SVCXPRT *transp; X{ X union { X char *tenter_1_arg; X char *getpos_1_arg; X int getmaze_1_arg; X char *texit_1_arg; X } argument; X char *result; X bool_t (*xdr_argument)(), (*xdr_result)(); X char *(*local)(); X X switch (rqstp->rq_proc) { X case NULLPROC: X (void)svc_sendreply(transp, xdr_void, (char *)NULL); X return; X X case TENTER: X xdr_argument = xdr_wrapstring; X xdr_result = xdr_wrapstring; X local = (char *(*)()) tenter_1; X break; X X case GETPOS: X xdr_argument = xdr_wrapstring; X xdr_result = xdr_wrapstring; X local = (char *(*)()) getpos_1; X break; X X case GETMAZE: X xdr_argument = xdr_int; X xdr_result = xdr_wrapstring; X local = (char *(*)()) getmaze_1; X break; X X case TEXIT: X xdr_argument = xdr_wrapstring; X xdr_result = xdr_wrapstring; X local = (char *(*)()) texit_1; X break; X X case GETPLYRCNT: X xdr_argument = xdr_void; X xdr_result = xdr_int; X local = (char *(*)()) getplyrcnt_1; X break; X X default: X svcerr_noproc(transp); X return; X } X bzero((char *)&argument, sizeof(argument)); X if (!svc_getargs(transp, xdr_argument, &argument)) { X svcerr_decode(transp); X return; X } X result = (*local)(&argument, rqstp); X if (result != NULL && !svc_sendreply(transp, xdr_result, result)) { X svcerr_systemerr(transp); X } X if (!svc_freeargs(transp, xdr_argument, &argument)) { X (void)fprintf(stderr, "unable to free arguments\n"); SHAR_EOF echo "End of stank part 2" echo "File stank/tankmsg_svc.c is continued in part 3" echo "3" > s3_seq_.tmp exit 0 -- "The bear new nine songs; all of them on honey." jojo@key.com -- Dan Heller ------------------------------------------------ O'Reilly && Associates Z-Code Software Senior Writer President argv@ora.com argv@zipcode.com ------------------------------------------------ General Email: argv@sun.com Comp-sources-x stuff: comp-sources.x@uunet.uu.net