From f523585b95fdb2cbcecc3a155f6b3755e789ffab Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 18 Sep 2019 19:20:02 +1000
Subject: applying patch maelstrom-3.0.6-64bits.patch


diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index d1e087f..01bb13a 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -847,10 +847,8 @@ FrameBuf:: AddDirtyRect(SDL_Rect *rect)
 			/* Update the dirty rectangle map with the new list */
 			for ( i=0; i<dirtymaplen; ++i ) {
 				if ( dirtymap[i] != NULL ) {
-					dirtymap[i] = (SDL_Rect *)(
-					((int)dirtymap[i]-(int)updatelist) +
-								(int)newlist
-					);
+					dirtymap[i] = newlist
+						+ (dirtymap[i]-updatelist);
 				}
 			}
 			delete[] updatelist;
-- 
2.23.0


From e7dbfee8a7a26a20bb222d13077882af1797afe4 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 18 Sep 2019 19:20:02 +1000
Subject: applying patch maelstrom-3.0.6-gcc34.patch


diff --git a/buttonlist.h b/buttonlist.h
index 7bb37b3..980213f 100644
--- a/buttonlist.h
+++ b/buttonlist.h
@@ -16,7 +16,7 @@ public:
 
 	void Add_Button(Uint16 x, Uint16 y, Uint16 width, Uint16 height, 
 						void (*callback)(void)) {
-		struct button *belem;
+		button *belem;
 		
 		for ( belem=&button_list; belem->next; belem=belem->next );
 		belem->next = new button;
@@ -30,7 +30,7 @@ public:
 	}
 
 	void Activate_Button(Uint16 x, Uint16 y) {
-		struct button *belem;
+		button *belem;
 
 		for ( belem=button_list.next; belem; belem=belem->next ) {
 			if ( (x >= belem->x1) && (x <= belem->x2) &&
@@ -42,7 +42,7 @@ public:
 	}
 
 	void Delete_Buttons(void) {
-		struct button *belem, *btemp;
+		button *belem, *btemp;
 
 		for ( belem=button_list.next; belem; ) {
 			btemp = belem;
-- 
2.23.0


From c847365123c9d5183de6b014d6490beced8cb190 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 18 Sep 2019 19:20:02 +1000
Subject: applying patch maelstrom-3.0.6-gcc53.patch


diff --git a/Maelstrom-netd.c b/Maelstrom-netd.c
index fde5c05..0981ebe 100644
--- a/Maelstrom-netd.c
+++ b/Maelstrom-netd.c
@@ -201,7 +201,7 @@ main(int argc, char *argv[])
 	memset(&serv_addr, 0, sizeof(serv_addr));
 	serv_addr.sin_family      = AF_INET;
 	serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
-	serv_addr.sin_port        = htons(NETPLAY_PORT-1);
+	serv_addr.sin_port        = htons(NETPLAY_PORT - 1);
 	if (bind(netfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
 		perror("Can't bind local address");
 		exit(3);
-- 
2.23.0


From 6ccb9114abdc4d7811699b1fcf5c8ed9d71346cf Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 18 Sep 2019 19:20:02 +1000
Subject: applying patch maelstrom-3.0.6-security.patch


diff --git a/controls.cpp b/controls.cpp
index a85e78a..f7eab18 100644
--- a/controls.cpp
+++ b/controls.cpp
@@ -83,7 +83,7 @@ static FILE *OpenData(char *mode, char **fname)
 	if ( fname ) {
 		*fname = datafile;
 	}
-	sprintf(datafile,  "%s"DIR_SEP"%s", home, MAELSTROM_DATA);
+	snprintf(datafile, sizeof(datafile), "%s"DIR_SEP"%s", home, MAELSTROM_DATA);
 	if ( (data=fopen(datafile, mode)) == NULL )
 		return(NULL);
 	return(data);
diff --git a/dialog.h b/dialog.h
index d658d5e..48f4792 100644
--- a/dialog.h
+++ b/dialog.h
@@ -92,7 +92,7 @@ protected:
 		va_list ap;
 
 		va_start(ap, fmt);
-		vsprintf(errbuf, fmt, ap);
+		vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
 		va_end(ap);
 		errstr = errbuf;
         }
@@ -878,7 +878,7 @@ private:
 		if ( entry->text ) {
 			Fontserv->FreeText(entry->text);
 		}
-		sprintf(buf, "%d", *entry->variable);
+		snprintf(buf, sizeof(buf), "%d", *entry->variable);
 
 		if ( entry->hilite ) {
 			clear = Fg;
diff --git a/load.cpp b/load.cpp
index 50ab0c3..79c01fd 100644
--- a/load.cpp
+++ b/load.cpp
@@ -81,7 +81,7 @@ SDL_Surface *Load_Title(FrameBuf *screen, int title_id)
 	SDL_Surface *bmp, *title;
 	
 	/* Open the title file -- we know its colormap is our global one */
-	sprintf(file, "Images"DIR_SEP"Maelstrom_Titles#%d.bmp", title_id);
+	snprintf(file, sizeof(file), "Images"DIR_SEP"Maelstrom_Titles#%d.bmp", title_id);
 	bmp = SDL_LoadBMP(path.Path(file));
 	if ( bmp == NULL ) {
 		return(NULL);
@@ -103,7 +103,7 @@ SDL_Surface *GetCIcon(FrameBuf *screen, short cicn_id)
 	Uint16 w, h;
 	
 	/* Open the cicn sprite file.. */
-	sprintf(file, "Images"DIR_SEP"Maelstrom_Icon#%hd.cicn", cicn_id);
+	snprintf(file, sizeof(file), "Images"DIR_SEP"Maelstrom_Icon#%hd.cicn", cicn_id);
 	if ( (cicn_src=SDL_RWFromFile(path.Path(file), "r")) == NULL ) {
 		error("GetCIcon(%hd): Can't open CICN %s: ",
 					cicn_id, path.Path(file));
diff --git a/maclib/Mac_FontServ.h b/maclib/Mac_FontServ.h
index e919cca..be508c6 100644
--- a/maclib/Mac_FontServ.h
+++ b/maclib/Mac_FontServ.h
@@ -135,7 +135,7 @@ private:
 		va_list ap;
 
 		va_start(ap, fmt);
-		vsprintf(errbuf, fmt, ap);
+		vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
 		va_end(ap);
 		errstr = errbuf;
 	}
diff --git a/maclib/Mac_Resource.h b/maclib/Mac_Resource.h
index 1115b2d..fed5634 100644
--- a/maclib/Mac_Resource.h
+++ b/maclib/Mac_Resource.h
@@ -96,7 +96,7 @@ protected:
 		va_list ap;
 
 		va_start(ap, fmt);
-		vsprintf(errbuf, fmt, ap);
+		vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
 		va_end(ap);
 		errstr = errbuf;
 	}
diff --git a/maclib/Mac_Sound.h b/maclib/Mac_Sound.h
index ba3b36d..d50450e 100644
--- a/maclib/Mac_Sound.h
+++ b/maclib/Mac_Sound.h
@@ -199,7 +199,7 @@ printf("Freeing Wave id %hu at hash page %d/%d\n",(upper<<8)|lower,upper,lower);
 		va_list ap;
 
 		va_start(ap, fmt);
-		vsprintf(errbuf, fmt, ap);
+		vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
 		va_end(ap);
 		errstr = errbuf;
 	}
diff --git a/maclib/Mac_Wave.h b/maclib/Mac_Wave.h
index 54b03a2..9f43d8b 100644
--- a/maclib/Mac_Wave.h
+++ b/maclib/Mac_Wave.h
@@ -108,7 +108,7 @@ private:
 		va_list ap;
 
 		va_start(ap, fmt);
-		vsprintf(errbuf, fmt, ap);
+		vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
 		va_end(ap);
 		errstr = errbuf;
 	}
diff --git a/maclib/macres.cpp b/maclib/macres.cpp
index 756a9e9..ce52342 100644
--- a/maclib/macres.cpp
+++ b/maclib/macres.cpp
@@ -58,8 +58,8 @@ int main(int argc, char *argv[])
 				ids[j], res->ResourceName(types[i], ids[j]));
 			if ( argv[2] ) {
 				char path[23];
-				sprintf(path,"%s/%s:%hu", argv[2],
-							types[i], ids[j]);
+				snprintf(path, sizeof(path), "%s/%s:%hu",
+					 argv[2], types[i], ids[j]);
 				FILE *output;
 				Mac_ResData *D;
             			if ( (output=fopen(path, "w")) != NULL ) {
diff --git a/maclib/snd2wav.cpp b/maclib/snd2wav.cpp
index 987eb07..06101df 100644
--- a/maclib/snd2wav.cpp
+++ b/maclib/snd2wav.cpp
@@ -82,7 +82,7 @@ int main(int argc, char *argv[])
 			continue;
 		}
 		wave.Load(snd, rate);
-		sprintf(wavname, "snd_%d.wav", ids[i]);
+		snprintf(wavname, sizeof(wavname), "snd_%d.wav", ids[i]);
 		wave.Save(wavname);
 	}
 	delete macx;
diff --git a/main.cpp b/main.cpp
index 7728c0b..69ee31e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -445,7 +445,7 @@ static void DrawSoundLevel(void)
 		DrawText(xOff+309-7, yOff+240-6, text, geneva, STYLE_BOLD,
 							0x00, 0x00, 0x00);
 	}
-	sprintf(text, "%d", gSoundLevel);
+	snprintf(text, sizeof(text), "%d", gSoundLevel);
 	DrawText(xOff+309-7, yOff+240-6, text, geneva, STYLE_BOLD,
 						30000>>8, 30000>>8, 0xFF);
 	screen->Update();
@@ -547,11 +547,11 @@ void DrawMainScreen(void)
 		}
 		DrawText(xOff+5, botDiv+42+(index*18), hScores[index].name,
 						font, STYLE_BOLD, R, G, B);
-		sprintf(buffer, "%u", hScores[index].score);
+		snprintf(buffer, sizeof(buffer), "%u", hScores[index].score);
 		sw = fontserv->TextWidth(buffer, font, STYLE_BOLD);
 		DrawText(sRt-sw, botDiv+42+(index*18), buffer, 
 						font, STYLE_BOLD, R, G, B);
-		sprintf(buffer, "%u", hScores[index].wave);
+		snprintf(buffer, sizeof(buffer), "%u", hScores[index].wave);
 		sw = fontserv->TextWidth(buffer, font, STYLE_BOLD);
 		DrawText(wRt-sw, botDiv+42+(index*18), buffer, 
 						font, STYLE_BOLD, R, G, B);
@@ -560,7 +560,7 @@ void DrawMainScreen(void)
 
 	DrawText(xOff+5, botDiv+46+(10*18)+3, "Last Score: ", 
 					bigfont, STYLE_NORM, 0xFF, 0xFF, 0xFF);
-	sprintf(buffer, "%d", GetScore());
+	snprintf(buffer, sizeof(buffer), "%d", GetScore());
 	sw = fontserv->TextWidth("Last Score: ", bigfont, STYLE_NORM);
 	DrawText(xOff+5+sw, botDiv+46+(index*18)+3, buffer, 
 					bigfont, STYLE_NORM, 0xFF, 0xFF, 0xFF);
diff --git a/myerror.cpp b/myerror.cpp
index 83bf1f8..2cb6a71 100644
--- a/myerror.cpp
+++ b/myerror.cpp
@@ -16,7 +16,7 @@ void error(char *fmt, ...)
 	va_list ap;
 
 	va_start(ap, fmt);
-	vsprintf(mesg, fmt, ap);
+	vsnprintf(mesg, sizeof(mesg), fmt, ap);
 	fputs(mesg, stderr);
 	va_end(ap);
 }
@@ -27,7 +27,7 @@ void mesg(char *fmt, ...)
 	va_list ap;
 
 	va_start(ap, fmt);
-	vsprintf(mesg, fmt, ap);
+	vsnprintf(mesg, sizeof(mesg), fmt, ap);
 	fputs(mesg, stdout);
 	va_end(ap);
 }
@@ -37,7 +37,7 @@ void myperror(char *msg)
 	char buffer[BUFSIZ];
 
 	if ( *msg ) {
-		sprintf(buffer, "%s: %s\n", msg, strerror(errno));
+		snprintf(buffer, sizeof(buffer), "%s: %s\n", msg, strerror(errno));
 		error(buffer);
 	} else
 		error((char *)strerror(errno));
diff --git a/netlogic/game.cpp b/netlogic/game.cpp
index 6cc1ff9..bfa39eb 100644
--- a/netlogic/game.cpp
+++ b/netlogic/game.cpp
@@ -232,7 +232,7 @@ void DrawStatus(Bool first, Bool ForceDraw)
 
 			lastDisplayed = gDisplayed;
 			screen->FillRect(0, 0, SCREEN_WIDTH, 12, ourBlack);
-			sprintf(caption,
+			snprintf(caption, sizeof(caption),
 				"You are player %d --- displaying player %d",
 						gOurPlayer+1, gDisplayed+1);
 			DrawText(SPRITES_WIDTH, 11, caption, geneva,
@@ -357,7 +357,7 @@ void DrawStatus(Bool first, Bool ForceDraw)
 				/* -- Erase old and draw new score */
 				screen->FillRect(45, gStatusLine+1,
 					score_width, text_height, ourBlack);
-				sprintf(numbuf, "%d", Score);
+				snprintf(numbuf, sizeof(numbuf), "%d", Score);
 				score_width = DrawText(45, gStatusLine+11, 
 						numbuf, geneva, STYLE_BOLD,
 							0xFF, 0xFF, 0xFF);
@@ -380,7 +380,7 @@ void DrawStatus(Bool first, Bool ForceDraw)
 		if (lastWave != gWave) {
 			screen->FillRect(255, gStatusLine+1,
 					wave_width, text_height, ourBlack);
-			sprintf(numbuf, "%d", gWave);
+			snprintf(numbuf, sizeof(numbuf), "%d", gWave);
 			wave_width = DrawText(255, gStatusLine+11, 
 					numbuf, geneva, STYLE_BOLD,
 							0xFF, 0xFF, 0xFF);
@@ -391,7 +391,7 @@ void DrawStatus(Bool first, Bool ForceDraw)
 		if (lastLives != Lives) {
 			screen->FillRect(319, gStatusLine+1,
 					lives_width, text_height, ourBlack);
-			sprintf(numbuf, "%-3.1d", Lives);
+			snprintf(numbuf, sizeof(numbuf), "%-3.1d", Lives);
 			lives_width = DrawText(319, gStatusLine+11,
 					numbuf, geneva, STYLE_BOLD,
 							0xFF, 0xFF, 0xFF);
@@ -402,7 +402,7 @@ void DrawStatus(Bool first, Bool ForceDraw)
 		if (lastBonus != Bonus) {
 			screen->FillRect(384, gStatusLine+1,
 					bonus_width, text_height, ourBlack);
-			sprintf(numbuf, "%-7.1d", Bonus);
+			snprintf(numbuf, sizeof(numbuf), "%-7.1d", Bonus);
 			bonus_width = DrawText(384, gStatusLine+11,
 					numbuf, geneva, STYLE_BOLD,
 							0xFF, 0xFF, 0xFF);
@@ -414,7 +414,7 @@ void DrawStatus(Bool first, Bool ForceDraw)
 			if (lastFrags != Frags) {
 				screen->FillRect(fragoff, gStatusLine+1,
 					frags_width, text_height, ourBlack);
-				sprintf(numbuf, "%-3.1d", Frags);
+				snprintf(numbuf, sizeof(numbuf), "%-3.1d", Frags);
 				frags_width = DrawText(fragoff, gStatusLine+11,
 						numbuf, geneva, STYLE_BOLD,
 							0xFF, 0xFF, 0xFF);
@@ -747,10 +747,11 @@ static void DoGameOver(void)
 		for ( i=0; i<gNumPlayers; ++i ) {
 			char buffer[BUFSIZ], num1[12], num2[12];
 
-			sprintf(num1, "%7.1d", final[i].Score);
-			sprintf(num2, "%3.1d", final[i].Frags);
-			sprintf(buffer, "Player %d: %-.7s Points, %-.3s Frags",
-						final[i].Player, num1, num2);
+			snprintf(num1, sizeof(num1), "%7.1d", final[i].Score);
+			snprintf(num2, sizeof(num2), "%3.1d", final[i].Frags);
+			snprintf(buffer, sizeof(buffer),
+				 "Player %d: %-.7s Points, %-.3s Frags",
+				 final[i].Player, num1, num2);
 			DrawText(160, 380+i*newyork_height, buffer,
 				newyork, STYLE_NORM, 30000>>8, 30000>>8, 0xFF);
 		}
@@ -898,7 +899,7 @@ static void DoBonus(void)
 	
 
 	/* -- Draw the wave completed message */
-	sprintf(numbuf, "Wave %d completed.", gWave);
+	snprintf(numbuf, sizeof(numbuf), "Wave %d completed.", gWave);
 	sw = fontserv->TextWidth(numbuf, geneva, STYLE_BOLD);
 	x = (SCREEN_WIDTH - sw) / 2;
 	DrawText(x,  150, numbuf, geneva, STYLE_BOLD, 0xFF, 0xFF, 0x00);
@@ -935,7 +936,7 @@ static void DoBonus(void)
 		if (OurShip->GetBonusMult() != 1) {
 			SDL_Surface *sprite;
 
-			sprintf(numbuf, "%-5.1d", OurShip->GetBonus());
+			snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetBonus());
 			DrawText(x, 200, numbuf, geneva, STYLE_BOLD,
 							0xFF, 0xFF, 0xFF);
 			x += 75;
@@ -951,10 +952,10 @@ static void DoBonus(void)
 	Delay(SOUND_DELAY);
 	sound->PlaySound(gFunk, 5);
 
-	sprintf(numbuf, "%-5.1d", OurShip->GetBonus());
+	snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetBonus());
 	bonus_width = DrawText(x, 200, numbuf, geneva, STYLE_BOLD,
 							0xFF, 0xFF, 0xFF);
-	sprintf(numbuf, "%-5.1d", OurShip->GetScore());
+	snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetScore());
 	score_width = DrawText(xt, 220, numbuf, geneva, STYLE_BOLD,
 							0xFF, 0xFF, 0xFF);
 	screen->Update();
@@ -997,12 +998,12 @@ static void DoBonus(void)
 	
 			screen->FillRect(x, 200-text_height+2,
 					bonus_width, text_height, ourBlack);
-			sprintf(numbuf, "%-5.1d", OurShip->GetBonus());
+			snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetBonus());
 			bonus_width = DrawText(x, 200, numbuf,
 					geneva, STYLE_BOLD, 0xFF, 0xFF, 0xFF);
 			screen->FillRect(xt, 220-text_height+2,
 					score_width, text_height, ourBlack);
-			sprintf(numbuf, "%-5.1d", OurShip->GetScore());
+			snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetScore());
 			score_width = DrawText(xt, 220, numbuf,
 					geneva, STYLE_BOLD, 0xFF, 0xFF, 0xFF);
 
@@ -1015,7 +1016,7 @@ static void DoBonus(void)
 	HandleEvents(10);
 
 	/* -- Draw the "next wave" message */
-	sprintf(numbuf, "Prepare for Wave %d...", gWave+1);
+	snprintf(numbuf, sizeof(numbuf), "Prepare for Wave %d...", gWave+1);
 	sw = fontserv->TextWidth(numbuf, geneva, STYLE_BOLD);
 	x = (SCREEN_WIDTH - sw)/2;
 	DrawText(x, 259, numbuf, geneva, STYLE_BOLD, 0xFF, 0xFF, 0x00);
diff --git a/netlogic/netplay.cpp b/netlogic/netplay.cpp
index 6c4dc1e..30eb55f 100644
--- a/netlogic/netplay.cpp
+++ b/netlogic/netplay.cpp
@@ -670,7 +670,9 @@ int Send_NewGame(int *Wave, int *Lives, int *Turbo)
 		strcpy(message, "Waiting for players:");
 		for ( i=0; i<gNumPlayers; ++i ) {
 			if ( ! acked[i] )
-				sprintf(&message[strlen(message)], " %d", i+1);
+				snprintf(&message[strlen(message)],
+					 sizeof(message)-strlen(message),
+					 " %d", i+1);
 		}
 		Message(message);
 
@@ -725,7 +727,7 @@ int Send_NewGame(int *Wave, int *Lives, int *Turbo)
 			/* Check the player... */
 			if ( (i != gOurPlayer) && (netbuf[1] == gOurPlayer) ) {
 				/* Print message, sleep 3 seconds absolutely */
-				sprintf(message, 
+			  snprintf(message, sizeof(message),
 	"Error: Another player (%d) thinks they are player 1!\r\n", i+1);
 				ErrorMessage(message);
 				/* Suck up retransmission packets */
diff --git a/netscore.cpp b/netscore.cpp
index 27c2713..3cfc71c 100644
--- a/netscore.cpp
+++ b/netscore.cpp
@@ -59,7 +59,7 @@ void RegisterHighScore(Scores high)
 
 	/* Send the scores */
 	crc = get_checksum(key, KEY_LEN);
-	sprintf(netbuf, SCOREFMT, crc, high.name, high.score, high.wave);
+	snprintf(netbuf, sizeof(netbuf), SCOREFMT, crc, high.name, high.score, high.wave);
 	SDLNet_TCP_Send(remote, netbuf, strlen(netbuf));
 	n = SDLNet_TCP_Recv(remote, netbuf, 1024);
 	if ( n > 0 ) {
diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index 01bb13a..3ce33d2 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -628,7 +628,7 @@ FrameBuf:: ScreenDump(char *prefix, Uint16 x, Uint16 y, Uint16 w, Uint16 h)
 
 		found = 0;
 		for ( which=0; !found; ++which ) {
-			sprintf(file, "%s%d.bmp", prefix, which);
+			snprintf(file, sizeof(file), "%s%d.bmp", prefix, which);
 			if ( ((fp=fopen(file, "r")) == NULL) &&
 			     ((fp=fopen(file, "w")) != NULL) ) {
 				found = 1;
diff --git a/screenlib/SDL_FrameBuf.h b/screenlib/SDL_FrameBuf.h
index 1957c81..cb53085 100644
--- a/screenlib/SDL_FrameBuf.h
+++ b/screenlib/SDL_FrameBuf.h
@@ -165,7 +165,7 @@ private:
 		va_list ap;
 
 		va_start(ap, fmt);
-		vsprintf(errbuf, fmt, ap);
+		vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
 		va_end(ap);
 		errstr = errbuf;
         }
-- 
2.23.0


From cdf04bd50e54c382eae96f1d8f9711e7aacbe0a2 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 18 Sep 2019 19:20:02 +1000
Subject: applying patch maelstrom-3.0.6-warnings.patch


diff --git a/Maelstrom-netd.c b/Maelstrom-netd.c
index 0981ebe..afc409c 100644
--- a/Maelstrom-netd.c
+++ b/Maelstrom-netd.c
@@ -1,7 +1,9 @@
 
 /* Here we go... */
 
+#include <stdlib.h>
 #include <stdio.h>
+#include <time.h>
 #include <string.h>
 #include <signal.h>
 #include <errno.h>
@@ -9,6 +11,7 @@
 #include <sys/time.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
 #include <netdb.h>
 #include <unistd.h>
 
-- 
2.23.0


From 6fb3dc44dd2a5af83d81abee0bb9db9d40cb6158 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 12 Jan 2014 13:27:13 +0100
Subject: Add haiku support to configure script.


diff --git a/configure.in b/configure.in
index 0170f4b..4f99f3f 100644
--- a/configure.in
+++ b/configure.in
@@ -33,6 +33,10 @@ case "$target" in
         MATHLIB=""
         INETLIB=""
         ;;
+    *-*-haiku*)
+        MATHLIB=""
+        INETLIB="-lnetwork"
+        ;;
     *-*-darwin*)
         MATHLIB=""
         INETLIB=""
-- 
2.23.0


From 36daf3d5258e31f4850273e52ca6b9dc15bc2044 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Mon, 8 Jul 2019 21:44:51 +0200
Subject: Fix install path


diff --git a/configure.in b/configure.in
index 4f99f3f..b7e4942 100644
--- a/configure.in
+++ b/configure.in
@@ -108,6 +108,10 @@ case "$target" in
         ac_default_prefix=/boot/beos
         GAME_INSTALLDIR="\$(prefix)/games/$PACKAGE"
         ;;
+    *-*-haiku*)
+        ac_default_prefix=/system
+        GAME_INSTALLDIR="\$(prefix)/apps/$PACKAGE"
+        ;;
     *)
         GAME_INSTALLDIR="\$(prefix)/games/$PACKAGE"
         ;;
-- 
2.23.0


From 7cb40b66613a6e1ffaf02cbc903617b5b3255259 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 18 Sep 2019 20:02:29 +1000
Subject: Set realpath for binary


diff --git a/main.cpp b/main.cpp
index 69ee31e..78b4168 100644
--- a/main.cpp
+++ b/main.cpp
@@ -174,6 +174,12 @@ int main(int argc, char *argv[])
 
 	/* Normal variables */
 	SDL_Event event;
+#ifdef __HAIKU__
+	char *binpath = realpath(argv[0], NULL);
+	if (binpath != NULL)
+		argv[0] = binpath;
+#endif
+
 	LibPath::SetExePath(argv[0]);
 
 #ifndef __WIN95__
-- 
2.23.0

