home *** CD-ROM | disk | FTP | other *** search
- Subject: v17i041: napoleon - text adventure game, Part04/04
- Newsgroups: comp.sources.games
- Approved: billr@saab.CNA.TEK.COM
-
- Submitted-by: pc123@cus.cam.ac.uk (Pete Chown)
- Posting-number: Volume 17, Issue 41
- Archive-name: napoleon/Part04
- Environment: Unix, ASNI-C
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 4 (of 4)."
- # Contents: adv.h copyright toplev.c
- # Wrapped by billr@saab on Thu Mar 4 09:46:52 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'adv.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'adv.h'\"
- else
- echo shar: Extracting \"'adv.h'\" \(4570 characters\)
- sed "s/^X//" >'adv.h' <<'END_OF_FILE'
- X/* Copyright (C) 1992 Pete Chown.
- X
- X Here is my latest adventure game, Napoleon (see the documentation
- X if you don't know why it's called that). Have fun... (don't cheat,
- X even though you've got the source :-) ).
- X
- X This game is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X The game is distributed in the hope that it will be useful, but
- X WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- X General Public License for more details.
- X
- X The GNU General Public License is often shipped with GNU software, and
- X is generally kept in a file called COPYING or LICENSE. If you do not
- X have a copy of the license, write to the Free Software Foundation,
- X 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X/* Define PURE_ANSI if you are building Napoleon on a system which is not
- X Unix compatible. Then the result will be ANSI conforming, but will
- X have no command history and will not be able to detect the size of the
- X screen. Otherwise define UNIX.
- X
- X Define HAS_XMALLOC if your system has xmalloc() built into the C library.
- X It will not then be defined again by this program.
- X*/
- X
- X#if (!defined(PURE_ANSI) && !defined(UNIX)) || (defined(PURE_ANSI) && defined(UNIX))
- X#error You must define one of PURE_ANSI and UNIX.
- X#endif
- X
- X#include <stdio.h>
- X#include <string.h>
- X#include <ctype.h>
- X#include <stdarg.h>
- X#include <signal.h>
- X#include <time.h>
- X
- X#ifdef HAS_STDLIB
- X#include <stdlib.h>
- X#endif
- X
- X#ifndef PURE_ANSI
- X
- X#include "readline/readline.h"
- X#include "readline/history.h"
- X
- X#endif
- X
- X#define VERSION "1.02 (" __DATE__ ")"
- X#define NAME "Napoleon"
- X#define bool int
- X#define TRUE 1
- X#define FALSE 0
- X#define LINE_NO_HISTORY 5
- X#define LINE_HISTORY 6
- X#ifdef CHECKING_CONSISTENCY
- X#define fail() { fprintf(stderr,"Internal inconsistency detected\n"); exit(4); }
- X#else
- X#define fail() { fprintf(stderr,"Internal inconsistency detected, fail point is " __FILE__ ":%d\n",__LINE__); exit(4); }
- X#endif
- X
- Xstruct objtype {
- X unsigned int room:1,player:1,alive:1,luminous:1,opaque:1,virtual:1,visited:1,container:1;
- X};
- X
- Xtypedef struct tagobject {
- X int above,below,inside,next,parent,n,s,w,e,nw,ne,sw,se,u,d;
- X char *examine,*longname,*shortname;
- X struct objtype objtype;
- X} object;
- X
- Xextern void format(char *,...);
- Xextern char *getline(char *,int);
- Xextern void loadgame(void);
- Xextern void initialise(void);
- Xextern void describe_room(int,bool);
- Xextern void command(int,char *);
- Xextern int getroom(int);
- Xextern void detachfromchain(int);
- Xextern int yyparse(void);
- Xextern bool strcmp_ci(char *,char *);
- Xextern void addtochain(int,int,int *);
- Xextern bool ancestor(int,int);
- Xextern void savegame(void);
- Xextern void addfirstdescendants(int);
- Xextern void inventory(int);
- Xextern int yylex(void);
- Xextern void moveplayer(void);
- Xextern int rnd(int);
- Xextern void yyerror(char *);
- Xextern void addadjective(char *);
- Xextern void addobject(int);
- Xextern int getobject(char *);
- Xextern bool ispresent(int,int);
- Xextern void examine(void);
- Xextern void do_read(void);
- Xextern void get(void);
- Xextern void drop(void);
- Xextern void put(int,int *);
- Xextern int premove(int,int);
- Xextern void postmove(void);
- Xextern void postdescription(int);
- Xextern void speech(int,int);
- Xextern bool dogreeting(int);
- Xextern bool dofarewell(int);
- Xextern void doyes(int);
- Xextern void dono(int);
- Xextern void twirl(void);
- Xextern void turn(void);
- Xextern void examineobject(int,int);
- Xextern int playnoughts(void);
- Xextern void more(void);
- Xextern void hack(void);
- Xextern bool illuminated(int);
- Xextern void justput(int,int,int *);
- Xextern void play(int);
- Xextern char *quickname(char *,int);
- Xextern void playnandc(int);
- Xextern void give(int);
- Xextern bool wantsit(int,int);
- Xextern void destroy(int);
- Xextern void throw(int);
- Xextern void jump(int);
- Xextern void touch(int);
- Xextern void unlock(int,int);
- Xextern void resumscore(void);
- Xextern bool referred_to(int);
- Xextern int getbeastie(void);
- Xextern void record(int,int);
- Xextern void drink(int);
- Xextern void precommand(void);
- Xextern void do_wait(void);
- Xextern void kiss(int);
- Xextern bool quadruples(void);
- Xextern void search(int);
- Xextern void climb(int);
- X
- Xextern void *xmalloc(int);
- X
- Xextern bool descr,looked,dead,all,hacker,finished,speechflag;
- Xextern object *objects,intobjects [];
- Xextern int player,direction,score,yaccplayer,listedobjects,objectlist [200],subject,said,delay;
- Xextern char *yaccstring;
- Xextern unsigned char flags [128];
- END_OF_FILE
- if test 4570 -ne `wc -c <'adv.h'`; then
- echo shar: \"'adv.h'\" unpacked with wrong size!
- fi
- # end of 'adv.h'
- fi
- if test -f 'copyright' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'copyright'\"
- else
- echo shar: Extracting \"'copyright'\" \(961 characters\)
- sed "s/^X//" >'copyright' <<'END_OF_FILE'
- X/* Copyright (C) 1992 Pete Chown.
- X
- X Here is my latest adventure game, Napoleon (see the documentation
- X if you don't know why it's called that). Have fun... (don't cheat,
- X even though you've got the source :-) ).
- X
- X This game is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X The game is distributed in the hope that it will be useful, but
- X WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- X General Public License for more details.
- X
- X The GNU General Public License is often shipped with GNU software, and
- X is generally kept in a file called COPYING or LICENSE. If you do not
- X have a copy of the license, write to the Free Software Foundation,
- X 675 Mass Ave, Cambridge, MA 02139, USA. */
- END_OF_FILE
- if test 961 -ne `wc -c <'copyright'`; then
- echo shar: \"'copyright'\" unpacked with wrong size!
- fi
- # end of 'copyright'
- fi
- if test -f 'toplev.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'toplev.c'\"
- else
- echo shar: Extracting \"'toplev.c'\" \(2356 characters\)
- sed "s/^X//" >'toplev.c' <<'END_OF_FILE'
- X/* Copyright (C) 1992 Pete Chown.
- X
- X Here is my latest adventure game, Napoleon (see the documentation
- X if you don't know why it's called that). Have fun... (don't cheat,
- X even though you've got the source :-) ).
- X
- X This game is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X The game is distributed in the hope that it will be useful, but
- X WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- X General Public License for more details.
- X
- X The GNU General Public License is often shipped with GNU software, and
- X is generally kept in a file called COPYING or LICENSE. If you do not
- X have a copy of the license, write to the Free Software Foundation,
- X 675 Mass Ave, Cambridge, MA 02139, USA. */
- X
- X#include "adv.h"
- X
- Xextern int main(int,char *[]);
- X
- Xbool dead,finished = FALSE,descr,looked,hacker = FALSE;
- Xint player,score = 0;
- X
- Xstatic void write_disclaimer(void)
- X{
- X format("%s, version %s, copyright (c) Pete Chown 1992\n\n",NAME,VERSION);
- X format("Napoleon is free software and you are welcome to distribute copies"
- X" of it under certain conditions; read the scroll (in the office where you st"
- X"art) to see them. There is absolutely no warranty for Napoleon; again detai"
- X"ls are on the scroll.\n\n");
- X}
- X
- Xextern int main(int argc,char *argv [])
- X{
- X bool quitting,gotinput;
- X char *line;
- X
- X write_disclaimer();
- X initialise();
- X
- X do {
- X dead = FALSE;
- X descr = TRUE;
- X for(;;)
- X {
- X if(descr) {
- X describe_room(player,looked);
- X descr = FALSE;
- X looked = FALSE;
- X }
- X precommand();
- X if(dead || finished) break;
- X line = getline("(napoleon) ",LINE_HISTORY);
- X command(player,line);
- X if(dead || finished) break;
- X }
- X quitting = gotinput = FALSE;
- X do {
- X format("Enter 'R' to restart, 'L' to load a saved game or 'Q' to quit:");
- X line = getline(">",LINE_NO_HISTORY);
- X switch(tolower(*line))
- X {
- X case 'r':
- X initialise();
- X gotinput = TRUE;
- X break;
- X case 'l':
- X loadgame();
- X gotinput = TRUE;
- X break;
- X case 'q':
- X quitting = gotinput = TRUE;
- X break;
- X }
- X } while(! gotinput);
- X } while(! quitting);
- X
- X return 0;
- X}
- END_OF_FILE
- if test 2356 -ne `wc -c <'toplev.c'`; then
- echo shar: \"'toplev.c'\" unpacked with wrong size!
- fi
- # end of 'toplev.c'
- fi
- echo shar: End of archive 4 \(of 4\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-