v12i048: stank, Part01/03
Jonathan Wesener
jojo at key.COM
Wed Mar 20 21:42:47 AEST 1991
Submitted-by: jojo at key.COM (Jonathan Wesener)
Posting-number: Volume 12, Issue 48
Archive-name: stank/part01
A Tank Game for X11
#!/bin/sh
# This is stank, a shell archive (shar 3.11)
# made 03/19/1991 23:48 UTC by jojow at roadkill
# Source directory /usr/key/jojow/X/src
#
# existing files WILL be overwritten
#
# This is part 1 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 4784 -r-------- stank/bif.c
# 848 -r-------- stank/bif.h
# 6486 -r-------- stank/bits.c
# 11731 -r-------- stank/bits.h
# 1984 -r-------- stank/bon.c
# 15342 -r-------- stank/client.c
# 1846 -r-------- stank/client.h
# 2020 -r-------- stank/expl.c
# 3931 -r-------- stank/heat.c
# 2441 -r-------- stank/mine.c
# 2094 -r-------- stank/pow.c
# 11344 -r-------- stank/server.c
# 5643 -r-------- stank/server.h
# 2813 -r-------- stank/shell.c
# 4881 -r-------- stank/tank.c
# 1029 -r-------- stank/tank.h
# 973 -r-------- stank/tankmsg.h
# 885 -r-------- stank/tankmsg.x
# 2060 -r-------- stank/tankmsg_clnt.c
# 3262 -r-------- stank/tankmsg_svc.c
# 1848 -r-------- stank/Imakefile
# 10658 -rw------- stank/Makefile
# 1056 -rw------- stank/mazes/maze.1
# 1056 -rw------- stank/mazes/maze.2
# 1056 -rw------- stank/mazes/maze.3
# 1056 -rw------- stank/mazes/maze.4
# 1056 -rw------- stank/mazes/maze.5
# 1056 -rw------- stank/mazes/maze.6
# 968 -rw------- stank/stankbif.6
# 2885 -rw------- stank/stank.6
# 1548 -rw------- stank/README
# 1371 -rw------- stank/stankserver.6
#
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$$
if test -r s3_seq_.tmp
then echo "Must unpack archives in sequence!"
next=`cat s3_seq_.tmp`; echo "Please unpack part $next next"
exit 1; fi
# ============= stank/bif.c ==============
if test ! -d 'stank' ; then
echo "x - creating directory stank"
mkdir 'stank'
fi
echo "x - extracting stank/bif.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > stank/bif.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 "@(#)bif.c 1.4 :/usr/key/jojow/X/src/guts/SCCS/s.bif.c 3/19/91 10:15:20 "
X
X/* bif.c - check and update number of players of tank */
X
X#include <stdio.h>
X#include <rpc/rpc.h>
X#include "tankmsg.h"
X
X#include <signal.h>
X#include <string.h>
X
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X
X#include "bif.h"
X
XCLIENT *cl;
Xchar *server;
Xchar msgbuf[256];
X
X#ifndef NULL
X#define NULL 0L
X#endif
X
X#define MASK 0x40
X
X#define SECOND 1000000L
X#define MINUTE (60 * SECOND)
X#define DELAYCNT (1 * MINUTE)
X
X
XDisplay *display;
XWindow root, window;
Xint screen, depth, black, white;
XGC copyGC;
XKeySym last_key;
Xint ascent, descent;
XFont font;
X
Xlong frame_delay = 30000L;
X
Xint plyrcnt = 0;
X
Xmain(ac, av)
X int ac;
X char *av[];
X
X{
X XEvent event;
X unsigned long event_mask;
X int dummy;
X XCharStruct chars;
X char *getenv();
X
X
X /* open the display */
X display = XOpenDisplay(NULL);
X screen = DefaultScreen(display);
X root = DefaultRootWindow(display);
X depth = DefaultDepth(display, screen);
X black = BlackPixel(display, screen);
X white = WhitePixel(display, screen);
X
X /* get a font */
X font = XLoadFont(display, "fixed");
X XQueryTextExtents(display, font, "000000", 6, &dummy,
X &ascent, &descent, &chars);
X
X create_GCs();
X create_cells();
X create_window(ac, av);
X
X server = getenv("STANKSERVER");
X
X /* the command line overrides the environment variable */
X if( ac == 2 )
X server = av[1];
X
X if( !server ) {
X (void)fprintf(stderr,"usage: %s host\n",av[0]);
X exit(1);
X }
X
X /* create client handle */
X
X cl = clnt_create(server,MESSAGEPROG,MESSAGEVERS,"tcp");
X if( cl == NULL ) {
X /* couldn't establish connection */
X clnt_pcreateerror(server);
X exit(1);
X }
X
X /* select the event mask for the window */
X event_mask = ExposureMask;
X XSelectInput(display, window, event_mask);
X
X /* display the window */
X XMapWindow(display, window);
X while (True) {
X XNextEvent(display, &event);
X if (event.xany.window != window)
X continue;
X if (event.type == Expose)
X break;
X }
X
X /* go to it */
X bif_away();
X
X /* exit */
X do_exit();
X}
X
X
X/*
X * The following function contains the main game loop.
X */
Xbif_away()
X{
X XEvent event;
X int new;
X
X
X draw_bif();
X
X for(;;) {
X
X /* find out the number of players */
X new = getplayercnt();
X
X while (QLength(display) > 0) {
X XNextEvent(display, &event);
X if (event.xany.window != window)
X continue;
X switch (event.type) {
X case Expose:
X draw_bif();
X break;
X default:
X break;
X }
X }
X
X if( new != plyrcnt ) {
X if( new > plyrcnt )
X XBell(display,0);
X plyrcnt = new;
X draw_bif();
X }
X
X /*-- Synchronization And Delay ------------------------------*/
X
X XSync(display, False);
X
X usleep((unsigned)DELAYCNT);
X }
X}
X
X
Xdo_exit()
X{
X XUnmapWindow(display, window);
X XFlush(display);
X XCloseDisplay(display);
X exit(1);
X}
X
Xcreate_window(ac, av)
X int ac;
X char *av[];
X
X{
X XSizeHints hints;
X XWMHints xwmh;
X char *name = "tankbif";
X
X window = XCreateSimpleWindow(display, root, 0, 0, BIF_WXSIZE,
X BIF_WYSIZE, 1, white, black);
X
X hints.flags = PSize | PMinSize | PMaxSize;
X hints.width = hints.min_width = hints.max_width = BIF_WXSIZE;
X hints.height = hints.min_height =
X hints.max_height = BIF_WYSIZE;
X
X XSetStandardProperties(display, window, name, name, NULL,
X av, ac, &hints);
X
X xwmh.input = False;
X xwmh.initial_state = NormalState;
X xwmh.flags = StateHint;
X XSetWMHints(display, window, &xwmh);
X}
X
X
Xcreate_GCs()
X{
X XGCValues gcv;
X unsigned long mask;
X
X mask = GCForeground | GCBackground | GCFunction |
X GCFont | GCGraphicsExposures;
X
X /* context for copying; used for animation */
X gcv.foreground = black;
X gcv.background = white;
X gcv.font = font;
X gcv.function = GXcopy;
X gcv.graphics_exposures = False;
X copyGC = XCreateGC(display, root, mask, &gcv);
X}
X
X
Xdraw_bif()
X{
X Pixmap pm;
X int i;
X
X
X for( i = 0 ; i < MAXBIF ; i++ ) {
X pm = ( i < plyrcnt ) ? tcells[i][0] : tcells[i][3];
X XCopyArea(display,pm,window,copyGC,0,0,TANK_LEN,TANK_LEN,
X i*TANK_LEN,0);
X }
X}
X
X
Xgetplayercnt()
X{
X int *result;
X static void *tmp;
X
X /* call remote procedure */
X result = getplyrcnt_1(&tmp,cl);
X
X if( result == NULL ) {
X /* an error occurred while calling the server */
X clnt_perror(cl,server);
X exit(1);
X }
X
X return *result;
X}
X
X/* Lint Output
X*/
SHAR_EOF
chmod 0400 stank/bif.c || echo "restore of stank/bif.c fails"
if [ $TOUCH = can ]
then
touch -am 0319105291 stank/bif.c
fi
set `wc -c stank/bif.c`;Wc_c=$1
if test "$Wc_c" != "4784"
then echo original size 4784, current size $Wc_c;fi
# ============= stank/bif.h ==============
echo "x - extracting stank/bif.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > stank/bif.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 "@(#)bif.h 1.2 :/usr/key/jojow/X/src/guts/SCCS/s.bif.h 3/19/91 10:15:24 "
X
X/* bif.h - bif specific includes */
X
X#include "tank.h"
X
X/* EXTERNALS */
Xextern Pixmap tcells[MAXTANK][MAXDIR];
X
X/* STRUCTURES */
X
X/* OTHER */
X
X#define MAXBIF 4
X#define BIF_WXSIZE (MAXBIF * TANK_LEN)
X#define BIF_WYSIZE TANK_LEN
SHAR_EOF
chmod 0400 stank/bif.h || echo "restore of stank/bif.h fails"
if [ $TOUCH = can ]
then
touch -am 0319105291 stank/bif.h
fi
set `wc -c stank/bif.h`;Wc_c=$1
if test "$Wc_c" != "848"
then echo original size 848, current size $Wc_c;fi
# ============= stank/bits.c ==============
echo "x - extracting stank/bits.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > stank/bits.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 "@(#)bits.c 1.13 :/usr/key/jojow/X/src/guts/SCCS/s.bits.c 3/19/91 10:15:27 "
X
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X
X#include "tank.h"
X#include "bits.h"
X
Xextern Window root;
Xextern Display *display;
Xextern int depth;
X
XPixmap tcells[MAXTANK][MAXDIR];
XPixmap scells[MAXDIR];
XPixmap hcells[MAXDIR];
XPixmap ecells[EXPCNT];
XPixmap mcell;
XPixmap pcell;
XPixmap wcells[MAXWALL];
XPixmap xcell;
XPixmap bcells[BONCNT];
X
Xcreate_cells()
X{
X int i;
X
X
X xcell = XCreatePixmapFromBitmapData(display, root, x0_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X mcell = XCreatePixmapFromBitmapData(display, root, m_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X pcell = XCreatePixmapFromBitmapData(display, root, p_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X i = 0;
X bcells[i++] = XCreatePixmapFromBitmapData(display, root, b0_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X bcells[i++] = XCreatePixmapFromBitmapData(display, root, b1_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X i = 0;
X hcells[i++] = XCreatePixmapFromBitmapData(display, root, hn_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X hcells[i++] = XCreatePixmapFromBitmapData(display, root, he_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X hcells[i++] = XCreatePixmapFromBitmapData(display, root, hs_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X hcells[i++] = XCreatePixmapFromBitmapData(display, root, hw_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X i = 0;
X scells[i++] = XCreatePixmapFromBitmapData(display, root, sn_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X scells[i++] = XCreatePixmapFromBitmapData(display, root, se_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X scells[i++] = XCreatePixmapFromBitmapData(display, root, ss_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X scells[i++] = XCreatePixmapFromBitmapData(display, root, sw_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X i = 0;
X tcells[0][i++] = XCreatePixmapFromBitmapData(display, root, t0n_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[0][i++] = XCreatePixmapFromBitmapData(display, root, t0e_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[0][i++] = XCreatePixmapFromBitmapData(display, root, t0s_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[0][i++] = XCreatePixmapFromBitmapData(display, root, t0w_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X i = 0;
X tcells[1][i++] = XCreatePixmapFromBitmapData(display, root, t1n_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[1][i++] = XCreatePixmapFromBitmapData(display, root, t1e_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[1][i++] = XCreatePixmapFromBitmapData(display, root, t1s_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[1][i++] = XCreatePixmapFromBitmapData(display, root, t1w_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X i = 0;
X tcells[2][i++] = XCreatePixmapFromBitmapData(display, root, t2n_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[2][i++] = XCreatePixmapFromBitmapData(display, root, t2e_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[2][i++] = XCreatePixmapFromBitmapData(display, root, t2s_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[2][i++] = XCreatePixmapFromBitmapData(display, root, t2w_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X i = 0;
X tcells[3][i++] = XCreatePixmapFromBitmapData(display, root, t3n_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[3][i++] = XCreatePixmapFromBitmapData(display, root, t3e_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[3][i++] = XCreatePixmapFromBitmapData(display, root, t3s_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X tcells[3][i++] = XCreatePixmapFromBitmapData(display, root, t3w_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X i = 0;
X ecells[i++] = XCreatePixmapFromBitmapData(display, root, e0_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X ecells[i++] = XCreatePixmapFromBitmapData(display, root, e1_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X ecells[i++] = XCreatePixmapFromBitmapData(display, root, e2_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X ecells[i++] = XCreatePixmapFromBitmapData(display, root, e3_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X ecells[i++] = XCreatePixmapFromBitmapData(display, root, e4_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X ecells[i++] = XCreatePixmapFromBitmapData(display, root, e5_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X ecells[i++] = XCreatePixmapFromBitmapData(display, root, e6_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X i = 0;
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w0_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w1_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w2_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w3_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w4_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w5_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w6_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w7_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w8_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w9_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w10_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w11_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w12_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w13_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w14_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X wcells[i++] = XCreatePixmapFromBitmapData(display, root, w15_bits,
X TANK_LEN, TANK_LEN, 0, 1, depth);
X}
X/* Lint Output
X*/
SHAR_EOF
chmod 0400 stank/bits.c || echo "restore of stank/bits.c fails"
if [ $TOUCH = can ]
then
touch -am 0319105291 stank/bits.c
fi
set `wc -c stank/bits.c`;Wc_c=$1
if test "$Wc_c" != "6486"
then echo original size 6486, current size $Wc_c;fi
# ============= stank/bits.h ==============
echo "x - extracting stank/bits.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > stank/bits.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 "@(#)bits.h 1.2 :/usr/key/jojow/X/src/guts/SCCS/s.bits.h 3/19/91 10:15:31 "
X
X/* bits.h - bitmaps of everything */
X
Xstatic char b0_bits[] = {
X 0x00, 0x00, 0x80, 0x01, 0xc1, 0x83, 0xc1, 0x83, 0xc2, 0x43, 0x82, 0x41,
X 0xfc, 0x3f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07,
X 0x30, 0x0c, 0x10, 0x08, 0x10, 0x08, 0x1c, 0x38};
Xstatic char b1_bits[] = {
X 0x00, 0x00, 0x80, 0x01, 0xd0, 0x0b, 0xd0, 0x0b, 0xc8, 0x13, 0x84, 0x21,
X 0xfc, 0x3f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07,
X 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x78, 0x1e};
Xstatic char e0_bits[] = {
X 0xe0, 0x07, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff,
X 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f,
X 0xfe, 0x7f, 0xfc, 0x3f, 0xf8, 0x1f, 0xe0, 0x07};
Xstatic char e1_bits[] = {
X 0x00, 0x00, 0x4c, 0x4e, 0x14, 0x00, 0xc1, 0x23, 0xf0, 0x0f, 0xf4, 0x0f,
X 0xf8, 0x1f, 0xfa, 0xdf, 0xf9, 0x1f, 0xf8, 0x5f, 0xf0, 0x0f, 0xf4, 0x2f,
X 0xc4, 0x03, 0x10, 0x10, 0x82, 0x4c, 0x18, 0x08};
Xstatic char e2_bits[] = {
X 0x00, 0x00, 0x42, 0x8e, 0x94, 0x01, 0x05, 0xa4, 0x50, 0x26, 0x54, 0x80,
X 0x80, 0x11, 0xc8, 0xc3, 0xc1, 0x03, 0x8c, 0x49, 0x58, 0x15, 0x22, 0x38,
X 0x44, 0x45, 0x10, 0x12, 0x03, 0x40, 0x68, 0x08};
Xstatic char e3_bits[] = {
X 0xc0, 0x02, 0x30, 0x12, 0x08, 0x07, 0x82, 0x5d, 0xa8, 0x17, 0xfe, 0x47,
X 0x62, 0x8f, 0xb2, 0x5d, 0xfe, 0x59, 0xe6, 0xd7, 0xf0, 0x7d, 0xe4, 0x2f,
X 0x85, 0x08, 0x9c, 0x11, 0xe2, 0x08, 0x00, 0x20};
Xstatic char e4_bits[] = {
X 0x82, 0x82, 0x21, 0x63, 0xf9, 0x4b, 0xb8, 0x1e, 0xdc, 0x1e, 0xfa, 0x3b,
X 0x5e, 0xbe, 0xfe, 0x5b, 0xfc, 0x7f, 0x5c, 0x4d, 0xdc, 0x5e, 0x3f, 0x7f,
X 0xfc, 0x4f, 0xf1, 0x13, 0x80, 0x50, 0x08, 0x01};
Xstatic char e5_bits[] = {
X 0x4a, 0x82, 0x0d, 0x62, 0xa9, 0x4b, 0x80, 0x0a, 0x51, 0x10, 0x1a, 0x00,
X 0x12, 0xb0, 0x08, 0x50, 0x0d, 0x70, 0x05, 0x40, 0x0c, 0x58, 0x1f, 0x78,
X 0x0c, 0x48, 0x65, 0x13, 0xb0, 0x4c, 0x08, 0x01};
Xstatic char e6_bits[] = {
X 0xc4, 0x80, 0x04, 0x2a, 0x02, 0x40, 0x11, 0x80, 0x00, 0x00, 0x03, 0x00,
X 0x00, 0x80, 0x82, 0x10, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x8a, 0x30,
X 0x03, 0x00, 0x01, 0x20, 0x94, 0x89, 0x06, 0x41};
Xstatic char he_bits[] = {
X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x06,0x00,0xfc,0x3f,0x5e,
X 0x7d,0x5e,0x7d,0xfc,0x3f,0x06,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
X 0x00,0x00};
Xstatic char hn_bits[] = {
X 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03,
X 0x40, 0x02, 0xc0, 0x03, 0x40, 0x02, 0xc0, 0x03, 0x40, 0x02, 0xc0, 0x03,
X 0xc0, 0x03, 0xe0, 0x07, 0xb0, 0x0d, 0x00, 0x00};
Xstatic char hs_bits[] = {
X 0x00,0x00,0xb0,0x0d,0xe0,0x07,0xc0,0x03,0xc0,0x03,0x40,0x02,0xc0,0x03,0x40,
X 0x02,0xc0,0x03,0x40,0x02,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x80,0x01,
X 0x00,0x00};
Xstatic char hw_bits[] = {
X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x60,0xfc,0x3f,0xbe,
X 0x7a,0xbe,0x7a,0xfc,0x3f,0x00,0x60,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
X 0x00,0x00};
Xstatic char m_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x11, 0x50, 0x0a, 0xa0, 0x05,
X 0x50, 0x0a, 0xa8, 0x15, 0xa8, 0x15, 0x50, 0x0a, 0xa0, 0x05, 0x50, 0x0a,
X 0x88, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Xstatic char p_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x21, 0x08, 0x10, 0x90, 0x03,
X 0xc0, 0x07, 0xe0, 0x0f, 0xec, 0x6f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03,
X 0x10, 0x10, 0x08, 0x21, 0x00, 0x01, 0x00, 0x00};
Xstatic char se_bits[] = {
X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8a,0x3f,0xfe,
X 0x7f,0xfe,0x7f,0x8a,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
X 0x00,0x00};
Xstatic char sn_bits[] = {
X 0x00,0x00,0x80,0x01,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,
X 0x03,0xc0,0x03,0x80,0x01,0x80,0x01,0x80,0x01,0xc0,0x03,0x80,0x01,0xc0,0x03,
X 0x00,0x00};
Xstatic char ss_bits[] = {
X 0x00,0x00,0xc0,0x03,0x80,0x01,0xc0,0x03,0x80,0x01,0x80,0x01,0x80,0x01,0xc0,
X 0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x80,0x01,
X 0x00,0x00};
Xstatic char sw_bits[] = {
X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x51,0xfe,
X 0x7f,0xfe,0x7f,0xfc,0x51,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
X 0x00,0x00};
Xstatic char t0e_bits[] = {
X 0x00,0x00,0x00,0x00,0xfe,0x0f,0xfe,0x0f,0xf8,0x01,0xfc,0x03,0xfe,0x07,0xfe,
X 0x7f,0xfe,0x7f,0xfe,0x07,0xfc,0x03,0xf8,0x01,0xfe,0x0f,0xfe,0x0f,0x00,0x00,
X 0x00,0x00};
Xstatic char t0n_bits[] = {
X 0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x8c,0x31,0xcc,0x33,0xec,0x37,0xfc,
X 0x3f,0xfc,0x3f,0xfc,0x3f,0xfc,0x3f,0xfc,0x3f,0xfc,0x3f,0xec,0x37,0xcc,0x33,
X 0x00,0x00};
Xstatic char t0s_bits[] = {
X 0x00,0x00,0xcc,0x33,0xec,0x37,0xfc,0x3f,0xfc,0x3f,0xfc,0x3f,0xfc,0x3f,0xfc,
X 0x3f,0xfc,0x3f,0xec,0x37,0xcc,0x33,0x8c,0x31,0x80,0x01,0x80,0x01,0x80,0x01,
X 0x00,0x00};
Xstatic char t0w_bits[] = {
X 0x00,0x00,0x00,0x00,0xf0,0x7f,0xf0,0x7f,0x80,0x1f,0xc0,0x3f,0xe0,0x7f,0xfe,
X 0x7f,0xfe,0x7f,0xe0,0x7f,0xc0,0x3f,0x80,0x1f,0xf0,0x7f,0xf0,0x7f,0x00,0x00,
X 0x00,0x00};
Xstatic char t1e_bits[] = {
X 0x00,0x00,0x00,0x00,0xfe,0x0f,0xfe,0x0f,0xf8,0x01,0xfc,0x03,0xfe,0x07,0x06,
X 0x7e,0x06,0x7e,0xfe,0x07,0xfc,0x03,0xf8,0x01,0xfe,0x0f,0xfe,0x0f,0x00,0x00,
X 0x00,0x00};
Xstatic char t1n_bits[] = {
X 0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x8c,0x31,0xcc,0x33,0xec,0x37,0x7c,
X 0x3e,0x7c,0x3e,0x7c,0x3e,0x7c,0x3e,0x7c,0x3e,0x7c,0x3e,0xec,0x37,0xcc,0x33,
X 0x00,0x00};
Xstatic char t1s_bits[] = {
X 0x00,0x00,0xcc,0x33,0xec,0x37,0x7c,0x3e,0x7c,0x3e,0x7c,0x3e,0x7c,0x3e,0x7c,
X 0x3e,0x7c,0x3e,0xec,0x37,0xcc,0x33,0x8c,0x31,0x80,0x01,0x80,0x01,0x80,0x01,
X 0x00,0x00};
Xstatic char t1w_bits[] = {
X 0x00,0x00,0x00,0x00,0xf0,0x7f,0xf0,0x7f,0x80,0x1f,0xc0,0x3f,0xe0,0x7f,0x7e,
X 0x60,0x7e,0x60,0xe0,0x7f,0xc0,0x3f,0x80,0x1f,0xf0,0x7f,0xf0,0x7f,0x00,0x00,
X 0x00,0x00};
Xstatic char t2e_bits[] = {
X 0x00,0x00,0x00,0x00,0xfe,0x0f,0xfe,0x0f,0xf8,0x01,0x9c,0x03,0x9e,0x07,0x9e,
X 0x7f,0x9e,0x7f,0x9e,0x07,0x9c,0x03,0xf8,0x01,0xfe,0x0f,0xfe,0x0f,0x00,0x00,
X 0x00,0x00};
Xstatic char t2n_bits[] = {
X 0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x8c,0x31,0xcc,0x33,0xec,0x37,0xfc,
X 0x3f,0xfc,0x3f,0x1c,0x38,0x1c,0x38,0xfc,0x3f,0xfc,0x3f,0xec,0x37,0xcc,0x33,
X 0x00,0x00};
Xstatic char t2s_bits[] = {
X 0x00,0x00,0xcc,0x33,0xec,0x37,0xfc,0x3f,0xfc,0x3f,0x1c,0x38,0x1c,0x38,0xfc,
X 0x3f,0xfc,0x3f,0xec,0x37,0xcc,0x33,0x8c,0x31,0x80,0x01,0x80,0x01,0x80,0x01,
X 0x00,0x00};
Xstatic char t2w_bits[] = {
X 0x00,0x00,0x00,0x00,0xf0,0x7f,0xf0,0x7f,0x80,0x1f,0xc0,0x39,0xe0,0x79,0xfe,
X 0x79,0xfe,0x79,0xe0,0x79,0xc0,0x39,0x80,0x1f,0xf0,0x7f,0xf0,0x7f,0x00,0x00,
X 0x00,0x00};
Xstatic char t3e_bits[] = {
X 0x00,0x00,0x00,0x00,0xfe,0x0f,0xfe,0x0f,0xf8,0x01,0xfc,0x03,0x0e,0x07,0x0e,
X 0x7f,0x0e,0x7f,0x0e,0x07,0xfc,0x03,0xf8,0x01,0xfe,0x0f,0xfe,0x0f,0x00,0x00,
X 0x00,0x00};
Xstatic char t3n_bits[] = {
X 0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x8c,0x31,0xcc,0x33,0xec,0x37,0xfc,
X 0x3f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xfc,0x3f,0xec,0x37,0xcc,0x33,
X 0x00,0x00};
Xstatic char t3s_bits[] = {
X 0x00,0x00,0xcc,0x33,0xec,0x37,0xfc,0x3f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,
X 0x3c,0xfc,0x3f,0xec,0x37,0xcc,0x33,0x8c,0x31,0x80,0x01,0x80,0x01,0x80,0x01,
X 0x00,0x00};
Xstatic char t3w_bits[] = {
X 0x00,0x00,0x00,0x00,0xf0,0x7f,0xf0,0x7f,0x80,0x1f,0xc0,0x3f,0xe0,0x70,0xfe,
X 0x70,0xfe,0x70,0xe0,0x70,0xc0,0x3f,0x80,0x1f,0xf0,0x7f,0xf0,0x7f,0x00,0x00,
X 0x00,0x00};
Xstatic char w0_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
X 0xc0, 0x03, 0x60, 0x06, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Xstatic char w1_bits[] = {
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
X 0xc0, 0x03, 0x60, 0x06, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Xstatic char w10_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
X 0xc0, 0x03, 0x7f, 0xfe, 0x7f, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Xstatic char w11_bits[] = {
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
X 0xc0, 0x03, 0x7f, 0xfe, 0x7f, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Xstatic char w12_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
X 0xc0, 0x03, 0x7f, 0x06, 0x7f, 0x06, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01};
Xstatic char w13_bits[] = {
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
X 0xc0, 0x03, 0x7f, 0x06, 0x7f, 0x06, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01};
Xstatic char w14_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
X 0xc0, 0x03, 0x7f, 0xfe, 0x7f, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01};
Xstatic char w15_bits[] = {
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
X 0xc0, 0x03, 0x7f, 0xfe, 0x7f, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01};
Xstatic char w2_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
X 0xc0, 0x03, 0x60, 0xfe, 0x60, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Xstatic char w3_bits[] = {
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
X 0xc0, 0x03, 0x60, 0xfe, 0x60, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Xstatic char w4_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
X 0xc0, 0x03, 0x60, 0x06, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01};
Xstatic char w5_bits[] = {
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
X 0xc0, 0x03, 0x60, 0x06, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01};
Xstatic char w6_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
X 0xc0, 0x03, 0x60, 0xfe, 0x60, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01};
Xstatic char w7_bits[] = {
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
X 0xc0, 0x03, 0x60, 0xfe, 0x60, 0xfe, 0xc0, 0x03, 0x80, 0x01, 0x80, 0x01,
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01};
Xstatic char w8_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
X 0xc0, 0x03, 0x7f, 0x06, 0x7f, 0x06, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Xstatic char w9_bits[] = {
X 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
X 0xc0, 0x03, 0x7f, 0x06, 0x7f, 0x06, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Xstatic char x0_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
SHAR_EOF
chmod 0400 stank/bits.h || echo "restore of stank/bits.h fails"
if [ $TOUCH = can ]
then
touch -am 0319105291 stank/bits.h
fi
set `wc -c stank/bits.h`;Wc_c=$1
if test "$Wc_c" != "11731"
then echo original size 11731, current size $Wc_c;fi
# ============= stank/bon.c ==============
echo "x - extracting stank/bon.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > stank/bon.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 "@(#)bon.c 1.1 :/usr/key/jojow/X/src/guts/SCCS/s.bon.c 3/19/91 10:14:41 "
X
X/* bon.c - support for bonus's */
X
X#include "server.h"
X
X#define BONTIME 9
X
Xplace_bonus(tp,nx,ny)
X tank_t *tp;
X{
X static int bontime = 0;
X bon_t *bp;
X
X if( ++bontime < BONTIME )
X return;
X
X /* if all expended, return */
X if( !(bp = Bfree) )
X return;
X
X bontime = 0;
X
X Bfree = bp->b_next;
X
X bp->b_x = nx;
X bp->b_y = ny;
X
X field[nx][ny] = FBON;
X fpts[nx][ny] = (void *)bp;
X
X bp->b_next = Bvalid;
X Bvalid = bp;
X}
X
X
Xbonblow(tp,bp,nx,ny)
X tank_t *tp;
X bon_t *bp;
X int nx, ny;
X{
X bon_t *br;
X
X
X /* remove the bonus */
X field[nx][ny] = FSPACE;
X fpts[nx][ny] = NULL;
X
X if( Bvalid == bp)
X Bvalid = bp->b_next;
X else {
X for( br = Bvalid ; br->b_next != bp ; br = br->b_next );
X br->b_next = bp->b_next;
X }
X
X bp->b_next = Bfree;
X Bfree = bp;
X
X /* figure out what the bonus is */
X
X switch( (int)(random() % 3) ) {
X
X /* raise energy */
X case 0: {
X int energy;
X
X
X energy = Tmaxenergy * 3;
X
X Totenergy -= energy;
X Totenergy += tp->t_energy;
X tp->t_energy = energy;
X
X break;
X }
X
X /* raise damage */
X case 1:
X tp->t_damage = Tdamage * 3;
X break;
X
X /* destruction */
X case 2: {
X tankdest(tp);
X powdest(tp);
X shelldest();
X heatdest();
X minedest();
X break;
X }
X }
X}
X
X
Xcheckbons()
X{
X static int bpri = 0;
X
X if( !Bvalid )
X return;
X
X if( ++bpri < BONUSPRI )
X return;
X
X bpri = 0;
X
X Bonfrm = !Bonfrm;
X Servstate |= SSCUDFRC;
X}
X
X/* Lint Output
X*/
SHAR_EOF
chmod 0400 stank/bon.c || echo "restore of stank/bon.c fails"
if [ $TOUCH = can ]
then
touch -am 0319105291 stank/bon.c
fi
set `wc -c stank/bon.c`;Wc_c=$1
if test "$Wc_c" != "1984"
then echo original size 1984, current size $Wc_c;fi
# ============= stank/client.c ==============
echo "x - extracting stank/client.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > stank/client.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 "@(#)client.c 1.19 :/usr/key/jojow/X/src/guts/SCCS/s.client.c 3/19/91 10:15:36 "
X
X/* client.c - tank client */
X
X#include <stdio.h>
X#include <rpc/rpc.h>
X#include "tankmsg.h"
X
X#include <signal.h>
X#include <string.h>
X
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <X11/keysym.h>
X
X#include "client.h"
X
XCLIENT *cl;
Xchar *server = NULL;
Xchar msgbuf[256];
X
X
XDisplay *display;
XWindow root, window;
Xint screen, depth, black, white;
XGC copyGC;
XKeySym last_key;
Xint ascent, descent;
XFont font;
X
Xlong frame_delay = 10000L;
X
Xlong lastact = 0;
X
Xblob_t blobs[MAZE_XL][MAZE_YL];
Xblob_t *Bvalid;
Xstat_t stats[MAXSTAT];
Xstat_t estat;
X
Xint plyrid;
Xchar *sprintf();
X
Xmain(ac, av)
X int ac;
X char *av[];
X
X{
X XEvent event;
X unsigned long event_mask;
X int dummy;
X XCharStruct chars;
X char *getenv();
X void ignoresig(), entrysig(), hup();
X
X
X /* open the display */
X display = XOpenDisplay(NULL);
X screen = DefaultScreen(display);
X root = DefaultRootWindow(display);
X depth = DefaultDepth(display, screen);
X black = BlackPixel(display, screen);
X white = WhitePixel(display, screen);
X
X /* get a font */
X font = XLoadFont(display, "fixed");
X XQueryTextExtents(display, font, "000000", 6, &dummy,
X &ascent, &descent, &chars);
X
X create_GCs();
X create_cells();
X create_window(ac, av);
X
X XSetBackground(display,copyGC,black);
X XSetForeground(display,copyGC,white);
X
X server = getenv("STANKSERVER");
X
X /* the command line overrides the environment variable */
X if( ac == 2 )
X server = av[1];
X
X if( !server ) {
X (void)fprintf(stderr,"usage: %s host\n",av[0]);
X exit(1);
X }
X
X /* catch various signals */
X ignoresig();
X
X /* create client handle */
X cl = clnt_create(server,MESSAGEPROG,MESSAGEVERS,"tcp");
X if( cl == NULL ) {
X /* couldn't establish connection */
X clnt_pcreateerror(server);
X exit(1);
X }
X
X if( enter_game() ) {
X (void)printf("game is full, try again later.\n");
X exit(1);
X }
X
X (void)sprintf(msgbuf,"i%c ",'0'+plyrid);
X
X /* select the event mask for the window */
X event_mask = ExposureMask | KeyPressMask;
X XSelectInput(display, window, event_mask);
X
X init_blobs();
X
X /* display the window */
X XMapWindow(display, window);
X while (True) {
X XNextEvent(display, &event);
X if (event.xany.window != window)
X continue;
X if (event.type == Expose)
X break;
X }
X
X /* go to it */
X sit_n_spin();
X
X exit_game();
X
X entrysig();
X
X /* exit */
X do_exit();
X}
X
X
Xint Done = 0;
X
X/*
X * The following function contains the main game loop.
X */
Xsit_n_spin()
X{
X char c_buf;
X XComposeStatus status;
X XEvent event;
X
X
X draw_screen();
X
X if( update_pos() )
X update_screen();
X
X XSync(display, False);
X
X while( !Done ) {
X while (QLength(display) > 0) {
X XNextEvent(display, &event);
X if (event.xany.window != window)
X continue;
X switch (event.type) {
X case KeyPress:
X lastact = 0;
X XLookupString(&event, &c_buf, 1, &last_key, &status);
X if (last_key == XK_q)
X Done = 1;
X break;
X case Expose:
X draw_screen();
X break;
X default:
X break;
X }
X }
X
X if( update_pos() )
X update_screen();
X
X /*-- Synchronization And Delay ------------------------------*/
X
X XSync(display, False);
X
X /* has the player been idle too long? */
X if( ++lastact > LASTACT) {
X (void)fprintf(stderr,"player dropped due to inactivity\n");
X Done = 1;
X }
X usleep((unsigned)frame_delay);
X }
X}
X
X
Xdo_exit()
X{
X XUnmapWindow(display, window);
X XFlush(display);
X XCloseDisplay(display);
X exit(1);
X}
X
Xcreate_window(ac, av)
X int ac;
X char *av[];
X
X{
X XSizeHints hints;
X XWMHints xwmh;
X char *name = "tank";
X
X window = XCreateSimpleWindow(display, root, 0, 0, WIN_XL,
X WIN_YL, 1, white, black);
X
X hints.flags = PSize | PMinSize | PMaxSize;
X hints.width = hints.min_width = hints.max_width = WIN_XL;
X hints.height = hints.min_height =
X hints.max_height = WIN_YL;
X
X XSetStandardProperties(display, window, name, name, NULL,
X av, ac, &hints);
X
X xwmh.input = True;
X xwmh.initial_state = NormalState;
X xwmh.flags = InputHint | StateHint;
X XSetWMHints(display, window, &xwmh);
X}
X
X
Xcreate_GCs()
X{
X XGCValues gcv;
X unsigned long mask;
X
X mask = GCForeground | GCBackground | GCFunction |
X GCFont | GCGraphicsExposures;
X
X /* context for copying; used for animation */
X gcv.foreground = black;
X gcv.background = white;
X gcv.font = font;
X gcv.function = GXcopy;
X gcv.graphics_exposures = False;
X copyGC = XCreateGC(display, root, mask, &gcv);
X}
X
Xupdate_pos()
X{
X char **result;
X char *move;
X char *scr, *dostats();
X
X switch ((int)last_key) {
X case XK_Left:
X case XK_h:
X msgbuf[2] = 'h';
X break;
X case XK_Down:
X case XK_j:
X msgbuf[2] = 'j';
X break;
X case XK_Up:
X case XK_k:
X msgbuf[2] = 'k';
X break;
X case XK_Right:
X case XK_l:
X msgbuf[2] = 'l';
X break;
X case XK_f:
X case XK_space:
X msgbuf[2] = 'f';
X break;
X case XK_c:
X msgbuf[2] = 'c';
X break;
X case XK_d:
X msgbuf[2] = 'd';
X break;
X case XK_s:
X msgbuf[2] = 's';
X break;
X default:
X msgbuf[2] = '\0';
X break;
X }
X
X last_key = 0;
X
X move = msgbuf;
X
X /* call remote procedure */
X result = getpos_1(&move,cl);
X
X if( result == NULL ) {
X /* an error occurred while calling the server */
X clnt_perror(cl,server);
X exit(1);
X }
X
X /* screen info? */
X scr = *result;
X if( ! (*scr) )
X return 0;
X
X /* check for a terminate message */
X if( *scr == 'T' ) {
X (void)printf("get_pos: Terminate\n");
X exit( -1 );
X }
X
X if( *scr == 'F' ) {
X#if DEBUG
X (void)printf("FORCE-----\n");
X#endif /* DEBUG */
X return 1;
X }
X
X /* Reset the screen map */
X
X#if DEBUG
X (void)printf("P---------\n");
X#endif /* DEBUG */
X while( *scr ) {
X int x, y, btype, id, dir;
X blob_t *bp;
X
X btype = *scr++;
X
X /* special stat processing */
X if( (btype == 'E') || (btype == 'S') ) {
X scr = dostats(btype,scr);
X continue;
X }
X
X x = *scr++ & 0x3f;
X y = *scr++ & 0x3f;
X id = *scr++ & 0x3f;
X dir = *scr++ & 0x3f;
X
X bp = &blobs[x][y];
X
X /* reset screen item */
X if( (bp->b_id != id) || (bp->b_dir != dir) || (bp->b_type != btype) ||
X !(bp->b_state & BVALID) ) {
X
X bp->b_type = btype;
X bp->b_id = id;
X bp->b_dir = dir;
X
X /* if not already valid, link it in */
X if( !(bp->b_state & BVALID) ) {
X if( bp->b_next = Bvalid )
X Bvalid->b_last = bp;
X bp->b_last = NULL;
X Bvalid = bp;
X }
X
X#if DEBUG
X (void)printf("R%c x= %d y = %d id = %d d = %d\n",bp->b_type,
X bp->b_x,bp->b_y,bp->b_id,bp->b_dir);
X#endif /* DEBUG */
X bp->b_state = BVALID | BDRAW;
X }
X else {
X#if DEBUG
X (void)printf("N%c x= %d y = %d id = %d d = %d\n",bp->b_type,
X bp->b_x,bp->b_y,bp->b_id,bp->b_dir);
X#endif /* DEBUG */
X bp->b_state = BVALID | BNODRAW;
X }
X }
X
X return 1;
X}
X
X
Xchar *
Xdostats(f,scr)
X char f;
X char *scr;
X{
X int cc, r, i;
X char btmp[MAXSTRLEN], *bp;
X
X
X /* energy stat */
X if( f == 'E' ) {
X for( bp = btmp, cc = 0 ; *scr != '#' ; cc++, scr++ )
X if( cc < MAXSTRLEN )
X *bp++ = *scr;
X
X if( cc < MAXSTRLEN )
X *bp = '\0';
X else
X btmp[MAXSTRLEN] = '\0';
X
X if( strcmp(btmp, estat.st_str) ) {
X (void)strcpy(estat.st_str,btmp);
X estat.st_state = BVALID | BDRAW;
X }
X else
X estat.st_state = BVALID | BNODRAW;
X
X scr++;
X return scr;
X }
X
X for( r = 0 ; r < MAXSTAT ; r++ )
X if( stats[r].st_state & BVALID )
X stats[r].st_state = BVALID | BERASE;
X /* player stats */
X while( *scr != '$') {
X
X r = (*scr++ & 0x3f) * 2;
X
X for( i = 0 ; i < 2 ; i++, r++ ) {
X for( bp = btmp, cc = 0 ; *scr != '#' ; cc++, scr++ )
X if( cc < MAXSTRLEN )
X *bp++ = *scr;
X
X if( cc < MAXSTRLEN )
X *bp = '\0';
X else
X btmp[MAXSTRLEN] = '\0';
X scr++;
X
X if( strcmp(btmp, stats[r].st_str) ) {
X (void)strcpy(stats[r].st_str,btmp);
X stats[r].st_state = BVALID | BDRAW;
X }
X else
X stats[r].st_state = BVALID | BNODRAW;
X }
X
X }
X scr++;
X return scr;
X}
X
X
Xupdate_screen()
X{
X blob_t *bp;
X int x;
X
X
X#if DEBUG
X (void)printf("S---------\n");
X#endif /* DEBUG */
X /* walk down the list */
X for( bp = Bvalid ; bp ; bp = bp->b_next ) {
X
X /* erase object */
X if( bp->b_state == BVALID ) {
X
X#if NOTDEF
X XFillRectangle(display, window, copyGC, bp->b_x, bp->b_y,
X TANK_LEN, TANK_LEN);
X#endif /* NOTDEF */
X XCopyArea(display,xcell,window,copyGC,0,0,TANK_LEN,TANK_LEN,
X bp->b_x*TANK_LEN,bp->b_y*TANK_LEN);
X
X if( bp->b_last )
X bp->b_last->b_next = bp->b_next;
X else
X Bvalid = bp->b_next;
X
X if( bp->b_next )
X bp->b_next->b_last = bp->b_last;
X
X bp->b_state = 0;
X#if DEBUG
X (void)printf("x%c x= %d y = %d id = %d d = %d\n",bp->b_type,
X bp->b_x,bp->b_y,bp->b_id,bp->b_dir);
X#endif DEBUG
X
X continue;
X }
X
X
X /* redraw item? */
X if( bp->b_state & BDRAW ) {
X Pixmap pm;
X
X switch( (int)bp->b_type ) {
X case 't' : pm = tcells[bp->b_id][bp->b_dir];
X break;
X case 'h' : pm = hcells[bp->b_dir];
X break;
X case 's' : pm = scells[bp->b_dir];
X break;
X case 'e' : pm = ecells[bp->b_dir];
X break;
X case 'b' : pm = bcells[bp->b_dir];
X break;
X case 'm' : pm = mcell;
X break;
X case 'p' : pm = pcell;
X break;
X default : (void)printf("update_screen: invalid type '%c'\n",
X bp->b_type);
X break;
X }
X
X#if DEBUG
X (void)printf("D%c x= %d y = %d id = %d d = %d\n",bp->b_type,
X bp->b_x,bp->b_y,bp->b_id,bp->b_dir);
X#endif /* DEBUG */
X XCopyArea(display,pm,window,copyGC,0,0,TANK_LEN,TANK_LEN,
X bp->b_x*TANK_LEN,bp->b_y*TANK_LEN);
X }
X
X bp->b_state = BVALID;
X }
X
X /* draw stats */
X if( estat.st_state & BVALID ) {
X if( estat.st_state & BNODRAW )
X estat.st_state = BVALID | BERASE;
X else {
X if( estat.st_state & BERASE ) {
X XDrawImageString(display,window,copyGC,ESTATX,ESTATY,
X " ",20);
X estat.st_state = 0;
X estat.st_str[0] = '\0';
X }
X else {
X XDrawImageString(display,window,copyGC,ESTATX,ESTATY,
X estat.st_str,strlen(estat.st_str));
X estat.st_state = BVALID | BERASE;
X }
X }
X }
X
X for( x = 0 ; x < MAXSTAT ; x++ ) {
X if( !(stats[x].st_state & BVALID) )
X continue;
X
X if( stats[x].st_state & BNODRAW ) {
X stats[x].st_state = BVALID;
X continue;
X }
X
X /* identify tank? */
X if( ! (x & 1) ) {
X if( stats[x].st_state & BERASE )
X XCopyArea(display,xcell,window,copyGC,0,0,TANK_LEN,TANK_LEN,
X STATIDX,STATIDY(x));
X else
X XCopyArea(display,tcells[(x>>1) & 3][0],window,copyGC,0,0,
X TANK_LEN,TANK_LEN,STATIDX,STATIDY(x));
X }
X
X /* stat text */
X if( stats[x].st_state & BERASE ) {
X XDrawImageString(display,window,copyGC,STATX,STATY(x),
X " ",20);
X stats[x].st_state = 0;
X stats[x].st_str[0] = '\0';
X }
X else {
X XDrawImageString(display,window,copyGC,STATX,STATY(x),
X stats[x].st_str,strlen(stats[x].st_str));
X stats[x].st_state = BVALID;
X }
X }
X}
X
X
Xdraw_screen()
X{
X blob_t *bp;
X int x, y;
X Pixmap pm;
X
X
X#if DEBUG
X (void)printf("DS--------\n");
X#endif /* DEBUG */
X XClearWindow(display,window);
X for( x = 0 ; x < MAZE_XL ; x++ )
X for( y = 0 ; y < MAZE_YL ; y++ ) {
X
X bp = &blobs[x][y];
X
X if( !(bp->b_state & BVALID) ) {
X pm = xcell;
X bp->b_type = '-';
X }
X else {
X switch( (int)bp->b_type) {
X case 't' : pm = tcells[bp->b_id][bp->b_dir];
X break;
X case 'h' : pm = hcells[bp->b_dir];
X break;
X case 's' : pm = scells[bp->b_dir];
X break;
X case 'e' : pm = ecells[bp->b_dir];
X break;
X case 'm' : pm = mcell;
X break;
X case 'p' : pm = pcell;
X break;
X case 'w' : pm = wcells[bp->b_dir];
X break;
X case 'b' : pm = bcells[bp->b_dir];
X break;
X default :
X continue;
X }
X }
X
X#if DEBUG
X (void)printf("D%c x= %d y = %d id = %d d = %d\n",bp->b_type,
X bp->b_x,bp->b_y,bp->b_id,bp->b_dir);
X#endif /* DEBUG */
X XCopyArea(display,pm,window,copyGC,0,0,TANK_LEN,TANK_LEN,
X bp->b_x*TANK_LEN,bp->b_y*TANK_LEN);
X }
X
X /* draw stats */
X if( estat.st_state & BVALID )
X XDrawImageString(display,window,copyGC,ESTATX,ESTATY,
X estat.st_str,strlen(estat.st_str));
X
X for( x = 0 ; x < MAXSTAT ; x++ ) {
X if( !(stats[x].st_state & BVALID) )
X continue;
X
X /* identifying tank? */
X if( ! (x & 1) ) {
X XCopyArea(display,tcells[(x>>1)& 3][0],window,copyGC,0,0,
X TANK_LEN,TANK_LEN,STATIDX,STATIDY(x));
X }
X
X /* stat text */
X XDrawImageString(display,window,copyGC,STATX,STATY(x),
X stats[x].st_str,strlen(stats[x].st_str));
X }
X}
X
Xenter_game()
X{
X char **result, *res;
X char *uid, *cuserid();
X char uidbuf[256];
X char hbuf[256];
X char ubuf[256];
X
X if( !cuserid(ubuf) )
X (void)strcpy(ubuf,"anonymous");
X
X if( gethostname(hbuf,256) )
X (void)strcpy(hbuf,"somewhere");
X
X (void)sprintf(uidbuf,"%s@%s",ubuf,hbuf);
X
X uid = uidbuf;
X
X /* call remote procedure */
X result = tenter_1(&uid,cl);
X
X if( result == NULL ) {
X /* an error occurred while calling the server */
X clnt_perror(cl,server);
X exit(1);
X }
X
X if( !strcmp(*result,"iF") )
X return 1;
X
X /* NOTE: this done like this
X * to avoid a core dump, very very odd
X */
X res = *result;
X
X plyrid = res[1] - '0';
X
X return 0;
X}
X
Xexit_game()
X{
X char *move;
X char **msg;
X
X move = "i0";
X
X move[1] = '0'+plyrid;
X
X /* call remote procedure */
X msg = texit_1(&move,cl);
X
X if( *msg ) {
X (void)printf("%s\n",*msg);
X }
X}
X
X
Xchar *
Xget_maze()
X{
X int ret;
X char **result;
X
X /* call remote procedure */
X result = getmaze_1(&ret,cl);
X
X if( result == NULL ) {
X /* an error occurred while calling the server */
X clnt_perror(cl,server);
X exit(1);
X }
X
X return *result;
X}
X
X
Xinit_blobs()
X{
X int x,y,off;
X char *maze;
X blob_t *bp;
X
X
X /* clear status */
X estat.st_state = 0;
X estat.st_str[0] = '\0';
X for(x = 0 ; x < MAXSTAT ; x++ ) {
X stats[x].st_state = 0;
X stats[x].st_str[0] ='\0';
X }
X
X /* setup the maze */
X maze = get_maze();
X
X off = 0;
X for( y = 0 ; y < MAZE_YL ; y++ )
X for( x = 0 ; x < MAZE_XL ; x++ ) {
X bp = & blobs[x][y];
X bp->b_x = x;
X bp->b_y = y;
X
X if( maze[off] == 'w') {
X bp->b_state = BVALID;
X bp->b_type = 'w';
X bp->b_dir = 0;
X /* check NORTH */
X if( y && (maze[off - MAZE_YL] == 'w') )
X bp->b_dir |= 0x1;
X /* check EAST */
X if( (x < MAZE_YL - 1) && (maze[off+1] == 'w') )
X bp->b_dir |= 0x2;
X if( (y < MAZE_YL - 1) && (maze[off + MAZE_YL] == 'w') )
X bp->b_dir |= 0x4;
X if( x && (maze[off - 1] == 'w') )
X bp->b_dir |= 0x8;
X }
X else
X bp->b_state = 0;
X
X off++;
X }
X
X Bvalid = NULL;
X}
X
X
Xstatic void (*entryint)(), (*entryquit)();
X
Xvoid faterr();
X
Xvoid
Xignoresig()
X{
X static first = 1;
X
X if( first ) {
X first = 0;
X entryint = signal(SIGINT,SIG_IGN);
X entryquit = signal(SIGQUIT,SIG_IGN);
X if( (entryint == BADSIG) || (entryquit == BADSIG) )
X faterr("signal");
X if( signal(SIGHUP,hup) == BADSIG )
X faterr("signal hup");
X }
X else if( (signal(SIGINT,SIG_IGN) == BADSIG) ||
X (signal(SIGQUIT,SIG_IGN) == BADSIG) )
X faterr("signal");
X}
X
Xvoid
Xentrysig()
X{
X if( (signal(SIGINT,entryint) == BADSIG) ||
X (signal(SIGQUIT,entryquit) == BADSIG) )
X faterr("signal");
X}
X
Xvoid
Xhup()
X{
X Done = 1;
X}
X
Xvoid
Xfaterr(msg)
X char *msg;
X{
X (void)printf("fatal error: %s\n",msg);
X exit(1);
X}
X
X
X/* Lint Output
X*/
SHAR_EOF
chmod 0400 stank/client.c || echo "restore of stank/client.c fails"
if [ $TOUCH = can ]
then
touch -am 0319105291 stank/client.c
fi
set `wc -c stank/client.c`;Wc_c=$1
if test "$Wc_c" != "15342"
then echo original size 15342, current size $Wc_c;fi
# ============= stank/client.h ==============
echo "x - extracting stank/client.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > stank/client.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 "@(#)client.h 1.13 :/usr/key/jojow/X/src/guts/SCCS/s.client.h 3/19/91 10:15:42 "
X
X#include "tank.h"
X
X/* EXTERNALS */
Xextern Pixmap tcells[MAXTANK][MAXDIR];
Xextern Pixmap scells[MAXDIR];
Xextern Pixmap hcells[MAXDIR];
Xextern Pixmap ecells[EXPCNT];
Xextern Pixmap mcell;
Xextern Pixmap pcell;
Xextern Pixmap wcells[MAXWALL];
Xextern Pixmap xcell;
Xextern Pixmap bcells[BONCNT];
X
X/* STRUCTURES */
X
Xstruct blob {
X char b_type; /* type of object to draw */
X char b_dir; /* direction/frame of object */
X char b_id; /* tank id */
X char b_state; /* blob state */
X#define BVALID 0x1
X#define BDRAW 0x2
X#define BNODRAW 0x4
X#define BERASE 0x8
X char b_x;
X char b_y; /* position */
X struct blob *b_next; /* forward chain */
X struct blob *b_last; /* reverse chain */
X};
Xtypedef struct blob blob_t;
X
Xstruct stat {
X char st_str[MAXSTRLEN]; /* stat line val */
X char st_state; /* statistic state */
X};
Xtypedef struct stat stat_t;
X
X#define ESTATX ((MAZE_XL+ 1) * TANK_LEN + 5)
X#define ESTATY (TANK_LEN*2 - 3)
X
X#define STATYPOS 4
X#define STATIDX (MAZE_XL * TANK_LEN)
X#define STATIDY(st) (TANK_LEN*(st+STATYPOS))
X#define STATX ((MAZE_XL+1) * TANK_LEN + 3)
X#define STATY(st) (TANK_LEN*(st+STATYPOS) + 3)
X
X/* Wait this long before killing a non-active player */
X#define LASTACT 10000
X
X/* OTHER */
SHAR_EOF
chmod 0400 stank/client.h || echo "restore of stank/client.h fails"
if [ $TOUCH = can ]
then
touch -am 0319105291 stank/client.h
fi
set `wc -c stank/client.h`;Wc_c=$1
if test "$Wc_c" != "1846"
then echo original size 1846, current size $Wc_c;fi
# ============= stank/expl.c ==============
echo "x - extracting stank/expl.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > stank/expl.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 "@(#)expl.c 1.5 :/usr/key/jojow/X/src/guts/SCCS/s.expl.c 3/19/91 10:15:47 "
X
X/* expl.c - routines for handling explosions */
X
X#include "server.h"
X
X#define EBIG 'b'
X#define ESMALL 's'
SHAR_EOF
echo "End of stank part 1"
echo "File stank/expl.c is continued in part 2"
echo "2" > s3_seq_.tmp
exit 0
--
"The bear new nine songs; all of them on honey."
jojo at key.com
--
Dan Heller
------------------------------------------------
O'Reilly && Associates Z-Code Software
Senior Writer President
argv at ora.com argv at zipcode.com
------------------------------------------------
General Email: argv at sun.com
Comp-sources-x stuff: comp-sources.x at uunet.uu.net
More information about the Comp.sources.x
mailing list