From 274e3fd30dd99735cbbff6732c22a308b16e83e8 Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Thu, 14 Oct 2021 15:54:45 +0200
Subject: fix build


diff --git a/Makefile b/Makefile
index 686e636..94a5b07 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ ifndef bindir
 endif
 
 
-CFLAGS+=-Wall -Werror $(OPTIMIZE) $(SDL_CFLAGS) -DDATAPREFIX=\"$(datadir)/icebreaker\"
+CFLAGS+=-Wall -Werror -Wno-error=format-truncation $(OPTIMIZE) $(SDL_CFLAGS) -DDATAPREFIX=\"$(datadir)/icebreaker\"
 
 SRC=icebreaker.c cursor.c grid.c laundry.c line.c penguin.c sound.c \
     level.c intro.c text.c status.c transition.c hiscore.c dialog.c \
@@ -33,7 +33,7 @@ SDL_MIXER := $(shell $(PKG_CONFIG) SDL_mixer --libs)
 SDL_LIB=$(SDL_MIXER) $(SDL_LDFLAGS)
 SDL_CFLAGS := $(shell $(PKG_CONFIG) sdl --cflags)
 SDL_LDFLAGS := $(shell $(PKG_CONFIG) sdl --libs)
-VERSION := $(shell awk '/^#define VERSION/ { print $$3 }' icebreaker.h)
+VERSION := $(shell awk '/^\#define VERSION/ { print $$3 }' icebreaker.h)
 VERDATE := $(shell LC_ALL=C date -u -r icebreaker.h +"%d %B %Y")
 
 WINARCH=i686
-- 
2.30.2


From 3c5669c59868ba961895a7a38748dce6fa995d1a Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Thu, 14 Oct 2021 15:54:58 +0200
Subject: add paths for Haiku


diff --git a/Makefile b/Makefile
index 94a5b07..0b91af2 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,8 @@ ifndef bindir
 endif
 
 
-CFLAGS+=-Wall -Werror -Wno-error=format-truncation $(OPTIMIZE) $(SDL_CFLAGS) -DDATAPREFIX=\"$(datadir)/icebreaker\"
+CFLAGS+=-Wall -Werror -Wno-error=format-truncation $(OPTIMIZE) $(SDL_CFLAGS)
+CFLAGS+=-DDATAPREFIX=\"$(datadir)/icebreaker\" -DHISCOREPREFIX=\"$(highscoredir)\"
 
 SRC=icebreaker.c cursor.c grid.c laundry.c line.c penguin.c sound.c \
     level.c intro.c text.c status.c transition.c hiscore.c dialog.c \
diff --git a/icebreaker.h b/icebreaker.h
index 907ffa4..f041df3 100644
--- a/icebreaker.h
+++ b/icebreaker.h
@@ -65,6 +65,18 @@
 #endif
 
 
+#ifdef __HAIKU__
+
+  #define NEEDCHANGETOARGV0PATH
+
+  #ifndef OPTIONFILE
+    #define OPTIONFILE "config/settings/icebreaker.cfg"
+  #endif
+
+  // HISCOREPREFIX and DATAPREFIX should probably be ".". Set in Makefile
+#endif
+
+
 #ifdef __BEOS__
 
   #define NEEDCHANGETOARGV0PATH
-- 
2.30.2


From 4cdf2d897d2e0e864c41fafa6fc97ae54de25433 Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Thu, 14 Oct 2021 15:55:07 +0200
Subject: adjust high score filename


diff --git a/Makefile b/Makefile
index 0b91af2..3df49fe 100644
--- a/Makefile
+++ b/Makefile
@@ -188,6 +188,7 @@ man: icebreaker.6
 install-mkdirs:
 	install -m 755 -d $(datadir)/icebreaker
 	install -m 755 -d $(bindir)
+	install -m 755 -d $(highscoredir)
 	install -m 755 -d $(mandir)/man6
 
 themes-install: install-themes
@@ -202,7 +203,13 @@ install-bin: install-mkdirs icebreaker
 install-man: install-mkdirs icebreaker.6
 	install -m 644 icebreaker.6 $(mandir)/man6
 
-install: all install-mkdirs install-themes install-bin install-man
+install-scorefile: install-mkdirs
+	touch $(highscoredir)/icebreaker.scores
+	chown -f games:games $(highscoredir)/icebreaker.scores && \
+	chmod 664 $(highscoredir)/icebreaker.scores || \
+	chmod 644 $(highscoredir)/icebreaker.scores
+
+install: all install-mkdirs install-themes install-bin install-man install-scorefile
 
 %.d: %.c
 	set -e; $(CC) -M $(CFLAGS) $< \
diff --git a/hiscore.c b/hiscore.c
index 3fd7393..e867de5 100644
--- a/hiscore.c
+++ b/hiscore.c
@@ -77,7 +77,7 @@ void readhiscores()
 		temphiscoreval[i]=100; //100 is better than 0. :)
 	}
 
-	snprintf(filename,274,"%s/%s",homedir,HISCOREFILE);
+	snprintf(filename,274,HISCOREPREFIX "/" HISCOREFILE);
 
 	hiscorefile=fopen(filename,"r");
 	if (hiscorefile==NULL)
@@ -129,7 +129,7 @@ int addhiscore(char* username, long finalscore, int candelay)
 	FILE_DESC filelock;
 	char filename[274]; // fix -- use defined OS constant
 	
-	snprintf(filename,274,"%s/%s",homedir,HISCORELOCKFILE);
+	snprintf(filename,274,HISCORELOCKFILE);
 
 	filelock = openlockfile(filename);
 	if (filelock == INVALID_FILE_DESC)
@@ -240,7 +240,7 @@ void writehiscores(char * username, long thisgamescore)
 
 	sorthiscore(hiscorename,hiscoreval,username,thisgamescore);
 
-	snprintf(filename,274,"%s/%s",homedir,HISCOREFILE);
+	snprintf(filename,274,HISCOREPREFIX "/" HISCOREFILE);
 	
 	hiscorefile=fopen(filename,"w");
 	if (hiscorefile==NULL)
diff --git a/icebreaker.h b/icebreaker.h
index f041df3..96f89bf 100644
--- a/icebreaker.h
+++ b/icebreaker.h
@@ -73,7 +73,8 @@
     #define OPTIONFILE "config/settings/icebreaker.cfg"
   #endif
 
-  // HISCOREPREFIX and DATAPREFIX should probably be ".". Set in Makefile
+  #define HISCOREFILE "icebreaker.scores"
+
 #endif
 
 
@@ -117,7 +118,7 @@
 #endif
 
 #ifndef HISCORELOCKFILE
-  #define HISCORELOCKFILE HISCOREFILE
+  #define HISCORELOCKFILE HISCOREPREFIX "/" HISCOREFILE
 #endif
 
 #ifndef PENGUINICONFILE
-- 
2.30.2

