--- maze-1.0/makefile.unx 2008-01-20 11:29:24.000000000 +0100 +++ maze-1.0.new/makefile.unx 2008-01-20 12:02:33.000000000 +0100 @@ -2,7 +2,7 @@ CC = g++ PREFIX = /usr DATADIR = $(PREFIX)/share/$(TARGET) CFLAGS = -g -Wall -O2 -Wno-deprecated-declarations -Wno-deprecated -LDFLAGS = `allegro-config --libs` -lgstrm -ldumb -laldmb +LDFLAGS = `allegro-config --libs` -lgstrm -ldumb -laldmb -lpthread DEFINES = -DDATADIR=\"$(DATADIR)/\" INCLUDES= -Iinclude OBJS = src/main.o src/3d.o src/game.o src/hiscore.o src/JBdraw.o src/maze_ai.o src/mengine.o src/menu.o src/msg.o src/particle.o src/scrshot.o src/shandler.o src/jgmod.o @@ -19,7 +19,9 @@ install: $(TARGET) mkdir -p $(PREFIX)/bin + mkdir -p $(DATADIR) install -p -m 755 $(TARGET) $(PREFIX)/bin + install -p -m 644 maze.dat $(DATADIR) clean: rm -f $(OBJS) $(TARGET) *~ src/*~ include/*~ --- maze-1.0/src/hiscore.cpp 2008-01-20 11:29:24.000000000 +0100 +++ maze-1.0.new/src/hiscore.cpp 2008-01-20 11:59:19.000000000 +0100 @@ -7,6 +7,10 @@ #include "JBdraw.h" #include "hiscore.h" #include <gstream.h> +#ifdef __unix__ +#include <sys/param.h> /* for PATH_MAX */ +#include <stdlib.h> +#endif #define RELX( x ) (( x ) * buffer->w / 640) #define RELY( x ) (( x ) * buffer->h / 480) @@ -38,7 +41,14 @@ void HiScore::load() { +#ifdef __unix__ + char fname[PATH_MAX]; + char *home = getenv("HOME"); + snprintf(fname, PATH_MAX, "%s/.maze.hi", home? home:"."); + ifstream inhiscorefile (fname, ios::in); +#else ifstream inhiscorefile ("hiscore.hi", ios::in); +#endif if (!inhiscorefile) { setDefault(); @@ -55,11 +65,18 @@ void HiScore::save() { +#ifdef __unix__ + char fname[PATH_MAX]; + char *home = getenv("HOME"); + snprintf(fname, PATH_MAX, "%s/.maze.hi", home? home:"."); + ofstream outhiscorefile (fname, ios::out); +#else ofstream outhiscorefile ("hiscore.hi", ios::out); +#endif if (!outhiscorefile) { - cerr << "File could not be saved\n"; - exit(1); + cerr << "Hiscore file could not be saved\n"; + return; } int x=0; do { --- maze-1.0/src/mengine.cpp 2008-01-20 11:30:48.000000000 +0100 +++ maze-1.0.new/src/mengine.cpp 2008-01-20 11:32:03.000000000 +0100 @@ -5,6 +5,10 @@ #define RELX( x ) (( x ) * background->w / 640) #define RELY( x ) (( x ) * background->h / 480) +#ifndef DATADIR +#define DATADIR "" +#endif + void MainEngine::createbackground() { srand (0); @@ -57,7 +61,7 @@ menu.init(); menu.setGameEngine (&ge); - data = load_datafile ("maze.dat"); + data = load_datafile (DATADIR "maze.dat"); if (!data) { allegro_message ("could not open datafile"); @@ -99,7 +103,7 @@ allegro_message ("Error setting digi voices"); return 1; } - ex = load_mod ("maze.dat#MUSIC"); + ex = load_mod (DATADIR "maze.dat#MUSIC"); if (ex==NULL) { allegro_message ("Error reading Music from datafile");