diff --git a/CMakeLists.txt b/CMakeLists.txt index f204134..bb77465 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,9 +177,10 @@ if(NOT MSVC) 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) diff --git a/src/level.c b/src/level.c index 1b236e6..0d3667a 100644 --- a/src/level.c +++ b/src/level.c @@ -130,9 +130,9 @@ void GameStartMenu( void ) 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,8 +150,10 @@ void GameStartMenu( void ) 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 @@ void ResetWidescreenLayout() 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); } diff --git a/src/main.c b/src/main.c index b2cdca0..7f628cd 100644 --- a/src/main.c +++ b/src/main.c @@ -659,7 +659,7 @@ void QuickFadeIn( MRGBColor *color ) for( float percent=0.0f; percent<1.0f; percent += 0.04f ) { - int c = MTickCount( ); + MTicks c = MTickCount( ); SDLU_SetBrightness( percent ); while( c == MTickCount( ) ) { @@ -679,7 +679,7 @@ void QuickFadeOut( MRGBColor *color ) for( float percent=1.0f; percent>0.0f; percent -= 0.04f ) { - int c = MTickCount( ); + MTicks c = MTickCount( ); SDLU_SetBrightness( percent ); while( c == MTickCount( ) ) { diff --git a/src/pause.c b/src/pause.c index 9fe7e54..a4e76ee 100644 --- a/src/pause.c +++ b/src/pause.c @@ -170,38 +170,38 @@ void SurfaceCurveEdges( SDL_Surface* edgeSurface, const MRect *rect ) { unsigned char* src[4]; int srcRowBytes, width, height, count; - char edgeMap[4][kEdgeSize][kEdgeSize+1]={ " --", + char edgeMap[4][kEdgeSize][kEdgeSize+1]={{ " --", " -...", " -.xxX", " -.xXXX", " -.xXXXX", " .xXXXXX", "-.xXXXXX", - "-.XXXXXX", - "-- ", + "-.XXXXXX" }, + { "-- ", "...- ", "Xxx.- ", "XXXx.- ", "XXXXx.- ", "XXXXXx. ", "XXXXXx.-", - "XXXXXX.-", - "-.XXXXXX", + "XXXXXX.-" }, + { "-.XXXXXX", "-.xXXXXX", " .xXXXXX", " -.xXXXX", " -.xXXX", " -.xxX", " -...", - " --", - "XXXXXX.-", + " --" }, + { "XXXXXX.-", "XXXXXx.-", "XXXXXx. ", "XXXXx.- ", "XXXx.- ", "Xxx.- ", "...- ", - "-- " }; + "-- " } }; src[0] = src[1] = src[2] = src[3] = (unsigned char*) edgeSurface->pixels; @@ -804,6 +804,8 @@ static MBoolean GetClickedZone( int* item, SDL_Keycode inSDLKey, int numZones, c 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 ControlsSelected( int *item, unsigned char inKey, SDL_Keycode in 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 PauseSelected( int *item, unsigned char inKey, SDL_Keycode inSDL static MBoolean VideoSettingsSelected( int *item, unsigned char inKey, SDL_Keycode inSDLKey ) { - (void) inSDLKey; // is unused + (void) inKey; static const ClickableZone zones[] = { diff --git a/src/prefs.c b/src/prefs.c index 6e83808..bfb1a88 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -93,7 +93,7 @@ void SavePrefs() 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); diff --git a/src/tweak.c b/src/tweak.c index 35ca4d8..903bc40 100644 --- 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 )