From cc9d495228bfe5b1a3c34f7ec2829764a19d1410 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Fri, 1 Jan 2021 13:23:27 +0000
Subject: Fix launch from Tracker/Deskbar


diff --git a/biniax.c b/biniax.c
old mode 100755
new mode 100644
index 886b692..9ca0bba
--- a/biniax.c
+++ b/biniax.c
@@ -50,6 +50,11 @@ INCLUDES
 #include "game.h"
 #include "lev.h"
 #include "inc.h"
+
+#ifdef __HAIKU__
+#include <libgen.h>
+#include <unistd.h>
+#endif
 
 /* Global instance of GAME structure */
 BNX_GAME Game;
@@ -88,7 +93,13 @@ PROGRAM START
 ******************************************************************************/
 
 int main( int argc, char *argv[] )
-{
+{
+	char *binpath = realpath(argv[0], NULL);
+	if (binpath != NULL) {
+		chdir(dirname(binpath));
+		free(binpath);
+	}
+
 	BNX_BOOL		bquit		= BNX_FALSE;
 	BNX_INT16		enterState	= cStateMainMenu;
 	BNX_INT16		nmenu		= 0;
-- 
2.28.0

