Skip to content

Commit

Permalink
Warning fixes and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Nov 23, 2023
1 parent 63faa33 commit d853a9e
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 81 deletions.
1 change: 0 additions & 1 deletion src/common/TilesetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class CTileset
private:
char szName[256];
char szTilesetPath[1024];
char szGfxPack[256];

SDL_Surface * sSurfaces[3];
gfxSprite sSprites[3];
Expand Down
2 changes: 0 additions & 2 deletions src/common/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,13 @@ void CPlayerInput::Update(SDL_Event event, short iGameState)
for (short iPlayer = -1; iPlayer < MAX_PLAYERS; iPlayer++) {
CInputControl * inputControl;
COutputControl * outputControl;
short iPlayerID = iPlayer;
short iDeviceID = DEVICE_KEYBOARD;

//Allow keyboard input from player 1 at all times (even when he is configured to use joystick)
if (iPlayer == -1) {
if (iGameState == 1 && inputControls[0]->iDevice != DEVICE_KEYBOARD) {
inputControl = &game_values.inputConfiguration[0][0].inputGameControls[1];
outputControl = &outputControls[0];
iPlayerID = 0;
iDeviceID = game_values.inputConfiguration[0][0].iDevice;
} else {
continue;
Expand Down
16 changes: 1 addition & 15 deletions src/common/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,27 +437,13 @@ void DrawPlatform(short pathtype, TilesetTile ** tiles, short startX, short star


CMap::CMap()
: iNumMapItems(0)
, iNumMapHazards(0)
, platforms(nullptr)
, iNumPlatforms(0)
, warpexits()
, maxConnection(0)
: warpexits()
, tilebltrect()
, bltrect()
, drawareas()
, numdrawareas(0)
, iSwitches()
, racegoallocations()
, flagbaselocations()
, iTileAnimationTimer(0)
, iTileAnimationFrame(0)
, iAnimatedBackgroundLayers(0)
, animatedFrontmapSurface(nullptr)
, animatedBackmapSurface(nullptr)
, animatedTilesSurface(nullptr)
, iAnimatedTileCount(0)
, numwarpexits(0)
{}

CMap::~CMap()
Expand Down
33 changes: 16 additions & 17 deletions src/common/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ class CMap
short eyecandy[3];
short musicCategoryID;

short iNumMapItems;
short iNumMapHazards;
short iNumMapItems = 0;
short iNumMapHazards = 0;

short iNumRaceGoals;
short iNumFlagBases;
short iNumRaceGoals = 0;
short iNumFlagBases = 0;


private:
Expand All @@ -317,8 +317,8 @@ class CMap

std::vector<AnimatedTile*> animatedtiles;

MovingPlatform ** platforms;
short iNumPlatforms;
MovingPlatform ** platforms = nullptr;
short iNumPlatforms = 0;

std::list<MovingPlatform*> tempPlatforms;

Expand All @@ -330,17 +330,17 @@ class CMap
short totalspawnsize[NUMSPAWNAREATYPES];

Warp warpdata[MAPWIDTH][MAPHEIGHT];
short numwarpexits; //number of warp exits
short numwarpexits = 0; //number of warp exits
WarpExit warpexits[MAXWARPS];
short warplocktimer[10];
bool warplocked[10];
short maxConnection;
short maxConnection = 0;

SDL_Rect tilebltrect;
SDL_Rect bltrect;

SDL_Rect drawareas[MAXDRAWAREAS];
short numdrawareas;
short numdrawareas = 0;

short iSwitches[4];
std::list<IO_Block*> switchBlocks[8];
Expand All @@ -351,17 +351,16 @@ class CMap

Point flagbaselocations[4];

short iTileAnimationTimer;
short iTileAnimationFrame;
short iTileAnimationTimer = 0;
short iTileAnimationFrame = 0;

short iAnimatedBackgroundLayers;
SDL_Surface * animatedFrontmapSurface;
SDL_Surface * animatedBackmapSurface;
short iAnimatedBackgroundLayers = 0;
SDL_Surface * animatedFrontmapSurface = nullptr;
SDL_Surface * animatedTilesSurface = nullptr;

SDL_Surface * animatedTilesSurface;

short iAnimatedTileCount;
short iAnimatedTileCount = 0;
short iAnimatedVectorIndices[NUM_FRAMES_BETWEEN_TILE_ANIMATION + 1];
SDL_Surface * animatedBackmapSurface = nullptr;

std::list<MovingPlatform*> platformdrawlayer[5];

Expand Down
10 changes: 2 additions & 8 deletions src/leveleditor/leveleditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ int main(int argc, char *argv[])
if (cmd.debug) {
cmd::show_windows_console();
}
if (!cmd.data_root.empty())
if (!cmd.data_root.empty()) {
RootDataDirectory = cmd.data_root;

}

smw = new CGame(RootDataDirectory.c_str());
rm = new CResourceManager();
Expand Down Expand Up @@ -869,12 +869,6 @@ int editor_edit()
if (fExiting) {
//handle messages
while (SDL_PollEvent(&event)) {
#if defined(USE_SDL2) || defined(__EMSCRIPTEN__)
const Uint8 * keystate = SDL_GetKeyboardState(NULL);
#else
Uint8 * keystate = SDL_GetKeyState(NULL);
#endif

switch (event.type) {
case SDL_KEYDOWN: {
#ifdef USE_SDL2
Expand Down
3 changes: 2 additions & 1 deletion src/smw/GSSplashScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ void SplashScreenState::update()

#ifndef _XBOX
case SDLK_F4:
if (loop_event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))
if (loop_event.key.keysym.mod & (KMOD_LALT | KMOD_RALT)) {
game_values.gamestate = GS_QUIT;
return;
}
break;

case SDLK_INSERT:
Expand Down
1 change: 0 additions & 1 deletion src/smw/gamemodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,6 @@ void CGM_ShyGuyTag::think()
//Award points to non shyguys
if (shyguycount > 0) {
if (++scorecounter >= game_values.pointspeed) {
bool playwarning = false;
scorecounter = 0;

CPlayer * pCheckWinner = NULL;
Expand Down
18 changes: 5 additions & 13 deletions src/smw/objectgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,10 +1365,11 @@ void MO_SuperFireball::update()
setXf(fx + velx);
setYf(fy + vely);

if (ix < 0)
if (ix < 0) {
setXi(ix + smw->ScreenWidth);
else if (ix > smw->ScreenWidth - 1)
} else if (ix > smw->ScreenWidth - 1) {
setXi(ix - smw->ScreenWidth);
}

if (iy > smw->ScreenHeight|| iy < -ih || --ttl <= 0)
removeifprojectile(this, false, true);
Expand Down Expand Up @@ -5998,18 +5999,9 @@ bool CO_ThrowBox::collide(CPlayer * player)
return false;
}

if (HasKillVelocity()) {
short flipx = 0;

if (player->ix + PW < 320 && ix > 320)
flipx = smw->ScreenWidth;
else if (ix + iw < 320 && player->ix > 320)
flipx = -smw->ScreenWidth;
if (HasKillVelocity() && player->globalID != iPlayerID)
return KillPlayer(player);

if (player->globalID != iPlayerID) {
return KillPlayer(player);
}
}
/*
//Kill player when another player is holding the box
else
Expand Down
7 changes: 1 addition & 6 deletions src/smw/objects/MysteryMushroomTempPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ class MysteryMushroomTempPlayer
float fOldX, fOldY;
float velx, vely;

bool bobomb;
short powerup;

short burnupstarttimer, burnuptimer;

bool inair, onice, invincible;
short invincibletimer;
bool inair, onice;

MovingPlatform * platform;

short iCapeFrameX, iCapeFrameY, iCapeTimer, iCapeYOffset;
short gamepowerup;

short iOldPowerupX, iOldPowerupY;
Expand Down
1 change: 0 additions & 1 deletion src/smw/objects/moving/IceBlast.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class MO_IceBlast : public IO_MovingObject
void draw();

private:
short colorOffset;
short ttl;
Spotlight * sSpotlight;
};
Expand Down
1 change: 0 additions & 1 deletion src/smw/objects/moving/SledgeHammer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class MO_SledgeHammer : public IO_MovingObject
short colorOffset;

private:
short ttl;
bool fSuper;
};

Expand Down
5 changes: 1 addition & 4 deletions src/smw/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1857,11 +1857,8 @@ short CPlayer::KilledPlayer(CPlayer * killed, short deathstyle, killstyle style,
if (killed->state != player_ready)
return player_kill_none;

bool fSoundPlayed = false;
if (game_values.gamemode->chicken == killer && style != kill_style_pow) {
if (game_values.gamemode->chicken == killer && style != kill_style_pow)
ifSoundOnPlay(rm->sfx_chicken);
fSoundPlayed = true;
}

if (killed->frozen)
deathstyle = death_style_shatter;
Expand Down
6 changes: 2 additions & 4 deletions src/smw/uicustomcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1866,10 +1866,8 @@ MI_BonusWheel::~MI_BonusWheel()
{
delete miContinueButton;

if (miBonusImages) {
for (int iImage = 0; iImage < NUMBONUSITEMSONWHEEL; iImage++)
delete miBonusImages[iImage];
}
for (int iImage = 0; iImage < NUMBONUSITEMSONWHEEL; iImage++)
delete miBonusImages[iImage];

if (miPlayerImages) {
for (int iPlayer = 0; iPlayer < iNumPlayers; iPlayer++)
Expand Down
1 change: 0 additions & 1 deletion src/smw/uicustomcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ class MI_World : public UI_Control
void UseCloud(bool fUseCloud);

short iState;
bool fItemPopup;
short iStateTransition[4];
short iItemPopupDrawY[4];
short iPopupOffsets[4];
Expand Down
6 changes: 0 additions & 6 deletions src/worldeditor/worldeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,12 +1070,6 @@ int editor_edit()
if (fExiting) {
//handle messages
while (SDL_PollEvent(&event)) {
#if defined(USE_SDL2) || defined(__EMSCRIPTEN__)
const Uint8 * keystate = SDL_GetKeyboardState(NULL);
#else
Uint8 * keystate = SDL_GetKeyState(NULL);
#endif

switch (event.type) {
case SDL_KEYDOWN: {
#ifdef USE_SDL2
Expand Down

0 comments on commit d853a9e

Please sign in to comment.