From cc7023a6b32c9741929529fe1bf779a3201d7452 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Thu, 25 Sep 2014 10:49:04 +0200
Subject: Fix path issues.


diff --git a/Makefile b/Makefile
index 1114af0..b1f9034 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
-CC = gcc -Wall -ansi
+CC = gcc -Wall -Wno-multichar
 
 all:
-	$(CC) dragonmemory.cpp -o dragonmemory -lGL -lGLU -lSDL_image -lSDL_mixer `sdl-config --cflags --libs`
+	$(CC) dragonmemory.cpp -o dragonmemory -lGL -lGLU -lSDL_image -lSDL_mixer `sdl-config --cflags --libs` -lbe
 
 clean:
 	@echo Cleaning up...
diff --git a/dragonmemory.cpp b/dragonmemory.cpp
index 145dd8b..2fc7ac9 100644
--- a/dragonmemory.cpp
+++ b/dragonmemory.cpp
@@ -8,6 +8,8 @@
 #include<stdlib.h>
 #include<math.h>
 #include<time.h>
+#include <libgen.h>
+#include <unistd.h>
 #ifdef ANDROID
 #include<SDL.h>
 #include<SDL_image.h>
@@ -40,6 +42,7 @@
 
 int main (int argc, char * argv[])
 {
+	chdir(dirname(argv[0]));
     initSDL();
     initGL();
     showIntro();
diff --git a/file.h b/file.h
index fdac20a..31369ae 100644
--- a/file.h
+++ b/file.h
@@ -1,11 +1,20 @@
+#include <Path.h>
+#include <PathFinder.h>
+
 void loadScores()
 {
     int hiByte, loByte;
     FILE *scores;
-    scores = fopen(SAVEDIR "/hiscore.dat", "rb");
+
+	char buffer[1024];
+	buffer[0] = 0;
+	status_t x = find_directory(B_USER_SETTINGS_DIRECTORY, 0, true, buffer, 1024);
+	strcat(buffer, "/DragonMemory.dat");
+
+    scores = fopen(buffer, "rb");
     if(scores == NULL)
     {
-		scores = fopen(SAVEDIR "/hiscore.dat", "wb+");
+		scores = fopen(buffer, "wb+");
 		fputc(1 ,scores);
 		fputc(0, scores);
 		fputc(0 ,scores);
@@ -13,7 +22,7 @@ void loadScores()
 		fputc(0 ,scores);
 		fputc(0 ,scores);
 		fclose(scores);
-		scores = fopen(SAVEDIR "/hiscore.dat", "rb");
+		scores = fopen(buffer, "rb");
     }
     maxLevel = fgetc(scores);
     if(maxLevel == EOF)
@@ -47,7 +56,14 @@ void saveScore(int score, int time)
 // 1 extra byte at the BEGINING of the file to store the last unlocked level
     int maxSavedLevel, hiByte, loByte;
     FILE *scores;
-    scores = fopen(SAVEDIR "/hiscore.dat", "rb+");
+
+	char buffer[1024];
+	buffer[0] = 0;
+	status_t x = find_directory(B_USER_SETTINGS_DIRECTORY, 0, true, buffer, 1024);
+	strcat(buffer, "/DragonMemory.dat");
+
+
+    scores = fopen(buffer, "rb+");
 
     maxSavedLevel = fgetc(scores);
     if(levelNumber + 1 > maxSavedLevel)
-- 
1.8.3.4

