[comp.sources.games] v03i062: omega - rogue like dungeon exploration, Part15/15

games-request@tekred.TEK.COM (01/21/88)

Submitted by: "Laurence R. Brothers" <brothers@paul.rutgers.edu>
Comp.sources.games: Volume 3, Issue 62
Archive-name: omega/Part15

#! /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 15 (of 15)."
# Contents:  Makefile o.c ocity.dat olev.c omega.compilation.notes
#   omega.license otime.c
# Wrapped by billr@tekred on Mon Jan 18 10:20:52 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(1399 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X# This makefile works on a Sun, but may not work on some other machines
X# It is pretty obviou what it does, though, just runs cc.
X# I use the -g flag for debugging info; if you don't intend to
X# hack omega you might change the -g's to -O's for optimization
X# Modified Makefile (add install section) by Bill Randle, 1/18/88
X
XBINDIR = /usr/games
X# Note: LIBDIR should refer to the directory specified in "odefs.h"
XLIBDIR = /usr/games/lib/omegalib
X
Xobjects = o.o oaux1.o oaux2.o ochar.o ocity.o ocom.o odepths.o\
X	oeffect1.o oeffect2.o\
X	oetc.o ofile.o ogen.o oguild.o oinititem1.o oinititem2.o\
X	oinitmon0to3.o oinitmon4to7.o oinitmon8to10.o\
X	oinv.o oitem.o oitemf.o olev.o omon.o omonf.o omove.o\
X	oscr.o osite.o ospell.o otime.o outil.o
X
XAUXFILES = ocity.dat ocommands.txt odepths.dat ohelp.txt omega.hiscore\
X	omega.intro omega.log omega.lognum omega.motd\
X	oscroll1.txt oscroll2.txt
X
XWRITEABLEFILES = $(LIBDIR)/omega.saves $(LIBDIR)/omega.hiscore\
X	$(LIBDIR)/omega.log $(LIBDIR)/omega.lognum
X
Xsourceflags = -c -O # -g
X
Xobjectflags = # -g
X
Xlibraries =  -lcurses -ltermlib
X
Xomega: $(objects)
X	cc -o $@ $(objectflags) $(objects) $(libraries)
X
X$(objects): odefs.h oglob.h $(@:.o=.c)
X	cc $(sourceflags) $(@:.o=.c)
X
Xinstall: omega $(AUXFILES)
X	-mkdir $(LIBDIR)
X	chmod 777 $(LIBDIR)
X	install -s omega $(BINDIR)
X	cp $(AUXFILES) $(LIBDIR)
X	cp /dev/null $(LIBDIR)/omega.saves
X	chmod 666 $(WRITEABLEFILES)
X
END_OF_Makefile
if test 1399 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f o.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"o.c\"
else
echo shar: Extracting \"o.c\" \(7142 characters\)
sed "s/^X//" >o.c <<'END_OF_o.c'
X/* omega copyright (c) 1987 by Laurence Raphael Brothers */
X
X/* this file includes main() and some top-level functions */
X/* o.c */
X
X#include <stdio.h>
X#include <signal.h>
X#include <strings.h>
X#include "odefs.h"
X
X/* from ofile */
Xextern int filecheck();
X
X/* from outil */
Xextern void initdirs();
Xextern int getdir();
X
X/* from oscr */
Xextern void initgraf(),drawvision(),endgraf(),mprint(),dataprint();
Xextern void printm(),morewait(),showflags(),show_screen(),screencheck();
Xextern char ynq();
X
X/* from ocom */
Xextern void p_process(),pickup(),save(),quit();
X
X/* from somewhere */
Xextern int calcmana();
X
X/* from oaux */
Xextern void initplayer(),initspells(),p_damage(),p_teleport(),hourly_check();
Xextern void foodcheck(),move_status_check(),hour_status_check();
Xextern void damage_item();
X
X/* from otime */
Xextern void time_clock();
X
X/* from oetc */
Xextern void hint();
X
X/* from oinitmon0to3 */
Xextern void initmon0to3();
X
X/* from oinitmon4to7 */
Xextern void initmon4to7();
X
X/* from oinitmon8to10 */
Xextern void initmon8to10();
X
X/* from olev */
Xextern void wandercheck();
Xextern int restore_game();
X
X/* from ogen */
Xextern void init_dungeon();
X
X/* from oitem */
Xextern pob create_object();
X
X/* from oinititem1 */
Xextern void inititem1();
X
X/* from oinititem2 */
Xextern void inititem2();
X
X              /* globals all originate in o.c */
X              /* extern defs in oglob.h */
X              /* There do seem to be an awful lot of them.... */
X
X/* one of each monster */
Xstruct monster Monsters[NUMMONSTERS];
X
X/* one of each spell */
Xstruct spell Spells[NUMSPELLS+1];
X
X/* one of each item */
Xstruct object Objects[TOTALITEMS];
X
Xpml Mlist[NUMLEVELS];                 /* monsters on each level */
Xstruct player Player;                 /* the player */
Xstruct location Dungeon[NUMLEVELS][WIDTH][LENGTH];  /* the whole dungeon */
Xstruct level_data Leveldata[NUMLEVELS];  /* info about various levels */
Xint Dirs[2][9];                       /* 9 xy directions */
Xchar Cmd='s';                         /* last player command */
Xint Lunarity=0;                       /* Effect of the moon on character */
Xint Phase;                            /* Phase of the moon */
Xint Date;                             /* Starting date */
Xint Searchnum = 1;                    /* number of times to search on 's' */
Xint Wizard = FALSE;                   /* Wizard mode ? */
Xint Cheated = FALSE;                  /* If ever used wizard mode */
Xint Fastmove = TRUE;                  /* are we in the middle of a fast move */
Xint Skipmonsters = FALSE;             /* don't deal with them this move */
Xint Skipplayer = FALSE;               /* don't deal with him this move */
Xint Gameover = FALSE;                 /* yow! are we having fun yet? */
Xint Dlevel = 0;                       /* current dungeon level */
Xint WhichScreen=0;                    /* which screen are we on? (0..3) */
Xchar Seed;                            /* random seed */
Xint Time = 0;                         /* turn number */
Xint Tick = 0;                         /* 1/0 a turn; action coordinator */
Xchar Laststring[80];                  /* the last mprint string */
Xint Logsize;                          /* number of players in log */
Xint Tacmode=FALSE;                    /* In tactical combat mode? */
Xint Arena = FALSE;                    /* Arena combat leaves no corpses */
Xint Final = FALSE;                    /* Final duel flag */
Xint Gymcredit = 0;                    /* credit at rampart gym */
Xint Balance = 0;                      /* bank account */
Xint Bank_Broken = FALSE;              /* Has bank been broken into */
Xchar Password[64];                    /* autoteller password */
Xint Deepest = 0;                      /* The deepest level attained */
Xint SuppressPrinting=FALSE;           /* turn off mprint, printm, when TRUE */
Xchar Str1[100],Str2[100],Str3[100],Str4[100];
X   /* Some string space, random uses */
X
Xint Thieflevel,Clericlevel,Sorcerorlevel,Collegelevel,Merclevel;
X/*record entry levels for various guilds, etc */
X
Xint Clubmember=FALSE;                       /* Explorers' club member? */ 
Xint Sawdruid=FALSE;                         /* met the druid? */
Xint Soldcondo=FALSE;                        /* Bought the condo? */
Xpol Condoitems=NULL;                        /* Items in condo */
X
X/* high score names, levels, behavior */
Xint Shadowlordbehavior,Archmagebehavior,Primebehavior,Commandantbehavior;
Xint Championbehavior,Priestbehavior[7],Hibehavior,Dukebehavior;
Xchar Shadowlord[80],Archmage[80],Prime[80],Commandant[80],Duke[80];
Xchar Champion[80],Priest[7][80],Hiscorer[80],Hidescrip[80];
Xint Shadowlordlevel,Archmagelevel,Primelevel,Commandantlevel,Dukelevel;
Xint Championlevel,Priestlevel[7],Hiscore,Hilevel;
X
X
X/* o.c functions */
Xvoid intercycle(),initrand();
Xint game_restore(),signalexit(),main();
X
X/* bookkeeping between monster and player moves. Is executed every move */
X
X
X
X/* This may be implementation dependent */
Xvoid initrand()
X{
X  srandom(time()+Seed);
X}
X
X
X
X
Xint game_restore(argc,argv)
Xint argc;
Xchar *argv[];
X{
X  char savestr[80];
X  int ok;
X  if (argc==2) {
X    strcpy(savestr,argv[1]);
X    ok = restore_game(savestr);
X    unlink(savestr);
X    if (! ok) {
X      endgraf();
X      mprint("Try again with the right save file, luser!");
X      exit(0);
X    }
X    return(TRUE);
X  }
X  else return(FALSE);
X}
X
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X  int continuing;
X
X
X  if (CATCH_SIGNALS) {
X    signal(SIGINT,quit);
X    signal(3,signalexit);
X    signal(4,signalexit);
X    signal(5,signalexit);
X    signal(6,signalexit);
X    signal(7,signalexit);
X    signal(8,signalexit);
X    signal(10,signalexit);
X    signal(11,signalexit);
X    signal(12,signalexit);
X    signal(29,signalexit);
X  }
X
X  /* if filecheck is 0, some necessary data files are missing */
X  if (filecheck() == 0) exit(0);
X
X  /* all kinds of initialization */
X  initdirs();
X  initrand();
X  inititem1();
X  inititem2();
X  initspells();
X  initgraf();
X
X  /* if filecheck is 0, some necessary data files are missing */
X  if (filecheck == 0) {
X    endgraf();
X    exit(0);
X  }
X
X  /* game restore attempts to restore game if there is an argument */
X  continuing = game_restore(argc,argv);
X
X
X  /* monsters initialized in game_restore if game is being restored */  
X  if (! continuing) {
X    initplayer();
X    initmon0to3();
X    initmon4to7();
X    initmon8to10();
X    init_dungeon();
X    Leveldata[0].generated=TRUE;  
X    Dlevel = 0;
X    Player.x = 32;
X    Player.y = 2;
X    Date = random_range(360);
X    Phase = random_range(24);
X    strcpy(Password,"");
X    mprint("You find yourself on Park Avenue, the City of Rampart.");
X    mprint("'?' for help or commandlist, 'Q' to quit.");
X    show_screen(0);
X  }
X  else mprint("Your adventure continues....");
X
X  
X  timeprint();
X  showflags();
X  drawvision(Player.x,Player.y,Player.vision);
X
X  /* game cycle */
X  while (! Gameover) time_clock();
X  
X  /* clean up curses */
X  endgraf();
X  
X}
X
Xint signalexit()
X{
X  mprint("Yikes!");
X  morewait();
X  mprint("Sorry, caught a core-dump signal.");
X  if (Dlevel==0) {
X    mprint("Want to try and save the game?");
X    if (ynq()=='y')
X      save();
X  }
X  mprint("Bye!");
X  endgraf();
X  exit(0);
X}
X
END_OF_o.c
if test 7142 -ne `wc -c <o.c`; then
    echo shar: \"o.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f ocity.dat -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"ocity.dat\"
else
echo shar: Extracting \"ocity.dat\" \(4162 characters\)
sed "s/^X//" >ocity.dat <<'END_OF_ocity.dat'
X################################################################
X#..............................................................#
X#.######.#######..########..##x....x##.#########..###.###.###..#
X#.######.######x..####x###..###."".###.#########..#######.##x..#
X#.x####x........................"".....#########..#######.###..#
X#.######.######x..#x#..#x#..##x."".###.####........####s.......#
X#.######.#######..###..###..###."".x##.###C.......#######.###..#
X#.................###xx###......"".....###C.......#######.###..#
X#..#######..####..########...#x."".x##.####.......###.###.#x#..#
X#.##2#6#5##.x###.###########.##."".###.#########...............#
X#..#.....#..###x.#.........#...."".x##.#########...............#
X#.####.####.####.#.###.###.#.##."".....#########..##....##...#.#
X#..#3...4#.......#.##x.x##.#.#x."".##.............###MM###..##.#
X#.####.####.##...............##."".##..######..##..######..#x#.#
X#....#.#....##...#.##x.x##.#.#x."".x#..#####x..###..####..####.#
X#................#.###.###.#.##."".##..######........##..#####.#
X#.#S#######.####.#.........#.......##..######.######....####x..#
X#.#S#SSSSS#.####.#####.#####....##.....######.#####x#..#x###.#.#
X#.#S#S###S#.###x................##.............................#
X#.#S#SSS#S#.####.....#B#....####################################
X#.#S#####S#.........#####...............................G.G.G.XY
X#.#SSSSSSS#.######..#####................................G.G.GXY
X#.#########.######...###....####################################
X#..............................................................#
X#."""""""""""""""""""""""""".......###########.###.###########.#
X#.'"""""""""""""""""""""""'".......#####x#####.###.#####x#####.#
X#.'"......................'"...................................#
X#.'"."""".##########."""".'".......######..#######.##x.##x.##x.#
X#.'"."..1.#~~#>>#~~#.1..".'".......x#####..##x#x##.###.###.###.#
X#.'"."""".#~~#SS#~~#."""".'".......######......................#
X#.'"......#111~~111#......'".......######..#####...##...##.###.#
X#.'".""""."..~~~~.."."""".'"...............#####x#.##...##.....#
X#.'".""""."""1..1""".""""1'".......#######......##.####.##x###.#
X#.'".........1..1.........g........x######.#x##....####.####x#.#
X#.'".....................1'".......#######.####.##.##x#.....##.#
X#.'"y"z"""""""""""""""""""'".......x######.x###.##..........##.#
X#.'"."."...".....".".."...'".......#######.####....######...##.#
X#.'"."..."."."-".".?".""".'".......................######.####.#
X#.'"."""""."."?"."."."..".'".......###......###.##........##x#.#
X#.'".".......""".""".""...'".......x##.####.###.##.#x##x#...##.#
X#.'"."-"""""."....."".""".'".......###.x###........######...##.#
X#.'"."?".....".""""""?..".'"...........####.#x##x#.######.#.##.#
X#.'"."""."."""."###"""".".'".......###......######........#....#
X#.'"."..."..?"."#D"^1...".'".......x##.####.....##.##.###.#.##.#
X#.'"."."""""""."###"""""".'".......###.####.###.#x.#x.###...##.#
X#.'"."...?""."."""""".".".'".......x##......###.......##x##.##.#
X#.'".""""""?"........"."?.'".......###..####x##.##.##.#####.##.#
X#.'"."""""""""""""""""""""'"............####...................#
X#.'".S..........S-1$-1$-1>'".......###.......##..###.#######.#.#
X#.'"""""""""""""""""""""""'".......###..####.##..###.####x##.#.#
X#."""""""""""""""""""""""""".......##x##x###.##..#x#.###..##.#.#
X#..............................................................#
X#.####..................####.......##*##*##*##.....######......#
X#.&#&#S#################&#&#.......&#*##*#*#&#...###....###....#
X#.&##S###.#^##############&#.......&#?#?#?#?&#..###..##..###...#
X#.#&.###.#^#V#########&#####.......&#J#J#J#J&#..##..####..##...#
X#..&S##S####-#########&#c..........&#.#.#.#.&#..##..####..##...#
X#..&^#$#####$$$$$$$$##&#c..........&#.......&#..###..##..###...#
X#.#&#.######$$$$$$$$##&#####.......####G.G####..####....####...#
X#.&#######################&#.....................####..####....#
X#.&#&###################&#&#.......###########.....##AA##......#
X#.####..................####.......###########.................#
X#..............................................................#
X################################################################
X
X
END_OF_ocity.dat
if test 4162 -ne `wc -c <ocity.dat`; then
    echo shar: \"ocity.dat\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f olev.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"olev.c\"
else
echo shar: Extracting \"olev.c\" \(21323 characters\)
sed "s/^X//" >olev.c <<'END_OF_olev.c'
X/* omega copyright (c) 1987 by Laurence Raphael Brothers */
X/* olev.c */
X
X#include <stdio.h>
X#include <strings.h>
X#include "oglob.h"
X
X
X/* from oinitmon's */
Xextern void oinitmon0to3(),oinitmon4to7(),oinitmon8to10();
X
X/* from outil */
Xextern int random_range();
Xextern void findspace();
X
X/* from omon */
Xextern void m_status_set(),make_log_npc(),m_pickup();
X
X/* from oitem */
Xextern pob create_object();
Xextern void make_cash();
X
X/* from ogen */
Xextern void clear_level(),clear_dungeon();
X
X/* from oscr */
Xextern void erase_level(),mprint(),morewait(),show_screen();
Xextern char ynq();
Xextern void screencheck(),drawvision(),showflags();
X
X/* from ofile */
Xextern void filescanstring();
X
X/* olev functions */
X/* level creation functions */
Xvoid populate_level(),stock_level(),wandercheck();
Xpmt m_create(),make_creature();
X
X/* save/restore functions */
Xvoid itemusecheck();
Xint save_game(),restore_game(),gameidcheck();
X
Xvoid save_player(),save_player_items(),save_player_spells();
Xvoid save_player_item_knowledge(),save_level_monsters();
Xvoid save_level(),save_item(),save_itemlist();
X
Xvoid restore_player(),restore_player_items(),restore_player_spells();
Xvoid restore_player_item_knowledge(),restore_level_monsters();
Xvoid restore_level(),write_int();
Xint read_int();
Xpob restore_item();
Xpol restore_itemlist();
X
X
X/* If monster is -1, use random monsters, otherwise use that monster id to
X   populate level */
Xvoid populate_level(level,monster)
Xint level;
Xint monster;
X{
X  pml head,tml;
X  int i,j,k,nummonsters=(random_range(level/5)+1)*3+8;
X  head = tml = ((pml) malloc(sizeof(mltype)));
X  if (monster > -1) nummonsters *=2;
X  for(k=0;k<nummonsters;k++) {
X    findspace(&i,&j);
X    if (monster > -1) {
X      Dungeon[level][i][j].creature = make_creature(monster);
X      Dungeon[level][i][j].creature->x = i;
X      Dungeon[level][i][j].creature->y = j;
X      if (m_statusp(Dungeon[level][i][j].creature,SWIMMING)) {
X	Dungeon[level][i][j].locchar = WATER;
X	Dungeon[level][i][j].p_locf = L_WATER;
X      }
X    }
X    else Dungeon[level][i][j].creature = m_create(i,j,FALSE,level);
X    tml->next = ((pml) malloc(sizeof(mltype)));
X    tml->next->m = Dungeon[level][i][j].creature;
X    tml = tml->next;
X  }
X  if (Mlist[level]==NULL) {
X    tml->next = NULL;
X    Mlist[level] = head->next;
X  }
X  else {
X    tml->next = Mlist[level];
X    Mlist[level] = head->next;
X  }
X}
X
Xvoid wandercheck()
X{
X  int x,y;
X  pml tml;
X  if (random_range(NUMLEVELS) < Dlevel) {
X    findspace(&x,&y);
X    tml = ((pml) malloc(sizeof(mltype)));
X    tml->next = Mlist[Dlevel];
X    tml->m = Dungeon[Dlevel][x][y].creature = m_create(x,y,WANDERING,Dlevel);
X    Mlist[Dlevel] = tml;    
X  }
X}
X
X/* make and return an appropriate monster */
X/* eventually to be more intelligent */
Xpmt m_create(x,y,kind,level)
Xint x,y,kind,level;
X{
X  pmt newmonster;
X  int monster_range;
X
X  /* dungeon level --> monster level */
X  level = level/3 + 1;
X
X  switch(level) {
X    case 0:monster_range = ML1; break;
X    case 1:monster_range = ML2; break;
X    case 2:monster_range = ML3; break;
X    case 3:monster_range = ML4; break;
X    case 4:monster_range = ML5; break;
X    case 5:monster_range = ML6; break;
X    case 6:monster_range = ML7; break;
X    case 7:monster_range = ML8; break;
X    case 8:monster_range = ML9; break;
X    case 9:monster_range = ML10; break;
X    default:monster_range = NUMMONSTERS; break;
X  }
X  do 
X    newmonster = make_creature(random_range(monster_range));
X  while (Monsters[newmonster->id].uniqueness != 0); 
X  /*only nonunique with this */
X  if (kind == WANDERING) m_status_set(newmonster,WANDERING);
X  newmonster->x = x;
X  newmonster->y = y;
X  return(newmonster);
X}
X
X/* make creature # mid */
Xpmt make_creature(mid)
Xint mid;
X{
X  pmt newmonster = ((pmt) malloc(sizeof(montype)));
X  pob ob;
X  int i,treasures;
X
X  *newmonster = Monsters[mid];
X
X  if (mid == ML0+4)
X    make_log_npc(newmonster);
X  else {
X    if (newmonster->sleep < random_range(100))
X      m_status_set(newmonster,AWAKE);
X    treasures = random_range(newmonster->treasure);
X    for(i=0;i<treasures;i++) {
X      ob = ((pob) malloc(sizeof(objtype)));    
X      do ob = ((pob) (create_object())); while (ob->uniqueness != 0);
X      m_pickup(newmonster,ob);
X    }
X  }
X  newmonster->click = (Tick + 1) % 50;
X  return(newmonster);
X}
X
X
X
X
X/* drop treasures randomly onto level */
Xvoid stock_level(level)
Xint level;
X{
X  int i,j,k=0,numtreasures=2*random_range(Dlevel/4)+4;
X
X  /* put cash anywhere, including walls, put other treasures only on floor */
X  for (k=0;k<numtreasures;k++) {
X    do {
X      i = random_range(WIDTH);
X      j = random_range(LENGTH);
X    } while (Dungeon[level][i][j].locchar != FLOOR);
X    Dungeon[level][i][j].things = ((pol) malloc(sizeof(oltype)));
X    Dungeon[level][i][j].things->thing = ((pob) create_object());
X    Dungeon[level][i][j].things->next = NULL;
X    i = random_range(WIDTH);
X    j = random_range(LENGTH);
X    Dungeon[level][i][j].things = ((pol) malloc(sizeof(oltype)));
X    Dungeon[level][i][j].things->thing = ((pob) malloc(sizeof(objtype)));
X    make_cash(Dungeon[level][i][j].things->thing,level);
X    Dungeon[level][i][j].things->next = NULL;
X  }
X}
X
X
X/**************** SAVE AND RESTORE FUNCTIONS ***************/
X/**************** SAVE FUNCTIONS */
X
X/* writes integers to file using putc instead of fprintf */
Xvoid write_int(fd,d)
XFILE *fd;
Xint d;
X{
X  int sign;
X  if (d > 0) sign = 0;
X  else {
X    sign = 64;
X    d = -d;
X  }
X  while (d > 63) {
X    putc(((char) (d % 128)),fd);
X    d = d/128;
X  }
X  putc(((char) (128+sign+d)),fd);
X}
X
X
X
X/* Checks to see if save file already exists.
X   Checks to see if save file can be opened for write.
X   Checks to see if gameid in file is same as gameid in omega.saves;
X if it isn't, only WIZARD can restore game. If it is, and
X  DESTRUCTIVE_RESTORE is set, then that gameid is removed from
X  omega.saves (done in gameidcheck()).
X   After all, this, the player, the city level, and the player's
X  current level are saved. All other levels will be regenerated.
X*/
X    
Xint save_game(savestr)
Xchar *savestr;
X{
X  int writeok=TRUE,gameid;
X  FILE *fd=fopen(savestr,"r");
X  FILE *fd2;
X  if (fd != NULL) {
X    mprint("Overwrite old file?");
X    writeok = (ynq() == 'y');
X    fclose(fd);
X  }
X  if (writeok) {
X    fd=fopen(savestr,"w");
X    if (fd == NULL) {
X      writeok = FALSE;
X      mprint("Error opening file.");
X    }
X  }
X  if (! writeok)
X    mprint("Save aborted.");
X  else {
X    /* keep track of player saves, use a game id */
X    strcpy(Str3,OMEGALIB);
X    strcat(Str3,"omega.saves");
X    fd2 = fopen(Str3,"a");
X    gameid = random_range(32000)+random_range(32000);
X    write_int(fd2,gameid);
X    fclose(fd2);
X
X    /* write the version number */
X    fprintf(fd,"%d\n",VERSION);
X    /* write game id to save file */
X    fprintf(fd,"%d\n",gameid);
X    save_player(fd);
X    save_level(fd,0);
X    save_level(fd,Dlevel);
X    fclose(fd);
X    mprint("Game Saved.");
X    morewait();
X  }
X  return(writeok);
X}
X
X
X    
X
X	
X
X
X
X/* Look for incidence of game id in omega.saves, if it appears zero or one
Xtimes it is ok to restore. Twice and it is invalid to restore if not
Ximplementor. If it is ok to restore, and DESTUCTIVE_RESTORE is #defined
Xto be true, the game id is appended enough times to make precisely two in 
Xthe file. Note that this allows the file owner simply to delete it,
Xthus validating all saved games. */
X
Xint gameidcheck(gameid)
Xint gameid;
X{
X  FILE *fd;
X  int i,id,found=0;
X
X  strcpy(Str2,OMEGALIB);
X  strcat(Str2,"omega.saves");
X  fd = fopen(Str2,"r");
X  if (fd != NULL) {
X    /* note read_int returns -1 on EOF */
X    while ((id = read_int(fd)) > -1)
X      if (gameid == id) found++;
X    fclose(fd);
X
X    if (DESTRUCTIVE_RESTORE && found < 2) {
X      fd = fopen(Str2,"a");
X      for(i=0;i<2-found;i++)
X	write_int(fd,gameid);
X      return((found<2) || (strcmp(getlogin(),WIZARD)==0));
X    }
X  }
X  else {
X    mprint("No omega.saves file! But I'll restore your game anyhow.");
X    return(TRUE);
X  }
X}
X      
X  
X
X
X/* also saves some globals like Dlevel... */
X
Xvoid save_player(fd)
XFILE *fd;
X{
X  int i;
X  fprintf(fd,"%s\n",Player.name);
X  fprintf(fd,"%s\n",Password);
X  putc(Player.preference,fd);
X  write_int(fd,Dlevel);
X  write_int(fd,Wizard);
X  write_int(fd,Cheated);
X  write_int(fd,Time);
X  write_int(fd,Tick);
X  write_int(fd,Phase);
X  write_int(fd,Date);
X  write_int(fd,Gymcredit);
X  write_int(fd,Balance);
X  write_int(fd,Bank_Broken);
X  write_int(fd,Deepest);
X  write_int(fd,Clubmember);
X  write_int(fd,Sawdruid);
X  write_int(fd,Soldcondo);
X  write_int(fd,Player.str);
X  write_int(fd,Player.con);
X  write_int(fd,Player.dex);
X  write_int(fd,Player.agi);
X  write_int(fd,Player.iq);
X  write_int(fd,Player.pow);
X  write_int(fd,Player.hp);
X  write_int(fd,Player.maxstr);
X  write_int(fd,Player.maxcon);
X  write_int(fd,Player.maxdex);
X  write_int(fd,Player.maxagi);
X  write_int(fd,Player.maxiq);
X  write_int(fd,Player.maxpow);
X  write_int(fd,Player.maxhp);
X  write_int(fd,Player.xp);
X  write_int(fd,Player.x);
X  write_int(fd,Player.y);
X  write_int(fd,Player.click);
X  write_int(fd,Player.level);
X  write_int(fd,Player.vision);
X  write_int(fd,Player.food);
X  write_int(fd,abs(Player.alignment));
X  putc(Player.alignment > 0 ? '+' : '-',fd);
X  write_int(fd,Player.mana);
X  write_int(fd,Player.cash);
X  write_int(fd,Player.patron);
X  write_int(fd,Player.sx);
X  write_int(fd,Player.sy);
X  write_int(fd,Player.slevel);
X  write_int(fd,Player.options);
X  for(i=0;i<NUMIMMUNITIES;i++)
X    write_int(fd,Player.immunity[i]);
X  for(i=0;i<NUMSTATI;i++)
X    write_int(fd,Player.status[i]);
X  for(i=0;i<NUMRANKS;i++)
X    write_int(fd,Player.rank[i]);
X
X  save_itemlist(fd,Condoitems);
X  save_player_items(fd);
X  save_player_item_knowledge(fd);
X  save_player_spells(fd);
X}
X
X
Xvoid save_player_items(fd)
XFILE *fd;
X{
X  int i;
X  for(i=0;i<MAXITEMS;i++) save_item(fd,Player.possessions[i]);
X}
X
X
Xvoid save_player_item_knowledge(fd)
XFILE *fd;
X{
X  int i;
X  for (i=0;i<TOTALITEMS;i++)
X    putc(((char)Objects[i].known),fd);
X}
X
Xvoid save_player_spells(fd)
XFILE *fd;
X{
X  int i;
X  for (i=0;i<NUMSPELLS;i++){
X    putc(((char)Spells[i].known),fd);
X    putc(((char)Spells[i].powerdrain),fd);
X  }
X}
X
X
Xvoid save_level(fd,level)
XFILE *fd;
Xint level;
X{
X  int i,j;
X
X  write_int(fd,level);
X  write_int(fd,Leveldata[level].numrooms);
X  write_int(fd,Leveldata[level].tunnelled);  
X
X  for(i=0;i<Leveldata[level].numrooms;i++) {
X    write_int(fd,Leveldata[level].rooms[i-1].lighted);
X    write_int(fd,Leveldata[level].rooms[i-1].rsi);
X    write_int(fd,Leveldata[level].rooms[i-1].top);
X    write_int(fd,Leveldata[level].rooms[i-1].bottom);
X    write_int(fd,Leveldata[level].rooms[i-1].left);
X    write_int(fd,Leveldata[level].rooms[i-1].right);
X  }
X  
X  for(j=0;j<LENGTH;j++)
X    for(i=0;i<WIDTH;i++) {
X      if ((Dungeon[level][i][j].locchar == WALL) &&
X	  (Dungeon[level][i][j].aux == level*2) &&
X	  (Dungeon[level][i][j].seen == TRUE) &&
X	  (Dungeon[level][i][j].showchar == WALL) &&
X	  (Dungeon[level][i][j].p_locf == L_NO_OP) &&
X	  (Dungeon[level][i][j].stopsrun == FALSE) &&
X	  (Dungeon[level][i][j].secret == FALSE) &&
X	  (Dungeon[level][i][j].roomnumber == RS_WALLSPACE))
X	putc('2',fd);
X      else if ((Dungeon[level][i][j].locchar == WALL) &&
X	  (Dungeon[level][i][j].seen == FALSE) &&
X	  (Dungeon[level][i][j].aux == level*2) &&
X	  (Dungeon[level][i][j].showchar == SPACE) &&
X	  (Dungeon[level][i][j].p_locf == L_NO_OP) &&
X	  (Dungeon[level][i][j].stopsrun == FALSE) &&
X	  (Dungeon[level][i][j].secret == FALSE) &&
X	  (Dungeon[level][i][j].roomnumber == RS_WALLSPACE))
X	putc('3',fd);
X      else {
X	putc(Dungeon[level][i][j].locchar,fd);
X	putc(Dungeon[level][i][j].seen,fd);
X	putc(Dungeon[level][i][j].showchar,fd);
X	putc(Dungeon[level][i][j].p_locf,fd);
X	putc(Dungeon[level][i][j].stopsrun,fd);
X	putc(Dungeon[level][i][j].secret,fd);
X	putc(Dungeon[level][i][j].roomnumber,fd);
X	write_int(fd,Dungeon[level][i][j].aux);
X      }
X      save_itemlist(fd,Dungeon[level][i][j].things);
X    }
X  save_level_monsters(fd,level);
X}
X  
X
Xvoid save_level_monsters(fd,level)
XFILE *fd;
Xint level;
X{
X  pml ml;
X  int nummonsters = 0;
X  
X  for(ml=Mlist[level];ml!=NULL;ml=ml->next)nummonsters++;
X
X  write_int(fd,nummonsters);
X
X  for(ml=Mlist[level];ml!=NULL;ml=ml->next) {
X    write_int(fd,ml->m->id);
X    write_int(fd,ml->m->hp);
X    write_int(fd,ml->m->status);
X    write_int(fd,ml->m->x);
X    write_int(fd,ml->m->y);
X    write_int(fd,ml->m->click);
X    write_int(fd,ml->m->attacked);
X    write_int(fd,ml->m->talkf);
X    write_int(fd,ml->m->movef);
X    write_int(fd,ml->m->meleef);
X    write_int(fd,ml->m->specialf);
X    save_itemlist(fd,ml->m->possessions);
X  }
X}
X
Xvoid save_item(fd,o)
XFILE *fd;
Xpob o;
X{
X  if (o != NULL) {
X    putc('*',fd);
X    write_int(fd,o->id);
X    write_int(fd,o->plus);
X    write_int(fd,o->used);
X    write_int(fd,o->usef);
X    write_int(fd,o->known);
X    write_int(fd,o->charge);
X    write_int(fd,o->blessing);
X    write_int(fd,o->aux);
X    write_int(fd,o->number);
X  }
X  else putc('#',fd);
X}
X
X
X
Xvoid save_itemlist(fd,ol)
XFILE *fd;
Xpol ol;
X{
X  while (ol != NULL) {
X    putc('$',fd);
X    save_item(fd,ol->thing);
X    ol = ol->next;
X  }
X  putc('&',fd);
X}
X
X
X
X
X
X
X/************************ RESTORE FUNCTIONS *************************
X/* reads integers from getc's */
X/* explicitly returns -1 on EOF */
Xint read_int(fd)
XFILE *fd;
X{
X  int d,e,mult=1;
X  d=0;
X  while (((e = getc(fd)) < 128) && (e != EOF)) {
X    d = d+mult*e;	
X    mult=mult*128;
X  }
X  if (e == EOF)
X    return(-1);
X  else {
X   e = e-128;
X   if (e > 63) return(-((e-64)*mult+d));
X   else return(e*mult+d);
X }
X}
X
X
X
X/* read player data, city level, dungeon level,
X   check on validity of save file, etc.
X   return TRUE if game restored, FALSE otherwise */
X
Xint restore_game(savestr)
Xchar *savestr;
X{
X  int i,version,gameid; 
X  FILE *fd = fopen(savestr,"r");
X
X  if (fd == NULL) {
X    mprint("Error restoring game -- aborted.");
X    return(FALSE);
X  }
X  else {
X    mprint("Restoring....");
X
X    fscanf(fd,"%d\n",&version);
X    fscanf(fd,"%d\n",&gameid);
X    if (VERSION != version) {
X      mprint("Sorry, I can't restore an outdated save file!");
X      return(FALSE);
X    }
X    else if (! gameidcheck(gameid)) 
X      mprint("Sorry. Only the omega WIZARD can restore this file.");
X    else {
X      for(i=0;i<NUMLEVELS;i++)
X	Leveldata[i].generated = FALSE;
X      restore_player(fd);
X      initmon0to3();
X      initmon4to7();
X      initmon8to10();
X      restore_level(fd);
X      restore_level(fd);
X      mprint("Restoration complete");
X      WhichScreen = -1;
X      screencheck(Player.y);
X      drawvision(Player.x,Player.y,Player.vision);
X      dataprint();
X      showflags();
X      fclose(fd);
X      return(TRUE);
X    }
X  }
X}
X
X
X
Xvoid restore_player(fd)
XFILE *fd;
X{
X  int i;
X  filescanstring(fd,Player.name);
X  filescanstring(fd,Password);
X  Player.preference=((char) getc(fd));
X  Dlevel = read_int(fd);
X  Wizard =  read_int(fd);
X  Cheated = read_int(fd);
X  Time = read_int(fd);
X  Tick = read_int(fd);
X  Phase = read_int(fd);
X  Date = read_int(fd);
X  Gymcredit = read_int(fd);
X  Balance = read_int(fd);
X  Bank_Broken = read_int(fd);
X  Deepest = read_int(fd);
X  Clubmember = read_int(fd);
X  Sawdruid = read_int(fd);
X  Soldcondo = read_int(fd);
X  Player.str = read_int(fd);
X  Player.con = read_int(fd);
X  Player.dex = read_int(fd);
X  Player.agi = read_int(fd);
X  Player.iq = read_int(fd);
X  Player.pow = read_int(fd);
X  Player.hp = read_int(fd);
X  Player.maxstr = read_int(fd);
X  Player.maxcon = read_int(fd);
X  Player.maxdex = read_int(fd);
X  Player.maxagi = read_int(fd);
X  Player.maxiq = read_int(fd);
X  Player.maxpow = read_int(fd);
X  Player.maxhp = read_int(fd);
X  Player.xp = read_int(fd);
X  Player.x = read_int(fd);
X  Player.y = read_int(fd);
X  Player.click = read_int(fd);
X  Player.level = read_int(fd);
X  Player.vision = read_int(fd);
X  Player.food = read_int(fd);
X  Player.alignment = read_int(fd);
X  Player.alignment *= (((char) getc(fd)) == '+' ? 1 : -1);
X  Player.mana = read_int(fd);
X  Player.maxmana = calcmana();
X  Player.cash = read_int(fd);
X  Player.patron = read_int(fd);
X  Player.sx = read_int(fd);
X  Player.sy = read_int(fd);
X  Player.slevel = read_int(fd);
X  Player.options = read_int(fd);
X  for(i=0;i<NUMIMMUNITIES;i++)
X    Player.immunity[i] = read_int(fd);
X  for(i=0;i<NUMSTATI;i++)
X    Player.status[i] = read_int(fd);
X  for(i=0;i<NUMRANKS;i++)
X    Player.rank[i] = read_int(fd);
X
X  Condoitems = restore_itemlist(fd);
X  restore_player_items(fd);
X  restore_player_item_knowledge(fd);
X  itemusecheck();
X  restore_player_spells(fd);
X  calc_melee();
X}
X
X
X
Xvoid restore_player_items(fd)
XFILE *fd;
X{
X  int i;
X  Player.itemweight = 0;
X  for(i=0;i<MAXITEMS;i++) {
X    Player.possessions[i] = restore_item(fd);
X    if (Player.possessions[i] != NULL)
X      Player.itemweight += 
X	Player.possessions[i]->number * Player.possessions[i]->weight;
X  }
X}
X
X
X
X
Xvoid itemusecheck()
X{
X  int i;
X  
X  for(i=0;i<MAXITEMS;i++)
X    if (Player.possessions[i] != NULL)
X      if (Player.possessions[i]->used)
X      switch(Player.possessions[i]->objchar) {
X      case ARMOR:
X	Player.armor = Player.possessions[i];
X	break;
X      case WEAPON: case MISSILE:
X	Player.primary = Player.possessions[i];
X	break;
X      case SHIELD:
X	Player.secondary = Player.possessions[i];
X	break;
X      case CLOAK:
X	Player.cloak = Player.possessions[i];
X	break;
X      case BOOTS:
X	Player.boots = Player.possessions[i];
X	break;
X      }
X}
X
X
Xvoid restore_player_item_knowledge(fd)
XFILE *fd;
X{
X  int i;
X  char c;
X  for (i=0;i<TOTALITEMS;i++) {
X    Objects[i].known =  getc(fd);
X  }
X}
X
X
X
Xvoid restore_player_spells(fd)
XFILE *fd;
X{
X  int i;
X  char c,d;
X  for (i=0;i<NUMSPELLS;i++) {
X    Spells[i].known =  getc(fd);
X    Spells[i].powerdrain = getc(fd);
X  }
X}
X
X
X
Xvoid restore_level(fd)
XFILE *fd;
X{
X  int i,j,level;
X  char c,d;
X
X  level = read_int(fd);
X  Leveldata[level].numrooms = read_int(fd);
X  Leveldata[level].tunnelled = read_int(fd);
X
X  Leveldata[level].generated = TRUE;
X  
X  for(i=0;i<Leveldata[level].numrooms;i++) {
X    Leveldata[level].rooms[i-1].lighted = read_int(fd);
X    Leveldata[level].rooms[i-1].rsi = read_int(fd);
X    Leveldata[level].rooms[i-1].top = read_int(fd);
X    Leveldata[level].rooms[i-1].bottom = read_int(fd);
X    Leveldata[level].rooms[i-1].left = read_int(fd);
X    Leveldata[level].rooms[i-1].right = read_int(fd);
X  }
X  
X  for(j=0;j<LENGTH;j++) 
X    for(i=0;i<WIDTH;i++) {
X      Dungeon[level][i][j].locchar = ((char) getc(fd));
X      if (Dungeon[level][i][j].locchar == '2') {
X	Dungeon[level][i][j].locchar = WALL;
X	Dungeon[level][i][j].aux = level*2;
X	Dungeon[level][i][j].seen = TRUE;
X	Dungeon[level][i][j].showchar = WALL;
X	Dungeon[level][i][j].p_locf = L_NO_OP;
X	Dungeon[level][i][j].stopsrun = FALSE;
X	Dungeon[level][i][j].secret = FALSE;
X	Dungeon[level][i][j].roomnumber = RS_WALLSPACE;
X      }
X      else if (Dungeon[level][i][j].locchar == '3') {
X	Dungeon[level][i][j].locchar = WALL;
X	Dungeon[level][i][j].aux = level*2;
X	Dungeon[level][i][j].seen = FALSE;
X	Dungeon[level][i][j].showchar = SPACE;
X	Dungeon[level][i][j].p_locf = L_NO_OP;
X	Dungeon[level][i][j].stopsrun = FALSE;
X	Dungeon[level][i][j].secret = FALSE;
X	Dungeon[level][i][j].roomnumber = RS_WALLSPACE;
X      }
X      else {
X	Dungeon[level][i][j].seen = ((char) getc(fd));
X	Dungeon[level][i][j].showchar = ((char) getc(fd));
X	Dungeon[level][i][j].p_locf = ((char) getc(fd));
X	Dungeon[level][i][j].stopsrun = ((char) getc(fd));
X	Dungeon[level][i][j].secret = ((char) getc(fd));
X	Dungeon[level][i][j].roomnumber = ((char) getc(fd));
X	Dungeon[level][i][j].aux = read_int(fd);
X      }
X      Dungeon[level][i][j].things = restore_itemlist(fd);
X    }
X  restore_level_monsters(fd,level);
X}
X
X
X
X
Xvoid restore_level_monsters(fd,level)
XFILE *fd;
Xint level;
X{
X  pml ml;
X  pmt m;
X  int i,nummonsters;
X  char c;
X
X  Mlist[level] = NULL;
X
X  nummonsters = read_int(fd);
X  
X  for(i=0;i<nummonsters;i++) {
X    ml = ((pml) malloc(sizeof(mltype)));
X    m = ((pmt) malloc(sizeof(montype)));
X    ml->m = m;
X    ml->next = NULL;
X    ml->m->id = read_int(fd);
X    *(ml->m) = Monsters[ml->m->id];
X    ml->m->hp = read_int(fd);
X    ml->m->status = read_int(fd);
X    ml->m->x = read_int(fd);
X    ml->m->y = read_int(fd);
X    ml->m->click = read_int(fd);
X    ml->m->attacked = read_int(fd);
X    ml->m->talkf = read_int(fd);
X    ml->m->movef = read_int(fd);
X    ml->m->meleef = read_int(fd);
X    ml->m->specialf = read_int(fd);
X    ml->m->possessions = restore_itemlist(fd);
X    ml->next = Mlist[level];
X    Mlist[level] = ml;
X  }
X}
X
X
X
Xpob restore_item(fd)
XFILE *fd;
X{
X  pob o;
X  char c;
X  if (((char) getc(fd)) != '*') return(NULL);
X  else {
X    o = ((pob) malloc(sizeof(objtype)));
X    o->id = read_int(fd);
X    *o = Objects[o->id];
X    o->plus = read_int(fd);
X    o->used = read_int(fd);
X    o->usef = read_int(fd);
X    o->known = read_int(fd);
X    o->charge = read_int(fd);
X    o->blessing = read_int(fd);
X    o->aux = read_int(fd);
X    o->number = read_int(fd);
X    if (o->id == CORPSEID) {
X      strcpy(o->objstr,Monsters[o->aux].corpsestr);
X      strcpy(o->truename,Monsters[o->aux].corpsestr);
X      strcpy(o->cursestr,Monsters[o->aux].corpsestr);
X    }
X    return(o);
X  }
X}
X
X
X
Xpol restore_itemlist(fd)
XFILE *fd;
X{
X  pol head=NULL;
X  pol ol=NULL;
X
X  while (((char) getc(fd)) == '$') {
X    if (ol == NULL) {
X      ol = ((pol) malloc(sizeof(oltype)));
X      head = ol;
X    }
X    else {
X      ol->next = ((pol) malloc(sizeof(oltype)));
X      ol = ol->next;
X    }
X    ol->thing = restore_item(fd);
X    ol->next = NULL;
X  }
X  return(head);
X}
X
X
END_OF_olev.c
if test 21323 -ne `wc -c <olev.c`; then
    echo shar: \"olev.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f omega.compilation.notes -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"omega.compilation.notes\"
else
echo shar: Extracting \"omega.compilation.notes\" \(3237 characters\)
sed "s/^X//" >omega.compilation.notes <<'END_OF_omega.compilation.notes'
XFirst I should note that omega is copyrighted; you are using this
Xprogram under the terms of the license, hopefully included in the file
Xomega.license.
X
Xomega is set up for compilation under Sun's unix; some changes may be
Xnecessary for correct functioning under other unixes. I have included
Xsome ifdef lines in odefs.h that ought to have some positive effect.
XHowever, not having anything besides a sun to test omega on, I will
Xhave to rely on your feedback as to the effect.
X
XFor some reason, some systems have <string.h> instead of <strings.h>
Xso you may have to include the former instead of the latter in
Xmost modules.
X
XTo implement omega on your system:
X
X0) Make sure you have the files listed in the file called MANIFEST.
XIf you don't have these files, you lose! Get them from somewhere. In
Xparticular, it is a violation of the license not to have a copy of
Xomega.license.
X
X0) Change omega.motd to say whatever you like. Create a null file
Xcalled omega.saves, publically readable and writeable. 
X
X1) Set up a directory for omega's data files. Protection must allow the
Xgeneral public to create files in it, and otherwise can allow access
Xas per file protection. omega does not use setuid.
X
X2) Change the first few #define's in odefs.h to conform to the 
Xdata file directory, your user name, etc, as the comments in the file
Xdiscuss.
X
X3) with Makefile, *.h, and *.c in one directory, make should produce
Xan executable file omega. If you get errors, you'll have to work them
Xout for yourself....
X
X4) All the files which are not *.h, *.c, and Makefile should have at
Xthe least public read access. The following files should have write
Xaccess as well:
X
Xomega.saves
Xomega.hiscores
Xomega.log
Xomega.lognum
X
X5) At this point, omega should be ready to run.
X
X6) As the implementor (or whoever's user name is defined as WIZARD in
Xodefs.h), you have the ability to toggle wizard mode with ^g (^x
Xwill then give you a wish, and ^w will display the current dungeon
Xlevel), and you also have the ability to restore games that omega
Xthinks have been copied. If someone wants you to restore a game for
Xthem, simply restore the game as usual, and then save it again. This
Xsaved game should be restorable by anyone.
X
X7) Send any questions to brothers@paul.rutgers.edu.
X
XGood luck -- and let's be careful out there, shall we?
X
X
X
XNOTES TO THE WIZARD
X===================
X
X^g toggles wizard mode during game play. If you ever set wizard mode, your
Xhigh score and npc will not be saved.
X
XIn wizard mode, ^x gives you a wish. ^w draws the current level.
X
XThe wizard is allowed to restore games regardless of the settings of
XDESTRUCTIVE_RESTORE and how many times the file has been copied.
XTherefore, if you want to restore a game for some user, simply restore
Xfrom their file and immediately save again. Details like inode and
Xuserid are not saved with the file, so the user will be able to simply
Xcopy the file you just saved. 
X
XNote that it is possible for some random person to maliciously restore
Xsomeone else's saved game (if it is not protected), causing
Xomega.saves to think that it should not allow that game to be restored
Xwhen the rightful file owner tries to do it. This could be easily
Xfixed if I wasn't so lazy, but shouldn't happen anyway.
END_OF_omega.compilation.notes
if test 3237 -ne `wc -c <omega.compilation.notes`; then
    echo shar: \"omega.compilation.notes\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f omega.license -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"omega.license\"
else
echo shar: Extracting \"omega.license\" \(1115 characters\)
sed "s/^X//" >omega.license <<'END_OF_omega.license'
Xomega
X=====
X
XGeneral Public License:
X
Xomega is copyright (C) 1987 by Laurence R. Brothers
X
XAll rights are reserved, save the following permissions:
X
XFree copying: Anyone may make a copy of omega, and distribute the
Xcopy, so long as this license remains accessible (via the 'P'
Xcommand).
X
XModification: No one may modify omega except inasmuch as may be
Xnecessary to cause omega to function in any given computer
Xenvironment.  'Porting' is therefore freely allowed. Any such
Xmodifications will be considered 'works for hire' and the modifiers
Xwill have no rights of ownership over such modifications. I
Xspecifically note that no compensation in any form will be rendered to
Xthose who make such allowed changes to omega. All other modifications
Xare in violation of this license.
X
XWarranty: No warranty is made for omega's operation. Any damages
Xincurred in the use of omega or in its implementation are solely the
Xresponsibility of the end-user.
X
XCoverage: Anyone who compiles, runs, copies, or in any other way
Xmanipulates any copy of omega's code, programs, or files shall be
Xconsidered to be bound by this license.
END_OF_omega.license
if test 1115 -ne `wc -c <omega.license`; then
    echo shar: \"omega.license\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f otime.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"otime.c\"
else
echo shar: Extracting \"otime.c\" \(1595 characters\)
sed "s/^X//" >otime.c <<'END_OF_otime.c'
X/* omega copyright (c) 1987 by Laurence Raphael Brothers */
X
X/* this file deals with the passage of time in omega */
X/* This marks a change toward event-driven action */
X/* otime.c */
X
X#include <strings.h>
X#include "oglob.h"
X
X/* from oscr */
Xvoid drawmonsters(),dataprint();;
X
X/* from omon */
Xvoid m_pulse();
X
X/* from oaux */
Xvoid move_status_check(),hourly_check();
X
Xvoid time_clock();
X
X
X/* This function coordinates monsters and player actions,
Xas well as random events.
X
XThere are 10 clicks to the turn; depending on the speed rating of
Xmonsters and player, they may "go off" from any speed from 1/10 turns
Xto 10 times per turn */
X
Xvoid time_clock()
X{
X  pml ml,tempml,prevml;
X
X  Tick = ((Tick+1) % 50);
X
X  if (Tick % 5 == 0) {
X    move_status_check(); /* see about some player statuses each turn */
X    Time++;
X    if (Time % 100 == 0) hourly_check(); /* 100 moves == 1 hour */
X  }
X  
X  Skipmonsters = FALSE;
X  if (Tick == Player.click) {
X    Player.click = (Player.click + Player.speed) % 50;
X    if (! Skipplayer) do p_process(); while (Skipmonsters);
X  }
X  Skipplayer = FALSE;
X
X  drawmonsters(FALSE);
X
X  /* Check all monsters */
X  ml = Mlist[Dlevel];
X  prevml = ml;
X  while(ml != NULL) {
X    if (ml->m->hp < 1) {
X      tempml = ml;
X      if (ml == Mlist[Dlevel]) Mlist[Dlevel] = Mlist[Dlevel]->next;
X      else prevml->next = ml->next;
X      ml = ml->next;
X      free((char *) tempml->m);
X      free((char *) tempml);
X    }
X    else if (Tick == ml->m->click) {
X      ml->m->click = (ml->m->click + ml->m->speed) % 50;
X      m_pulse(ml->m);
X    }
X    prevml = ml;
X    ml = ml->next;
X  }
X}
X
END_OF_otime.c
if test 1595 -ne `wc -c <otime.c`; then
    echo shar: \"otime.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 15 \(of 15\).
cp /dev/null ark15isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 15 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0