From 62f4ee23ae8021134b861e3d6faf0dd089b075f1 Mon Sep 17 00:00:00 2001
From: Damien Lee <hometue.lee@gmail.com>
Date: Tue, 5 Jan 2016 18:51:11 +0000
Subject: Patch for Haiku and C89 standard


diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed8bf91..618d158 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,14 +14,16 @@ endif(NOT ${INSTALL_FHS})
 # Uncomment this to hardcode the data path. On the command line, you
 # would actually give -DDATAPATH='"/usr/share/games/gish"' or similar
 # but CMake does the extra quoting for us.
-#add_definitions(-DDATAPATH="/usr/share/games/gish")
+#add_definitions(-DDATAPATH="/boot/home/config/non-packaged/bin/")
 
 find_package(SDL REQUIRED)
 find_package(OpenAL REQUIRED)
 find_package(OpenGL REQUIRED)
 find_package(Vorbis REQUIRED)
 find_package(PNG REQUIRED)
-find_library(M_LIBRARIES m)
+if(NOT HAIKU)
+	find_library(M_LIBRARIES m)
+endif(NOT HAIKU)
 
 include_directories(
     ${SDL_INCLUDE_DIR}
@@ -29,6 +31,7 @@ include_directories(
     ${OPENGL_INCLUDE_DIR}
     ${Vorbis_INCLUDE_DIR}
     ${PNG_INCLUDE_DIR}
+
 )
 
 if(NOT BIN_DIR)
diff --git a/src/main.c b/src/main.c
index d1f00c8..9b1a513 100644
--- a/src/main.c
+++ b/src/main.c
@@ -85,6 +85,8 @@ int main (int argc,char *argv[])
   int count;
   int flags;
   const char *temp;
+  Uint32 videoModeFlags;
+  SDL_Surface *surface;
 
 #ifdef DATAPATH
   chdir(DATAPATH);
@@ -151,12 +153,12 @@ int main (int argc,char *argv[])
   SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,windowinfo.depthbits);
   SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,windowinfo.stencilbits);
   SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
-
-
-  Uint32 videoModeFlags = SDL_OPENGL;
+  
+  
+  videoModeFlags = SDL_OPENGL;
   if (windowinfo.fullscreen)
     videoModeFlags |= SDL_FULLSCREEN;
-  SDL_Surface *surface = SDL_SetVideoMode(windowinfo.resolutionx,windowinfo.resolutiony,windowinfo.bitsperpixel,videoModeFlags);
+  *surface = *SDL_SetVideoMode(windowinfo.resolutionx,windowinfo.resolutiony,windowinfo.bitsperpixel,videoModeFlags);
   if (!surface)
     {
     fprintf(stderr, "Failed to initialize video:\n%s\n",SDL_GetError());
diff --git a/src/video/opengl.h b/src/video/opengl.h
index 77ce8bc..aa030b0 100644
--- a/src/video/opengl.h
+++ b/src/video/opengl.h
@@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "../video/glext.h"
 #endif
 
-#if defined(LINUX) || defined(__FreeBSD_kernel__) || defined(__GNU__)
+#if defined(LINUX) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__HAIKU__)
 #include <GL/gl.h>
 #include <GL/glext.h>
 #endif
diff --git a/src/video/texture.c b/src/video/texture.c
index 69ecae4..6196260 100644
--- a/src/video/texture.c
+++ b/src/video/texture.c
@@ -52,7 +52,12 @@ int loadtexturepng(const char *filename, unsigned int **rgba, int *width, int *h
 {
 	FILE *fp;
 	int load_status;
-	
+	png_uint_32 texwidth;
+	png_uint_32 texheight;
+	int bit_depth;
+	int color_type;
+	int interlace_type;
+
 	if((fp = fopen(filename, "rb")) == NULL)
 	{
 		if(debug_texture_load) fprintf(stderr, "Texture Load Failed: %s\n", filename);
@@ -88,12 +93,12 @@ int loadtexturepng(const char *filename, unsigned int **rgba, int *width, int *h
 						png_init_io(png_ptr, fp);
 						png_set_sig_bytes(png_ptr, 8);
 						png_read_info(png_ptr, info_ptr);
-						png_uint_32 texwidth = 0;
-						png_uint_32 texheight = 0;
-						int bit_depth = 0;
-                        			int color_type = 0;
-                        			int interlace_type = 0;
-			                        png_get_IHDR(png_ptr, info_ptr, &texwidth, &texheight, &bit_depth, &color_type, 0, 0, 0);
+						texwidth = 0;
+						texheight = 0;
+						bit_depth = 0;
+						color_type = 0;
+						interlace_type = 0;
+						png_get_IHDR(png_ptr, info_ptr, &texwidth, &texheight, &bit_depth, &color_type, 0, 0, 0);
 
 						/* expand paletted colors into true rgb */
 						if (color_type == PNG_COLOR_TYPE_PALETTE)
-- 
2.2.2