shithub: candycrisis

Download patch

ref: d6986d5f616a7cd189abb239e2ec2019819cfeb9
parent: 9cfde203bbe109f41b25d02b5c9602345c986fff
author: Iliyas Jorio <iliyas@jor.io>
date: Sat Feb 11 06:49:44 EST 2023

Fix compile warnings

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -177,9 +177,10 @@
 	target_compile_options(${GAME_TARGET} PRIVATE
 		-Wall
 		-Wextra
-		-Wshadow
+		#-Wshadow  # Note: Candy Crisis goes crazy with shadowing
 		-Werror=return-type
 		-Wstrict-aliasing=2
+		-Wno-multichar
 	)
 
 	# Sanitizers in debug mode (Linux only)
--- a/src/level.c
+++ b/src/level.c
@@ -130,9 +130,9 @@
     SDL_Surface*    gameStartDrawSurface;
 #if USE_CURSOR_SPRITE
     SDL_Surface*    cursorBackSurface;
+	SDL_Rect        cursorBackSDLRect = { 0, 0, kCursorWidth, kCursorHeight };
 #endif
 	SDL_Rect        backdropSDLRect = { 0, 0, 640, 480 };
-	SDL_Rect        cursorBackSDLRect = { 0, 0, kCursorWidth, kCursorHeight };
 	SDL_Rect        destSDLRect;
 	MRect           drawRect[4], chunkRect, tempRect;
 	int             blob, count, oldGlow, splat, chunkType, selected;
@@ -150,9 +150,11 @@
     const int       kTitleGlowOff = useNewTitle? 150: 192;
     const bool      secretCreditsItem = !useNewTitle;
     
-	const int       kLeftSide = 0, kRightSide = 1, kGlow = 2, kCursor = 3;
+	const int       kLeftSide = 0, kRightSide = 1, kGlow = 2;
+#if USE_CURSOR_SPRITE
+	const int       kCursor = 3;
+#endif
 	
-	
 redo:
 	memcpy(titleItems, k_titleItemDefs, sizeof(titleItems));
 
@@ -799,23 +801,23 @@
 MBoolean InitCharacter( int player, int level )
 {
 	const Character characterList[] = {
-		{ -1 }, // no zero'th character
-		{ 0, 3, 1, { 8, 8, 8, 8, 8, 8 }, 13, 9, 0, 25,          { 0, _15TO8_8_8(0),     0, 0, _15TO8_8_8(0), 0 }, true },
-		{ 1, 6, 2, { 10, 9, 8, 8, 9, 10 }, 12, 7, 1, 20,        { 0, _15TO8_8_8(223),   7, 0, _15TO8_8_8(0), 0 }, true },
-		{ 2, 9, 3, { 7, 7, 7, 11, 7, 7 }, 10, 6, 2, 17,         { 0, _15TO8_8_8(0),     0, 0, _15TO8_8_8(0), 0 }, false },
-		{ 3, 12, 4, { 11, 10, 9, 8, 7, 6 }, 8, 5, 3, 13,        { 0, _15TO8_8_8(32767), 4, 0, _15TO8_8_8(16912), 4 }, false },
-		{ 4, 15, 0, { 5, 9, 10, 10, 9, 5 }, 7, 4, 4, 10,        { 0, _15TO8_8_8(32767), 1, 0, _15TO8_8_8(0), 0 }, false },
-		{ 5, 17, 1, { 4, 7, 11, 11, 6, 3 }, 7, 2, 5, 8,         { 0, _15TO8_8_8(14835), 8, 0, _15TO8_8_8(0), 0 }, false },
-		{ 6, 18, 2, { 7, 9, 10, 10, 9, 7 }, 6, 4, 6, 7,         { 0, _15TO8_8_8(0),     0, 0, _15TO8_8_8(0), 0 }, false },
-		{ 7, 20, 3, { 5, 10, 10, 10, 10, 5 }, 5, 3, 7, 5,       { 0, _15TO8_8_8(9696),  2, 0, _15TO8_8_8(21151), 3 }, false },
-		{ 8, 21, 4, { 11, 11, 10, 10, 9, 9 }, 4, 3, 8, 5,       { 0, _15TO8_8_8(32738), 5, 0, _15TO8_8_8(0), 0 }, false },
-		{ 9, 22, 0, { 11, 7, 11, 7, 11, 7 }, 3, 1, 9, 4,        { 0, _15TO8_8_8(32356), 5, 0, _15TO8_8_8(17392), 3 }, false },
-		{ 10, 23, 1, { 11, 11, 11, 11, 11, 11 }, 2, 1, 10, 2,   { 0, _15TO8_8_8(6337),  1, 0, _15TO8_8_8(0), 0 }, false },
-		{ 11, 24, 2, { 11, 11, 11, 11, 11, 11 }, 2, 1, 11, 2,   { 1, _15TO8_8_8(32767), 7, 0, _15TO8_8_8(0), 0 }, false },
-		{ -1 }, // skip
-		{ 13, 24, 1, { 11, 11, 11, 11, 11, 11 }, 10, 5, 0, 30,  { 0, _15TO8_8_8(0),     0, 0, _15TO8_8_8(0), 0 }, true }
+		{ .picture=-1 }, // no zero'th character
+		{  0,  3, 1, {  8,  8,  8,  8,  8,  8 }, 13, 9,  0, 25, {{ 0, _15TO8_8_8(    0), 0 }, { 0, _15TO8_8_8(    0), 0 }}, true },
+		{  1,  6, 2, { 10,  9,  8,  8,  9, 10 }, 12, 7,  1, 20, {{ 0, _15TO8_8_8(  223), 7 }, { 0, _15TO8_8_8(    0), 0 }}, true },
+		{  2,  9, 3, {  7,  7,  7, 11,  7,  7 }, 10, 6,  2, 17, {{ 0, _15TO8_8_8(    0), 0 }, { 0, _15TO8_8_8(    0), 0 }}, false },
+		{  3, 12, 4, { 11, 10,  9,  8,  7,  6 },  8, 5,  3, 13, {{ 0, _15TO8_8_8(32767), 4 }, { 0, _15TO8_8_8(16912), 4 }}, false },
+		{  4, 15, 0, {  5,  9, 10, 10,  9,  5 },  7, 4,  4, 10, {{ 0, _15TO8_8_8(32767), 1 }, { 0, _15TO8_8_8(    0), 0 }}, false },
+		{  5, 17, 1, {  4,  7, 11, 11,  6,  3 },  7, 2,  5,  8, {{ 0, _15TO8_8_8(14835), 8 }, { 0, _15TO8_8_8(    0), 0 }}, false },
+		{  6, 18, 2, {  7,  9, 10, 10,  9,  7 },  6, 4,  6,  7, {{ 0, _15TO8_8_8(    0), 0 }, { 0, _15TO8_8_8(    0), 0 }}, false },
+		{  7, 20, 3, {  5, 10, 10, 10, 10,  5 },  5, 3,  7,  5, {{ 0, _15TO8_8_8( 9696), 2 }, { 0, _15TO8_8_8(21151), 3 }}, false },
+		{  8, 21, 4, { 11, 11, 10, 10,  9,  9 },  4, 3,  8,  5, {{ 0, _15TO8_8_8(32738), 5 }, { 0, _15TO8_8_8(    0), 0 }}, false },
+		{  9, 22, 0, { 11,  7, 11,  7, 11,  7 },  3, 1,  9,  4, {{ 0, _15TO8_8_8(32356), 5 }, { 0, _15TO8_8_8(17392), 3 }}, false },
+		{ 10, 23, 1, { 11, 11, 11, 11, 11, 11 },  2, 1, 10,  2, {{ 0, _15TO8_8_8( 6337), 1 }, { 0, _15TO8_8_8(    0), 0 }}, false },
+		{ 11, 24, 2, { 11, 11, 11, 11, 11, 11 },  2, 1, 11,  2, {{ 1, _15TO8_8_8(32767), 7 }, { 0, _15TO8_8_8(    0), 0 }}, false },
+		{ .picture=-1 }, // skip
+		{ 13, 24, 1, { 11, 11, 11, 11, 11, 11 }, 10, 5,  0, 30, {{ 0, _15TO8_8_8(    0), 0 }, { 0, _15TO8_8_8(    0), 0 }}, true }
 	};
-		
+	
 	character[player] = characterList[level];
 	return (character[player].picture != -1);
 }
binary files a/src/main.c b/src/main.c differ
--- a/src/pause.c
+++ b/src/pause.c
@@ -170,7 +170,7 @@
 {
 	unsigned char* src[4];
 	int srcRowBytes, width, height, count;
-	char edgeMap[4][kEdgeSize][kEdgeSize+1]={  "      --",
+	char edgeMap[4][kEdgeSize][kEdgeSize+1]={{ "      --",
 					                           "    -...",
 					                           "   -.xxX",
 					                           "  -.xXXX",
@@ -177,8 +177,8 @@
 					                           " -.xXXXX",
 					                           " .xXXXXX",
 					                           "-.xXXXXX",
-					                           "-.XXXXXX",
-					                           "--      ",
+					                           "-.XXXXXX" },
+					                         { "--      ",
 					                           "...-    ",
 					                           "Xxx.-   ",
 					                           "XXXx.-  ",
@@ -185,8 +185,8 @@
 					                           "XXXXx.- ",
 					                           "XXXXXx. ",
 					                           "XXXXXx.-",
-					                           "XXXXXX.-",
-					                           "-.XXXXXX",
+					                           "XXXXXX.-" },
+					                         { "-.XXXXXX",
 					                           "-.xXXXXX",
 					                           " .xXXXXX",
 					                           " -.xXXXX",
@@ -193,8 +193,8 @@
 					                           "  -.xXXX",
 					                           "   -.xxX",
 					                           "    -...",
-					                           "      --",
-					                           "XXXXXX.-",
+					                           "      --" },
+					                         { "XXXXXX.-",
 					                           "XXXXXx.-",
 					                           "XXXXXx. ",
 					                           "XXXXx.- ",
@@ -201,7 +201,7 @@
 					                           "XXXx.-  ",
 					                           "Xxx.-   ",
 					                           "...-    ",
-					                           "--      "  };
+					                           "--      " } };
 	                         	                         
 	
 	src[0] = src[1] = src[2] = src[3] = (unsigned char*) edgeSurface->pixels;
@@ -804,6 +804,8 @@
 
 static MBoolean ContinueSelected( int *item, unsigned char inKey, SDL_Keycode inSDLKey )
 {
+	(void) inKey;
+
 	static const ClickableZone zones[] =
 	{
 		{ kContinue,	{280, 220, 300, 260} },
@@ -947,8 +949,8 @@
 
 static MBoolean PauseSelected( int *item, unsigned char inKey, SDL_Keycode inSDLKey )
 {
-	(void) inSDLKey; // is unused
-	
+	(void) inKey;
+
 	static const ClickableZone zones[] = 
 	{	
 		{ kMusic,		{ 240, 180, 260, 320 } },		{ kResume,		{ 240, 340, 260, 480 } },
@@ -1028,7 +1030,7 @@
 
 static MBoolean VideoSettingsSelected( int *item, unsigned char inKey, SDL_Keycode inSDLKey )
 {
-	(void) inSDLKey; // is unused
+	(void) inKey;
 	
 	static const ClickableZone zones[] = 
 	{	
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -93,7 +93,7 @@
     for (int i = 0; i < arrsize(prefList); i++)
     {
         const Preference* pref = &prefList[i];
-        fputc(strlen(pref->keyName), stream);
+        fputc((uint8_t) strlen(pref->keyName), stream);
         fwrite(pref->keyName, strlen(pref->keyName), 1, stream);
         fwrite(&pref->valueLength, sizeof(pref->valueLength), 1, stream);
         fwrite(pref->valuePtr, pref->valueLength, 1, stream);
--- a/src/tweak.c
+++ b/src/tweak.c
@@ -12,7 +12,7 @@
 
 MTicks xTweakTime[2], yTweakTime[2], rTweakTime[2];
 int yTweak[2], xTweak[2], xDirection[2], rTweak[2], rDirection[2];
-int lastShadow[2];
+static unsigned int lastShadow[2];
 int tweakOffsetX[4][11], tweakOffsetY[4][11];
 
 void InitTweak( void )