DEADSOFTWARE

opengl: fix segfault
[flatwaifu.git] / src / gl / render.c
index e9dc5b5addb443537778fc50ed596e4a0f05244b..e74d6bb5229989165983fcc619a715a25cfdd41c 100644 (file)
 #include "view.h"
 #include "switch.h" // sw_secrets
 
-#include <OpenGL/GL.h>
+#ifdef __APPLE__
+#  include <OpenGL/gl.h>
+#else
+#  include <GL/gl.h>
+#endif
 #include <stdlib.h> // malloc free abs
 #include <assert.h> // assert
 #include <SDL.h>
@@ -1628,10 +1632,10 @@ void R_get_name (int n, char s[8]) {
 
 static short getani (char n[8]) {
   short i = 0;
-  while (i < ANIT && strncasecmp(n, anm[i][0], 8) != 0) {
+  while (i < ANIT - 1 && strncasecmp(n, anm[i][0], 8) != 0) {
     i++;
   }
-  return i < ANIT ? i + 1 : 0;
+  return i < ANIT - 1 ? i + 1 : 0;
 }
 
 int R_get_special_id (int n) {
@@ -1669,7 +1673,7 @@ void R_load (char s[8], int f) {
     };
   } else if (strncasecmp(s, "_WATER_", 7) == 0) {
     walp[max_textures] = (image) {
-      .n = (void*)(s[7] - '0' + 1),
+      .n = (void*)((intptr_t)s[7] - '0' + 1),
       .x = 0,
       .y = 0,
       .w = 8,
@@ -1723,4 +1727,4 @@ void R_loadsky (int sky) {
   s[4] = '0' + sky;
   R_gl_free_image(&horiz);
   horiz = R_gl_loadimage(s);
-}
\ No newline at end of file
+}