Skip to content

Commit

Permalink
Fix compile warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jorio committed Feb 11, 2023
1 parent 9cfde20 commit d6986d5
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 35 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
40 changes: 21 additions & 19 deletions src/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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( ) )
{
Expand All @@ -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( ) )
{
Expand Down
24 changes: 13 additions & 11 deletions src/pause.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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} },
Expand Down Expand Up @@ -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 } },
Expand Down Expand Up @@ -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[] =
{
Expand Down
2 changes: 1 addition & 1 deletion src/prefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/tweak.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit d6986d5

Please sign in to comment.