--- omega-rpg-0.90-pa9.orig/char.c
+++ omega-rpg-0.90-pa9/char.c
@@ -17,7 +17,7 @@
   int oldchar=FALSE;
   FILE *fd;
   char *lname;
-  int ret_value = FALSE;
+  int loaded = FALSE;
 #ifndef MSDOS
   struct passwd *dastuff;
 #endif
@@ -81,18 +81,20 @@
     optionset(COMPRESS_OPTION);
 #endif
     optionset(SHOW_COLOUR);
-    ret_value = initstats() ; /* RM 04-19-2000:loading patch */ /* DAG */
+    loaded = initstats() ; /* RM 04-19-2000:loading patch */ /* DAG */
   }
   /* This gets executed when the player loads from .omegarc */
   /* DAG - put the code back in the same place, rather than duplicating */
   Searchnum = max(1,min(9,Searchnum));
-  Player.hp = Player.maxhp = Player.maxcon;
-  Player.mana = Player.maxmana = calcmana();
-  Player.click = 1;
-  strcpy(Player.meleestr,"CCBC");
+  if (!loaded) {
+	  Player.hp = Player.maxhp = Player.maxcon;
+	  Player.mana = Player.maxmana = calcmana();
+	  Player.click = 1;
+	  strcpy(Player.meleestr,"CCBC");
+  }
   calc_melee();
   ScreenOffset = -1000;	/* to force a redraw */
-  return ret_value; /* RM 04-19-2000: loading patch */ /* DAG */
+  return loaded; /* RM 04-19-2000: loading patch */ /* DAG */
 }
 
 
@@ -103,7 +105,7 @@
   if ((fd = fopen("omega.rc","rb")) != NULL) {
     print2("Use omega.rc charcter record in current directory? [yn] ");
 #else
-    sprintf(Str1, "%s/.omegarc", getenv("HOME"));
+    snprintf(Str1, sizeof(Str1)-1, "%s/.omegarc", getenv("HOME"));
     if ((fd = fopen(Str1,"r")) != NULL) {
       print2("Use .omegarc in home directory? [yn] ");
 #endif
@@ -160,7 +162,7 @@
 #if defined(MSDOS) || defined(AMIGA)
   fd = fopen("omega.rc","wb");
 #else
-  sprintf(Str1, "%s/.omegarc", getenv("HOME"));
+  snprintf(Str1, sizeof(Str1)-1, "%s/.omegarc", getenv("HOME"));
   fd = fopen(Str1,"w");
 #endif
   if (fd == NULL)
--- omega-rpg-0.90-pa9.orig/omega.c
+++ omega-rpg-0.90-pa9/omega.c
@@ -22,6 +22,7 @@
 /* most globals originate in omega.c */
 
 char *Omegalib;		/* contains the path to the library files */
+char *Omegavar;		/* contains the path to the highscore and log files */
 
 #ifdef DEBUG
 FILE *DG_debug_log; /* debug log file pointer */
@@ -300,13 +301,13 @@
   } else {
     /* savefile given */
     continuing = 1;
-    strcpy(SaveFileName,argv[optind]);
+    strncpy(SaveFileName,argv[optind],sizeof(SaveFileName)-1);
   }
 
 #else 
   /* alternate code for people who don't support getopt() -- no enhancement */
   if (argc ==2) {
-    strcpy( SaveFileName, argv[1]);
+    strncpy( SaveFileName, argv[1], sizeof(SaveFileName)-1);
     continuing = 1;
   } else {
     strcpy( SaveFileName,"Omega");
@@ -358,6 +359,11 @@
 #endif
     Omegalib = OMEGALIB;
 
+#ifndef FIXED_OMEGALIB
+  if (!(Omegavar = getenv("OMEGAVAR")))
+#endif
+    Omegavar = OMEGAVAR;
+
   /* if filecheck is 0, some necessary data files are missing */
   if (filecheck() == 0) exit(0);
 
--- omega-rpg-0.90-pa9.orig/gen2.c
+++ omega-rpg-0.90-pa9/gen2.c
@@ -243,7 +243,13 @@
     
 
     /* corridor which is guaranteed to connect */
-    findspace(&tx,&ty,i);
+
+    /* If there is no starting point for it, then our current room
+     * might have been big enough to wipe out all previous rooms on
+     * the level (it's rare but possible).  In that case just consider
+     * this the new first room, and continue.  -- Richard Braakman */
+    if (!try_findspace(&tx,&ty,i))
+	continue;
 
     /* figure out where to start corridor from */
     if ((ty <= t) && (tx <= l+e)) {
@@ -390,79 +396,79 @@
         case 4: rsi = RS_FIREPLANE; break;
         case 5: rsi = RS_HIGHASTRAL; break;
         }
+    }
 
-      maze_corridor(1 + random_range(Level->level_width - 1),
-                    1 + random_range(Level->level_length - 1),
-                    1 + random_range(Level->level_width - 1),
-                    1 + random_range(Level->level_length - 1),
-                    rsi,
-                    0);
+  maze_corridor(1 + random_range(Level->level_width - 1),
+                1 + random_range(Level->level_length - 1),
+                1 + random_range(Level->level_width - 1),
+                1 + random_range(Level->level_length - 1),
+                rsi,
+                0);
 
-      if (E_ASTRAL == Current_Dungeon)
+  if (E_ASTRAL == Current_Environment)
+    {
+      for (x_idx = 0; x_idx < Level->level_width; ++x_idx) 
         {
-          for (x_idx = 0; x_idx < Level->level_width; ++x_idx) 
+          for (y_idx = 0; y_idx < Level->level_length; ++y_idx) 
             {
-              for (y_idx = 0; y_idx < Level->level_length; ++y_idx) 
+              if (WALL == Level->site[x_idx][y_idx].locchar)
                 {
-                  if (WALL == Level->site[x_idx][y_idx].locchar)
+                  switch (Level->depth)
                     {
-                      switch (Level->depth)
-                        {
-                        case 1:
-                          Level->site[x_idx][y_idx].aux = 500;
-                          break;
-
-                        case 2: 
-                          Level->site[x_idx][y_idx].locchar = WHIRLWIND;
-                          Level->site[x_idx][y_idx].p_locf = L_WHIRLWIND;
-                          break;
-
-                        case 3: 
-                          Level->site[x_idx][y_idx].locchar = WATER;
-                          Level->site[x_idx][y_idx].p_locf = L_WATER;
-                          break;
-
-                        case 4:
-                          Level->site[x_idx][y_idx].locchar = FIRE;
-                          Level->site[x_idx][y_idx].p_locf = L_FIRE;
-                          break;
-
-                        case 5: 
-                          Level->site[x_idx][y_idx].locchar = ABYSS;
-                          Level->site[x_idx][y_idx].p_locf = L_ABYSS;
-                          break;
-                        }
+                    case 1:
+                      Level->site[x_idx][y_idx].aux = 500;
+                      break;
+
+                    case 2: 
+                      Level->site[x_idx][y_idx].locchar = WHIRLWIND;
+                      Level->site[x_idx][y_idx].p_locf = L_WHIRLWIND;
+                      break;
+
+                    case 3: 
+                      Level->site[x_idx][y_idx].locchar = WATER;
+                      Level->site[x_idx][y_idx].p_locf = L_WATER;
+                      break;
+
+                    case 4:
+                      Level->site[x_idx][y_idx].locchar = FIRE;
+                      Level->site[x_idx][y_idx].p_locf = L_FIRE;
+                      break;
+
+                    case 5: 
+                      Level->site[x_idx][y_idx].locchar = ABYSS;
+                      Level->site[x_idx][y_idx].p_locf = L_ABYSS;
+                      break;
                     }
                 }
+            }
+        }
 
-              switch (Level->depth)
-                {
-                case 1: mid = LORD_EARTH; break; /* Elemental Lord of Earth */
-                case 2: mid = LORD_AIR; break; /* Elemental Lord of Air */
-                case 3: mid = LORD_WATER; break; /* Elemental Lord of Water */
-                case 4: mid = LORD_FIRE; break; /* Elemental Lord of Fire */
-                case 5: mid = ELEM_MASTER; break; /* Elemental Master */
-                default: mid = ELEM_MASTER; assert(FALSE); /* bomb if this happens */
-                }
+      switch (Level->depth)
+        {
+        case 1: mid = LORD_EARTH; break; /* Elemental Lord of Earth */
+        case 2: mid = LORD_AIR; break; /* Elemental Lord of Air */
+        case 3: mid = LORD_WATER; break; /* Elemental Lord of Water */
+        case 4: mid = LORD_FIRE; break; /* Elemental Lord of Fire */
+        case 5: mid = ELEM_MASTER; break; /* Elemental Master */
+        default: mid = ELEM_MASTER; assert(FALSE); /* bomb if this happens */
+        }
 
-              if (5 == Level->depth)
-                {
-                  findspace(&tx, &ty, -1);
-                  Level->site[tx][ty].p_locf = L_ENTER_CIRCLE;
-                  Level->site[tx][ty].locchar = STAIRS_DOWN;
-                }
+      if (5 == Level->depth)
+        {
+          findspace(&tx, &ty, -1);
+          Level->site[tx][ty].p_locf = L_ENTER_CIRCLE;
+          Level->site[tx][ty].locchar = STAIRS_DOWN;
+        }
 
-              if (!gamestatusp(COMPLETED_ASTRAL))
-                {
-                  findspace(&tx, &ty, -1);
-                  Level->mlist = checkmalloc(sizeof(mltype));
-                  Level->mlist->next = NULL;
-                  Level->mlist->m = make_creature(mid);
-                  Level->mlist->m->x = tx;
-                  Level->mlist->m->y = ty;
-                  Level->site[tx][ty].creature = Level->mlist->m;
-                }
-            }
+      if (!gamestatusp(COMPLETED_ASTRAL))
+        {
+          findspace(&tx, &ty, -1);
+          Level->mlist = checkmalloc(sizeof(mltype));
+          Level->mlist->next = NULL;
+          Level->mlist->m = make_creature(mid);
+          Level->mlist->m->x = tx;
+          Level->mlist->m->y = ty;
+          Level->site[tx][ty].creature = Level->mlist->m;
         }
     }
   else if (E_VOLCANO == Current_Environment)
--- omega-rpg-0.90-pa9.orig/file.c
+++ omega-rpg-0.90-pa9/file.c
@@ -14,6 +14,7 @@
 #  include <curses.h>
 # endif
 # include <sys/types.h>
+# include <sys/stat.h>
 # include <unistd.h>
 # include <sys/file.h>
 # include <fcntl.h>
@@ -160,13 +161,13 @@
 
   FILE * lockfile;
 
-  strcpy(Str1,Omegalib);
+  strcpy(Str1,Omegavar);
   strcat(Str1,"omega.hi.lock");
 
   do
     {
       /* create lock file */
-      lock = open(Str1, O_CREAT | O_EXCL, 0600);
+      lock = open(Str1, O_WRONLY | O_CREAT | O_EXCL, 0600);
       if (lock < 0 && errno == EEXIST)
         {
           lockfile = fopen(Str1, "rb");
@@ -206,7 +207,7 @@
 void unlock_score_file(void)
 {
 #ifndef MSDOS
-    strcpy(Str1,Omegalib);
+    strcpy(Str1,Omegavar);
     strcat(Str1,"omega.hi.lock");
     unlink(Str1);
 #endif
@@ -218,7 +219,7 @@
   int i;
 
   lock_score_file();
-  strcpy(Str1,Omegalib);
+  strcpy(Str1,Omegavar);
   strcat(Str1,"omega.hi");
   fd = checkfopen(Str1,"rb");
   filescanstring(fd,Hiscorer);
@@ -302,10 +303,10 @@
   if (gamestatusp(CHEATED))
       return;
   lock_score_file();
-  strcpy(Str1,Omegalib);
+  strcpy(Str1,Omegavar);
   strcat(Str1,"omega.hi");
   infile = checkfopen(Str1,"rb");
-  strcpy(Str2,Omegalib);
+  strcpy(Str2,Omegavar);
 #ifdef MSDOS
   strcat(Str2,"omegahi.new");	/* stupid 8.3 msdos filename limit */
 #else
@@ -377,6 +378,7 @@
   }
   fclose(infile);
   fclose(outfile);
+  chmod(Str2, 0664);
   unlink(Str1);
 #if defined(MSDOS) || defined(AMIGA)
   rename(Str2, Str1);
@@ -434,7 +436,7 @@
     change_to_game_perms();
     npcbehavior=fixnpc(lifestatus);
     checkhigh(descrip,npcbehavior);
-    strcpy(Str1,Omegalib);
+    strcpy(Str1,Omegavar);
     strcat(Str1,"omega.log");
     fd = checkfopen(Str1,"a");
     fprintf(fd, " %d %d %d %s\n", lifestatus, Player.level, npcbehavior,
@@ -496,10 +498,15 @@
 
 char *required_file_list[] =
 {
-  "maps.dat", "omega.hi", "omega.log", "motd.txt",
+  "maps.dat", "motd.txt",
   "license.txt", NULL
 };
 
+char *required_writeable[] =
+{
+  "omega.hi", "omega.log", NULL
+};
+		
 char *optional_file_list[] =
 {
   "help1.txt", "help2.txt", "help3.txt", "help4.txt", "help5.txt",
@@ -516,24 +523,30 @@
     int endpos;
     int file;
 
-    strcpy(Str1, Omegalib);
+    strcpy(Str1, Omegavar);
     endpos = strlen(Str1);
-    for (file = 0; required_file_list[file]; file++)
+    for (file = 0; required_writeable[file]; file++)
     {
-	strcpy(&(Str1[endpos]), required_file_list[file]);
-	if ((strcmp(required_file_list[file], "omega.hi") == 0 ||
-	    strcmp(required_file_list[file], "omega.log") == 0) &&
-	    test_file_access(Str1, 'w') == 0)
+	strcpy(&(Str1[endpos]), required_writeable[file]);
+	if (test_file_access(Str1, 'w') == 0)
 	{
 	    impossible = TRUE;
 	    printf("\nError! File not appendable or accessible: %s", Str1);
 	}
-	else if (test_file_access(Str1, 'r') == 0)
+    }
+
+    strcpy(Str1, Omegalib);
+    endpos = strlen(Str1);
+    for (file = 0; required_file_list[file]; file++)
+    {
+	strcpy(&(Str1[endpos]), required_file_list[file]);
+	if (test_file_access(Str1, 'r') == 0)
 	{
 	    impossible = TRUE;
 	    printf("\nError! File not accessible: %s", Str1);
 	}
     }
+
     for (file = 0; optional_file_list[file]; file++)
     {
 	strcpy(&(Str1[endpos]), optional_file_list[file]);
@@ -545,13 +558,13 @@
     }
     if (impossible) {
 	printf("\nFurther execution is impossible. Sorry.");
-	if (strcmp(Omegalib, OMEGALIB))
+	if (strcmp(Omegavar, OMEGALIB))
 	  printf("\nEnvironment variable OMEGALIB badly set\n");
 	else {
 	  printf("\nOMEGALIB may be badly #defined in defs.h\n");
 #ifndef FIXED_OMEGALIB
 	  printf("\nYou can set the environment variable OMEGALIB to\n");
-	  printf("the location of the omegalib directory.\n");
+	  printf("the location of the omegavar directory.\n");
 #endif
 	}
 	return(0);
--- omega-rpg-0.90-pa9.orig/util.c
+++ omega-rpg-0.90-pa9/util.c
@@ -850,6 +850,21 @@
   assert(FALSE);
 }
 
+/* finds floor space on level with buildaux not equal to baux,
+sets x,y there. Return false is no such space exists on the level. */
+int try_findspace (int * x_out, int * y_out, int baux)
+{
+  /* try to quickly find a space by sampling randomly */
+  if (findspace_method_one(x_out, y_out, Level, baux))
+    return TRUE;
+
+  /* examine every space on the level */
+  if (findspace_method_two(x_out, y_out, Level, baux))
+    return TRUE;
+
+  return FALSE;
+}
+
 /* is prefix a prefix of s? */
 int strprefix(char *prefix, char *s)
 {
--- omega-rpg-0.90-pa9.orig/mon.c
+++ omega-rpg-0.90-pa9/mon.c
@@ -696,7 +696,7 @@
   status = 2;
   strcpy(Str2,"Malaprop the Misnamed");
   
-  strcpy(Str1,Omegalib);
+  strcpy(Str1,Omegavar);
   strcat(Str1,"omega.log");
   fd = checkfopen(Str1,"r");
   n = 1;
--- omega-rpg-0.90-pa9.orig/save.c
+++ omega-rpg-0.90-pa9/save.c
@@ -336,7 +336,7 @@
       }
       mask >>= 1;
       if (level->site[i][j].lstatus&SEEN)
-	mask |= (1<<(sizeof(long int)*8 - 1));
+	mask |= (1UL<<(sizeof(long int)*8 - 1));
       run--;
     }
   if (run < 8*sizeof(long int))
@@ -477,7 +477,7 @@
       }
       mask >>= 1;
       if (c_statusp(i, j, SEEN))
-	mask |= (1<<(sizeof(long int)*8 - 1));
+	mask |= (1UL<<(sizeof(long int)*8 - 1));
       run--;
     }
   if (run < 8*sizeof(long int))
--- omega-rpg-0.90-pa9.orig/extern.h
+++ omega-rpg-0.90-pa9/extern.h
@@ -1126,6 +1126,7 @@
 void do_los( Symbol,int *,int *,int,int );
 void do_object_los (Symbol, int *, int *, int, int);
 void findspace( int *,int *,int );
+int try_findspace( int *,int *,int );
 void initdirs( void );
 #ifdef NO_USLEEP
 void usleep( int );
--- omega-rpg-0.90-pa9.orig/defs.h
+++ omega-rpg-0.90-pa9/defs.h
@@ -71,7 +71,8 @@
    This might usually be "/usr/games/lib/omegalib/", for unix,
    or something like "c:\\games\\omega\\omegalib\\" for msdos */
 
-#define OMEGALIB "./lib/"
+#define OMEGALIB "/usr/share/games/omega-rpg/"
+#define OMEGAVAR "/var/games/omega-rpg/"
 
 /* TILEFILE is the name of the file you want to use for graphics tiles. You */
 /* aren't really free to use any file you want here. It should be the Omega */
@@ -93,7 +94,7 @@
 
 /* set WIZARD to maintainers's username */
 
-#define WIZARD "sheldon"
+#define WIZARD "root"
 
 /* If CATCH_SIGNALS is set to 1, will not dump core, nicer for players. */
 /* dbx still intercepts the signals first, so it's ok for debugging */
--- omega-rpg-0.90-pa9.orig/glob.h
+++ omega-rpg-0.90-pa9/glob.h
@@ -26,6 +26,9 @@
 /* This string holds the path to the library files */
 extern char *Omegalib;
 
+/* This string holds the path to the highscore and log files */
+extern char *Omegavar;
+
 /* one of each monster */
 extern struct monster Monsters[NUMMONSTERS];
 
--- omega-rpg-0.90-pa9.orig/city.c
+++ omega-rpg-0.90-pa9/city.c
@@ -543,18 +543,15 @@
 void resurrect_guards(void)
 {
   int i,j;
-  char site;
+  map *city;
   
-  FILE *fd;
-  
-  strcpy(Str3,Omegalib);
-  strcat(Str3,"city.dat");
-  fd = checkfopen(Str3,"rb");
-  site = cryptkey("city.dat");
+  /* Get the original city. */
+  city = map_open(MAP_city);
+  map_setLevel(city,0);
+
   for(j=0;j<Level->level_length;j++) {
     for(i=0;i<Level->level_width;i++) {
-      site = getc(fd)^site;
-      if (site == 'G') {
+      if (map_getSiteChar(city,i,j) == 'G') {
 	make_site_monster(i,j,GUARD);
 	Level->site[i][j].creature->monstring = "undead guardsman";
 	Level->site[i][j].creature->meleef = M_MELEE_SPIRIT;
@@ -569,9 +566,7 @@
 	m_status_set(Level->site[i][j].creature,AWAKE);
       }
     }
-    site = getc(fd)^site;
   }
-  fclose(fd);
 }
 
 
--- omega-rpg-0.90-pa9.orig/inv.c
+++ omega-rpg-0.90-pa9/inv.c
@@ -78,7 +78,7 @@
    may drop things back onto the now null ground */
 void pickup_at (int x, int y)
 {
-  char response;
+  char response = 0;
 
   pol ol;
   pol temp;
@@ -90,10 +90,10 @@
 
   while (ol != 0)
     {
-      clearmsg1();
-      response = cinema_ynq(strjoin("Pick up: ", itemid(ol->thing)));
-      if ('q' == response)
-        break;
+      if(response != 'q') {
+        clearmsg1();
+        response = cinema_ynq(strjoin("Pick up: ", itemid(ol->thing)));
+      }
 
       if (response == 'y')
         gain_item(ol->thing);
@@ -106,15 +106,6 @@
       temp->thing = 0;
       free(temp);
     }
-
-  while (ol != 0)
-    {
-      temp = ol;
-      ol = ol->next;
-      temp->next = 0;
-      temp->thing = 0;
-      free(temp);
-    }
 }
 
 /* WDT -- convert from a char (keypress) to an item index in
@@ -553,7 +544,7 @@
 
 int getitem_prompt (char * prompt, Symbol itype)
 {
-  char key;
+  int key;
   char *line3;
   char invstr[64];
   char selectstr[80];
--- omega-rpg-0.90-pa9.orig/bank.c
+++ omega-rpg-0.90-pa9/bank.c
@@ -1142,6 +1142,9 @@
   int num_accounts;
   bank_account *account;
 
+  if(!bank)
+    return 0;
+
   num_accounts = 0;
   for (account = bank; account; account = account->next_account)
     {
--- omega-rpg-0.90-pa9.orig/command3.c
+++ omega-rpg-0.90-pa9/command3.c
@@ -206,15 +206,13 @@
   xredraw();
 }
 
-extern const char * LAST_OMEGA_BUILD_TIME;
-
 void version(void)
 {
   setgamestatus(SKIP_MONSTERS);
   print3(VERSIONSTRING);
   nprint3(":");
   nprint3(" build date: ");
-  nprint3((char *)LAST_OMEGA_BUILD_TIME);
+  nprint3(__DATE__" "__TIME__);
 }
 
 void fire(void)
--- omega-rpg-0.90-pa9.orig/Makefile
+++ omega-rpg-0.90-pa9/Makefile
@@ -1,17 +1,17 @@
 ### These two definitions are used if you 'make install'
 ### the value of LIBDIR should be the same as OMEGALIB in defs.h
-BINDIR = ./omega/
-LIBDIR = ./lib/
+BINDIR = $(DESTDIR)/usr/games
+LIBDIR = $(DESTDIR)/usr/share/games/omega-rpg
 
 ### choose your optimization level
-OFLAGS = -O2
+OFLAGS = -O2 -pipe
 
 ### One of these should be uncommented, as appropriate, unless your compiler
 ### does it for you.  You can test this by simply trying to 'make' omega -
 ### it will fail if none of them are defined.  If you do uncomment
 ### one, make sure you comment out the other definition of CFLAGS lower down
 
-CFLAGS = -ggdb -Wall $(OFLAGS) -DBSD # -ansi
+CFLAGS = -Wall $(OFLAGS) -DBSD # -ansi
 #CFLAGS = -DSYSV $(OFLAGS)
 #CFLAGS = -DMSDOS $(OFLAGS)
 #CFLAGS = -DAMIGA $(OFLAGS)
@@ -30,15 +30,15 @@
 #LIBS = -lcurses -ltermlib
 #LIBS = -lpdcurses
 #Linux links in term?? automatically.
-#LIBS = -lncurses
+LIBS = -lncurses
 
 ### uncomment to use "op-curses" package
-OPDEF = -DUSE_OPCURSES
-CUROBJ = ../opcurses/curses.o ../opcurses/curgtk.o
+#OPDEF = -DUSE_OPCURSES
+#CUROBJ = ../opcurses/curses.o ../opcurses/curgtk.o
 
 ### uncomment to compile using opcurses GTK+ driver
-CPPFLAGS = `gtk-config --cflags` -DUSE_OPCURSES
-LDFLAGS = `gtk-config --libs`
+#CPPFLAGS = `gtk-config --cflags` -DUSE_OPCURSES
+#LDFLAGS = `gtk-config --libs`
 
 #################### that's it for changing the Makefile ####################
 
@@ -49,7 +49,7 @@
 CLROBJ = clrgen.o
 
 OBJ = omega.o abyss.o aux1.o aux2.o aux3.o bank.o char.o city.o\
-      command1.o command2.o command3.o country.o date.o effect1.o\
+      command1.o command2.o command3.o country.o effect1.o\
       effect2.o effect3.o etc.o env.o file.o gen1.o gen2.o guild1.o guild2.o\
       house.o init.o inv.o item.o itemf1.o itemf2.o itemf3.o lev.o map.o\
       mmelee.o mmove.o mon.o move.o movef.o mspec.o mstrike.o mtalk.o\
@@ -60,7 +60,7 @@
 
 omega: $(CUROBJ) $(CLROBJ) $(OBJ)
 	$(CC) $(LDFLAGS) $(OFLAGS) $(CUROBJ) $(CLROBJ) $(OBJ) $(LIBS) -o omega
-	rm date.c date.o
+	#rm date.c date.o
 
 date.c:
 	tools/makedate > date.c
@@ -70,26 +70,29 @@
 	cd tools/libsrc; make maps.dat
 
 install: omega maps.dat $(BINDIR) $(LIBDIR)
-	cp omega $(BINDIR)
-	chmod 4711 $(BINDIR)/omega
+	cp omega $(BINDIR)/omega-rpg
+	chmod 4711 $(BINDIR)/omega-rpg
 	- cp lib/* $(LIBDIR)
-	cp maps.dat $(LIBDIR)
+	cp lib/maps.dat $(LIBDIR)
 	chmod 0644 $(LIBDIR)/help*.txt $(LIBDIR)/license.txt $(LIBDIR)/motd.txt $(LIBDIR)/thanks.txt $(LIBDIR)/update.txt
 	chmod 0600 $(LIBDIR)/abyss.txt $(LIBDIR)/scroll[1234].txt $(LIBDIR)/maps.dat
-	chmod 0600 $(LIBDIR)/omega.hi $(LIBDIR)/omega.log $(LIBDIR)/omegahi.bak
+	chmod 0600 $(LIBDIR)/omega.hi $(LIBDIR)/omega.log $(LIBDIR)/omega.hi.backup
 
 install_not_suid: omega maps.dat $(BINDIR) $(LIBDIR)
-	cp omega $(BINDIR)
-	chmod 0711 $(BINDIR)/omega
+	cp omega $(BINDIR)/omega-rpg
+	chmod 0711 $(BINDIR)/omega-rpg
 	- cp lib/* $(LIBDIR)
 	cp maps.dat $(LIBDIR)
 	chmod 0644 $(LIBDIR)/help*.txt $(LIBDIR)/license.txt $(LIBDIR)/motd.txt $(LIBDIR)/thanks.txt $(LIBDIR)/update.txt
 	chmod 0644 $(LIBDIR)/abyss.txt $(LIBDIR)/scroll[1234].txt $(LIBDIR)/*.dat
 	chmod 0666 $(LIBDIR)/omega.hi $(LIBDIR)/omega.log
-	chmod 0600 $(LIBDIR)/omegahi.bak
+	chmod 0600 $(LIBDIR)/omega.hi.backup	
 
 clean:
-	rm -f $(OBJ) clrgen.h clrgen.c genclr.o genclr omega
+	rm -f $(OBJ) $(CLROBJ) clrgen.h clrgen.c genclr.o genclr omega
+	cd tools; $(MAKE) clean
+	cd tools/libsrc; $(MAKE) clean
+	cd lib; $(MAKE) clean
 
 distclean:
 	rm -f $(OBJ) $(CUROBJ) $(TOOLS) $(OLIBSTUFF) clrgen.h clrgen.c genclr.o genclr omega
@@ -98,12 +101,13 @@
 
 $(CUROBJ): ../opcurses/curses.h ../opcurses/cmacros.h ../opcurses/xcurses.h
 
-$(CLROBJ): clrgen.h
+$(CLROBJ): clrgen.c
 
 $(OBJ): defs.h extern.h glob.h iinit.h minit.h clrgen.h
 
-clrgen.h clrgen.c: genclr.c minit.h defs.h
-	$(MAKE) genclr
+clrgen.c: clrgen.h
+
+clrgen.h: genclr minit.h defs.h
 	$(CPP) $(OPDEF) -DOMEGA_CLRGEN *.[ch] | ./genclr clrgen.c clrgen.h
 
 genclr: genclr.o
--- omega-rpg-0.90-pa9.orig/effect1.c
+++ omega-rpg-0.90-pa9/effect1.c
@@ -80,11 +80,11 @@
       }
     }
     else {
-      if (Player.possessions[i]->plus > random_range(20)+1) {
+      if (abs(Player.possessions[i]->plus) > random_range(20)+1) {
 	print1("Uh-oh, the force of the enchantment was too much!");
 	print2("There is a loud explosion!");
 	morewait();
-	manastorm(Player.x,Player.y,Player.possessions[i]->plus*5);
+	manastorm(Player.x,Player.y,abs(Player.possessions[i]->plus)*5);
 	dispose_lost_objects(1,Player.possessions[i]);
       }
       else {
@@ -382,6 +382,9 @@
   for(i=0;i<9;i++) {
     ex = xx + Dirs[0][i];
     ey = yy + Dirs[1][i];
+
+    if(offscreen(ex, ey))
+      continue;
     
     if ((ex == Player.x) && (ey == Player.y)) {
       switch(dtype) {
--- omega-rpg-0.90-pa9.orig/tools/libsrc/Makefile
+++ omega-rpg-0.90-pa9/tools/libsrc/Makefile
@@ -9,3 +9,6 @@
 
 ../crypt: ../crypt.c
 	cd ..; make
+
+clean:
+	rm -f maps.dat ../crypt
--- omega-rpg-0.90-pa9.orig/lib/Makefile
+++ omega-rpg-0.90-pa9/lib/Makefile
@@ -10,3 +10,6 @@
 .map.dat:
 	cd ../tools; make -f makefile
 	../tools/crypt $@ > $@ < $<
+
+clean:
+	rm -f .maps.dat maps.dat
--- omega-rpg-0.90-pa9.orig/lib/motd.txt
+++ omega-rpg-0.90-pa9/lib/motd.txt
@@ -9,7 +9,7 @@
                               *    **    **    *
                                *****      *****
 
-            omega version 0.90-pa8 is copyright (C) 1987,1988,1989 by:
+            omega version 0.90-pa9 is copyright (C) 1987,1988,1989 by:
                              Laurence R. Brothers
                        and is licensed under the LGPL.
              Maintained by: William Tanksley (wtanksley@bigfoot.com).
