--- /dev/null	2004-10-22 19:49:05.000000000 -0700
+++ .cvsignore	2004-10-24 20:21:00.000000000 -0700
@@ -0,0 +1,14 @@
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache*
+config.guess
+config.h
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+missing
+stamp-h1*
--- /dev/null	2004-10-22 19:49:05.000000000 -0700
+++ bin/.cvsignore	2004-10-24 20:21:14.000000000 -0700
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
--- /dev/null	2004-10-22 19:49:05.000000000 -0700
+++ src/.cvsignore	2004-10-24 20:21:58.000000000 -0700
@@ -0,0 +1,6 @@
+.deps
+Makefile
+Makefile.in
+snipe2d.*.dynamic
+snipe2d.*.static
+snipe2d
? .cvsignore
? bin/.cvsignore
? src/.cvsignore
Index: ChangeLog
===================================================================
RCS file: /cvs/cvsroot/oes/ChangeLog,v
retrieving revision 1.10
diff -u -p -u -r1.10 ChangeLog
--- ChangeLog	21 Apr 2003 14:04:57 -0000	1.10
+++ ChangeLog	25 Oct 2004 03:59:09 -0000
@@ -1,4 +1,8 @@
 Changes (for the Linux port):
+1.30
+Added game data dir knowledge.
+Added fopen error checking.
+
 1.29
 Phaethon fixed the menus, and added URL linking stuff!
 The config stuff is different!
Index: config.h.in
===================================================================
RCS file: /cvs/cvsroot/oes/config.h.in,v
retrieving revision 1.2
diff -u -p -u -r1.2 config.h.in
--- config.h.in	8 Oct 2002 19:30:25 -0000	1.2
+++ config.h.in	25 Oct 2004 03:59:09 -0000
@@ -1,5 +1,8 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Game data directory */
+#undef GAMEDATADIR
+
 /* Define to 1 if you have the `atexit' function. */
 #undef HAVE_ATEXIT
 
Index: configure.ac
===================================================================
RCS file: /cvs/cvsroot/oes/configure.ac,v
retrieving revision 1.7
diff -u -p -u -r1.7 configure.ac
--- configure.ac	6 Oct 2004 01:21:13 -0000	1.7
+++ configure.ac	25 Oct 2004 03:59:09 -0000
@@ -51,12 +51,14 @@ AC_ARG_WITH(games-dir,
  ,dnl default action of assigning shell value
  with_games_dir='${prefix}/games'
 )
+AC_SUBST(datadir,"${with_games_dir}")
+AC_DEFINE_UNQUOTED([GAMEDATADIR], "${datadir}/$PACKAGE_NAME",
+                               [Game data directory])
 
-[datadir="$with_games_dir"]
 
 #These should be automagically determined somehow.
 #CPU Instruction Set.  Should be automagic.
-AC_SUBST(CPU_IS,x86)
+AC_SUBST(CPU_IS,`uname -m`)
 
 
 echo $ac_n "ordering crap from http://www.amazon.com/gp/registry/296ST2NHEBO0Z" 1>&6
Index: src/binds.cpp
===================================================================
RCS file: /cvs/cvsroot/oes/src/binds.cpp,v
retrieving revision 1.1
diff -u -p -u -r1.1 binds.cpp
--- src/binds.cpp	28 Mar 2003 10:42:02 -0000	1.1
+++ src/binds.cpp	25 Oct 2004 03:59:09 -0000
@@ -3,6 +3,9 @@
 */
 
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -112,6 +115,8 @@ oeskeymap_init (oeskeymap_t *self)
   sexp_iowrap_t *io;
   sexp_t *se;
   int i;
+  char *keysname="keys.cfg";
+  char *keyspath;
 
   if (!self)
     {
@@ -126,8 +131,15 @@ oeskeymap_init (oeskeymap_t *self)
 
   if (addlkeys) return self;
 
-  if (!(keysfile = fopen("keys.cfg", "r")))
-      return 0;
+  keyspath=(char*)calloc(1,strlen(GAMEDATADIR)+1+strlen(keysname)+1);
+  sprintf(keyspath,"%s/%s",GAMEDATADIR,keysname);
+  if (!(keysfile = fopen(keyspath, "r"))) {
+    fprintf(stderr,"Cannot open key config '%s'\n",keyspath);
+    exit(1);
+  }
+  free(keyspath);
+  keyspath=NULL;
+
   io = init_iowrap(fileno(keysfile));
   se = read_one_sexp(io);
   if (se->ty == SEXP_LIST)
Index: src/snipe2d.cpp
===================================================================
RCS file: /cvs/cvsroot/oes/src/snipe2d.cpp,v
retrieving revision 1.56
diff -u -p -u -r1.56 snipe2d.cpp
--- src/snipe2d.cpp	21 Apr 2003 11:18:47 -0000	1.56
+++ src/snipe2d.cpp	25 Oct 2004 03:59:10 -0000
@@ -240,10 +240,12 @@ sniperbgm_music (sniperbgm_t *self)
   return self->BGM;
 }
 
-void
+int
 sniperbgm_use (sniperbgm_t *self, Mix_Music *m)
 {
+  if (!m) return 0;
   self->BGM = m;
+  return 1;
 }
 
 void
@@ -696,16 +698,28 @@ oes_setup ()
 
   sprintf(path, "%s/%s", Game.mediaPath, city_img);
   SDL_Surface *temp = IMG_Load(path);
+  if (!temp) {
+    fprintf(stderr, "Unable to load city map from '%s'\n",path);
+    exit(1);
+  }
   Game.Map = SDL_ConvertSurface(temp, Game.Screen->format,SDL_SWSURFACE);
   SDL_FreeSurface(temp);
     
   sprintf(path, "%s/%s", Game.mediaPath, charseq_img);
   temp = IMG_Load(path);
+  if (!temp) {
+    fprintf(stderr, "Unable to load character image from '%s'\n",path);
+    exit(1);
+  }
   Game.CharSprite = SDL_ConvertSurface(temp, Game.Screen->format,SDL_SWSURFACE);
   SDL_FreeSurface(temp);
 
   sprintf(path, "%s/%s", Game.mediaPath, aimap_img);
   Game.AIMap = IMG_Load(path);
+  if (!temp) {
+    fprintf(stderr, "Unable to load AI map from '%s'\n",path);
+    exit(1);
+  }
     
   // Okay, this is ugly. Load font several times & change the color of each.
     
@@ -713,6 +727,10 @@ oes_setup ()
   {
       sprintf(path, "%s/%s", Game.mediaPath, font_img);
       Game.Font[i] = IMG_Load(path);
+      if (!Game.Font[i]) {
+        fprintf(stderr, "Unable to load font %d from '%s'\n",i,path);
+        exit(1);
+      }
       SDL_SetColorKey(Game.Font[i],SDL_SRCCOLORKEY,1); // set color index 1 (black) transparent
   }
   *(int*)&(Game.Font[0]->format->palette->colors[0]) = 0x000000; // black
@@ -731,13 +749,28 @@ oes_setup ()
     {
       sprintf(path, "%s/%s", Game.mediaPath, zoomin_snd);
       Game.AudioZoomIn = Mix_LoadWAV(path);
+      if (!Game.AudioZoomIn) {
+        fprintf(stderr, "Unable to load zoom in sound from '%s'\n",path);
+        exit(1);
+      }
       sprintf(path, "%s/%s", Game.mediaPath, zoomout_snd);
       Game.AudioZoomOut = Mix_LoadWAV(path);
+      if (!Game.AudioZoomOut) {
+        fprintf(stderr, "Unable to load zoom out sound from '%s'\n",path);
+        exit(1);
+      }
       sprintf(path, "%s/%s", Game.mediaPath, boing_snd);
       Game.AudioFire = Mix_LoadWAV(path);
+      if (!Game.AudioFire) {
+        fprintf(stderr, "Unable to load fire sound from '%s'\n",path);
+        exit(1);
+      }
       sprintf(path, "%s/%s", Game.mediaPath, bgmusic);
 //      Game.BGM = Mix_LoadMUS(path);
-      sniperbgm_use(Game.BGM, Mix_LoadMUS(path));
+      if (!sniperbgm_use(Game.BGM, Mix_LoadMUS(path))) {
+        fprintf(stderr, "Unable to load background music from '%s'\n",path);
+        exit(1);
+      }
 
 //      SDL_PauseAudio(0); // let it play
     }
@@ -1632,11 +1665,14 @@ int main(int argc, char *argv[])
 
     srand(SDL_GetTicks());
    
+    /*
     Game.mediaPath = (char*)calloc(strlen(argv[0]), sizeof(char));
 //   invocation = (char*)malloc(strlen(argv[0]) + 1); memcpy(invocation, argv[0], strlen(argv[0]));
     invocation = strdup(argv[0]);
     sprintf(Game.mediaPath, "%s", dirname(invocation));
     free(invocation);
+    */
+    Game.mediaPath = strdup(GAMEDATADIR);
     invocation = argv[0];
 
     /* Load Preferences. */
@@ -1709,7 +1745,7 @@ SDL_Surface *oes_load_img (const char *p
     snprintf (lpath, PATH_MAX, "%s/%s", Game.mediaPath, path);
     sfc = IMG_Load (lpath);
     if (!sfc) {
-	std::cerr << "Unable to load image: " << SDL_GetError() << std::endl;
+	fprintf(stderr,"Unable to load image '%s': %s\n",lpath,SDL_GetError());
 	exit (1);
     }
     return sfc;
Index: src/snipe2d.h
===================================================================
RCS file: /cvs/cvsroot/oes/src/snipe2d.h,v
retrieving revision 1.31
diff -u -p -u -r1.31 snipe2d.h
--- src/snipe2d.h	21 Apr 2003 11:18:47 -0000	1.31
+++ src/snipe2d.h	25 Oct 2004 03:59:10 -0000
@@ -36,7 +36,6 @@
 //
 //#include <windows.h>
 #include <iostream>
-#include <linux/limits.h>
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
@@ -53,6 +52,10 @@
 #include <stdarg.h>
 #include "petopt.h"
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 // When trying to debug a segfault, you REALLY, REALLY need to be able to
 // switch windows.  :(
 #ifdef DEBUG_MODE
@@ -244,7 +247,7 @@ sniperbgm_t * sniperbgm_init_music (snip
 sniperbgm_t * sniperbgm_destroy (sniperbgm_t *);
 void sniperbgm_delete (sniperbgm_t *);
 Mix_Music * sniperbgm_music (sniperbgm_t *);
-void sniperbgm_use (sniperbgm_t *, Mix_Music *);
+int  sniperbgm_use (sniperbgm_t *, Mix_Music *);
 void sniperbgm_start (sniperbgm_t *);
 void sniperbgm_stimulate (sniperbgm_t *);
 void sniperbgm_depress (sniperbgm_t *);
Index: src/snipe2d.in
===================================================================
RCS file: /cvs/cvsroot/oes/src/snipe2d.in,v
retrieving revision 1.1
diff -u -p -u -r1.1 snipe2d.in
--- src/snipe2d.in	8 Oct 2002 04:42:52 -0000	1.1
+++ src/snipe2d.in	25 Oct 2004 03:59:10 -0000
@@ -1,4 +1,2 @@
 #! /bin/bash
-prefix=@prefix@
-cd @datadir@/@PACKAGE@
-./snipe2d.x86.dynamic $*
+@datadir@/@PACKAGE_NAME@/snipe2d.@CPU_IS@.dynamic $*
Index: src/ui.cpp
===================================================================
RCS file: /cvs/cvsroot/oes/src/ui.cpp,v
retrieving revision 1.11
diff -u -p -u -r1.11 ui.cpp
--- src/ui.cpp	21 Apr 2003 12:49:33 -0000	1.11
+++ src/ui.cpp	25 Oct 2004 03:59:10 -0000
@@ -1482,9 +1482,18 @@ oesui_load (oesui_t *self, const char *f
   sexp_t *se;
   const char *objtype;
   oesui_widget_t *widget;
+  char * menuname = "menus.cfg";
+  char * menupath;
+
+  menupath=(char*)calloc(1,strlen(GAMEDATADIR)+1+strlen(menuname)+1);
+  sprintf(menupath,"%s/%s",GAMEDATADIR,menuname);
+  if (!(guifile = fopen(menupath, "r"))) {
+    fprintf(stderr,"Cannot load menu '%s'\n",menupath);
+    exit(1);
+  }
+  free(menupath);
+  menupath=NULL;
 
-  if (!(guifile = fopen("menus.cfg", "r")))
-      return 0;
   io = init_iowrap(fileno(guifile));
 //  self->toplevel = read_one_sexp(io);
   while ((se = read_one_sexp(io)))
