diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp index 57e42d5..b652ebb 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp @@ -252,8 +252,8 @@ bool BlockGame::GetIsWinner() const { } -void BlockGame::NewGame(const BlockGameStartInfo &s) { - NewGame(s.ticks); +void BlockGame::NewGame(const BlockGameStartInfo& s) { + NewGame(s.ticks); if (s.timeTrial) { timetrial = true; putStartBlocks(); diff --git a/source/code/DialogBox.cpp b/source/code/DialogBox.cpp index eca6525..294a336 100644 --- a/source/code/DialogBox.cpp +++ b/source/code/DialogBox.cpp @@ -67,7 +67,7 @@ void DialogBox::Draw(SDL_Renderer* target) { } } -void DialogBox::ProcessInput(const SDL_Event& event, bool &processed) { +void DialogBox::ProcessInput(const SDL_Event& event, bool& processed) { if (event.type == SDL_TEXTINPUT) { if ((rk->ReadKey(event))&&(SoundEnabled)&&(!NoSound)) { Mix_PlayChannel(1, typingChunk, 0); diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp index 479e1ca..bf81178 100644 --- a/source/code/MenuSystem.cpp +++ b/source/code/MenuSystem.cpp @@ -281,25 +281,25 @@ void Menu::run() { Config::getInstance()->setShuttingDown(5); running = false; } - + if (isUpEvent(event)) { marked--; if (marked<0) { marked = buttons.size(); //not -1, since exit is after the last element in the list } } - + if (isDownEvent(event)) { marked++; if (marked> (int)buttons.size()) { marked = 0; } } - + if (isEscapeEvent(event) && isSubmenu) { running = false; } - + if (isConfirmEvent(event)) { if (marked < (int)buttons.size()) { buttons.at(marked)->doAction(); diff --git a/source/code/ScoresDisplay.cpp b/source/code/ScoresDisplay.cpp index 5043f2d..5156ebc 100644 --- a/source/code/ScoresDisplay.cpp +++ b/source/code/ScoresDisplay.cpp @@ -160,7 +160,7 @@ void ScoresDisplay::Draw(SDL_Renderer* target) { } void ScoresDisplay::ProcessInput(const SDL_Event& event, bool& processed) { - + if (isLeftEvent(event)) { page++; if (page>=numberOfPages) { diff --git a/source/code/gamecontroller.cpp b/source/code/gamecontroller.cpp index 1162d0d..c1f38f7 100644 --- a/source/code/gamecontroller.cpp +++ b/source/code/gamecontroller.cpp @@ -27,7 +27,7 @@ http://www.blockattack.net void InitGameControllers() { std::cout << "Number of Game controllers: " << SDL_NumJoysticks() << std::endl; - SDL_GameController *controller = nullptr; + SDL_GameController* controller = nullptr; for (int i = 0; i < SDL_NumJoysticks(); ++i) { if (SDL_IsGameController(i)) { controller = SDL_GameControllerOpen(i); diff --git a/source/code/highscore.cpp b/source/code/highscore.cpp index 96c06df..d7d7ffc 100644 --- a/source/code/highscore.cpp +++ b/source/code/highscore.cpp @@ -28,17 +28,17 @@ http://www.blockattack.net #include "cereal/types/vector.hpp" #include "cereal/archives/json.hpp" #include "sago/SagoMisc.hpp" -#include +#include namespace cereal { - + template -void save(Archive & archive, record const & m) { +void save(Archive& archive, record const& m) { archive( cereal::make_nvp("Name", m.name), cereal::make_nvp("Score", m.score) ); } template -void load(Archive & archive, record & m) { +void load(Archive& archive, record& m) { archive( cereal::make_nvp("Name", m.name), cereal::make_nvp("Score", m.score) ); } @@ -47,7 +47,9 @@ void load(Archive & archive, record & m) { /* This sorts in reverse order. So the highest will be first */ -bool record_sorter (const record& i,const record& j) { return (i.score > j.score); } +bool record_sorter (const record& i,const record& j) { + return (i.score > j.score); +} Highscore::Highscore(const std::string& type) { this->type = type; @@ -61,9 +63,9 @@ Highscore::Highscore(const std::string& type) { archive(cereal::make_nvp("highscore", table)); } } - catch (cereal::Exception &e) { + catch (cereal::Exception& e) { std::cerr << "Failed to read highscore " << filename << " due to formatting errors. Resetting the file. Reason: " << - e.what() << std::endl; + e.what() << std::endl; table.clear(); } } @@ -111,7 +113,7 @@ void Highscore::addScore(const std::string& newName, int newScore) { record Highscore::getScoreNumber(int room) { record ret; - if(room < static_cast(table.size()) ) { + if (room < static_cast(table.size()) ) { ret = table.at(room); } return ret; diff --git a/source/code/main.cpp b/source/code/main.cpp index 17b100c..1f89d68 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -1179,7 +1179,7 @@ void DrawEverything(int xsize, int ysize,BlockGameSdl* theGame, BlockGameSdl* th strHolder = itoa(theGame2->GetSpeedLevel()); NFont_Write(screen, theGame2->GetTopX()+310,theGame2->GetTopY()+250,strHolder.c_str()); //draw exit - bExit.Draw(screen,SDL_GetTicks(), xsize-bExitOffset, ysize-bExitOffset); + bExit.Draw(screen,SDL_GetTicks(), xsize-bExitOffset, ysize-bExitOffset); } //player2 finnish @@ -1562,7 +1562,7 @@ int main(int argc, char* argv[]) { } if (SDL_Init(SDL_INIT_GAMECONTROLLER ) != 0) { cerr << "Warning: Game controller failed to initialize. Reason: " << SDL_GetError() << endl; - } + } InitGameControllers(); TTF_Init(); atexit(SDL_Quit); //quits SDL when the game stops for some reason (like you hit exit or Esc) @@ -1782,8 +1782,8 @@ int main(int argc, char* argv[]) { Stats::getInstance()->save(); Config::getInstance()->save(); - - + + } catch (exception& e) { @@ -1922,7 +1922,7 @@ int runGame(int gametype, int level) { Config::getInstance()->setShuttingDown(5); done = 1; } - + if (theGame.isGameOver() && isEscapeEvent(event)) { done = 1; } @@ -2003,7 +2003,7 @@ int runGame(int gametype, int level) { done=1; } } - + if (isPlayerUpEvent(1, event)) { theGame.MoveCursor('N'); } @@ -2124,7 +2124,7 @@ int runGame(int gametype, int level) { &&(mousey > theGame.GetTopY()+cordNextButton.y)&&(mousey < theGame.GetTopY()+cordNextButton.y+cordNextButton.ysize)) { //Clicked the next button after a stage clear or puzzle nextLevel(theGame, SDL_GetTicks()); - + } if (stageButtonStatus != SBdontShow && (mousex > theGame.GetTopX()+cordRetryButton .x) &&(mousex < theGame.GetTopX()+cordRetryButton.x+cordRetryButton.xsize) @@ -2133,8 +2133,8 @@ int runGame(int gametype, int level) { retryLevel(theGame, SDL_GetTicks()); } - if (mousex > xsize-bExitOffset && mousex < xsize-bExitOffset+bExitSize && - mousey > ysize-bExitOffset && mousey < ysize-bExitOffset+bExitSize) { + if (mousex > xsize-bExitOffset && mousex < xsize-bExitOffset+bExitSize && + mousey > ysize-bExitOffset && mousey < ysize-bExitOffset+bExitSize) { done = 1; } //cout << "Mouse x: " << mousex << ", mouse y: " << mousey << endl; diff --git a/source/code/puzzlehandler.cpp b/source/code/puzzlehandler.cpp index 9fa815d..00c4916 100644 --- a/source/code/puzzlehandler.cpp +++ b/source/code/puzzlehandler.cpp @@ -77,7 +77,7 @@ void LoadClearData() { cereal::JSONInputArchive archive(ss); archive(cereal::make_nvp("cleared", puzzleCleared)); } - catch (cereal::Exception &e) { + catch (cereal::Exception& e) { std::cerr << "Failed to read \"" << puzzleSavePath << "\". File will be regenerated. Reason: " << e.what() << std::endl; puzzleCleared.clear(); } diff --git a/source/code/stageclearhandler.cpp b/source/code/stageclearhandler.cpp index 53fac6c..b48903f 100644 --- a/source/code/stageclearhandler.cpp +++ b/source/code/stageclearhandler.cpp @@ -39,11 +39,10 @@ struct StageClearElement { bool cleared = false; int time = 0; int score = 0; - + template - void serialize(Archive & archive) - { - archive( cereal::make_nvp("cleared", cleared), cereal::make_nvp("time", time), cereal::make_nvp("score", score) ); + void serialize(Archive& archive) { + archive( cereal::make_nvp("cleared", cleared), cereal::make_nvp("time", time), cereal::make_nvp("score", score) ); } }; @@ -56,7 +55,7 @@ Sint32 totalScore = 0; Sint32 totalTime = 0; using namespace std; - + static void SaveStageClearStages() { std::stringstream ss; { @@ -67,7 +66,7 @@ static void SaveStageClearStages() { } void StageClearSetClear(int Level, int score, int time) { - + stages.at(Level).cleared = true; int gameEndedAfter = time; if (stages.at(Level).score