From dfeebcbe34b05ff5a8a343b7e89bb1ff713ed210 Mon Sep 17 00:00:00 2001
From: Victor Gamper <victor@wenzeslaus.de>
Date: Sun, 12 Dec 2021 22:33:39 +0100
Subject: switch the workdir to the data directory


diff --git a/main.c b/main.c
index f4f650b..0928de6 100644
--- a/main.c
+++ b/main.c
@@ -24,6 +24,7 @@
 #include "music.h"
 
 #define TICKS  30
+#define HIGHSCORE_FILE "/boot/system/settings/sdlinvaders/highscores"
 
 /* The images */
 extern SDL_Surface *screen;
@@ -773,7 +774,7 @@ void save_scores ()
   int i;
   char filename[100];
        
-  sprintf (filename, "data/highscores");
+  sprintf (filename, HIGHSCORE_FILE);
 
   file = fopen(filename, "w");
 
@@ -800,7 +801,7 @@ void show_highscore ()
   int i;
   char filename[100];
        
-  sprintf (filename, "data/highscores");
+  sprintf (filename, HIGHSCORE_FILE);
 
   file = fopen(filename, "r");
 
@@ -831,6 +832,9 @@ void show_highscore ()
 int main(int argc, char *argv[])
 {
   int quit = 0;
+  
+  /* HACK: change the directory to the data directory of Haiku */
+  chdir("/boot/system/data/sdlinvaders/");	
 
   printf("\nSDLInvaders Version %s\n\n",VERSION);
 
-- 
2.30.2


From a541928fe0f484bbd288923254f3892a71556f34 Mon Sep 17 00:00:00 2001
From: Victor Gamper <victor@wenzeslaus.de>
Date: Mon, 13 Dec 2021 17:53:22 +0100
Subject: Use find_directory instead of hard coded paths


diff --git a/main.c b/main.c
index 0928de6..8c4a3ad 100644
--- a/main.c
+++ b/main.c
@@ -17,6 +17,10 @@
 */
 #include <time.h>
 #include <errno.h>
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <fs_info.h>
+#endif
 #include "common.h"
 #include "graphics.h"
 #include "alien.h"
@@ -24,7 +28,12 @@
 #include "music.h"
 
 #define TICKS  30
-#define HIGHSCORE_FILE "/boot/system/settings/sdlinvaders/highscores"
+#ifdef __HAIKU__
+#define HIGHSCORE_FILE "/sdlinvaders/highscores"
+#else
+#define HIGHSCORE_FILE "data/highscores"
+#endif
+char* highscore_file_path = "";
 
 /* The images */
 extern SDL_Surface *screen;
@@ -774,7 +783,7 @@ void save_scores ()
   int i;
   char filename[100];
        
-  sprintf (filename, HIGHSCORE_FILE);
+  sprintf (filename, highscore_file_path);
 
   file = fopen(filename, "w");
 
@@ -801,7 +810,7 @@ void show_highscore ()
   int i;
   char filename[100];
        
-  sprintf (filename, HIGHSCORE_FILE);
+  sprintf (filename, highscore_file_path);
 
   file = fopen(filename, "r");
 
@@ -833,8 +842,24 @@ int main(int argc, char *argv[])
 {
   int quit = 0;
   
+  #ifdef __HAIKU__
+  dev_t volume = dev_for_path("/boot");
+  char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+  status_t result;
+  result = find_directory(B_SYSTEM_DATA_DIRECTORY, volume, false, buffer, sizeof(buffer));
+  strcat(buffer, "/sdlinvaders/");
+  
   /* HACK: change the directory to the data directory of Haiku */
-  chdir("/boot/system/data/sdlinvaders/");	
+  chdir(buffer);
+  
+  /* set the highscore position */
+  highscore_file_path = malloc(strlen(buffer + strlen(HIGHSCORE_FILE) + 1));
+  strcpy(highscore_file_path, buffer);
+  strcat(highscore_file_path, HIGHSCORE_FILE);
+  #else
+  highscore_file_path = malloc(strlen(strlen(HIGHSCORE_FILE) + 1));
+  strcat(highscore_file_path, HIGHSCORE_FILE);
+  #endif
 
   printf("\nSDLInvaders Version %s\n\n",VERSION);
 
-- 
2.30.2


From ed93c823882892986dee98e572fce74fad95477c Mon Sep 17 00:00:00 2001
From: Victor Gamper <victor@wenzeslaus.de>
Date: Wed, 22 Dec 2021 17:55:24 +0100
Subject: fix build for gcc11


diff --git a/Makefile b/Makefile
index cdd498f..3daa85d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-CC=gcc -Wall -ansi -pedantic
-CFLAGS=-g `sdl-config --cflags --libs` -Wall -ansi -pedantic -lSDL_image
+CC=gcc -Wall -pedantic -frepo -fcommon
+CFLAGS=-g `sdl-config --cflags --libs` -Wall -pedantic -lSDL_image
 SRC=main.c graphics.c SFont.c alien.c weapons.c music.c
 TARGET=SDLInvaders
 
-- 
2.30.2


From 95db0ae228050574fbb1df49194e35416db97bb7 Mon Sep 17 00:00:00 2001
From: Victor Gamper <victor@wenzeslaus.de>
Date: Thu, 23 Dec 2021 13:26:14 +0100
Subject: disable fullscreen by default


diff --git a/main.c b/main.c
index 8c4a3ad..f32e4e4 100644
--- a/main.c
+++ b/main.c
@@ -53,7 +53,11 @@ int sound = 0;
 #else
 int sound = 1;
 #endif
-int fullscreen=1;
+#ifdef __HAIKU__
+int fullscreen=0;
+#else
+inf fullscreen=1;
+#endif
 extern int wavenumber;
 int max_shots = INIT_MAX_SHOTS;
 extern int game_points;
@@ -673,8 +677,13 @@ void TextHelp(char *argv[])
 {
     puts("The newest version can be obtained at http://www.sdlinvaders.de/\n");
     printf("Usage: %s [options]\n",argv[0]);
+    #ifdef __HAIKU__
+    puts("  [-f, --fullscreen]         start in fullscreen mode");
+    puts("  [-w, --windowed]           start in windowed mode (default)");
+    #else
     puts("  [-f, --fullscreen]         start in fullscreen mode (default)");
     puts("  [-w, --windowed]           start in windowed mode");
+    #endif
     puts("  [-s, --nosound]            start without sound");
     puts("  [-e, --easy]               play in easy mode - only for wimps");
     puts("  [-h, --help]               this text\n");
@@ -853,6 +862,7 @@ int main(int argc, char *argv[])
   chdir(buffer);
   
   /* set the highscore position */
+  result = find_directory(B_SYSTEM_SETTINGS_DIRECTORY, volume, false, buffer, sizeof(buffer));
   highscore_file_path = malloc(strlen(buffer + strlen(HIGHSCORE_FILE) + 1));
   strcpy(highscore_file_path, buffer);
   strcat(highscore_file_path, HIGHSCORE_FILE);
-- 
2.30.2

