Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/15/85; site ucbvax.ARPA Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!ucbvax!MRDCH From: MRDCH@TAURUS.BITNET Newsgroups: net.sources.games Subject: Galaxy sources (#4) and updates. Message-ID: <8168@ucbvax.ARPA> Date: Fri, 14-Jun-85 16:02:40 EDT Article-I.D.: ucbvax.8168 Posted: Fri Jun 14 16:02:40 1985 Date-Received: Sat, 15-Jun-85 08:39:40 EDT Sender: daemon@ucbvax.ARPA Organization: University of California at Berkeley Lines: 975 From: Mordechai Chachamu Hello everybody!!! Since galaxy was posted, I received many requests for part #4. This is the part that contains "utility" programs, and should be placed in ~galaxy/src1. I take this opportunity to add and correct few things, along with the reposting of that part. Even if you got that part in good shape, it's worth looking at it's new version. A brief description of it follows. ~galaxy/src1 changes: 1. The first posting contained a hidden subdirectory, ("safe") which escaped my attention. That directory contained redundant data and should be ignored. 2. The src1/Makefile is now better and cleaner.(called here "makefile") 3. Comments were added to most src1 files. 4. The file "constants.h" was trimmed to contain only relevant info. It should be copied to ~galaxy/src as well. (They should be identical). ~galaxy/src changes: 1. The Makefile was improved. (especially "make install"). 2. The file "diffsrc" contains some context diffs that should be patched in. ~galaxy changes: The installation shell script "install.sh" and "install_howto" underwent some major changes. They accompany the NEW makefiles. Waiting for comments. My address: mrdch@taurus (BITNET) mrdch@taurus.bitnet@berkeley (ARPA) mrdch%taurus.bitnet@wiscvm.ARPA (CSNET) and if all fails, then ...!decvax!humus!taurus!mrdch (UUCP) *GALAXY* wishes you a pleasant journey in the void... Mordechai. # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. -----cut here-----cut here-----cut here-----cut here----- #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # install.sh # install_howto # Makefile # diffsrc # makefile # READ_ME # constants.h # edscore.c # galaxy.csh # galaxy.motd # local.c # okgalaxy.c # pager.c # score.h # This archive created: Fri Jun 14 21:48:53 1985 echo shar: extracting install.sh '(2104 characters)' sed 's/^XX//' << \SHAR_EOF > install.sh XX# This is the galaxy maker. XX# It should be run: /bin/sh install.sh XX# Be sure to set the following shell-variables XX# before you run this command file. XX# Since this file has to use super-user privileges, XX# make sure you read it BEFORE using it. XX# Good luck. XX XXSDIR=/users/guest/galaxy/distr XX# Set this to reflect the home directory of galaxy. XX# All the rest resides in subdirectories. XXSOURCES=$SDIR/src XXSOURCES1=$SDIR/src1 XXMAN=$SDIR/man XXDOC=$SDIR/doc XXONLINE=$SDIR/online XX# This are system variables. XX# The first should be carefully matched with variables set in XX# $SDIR/src/constants.h!!! XXLIBDIR=/usr/games/lib/galaxy XXSYSMAN6=/usr/man/man6 XXSYSDOC=/usr/doc XX XXcat << Funny XXWarning: Read this file before running it! XX XXWarning: This file must be run with super_user priviliges. XX Before running it , create a user named galaxy, XX group - games. XX XXShall I proceed ? XXFunny XXread answer XXif [ "$answer" != y ]; then XX echo GoodBye XX exit 1 XXfi XX XXif [ ! -d $LIBDIR ]; then XX mkdir $LIBDIR XX chown galaxy $LIBDIR XXfi XX XXecho 'Making the galaxy game' XXcd $SOURCES ; make galaxy # install the main game XXecho 'Installing the galaxy game' XXmake install XXecho 'Making the utility files' XXcd $SOURCES1 ; make all # install utility files XXecho 'Installing the utility files' XXmake install XX XXecho 'Checking/creating online directory' XXif [ ! -d $LIBDIR/online ]; then XX mkdir $LIBDIR/online XXfi XX XXchown galaxy $LIBDIR/online XXecho 'Copying online files' XXcp $ONLINE/* $LIBDIR/online XXchown galaxy $LIBDIR/online/* # install online documents XXcd $LIBDIR XXecho 'Creating the "score" and "wizards" files' XXecho > galaxy.scor # score file. XXchown galaxy galaxy.scor XXchmod 600 galaxy.scor XXecho mrdch > wizards # wizard file. XXchmod 644 wizards # I'm always... XXchown galaxy wizards XXecho 'Placing the manual page' XXcp $MAN/galaxy.6 $SYSMAN6/galaxy.6 # manual XXecho 'Placing the document' XXcp $DOC/Galaxy.doc $SYSDOC/galaxy # document SHAR_EOF if test 2104 -ne "`wc -c install.sh`" then echo shar: error transmitting install.sh '(should have been 2104 characters)' fi echo shar: extracting install_howto '(7251 characters)' sed 's/^XX//' << \SHAR_EOF > install_howto XX*************************************************************** XX* PLEASE NOTICE THE FOLLOWING CONDITIONS * XX*************************************************************** XX XXAs the authors of the game, we would like to make some XXrequests and remarks concerning the game installation. XX XX1. The sources contained hereby are distributed free, for the XX much hoped enjoyment of all game lovers. XX XX2. Being in public domain, anyone is entitled to change/add/delete XX anything he wishes. XX XX3. We make a distinction between two kinds of changes: XX "Bug fix" - a change that brings the game to act closer to XX the way it should. (As defined in the document). XX "Enhancement" - a change that alters the way a player THINKS XX during the play. XX As a test to distinguish between the two, one should answer XX the question: XX "Will I play differently BECAUSE of that change?" XX XX4. We would appreciate hearing about changes of the first kind. XX If possible, please mail them to us. XX XX5. If a change of the second kind is introduced, we expect the XX person to compile it under a DIFFERENT name. XX (However similar to the origin). In addition, we would like XX to hear about it, and the reasoning behind it. XX XX7. The game may be redistributed on the condition that no file XX from the original distribution will be left out. XX XX8. The reason for the requests above is: XX Galaxy is different from many computer games, by involving XX TWO players at the same time. It is our wish that two XX people from different SITES will be able to compete one XX against the other. This can be achieved ONLY if the rules and XX conditions specified in the document remain intact. XX XX9. On the other hand, we are eagerly waiting for reactions XX of any kind. If there will be some public opinion concerning XX the way the game SHOULD be, we will correct it on future XX versions. XX XX*************************************************************** XX* END OF CONDITIONS. NOW THE FUN. * XX*************************************************************** XX XX Installing galaxy - Three ways to treat a lady. XX XX1. Run the install.sh in this directory. It must be run with XX Super User privileges, so at least read it before typing XX the command. XX2. Refer to the end of this document, which outlines a step by XX step procedure. XX3. Read further, and possibly gain more insight to the structure XX of this game. XX XXContents of the distribution directory. XX XXThe distribution directory contains several subdirectories: XX"Src" holds the source for the main program and "src1" has the XXsource for miscellaneous programs. XX"Man" holds the manual page, for general reference. XX"Doc" contains the complete documentation for the novice and XXexperienced player. XX"Online" is the same document in small pieces, that can be viewed XXduring the game. XX XXAfter compiling the source two programs are obtained: XX"galaxy" and "okgalaxy". XX"galaxy" is the game itself. Whenever a user wishes to challenge XXsomebody to this play, he should run "galaxy". If the offer is XXaccepted, the other user runs "okgalaxy". XX XXProtection XX XXIn order to enjoy the game to it's full potential, ALL relevant XXfiles should have their access bits set so that NO forgery XXis possible. When a game is saved, the saved file belongs to XX"galaxy", and it's mode set to 600. Encryption is used as a further XXprotection tool. The encryption source file is the ONLY code that should XXnot be left open to public. XX XXThe two runable modules belong to galaxy. XXTheir mode should be 4111. XXThe directory "/usr/games/lib/galaxy" is to be owned by galaxy too, XXand have it's mode bits set to 700. XX XXManuals XX XX"Nroff" the document and the manual page. Place them in their XXappropriate place. XX XX(The "Galaxy.doc" at "/usr/doc" and "Galaxy.nrf" in "/usr/doc/nroffed"). XX XXThe "online" holds the entries for the online "help" facility of XXthe game. It should be copied entirely to "/usr/games/lib/galaxy/online" XXdirectory. XX XX XXTerminals XX XXThe screen is a vital instrument here. The game looks for the type XXof terminal used, as defined by TERM in the environment. It then XXextracts some entries from the "termcap" data base. If the XXterminal lacks some basic capabilities, the session will be aborted. XX ***** High baud rates are recommended. ***** XXOne feature of the game is it's ability to make good use of XX2 screens terminals. There is NO entry for "FLip to the next page" and XX"Flip Back to the previous page" in termcap(5). In many new terminals XXsuch capability exists. If such is the case at your place, add those XXtwo entries. We have defined them as "fl" and "fb" respectively. XXThis feature is NOT essential to the game. XXAnother assumption, however, IS. We assume existence of a numeric keypad. XXThere might be a way do avoid such prerequisite, XXwith the cost of much less comfort to the players. XX XXInstallation - step by step XX XXThe procedure outlined here is a detailed version of the XXcommand file install.sh in this directory. XX XX XXIt is assumed that a uid named "galaxy" is created, within the XX"games" group. To avoid use of super user privileges, all files XXbelong to galaxy. XX XXThe variables outlined here can be freely changed. XX XXSDIR = /users/guest/galaxy ; the "home" dir. XX XX; subdirectories within "home" directory. XX XXSOURCES = $SDIR/src XXSOURCES1 = $SDIR/src1 XXMAN = $SDIR/man XXDOC = $SDIR/doc XXONLINE = $SDIR/online XX XX; where most of the game will reside XX XXLIBDIR = /usr/games/lib/galaxy XX XX; create LIBDIR with galaxy ownership XX XX mkdir $LIBDIR XX chown galaxy $LIBDIR XX XX; compile the programs and... XX; transfer them to their place and... XX; take care of mode bits. XX XXcd $SOURCES; make galaxy XXmake install XXcd $SOURCES1; make all XXmake install XX XX XX; create the score file XX XXecho > galaxy.scor # score file. XXchown galaxy galaxy.scor XX XX; make a file in /usr/games/lib/galaxy by the name "wizards". XX; This file should contain login names of people who would XX; like to experiment and debug (???) things in that game. XX; They have great power as wizards. XX XXecho mrdch > wizards # wizard file XXchown galaxy wizards XXchmod 600 wizards XX XX; Take care of documentation... XX XXcp $MAN/galaxy.6 /usr/man/man6/galaxy.6 # manual XXcp $DOC/galaxy.doc /usr/doc/galaxy # document XX XX; and the online documentation. XX XXmkdir $LIBDIR/online ; chown galaxy $LIBDIR/online XXcp $ONLINE/* $LIBDIR/online ; chown galaxy $LIBDIR/online/* XX XX; The following suggestions are not essential, but recommended. XX XX Copy the sources to /usr/src/games/galaxy XX XX Read the "Terminals" paragraph above, and see if you can do XX something about it. XX XX We cannot over-emphasize our request for comments criticism and, XX yes, even encouragements. XX XX Please mail them to XX XXOur address: XX {mrdch,amnnon}@taurus (BITNET) XX {mrdch,amnnon}@taurus.bitnet@berkeley (ARPA) XX {mrdch,amnnon}%taurus.bitnet@wiscvm.ARPA (CSNET) XXand if all fails, then XX ...!decvax!humus!taurus!{mrdch,amnnon} (UUCP) XX XX Mordechai Chachamu XX Amnon Horowits SHAR_EOF if test 7251 -ne "`wc -c install_howto`" then echo shar: error transmitting install_howto '(should have been 7251 characters)' fi echo shar: extracting Makefile '(2068 characters)' sed 's/^XX//' << \SHAR_EOF > Makefile XX# Galaxy Makefile. Belongs to ~galaxy/src. XX# SccsId %W% (mrdch&amnnon) %G% XX# XX XXLIBDIR = /usr/games/lib/galaxy XXHOMEDIR = /users/guest/galaxy XX XXCFILES = assign.c blackout.c build.c detect_mv.c feed_pop.c \ XX global.c init_all.c kill_alm.c leave_at.c \ XX move_to.c no_detect.c over_stat.c parse.c planet_enq.c \ XX planet_inf.c planet_sit.c play.c put_alm.c \ XX retrieve.c softclock.c take_from.c term2init.c trade.c \ XX use_term.c wizard.c write.c end_game.c \ XX savegame.c terminal.c set_missle.c best_score.c XX XXOFILES = assign.o blackout.o build.o detect_mv.o feed_pop.o \ XX global.o init_all.o kill_alm.o leave_at.o \ XX move_to.o no_detect.o over_stat.o parse.o planet_enq.o \ XX planet_inf.o planet_sit.o play.o put_alm.o \ XX retrieve.o softclock.o take_from.o term2init.o trade.o \ XX use_term.o wizard.o write.o end_game.o \ XX savegame.o terminal.o set_missle.o best_score.o XX XXHEADERS = header constants.h funcdef.h global.h typedefs.h options.h \ XX score.h table.h XX XXSOURCEDIR = . XXLDFLAGS = XXCC = /bin/cc XXRM = /bin/rm XXCTAGS = /usr/ucb/ctags XXGET = /usr/bin/sccs get -s XXPR = /bin/pr XXLPR = /usr/bin/lpr XXECHO = /bin/echo XXMV = /bin/mv XXTAR = /bin/tar XX XXall : galaxy XX @${ECHO} Galaxy is up to date. XX XXgalaxy : ${OFILES} XX ${CC} ${LDFLAGS} ${OFILES} -ltermlib XX @${MV} a.out galaxy XX XXtags : ${CFILES} ${HEADERS} XX ${CTAGS} ${CFILES} ${HEADERS} XX XXclean : XX ${RM} -f ${OFILES} XX XXlpr : XX ${PR} ${HEADERS} ${CFILES} | ${LPR} XX XX${OFILES} : ${HEADERS} XX.PRECIOUS: ${CFILES} ${HEADERS} XX.DEFAULT: ${CFILES} ${HEADERS} XX ${GET} $@ XX XXinstall: galaxy XX cp galaxy ${LIBDIR} XX mv ${LIBDIR}/galaxy ${LIBDIR}/galaxy.out XX chuser galaxy ${LIBDIR}/galaxy.out XX chmod 4111 ${LIBDIR}/galaxy.out XX XXgamelock: XX chmod 700 ${LIBDIR}/galaxy.out XX XXgameok: XX chmod 4111 ${LIBDIR}/galaxy.out XX XXtar : XX ${TAR} cv ${SOURCEDIR} XX XXbackup : XX ${TAR} cv ${HOMEDIR} SHAR_EOF if test 2068 -ne "`wc -c Makefile`" then echo shar: error transmitting Makefile '(should have been 2068 characters)' fi echo shar: extracting diffsrc '(1324 characters)' sed 's/^XX//' << \SHAR_EOF > diffsrc XX*** parse.c Fri Jun 14 18:55:08 1985 XX--- compare/parse.c Fri Jun 14 18:53:27 1985 XX*************** XX*** 500,509 XX * A suicidal command. When all is lost. XX */ XX give_up () { XX! if (!iswiz[player]) XX! end_game (!player); XX! else XX! endgame(!player); XX } XX XX /* XX XX--- 500,506 ----- XX * A suicidal command. When all is lost. XX */ XX give_up () { XX! end_game (!player); XX } XX XX /* XX*** savegame.c Fri Jun 14 18:55:24 1985 XX--- compare/savegame.c Fri Jun 14 18:53:41 1985 XX*************** XX*** 32,38 XX XX int SWITCH_FLAG; XX XX! char version[80] = "Galaxy: version 1.0 13/6/85"; XX XX /* XX * A few helpfull hints about galaxy's save file structure: XX XX--- 32,38 ----- XX XX int SWITCH_FLAG; XX XX! char version[80] = "Galaxy: version 1 6/9/84"; XX XX /* XX * A few helpfull hints about galaxy's save file structure: XX*** terminal.c Fri Jun 14 18:55:36 1985 XX--- compare/terminal.c Fri Jun 14 18:53:55 1985 XX*************** XX*** 182,188 XX if (ttyc -> t_curpage == 0) XX ttyc -> t_curpage = 1; XX else { XX! init_disc (); XX ttyc -> t_curpage = 0; XX } XX } XX XX--- 182,188 ----- XX if (ttyc -> t_curpage == 0) XX ttyc -> t_curpage = 1; XX else { XX! init_dis (); XX ttyc -> t_curpage = 0; XX } XX } SHAR_EOF if test 1324 -ne "`wc -c diffsrc`" then echo shar: error transmitting diffsrc '(should have been 1324 characters)' fi echo shar: extracting makefile '(1215 characters)' sed 's/^XX//' << \SHAR_EOF > makefile XX# This makefile belongs to ~galaxy/src1. XX# %W% (mrdch&amnnon) %E% XX# XX XXLIBDIR = /usr/games/lib/galaxy XXGAMES = /usr/games XXECHO = /bin/echo XXCFLAGS = -O -s XX XXall: okgalaxy pager local edscore XX @${ECHO} Utility files are up to date. XX XXokgalaxy: okgalaxy.c XX cc ${CFLAGS} -o okgalaxy okgalaxy.c XX XXpager: pager.c XX cc ${CFLAGS} -o pager pager.c XX XXlocal: local.c XX cc ${CFLAGS} -o local local.c XX XXedscore: edscore.c constants.h score.h XX cc $(CFLAGS) -o edscore edscore.c XX XX.DEFAULT: XX sccs get $@ XX XXclean: XX /bin/rm okgalaxy pager local edscore XX XXinstall: okgalaxy pager local edscore XX cp pager local edscore ${LIBDIR} XX chown galaxy ${LIBDIR}/pager XX chown galaxy ${LIBDIR}/local XX chown galaxy ${LIBDIR}/edscore XX chmod 755 ${LIBDIR}/pager XX chmod 755 ${LIBDIR}/local XX chmod 755 ${LIBDIR}/edscore XX cp galaxy.csh ${GAMES}/galaxy XX chown galaxy ${GAMES}/galaxy XX chmod 755 galaxy.csh XX cp okgalaxy ${GAMES}/okgalaxy XX chown galaxy ${GAMES}/okgalaxy XX chmod 4111 ${GAMES}/okgalaxy XX cp galaxy.motd ${LIBDIR} XX chown galaxy ${LIBDIR}/galaxy.motd XX chmod 600 ${LIBDIR}/galaxy.motd SHAR_EOF if test 1215 -ne "`wc -c makefile`" then echo shar: error transmitting makefile '(should have been 1215 characters)' fi echo shar: extracting READ_ME '(522 characters)' sed 's/^XX//' << \SHAR_EOF > READ_ME XX# %W% (mrdch&amnnon) %E% XXThis directory holds the service programs, used by galaxy. XXThe make will make it all. Read before using. XX XXSome remarks: XX"galaxy.csh" is the front end of the whole game. It enables XX posting of some remarks through a motd file in XX /users/games/lib/galaxy. XX"edscore" enables paging through the score file for editing XX purpose. Use whenever necessary. XX"okgalxy","pager" and "local" are programs to establish XX communication when the game starts. XX XX mrdch & amnnon SHAR_EOF if test 522 -ne "`wc -c READ_ME`" then echo shar: error transmitting READ_ME '(should have been 522 characters)' fi echo shar: extracting constants.h '(3659 characters)' sed 's/^XX//' << \SHAR_EOF > constants.h XX/* XX * %W% (mrdch&amnnon) %E% XX */ XX XX/* XX * this file contains all the constants used by the game. XX */ XX XX# define HOME "/usr/games/lib/galaxy/" XX# define LOCAL "/usr/games/lib/galaxy/local" XX# define WIZFIL "/usr/games/lib/galaxy/wizards" XX# define GALSCOR "/usr/games/lib/galaxy/galaxy.scor" XX# define ONLINE "/usr/games/lib/galaxy/online/" XX# define PAGER "/usr/games/lib/galaxy/pager" XX XX# define ESPSIZ 8 /* max nesting of espionage */ XX# define MAXSHIPS 7 /* how many types of ships */ XX# define MAXPL 91 /* how many planets are there */ XX# define PLKINDS 5 /* how many kinds of planets */ XX# define MAXCHAN 2 /* maximum no. of chanels to open */ XX XX# define NCREW 64 /* no. of fighters in A-type HAWK */ XX# define VISITORS 128 /* no. of additional people */ XX# define MSGSIZ 150 /* max chars in a single masseg */ XX XX# define CLASES 6 /* how many clases of people */ XX XX# define FIGT 0 /* fighters */ XX# define CITI 1 /* citizens */ XX# define SCIE 2 /* scientists */ XX# define BUIL 3 /* builders */ XX# define MINE 4 /* miners */ XX# define SLAV 5 /* slaves */ XX XX# define ESPTYP 7 /* different types of espionage: */ XX XX# define ESPKIND 0 /* what kind of planet is it */ XX# define ESPPOP 1 /* how many people are there */ XX# define ESPKNOW 2 /* what is the knowledge level */ XX# define ESPMTL 3 /* how much metal was digged out */ XX# define ESPSHIP 4 /* what are the forces there */ XX# define ESPALM 5 /* how many ALM were installed */ XX# define ESPMSL 6 /* how many missiles are there */ XX XX# define BUILD_MONEY 0 /* MONEY given to build ships */ XX# define LEVEL 1 /* the LEVEL of ships ordered build */ XX# define NSHIPS 2 /* the NO. of ships ordered build */ XX XX# define N_PSI 20 /* max possible messages on screen */ XX XX# define ALMCOST 100 /* how much costs 1 ALM */ XX# define REMOVE_COST 50 /* to remove one if yours */ XX# define ALM_KILL_COST 200 /* to remove from the enemy's planet */ XX XX# define YEARLENGTH 180 /* a turn is 3 min. */ XX# define PERC_TRADE 5 /* the minimum % of profit in trade */ XX# define PERC_POPUL 10 /* the % of natural growth */ XX# define FEED_RATIO 100 /* no. people fed by 1 teller a year */ XX# define MINING_FACTOR 100 /* years_manpower 1A metals */ XX# define KNOW_FACTOR 2000 /* years_manpower to raise 1 level */ XX# define SHIP_COST 100 /* basic cost factor to build ship */ XX# define MISSILE_COST 400 /* to put a A-type missile */ XX# define REDUCE_RATE 10 /* detecting lost effect % in a year */ XX# define FADE_RATE 25 /* undetection paint fading rate */ XX XX# define MIN_ESP 100 /* the minimum to report ANYTHING */ XX# define KIND_ESP MIN_ESP /* to find out the planet's type */ XX# define POPUL_ESP 5*MIN_ESP /* for it's population */ XX# define KNOW_ESP 3*MIN_ESP /* the level of knowledge there */ XX# define METAL_ESP 2*MIN_ESP /* how much metal has he */ XX# define FORCE_ESP 10*MIN_ESP /* what are his forces there */ XX# define ALM_ESP 2*MIN_ESP /* how many alms he's got */ XX# define MSL_ESP 8*MIN_ESP /* how many missiles he set there */ SHAR_EOF if test 3659 -ne "`wc -c constants.h`" then echo shar: error transmitting constants.h '(should have been 3659 characters)' fi echo shar: extracting edscore.c '(1888 characters)' sed 's/^XX//' << \SHAR_EOF > edscore.c XX/* XX * %W% (mrdch&amnnon) %E% XX */ XX XX# include XX# include "constants.h" XX# include "score.h" XX# include XX XXchar *tmpf = "/usr/games/lib/galaxy/scoreXXXXXX"; XXchar *ctime (); XXint tmp, XX sc; XX XXmain () { XX struct score s; XX char c; XX long time(); XX XX sc = open (GALSCOR, 0); XX if (sc < 0) { XX perror (GALSCOR); XX exit (1); XX } XX tmp = creat (mktemp (tmpf), 0600); XX if (tmp < 0) { XX perror (tmpf); XX exit (1); XX } XX XX while (read (sc, &s, sizeof (s)) == sizeof (s)) { XX if (c != 'q') { XX char *str, XX *index (); XX str = ctime (&s.played_at); XX *index (str, '\n') = '\0'; XX printf ("%s,%s %d %s ", s.win, s.los, s.years, str); XX c = getchar (); XX if (c != '\n') XX while (getchar () != '\n'); XX } XX switch (c) { XX case 'd': XX break; XX case 'q': XX default: XX write (tmp, &s, sizeof (s)); XX break; XX case 'a': XX write (tmp, &s, sizeof (s)); XX printf("winner ? "); XX gets(s.win); XX printf("looser ? "); XX gets(s.los); XX printf("years ? "); XX rint(&s.years); XX s.played_at = time(0); XX write(tmp, &s, sizeof(s)); XX break; XX } XX } XX if (unlink (GALSCOR) < 0) { XX fprintf (stderr, "unlink "); XX perror (GALSCOR); XX exit (1); XX } XX if (link (tmpf, GALSCOR) < 0) { XX fprintf (stderr, "link "); XX perror (GALSCOR); XX exit (1); XX } XX if (unlink (tmpf) < 0) { XX fprintf (stderr, "unlink "); XX perror (tmpf); XX exit (1); XX } XX exit (0); XX} XX XXrint(i) XXint *i; XX{ XX char s[100]; XX gets(s); XX *i = atoi(s); XX} SHAR_EOF if test 1888 -ne "`wc -c edscore.c`" then echo shar: error transmitting edscore.c '(should have been 1888 characters)' fi echo shar: extracting galaxy.csh '(173 characters)' sed 's/^XX//' << \SHAR_EOF > galaxy.csh XX#! /bin/csh -f XX# XX# %W% (mrdch&amnnon) %E% XX# XX XXset motd = "/usr/games/lib/galaxy/galaxy.motd" XX XXif ( -e $motd && $#argv == 0) cat $motd XX XX/usr/games/lib/galaxy/galaxy.out $argv SHAR_EOF if test 173 -ne "`wc -c galaxy.csh`" then echo shar: error transmitting galaxy.csh '(should have been 173 characters)' fi echo shar: extracting galaxy.motd '(214 characters)' sed 's/^XX//' << \SHAR_EOF > galaxy.motd XX XX Wellcome to the Universe of Galaxies!!! XX XXIf that's your first time to try galaxy, I hope you have XXread the manual first. If not, hit 'del' to exit and XXthen do 'man galaxy'. XX XX Enjoy your journey!!! XX SHAR_EOF if test 214 -ne "`wc -c galaxy.motd`" then echo shar: error transmitting galaxy.motd '(should have been 214 characters)' fi echo shar: extracting local.c '(623 characters)' sed 's/^XX//' << \SHAR_EOF > local.c XX/* XX * %W% (mrdch&amnnon) %E% XX */ XX XX# include XX XXstruct chan XX{ XX int ichan ; XX char c ; XX} ; XX XX/* XX * this file is invoked to create TWO reading processes. XX * Each process reads from it's respective terminal, XX * and writes it to the main process. XX * The SOURCE is identified by the "ichan" no. XX */ XXmain(ac, av) XXint ac ; XXchar **av ; XX{ XX struct chan c ; XX if(ac != 2) XX exit(1) ; XX XX c.ichan = atoi(av[1]) ; XX while(!feof(stdin)) XX { XX c.c = getchar() ; XX write(1, (char *)&c, sizeof(c)) ; XX } XX exit(0) ; XX} SHAR_EOF if test 623 -ne "`wc -c local.c`" then echo shar: error transmitting local.c '(should have been 623 characters)' fi echo shar: extracting okgalaxy.c '(1453 characters)' sed 's/^XX//' << \SHAR_EOF > okgalaxy.c XX/* XX * %W% (mrdch&amnnon) %E% XX */ XX XX# include XX# include XX# include XX# include XX XXstruct stat stbuf ; XXchar *tty ; XX XX/* XX * The reason for this file is that usually there is no READ XX * permission on someone else terminal. Giving this command XX * enables the main game to read whatever is typed by the XX * second player, and interpret his commands. XX */ XXmain() XX{ XX char *ttyname() ; XX int doexit() ; XX XX tty = ttyname(0) ; XX XX if(tty == 0) XX { XX fprintf(stderr, "Don't know you.\n") ; XX exit(1) ; XX } XX XX/* XX * collect terminal situation in a temporary buf. XX */ XX stat(tty, &stbuf) ; XX/* XX * prepare for leaving the game when it's all over. XX */ XX signal(SIGINT, doexit) ; XX signal(SIGQUIT, doexit) ; XX signal(SIGTSTP, doexit) ; XX XX/* XX * try to make the terminal readable to all. XX */ XX if(chmod(tty, 0666) == -1) XX { XX fprintf(stderr, "Your tty ain't yours.\n") ; XX exit(1) ; XX } XX XX/* XX * all went fine, relax and let the originator to catch up. XX */ XX printf("Please wait.....") ; XX fflush(stdout) ; XX XX/* XX * Suspend all activity. To exit this mode after the game XX * has finished, one needs to interrupt it with a keybourd XX * signal. XX */ XX pause() ; XX} XX XX/* restore terminal mode to original state. */ XXdoexit() XX{ XX chmod(tty, stbuf.st_mode) ; XX exit(0) ; XX} SHAR_EOF if test 1453 -ne "`wc -c okgalaxy.c`" then echo shar: error transmitting okgalaxy.c '(should have been 1453 characters)' fi echo shar: extracting pager.c '(563 characters)' sed 's/^XX//' << \SHAR_EOF > pager.c XX/* XX * %W% (mrdch&amnnon) %E% XX */ XX XX# include XX XXmain(ac, av) XXint ac ; XXchar **av ; XX{ XX FILE *tty ; XX XX if(ac != 3) XX getout("arg count") ; XX XX tty = fopen(av[1], "w") ; XX if(tty == NULL) XX getout("cannot open terminal") ; XX XX fprintf(tty, "\07\07%s would like to play galaxy with you.\n\r",av[2]) ; XX fprintf(tty, "\07\07If you wish to play exec /usr/games/okgalaxy\n\r") ; XX XX exit(0) ; XX} XX XXgetout(s) XXchar *s ; XX{ XX fprintf(stderr, "pager: %s.\n", s) ; XX exit(1) ; XX} SHAR_EOF if test 563 -ne "`wc -c pager.c`" then echo shar: error transmitting pager.c '(should have been 563 characters)' fi echo shar: extracting score.h '(436 characters)' sed 's/^XX//' << \SHAR_EOF > score.h XX/* XX * %W% (mrdch&amnnon) %E% XX */ XX XX/* XX * this file defines the score information structure. XX */ XX XXstruct score /* score log structure */ XX{ XX char win[20] ; /* winner name */ XX char los[20] ; /* looser name */ XX int years ; /* game years played */ XX time_t played_at ; /* date played at */ XX} ; SHAR_EOF if test 436 -ne "`wc -c score.h`" then echo shar: error transmitting score.h '(should have been 436 characters)' fi # End of shell archive exit 0